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

packaging/install.sh +119−12

@@ -1,11 +1,13 @@
1 1 #!/bin/sh
2 # Install Vole from the signed package repository.
2 # Install Vole.
3 3 #
4 4 # The release publishes this file as install.sh and serves it at
5 # /<repository>/channels/<channel>/install.sh. It detects the distribution,
6 # installs the release key and a package source, and then hands the install to
7 # apt, dnf, or pacman. It does not install packages itself, so package and
8 # repository signature checks stay with the package manager.
5 # /<repository>/channels/<channel>/install.sh. On Linux it detects the
6 # distribution, installs the release key and a package source, and then hands the
7 # install to apt, dnf, or pacman, so package and repository signature checks stay
8 # with the package manager. On macOS there is no package manager to hand off to,
9 # so it installs the release binary itself after checking it against the
10 # release's SHA256SUMS.
9 11 #
10 12 # The key is pinned twice: its SHA-256 and its fingerprint. Both belong to
11 13 # packaging/keys/vole-release.asc, which sign-release.py publishes verbatim, so
@@ -33,22 +35,26 @@ PROG=vole-install
33 35
34 36 usage() {
35 37 cat <<'EOF'
36 Install Vole from its signed package repository.
38 Install Vole.
37 39
38 40 Usage: install.sh [options]
39 41
40 42 Options:
41 43 --channel <name> follow this release channel (default: stable)
42 44 --version <tag> install a pinned release, for example v0.2.0
43 --repo-only write the key and repository, do not install
45 --repo-only write the key and repository, do not install (Linux)
44 46 --dry-run print the plan, change nothing
45 47 --yes accepted for non-interactive callers
46 --root <dir> write configuration under <dir>; does not install
47 --key <file> use a local release key instead of downloading it
48 --root <dir> write configuration under <dir> (Linux), or install the
49 binary under <dir>/usr/local (macOS); does not use sudo
50 --key <file> use a local release key instead of downloading it (Linux)
48 51 -h, --help show this help
49 52
50 The script supports Debian and Ubuntu, Fedora, RHEL, Rocky, and AlmaLinux, and
51 Arch Linux. On anything else it stops and points at the manual steps.
53 On Linux the script supports Debian and Ubuntu, Fedora, RHEL, Rocky, and
54 AlmaLinux, and Arch Linux, and hands the install to the package manager. On any
55 other distribution it stops and points at the manual steps. On macOS it installs
56 the release binary into /usr/local/bin when run as root, and into ~/.local/bin
57 otherwise, after checking it against the release's SHA256SUMS.
52 58 EOF
53 59 }
54 60
@@ -191,6 +197,25 @@ else
191 197 fi
192 198
193 199 detect() {
200 case "$(uname -s)" in
201 Darwin)
202 FAMILY=darwin
203 DISTRO=macOS
204 ARCH=$(uname -m)
205 # The release names its macOS binaries after Go's GOARCH, not after
206 # uname's spelling of the same architecture.
207 case "$ARCH" in
208 arm64) ;;
209 x86_64 | amd64) ARCH=amd64 ;;
210 *) die "unsupported architecture: $ARCH" ;;
211 esac
212 return
213 ;;
214 Linux) ;;
215 *)
216 die "unsupported operating system '$(uname -s)'; this script installs Vole on Linux and macOS"
217 ;;
218 esac
194 219 if [ ! -r "$OS_RELEASE" ]; then
195 220 die "cannot read $OS_RELEASE; this script needs a Linux distribution that provides it"
196 221 fi
@@ -227,6 +252,34 @@ hint() {
227 252 esac
228 253 }
229 254
255 # macOS has no package manager to hand the work to, so the script installs the
256 # binary itself. Running as root installs for the machine; otherwise it installs
257 # for the account. --root puts it under a directory instead, which is what an
258 # image build or a test wants.
259 prepare_macos() {
260 [ "$FAMILY" = darwin ] || return 0
261 ASSET="vole-darwin-$ARCH"
262 if [ "$ROOT" != / ]; then
263 DEST="$ROOT/usr/local/bin"
264 elif [ "$(id -u)" -eq 0 ]; then
265 DEST=/usr/local/bin
266 else
267 [ -n "${HOME:-}" ] || die "HOME is not set; run as root to install into /usr/local/bin"
268 DEST="$HOME/.local/bin"
269 fi
270 }
271
272 # A Homebrew installation owns its own copy of the binary, and two copies shadow
273 # each other in PATH order, so this defers to it instead of writing a second one.
274 # A --root install is building an image or running a test, not this machine, so it
275 # is left alone.
276 homebrew_managed() {
277 [ "$FAMILY" = darwin ] || return 1
278 [ "$ROOT" = / ] || return 1
279 command -v brew >/dev/null 2>&1 || return 1
280 brew list --formula vole >/dev/null 2>&1
281 }
282
230 283 plan() {
231 284 if [ -n "$PIN" ]; then
232 285 log "would install release $PIN from $BASE_URL"
@@ -234,6 +287,21 @@ plan() {
234 287 log "would follow channel $CHANNEL at $BASE_URL"
235 288 fi
236 289 log "detected $DISTRO ($FAMILY) on $ARCH"
290 case "$FAMILY" in
291 darwin)
292 if [ "$REPO_ONLY" = 1 ]; then
293 log "would refuse --repo-only: macOS installs the binary, not a repository"
294 return 0
295 fi
296 if homebrew_managed; then
297 log "would leave the Homebrew installation alone; upgrade with: brew upgrade vole"
298 return 0
299 fi
300 log "would install $ASSET into $DEST"
301 log "would check it against $BASE_URL/SHA256SUMS"
302 return 0
303 ;;
304 esac
237 305 log "release key: $KEY_SOURCE (sha256 $VOLE_KEY_SHA256, fingerprint $VOLE_KEY_FPR)"
238 306 case "$FAMILY" in
239 307 apt)
@@ -326,14 +394,48 @@ install_package() {
326 394 esac
327 395 }
328 396
397 # macOS: no package manager is left to verify anything, so the binary is checked
398 # against the release's own SHA256SUMS instead. That list is fetched from the host
399 # that served the binary, so it authenticates the transfer but not the release;
400 # the detached signature over it is what packaging.md documents, and checking that
401 # needs gpg, which a stock macOS does not ship.
402 install_binary() {
403 if ! fetch "$BASE_URL/$ASSET" "$tmp/vole"; then
404 die "cannot download $ASSET from $BASE_URL; this release may not publish macOS binaries"
405 fi
406 if ! fetch "$BASE_URL/SHA256SUMS" "$tmp/SHA256SUMS"; then
407 die "cannot download SHA256SUMS from $BASE_URL, so the download cannot be checked"
408 fi
409 want=$(awk -v asset="$ASSET" '$2 == asset { print $1; exit }' "$tmp/SHA256SUMS")
410 [ -n "$want" ] || die "SHA256SUMS does not name $ASSET"
411 actual=$(sha256 "$tmp/vole")
412 [ "$actual" = "$want" ] || die "$ASSET checksum mismatch: expected $want, got $actual"
413 install -d -m 0755 "$DEST"
414 install -m 0755 "$tmp/vole" "$DEST/vole"
415 log "installed $DEST/vole"
416 case ":$PATH:" in
417 *":$DEST:"*) ;;
418 *) log "add $DEST to PATH to run vole" ;;
419 esac
420 log "checked against $BASE_URL/SHA256SUMS; for a signature check see https://vole.rodent.software/packaging/#verify-a-direct-download"
421 }
422
329 423 detect
424 prepare_macos
330 425
331 426 if [ "$DRY_RUN" = 1 ]; then
332 427 plan
333 428 exit 0
334 429 fi
335 430
336 if [ "$ROOT" = / ] && [ "$(id -u)" -ne 0 ]; then
431 if [ "$FAMILY" = darwin ]; then
432 if [ "$REPO_ONLY" = 1 ]; then
433 die "--repo-only configures a package manager; macOS installs the binary"
434 fi
435 if homebrew_managed; then
436 die "vole is installed by Homebrew; upgrade it with: brew upgrade vole"
437 fi
438 elif [ "$ROOT" = / ] && [ "$(id -u)" -ne 0 ]; then
337 439 die "run as root, for example: curl -fsSL $BASE_URL/install.sh | sudo sh"
338 440 fi
339 441 if [ -n "$KEY_FILE" ] && [ ! -r "$KEY_FILE" ]; then
@@ -343,6 +445,11 @@ fi
343 445 tmp=$(mktemp -d)
344 446 trap 'rm -rf "$tmp"' 0
345 447
448 if [ "$FAMILY" = darwin ]; then
449 install_binary
450 exit 0
451 fi
452
346 453 if [ -n "$KEY_FILE" ]; then
347 454 cp "$KEY_FILE" "$tmp/key.asc"
348 455 else