From f232de08a8fa8b18cf02ed6907c95889576668d1 Mon Sep 17 00:00:00 2001 From: Benoit de Chezelles Date: Sun, 2 Aug 2026 17:41:28 +0200 Subject: [PATCH] Unify & document flatpak distribution workflow (for local/release) --- ...org.wezfurlong.wezterm.LOCAL-TESTING.json} | 13 ++---- ....wezfurlong.wezterm.RELEASE-TEMPLATE.json} | 0 ...long.wezterm.appdata.RELEASE-TEMPLATE.xml} | 0 assets/wezterm.appdata.xml | 3 +- ci/flatpak-build.sh | 43 +++++++++++++++++++ ci/flatpak.sh | 23 ---------- ci/make-flathub-pr.sh | 26 ++++++++--- docs-internal/flatpak-distribution.md | 36 ++++++++++++++++ nix/flake.lock | 6 +-- nix/flake.nix | 5 +++ 10 files changed, 112 insertions(+), 43 deletions(-) rename assets/flatpak/{org.wezfurlong.wezterm.json => org.wezfurlong.wezterm.LOCAL-TESTING.json} (76%) rename assets/flatpak/{org.wezfurlong.wezterm.template.json => org.wezfurlong.wezterm.RELEASE-TEMPLATE.json} (100%) rename assets/flatpak/{org.wezfurlong.wezterm.appdata.template.xml => org.wezfurlong.wezterm.appdata.RELEASE-TEMPLATE.xml} (100%) create mode 100755 ci/flatpak-build.sh delete mode 100755 ci/flatpak.sh create mode 100644 docs-internal/flatpak-distribution.md diff --git a/assets/flatpak/org.wezfurlong.wezterm.json b/assets/flatpak/org.wezfurlong.wezterm.LOCAL-TESTING.json similarity index 76% rename from assets/flatpak/org.wezfurlong.wezterm.json rename to assets/flatpak/org.wezfurlong.wezterm.LOCAL-TESTING.json index 171bfc99e..4354ef7e0 100644 --- a/assets/flatpak/org.wezfurlong.wezterm.json +++ b/assets/flatpak/org.wezfurlong.wezterm.LOCAL-TESTING.json @@ -18,14 +18,12 @@ "--talk-name=org.freedesktop.Notifications", "--share=network" ], - "build-options": { - "append-path" : "/usr/lib/sdk/rust-stable/bin" - }, "modules": [ { "name": "wezterm", "buildsystem": "simple", "build-options": { + "append-path" : "/usr/lib/sdk/rust-stable/bin", "env": { "CARGO_HOME": "/run/build/wezterm/cargo" } @@ -33,12 +31,9 @@ "build-commands": [ "cargo --offline fetch --manifest-path Cargo.toml --verbose", "cargo --offline build --release --verbose", - "mkdir -p /app/share/icons/hicolor/128x128/apps/", - "cp ./assets/icon/terminal.png /app/share/icons/hicolor/128x128/apps/org.wezfurlong.wezterm.png", - "mkdir -p /app/share/metainfo/", - "cp ./assets/wezterm.appdata.xml /app/share/metainfo/org.wezfurlong.wezterm.appdata.xml", - "mkdir -p /app/share/applications/", - "cp ./assets/wezterm.desktop /app/share/applications/org.wezfurlong.wezterm.desktop", + "install -Dm644 ./assets/icon/terminal.png /app/share/icons/hicolor/128x128/apps/org.wezfurlong.wezterm.png", + "install -Dm644 ./assets/wezterm.appdata.xml /app/share/metainfo/org.wezfurlong.wezterm.appdata.xml", + "install -Dm644 ./assets/wezterm.desktop /app/share/applications/org.wezfurlong.wezterm.desktop", "install -Dm755 ./target/release/wezterm -t /app/bin/", "install -Dm755 ./target/release/wezterm-gui -t /app/bin/", "install -Dm755 ./target/release/wezterm-mux-server -t /app/bin/", diff --git a/assets/flatpak/org.wezfurlong.wezterm.template.json b/assets/flatpak/org.wezfurlong.wezterm.RELEASE-TEMPLATE.json similarity index 100% rename from assets/flatpak/org.wezfurlong.wezterm.template.json rename to assets/flatpak/org.wezfurlong.wezterm.RELEASE-TEMPLATE.json diff --git a/assets/flatpak/org.wezfurlong.wezterm.appdata.template.xml b/assets/flatpak/org.wezfurlong.wezterm.appdata.RELEASE-TEMPLATE.xml similarity index 100% rename from assets/flatpak/org.wezfurlong.wezterm.appdata.template.xml rename to assets/flatpak/org.wezfurlong.wezterm.appdata.RELEASE-TEMPLATE.xml diff --git a/assets/wezterm.appdata.xml b/assets/wezterm.appdata.xml index 237bef220..fdfa5fd4e 100644 --- a/assets/wezterm.appdata.xml +++ b/assets/wezterm.appdata.xml @@ -70,7 +70,8 @@ Wez Furlong - + +

Featuring more powerful key and mouse bindings, new lua functions for diff --git a/ci/flatpak-build.sh b/ci/flatpak-build.sh new file mode 100755 index 000000000..1261a0555 --- /dev/null +++ b/ci/flatpak-build.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +set -xeu + +if ! [[ -f Cargo.lock ]]; then + >&2 echo "ERROR: This script should be called from repo root!" + exit 1 +fi + +# Add flathub repo if not available +flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + +# Install SDK & Platform flatpak components +# NOTE: We install specific version of those components, make sure it corresponds with the +# runtime-version used in ../assets/flatpak/org.wezfurlong.wezterm.LOCAL-TESTING.json +flatpak install --user --noninteractive flathub \ + org.freedesktop.Platform//23.08 \ + org.freedesktop.Sdk//23.08 \ + org.freedesktop.Sdk.Extension.rust-stable//23.08 + +# Disabled for now: seems like it has an OpenSSL problem and fails to use SSL when +# validating the screenshot URLs +#flatpak install --user --noninteractive org.freedesktop.appstream-glib +#flatpak run --env=G_DEBUG=fatal-criticals org.freedesktop.appstream-glib validate assets/wezterm.appdata.xml + +# Generate list of cargo dependencies for the isolated flatpak build +if command -v flatpak-cargo-generator &>/dev/null; then + fcg_bin=(flatpak-cargo-generator) +else + python3 -m pip install toml aiohttp + curl -L 'https://github.com/flatpak/flatpak-builder-tools/raw/master/cargo/flatpak-cargo-generator.py' > /tmp/flatpak-cargo-generator.py + fcg_bin=(python3 /tmp/flatpak-cargo-generator.py) +fi +"${fcg_bin[@]}" Cargo.lock -o assets/flatpak/generated-sources.json + +# Build & install the flatpak locally +# NOTE: Disabled in CI +if [ "${CI:-}" != "yes" ] ; then + flatpak-builder \ + --state-dir /var/tmp/wezterm-flatpak-builder \ + --install /var/tmp/wezterm-flatpak-repo \ + assets/flatpak/org.wezfurlong.wezterm.LOCAL-TESTING.json \ + --user --force-clean -y +fi diff --git a/ci/flatpak.sh b/ci/flatpak.sh deleted file mode 100755 index 2d84f4c83..000000000 --- a/ci/flatpak.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -set -xe - -flatpak remote-add --if-not-exists --user flathub https://flathub.org/repo/flathub.flatpakrepo -flatpak install --noninteractive --user flathub org.freedesktop.Platform//23.08 org.freedesktop.Sdk//23.08 org.freedesktop.Sdk.Extension.rust-stable//23.08 - -flatpak install --noninteractive --user org.freedesktop.appstream-glib - -# Disabled for now: seems like it has an OpenSSL problem and fails to use SSL when -# validating the screenshot URLs -#flatpak run --env=G_DEBUG=fatal-criticals org.freedesktop.appstream-glib validate assets/wezterm.appdata.xml - -python3 -m pip install toml aiohttp -curl -L 'https://github.com/flatpak/flatpak-builder-tools/raw/master/cargo/flatpak-cargo-generator.py' > /tmp/flatpak-cargo-generator.py -python3 /tmp/flatpak-cargo-generator.py Cargo.lock -o assets/flatpak/generated-sources.json - -if [ "${CI}" != "yes" ] ; then - flatpak-builder \ - --state-dir /var/tmp/wezterm-flatpak-builder \ - --install /var/tmp/wezterm-flatpak-repo \ - assets/flatpak/org.wezfurlong.wezterm.json \ - --force-clean --user -y -fi diff --git a/ci/make-flathub-pr.sh b/ci/make-flathub-pr.sh index 1ad03db79..0089c674b 100755 --- a/ci/make-flathub-pr.sh +++ b/ci/make-flathub-pr.sh @@ -1,10 +1,22 @@ -#!/bin/bash -set -xe +#!/usr/bin/env bash +set -xeu + +if ! [[ -f Cargo.lock ]]; then + >&2 echo "ERROR: This script should be called from repo root!" + exit 1 +fi + TAG_NAME=$(ci/tag-name.sh) -python3 -m pip install toml aiohttp -curl -L 'https://github.com/flatpak/flatpak-builder-tools/raw/master/cargo/flatpak-cargo-generator.py' > /tmp/flatpak-cargo-generator.py -python3 /tmp/flatpak-cargo-generator.py Cargo.lock -o flathub/generated-sources.json +# Generate list of cargo dependencies for the isolated flatpak build +if command -v flatpak-cargo-generator &>/dev/null; then + fcg_bin=(flatpak-cargo-generator) +else + python3 -m pip install toml aiohttp + curl -L 'https://github.com/flatpak/flatpak-builder-tools/raw/master/cargo/flatpak-cargo-generator.py' > /tmp/flatpak-cargo-generator.py + fcg_bin=(python3 /tmp/flatpak-cargo-generator.py) +fi +"${fcg_bin[@]}" Cargo.lock -o assets/flatpak/generated-sources.json URL="https://github.com/wezterm/wezterm/releases/download/${TAG_NAME}/wezterm-${TAG_NAME}-src.tar.gz" @@ -12,10 +24,10 @@ URL="https://github.com/wezterm/wezterm/releases/download/${TAG_NAME}/wezterm-${ # in the current dir. This is handled by actions/download-artifact in CI SHA256=$(sha256sum wezterm*-src.tar.gz | cut -d' ' -f1) -sed -e "s,@URL@,$URL,g" -e "s/@SHA256@/$SHA256/g" < assets/flatpak/org.wezfurlong.wezterm.template.json > flathub/org.wezfurlong.wezterm.json +sed -e "s,@URL@,$URL,g" -e "s/@SHA256@/$SHA256/g" < assets/flatpak/org.wezfurlong.wezterm.RELEASE-TEMPLATE.json > flathub/org.wezfurlong.wezterm.json RELEASE_DATE=$(git -c "core.abbrev=8" show -s "--format=%cd" "--date=format:%Y-%m-%d") -sed -e "s,@TAG_NAME@,$TAG_NAME,g" -e "s/@DATE@/$RELEASE_DATE/g" < assets/flatpak/org.wezfurlong.wezterm.appdata.template.xml > flathub/org.wezfurlong.wezterm.appdata.xml +sed -e "s,@TAG_NAME@,$TAG_NAME,g" -e "s/@DATE@/$RELEASE_DATE/g" < assets/flatpak/org.wezfurlong.wezterm.appdata.RELEASE-TEMPLATE.xml > flathub/org.wezfurlong.wezterm.appdata.xml cd flathub git config user.email wez@wezfurlong.org diff --git a/docs-internal/flatpak-distribution.md b/docs-internal/flatpak-distribution.md new file mode 100644 index 000000000..68e102023 --- /dev/null +++ b/docs-internal/flatpak-distribution.md @@ -0,0 +1,36 @@ +# Flatpak distribution + +## Release build + +For a release build, the flatpak definition is +`assets/flatpak/org.wezfurlong.wezterm.RELEASE-TEMPLATE.json` with metadata in +`assets/flatpak/org.wezfurlong.wezterm.appdata.RELEASE-TEMPLATE.xml`. + +A GHA workflow runs the `ci/flathub-prepare-pr.sh` script from repo root to prepare a few metadata +files, followed by opening a PR on the [flathub repo][flathub-repo] for the new version. + +Once merged, flathub builders will auto-schedule the actual build for later inclusion in the flathub +app catalog. This can be followed on . + +[flathub-repo]: https://github.com/flathub/org.wezfurlong.wezterm + +## Local build + +For a local build, the flatpak definition is in +`assets/flatpak/org.wezfurlong.wezterm.LOCAL-TESTING.json`. It is basically the same as the +release one but uses the local repo instead of a specific release from github. + +The script needs the following dependencies: + +- flatpak-cargo-generator (auto-downloaded if not in `$PATH`, needs python3 with pip) +- flatpak-builder +- appstreamcli + +> [!NOTE] +> If using Nix, `nix develop` gives you these automatically. + +Run `ci/flatpak-build.sh` from the repo root to prepare, build & install the flatpak for the current +user. Then run the built flatpak with `flatpak run org.wezfurlong.wezterm`. + +> [!NOTE] +> The script stores tmp data in `/var/tmp/wezterm-flatpak-*` directories. diff --git a/nix/flake.lock b/nix/flake.lock index 683a5d3c2..138ec7201 100644 --- a/nix/flake.lock +++ b/nix/flake.lock @@ -71,11 +71,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1783816212, - "narHash": "sha256-2aZisVTVGSFEk3MYcOiWQp3zvwyzbqpktB69Rcfp150=", + "lastModified": 1785602060, + "narHash": "sha256-z7D96eESRM4CPV/XtwpwFn8IDdfLAmxz6lVWrGYXvR4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3b32825de172d0bc85664f495edb096b10862524", + "rev": "a5cbcfe954791221bfffe2307f7d1a1bf61a871e", "type": "github" }, "original": { diff --git a/nix/flake.nix b/nix/flake.nix index 3dc04e7f8..4e6d60d4a 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -255,6 +255,11 @@ nightly.latest.rustfmt nightly.latest.rust-analyzer + + # For local flatpak build + pkgs.flatpak-builder + pkgs.flatpak-builder-tools # for flatpak-cargo-generator + pkgs.appstream ]); LD_LIBRARY_PATH = libPath;