-
Notifications
You must be signed in to change notification settings - Fork 2
/
upgrade.sh
executable file
·77 lines (67 loc) · 2.06 KB
/
upgrade.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env sh
set -xe
mkdir -p /tmp/openbsd_app/{stable,current}
CURRENT_VER="7.52"
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}"
CURRENT_PUB=$(readlink -f /etc/signify/openbsd-76-pkg.pub)
STABLE_PUB=$(readlink -f /etc/signify/openbsd-76-pkg.pub)
(
cd /tmp/openbsd_app/current
curl -L -O https://cdn.openbsd.org/pub/OpenBSD/snapshots/packages/amd64/sqlports-${CURRENT_VER}.tgz
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
curl -L -O https://cdn.openbsd.org/pub/OpenBSD/7.6/packages/amd64/sqlports-${STABLE_VER}.tgz
curl -L -O https://cdn.openbsd.org/pub/OpenBSD/7.6/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