Files
proton-drive-linux/packaging/tarball/test.sh
T
nvrl a7baf2313c feat(packaging): an installable release tarball for immutable distributions (#99)
The release .tar.gz held the four binaries and their translations only,
and the service unit pointed at /usr/bin/pdfs, so it was no install on
its own. It now carries a /usr-like tree (bin, share, the user unit, the
tray's autostart entry) and install.sh, which installs it into ~/.local
without root:

- checks the libraries with ldd and names the packages to install per
  distribution, and that fusermount3 is there and setuid;
- refuses to install next to a package of the client;
- rewrites Exec= and ExecStart= to absolute paths, since ~/.local/bin is
  often not on a session's PATH;
- keeps a manifest, removes what an older version left, restarts a
  running service on update, and --uninstall leaves settings alone.

packaging/tarball/build.sh lays the tarball out and test.sh installs,
updates and uninstalls it in a throwaway home; the release job runs
both, CI runs shellcheck on them. The app looks for its translations in
share/locale beside its own bin directory and starts the tray from there,
so nothing needs PDFS_LOCALEDIR or the PATH. The -bin AUR package takes
every file from the new tarball instead of raw.githubusercontent.com.

INSTALL.md documents the tarball and layering the COPR package on Fedora
Atomic.
2026-11-15 23:57:01 +01:00

70 lines
3.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Check a release tarball: install it into a throwaway home, check that every
# file landed with its paths rewritten and that the programs run, update it in
# place, then uninstall and check nothing is left. Touches no real home and no
# systemd (--no-service).
#
# usage: packaging/tarball/test.sh <tarball>
set -euo pipefail
if [ $# -ne 1 ]; then
echo "usage: $0 <tarball>" >&2
exit 2
fi
tarball="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
fail() { echo "FAIL: $*" >&2; exit 1; }
tar -xzf "$tarball" -C "$work"
src="$(find "$work" -mindepth 1 -maxdepth 1 -type d -name 'proton-drive-linux-*')"
[ -x "$src/install.sh" ] || fail "no install.sh in the tarball"
export HOME="$work/home" XDG_CONFIG_HOME="$work/home/.config"
mkdir -p "$HOME"
prefix="$HOME/.local"
"$src/install.sh" --no-service --force >"$work/install.log" 2>&1 ||
{ cat "$work/install.log" >&2; fail "install.sh failed"; }
for exe in pdfs pdfs-app pdfs-tray pdfs-prompt; do
[ -x "$prefix/bin/$exe" ] || fail "$exe was not installed"
done
"$prefix/bin/pdfs" --version >/dev/null || fail "pdfs does not run"
app="$prefix/share/applications/io.narl.proton-drive-linux.desktop"
tray="$XDG_CONFIG_HOME/autostart/io.narl.proton-drive-linux-tray.desktop"
unit="$XDG_CONFIG_HOME/systemd/user/proton-drive.service"
grep -qx "Exec=\"$prefix/bin/pdfs-app\"" "$app" || fail "the app's Exec= was not rewritten: $(grep ^Exec= "$app")"
grep -qx "Exec=\"$prefix/bin/pdfs-tray\"" "$tray" || fail "the tray's Exec= was not rewritten: $(grep ^Exec= "$tray")"
grep -qx "ExecStart=\"$prefix/bin/pdfs\" daemon" "$unit" || fail "ExecStart= was not rewritten: $(grep ^ExecStart= "$unit")"
[ -f "$prefix/share/locale/de/LC_MESSAGES/pdfs.mo" ] || fail "no translations"
[ -f "$prefix/share/icons/hicolor/scalable/apps/io.narl.proton-drive-linux.svg" ] || fail "no icon"
[ -f "$prefix/share/bash-completion/completions/pdfs" ] || fail "no bash completion"
[ ! -e "$prefix/share/proton-drive-linux/managed-updates" ] || fail "the update check must stay on offer"
uninstaller="$prefix/share/proton-drive-linux/install.sh"
[ -x "$uninstaller" ] || fail "install.sh was not kept for --uninstall"
# An update from the same tarball leaves the same files.
before="$(cd "$work/home" && find . -type f | sort)"
"$src/install.sh" --no-service --force >"$work/update.log" 2>&1 ||
{ cat "$work/update.log" >&2; fail "updating failed"; }
after="$(cd "$work/home" && find . -type f | sort)"
[ "$before" = "$after" ] || fail "an update changed the set of files: $(diff <(echo "$before") <(echo "$after"))"
# A file an older version installed and this one does not is removed.
stale="$prefix/share/locale/xx/LC_MESSAGES/pdfs.mo"
mkdir -p "$(dirname "$stale")" && : >"$stale"
echo "$stale" >>"$prefix/share/proton-drive-linux/installed-files"
"$src/install.sh" --no-service --force >/dev/null 2>&1
[ ! -e "$stale" ] || fail "a file the new version does not ship was left behind"
# Settings are not the installer's: uninstalling keeps them.
mkdir -p "$XDG_CONFIG_HOME/proton-drive-linux"
echo '{}' >"$XDG_CONFIG_HOME/proton-drive-linux/config.json"
"$uninstaller" --uninstall --no-service >"$work/uninstall.log" 2>&1 ||
{ cat "$work/uninstall.log" >&2; fail "uninstall failed"; }
left="$(cd "$work/home" && find . -type f | sort)"
[ "$left" = "./.config/proton-drive-linux/config.json" ] || fail "uninstall left files behind: $left"
echo "tarball OK: $(basename "$tarball")"