openbsd.app/upgrade.sh

78 lines
2.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env sh
set -xe
2022-10-10 12:12:19 -06:00
mkdir -p /tmp/openbsd_app/{stable,current}
2023-12-04 12:05:05 -07:00
CURRENT_VER="7.52"
2024-04-05 09:14:13 -06:00
STABLE_VER="7.52"
CURRENT_FILE=${1:-/tmp/openbsd_app/current/share/sqlports}
STABLE_FILE=${2:-/tmp/openbsd_app/stable/share/sqlports}
SIGNIFY="${SIGNIFY:-signify}"
2024-03-07 07:06:32 -07:00
CURRENT_PUB=$(readlink -f /etc/signify/openbsd-75-pkg.pub)
2024-04-05 09:14:13 -06:00
STABLE_PUB=$(readlink -f /etc/signify/openbsd-75-pkg.pub)
(
cd /tmp/openbsd_app/current
curl -L -O https://cdn.openbsd.org/pub/OpenBSD/snapshots/packages/amd64/sqlports-${CURRENT_VER}.tgz
2022-10-10 12:12:19 -06:00
curl -L -O https://cdn.openbsd.org/pub/OpenBSD/snapshots/packages/amd64/SHA256.sig
${SIGNIFY} -C -p ${CURRENT_PUB} -x SHA256.sig sqlports-${CURRENT_VER}.tgz
tar -C . -zxvf sqlports-${CURRENT_VER}.tgz
)
(
cd /tmp/openbsd_app/stable
2024-04-05 09:14:13 -06:00
curl -L -O https://cdn.openbsd.org/pub/OpenBSD/7.5/packages/amd64/sqlports-${STABLE_VER}.tgz
curl -L -O https://cdn.openbsd.org/pub/OpenBSD/7.5/packages/amd64/SHA256.sig
${SIGNIFY} -C -p ${STABLE_PUB} -x SHA256.sig sqlports-${STABLE_VER}.tgz
tar -C . -zxvf sqlports-${STABLE_VER}.tgz
)
SQL=$(cat <<EOF
ATTACH DATABASE '%s' AS ports;
CREATE VIRTUAL TABLE
%s
USING fts5(
FULLPKGNAME,
FULLPKGPATH,
COMMENT,
DESCRIPTION,
HOMEPAGE);
INSERT INTO
%s
(FULLPKGNAME, FULLPKGPATH, COMMENT, DESCRIPTION, HOMEPAGE)
SELECT
fullpkgname,
_paths.fullpkgpath,
comment,
_descr.value,
homepage
FROM
ports._ports
JOIN _paths ON _paths.id=_ports.fullpkgpath
JOIN _descr ON _descr.fullpkgpath=_ports.fullpkgpath;
EOF
)
if [ -d ~/openbsd.app ]; then
rm -f ~/openbsd.app/combined.db
printf "$SQL\n" ${CURRENT_FILE} \
"current_ports_fts" \
"current_ports_fts" | sqlite3 ~/openbsd.app/combined.db
printf "$SQL\n" ${STABLE_FILE} \
"stable_ports_fts" \
"stable_ports_fts" | sqlite3 ~/openbsd.app/combined.db
else
# dev mode
rm -f ~/src/openbsd.app/combined.db
printf "$SQL\n" ${CURRENT_FILE} \
"current_ports_fts" \
"current_ports_fts" | sqlite3 ~/src/openbsd.app/combined.db
printf "$SQL\n" ${STABLE_FILE} \
"stable_ports_fts" \
"stable_ports_fts" | sqlite3 ~/src/openbsd.app/combined.db
fi