Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

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.

Install Vole on macOS from the install script

a4a6d1e9fadeb929dc7ace3728032e94eda1a7e2 · Keenan Nemetz · 12d ago · parent 629df77e

Install Vole on macOS from the install script

The script required /etc/os-release and stopped on macOS, which left macOS
instructions as a manual curl into ~/.local/bin. Once the release publishes
darwin binaries (#346) the script can install them: it maps uname's arm64 and
x86_64 to the asset names, installs into /usr/local/bin as root or ~/.local/bin
otherwise, and checks the download against the release's SHA256SUMS before
writing anything. --root installs under <root>/usr/local/bin, which is what an
image build or a test wants.

There is no package manager to defer to on macOS, so the script does the checking
itself. SHA256SUMS comes from the host that served the binary, so it
authenticates the transfer but not the release; the detached signature over that
list needs gpg, which a stock macOS does not ship, so the script says which check
it made and points at the documented signature steps.

It refuses when Homebrew already owns vole, because two copies shadow each other
in PATH order, and --repo-only is refused because there is no repository to
configure on macOS.

scripts/check-install.sh fakes uname, curl, and brew with fixtures, so both
architectures, a pinned --version, a mismatched checksum, --repo-only, an
unsupported operating system, a user install under $HOME, and the Homebrew
refusal all run on Linux CI. The Linux cases and their assertions are unchanged.

Closes: 01M7ZFNQYF4QAJK1B3ZQN16881

scripts/check-install.sh +141−4

@@ -3,10 +3,11 @@
3 3 #
4 4 # The script pins the release key's SHA-256 and fingerprint, so this check fails
5 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.
6 # runs install.sh against temporary roots for the three Linux families and for
7 # macOS, and asserts the files it writes, that a second run changes nothing, and
8 # that bad input is refused. No network, root, or package manager is needed: the
9 # key is supplied with --key, --root implies --repo-only, and the macOS case fakes
10 # uname, curl, and brew with fixtures under a temporary directory.
10 11 set -eu
11 12
12 13 ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
@@ -149,6 +150,142 @@ fi
149 150 grep -q 'checksum mismatch' "$tmp/wrong-key.log" || fail "a bad key did not report a checksum mismatch"
150 151 [ ! -e "$bad/etc/apt" ] || fail "a bad key still wrote apt configuration"
151 152
153 # macOS has no package manager, so the script installs the release binary itself
154 # after checking it against the release's SHA256SUMS. uname, curl and brew are
155 # faked from fixtures here, so the macOS path is exercised on Linux.
156 fakebin="$tmp/fakebin"
157 fixtures="$tmp/fixtures"
158 mkdir -p "$fakebin" "$fixtures"
159 cat >"$fakebin/uname" <<'EOF'
160 #!/bin/sh
161 case "$1" in
162 -m) printf '%s\n' "${FAKE_ARCH:-arm64}" ;;
163 -s) printf '%s\n' "${FAKE_OS:-Darwin}" ;;
164 *) exec /usr/bin/uname "$@" ;;
165 esac
166 EOF
167 cat >"$fakebin/curl" <<'EOF'
168 #!/bin/sh
169 out=
170 url=
171 while [ "$#" -gt 0 ]; do
172 case "$1" in
173 -o) out=$2; shift 2 ;;
174 --retry | --retry-delay) shift 2 ;;
175 -*) shift ;;
176 *) url=$1; shift ;;
177 esac
178 done
179 printf '%s\n' "$url" >>"$FAKE_LOG"
180 name=$(printf '%s' "$url" | sed 's|.*/||')
181 if [ -z "$out" ] || [ ! -f "$FAKE_FIXTURES/$name" ]; then
182 exit 22
183 fi
184 cp "$FAKE_FIXTURES/$name" "$out"
185 EOF
186 cat >"$fakebin/brew" <<'EOF'
187 #!/bin/sh
188 exit "${FAKE_BREW_STATUS:-1}"
189 EOF
190 chmod +x "$fakebin/uname" "$fakebin/curl" "$fakebin/brew"
191
192 printf '#!/bin/sh\necho 0.0.0\n' >"$fixtures/vole-darwin-arm64"
193 printf '#!/bin/sh\necho 0.0.0\n' >"$fixtures/vole-darwin-amd64"
194 {
195 printf '%s %s\n' "$(sha256 "$fixtures/vole-darwin-arm64")" vole-darwin-arm64
196 printf '%s %s\n' "$(sha256 "$fixtures/vole-darwin-amd64")" vole-darwin-amd64
197 } >"$fixtures/SHA256SUMS"
198
199 FAKE_LOG="$tmp/curl.log"
200 FAKE_FIXTURES="$fixtures"
201 export FAKE_LOG FAKE_FIXTURES
202 mac_path=$PATH
203 PATH="$fakebin:$PATH"
204
205 # An --root install puts the arm64 asset where the root says, unchanged.
206 : >"$tmp/curl.log"
207 sh packaging/install.sh --root "$tmp/mac" >/dev/null
208 [ -x "$tmp/mac/usr/local/bin/vole" ] || fail "macOS: the binary was not installed under --root"
209 cmp -s "$fixtures/vole-darwin-arm64" "$tmp/mac/usr/local/bin/vole" ||
210 fail "macOS: the installed binary is not the release asset"
211 grep -Fq '/channels/stable/vole-darwin-arm64' "$tmp/curl.log" ||
212 fail "macOS: the arm64 asset was not downloaded"
213 grep -Fq '/channels/stable/SHA256SUMS' "$tmp/curl.log" ||
214 fail "macOS: SHA256SUMS was not downloaded"
215
216 # uname spells Intel's architecture x86_64; the asset is named amd64.
217 : >"$tmp/curl.log"
218 FAKE_ARCH=x86_64 sh packaging/install.sh --root "$tmp/macintel" >/dev/null
219 grep -Fq '/channels/stable/vole-darwin-amd64' "$tmp/curl.log" ||
220 fail "macOS: an Intel Mac did not get the amd64 asset"
221
222 # --version replaces the channel with one release's artifact tree.
223 : >"$tmp/curl.log"
224 sh packaging/install.sh --root "$tmp/macpin" --version v0.2.0 >/dev/null
225 grep -Fq '/releases/v0.2.0/artifacts/vole-darwin-arm64' "$tmp/curl.log" ||
226 fail "macOS: the pinned release asset URL is wrong"
227
228 # --dry-run names the asset and the destination, and writes nothing.
229 plan=$(sh packaging/install.sh --dry-run)
230 printf '%s\n' "$plan" | grep -q 'would install vole-darwin-arm64 into' ||
231 fail "macOS dry-run: the asset and destination are missing from the plan"
232 printf '%s\n' "$plan" | grep -q 'would check it against' ||
233 fail "macOS dry-run: the checksum check is missing from the plan"
234 plan=$(sh packaging/install.sh --dry-run --repo-only)
235 printf '%s\n' "$plan" | grep -q 'would refuse --repo-only' ||
236 fail "macOS dry-run: --repo-only was not reported as refused"
237
238 # A release that serves a different binary is refused before it is installed.
239 badfixtures="$tmp/badfixtures"
240 mkdir -p "$badfixtures"
241 cp "$fixtures/vole-darwin-arm64" "$badfixtures/"
242 printf '%064d vole-darwin-arm64\n' 0 >"$badfixtures/SHA256SUMS"
243 if FAKE_FIXTURES=$badfixtures sh packaging/install.sh --root "$tmp/macbad" \
244 >"$tmp/macbad.log" 2>&1; then
245 fail "macOS: a mismatched checksum was accepted"
246 fi
247 grep -q 'checksum mismatch' "$tmp/macbad.log" || fail "macOS: a bad checksum did not say so"
248 [ ! -e "$tmp/macbad/usr/local/bin/vole" ] || fail "macOS: a bad checksum still installed the binary"
249
250 # There is no repository to configure on macOS.
251 if sh packaging/install.sh --root "$tmp/macrepo" --repo-only \
252 >"$tmp/macrepo.log" 2>&1; then
253 fail "macOS: --repo-only was accepted"
254 fi
255 grep -q 'configures a package manager' "$tmp/macrepo.log" ||
256 fail "macOS: --repo-only did not explain itself"
257
258 # A Homebrew copy owns the binary; the plan says so and an install refuses.
259 plan=$(FAKE_BREW_STATUS=0 sh packaging/install.sh --dry-run)
260 printf '%s\n' "$plan" | grep -q 'leave the Homebrew installation alone' ||
261 fail "macOS: a Homebrew copy is missing from the plan"
262 if [ "$(id -u)" -ne 0 ]; then
263 home="$tmp/home"
264 mkdir -p "$home"
265 if HOME=$home FAKE_BREW_STATUS=0 sh packaging/install.sh \
266 >"$tmp/brew.log" 2>&1; then
267 fail "macOS: a Homebrew-managed vole was installed over"
268 fi
269 grep -q 'installed by Homebrew' "$tmp/brew.log" ||
270 fail "macOS: a Homebrew-managed vole did not say so"
271 [ ! -e "$home/.local/bin/vole" ] || fail "macOS: a Homebrew-managed vole still wrote a binary"
272
273 # Without root and without Homebrew, the install is for that account.
274 : >"$tmp/curl.log"
275 HOME=$home sh packaging/install.sh >/dev/null
276 [ -x "$home/.local/bin/vole" ] || fail "macOS: a user install did not land in ~/.local/bin"
277 fi
278
279 # Unsupported operating systems are refused rather than guessed at.
280 if FAKE_OS=FreeBSD sh packaging/install.sh --dry-run >"$tmp/os.log" 2>&1; then
281 fail "an unsupported operating system was accepted"
282 fi
283 grep -q 'unsupported operating system' "$tmp/os.log" ||
284 fail "an unsupported operating system did not say so"
285
286 # Back to the real uname for the Linux cases below.
287 PATH=$mac_path
288
152 289 # Unsupported distributions and invalid options fail with a clear message.
153 290 other=$(make_root other gentoo "")
154 291 if sh packaging/install.sh --root "$other" --key packaging/keys/vole-release.asc \