vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Add a one-command install script for the stable channel
16a8be36308947758ae81c97500f9f891be18e52 · Keenan Nemetz · 13d ago · parent 1b1571bb
Add a one-command install script for the stable channel The signed package repositories still left a four- or five-command trust bootstrap on first install, because apt cannot fetch a key from a URL and pacman requires an explicit keyring signature. Ship packaging/install.sh as a release artifact served at channels/stable/install.sh: it detects the distribution, writes the key and repository, and hands the install to apt, dnf, or pacman. The script pins the release key's SHA-256 and fingerprint, and the release now publishes the committed key verbatim so the pin is exact. scripts/check-install.sh covers the three families without root or network, and the release attaches the script before SHA256SUMS so the checksum list covers it. closes: 01M7XG0ANWCC442YMFJSMW7HCC
scripts/check-install.sh +167
| @@ -0,0 +1,167 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Check the one-command installer without a package manager. | ||
| 3 | # | ||
| 4 | # The script pins the release key's SHA-256 and fingerprint, so this check fails | ||
| 5 | # when either constant disagrees with packaging/keys/vole-release.asc. It then | ||
| 6 | # runs install.sh against temporary roots for the three supported families and | ||
| 7 | # asserts the files it writes, that a second run changes nothing, and that bad | ||
| 8 | # input is refused. No network, root, or package manager is needed: the key is | ||
| 9 | # supplied with --key and --root implies --repo-only. | ||
| 10 | set -eu | ||
| 11 | |||
| 12 | ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) | ||
| 13 | cd "$ROOT" | ||
| 14 | |||
| 15 | tmp=$(mktemp -d) | ||
| 16 | trap 'rm -rf "$tmp"' 0 | ||
| 17 | |||
| 18 | fail() { | ||
| 19 | printf 'check-install: %s\n' "$*" >&2 | ||
| 20 | exit 1 | ||
| 21 | } | ||
| 22 | |||
| 23 | note() { | ||
| 24 | printf 'check-install: %s\n' "$*" | ||
| 25 | } | ||
| 26 | |||
| 27 | sha256() { | ||
| 28 | if command -v sha256sum >/dev/null 2>&1; then | ||
| 29 | sha256sum "$1" | awk '{print $1}' | ||
| 30 | elif command -v shasum >/dev/null 2>&1; then | ||
| 31 | shasum -a 256 "$1" | awk '{print $1}' | ||
| 32 | else | ||
| 33 | fail "sha256sum or shasum is required" | ||
| 34 | fi | ||
| 35 | } | ||
| 36 | |||
| 37 | [ -f packaging/install.sh ] || fail "packaging/install.sh is missing" | ||
| 38 | [ -x packaging/install.sh ] || fail "packaging/install.sh is not executable" | ||
| 39 | [ -f packaging/keys/vole-release.asc ] || fail "packaging/keys/vole-release.asc is missing" | ||
| 40 | |||
| 41 | sh -n packaging/install.sh || fail "packaging/install.sh has a syntax error" | ||
| 42 | |||
| 43 | pinned_sha=$(sed -n 's/^VOLE_KEY_SHA256=//p' packaging/install.sh) | ||
| 44 | pinned_fpr=$(sed -n 's/^VOLE_KEY_FPR=//p' packaging/install.sh) | ||
| 45 | [ -n "$pinned_sha" ] || fail "VOLE_KEY_SHA256 is missing from packaging/install.sh" | ||
| 46 | [ -n "$pinned_fpr" ] || fail "VOLE_KEY_FPR is missing from packaging/install.sh" | ||
| 47 | |||
| 48 | actual_sha=$(sha256 packaging/keys/vole-release.asc) | ||
| 49 | [ "$pinned_sha" = "$actual_sha" ] || | ||
| 50 | fail "VOLE_KEY_SHA256 ($pinned_sha) does not match packaging/keys/vole-release.asc ($actual_sha)" | ||
| 51 | |||
| 52 | if command -v gpg >/dev/null 2>&1; then | ||
| 53 | actual_fpr=$(gpg --batch --with-colons --import-options show-only \ | ||
| 54 | --import packaging/keys/vole-release.asc 2>/dev/null | | ||
| 55 | awk -F: '$1 == "fpr" {print $10; exit}') | ||
| 56 | [ "$pinned_fpr" = "$actual_fpr" ] || | ||
| 57 | fail "VOLE_KEY_FPR ($pinned_fpr) does not match packaging/keys/vole-release.asc (${actual_fpr:-none})" | ||
| 58 | fi | ||
| 59 | |||
| 60 | make_root() { # name ID ID_LIKE | ||
| 61 | root="$tmp/$1" | ||
| 62 | mkdir -p "$root/etc" | ||
| 63 | { | ||
| 64 | printf 'ID=%s\n' "$2" | ||
| 65 | if [ -n "${3:-}" ]; then | ||
| 66 | printf 'ID_LIKE="%s"\n' "$3" | ||
| 67 | fi | ||
| 68 | } >"$root/etc/os-release" | ||
| 69 | printf '%s\n' "$root" | ||
| 70 | } | ||
| 71 | |||
| 72 | run_install() { # root [extra arguments...] | ||
| 73 | root=$1 | ||
| 74 | shift | ||
| 75 | sh packaging/install.sh --root "$root" --key packaging/keys/vole-release.asc \ | ||
| 76 | --repo-only --yes "$@" >/dev/null | ||
| 77 | } | ||
| 78 | |||
| 79 | # Debian and Ubuntu use a signed-by keyring and a one-line source. | ||
| 80 | debian=$(make_root debian debian "") | ||
| 81 | run_install "$debian" | ||
| 82 | [ -f "$debian/etc/apt/keyrings/vole.asc" ] || fail "apt: keyring was not written" | ||
| 83 | [ -f "$debian/etc/apt/sources.list.d/vole.list" ] || fail "apt: source list was not written" | ||
| 84 | grep -q 'signed-by=/etc/apt/keyrings/vole.asc' "$debian/etc/apt/sources.list.d/vole.list" || | ||
| 85 | fail "apt: source list does not name the keyring" | ||
| 86 | grep -q '/channels/stable/apt \./' "$debian/etc/apt/sources.list.d/vole.list" || | ||
| 87 | fail "apt: source list does not name the stable apt tree" | ||
| 88 | run_install "$debian" | ||
| 89 | [ "$(wc -l <"$debian/etc/apt/sources.list.d/vole.list")" -eq 1 ] || | ||
| 90 | fail "apt: a second run rewrote the source list more than once" | ||
| 91 | |||
| 92 | ubuntu=$(make_root ubuntu ubuntu "debian") | ||
| 93 | run_install "$ubuntu" | ||
| 94 | [ -f "$ubuntu/etc/apt/sources.list.d/vole.list" ] || fail "ubuntu: apt was not detected from ID_LIKE" | ||
| 95 | |||
| 96 | # Fedora and its derivatives use an RPM repository file with both checks on. | ||
| 97 | fedora=$(make_root fedora fedora "") | ||
| 98 | run_install "$fedora" | ||
| 99 | repo="$fedora/etc/yum.repos.d/vole.repo" | ||
| 100 | [ -f "$repo" ] || fail "dnf: repository file was not written" | ||
| 101 | [ -f "$fedora/etc/pki/rpm-gpg/RPM-GPG-KEY-vole" ] || fail "dnf: key was not written" | ||
| 102 | grep -q '^baseurl=.*/channels/stable/yum/$' "$repo" || fail "dnf: baseurl is wrong" | ||
| 103 | grep -q '^gpgcheck=1$' "$repo" || fail "dnf: gpgcheck is not enabled" | ||
| 104 | grep -q '^repo_gpgcheck=1$' "$repo" || fail "dnf: repo_gpgcheck is not enabled" | ||
| 105 | grep -q '^gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-vole$' "$repo" || fail "dnf: gpgkey is wrong" | ||
| 106 | run_install "$fedora" | ||
| 107 | |||
| 108 | rocky=$(make_root rocky rocky "rhel centos fedora") | ||
| 109 | run_install "$rocky" | ||
| 110 | [ -f "$rocky/etc/yum.repos.d/vole.repo" ] || fail "rocky: dnf was not detected from ID_LIKE" | ||
| 111 | |||
| 112 | # Arch reads a section in pacman.conf and a keyring that was marked trusted. | ||
| 113 | arch=$(make_root arch arch "") | ||
| 114 | run_install "$arch" | ||
| 115 | conf="$arch/etc/pacman.conf" | ||
| 116 | [ -f "$conf" ] || fail "pacman: pacman.conf was not written" | ||
| 117 | grep -q '^\[vole\]$' "$conf" || fail "pacman: repository section is missing" | ||
| 118 | grep -Fq 'Server = https://rodent.software/vole/channels/stable/pacman/$arch' "$conf" || | ||
| 119 | fail "pacman: Server line is wrong" | ||
| 120 | grep -q '^SigLevel = Required DatabaseRequired$' "$conf" || fail "pacman: SigLevel is wrong" | ||
| 121 | run_install "$arch" | ||
| 122 | [ "$(grep -c '^\[vole\]$' "$conf" || true)" -eq 1 ] || | ||
| 123 | fail "pacman: a second run duplicated the repository section" | ||
| 124 | |||
| 125 | # --version replaces the channel with one release's artifact tree. | ||
| 126 | pinned=$(make_root pinned debian "") | ||
| 127 | run_install "$pinned" --version v0.2.0 | ||
| 128 | grep -q '/releases/v0.2.0/artifacts/apt \./' "$pinned/etc/apt/sources.list.d/vole.list" || | ||
| 129 | fail "version: the pinned apt tree is wrong" | ||
| 130 | |||
| 131 | # --dry-run works without root and writes nothing. | ||
| 132 | plan=$(sh packaging/install.sh --dry-run) | ||
| 133 | printf '%s\n' "$plan" | grep -q 'would run:' || fail "dry-run: no install command in the plan" | ||
| 134 | printf '%s\n' "$plan" | grep -q 'detected ' || fail "dry-run: no detected distribution in the plan" | ||
| 135 | printf '%s\n' "$plan" | grep -q 'would follow channel stable' || | ||
| 136 | fail "dry-run: no channel in the plan" | ||
| 137 | |||
| 138 | plan=$(sh packaging/install.sh --dry-run --version v0.2.0) | ||
| 139 | printf '%s\n' "$plan" | grep -q 'would install release v0.2.0' || | ||
| 140 | fail "dry-run: the pinned release was not reported" | ||
| 141 | |||
| 142 | # A key that is not the release key is refused before anything is written. | ||
| 143 | bad=$(make_root bad debian "") | ||
| 144 | : >"$tmp/wrong-key.asc" | ||
| 145 | if sh packaging/install.sh --root "$bad" --key "$tmp/wrong-key.asc" --repo-only \ | ||
| 146 | >"$tmp/wrong-key.log" 2>&1; then | ||
| 147 | fail "an empty key was accepted" | ||
| 148 | fi | ||
| 149 | grep -q 'checksum mismatch' "$tmp/wrong-key.log" || fail "a bad key did not report a checksum mismatch" | ||
| 150 | [ ! -e "$bad/etc/apt" ] || fail "a bad key still wrote apt configuration" | ||
| 151 | |||
| 152 | # Unsupported distributions and invalid options fail with a clear message. | ||
| 153 | other=$(make_root other gentoo "") | ||
| 154 | if sh packaging/install.sh --root "$other" --key packaging/keys/vole-release.asc \ | ||
| 155 | --repo-only >"$tmp/other.log" 2>&1; then | ||
| 156 | fail "an unsupported distribution was accepted" | ||
| 157 | fi | ||
| 158 | grep -q 'unsupported distribution' "$tmp/other.log" || fail "an unsupported distribution did not say so" | ||
| 159 | |||
| 160 | if sh packaging/install.sh --dry-run --channel '../bad' >"$tmp/channel.log" 2>&1; then | ||
| 161 | fail "an invalid channel name was accepted" | ||
| 162 | fi | ||
| 163 | grep -q 'invalid channel name' "$tmp/channel.log" || fail "an invalid channel name did not say so" | ||
| 164 | |||
| 165 | sh packaging/install.sh --help >/dev/null || fail "--help failed" | ||
| 166 | |||
| 167 | note "install script checks passed" | ||