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.
This commit is contained in:
nvrl committed 2026-11-15 23:57:01 +01:00
1 parent 7e0d7d020e
commit a7baf2313c
12 files changed
+462 -75

No files matched your search

@@ -31,16 +31,6 @@ pkgbase = proton-drive-for-linux-bin
options = !strip
options = !debug
source = proton-drive-linux-3.7.0-x86_64.tar.gz::https://github.com/narrrl/proton-drive-linux/releases/download/v3.7.0/proton-drive-linux-3.7.0-x86_64.tar.gz
source = io.narl.proton-drive-linux-3.7.0.desktop::https://raw.githubusercontent.com/narrrl/proton-drive-linux/v3.7.0/packaging/io.narl.proton-drive-linux.desktop
source = io.narl.proton-drive-linux-tray-3.7.0.desktop::https://raw.githubusercontent.com/narrrl/proton-drive-linux/v3.7.0/packaging/io.narl.proton-drive-linux-tray.desktop
source = io.narl.proton-drive-linux-3.7.0.svg::https://raw.githubusercontent.com/narrrl/proton-drive-linux/v3.7.0/packaging/io.narl.proton-drive-linux.svg
source = proton-drive-3.7.0.service::https://raw.githubusercontent.com/narrrl/proton-drive-linux/v3.7.0/packaging/proton-drive.service
source = LICENSE-3.7.0::https://raw.githubusercontent.com/narrrl/proton-drive-linux/v3.7.0/LICENSE
sha256sums = 3f0d16c19b10b30e3f181e3c7fb439f0a8c38980e8ab7a4a96ae6596b349787c
sha256sums = d190d6771fff0b975271fb62fd3fb0fa8bbf17d7278c10853c18557855b0c123
sha256sums = 1d95e250370220e3bb6aead6ce34d1d6cc759f42c4803b75f1667e78ff47c6c0
sha256sums = e598a93c2715c3a9fdc7fb937902083d4a1135e8fbdfe6fe7e37f0383ebbd828
sha256sums = 44c25dca6e759c46fca50b58099aa6194abe78293dee07d971bbbce0ff3ca58f
sha256sums = 02c419e7f9af08dda720e4f852f3e57cf5a69e192605440f750e9d244fa2817c
sha256sums = SKIP
pkgname = proton-drive-for-linux-bin
@@ -25,54 +25,37 @@ options=('!strip' '!debug')
# Stops the running daemon before removal, so the mount stops mirroring deletes.
install=proton-drive.install
_tag="v$pkgver"
_raw="https://raw.githubusercontent.com/narrrl/proton-drive-linux/$_tag"
# The release tarball holds the four binaries only, so the desktop integration
# files come straight from the tagged tree. Every one carries $pkgver in its
# name: makepkg reuses a cached file of the same name, so an unversioned name
# keeps the old copy after upstream changes it and fails the checksum.
source=("proton-drive-linux-$pkgver-x86_64.tar.gz::$_repo/releases/download/$_tag/proton-drive-linux-$pkgver-x86_64.tar.gz"
"io.narl.proton-drive-linux-$pkgver.desktop::$_raw/packaging/io.narl.proton-drive-linux.desktop"
"io.narl.proton-drive-linux-tray-$pkgver.desktop::$_raw/packaging/io.narl.proton-drive-linux-tray.desktop"
"io.narl.proton-drive-linux-$pkgver.svg::$_raw/packaging/io.narl.proton-drive-linux.svg"
"proton-drive-$pkgver.service::$_raw/packaging/proton-drive.service"
"LICENSE-$pkgver::$_raw/LICENSE")
sha256sums=('3f0d16c19b10b30e3f181e3c7fb439f0a8c38980e8ab7a4a96ae6596b349787c'
'd190d6771fff0b975271fb62fd3fb0fa8bbf17d7278c10853c18557855b0c123'
'1d95e250370220e3bb6aead6ce34d1d6cc759f42c4803b75f1667e78ff47c6c0'
'e598a93c2715c3a9fdc7fb937902083d4a1135e8fbdfe6fe7e37f0383ebbd828'
'44c25dca6e759c46fca50b58099aa6194abe78293dee07d971bbbce0ff3ca58f'
'02c419e7f9af08dda720e4f852f3e57cf5a69e192605440f750e9d244fa2817c')
# The release tarball holds the binaries and everything installed around them
# (desktop files, icon, user service, translations, completions) in a /usr-like
# tree under one directory.
source=("proton-drive-linux-$pkgver-x86_64.tar.gz::$_repo/releases/download/$_tag/proton-drive-linux-$pkgver-x86_64.tar.gz")
sha256sums=('SKIP')
package() {
install -Dm755 "$srcdir/pdfs" "$pkgdir/usr/bin/pdfs"
install -Dm755 "$srcdir/pdfs-tray" "$pkgdir/usr/bin/pdfs-tray"
install -Dm755 "$srcdir/pdfs-app" "$pkgdir/usr/bin/pdfs-app"
install -Dm755 "$srcdir/pdfs-prompt" "$pkgdir/usr/bin/pdfs-prompt"
cd "$srcdir/proton-drive-linux-$pkgver-x86_64"
local exe
for exe in pdfs pdfs-tray pdfs-app pdfs-prompt; do
install -Dm755 "bin/$exe" "$pkgdir/usr/bin/$exe"
done
install -Dm644 "$srcdir/io.narl.proton-drive-linux-$pkgver.desktop" \
install -Dm644 share/applications/io.narl.proton-drive-linux.desktop \
"$pkgdir/usr/share/applications/io.narl.proton-drive-linux.desktop"
install -Dm644 "$srcdir/io.narl.proton-drive-linux-tray-$pkgver.desktop" \
install -Dm644 etc/xdg/autostart/io.narl.proton-drive-linux-tray.desktop \
"$pkgdir/etc/xdg/autostart/io.narl.proton-drive-linux-tray.desktop"
install -Dm644 "$srcdir/io.narl.proton-drive-linux-$pkgver.svg" \
install -Dm644 share/icons/hicolor/scalable/apps/io.narl.proton-drive-linux.svg \
"$pkgdir/usr/share/icons/hicolor/scalable/apps/io.narl.proton-drive-linux.svg"
# systemd user unit for the auto-mount daemon; enabled per user, not by pacman.
install -Dm644 "$srcdir/proton-drive-$pkgver.service" \
install -Dm644 lib/systemd/user/proton-drive.service \
"$pkgdir/usr/lib/systemd/user/proton-drive.service"
# Translations ship precompiled in the release tarball.
# Translations and shell completion for bash, zsh and fish.
install -dm755 "$pkgdir/usr/share"
cp -r --no-preserve=ownership "$srcdir/locale" "$pkgdir/usr/share/locale"
cp -r --no-preserve=ownership share/locale share/bash-completion share/zsh share/fish \
"$pkgdir/usr/share/"
# Shell completion for bash, zsh and fish, written by the binary itself.
local share="$pkgdir/usr/share"
install -d "$share/bash-completion/completions" "$share/zsh/site-functions" \
"$share/fish/vendor_completions.d"
"$srcdir/pdfs" completions bash > "$share/bash-completion/completions/pdfs"
"$srcdir/pdfs" completions zsh > "$share/zsh/site-functions/_pdfs"
"$srcdir/pdfs" completions fish > "$share/fish/vendor_completions.d/pdfs.fish"
install -Dm644 "$srcdir/LICENSE-$pkgver" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
install -Dm644 share/licenses/proton-drive-linux/LICENSE \
"$pkgdir/usr/share/licenses/$pkgname/LICENSE"
# pacman brings new releases, so the app never checks for them itself.
install -Dm644 /dev/null "$pkgdir/usr/share/proton-drive-linux/managed-updates"
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
# Lay out the release tarball: built binaries, desktop files, icon, user
# service, translations, shell completions and install.sh, under one top-level
# directory with a /usr-like tree, then pack it.
#
# usage: packaging/tarball/build.sh <binary dir> <version> <output dir>
# e.g. packaging/tarball/build.sh target/release 3.8.0 dist
# Writes <output dir>/proton-drive-linux-<version>-x86_64.tar.gz and prints
# its path.
set -euo pipefail
if [ $# -ne 3 ]; then
echo "usage: $0 <binary dir> <version> <output dir>" >&2
exit 2
fi
bin_dir="$1"
version="$2"
out="$3"
repo="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
name="proton-drive-linux-$version-x86_64"
stage="$(mktemp -d)"
trap 'rm -rf "$stage"' EXIT
root="$stage/$name"
for exe in pdfs pdfs-app pdfs-tray pdfs-prompt; do
install -Dm755 "$bin_dir/$exe" "$root/bin/$exe"
done
install -Dm644 "$repo/packaging/io.narl.proton-drive-linux.desktop" \
"$root/share/applications/io.narl.proton-drive-linux.desktop"
install -Dm644 "$repo/packaging/io.narl.proton-drive-linux-tray.desktop" \
"$root/etc/xdg/autostart/io.narl.proton-drive-linux-tray.desktop"
install -Dm644 "$repo/packaging/io.narl.proton-drive-linux.svg" \
"$root/share/icons/hicolor/scalable/apps/io.narl.proton-drive-linux.svg"
install -Dm644 "$repo/packaging/proton-drive.service" \
"$root/lib/systemd/user/proton-drive.service"
install -Dm644 "$repo/LICENSE" "$root/share/licenses/proton-drive-linux/LICENSE"
"$repo/po/build.sh" "$root/share/locale"
"$repo/packaging/completions.sh" "$root/bin/pdfs" "$root/share"
install -Dm755 "$repo/packaging/tarball/install.sh" "$root/install.sh"
mkdir -p "$out"
tarball="$(cd "$out" && pwd)/$name.tar.gz"
tar -czf "$tarball" -C "$stage" --owner=0 --group=0 "$name"
echo "$tarball"
+192
View File
@@ -0,0 +1,192 @@
#!/usr/bin/env bash
# Install Proton Drive for Linux from this release tarball into your home
# directory, or remove it again. Needs no root, so it works on distributions
# where the system is read-only, as long as GTK 4, libadwaita, WebKitGTK 6 and
# FUSE 3 are on the system.
set -Eeuo pipefail
usage() {
cat >&2 <<'EOF'
usage: ./install.sh [--prefix DIR] [--no-service] [--force]
./install.sh --uninstall [--prefix DIR] [--no-service]
Installs the app, the tray, the search launcher and the `pdfs` command into
~/.local (bin/, share/), the background service into ~/.config/systemd/user and
the tray's login entry into ~/.config/autostart. Run it again from a newer
tarball to update; the running service restarts on the new version.
--prefix DIR install under DIR instead of ~/.local
--uninstall remove what an earlier run installed; your settings, cache
and the files in Proton Drive stay
--no-service leave systemd alone (no reload, restart or stop)
--force install although libraries are missing or a package
already installs Proton Drive for Linux
EOF
exit 2
}
prefix=""
uninstall=0
service=1
force=0
while [[ $# -gt 0 ]]; do
case "$1" in
--prefix) [[ $# -ge 2 ]] || usage; prefix="$2"; shift ;;
--prefix=*) prefix="${1#*=}" ;;
--uninstall) uninstall=1 ;;
--no-service) service=0 ;;
--force) force=1 ;;
-h | --help) usage ;;
*) echo "unknown option: $1" >&2; usage ;;
esac
shift
done
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# The copy kept for --uninstall knows where it was installed.
if [[ -z "$prefix" && -f "$here/installed-files" ]]; then
prefix="$(dirname "$(dirname "$here")")"
fi
prefix="${prefix:-$HOME/.local}"
[[ "$prefix" == /* ]] || prefix="$PWD/$prefix"
prefix="${prefix%/}"
config_home="${XDG_CONFIG_HOME:-$HOME/.config}"
unit_dir="$config_home/systemd/user"
autostart_dir="$config_home/autostart"
data_dir="$prefix/share/proton-drive-linux"
manifest="$data_dir/installed-files"
unit=proton-drive.service
say() { printf '%s\n' "$*"; }
warn() { printf 'warning: %s\n' "$*" >&2; }
die() { printf 'error: %s\n' "$*" >&2; exit 1; }
systemctl_user() {
[[ $service -eq 1 ]] || return 0
command -v systemctl >/dev/null || return 0
systemctl --user "$@" 2>/dev/null || true
}
# Remove every file listed in the manifest `$1` that is not in the list `$2`
# (one path per line), then the directories that leaves empty.
remove_listed() {
local list="$1" keep="${2:-}" path
[[ -f "$list" ]] || return 0
while IFS= read -r path; do
[[ -n "$path" ]] || continue
if [[ -n "$keep" ]] && grep -Fxq -- "$path" <<<"$keep"; then
continue
fi
rm -f -- "$path"
rmdir -p --ignore-fail-on-non-empty -- "$(dirname -- "$path")" 2>/dev/null || true
done <"$list"
}
if [[ $uninstall -eq 1 ]]; then
[[ -f "$manifest" ]] || die "nothing installed under $prefix (no $manifest)"
# Stopping unmounts My files; queued changes stay and upload on the next start.
systemctl_user disable --now "$unit"
remove_listed "$manifest"
rm -f -- "$manifest" "$data_dir/install.sh"
rmdir --ignore-fail-on-non-empty -- "$data_dir" 2>/dev/null || true
systemctl_user daemon-reload
say "Removed Proton Drive for Linux from $prefix."
say "Your settings, cache and sign-in stay; see the uninstall section of docs/INSTALL.md to remove them too."
exit 0
fi
[[ -x "$here/bin/pdfs" ]] || die "run install.sh from the unpacked tarball (no bin/pdfs next to it)"
# A package and this install would each bring a service unit, and the one in
# ~/.config wins: the two would run different versions against one database.
if [[ $force -eq 0 && ( -e /usr/bin/pdfs || -e /usr/lib/systemd/user/$unit ) ]]; then
die "a package already installs Proton Drive for Linux (/usr/bin/pdfs). Remove it first, or keep using it."
fi
# Missing libraries would only show when the app does not start.
missing="$(for exe in pdfs pdfs-app pdfs-tray pdfs-prompt; do
ldd "$here/bin/$exe" 2>&1 | grep -E 'not found' || true
done | sort -u)"
if [[ -n "$missing" ]]; then
printf '%s\n' "$missing" | sed 's/^[[:space:]]*/ /' >&2
if grep -q 'GLIBC_' <<<"$missing"; then
warn "these binaries need glibc 2.39 or newer (Ubuntu 24.04, Debian 13, Fedora 40)"
fi
cat >&2 <<'EOF'
Install the missing libraries, then run this again:
Fedora, Fedora Atomic gtk4 libadwaita webkitgtk6.0 fuse3
(on Silverblue and its siblings, layer the COPR package
instead: see docs/INSTALL.md)
Debian, Ubuntu libgtk-4-1 libadwaita-1-0 libwebkitgtk-6.0-4 fuse3
Arch Linux gtk4 libadwaita webkitgtk-6.0 fuse3
openSUSE libgtk-4-1 libadwaita-1-0 libwebkitgtk-6_0-4 fuse3
EOF
[[ $force -eq 1 ]] || die "missing libraries (--force installs anyway)"
fi
fusermount="$(command -v fusermount3 || true)"
if [[ -z "$fusermount" ]]; then
warn "fusermount3 is missing; install fuse3, or My files cannot be mounted"
elif [[ ! -u "$fusermount" ]]; then
warn "$fusermount is not setuid root; My files may not mount"
fi
# Where each file of the tarball goes, as "source<TAB>target" lines.
targets() {
local file rel
while IFS= read -r -d '' file; do
rel="${file#"$here"/}"
case "$rel" in
bin/* | share/*) printf '%s\t%s\n' "$rel" "$prefix/$rel" ;;
lib/systemd/user/*) printf '%s\t%s\n' "$rel" "$unit_dir/${rel##*/}" ;;
etc/xdg/autostart/*) printf '%s\t%s\n' "$rel" "$autostart_dir/${rel##*/}" ;;
esac
done < <(find "$here/bin" "$here/share" "$here/lib" "$here/etc" -type f -print0 | sort -z)
}
# A desktop entry and a unit file take a quoted path; double quotes and
# backslashes inside it are escaped.
quoted() {
local path="${1//\\/\\\\}"
printf '"%s"' "${path//\"/\\\"}"
}
new_files=""
while IFS=$'\t' read -r rel target; do
mode=644
[[ "$rel" == bin/* ]] && mode=755
install -Dm"$mode" -- "$here/$rel" "$target"
case "$rel" in
share/applications/*.desktop | etc/xdg/autostart/*.desktop)
exe="$(sed -n 's/^Exec=\([^ ]*\).*/\1/p' "$target" | head -n1)"
sed -i "s|^Exec=$exe|Exec=$(quoted "$prefix/bin/$exe" | sed 's/[&|]/\\&/g')|" "$target"
;;
lib/systemd/user/*)
sed -i "s|^ExecStart=/usr/bin/pdfs|ExecStart=$(quoted "$prefix/bin/pdfs" | sed 's/[&|]/\\&/g')|" "$target"
;;
esac
new_files+="$target"$'\n'
done < <(targets)
# Drop what an older version installed and this one does not.
remove_listed "$manifest" "$new_files"
mkdir -p -- "$data_dir"
printf '%s' "$new_files" >"$manifest"
install -m755 -- "$here/install.sh" "$data_dir/install.sh"
command -v gtk-update-icon-cache >/dev/null && [[ -f "$prefix/share/icons/hicolor/index.theme" ]] &&
gtk-update-icon-cache -q -t "$prefix/share/icons/hicolor" 2>/dev/null || true
systemctl_user daemon-reload
if [[ $service -eq 1 ]] && command -v systemctl >/dev/null &&
systemctl --user is-active -q "$unit" 2>/dev/null; then
systemctl --user restart "$unit" && say "Restarted the running service on the new version."
fi
say "Installed Proton Drive for Linux $("$prefix/bin/pdfs" --version 2>/dev/null | awk '{print $NF}') into $prefix."
say "Open \"Proton Drive for Linux\" from your applications menu and sign in; the app starts the service."
case ":$PATH:" in
*":$prefix/bin:"*) ;;
*) say "To use \`pdfs\` in a terminal, add $prefix/bin to your PATH." ;;
esac
say "To update, run install.sh from a newer tarball. To remove: $data_dir/install.sh --uninstall"
+69
View File
@@ -0,0 +1,69 @@
#!/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")"