From 8fe259dacd95e352dd8b846ec5e2d1161088f65a Mon Sep 17 00:00:00 2001 From: hazre Date: Wed, 22 Jul 2026 04:01:52 +0200 Subject: [PATCH] chore(scripts): replace fpm with nfpm for deb/rpm packaging - Add nfpm.yaml declarative config with contents, deps, per-packager overrides - Replace fpm CLI invocations in package.sh with nfpm pkg - Manage appimagetool and nfpm via mise file task tools - Remove manual appimagetool download + sha256 verification - Fix stale paths from scripts/cef/ move (ROOT, copy-libs reference, usage) - Add version extraction guard and appimagetool availability check Signed-off-by: hazre --- nfpm.yaml | 48 +++++++++++++++++++++++++++++ scripts/cef/package.sh | 70 +++++++++++++++++------------------------- 2 files changed, 76 insertions(+), 42 deletions(-) create mode 100644 nfpm.yaml diff --git a/nfpm.yaml b/nfpm.yaml new file mode 100644 index 000000000..8f44eab70 --- /dev/null +++ b/nfpm.yaml @@ -0,0 +1,48 @@ +# yaml-language-server: $schema=https://nfpm.goreleaser.com/schema.json + +name: sable +arch: amd64 +platform: linux +version: ${PKG_VERSION} +release: ${PKG_RELEASE} +version_schema: semver +section: net +maintainer: SableClient +description: Sable, a Matrix client +homepage: https://sable.moe + +contents: + - src: ${PKGROOT}/opt/sable/ + dst: /opt/sable + type: tree + - src: ${PKGROOT}/usr/ + dst: /usr + type: tree + +overrides: + deb: + depends: + - libgtk-3-0 + - libnss3 + - libnspr4 + - libgbm1 + - libdrm2 + - libxkbcommon0 + - libasound2 + - libcups2 + - xdg-utils + - xwayland + - libayatana-appindicator3-1 + rpm: + depends: + - gtk3 + - nss + - nspr + - mesa-libgbm + - libdrm + - libxkbcommon + - alsa-lib + - cups-libs + - xdg-utils + - xorg-x11-server-Xwayland + - libayatana-appindicator3.so.1()(64bit) diff --git a/scripts/cef/package.sh b/scripts/cef/package.sh index 440d48644..0523d777f 100644 --- a/scripts/cef/package.sh +++ b/scripts/cef/package.sh @@ -1,13 +1,15 @@ #!/usr/bin/env bash #MISE description="Package CEF build into deb/rpm/AppImage" +#MISE tools={nfpm="2.47.0", "github:AppImage/appimagetool" = {version = "1.9.1", matching = ".AppImage"}} # Package the Linux CEF build into deb/rpm/AppImage. Used by CI and locally. # Run after the binary is built (pnpm tauri:cef build). -# Usage: scripts/cef-package.sh [version] +# Usage: scripts/cef/package.sh [version] set -euo pipefail -ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" cd "$ROOT" VERSION="${1:-$(grep -m1 '"version":' src-tauri/tauri.conf.json | sed 's/.*: *"\(.*\)".*/\1/')}" +: "${VERSION:?version not found in src-tauri/tauri.conf.json}" DEB_VERSION="$VERSION" RPM_VERSION="$VERSION" RPM_ITERATION=1 @@ -45,7 +47,7 @@ stage_runtime() { local dest="$1" mkdir -p "$dest" cp "$STAGE/$BIN_NAME" "$dest/sable" - bash scripts/cef-copy-libs.sh release "$dest" + bash scripts/cef/copy-libs.sh release "$dest" } # Bundle the system-tray libraries (Tauri's linuxdeploy path normally does this, @@ -87,8 +89,10 @@ MimeType=x-scheme-handler/sable;x-scheme-handler/moe.sable.app; EOF } -if command -v fpm >/dev/null 2>&1; then +CONFIG="$ROOT/nfpm.yaml" +if command -v nfpm >/dev/null 2>&1; then PKGROOT="$WORK/pkgroot" + export PKGROOT stage_runtime "$PKGROOT/opt/sable" mkdir -p "$PKGROOT/usr/bin" "$PKGROOT/usr/share/applications" cat > "$PKGROOT/usr/bin/sable" <<'EOF' @@ -102,57 +106,39 @@ EOF cp "src-tauri/icons/${size}.png" \ "$PKGROOT/usr/share/icons/hicolor/${size}/apps/sable.png" done - # 128x128@2x is 256x256 mkdir -p "$PKGROOT/usr/share/icons/hicolor/256x256/apps" cp "src-tauri/icons/128x128@2x.png" \ "$PKGROOT/usr/share/icons/hicolor/256x256/apps/sable.png" - COMMON=(-s dir -n sable - --description "Sable, a Matrix client" - --url "https://sable.moe" --maintainer "SableClient" - --category net) - # CEF deps: no WebKitGTK. ALSA/CUPS are NEEDED by libcef.so; - # xwayland because main.rs forces GDK_BACKEND=x11. - DEB_DEPS=(--depends libgtk-3-0 --depends libnss3 --depends libnspr4 - --depends libgbm1 --depends libdrm2 --depends libxkbcommon0 - --depends libasound2 --depends libcups2 --depends xdg-utils - --depends xwayland --depends libayatana-appindicator3-1) - (cd "$OUT/deb" && fpm "${COMMON[@]}" -v "$DEB_VERSION" --iteration 1 \ - -t deb -a amd64 -p "Sable-${VERSION}-linux-x86_64.deb" "${DEB_DEPS[@]}" -C "$PKGROOT" .) + PKG_VERSION="$DEB_VERSION" PKG_RELEASE=1 nfpm pkg -f "$CONFIG" -p deb \ + -t "$OUT/deb/Sable-${VERSION}-linux-x86_64.deb" - RPM_DEPS=(--depends gtk3 --depends nss --depends nspr - --depends mesa-libgbm --depends libdrm --depends libxkbcommon - --depends alsa-lib --depends cups-libs --depends xdg-utils - --depends xorg-x11-server-Xwayland - --depends 'libayatana-appindicator3.so.1()(64bit)') - (cd "$OUT/rpm" && fpm "${COMMON[@]}" -v "$RPM_VERSION" --iteration "$RPM_ITERATION" \ - -t rpm -a x86_64 -p "Sable-${VERSION}-linux-x86_64.rpm" "${RPM_DEPS[@]}" -C "$PKGROOT" .) + PKG_VERSION="$RPM_VERSION" PKG_RELEASE="$RPM_ITERATION" nfpm pkg -f "$CONFIG" -p rpm \ + -t "$OUT/rpm/Sable-${VERSION}-linux-x86_64.rpm" else - echo "fpm not found; skipping deb/rpm (building AppImage only)" + echo "nfpm not found; skipping deb/rpm" fi -APPDIR="$WORK/Sable.AppDir" -stage_runtime "$APPDIR/usr/bin" -stage_appindicator "$APPDIR/usr/bin" -# nosuid AppImage mount: drop setuid chrome-sandbox, use the namespace sandbox. -rm -f "$APPDIR/usr/bin/chrome-sandbox" -write_desktop "$APPDIR/sable.desktop" -cp src-tauri/icons/128x128.png "$APPDIR/sable.png" -cat > "$APPDIR/AppRun" <<'EOF' +if command -v appimagetool >/dev/null 2>&1; then + APPDIR="$WORK/Sable.AppDir" + stage_runtime "$APPDIR/usr/bin" + stage_appindicator "$APPDIR/usr/bin" + # nosuid AppImage mount: drop setuid chrome-sandbox, use the namespace sandbox. + rm -f "$APPDIR/usr/bin/chrome-sandbox" + write_desktop "$APPDIR/sable.desktop" + cp src-tauri/icons/128x128.png "$APPDIR/sable.png" + cat > "$APPDIR/AppRun" <<'EOF' #!/bin/sh HERE="$(dirname "$(readlink -f "$0")")" export LD_LIBRARY_PATH="$HERE/usr/bin${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" exec "$HERE/usr/bin/sable" "$@" EOF -chmod 755 "$APPDIR/AppRun" + chmod 755 "$APPDIR/AppRun" -APPIMAGETOOL_SHA256=ed4ce84f0d9caff66f50bcca6ff6f35aae54ce8135408b3fa33abfc3cb384eb0 -APPIMAGETOOL="$WORK/appimagetool" -curl -fsSL -o "$APPIMAGETOOL" \ - https://github.com/AppImage/appimagetool/releases/download/1.9.1/appimagetool-x86_64.AppImage -echo "${APPIMAGETOOL_SHA256} $APPIMAGETOOL" | sha256sum -c - -chmod +x "$APPIMAGETOOL" -APPIMAGE_EXTRACT_AND_RUN=1 ARCH=x86_64 "$APPIMAGETOOL" "$APPDIR" \ - "$OUT/appimage/Sable-${VERSION}-linux-x86_64.AppImage" + ARCH=x86_64 appimagetool "$APPDIR" \ + "$OUT/appimage/Sable-${VERSION}-linux-x86_64.AppImage" +else + echo "appimagetool not found; skipping AppImage" >&2 +fi echo "Packages in: $OUT"