Repository navigation
Expand file tree
/
Copy pathassemble.sh
More file actions
executable file
·77 lines (67 loc) · 2.18 KB
/
Copy pathassemble.sh
File metadata and controls
executable file
·77 lines (67 loc) · 2.18 KB
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
#!/bin/bash
set -e
# This script runs on the HOST (the CI assemble job).
# It builds the final repository database from the package files in repo/:
# the build matrix jobs upload bare package files, and this isolated step signs
# them and turns them into the published repository. It never mounts or runs a
# PKGBUILD or package build directory.
KEYRING_DIR="packages/instantos-keyring"
if [ -s "$KEYRING_DIR/instantos.gpg" ] && [ -s "$KEYRING_DIR/instantos-trusted" ]; then
has_keyring=true
else
has_keyring=false
fi
if $has_keyring && [ -z "${GPG_PRIVATE_KEY:-}" ]; then
echo "ERROR: $KEYRING_DIR contains key material but GPG_PRIVATE_KEY is not set." >&2
exit 1
fi
if [ -n "${GPG_PRIVATE_KEY:-}" ] && ! $has_keyring; then
echo "ERROR: GPG_PRIVATE_KEY is set but $KEYRING_DIR has no key material." >&2
exit 1
fi
if [ -n "${GPG_PRIVATE_KEY:-}" ] && [ -z "${GPG_KEYID:-}" ]; then
echo "ERROR: GPG_PRIVATE_KEY is set but GPG_KEYID (signing subkey id) is not." >&2
exit 1
fi
mkdir -p repo
if ! ls repo/*.pkg.tar.zst >/dev/null 2>&1; then
echo "ERROR: no packages found in repo/" >&2
exit 1
fi
echo "Creating assembler image..."
docker build -q -t instantos-assembler - <<EOF
FROM archlinux:base-devel
RUN pacman -Syu --noconfirm --needed gnupg
EOF
if [ -n "${GPG_PRIVATE_KEY:-}" ]; then
docker run --rm \
--network none \
-e GPG_PRIVATE_KEY \
-e GPG_KEYID \
-e HOST_UID="$(id -u)" \
-e HOST_GID="$(id -g)" \
-v "$(pwd)/repo:/repo" \
instantos-assembler bash -c '
set -e
printf "%s" "$GPG_PRIVATE_KEY" | base64 -d | gpg --batch --import
for package in /repo/*.pkg.tar.zst; do
rm -f "$package.sig"
gpg --batch --yes --local-user "$GPG_KEYID" --detach-sign "$package"
done
repo-add --sign --key "$GPG_KEYID" /repo/instant.db.tar.gz /repo/*.pkg.tar.zst
chown -R "$HOST_UID:$HOST_GID" /repo
'
else
docker run --rm \
--network none \
-e HOST_UID="$(id -u)" \
-e HOST_GID="$(id -g)" \
-v "$(pwd)/repo:/repo" \
instantos-assembler bash -c '
set -e
repo-add /repo/instant.db.tar.gz /repo/*.pkg.tar.zst
chown -R "$HOST_UID:$HOST_GID" /repo
'
fi
echo "Repository assembled:"
ls -la repo/