diff --git a/.github/workflows/packaging-lint.yml b/.github/workflows/packaging-lint.yml index 40376cf58..aed79a90e 100644 --- a/.github/workflows/packaging-lint.yml +++ b/.github/workflows/packaging-lint.yml @@ -54,4 +54,13 @@ jobs: desktop-file-validate packaging/linux/ai.storyteller.pdfcraft.desktop sed -e 's/@VERSION@/0.0.0/' -e 's/@DATE@/2026-01-01/' packaging/linux/ai.storyteller.pdfcraft.metainfo.xml.in >"$RUNNER_TEMP/ai.storyteller.pdfcraft.metainfo.xml" appstreamcli validate --no-net --explain "$RUNNER_TEMP/ai.storyteller.pdfcraft.metainfo.xml" - python3 -c "import yaml; m = yaml.safe_load(open('packaging/linux/flatpak/ai.storyteller.pdfcraft.yml')); assert m['id'] == 'ai.storyteller.pdfcraft' and m['command'] == 'pdfcraft'" + python3 - <<'EOF' + import yaml + src = yaml.safe_load(open("packaging/linux/flatpak/ai.storyteller.pdfcraft.yml")) + bundle = yaml.safe_load(open("packaging/linux/flatpak/ai.storyteller.pdfcraft.bundle.yml")) + for m in (src, bundle): + assert m["id"] == "ai.storyteller.pdfcraft" and m["command"] == "pdfcraft", m["id"] + for key in ("runtime", "runtime-version", "sdk", "finish-args"): + assert src[key] == bundle[key], f"Flatpak manifests disagree on {key}: {src[key]} vs {bundle[key]}" + print("Flatpak manifests ok") + EOF diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4dd9f9519..aa09481b5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,12 @@ # Release pipeline: every push to `release` builds signed installers for every platform and # creates or updates the draft GitHub Release "PdfCraft v". See docs/releasing.md. # -# All jobs run in the `release` environment (restricted to the `release` branch), which holds -# the signing secrets. Every secret is optional: missing ones produce unsigned artifacts and a -# warning, never a failed build. +# The jobs that sign (macOS, Windows) and the one that drafts the release run in the `release` +# environment (restricted to the `release` branch), which holds the signing secrets. Every secret +# is optional: missing ones produce unsigned artifacts and a warning, never a failed build. The +# other jobs use no secrets and so no environment: a dispatch on another branch builds and checks +# them (a dry run), while the signing jobs are refused there and the draft-release job, which +# needs them, is skipped. name: Release on: @@ -35,7 +38,6 @@ jobs: version: name: version runs-on: ubuntu-latest - environment: release outputs: version: ${{ steps.v.outputs.version }} date: ${{ steps.v.outputs.date }} @@ -175,7 +177,7 @@ jobs: # The oldest GitHub-hosted image, so the binaries only need glibc >= 2.35 (Ubuntu 22.04+, # Debian 12+, Fedora 36+, RHEL 10). See docs/releasing.md. runs-on: ${{ matrix.runner }} - environment: release + # No `environment: release`: this job signs nothing, so it gets no release secrets. strategy: fail-fast: false matrix: @@ -200,7 +202,7 @@ jobs: sudo apt-get update sudo apt-get install -y --no-install-recommends \ libxkbcommon-dev libwayland-dev libx11-dev libxrandr-dev libxi-dev libgl1-mesa-dev \ - desktop-file-utils appstream python3-yaml + desktop-file-utils appstream python3-yaml zsync curl -fsSL -o "$RUNNER_TEMP/nfpm.deb" \ "https://github.com/goreleaser/nfpm/releases/download/v${NFPM_VERSION}/nfpm_${NFPM_VERSION}_${{ matrix.deb }}.deb" sudo dpkg -i "$RUNNER_TEMP/nfpm.deb" @@ -225,6 +227,9 @@ jobs: for appimage in dist/release/*.AppImage; do chmod +x "$appimage" APPIMAGE_EXTRACT_AND_RUN=1 "$appimage" --version + # Update information is embedded, and the .zsync for delta updates sits beside it. + "$appimage" --appimage-updateinformation | grep -F 'gh-releases-zsync|' + test -s "$appimage.zsync" done - uses: actions/upload-artifact@v4 with: @@ -232,13 +237,51 @@ jobs: path: dist/release/* if-no-files-found: error + flatpak: + name: Flatpak ${{ matrix.arch }} + needs: [version, linux] + # Repackages the Linux job's tarball (the same binaries as the AppImage/deb/rpm); no Rust + # build here. 24.04 for a newer flatpak-builder (1.4) than 22.04 ships. + runs-on: ${{ matrix.runner }} + # No `environment: release`: this job signs nothing, so it gets no release secrets. + strategy: + fail-fast: false + matrix: + include: + - { arch: x86_64, runner: ubuntu-24.04 } + - { arch: aarch64, runner: ubuntu-24.04-arm } + env: + PDFCRAFT_VERSION: ${{ needs.version.outputs.version }} + PDFCRAFT_BUILD_DATE: ${{ needs.version.outputs.date }} + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: release-linux-${{ matrix.arch }} + path: dist/linux + - name: Install flatpak-builder + run: | + sudo apt-get update + # librsvg2-common: the SVG pixbuf loader. flatpak-builder runs the host's + # `appstreamcli compose`, which renders the scalable icon and fails without it. + sudo apt-get install -y --no-install-recommends flatpak flatpak-builder librsvg2-common + # Ubuntu 24.04's AppArmor blocks the unprivileged user namespaces bubblewrap needs. + sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 + - name: Build the Flatpak bundle + run: packaging/linux/flatpak-bundle.sh "dist/linux/pdfcraft-$PDFCRAFT_VERSION-linux-${{ matrix.arch }}.tar.gz" + - uses: actions/upload-artifact@v4 + with: + name: release-flatpak-${{ matrix.arch }} + path: dist/release/*.flatpak + if-no-files-found: error + freebsd: name: FreeBSD x86_64 needs: version # GitHub has no FreeBSD runners: build in a FreeBSD VM (see .github/workflows/freebsd.yml). runs-on: ubuntu-latest - environment: release timeout-minutes: 180 + # No `environment: release`: this job signs nothing, so it gets no release secrets. env: PDFCRAFT_VERSION: ${{ needs.version.outputs.version }} PDFCRAFT_BUILD_DATE: ${{ needs.version.outputs.date }} @@ -284,7 +327,7 @@ jobs: name: Web (wasm) needs: version runs-on: ubuntu-latest - environment: release + # No `environment: release`: this job signs nothing, so it gets no release secrets. env: PDFCRAFT_VERSION: ${{ needs.version.outputs.version }} PDFCRAFT_BUILD_DATE: ${{ needs.version.outputs.date }} @@ -325,7 +368,8 @@ jobs: release: name: Draft GitHub Release - needs: [version, macos, windows, linux, freebsd, web] + # Needs the signing jobs, which only run on `release`: a branch dry run never drafts a release. + needs: [version, macos, windows, linux, flatpak, freebsd, web] runs-on: ubuntu-latest environment: release permissions: diff --git a/README.md b/README.md index 5fbc07fe3..0d35489aa 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ How it's built · Get started · What's next · + Downloads · Crafting Apps

@@ -369,8 +370,9 @@ git clone https://github.com/storytold/craft-fonts ../craft-fonts CRAFT_FONTS_DIR=../craft-fonts cargo run --release -p pdfcraft -- some.pdf ``` -Each [GitHub release](https://github.com/storytold/pdfcraft/releases) has ready-made builds, on Linux as -an AppImage, a `.deb`, an `.rpm` and a tarball. On Gentoo, the community [::snakebyte +Each [GitHub release](https://github.com/storytold/pdfcraft/releases) has ready-made builds for macOS, +Windows, Linux (AppImage, Flatpak, `.deb`, `.rpm` and a tarball), FreeBSD and the web; see +[Downloads](#downloads). On Gentoo, the community [::snakebyte overlay](https://github.com/switch87/snakebyte-overlay) packages the Linux release as `app-text/pdfcraft-bin` (not maintained by the PdfCraft team): @@ -400,6 +402,52 @@ The honest assessment by area, what's lacking and where we're going are in **[RO --- +## Downloads + +Every [release](https://github.com/storytold/pdfcraft/releases/latest) ships these builds. `` is the +version number; `SHA256SUMS.txt` lists a checksum for every file. + +### macOS + +| Build | File | Notes | +|---|---|---| +| App, universal (Apple silicon + Intel) | `pdfcraft--macos-universal.dmg` | Signed and notarized | +| Command-line tool, universal | `pdfcraft-cli--macos-universal.zip` | Signed and notarized | + +### Windows + +| Build | Installer | Portable | +|---|---|---| +| x64 (64-bit Intel/AMD) | `pdfcraft--windows-x64.msi` | `pdfcraft--windows-x64-portable.zip` | +| arm64 (Snapdragon and other ARM PCs) | `pdfcraft--windows-arm64.msi` | `pdfcraft--windows-arm64-portable.zip` | +| x86 (32-bit) | `pdfcraft--windows-x86.msi` | `pdfcraft--windows-x86-portable.zip` | + +Installers and executables are code-signed. + +### Linux + +| Format | x86_64 | aarch64 (ARM64) | Notes | +|---|---|---|---| +| AppImage | `pdfcraft--linux-x86_64.AppImage` | `pdfcraft--linux-aarch64.AppImage` | Runs anywhere; updates itself with [AppImageUpdate](https://github.com/AppImageCommunity/AppImageUpdate) (`.zsync` files) | +| Flatpak | `pdfcraft--linux-x86_64.flatpak` | `pdfcraft--linux-aarch64.flatpak` | Sandboxed; `flatpak install --user ` | +| Debian/Ubuntu | `pdfcraft--linux-x86_64.deb` | `pdfcraft--linux-aarch64.deb` | | +| Fedora/RHEL/openSUSE | `pdfcraft--linux-x86_64.rpm` | `pdfcraft--linux-aarch64.rpm` | | +| Tarball | `pdfcraft--linux-x86_64.tar.gz` | `pdfcraft--linux-aarch64.tar.gz` | Unpack anywhere | + +### FreeBSD + +| Build | File | +|---|---| +| x86_64 | `pdfcraft--freebsd-x86_64.tar.gz` | + +### Web (WebAssembly) + +| Build | File | Notes | +|---|---|---| +| Static site | `pdfcraft-web-.zip` | Runs in a modern browser; host it on any static server | + +--- + ## The Crafting Apps PdfCraft is one of the **Crafting Apps**: free, open-source creative tools from the diff --git a/docs/releasing.md b/docs/releasing.md index 89ee2d468..1b5616440 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -33,8 +33,12 @@ Once the draft is published, the workflow refuses to touch that version again, s **Test runs:** *Actions ▸ Release ▸ Run workflow* runs the whole pipeline by hand. The optional `version` input (such as `0.3.0-rc.1`) overrides `Cargo.toml` for that run only; each job applies it -with `cargo xtask version set` before building, so the binaries report it too. The jobs use the -`release` environment, so pick the `release` branch in the dialog. +with `cargo xtask version set` before building, so the binaries report it too. The signing jobs +(macOS, Windows) and the draft-release job use the `release` environment, so pick the `release` +branch in the dialog for a full run. On any other branch the same dispatch is a **dry run**: the +Linux, Flatpak, FreeBSD and web jobs build and check everything, the signing jobs are refused by the +environment's branch rule, and the draft-release job (which needs them) is skipped, so nothing is +published (`gh workflow run release.yml --ref `). ## What gets built @@ -44,8 +48,10 @@ with `cargo xtask version set` before building, so the binaries report it too. T | Windows 10+ x64 | `pdfcraft--windows-x64.msi`, `pdfcraft--windows-x64-portable.zip` | `windows-latest` | | Windows 10+ x86 (32-bit) | `pdfcraft--windows-x86.msi`, `pdfcraft--windows-x86-portable.zip` | `windows-latest` | | Windows 11 on ARM64 | `pdfcraft--windows-arm64.msi`, `pdfcraft--windows-arm64-portable.zip` | `windows-latest` (cross-compiled) | -| Linux x86_64 | `pdfcraft--linux-x86_64.{AppImage,deb,rpm,tar.gz}` | `ubuntu-22.04` | -| Linux aarch64 | `pdfcraft--linux-aarch64.{AppImage,deb,rpm,tar.gz}` | `ubuntu-22.04-arm` | +| Linux x86_64 | `pdfcraft--linux-x86_64.{AppImage,AppImage.zsync,deb,rpm,tar.gz}` | `ubuntu-22.04` | +| Linux aarch64 | `pdfcraft--linux-aarch64.{AppImage,AppImage.zsync,deb,rpm,tar.gz}` | `ubuntu-22.04-arm` | +| Flatpak x86_64 | `pdfcraft--linux-x86_64.flatpak` | `ubuntu-24.04` (repackages the Linux tarball) | +| Flatpak aarch64 | `pdfcraft--linux-aarch64.flatpak` | `ubuntu-24.04-arm` (repackages the Linux tarball) | | FreeBSD 14 x86_64 | `pdfcraft--freebsd-x86_64.tar.gz` | FreeBSD VM on `ubuntu-latest` | | Web | `pdfcraft-web-.zip` (a static site; see [`packaging/web/README.md`](../packaging/web/README.md)) | `ubuntu-latest` | @@ -127,7 +133,24 @@ The binaries are built on Ubuntu 22.04, the oldest GitHub-hosted image, so they xkbcommon) and the GPU (Vulkan, EGL) are loaded at runtime from the system; the .deb and .rpm declare them as dependencies (see `nfpm.yaml`). -Locally (on Linux, with nfpm): `packaging/linux/package.sh` or `--formats "deb tar"`. +Each AppImage embeds update information +(`gh-releases-zsync|storytold|pdfcraft|latest|pdfcraft-*-linux-.AppImage.zsync`), and its +`.zsync` is published beside it, so AppImageUpdate and AppImageLauncher can update it in place, +downloading only the changed blocks. `latest` is the newest published, non-pre-release version. +`package.sh` writes the `.zsync` when `zsyncmake` (the `zsync` package) is installed and warns +otherwise; the release job checks both. + +**Flatpak:** the `flatpak` job turns each arch's tarball into a single-file bundle with +`packaging/linux/flatpak-bundle.sh` and `flatpak/ai.storyteller.pdfcraft.bundle.yml` (no Rust build; +the same binaries), then installs it and runs `pdfcraft-cli --version` in the sandbox. +`flatpak/ai.storyteller.pdfcraft.yml` is the from-source manifest for a later Flathub submission; +packaging-lint keeps the runtime and sandbox permissions (`finish-args`) of the two identical. +Printing is not available in the Flatpak yet: it runs `lp`, which the freedesktop runtime lacks +(the job logs a note); it needs the print portal. Users install the bundle with `flatpak install --user pdfcraft--linux-.flatpak`; the +freedesktop runtime comes from Flathub. + +Locally (on Linux, with nfpm): `packaging/linux/package.sh` or `--formats "deb tar"`; then +`packaging/linux/flatpak-bundle.sh` for the Flatpak. ### FreeBSD diff --git a/packaging/linux/flatpak-bundle.sh b/packaging/linux/flatpak-bundle.sh new file mode 100755 index 000000000..f983fa226 --- /dev/null +++ b/packaging/linux/flatpak-bundle.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +# Repackage a PdfCraft Linux tarball as a single-file Flatpak bundle: +# +# $DIST/pdfcraft--linux-.flatpak +# +# Usage: packaging/linux/flatpak-bundle.sh [--no-test] [TARBALL] +# +# TARBALL defaults to $DIST/pdfcraft--linux-.tar.gz from package.sh. The bundle +# is built for the host architecture (x86_64 or aarch64), which must match the tarball's. +# Needs flatpak, flatpak-builder and the SVG pixbuf loader (librsvg2-common) for the host's +# `appstreamcli compose`; the freedesktop runtime and SDK named in the manifest are +# installed per-user from Flathub. Unless --no-test, the bundle is then installed per-user and +# `pdfcraft-cli --version` is run inside the sandbox as a smoke test. +# Manifest: packaging/linux/flatpak/ai.storyteller.pdfcraft.bundle.yml. +set -euo pipefail +# shellcheck source=../env.sh +. "$(dirname "${BASH_SOURCE[0]}")/../env.sh" +HERE="$ROOT/packaging/linux" +APP_ID=ai.storyteller.pdfcraft +FLATHUB=https://dl.flathub.org/repo/flathub.flatpakrepo + +TEST=1 +TARBALL="" +while [ $# -gt 0 ]; do + case "$1" in + --no-test) TEST=0; shift ;; + -h | --help) sed -n '2,14p' "$0"; exit 0 ;; + -*) echo "unknown argument: $1" >&2; exit 2 ;; + *) TARBALL="$1"; shift ;; + esac +done + +ARCH="$(uname -m)" +case "$ARCH" in + x86_64) ;; + aarch64 | arm64) ARCH=aarch64 ;; + *) echo "unsupported architecture $ARCH" >&2; exit 2 ;; +esac +BASENAME="pdfcraft-$VERSION-linux-$ARCH" +TARBALL="${TARBALL:-$DIST/$BASENAME.tar.gz}" +[ -f "$TARBALL" ] || { echo "error: $TARBALL not found (run packaging/linux/package.sh --formats tar first)" >&2; exit 1; } +for tool in flatpak flatpak-builder; do + command -v "$tool" >/dev/null || { echo "error: $tool not found (apt install flatpak flatpak-builder librsvg2-common)" >&2; exit 1; } +done + +echo "==> PdfCraft $VERSION Flatpak bundle for $ARCH from $(basename "$TARBALL")" + +WORK="$CARGO_TARGET_DIR/flatpak-bundle" +rm -rf "$WORK" +mkdir -p "$WORK/stage" +tar -xzf "$TARBALL" -C "$WORK/stage" --strip-components=1 +[ -x "$WORK/stage/bin/pdfcraft" ] || { echo "error: $TARBALL has no bin/pdfcraft" >&2; exit 1; } +cp "$HERE/flatpak/$APP_ID.bundle.yml" "$WORK/$APP_ID.yml" + +flatpak remote-add --user --if-not-exists flathub "$FLATHUB" +# --disable-rofiles-fuse: no FUSE in containers and CI runners. +flatpak-builder --user --install-deps-from=flathub --disable-rofiles-fuse --force-clean \ + --default-branch=stable --repo="$WORK/repo" --state-dir="$WORK/state" "$WORK/build" "$WORK/$APP_ID.yml" + +OUT="$DIST/$BASENAME.flatpak" +# --runtime-repo lets `flatpak install` fetch the freedesktop runtime from Flathub if missing. +flatpak build-bundle --runtime-repo="$FLATHUB" "$WORK/repo" "$OUT" "$APP_ID" stable +echo "wrote $OUT" + +if [ "$TEST" = 1 ]; then + flatpak install --user -y --noninteractive --reinstall "$OUT" + flatpak info --user "$APP_ID" + flatpak run --command=pdfcraft-cli "$APP_ID" --version + flatpak run --command=sh "$APP_ID" -c 'ls /app/share/applications /app/share/metainfo /app/share/mime/packages /app/share/icons/hicolor/scalable/apps' + # Informational: printing runs lp/lpstat, which the freedesktop runtime doesn't ship (see the + # manifest's finish-args). Says so if a runtime update ever adds them. + flatpak run --command=sh "$APP_ID" -c 'command -v lp lpstat' || echo "note: no lp/lpstat in the runtime, so printing is unavailable in the Flatpak" +fi +echo "==> done" +ls -lh "$OUT" diff --git a/packaging/linux/flatpak/ai.storyteller.pdfcraft.bundle.yml b/packaging/linux/flatpak/ai.storyteller.pdfcraft.bundle.yml new file mode 100644 index 000000000..05e951670 --- /dev/null +++ b/packaging/linux/flatpak/ai.storyteller.pdfcraft.bundle.yml @@ -0,0 +1,52 @@ +# Flatpak manifest for the single-file bundle attached to every GitHub release +# (pdfcraft--linux-.flatpak). Build it with packaging/linux/flatpak-bundle.sh. +# +# It repackages the release's own Linux tarball (pdfcraft--linux-.tar.gz, built on +# Ubuntu 22.04 by package.sh) instead of compiling Rust inside flatpak-builder: no network and no +# vendored crate sources during the build, a few seconds instead of 20+ minutes, and byte-for-byte +# the same binaries as the AppImage/deb/rpm. The script unpacks the tarball into `stage/` next to a +# copy of this file. The binaries need glibc >= 2.35 and load X11, Wayland, xkbcommon and Vulkan +# at runtime; the freedesktop runtime has all of them, and the GPU driver comes from its +# org.freedesktop.Platform.GL extension. +# +# ai.storyteller.pdfcraft.yml (same directory) is the from-source manifest for Flathub. Keep +# runtime-version and finish-args identical in both (packaging-lint checks this). +id: ai.storyteller.pdfcraft +runtime: org.freedesktop.Platform +runtime-version: '25.08' +sdk: org.freedesktop.Sdk +command: pdfcraft +finish-args: + # Display: Wayland first; X11 only when no Wayland compositor is running. + - --socket=wayland + - --socket=fallback-x11 + # X11 shared memory (MIT-SHM). Without it the X11 fallback is slow or fails. + - --share=ipc + # GPU access for the wgpu renderer (Vulkan, or GL as a fallback). + - --device=dri + # Open/Save dialogs go through the file-chooser portal (rfd's xdg-portal backend) and + # drag-and-drop through the document portal, so picked files work anywhere without broad + # filesystem access. Documents and Downloads, where PDFs usually live, are granted so files + # passed by path (the command line, Open Recent, "Save" next to the original) work there. + - --filesystem=xdg-documents + - --filesystem=xdg-download + # Deliberately not granted: network (Flatpak installs update through flatpak, so Help ▸ Check + # for updates reports that GitHub is unreachable; the optional --control channel listens on + # 127.0.0.1 inside the sandbox) and home/host filesystem access. No CUPS socket either: printing + # runs the `lp` command (crates/print), which the freedesktop runtime doesn't ship, so Print + # reports that the spooler is unavailable until it goes through the print portal. +modules: + - name: pdfcraft + buildsystem: simple + build-commands: + - install -Dm755 bin/pdfcraft /app/bin/pdfcraft + - install -Dm755 bin/pdfcraft-cli /app/bin/pdfcraft-cli + - install -Dm644 share/applications/ai.storyteller.pdfcraft.desktop /app/share/applications/ai.storyteller.pdfcraft.desktop + - install -Dm644 share/mime/packages/ai.storyteller.pdfcraft.xml /app/share/mime/packages/ai.storyteller.pdfcraft.xml + # Already has the release's version and date substituted by package.sh. + - install -Dm644 share/metainfo/ai.storyteller.pdfcraft.metainfo.xml /app/share/metainfo/ai.storyteller.pdfcraft.metainfo.xml + # Licences, including the embedded craft-fonts' OFL texts. + - mkdir -p /app/share/icons /app/share/doc && cp -R share/icons/hicolor /app/share/icons/ && cp -R share/doc/pdfcraft /app/share/doc/ + sources: + - type: dir + path: stage diff --git a/packaging/linux/flatpak/ai.storyteller.pdfcraft.yml b/packaging/linux/flatpak/ai.storyteller.pdfcraft.yml index c2ba3b8c2..b3b9c5384 100644 --- a/packaging/linux/flatpak/ai.storyteller.pdfcraft.yml +++ b/packaging/linux/flatpak/ai.storyteller.pdfcraft.yml @@ -8,6 +8,8 @@ # flatpak run ai.storyteller.pdfcraft # # For Flathub, replace the `dir` source with a `git` source pinned to a release tag and commit. +# The single-file .flatpak attached to each release comes from ai.storyteller.pdfcraft.bundle.yml, +# which repackages the prebuilt release binaries. Keep runtime-version and finish-args identical. id: ai.storyteller.pdfcraft runtime: org.freedesktop.Platform runtime-version: '25.08' @@ -16,14 +18,24 @@ sdk-extensions: - org.freedesktop.Sdk.Extension.rust-stable command: pdfcraft finish-args: - - --share=ipc + # Display: Wayland first; X11 only when no Wayland compositor is running. - --socket=wayland - --socket=fallback-x11 + # X11 shared memory (MIT-SHM). Without it the X11 fallback is slow or fails. + - --share=ipc + # GPU access for the wgpu renderer (Vulkan, or GL as a fallback). - --device=dri - # Open/Save dialogs use the file-chooser portal (rfd), and drag-and-drop uses the document - # portal, so broad filesystem access isn't needed. Pictures is granted for opening files by - # path from the command line. - - --filesystem=xdg-pictures + # Open/Save dialogs go through the file-chooser portal (rfd's xdg-portal backend) and + # drag-and-drop through the document portal, so picked files work anywhere without broad + # filesystem access. Documents and Downloads, where PDFs usually live, are granted so files + # passed by path (the command line, Open Recent, "Save" next to the original) work there. + - --filesystem=xdg-documents + - --filesystem=xdg-download + # Deliberately not granted: network (Flatpak installs update through flatpak, so Help ▸ Check + # for updates reports that GitHub is unreachable; the optional --control channel listens on + # 127.0.0.1 inside the sandbox) and home/host filesystem access. No CUPS socket either: printing + # runs the `lp` command (crates/print), which the freedesktop runtime doesn't ship, so Print + # reports that the spooler is unavailable until it goes through the print portal. build-options: append-path: /usr/lib/sdk/rust-stable/bin modules: diff --git a/packaging/linux/package.sh b/packaging/linux/package.sh index 4a57b4817..ae0166e20 100755 --- a/packaging/linux/package.sh +++ b/packaging/linux/package.sh @@ -2,6 +2,7 @@ # Build and package PdfCraft for Linux ( is x86_64 or aarch64): # # $DIST/pdfcraft--linux-.AppImage any distro with glibc >= the build host's +# $DIST/pdfcraft--linux-.AppImage.zsync delta updates (needs zsyncmake) # $DIST/pdfcraft--linux-.deb Debian, Ubuntu, Mint, Pop!_OS, ... # $DIST/pdfcraft--linux-.rpm Fedora, openSUSE, RHEL, ... # $DIST/pdfcraft--linux-.tar.gz plain FHS-style tree (bin/, share/) @@ -10,7 +11,8 @@ # # Needs: cargo; nfpm for deb/rpm (https://nfpm.goreleaser.com); appimagetool for the AppImage # (downloaded into $CARGO_TARGET_DIR if missing). Build on an old distro (CI: Ubuntu 22.04, -# glibc 2.35) so the binaries run on newer ones. Optional: desktop-file-validate, appstreamcli. +# glibc 2.35) so the binaries run on newer ones. Optional: desktop-file-validate, appstreamcli, +# zsyncmake (the zsync package) for the AppImage's .zsync. set -euo pipefail # shellcheck source=../env.sh . "$(dirname "${BASH_SOURCE[0]}")/../env.sh" @@ -108,11 +110,29 @@ if has appimage; then chmod +x "$TOOL" fi fi - OUT="$DIST/$BASENAME.AppImage" + # Absolute, because appimagetool runs in $DIST below (CARGO_TARGET_DIR or APPIMAGETOOL may be + # relative, e.g. target/agent-). + OUT="$(cd "$DIST" && pwd)/$BASENAME.AppImage" + APPDIR="$(cd "$APPDIR" && pwd)" + TOOL="$(cd "$(dirname "$TOOL")" && pwd)/$(basename "$TOOL")" + # A .zsync left by an earlier run would hide a missing zsyncmake and describe another file. + rm -f "$OUT.zsync" + # Update information: AppImageUpdate, AppImageLauncher and the like read it from the file and + # fetch only the blocks that changed in a newer release, through the .zsync published next to + # each AppImage on GitHub Releases. `latest` is the newest published release that is not a + # pre-release. A fork's builds point at its own releases through GITHUB_REPOSITORY. + REPO="${GITHUB_REPOSITORY:-storytold/pdfcraft}" + UPDATE_INFO="gh-releases-zsync|${REPO%%/*}|${REPO#*/}|latest|pdfcraft-*-linux-$ARCH.AppImage.zsync" # Extract-and-run: works without FUSE (containers, CI). The output embeds the static runtime, - # so users don't need libfuse2 either. - ARCH="$ARCH" APPIMAGE_EXTRACT_AND_RUN=1 "$TOOL" --no-appstream "$APPDIR" "$OUT" + # so users don't need libfuse2 either. With zsyncmake on the host (CI installs the zsync + # package) appimagetool also writes the .zsync, into its working directory, hence the cd. + (cd "$DIST" && ARCH="$ARCH" APPIMAGE_EXTRACT_AND_RUN=1 "$TOOL" --no-appstream -u "$UPDATE_INFO" "$APPDIR" "$OUT") echo "wrote $OUT" + if [ -s "$OUT.zsync" ]; then + echo "wrote $OUT.zsync" + else + warn "zsyncmake not found, so $OUT.zsync was not written; AppImage delta updates need it" + fi fi "$STAGE/usr/bin/pdfcraft-cli" --version