#!/usr/bin/env bash # Smoke-test one release artifact on a clean distro: install it the way a user # would, then the CLI runs, `albedo daemon` starts a daemon that outlives the # CLI, the daemon answers, and `albedo daemon --stop` ends it. # Usage: release/smoke.sh # AppImage: any image; .deb: Debian/Ubuntu; .rpm: Fedora; .pkg.tar.zst: Arch set -euo pipefail artifact="$(readlink -f "$1")" image="$2" engine="${CONTAINER_ENGINE:-$(command -v podman || command -v docker)}" name="$(basename "$artifact")" fuse=(-e APPIMAGE_EXTRACT_AND_RUN=1) # no /dev/fuse: the runtime extracts instead if [ -e /dev/fuse ]; then fuse=(--device /dev/fuse --cap-add SYS_ADMIN); fi "$engine" run --rm "${fuse[@]}" -v "$artifact:/in/$name:ro" -e NAME="$name" "$image" bash -euo pipefail -c ' quiet() { "$@" >/tmp/install.log 2>&1 || { tail -n 30 /tmp/install.log; exit 1; }; } case "$NAME" in *.AppImage) if command -v apt-get >/dev/null; then quiet apt-get update -qq; quiet env DEBIAN_FRONTEND=noninteractive apt-get install -y -qq fuse3 elif command -v dnf >/dev/null; then quiet dnf install -y -q fuse3 elif command -v pacman >/dev/null; then quiet pacman -Sy --noconfirm fuse3 fi install -m 755 "/in/$NAME" /usr/local/bin/albedo # Hosts that register AppImages with binfmt_misc (NixOS) would hand this # file to their own launcher, absent in here; clearing the magic bytes # runs it as the plain ELF it is. printf "\0\0\0" | dd of=/usr/local/bin/albedo bs=1 seek=8 conv=notrunc status=none ;; *.deb) quiet apt-get update -qq quiet env DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends "/in/$NAME" ;; *.rpm) quiet dnf install -y -q --setopt=install_weak_deps=False "/in/$NAME" ;; *.pkg.tar.zst) quiet pacman -U --noconfirm "/in/$NAME" ;; *) echo "unknown artifact $NAME"; exit 2 ;; esac export HOME=/root ALBEDO_HOME=/tmp/albedo-home ALBEDO_NO_BROWSER=1 albedo --help >/tmp/help.txt && head -n 1 /tmp/help.txt albedo daemon pid="$(sed -n "s/.*\"pid\": *\([0-9]*\).*/\1/p" "$ALBEDO_HOME/daemon.json")" test -n "$pid" && kill -0 "$pid" echo "daemon $pid outlived the CLI: $(tr "\0" " " /dev/null || break; sleep 0.1; done if kill -0 "$pid" 2>/dev/null; then echo "daemon $pid still running"; exit 1; fi echo "ok: $NAME on $(. /etc/os-release && echo "$PRETTY_NAME")" '