2022-09-28 22:37:15 -06:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
2023-08-08 07:12:47 -06:00
|
|
|
set -xe
|
2022-10-10 12:12:19 -06:00
|
|
|
|
2022-09-28 22:37:15 -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"
|
2022-09-28 22:37:15 -06:00
|
|
|
CURRENT_FILE=${1:-/tmp/openbsd_app/current/share/sqlports}
|
|
|
|
STABLE_FILE=${2:-/tmp/openbsd_app/stable/share/sqlports}
|
2023-08-08 07:12:47 -06:00
|
|
|
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)
|
2022-09-28 22:37:15 -06:00
|
|
|
|
|
|
|
(
|
|
|
|
cd /tmp/openbsd_app/current
|
2023-08-17 09:06:15 -06:00
|
|
|
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
|
2023-08-17 09:06:15 -06:00
|
|
|
${SIGNIFY} -C -p ${CURRENT_PUB} -x SHA256.sig sqlports-${CURRENT_VER}.tgz
|
|
|
|
tar -C . -zxvf sqlports-${CURRENT_VER}.tgz
|
2022-09-28 22:37:15 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
(
|
|
|
|
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
|
2023-08-17 09:06:15 -06:00
|
|
|
${SIGNIFY} -C -p ${STABLE_PUB} -x SHA256.sig sqlports-${STABLE_VER}.tgz
|
|
|
|
tar -C . -zxvf sqlports-${STABLE_VER}.tgz
|
2022-09-28 22:37:15 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
SQL=$(cat <<EOF
|
|
|
|
ATTACH DATABASE '%s' AS ports;
|
|
|
|
|
|
|
|
CREATE VIRTUAL TABLE
|
|
|
|
%s
|
|
|
|
USING fts5(
|
|
|
|
FULLPKGNAME,
|
|
|
|
FULLPKGPATH,
|
|
|
|
COMMENT,
|
2023-08-08 07:12:47 -06:00
|
|
|
DESCRIPTION,
|
|
|
|
HOMEPAGE);
|
2022-09-28 22:37:15 -06:00
|
|
|
|
|
|
|
INSERT INTO
|
|
|
|
%s
|
2023-08-08 07:12:47 -06:00
|
|
|
(FULLPKGNAME, FULLPKGPATH, COMMENT, DESCRIPTION, HOMEPAGE)
|
2022-09-28 22:37:15 -06:00
|
|
|
SELECT
|
|
|
|
fullpkgname,
|
|
|
|
_paths.fullpkgpath,
|
|
|
|
comment,
|
2023-08-08 07:12:47 -06:00
|
|
|
_descr.value,
|
|
|
|
homepage
|
2022-09-28 22:37:15 -06:00
|
|
|
FROM
|
|
|
|
ports._ports
|
|
|
|
JOIN _paths ON _paths.id=_ports.fullpkgpath
|
|
|
|
JOIN _descr ON _descr.fullpkgpath=_ports.fullpkgpath;
|
|
|
|
|
|
|
|
EOF
|
|
|
|
)
|
|
|
|
|
2023-08-08 07:12:47 -06:00
|
|
|
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
|