From cd56cc69d8cc90d3325faca92f5c2d1c28cead53 Mon Sep 17 00:00:00 2001 From: kev1n77 Date: Thu, 19 Nov 2026 09:24:22 +0800 Subject: [PATCH 1/5] fix(ci): build Linux desktop packages on Ubuntu 22.04 Use the glibc 2.35 baseline for release and nightly builds and verify the Linux packages before upload. Refs openBitFun/OpenBitFun#3767 --- .github/workflows/desktop-package.yml | 81 ++++++++++------------ .github/workflows/nightly-artifacts.yml | 81 ++++++++++------------ scripts/check-github-config.test.mjs | 22 ++++++ scripts/ci/check-glibc-floor.sh | 39 +++++------ scripts/ci/classify-build-impact.mjs | 3 +- scripts/ci/classify-build-impact.test.mjs | 11 ++- scripts/ci/verify-appimage-fcitx.sh | 43 ------------ scripts/ci/verify-linux-desktop-package.sh | 70 +++++++++++++++++++ scripts/desktop-package-platforms.json | 2 +- src/apps/desktop/tauri.conf.json | 2 +- 10 files changed, 194 insertions(+), 160 deletions(-) delete mode 100644 scripts/ci/verify-appimage-fcitx.sh create mode 100755 scripts/ci/verify-linux-desktop-package.sh diff --git a/.github/workflows/desktop-package.yml b/.github/workflows/desktop-package.yml index bf73ff0a39..bb05a3df51 100644 --- a/.github/workflows/desktop-package.yml +++ b/.github/workflows/desktop-package.yml @@ -196,6 +196,8 @@ jobs: package: name: Package (${{ matrix.platform.name }}) runs-on: ${{ matrix.platform.os }} + # Compile and bundle with Ubuntu 22.04's glibc on both Linux architectures. + container: ${{ startsWith(matrix.platform.name, 'linux-') && 'ubuntu:22.04' || '' }} needs: prepare if: needs.prepare.outputs.relay_image_only != 'true' && !inputs.artifact_run_ids && !inputs.verification_recovery_run_id env: @@ -218,6 +220,24 @@ jobs: platform: ${{ fromJSON(needs.prepare.outputs.package_matrix) }} steps: + - name: Install Linux desktop build dependencies + if: runner.os == 'Linux' + shell: bash + env: + DEBIAN_FRONTEND: noninteractive + run: | + apt-get update + # linuxdeploy needs the fcitx5 GTK3 module when it builds the AppImage. + apt-get install -y --no-install-recommends \ + build-essential ca-certificates clang cmake curl file git jq \ + libclang-dev pkg-config python3 unzip xz-utils \ + xdg-utils libglib2.0-dev libgtk-3-dev libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev gstreamer1.0-pipewire \ + gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ + fcitx5-frontend-gtk3 libxdo-dev libwebkit2gtk-4.1-dev \ + libayatana-appindicator3-dev librsvg2-dev patchelf fakeroot rpm \ + libleptonica-dev libtesseract-dev tesseract-ocr tesseract-ocr-eng + # Also preserve bytes when rebuilding an older immutable tag that does # not yet pin every hashed source file in .gitattributes. - name: Preserve source bytes on Windows @@ -279,49 +299,6 @@ jobs: where.exe makensis makensis /VERSION - - name: Install Linux system dependencies (Tauri bundler) - if: runner.os == 'Linux' - shell: bash - run: | - sudo apt-get update - - if apt-cache show libwebkit2gtk-4.1-dev >/dev/null 2>&1; then - WEBKIT_PKG=libwebkit2gtk-4.1-dev - else - WEBKIT_PKG=libwebkit2gtk-4.0-dev - fi - - if apt-cache show libappindicator3-dev >/dev/null 2>&1; then - APPINDICATOR_PKG=libappindicator3-dev - else - APPINDICATOR_PKG=libayatana-appindicator3-dev - fi - - # Tauri pins AppImage GTK input methods to its bundled cache, so the - # fcitx5 GTK3 bridge must be present before linuxdeploy builds it. - sudo apt-get install -y --no-install-recommends \ - pkg-config \ - xdg-utils \ - libglib2.0-dev \ - libgtk-3-dev \ - libgstreamer1.0-dev \ - libgstreamer-plugins-base1.0-dev \ - gstreamer1.0-pipewire \ - gstreamer1.0-plugins-base \ - gstreamer1.0-plugins-good \ - fcitx5-frontend-gtk3 \ - libxdo-dev \ - "$WEBKIT_PKG" \ - "$APPINDICATOR_PKG" \ - librsvg2-dev \ - patchelf \ - fakeroot \ - rpm \ - libleptonica-dev \ - libtesseract-dev \ - tesseract-ocr \ - tesseract-ocr-eng - - name: Setup pnpm uses: pnpm/action-setup@v5 @@ -374,6 +351,7 @@ jobs: uses: swatinem/rust-cache@v2 with: shared-key: "package-v2-${{ matrix.platform.name }}" + key: ${{ startsWith(matrix.platform.name, 'linux-') && 'ubuntu-22.04' || '' }} cache-bin: false - name: Install dependencies @@ -480,10 +458,23 @@ jobs: | tar -x -C "$verification_dir" bash "$verification_dir/scripts/ci/verify-macos-signing.sh" "${{ matrix.platform.target }}" - - name: Verify AppImage fcitx5 GTK module + - name: Verify Linux desktop package if: runner.os == 'Linux' shell: bash - run: bash scripts/ci/verify-appimage-fcitx.sh "${{ matrix.platform.target }}" + env: + WORKFLOW_SHA: ${{ github.workflow_sha }} + TARGET: ${{ matrix.platform.target }} + run: | + set -euo pipefail + # Apply the current packaging checks when rebuilding an older tag. + verification_dir="$(mktemp -d)" + trap 'rm -rf "$verification_dir"' EXIT + if ! git cat-file -e "$WORKFLOW_SHA^{commit}"; then + git fetch --no-tags --depth=1 origin "$WORKFLOW_SHA" + fi + git archive "$WORKFLOW_SHA" scripts/ci/verify-linux-desktop-package.sh scripts/ci/check-glibc-floor.sh \ + | tar -x -C "$verification_dir" + bash "$verification_dir/scripts/ci/verify-linux-desktop-package.sh" "$TARGET" - name: Preserve macOS verification recovery bundles if: failure() && runner.os == 'macOS' && steps.apple_verification.outcome == 'failure' diff --git a/.github/workflows/nightly-artifacts.yml b/.github/workflows/nightly-artifacts.yml index b203245601..2d715a8872 100644 --- a/.github/workflows/nightly-artifacts.yml +++ b/.github/workflows/nightly-artifacts.yml @@ -66,7 +66,9 @@ jobs: package: name: Package (${{ matrix.platform }}) if: ${{ inputs.build_desktop_packages }} - runs-on: ${{ fromJSON('{"linux-x64":"ubuntu-latest","linux-arm64":"ubuntu-24.04-arm","macos-arm64":"macos-15","macos-x64":"macos-15-intel","windows-x64":"windows-latest"}')[matrix.platform] }} + runs-on: ${{ fromJSON('{"linux-x64":"ubuntu-24.04","linux-arm64":"ubuntu-24.04-arm","macos-arm64":"macos-15","macos-x64":"macos-15-intel","windows-x64":"windows-latest"}')[matrix.platform] }} + # Use the same Linux build environment as Desktop Package. + container: ${{ startsWith(matrix.platform, 'linux-') && 'ubuntu:22.04' || '' }} env: NODE_OPTIONS: --max-old-space-size=6144 OPENBITFUN_RELEASE_CHANNEL: nightly @@ -85,52 +87,27 @@ jobs: platform: ${{ fromJSON(inputs.desktop_platforms) }} steps: - - uses: actions/checkout@v5 - with: - ref: ${{ inputs.checkout_ref }} - - - name: Install Linux system dependencies (Tauri bundler) + - name: Install Linux desktop build dependencies if: runner.os == 'Linux' shell: bash + env: + DEBIAN_FRONTEND: noninteractive run: | - sudo apt-get update + apt-get update + # linuxdeploy needs the fcitx5 GTK3 module when it builds the AppImage. + apt-get install -y --no-install-recommends \ + build-essential ca-certificates clang cmake curl file git jq \ + libclang-dev pkg-config python3 unzip xz-utils \ + xdg-utils libglib2.0-dev libgtk-3-dev libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev gstreamer1.0-pipewire \ + gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ + fcitx5-frontend-gtk3 libxdo-dev libwebkit2gtk-4.1-dev \ + libayatana-appindicator3-dev librsvg2-dev patchelf fakeroot rpm \ + libleptonica-dev libtesseract-dev tesseract-ocr tesseract-ocr-eng - if apt-cache show libwebkit2gtk-4.1-dev >/dev/null 2>&1; then - WEBKIT_PKG=libwebkit2gtk-4.1-dev - else - WEBKIT_PKG=libwebkit2gtk-4.0-dev - fi - - if apt-cache show libappindicator3-dev >/dev/null 2>&1; then - APPINDICATOR_PKG=libappindicator3-dev - else - APPINDICATOR_PKG=libayatana-appindicator3-dev - fi - - # Tauri pins AppImage GTK input methods to its bundled cache, so the - # fcitx5 GTK3 bridge must be present before linuxdeploy builds it. - sudo apt-get install -y --no-install-recommends \ - pkg-config \ - xdg-utils \ - libglib2.0-dev \ - libgtk-3-dev \ - libgstreamer1.0-dev \ - libgstreamer-plugins-base1.0-dev \ - gstreamer1.0-pipewire \ - gstreamer1.0-plugins-base \ - gstreamer1.0-plugins-good \ - fcitx5-frontend-gtk3 \ - libxdo-dev \ - "$WEBKIT_PKG" \ - "$APPINDICATOR_PKG" \ - librsvg2-dev \ - patchelf \ - fakeroot \ - rpm \ - libleptonica-dev \ - libtesseract-dev \ - tesseract-ocr \ - tesseract-ocr-eng + - uses: actions/checkout@v5 + with: + ref: ${{ inputs.checkout_ref }} - name: Setup pnpm uses: pnpm/action-setup@v5 @@ -185,6 +162,7 @@ jobs: uses: swatinem/rust-cache@v2 with: shared-key: "nightly-v3-${{ github.base_ref || github.ref_name }}-${{ matrix.platform }}" + key: ${{ startsWith(matrix.platform, 'linux-') && 'ubuntu-22.04' || '' }} cache-bin: false # A PR merge ref can never become a reusable base cache. Even a # trusted caller cannot override this guard. @@ -312,10 +290,23 @@ jobs: "${{ steps.macos-cli.outputs.archive }}" \ "${{ steps.macos-cli.outputs.checksum }}" - - name: Verify AppImage fcitx5 GTK module + - name: Verify Linux desktop package if: runner.os == 'Linux' shell: bash - run: bash scripts/ci/verify-appimage-fcitx.sh "${{ env.PACKAGE_TARGET }}" + env: + WORKFLOW_SHA: ${{ github.workflow_sha }} + TARGET: ${{ env.PACKAGE_TARGET }} + run: | + set -euo pipefail + # Apply the current packaging checks when rebuilding an older tag. + verification_dir="$(mktemp -d)" + trap 'rm -rf "$verification_dir"' EXIT + if ! git cat-file -e "$WORKFLOW_SHA^{commit}"; then + git fetch --no-tags --depth=1 origin "$WORKFLOW_SHA" + fi + git archive "$WORKFLOW_SHA" scripts/ci/verify-linux-desktop-package.sh scripts/ci/check-glibc-floor.sh \ + | tar -x -C "$verification_dir" + bash "$verification_dir/scripts/ci/verify-linux-desktop-package.sh" "$TARGET" # Keep output validation independent from artifact upload. PR callers do # not upload packages, but still need evidence that every selected diff --git a/scripts/check-github-config.test.mjs b/scripts/check-github-config.test.mjs index 70b5a4d33c..5b086ed382 100644 --- a/scripts/check-github-config.test.mjs +++ b/scripts/check-github-config.test.mjs @@ -1692,6 +1692,28 @@ test('stable and beta publication require every producer, while artifact-only ru }); +test('Desktop release and nightly package Linux on Ubuntu 22.04 and verify before upload', () => { + const readPackageJob = (file) => + yaml.parse(readFileSync(path.join(repoRoot, '.github/workflows', file), 'utf8')).jobs.package; + const release = readPackageJob('desktop-package.yml'); + const nightly = readPackageJob('nightly-artifacts.yml'); + const dependencies = (job) => job.steps.find((step) => step.name === 'Install Linux desktop build dependencies'); + + assert.equal(release.container, "${{ startsWith(matrix.platform.name, 'linux-') && 'ubuntu:22.04' || '' }}"); + assert.equal(nightly.container, "${{ startsWith(matrix.platform, 'linux-') && 'ubuntu:22.04' || '' }}"); + assert.equal(dependencies(release).run, dependencies(nightly).run); + + for (const job of [release, nightly]) { + const verify = job.steps.find((step) => step.name === 'Verify Linux desktop package'); + const buildIndex = job.steps.findIndex((step) => step.name === 'Build desktop app'); + const uploadIndex = job.steps.findIndex((step) => step.name === 'Upload bundles'); + assert.equal(verify.if, "runner.os == 'Linux'"); + assert.match(verify.run, /verify-linux-desktop-package\.sh/); + assert.ok(buildIndex >= 0 && buildIndex < job.steps.indexOf(verify)); + assert.ok(job.steps.indexOf(verify) < uploadIndex); + } +}); + test('Desktop recovery selects only one Mac target and cannot publish an incomplete release', (t) => { const workflow = yaml.parse(readFileSync(path.join(repoRoot, '.github/workflows/desktop-package.yml'), 'utf8')); const step = workflow.jobs.prepare.steps.find((entry) => entry.name === 'Select Desktop package platforms'); diff --git a/scripts/ci/check-glibc-floor.sh b/scripts/ci/check-glibc-floor.sh index 63eb3a5d25..89700d9c72 100755 --- a/scripts/ci/check-glibc-floor.sh +++ b/scripts/ci/check-glibc-floor.sh @@ -36,15 +36,17 @@ if ! command -v readelf >/dev/null 2>&1; then exit 2 fi -# Highest GLIBC_x.y this binary asks for; empty when it needs none. -# The trailing `|| true` matters: `grep` exits non-zero when a binary has no -# versioned glibc symbols at all (a static build), and under `set -e` that -# would abort the whole run at the command substitution below. +# Read version requirements only. A shared library can also define symbols. max_required_glibc() { - readelf -V "$1" 2>/dev/null | - grep -oE 'GLIBC_[0-9]+\.[0-9]+' | - sort -u -V | - tail -n 1 || true + LC_ALL=C readelf --version-info --wide "$1" | + awk ' + /^Version .* section / { needs = /^Version needs section / } + needs && match($0, /Name: GLIBC_[0-9]+\.[0-9]+(\.[0-9]+)?/) { + print substr($0, RSTART + length("Name: "), RLENGTH - length("Name: ")) + } + ' | + LC_ALL=C sort -u -V | + tail -n 1 } status=0 @@ -54,7 +56,11 @@ for bin in "$@"; do status=1 continue fi - required="$(max_required_glibc "$bin")" + if ! required="$(max_required_glibc "$bin")"; then + echo "ERROR: could not read ELF version information from $bin" >&2 + status=1 + continue + fi if [ -z "$required" ]; then echo "ok $(basename "$bin"): no versioned glibc requirement" continue @@ -63,24 +69,11 @@ for bin in "$@"; do # sort -V puts the larger version last: if that is not MAX, MAX was exceeded. highest="$(printf '%s\n%s\n' "$MAX" "$required" | sort -V | tail -n 1)" if [ "$highest" != "$MAX" ]; then - echo "FAIL $(basename "$bin"): requires glibc $required, above the $MAX floor" >&2 + echo "FAIL $bin: requires glibc $required, above the $MAX floor" >&2 status=1 else echo "ok $(basename "$bin"): requires glibc $required (floor $MAX)" fi done -if [ "$status" -ne 0 ]; then - cat >&2 < }), }, { - paths: ['scripts/ci/verify-appimage-fcitx.sh'], + paths: ['scripts/ci/verify-linux-desktop-package.sh'], result: expected({ rustRequired: true, desktopPlatforms: ['linux-x64', 'linux-arm64'], reason: 'platform-package-input', }), }, + { + paths: ['scripts/ci/check-glibc-floor.sh'], + result: expected({ + rustRequired: true, + desktopPlatforms: ['linux-x64', 'linux-arm64'], + linuxBinariesRequired: true, + reason: 'platform-package-input', + }), + }, ...[ 'scripts/prepare-flashgrep-resource.mjs', 'resources/flashgrep/VERSION.json', diff --git a/scripts/ci/verify-appimage-fcitx.sh b/scripts/ci/verify-appimage-fcitx.sh deleted file mode 100644 index d609dd27e7..0000000000 --- a/scripts/ci/verify-appimage-fcitx.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -target="${1:?usage: verify-appimage-fcitx.sh }" -bundle_dir="target/${target}/release/bundle/appimage" - -mapfile -t appimages < <(find "$bundle_dir" -maxdepth 1 -type f -name '*.AppImage' -print | sort) -if [[ ${#appimages[@]} -ne 1 ]]; then - echo "Expected exactly one AppImage in ${bundle_dir}, found ${#appimages[@]}" >&2 - exit 1 -fi - -appimage="$(realpath "${appimages[0]}")" -work_dir="$(mktemp -d)" -trap 'rm -rf "$work_dir"' EXIT - -( - cd "$work_dir" - chmod +x "$appimage" - "$appimage" --appimage-extract >/dev/null - - module_path="$(find squashfs-root -name 'im-fcitx5.so' -print -quit)" - if [[ -z "$module_path" ]]; then - echo "AppImage does not contain the fcitx5 GTK3 input method module" >&2 - exit 1 - fi - - cache_path="" - while IFS= read -r candidate; do - if grep -qi 'fcitx' "$candidate"; then - cache_path="$candidate" - break - fi - done < <(find squashfs-root -name 'immodules.cache' -type f -print) - - if [[ -z "$cache_path" ]]; then - echo "AppImage GTK immodules.cache does not register fcitx5" >&2 - exit 1 - fi - - echo "Verified AppImage fcitx5 GTK module: module=${module_path}, cache=${cache_path}" -) diff --git a/scripts/ci/verify-linux-desktop-package.sh b/scripts/ci/verify-linux-desktop-package.sh new file mode 100755 index 0000000000..db7001fde5 --- /dev/null +++ b/scripts/ci/verify-linux-desktop-package.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +set -euo pipefail + +target="${1:?usage: verify-linux-desktop-package.sh }" +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +release_dir="target/${target}/release" +shopt -s nullglob +appimages=("$release_dir"/bundle/appimage/*.AppImage) +debs=("$release_dir"/bundle/deb/*.deb) + +if [[ ${#appimages[@]} -ne 1 ]]; then + echo "Expected exactly one AppImage in $release_dir/bundle/appimage, found ${#appimages[@]}" >&2 + exit 1 +fi +if [[ ${#debs[@]} -ne 1 ]]; then + echo "Expected exactly one DEB in $release_dir/bundle/deb, found ${#debs[@]}" >&2 + exit 1 +fi + +appimage="$(realpath "${appimages[0]}")" +desktop="$(realpath -e "$release_dir/openbitfun-desktop")" +work_dir="$(mktemp -d)" +trap 'rm -rf "$work_dir"' EXIT + +( + cd "$work_dir" + chmod +x "$appimage" + "$appimage" --appimage-extract >/dev/null + + test -f squashfs-root/usr/bin/openbitfun-desktop + find squashfs-root -type f -print0 > "$work_dir/appimage-files" + elf_files=() + while IFS= read -r -d '' candidate; do + if LC_ALL=C IFS= read -r -N 4 magic < "$candidate" && [[ "$magic" == $'\x7fELF' ]]; then + elf_files+=("$candidate") + fi + done < "$work_dir/appimage-files" + bash "$script_dir/check-glibc-floor.sh" 2.35 "$desktop" "$appimage" "${elf_files[@]}" + + module_path="$(find squashfs-root -name 'im-fcitx5.so' -print -quit)" + if [[ -z "$module_path" ]]; then + echo "AppImage does not contain the fcitx5 GTK3 input method module" >&2 + exit 1 + fi + + cache_path="" + while IFS= read -r candidate; do + if grep -qi 'fcitx' "$candidate"; then + cache_path="$candidate" + break + fi + done < <(find squashfs-root -name 'immodules.cache' -type f -print) + + if [[ -z "$cache_path" ]]; then + echo "AppImage GTK immodules.cache does not register fcitx5" >&2 + exit 1 + fi + + echo "Verified AppImage fcitx5 GTK module: module=${module_path}, cache=${cache_path}" +) + +# Resolve the generated control metadata against the same Ubuntu 22.04 apt +# sources used for the build, including alternative dependencies such as OCR. +deb_depends="$(dpkg-deb --field "${debs[0]}" Depends)" +if [[ -z "$deb_depends" ]]; then + echo "Missing Depends field in ${debs[0]}" >&2 + exit 1 +fi +apt-get --simulate satisfy "$deb_depends" diff --git a/scripts/desktop-package-platforms.json b/scripts/desktop-package-platforms.json index f9edae01e0..62d27b0313 100644 --- a/scripts/desktop-package-platforms.json +++ b/scripts/desktop-package-platforms.json @@ -1,6 +1,6 @@ [ { - "os": "ubuntu-latest", + "os": "ubuntu-24.04", "name": "linux-x64", "target": "x86_64-unknown-linux-gnu", "build_command": "pnpm run desktop:build:linux -- --target x86_64-unknown-linux-gnu --bundles deb,rpm,appimage" diff --git a/src/apps/desktop/tauri.conf.json b/src/apps/desktop/tauri.conf.json index 55cb8109ba..89aa09a0b3 100644 --- a/src/apps/desktop/tauri.conf.json +++ b/src/apps/desktop/tauri.conf.json @@ -61,7 +61,7 @@ "liblept5", "liblzma5", "libsoup-3.0-0", - "libtesseract5", + "libtesseract5 | libtesseract4", "libxcb1", "libxdo3", "tesseract-ocr-eng", From 2ee651ba1dd195886a0bed3d5fee61924047bdcf Mon Sep 17 00:00:00 2001 From: kev1n77 Date: Thu, 19 Nov 2026 16:46:30 +0800 Subject: [PATCH 2/5] fix(desktop): statically link bzip2 on Linux --- src/apps/desktop/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/apps/desktop/Cargo.toml b/src/apps/desktop/Cargo.toml index bb40836236..96ccad1935 100644 --- a/src/apps/desktop/Cargo.toml +++ b/src/apps/desktop/Cargo.toml @@ -144,6 +144,8 @@ default = [] devtools = ["openbitfun-computer-use/test-support", "tauri/devtools", "openbitfun-webdriver/embedded"] [target.'cfg(target_os = "linux")'.dependencies] +# Keep Linux desktop packages independent of the build distribution's bzip2 SONAME. +bzip2 = { workspace = true, features = ["static"] } libc = { workspace = true } gtk = { workspace = true } From 26b447058676a5bb71ba8a2bddb1b22e9dc20434 Mon Sep 17 00:00:00 2001 From: kev1n77 Date: Thu, 19 Nov 2026 19:24:07 +0800 Subject: [PATCH 3/5] fix(linux): bundle a consistent desktop tray runtime --- scripts/check-github-config.test.mjs | 29 ++++++ scripts/ci/check-glibc-floor.sh | 39 ++++---- scripts/ci/classify-build-impact.mjs | 3 +- scripts/ci/classify-build-impact.test.mjs | 11 ++- scripts/ci/linux-appimage-tray-libraries.json | 7 ++ scripts/ci/verify-appimage-fcitx.sh | 43 --------- scripts/ci/verify-linux-desktop-package.sh | 96 +++++++++++++++++++ scripts/desktop-package-platforms.json | 2 +- scripts/desktop-tauri-build.mjs | 39 +++++++- scripts/desktop-tauri-build.test.mjs | 21 ++++ src/apps/desktop/tauri.conf.json | 3 +- 11 files changed, 222 insertions(+), 71 deletions(-) create mode 100644 scripts/ci/linux-appimage-tray-libraries.json delete mode 100644 scripts/ci/verify-appimage-fcitx.sh create mode 100755 scripts/ci/verify-linux-desktop-package.sh diff --git a/scripts/check-github-config.test.mjs b/scripts/check-github-config.test.mjs index 41eb48e667..3a386788c4 100644 --- a/scripts/check-github-config.test.mjs +++ b/scripts/check-github-config.test.mjs @@ -1695,6 +1695,35 @@ test('stable and beta publication require every producer, while artifact-only ru }); +test('Desktop release and nightly package Linux on Ubuntu 22.04 and verify before upload', () => { + const readPackageJob = (file) => + yaml.parse(readFileSync(path.join(repoRoot, '.github/workflows', file), 'utf8')).jobs.package; + const release = readPackageJob('desktop-package.yml'); + const nightly = readPackageJob('nightly-artifacts.yml'); + const dependencies = (job) => job.steps.find((step) => step.name === 'Install Linux desktop build dependencies'); + + assert.equal(release.container, "${{ startsWith(matrix.platform.name, 'linux-') && 'ubuntu:22.04' || '' }}"); + assert.equal(nightly.container, "${{ startsWith(matrix.platform, 'linux-') && 'ubuntu:22.04' || '' }}"); + assert.equal(dependencies(release).run, dependencies(nightly).run); + + for (const job of [release, nightly]) { + const checkout = job.steps.find((step) => step.uses === 'actions/checkout@v5'); + const trust = job.steps.find((step) => step.name === 'Trust the Linux build checkout'); + const verify = job.steps.find((step) => step.name === 'Verify Linux desktop package'); + const buildIndex = job.steps.findIndex((step) => step.name === 'Build desktop app'); + const uploadIndex = job.steps.findIndex((step) => step.name === 'Upload bundles'); + assert.equal(trust.if, "runner.os == 'Linux'"); + assert.equal(trust.run, 'git config --global --add safe.directory "$GITHUB_WORKSPACE"'); + assert.ok(job.steps.indexOf(checkout) < job.steps.indexOf(trust)); + assert.ok(job.steps.indexOf(trust) < buildIndex); + assert.equal(verify.if, "runner.os == 'Linux'"); + assert.match(verify.run, /verify-linux-desktop-package\.sh/); + assert.match(verify.run, /linux-appimage-tray-libraries\.json/); + assert.ok(buildIndex >= 0 && buildIndex < job.steps.indexOf(verify)); + assert.ok(job.steps.indexOf(verify) < uploadIndex); + } +}); + test('Desktop recovery selects one platform and cannot publish an incomplete release', (t) => { const workflow = yaml.parse(readFileSync(path.join(repoRoot, '.github/workflows/desktop-package.yml'), 'utf8')); const step = workflow.jobs.prepare.steps.find((entry) => entry.name === 'Select Desktop package platforms'); diff --git a/scripts/ci/check-glibc-floor.sh b/scripts/ci/check-glibc-floor.sh index 63eb3a5d25..89700d9c72 100755 --- a/scripts/ci/check-glibc-floor.sh +++ b/scripts/ci/check-glibc-floor.sh @@ -36,15 +36,17 @@ if ! command -v readelf >/dev/null 2>&1; then exit 2 fi -# Highest GLIBC_x.y this binary asks for; empty when it needs none. -# The trailing `|| true` matters: `grep` exits non-zero when a binary has no -# versioned glibc symbols at all (a static build), and under `set -e` that -# would abort the whole run at the command substitution below. +# Read version requirements only. A shared library can also define symbols. max_required_glibc() { - readelf -V "$1" 2>/dev/null | - grep -oE 'GLIBC_[0-9]+\.[0-9]+' | - sort -u -V | - tail -n 1 || true + LC_ALL=C readelf --version-info --wide "$1" | + awk ' + /^Version .* section / { needs = /^Version needs section / } + needs && match($0, /Name: GLIBC_[0-9]+\.[0-9]+(\.[0-9]+)?/) { + print substr($0, RSTART + length("Name: "), RLENGTH - length("Name: ")) + } + ' | + LC_ALL=C sort -u -V | + tail -n 1 } status=0 @@ -54,7 +56,11 @@ for bin in "$@"; do status=1 continue fi - required="$(max_required_glibc "$bin")" + if ! required="$(max_required_glibc "$bin")"; then + echo "ERROR: could not read ELF version information from $bin" >&2 + status=1 + continue + fi if [ -z "$required" ]; then echo "ok $(basename "$bin"): no versioned glibc requirement" continue @@ -63,24 +69,11 @@ for bin in "$@"; do # sort -V puts the larger version last: if that is not MAX, MAX was exceeded. highest="$(printf '%s\n%s\n' "$MAX" "$required" | sort -V | tail -n 1)" if [ "$highest" != "$MAX" ]; then - echo "FAIL $(basename "$bin"): requires glibc $required, above the $MAX floor" >&2 + echo "FAIL $bin: requires glibc $required, above the $MAX floor" >&2 status=1 else echo "ok $(basename "$bin"): requires glibc $required (floor $MAX)" fi done -if [ "$status" -ne 0 ]; then - cat >&2 < }), }, { - paths: ['scripts/ci/verify-appimage-fcitx.sh'], + paths: ['scripts/ci/verify-linux-desktop-package.sh'], result: expected({ rustRequired: true, desktopPlatforms: ['linux-x64', 'linux-arm64'], reason: 'platform-package-input', }), }, + { + paths: ['scripts/ci/check-glibc-floor.sh'], + result: expected({ + rustRequired: true, + desktopPlatforms: ['linux-x64', 'linux-arm64'], + linuxBinariesRequired: true, + reason: 'platform-package-input', + }), + }, ...[ 'scripts/prepare-flashgrep-resource.mjs', 'resources/flashgrep/VERSION.json', diff --git a/scripts/ci/linux-appimage-tray-libraries.json b/scripts/ci/linux-appimage-tray-libraries.json new file mode 100644 index 0000000000..689e12b6d1 --- /dev/null +++ b/scripts/ci/linux-appimage-tray-libraries.json @@ -0,0 +1,7 @@ +[ + "libayatana-appindicator3.so.1", + "libayatana-ido3-0.4.so.0", + "libayatana-indicator3.so.7", + "libdbusmenu-glib.so.4", + "libdbusmenu-gtk3.so.4" +] diff --git a/scripts/ci/verify-appimage-fcitx.sh b/scripts/ci/verify-appimage-fcitx.sh deleted file mode 100644 index d609dd27e7..0000000000 --- a/scripts/ci/verify-appimage-fcitx.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -target="${1:?usage: verify-appimage-fcitx.sh }" -bundle_dir="target/${target}/release/bundle/appimage" - -mapfile -t appimages < <(find "$bundle_dir" -maxdepth 1 -type f -name '*.AppImage' -print | sort) -if [[ ${#appimages[@]} -ne 1 ]]; then - echo "Expected exactly one AppImage in ${bundle_dir}, found ${#appimages[@]}" >&2 - exit 1 -fi - -appimage="$(realpath "${appimages[0]}")" -work_dir="$(mktemp -d)" -trap 'rm -rf "$work_dir"' EXIT - -( - cd "$work_dir" - chmod +x "$appimage" - "$appimage" --appimage-extract >/dev/null - - module_path="$(find squashfs-root -name 'im-fcitx5.so' -print -quit)" - if [[ -z "$module_path" ]]; then - echo "AppImage does not contain the fcitx5 GTK3 input method module" >&2 - exit 1 - fi - - cache_path="" - while IFS= read -r candidate; do - if grep -qi 'fcitx' "$candidate"; then - cache_path="$candidate" - break - fi - done < <(find squashfs-root -name 'immodules.cache' -type f -print) - - if [[ -z "$cache_path" ]]; then - echo "AppImage GTK immodules.cache does not register fcitx5" >&2 - exit 1 - fi - - echo "Verified AppImage fcitx5 GTK module: module=${module_path}, cache=${cache_path}" -) diff --git a/scripts/ci/verify-linux-desktop-package.sh b/scripts/ci/verify-linux-desktop-package.sh new file mode 100755 index 0000000000..9480b4332e --- /dev/null +++ b/scripts/ci/verify-linux-desktop-package.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +set -euo pipefail + +target="${1:?usage: verify-linux-desktop-package.sh }" +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +release_dir="target/${target}/release" +shopt -s nullglob +appimages=("$release_dir"/bundle/appimage/*.AppImage) +debs=("$release_dir"/bundle/deb/*.deb) + +if [[ ${#appimages[@]} -ne 1 ]]; then + echo "Expected exactly one AppImage in $release_dir/bundle/appimage, found ${#appimages[@]}" >&2 + exit 1 +fi +if [[ ${#debs[@]} -ne 1 ]]; then + echo "Expected exactly one DEB in $release_dir/bundle/deb, found ${#debs[@]}" >&2 + exit 1 +fi + +appimage="$(realpath "${appimages[0]}")" +desktop="$(realpath -e "$release_dir/openbitfun-desktop")" +work_dir="$(mktemp -d)" +trap 'rm -rf "$work_dir"' EXIT + +# Jammy and Noble use different bzip2 SONAMEs on arm64. +desktop_dynamic="$(LC_ALL=C readelf --dynamic --wide "$desktop")" +if grep -Eq 'Shared library: \[libbz2\.so[^]]*\]' <<< "$desktop_dynamic"; then + echo "Desktop executable must link bzip2 statically" >&2 + exit 1 +fi + +( + cd "$work_dir" + chmod +x "$appimage" + "$appimage" --appimage-extract >/dev/null + + test -f squashfs-root/usr/bin/openbitfun-desktop + tray_sonames="$(jq -er '.[]' "$script_dir/linux-appimage-tray-libraries.json")" + bundle_lib="$PWD/squashfs-root/usr/lib" + while IFS= read -r soname; do + if [[ ! -f "$bundle_lib/$soname" ]]; then + echo "AppImage is missing the tray runtime library $soname" >&2 + exit 1 + fi + done <<< "$tray_sonames" + if ! tray_dependencies="$(LC_ALL=C LD_LIBRARY_PATH="$bundle_lib" ldd -r "$bundle_lib/libayatana-appindicator3.so.1" 2>&1)" \ + || grep -Eq 'not found|undefined symbol' <<< "$tray_dependencies"; then + echo "AppImage tray runtime could not resolve its dependencies" >&2 + echo "$tray_dependencies" >&2 + exit 1 + fi + + find squashfs-root -type f -print0 > "$work_dir/appimage-files" + elf_files=() + while IFS= read -r -d '' candidate; do + if LC_ALL=C IFS= read -r -N 4 magic < "$candidate" && [[ "$magic" == $'\x7fELF' ]]; then + elf_files+=("$candidate") + fi + done < "$work_dir/appimage-files" + bash "$script_dir/check-glibc-floor.sh" 2.35 "$desktop" "$appimage" "${elf_files[@]}" + + module_path="$(find squashfs-root -name 'im-fcitx5.so' -print -quit)" + if [[ -z "$module_path" ]]; then + echo "AppImage does not contain the fcitx5 GTK3 input method module" >&2 + exit 1 + fi + + cache_path="" + while IFS= read -r candidate; do + if grep -qi 'fcitx' "$candidate"; then + cache_path="$candidate" + break + fi + done < <(find squashfs-root -name 'immodules.cache' -type f -print) + + if [[ -z "$cache_path" ]]; then + echo "AppImage GTK immodules.cache does not register fcitx5" >&2 + exit 1 + fi + + echo "Verified AppImage fcitx5 GTK module: module=${module_path}, cache=${cache_path}" +) + +# Resolve the generated control metadata against the same Ubuntu 22.04 apt +# sources used for the build, including alternative dependencies such as OCR. +deb_depends="$(dpkg-deb --field "${debs[0]}" Depends)" +if [[ -z "$deb_depends" ]]; then + echo "Missing Depends field in ${debs[0]}" >&2 + exit 1 +fi +if ! grep -Eq '(^|,)[[:space:]]*libayatana-appindicator3-1[[:space:]]*(,|$)' <<< "$deb_depends"; then + echo "DEB does not declare the Ayatana tray runtime dependency" >&2 + exit 1 +fi +apt-get --simulate satisfy "$deb_depends" diff --git a/scripts/desktop-package-platforms.json b/scripts/desktop-package-platforms.json index f9edae01e0..62d27b0313 100644 --- a/scripts/desktop-package-platforms.json +++ b/scripts/desktop-package-platforms.json @@ -1,6 +1,6 @@ [ { - "os": "ubuntu-latest", + "os": "ubuntu-24.04", "name": "linux-x64", "target": "x86_64-unknown-linux-gnu", "build_command": "pnpm run desktop:build:linux -- --target x86_64-unknown-linux-gnu --bundles deb,rpm,appimage" diff --git a/scripts/desktop-tauri-build.mjs b/scripts/desktop-tauri-build.mjs index 015720ced9..356ccc29d7 100644 --- a/scripts/desktop-tauri-build.mjs +++ b/scripts/desktop-tauri-build.mjs @@ -77,6 +77,7 @@ async function main() { miniappShell, resolution, releaseChannel, + appImageLibraryDir: requestsLinuxAppImage(forward) ? linuxTrayLibraryDir() : undefined, }); const tauriBin = join(ROOT, 'node_modules', '.bin', 'tauri'); const tauriArgs = [bundleOnly ? 'bundle' : 'build', '--config', tauriConfig, ...forward]; @@ -251,6 +252,26 @@ function requestsDmgBundle(args) { return bundles === undefined || bundles.split(',').some((bundle) => bundle.trim() === 'dmg'); } +export function requestsLinuxAppImage(args, platform = process.platform) { + const target = optionValue(args, '--target'); + const bundles = optionValue(args, '--bundles') ?? optionValue(args, '-b'); + return platform === 'linux' && (!target || target.includes('-linux-')) + && !args.includes('--no-bundle') + && (bundles === undefined || bundles.split(',').some((bundle) => bundle.trim() === 'appimage')); +} + +function linuxTrayLibraryDir() { + const result = spawnSync('pkg-config', ['--variable=libdir', 'ayatana-appindicator3-0.1'], { + encoding: 'utf8', + windowsHide: true, + }); + const directory = result.stdout?.trim(); + if (result.status !== 0 || !directory || !isAbsolute(directory)) { + throw new Error('Could not locate the Ayatana AppIndicator development package required for the AppImage.'); + } + return directory; +} + function optionValue(args, option) { const inlinePrefix = `${option}=`; for (let i = 0; i < args.length; i += 1) { @@ -336,7 +357,7 @@ export function configureWindowsSigning(config, env = process.env, platform = pr export function prepareTauriConfig( baseConfigPath, - { desktopDir, flashgrepBinary, miniappShell, resolution, releaseChannel } + { desktopDir, flashgrepBinary, miniappShell, resolution, releaseChannel, appImageLibraryDir } ) { const config = JSON.parse(readFileSync(baseConfigPath, 'utf8')); if (resolution) { @@ -362,6 +383,7 @@ export function prepareTauriConfig( // compiles the profile before Tauri copies resources. injectDshProfileResource(config); injectExternalFrontendResource(config); + if (appImageLibraryDir) injectAppImageTrayLibraries(config, appImageLibraryDir); const release = releaseChannel ?? resolveReleaseChannel(process.env.OPENBITFUN_RELEASE_CHANNEL); @@ -422,6 +444,21 @@ export function prepareTauriConfig( return generatedConfig; } +function injectAppImageTrayLibraries(config, libraryDir) { + // The tray implementation uses dlopen, so linuxdeploy cannot discover this + // chain from the desktop executable. Keep it on the same GLib as the bundle. + const libraries = JSON.parse(readFileSync(new URL('./ci/linux-appimage-tray-libraries.json', import.meta.url), 'utf8')); + const files = (config.bundle.linux.appimage.files ??= {}); + for (const soname of libraries) { + const source = join(libraryDir, soname); + if (!existsSync(source) || !statSync(source).isFile()) { + throw new Error(`Missing AppImage tray runtime library: ${source}`); + } + // Tauri copies the contents of the source symlink under the loader's SONAME. + files[`/usr/lib/${soname}`] = source; + } +} + const DSH_PROFILE_RESOURCE_SOURCE = '../../../packages/dsh-acp/dist-profile'; const DSH_PROFILE_RESOURCE_TARGET = 'resources/dsh-profile'; const EXTERNAL_FRONTEND_RESOURCE_SOURCE = '../../../dist'; diff --git a/scripts/desktop-tauri-build.test.mjs b/scripts/desktop-tauri-build.test.mjs index cf53d41e47..8bb3a214bc 100644 --- a/scripts/desktop-tauri-build.test.mjs +++ b/scripts/desktop-tauri-build.test.mjs @@ -8,6 +8,7 @@ import { configureWindowsSigning, prepareMacOSFlashgrepForSigning, prepareTauriConfig, + requestsLinuxAppImage, requestsMacosBundle, shouldRetryMacDmgBuild, } from './desktop-tauri-build.mjs'; @@ -414,6 +415,26 @@ test('Desktop packaging includes only the selected Flashgrep target', () => { } }); +test('Linux AppImage embeds the tray runtime under its SONAMEs', (t) => { + const fixture = mkdtempSync(join(tmpdir(), 'openbitfun-appimage-tray-')); + t.after(() => rmSync(fixture, { recursive: true, force: true })); + const baseConfig = join(ROOT, 'src/apps/desktop/tauri.conf.json'); + const libraries = JSON.parse(readFileSync(join(ROOT, 'scripts/ci/linux-appimage-tray-libraries.json'), 'utf8')); + const options = { desktopDir: fixture, appImageLibraryDir: fixture }; + assert.throws(() => prepareTauriConfig(baseConfig, options), /Missing AppImage tray runtime library/); + + for (const soname of libraries) writeFileSync(join(fixture, soname), 'tray library'); + const config = JSON.parse(readFileSync(prepareTauriConfig(baseConfig, options), 'utf8')); + assert.deepEqual(config.bundle.linux.appimage.files, + Object.fromEntries(libraries.map((soname) => [`/usr/lib/${soname}`, join(fixture, soname)]))); + assert.ok(config.bundle.linux.deb.depends.includes('libayatana-appindicator3-1')); + assert.equal(requestsLinuxAppImage([], 'linux'), true); + assert.equal(requestsLinuxAppImage(['--target', 'aarch64-unknown-linux-gnu', '--bundles', 'deb,rpm,appimage'], 'linux'), true); + assert.equal(requestsLinuxAppImage(['--bundles=deb'], 'linux'), false); + assert.equal(requestsLinuxAppImage(['--no-bundle'], 'linux'), false); + assert.equal(requestsLinuxAppImage([], 'darwin'), false); +}); + test('Windows updater installs NSIS packages without showing its progress window', () => { const fixture = join(tmpdir(), `openbitfun-tauri-updater-${process.pid}-${Date.now()}`); const baseConfig = join(fixture, 'tauri.conf.json'); diff --git a/src/apps/desktop/tauri.conf.json b/src/apps/desktop/tauri.conf.json index 55cb8109ba..ecc87bb161 100644 --- a/src/apps/desktop/tauri.conf.json +++ b/src/apps/desktop/tauri.conf.json @@ -52,6 +52,7 @@ "gstreamer1.0-plugins-base", "gstreamer1.0-plugins-good", "xdg-desktop-portal", + "libayatana-appindicator3-1", "libc6", "libcairo2", "libgcc-s1", @@ -61,7 +62,7 @@ "liblept5", "liblzma5", "libsoup-3.0-0", - "libtesseract5", + "libtesseract5 | libtesseract4", "libxcb1", "libxdo3", "tesseract-ocr-eng", From 0ca201f2825b87fa7671677196122df205cd1db9 Mon Sep 17 00:00:00 2001 From: kev1n77 <59403997+kev1n77@users.noreply.github.com> Date: Thu, 19 Nov 2026 19:24:50 +0800 Subject: [PATCH 4/5] fix(ci): build Linux desktop bundles in Ubuntu 22.04 --- .github/workflows/desktop-package.yml | 87 ++++++++++++------------- .github/workflows/nightly-artifacts.yml | 83 ++++++++++++----------- 2 files changed, 82 insertions(+), 88 deletions(-) diff --git a/.github/workflows/desktop-package.yml b/.github/workflows/desktop-package.yml index 3b6cbcb617..c55631fb15 100644 --- a/.github/workflows/desktop-package.yml +++ b/.github/workflows/desktop-package.yml @@ -198,6 +198,8 @@ jobs: package: name: Package (${{ matrix.platform.name }}) runs-on: ${{ matrix.platform.os }} + # Compile and bundle with Ubuntu 22.04's glibc on both Linux architectures. + container: ${{ startsWith(matrix.platform.name, 'linux-') && 'ubuntu:22.04' || '' }} needs: prepare if: needs.prepare.outputs.relay_image_only != 'true' && !inputs.artifact_run_ids && !inputs.verification_recovery_run_id env: @@ -220,6 +222,24 @@ jobs: platform: ${{ fromJSON(needs.prepare.outputs.package_matrix) }} steps: + - name: Install Linux desktop build dependencies + if: runner.os == 'Linux' + shell: bash + env: + DEBIAN_FRONTEND: noninteractive + run: | + apt-get update + # linuxdeploy needs the fcitx5 GTK3 module when it builds the AppImage. + apt-get install -y --no-install-recommends \ + build-essential ca-certificates clang cmake curl file git jq \ + libclang-dev pkg-config python3 unzip xz-utils \ + xdg-utils libglib2.0-dev libgtk-3-dev libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev gstreamer1.0-pipewire \ + gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ + fcitx5-frontend-gtk3 libxdo-dev libwebkit2gtk-4.1-dev \ + libayatana-appindicator3-dev librsvg2-dev patchelf fakeroot rpm \ + libleptonica-dev libtesseract-dev tesseract-ocr tesseract-ocr-eng + # Also preserve bytes when rebuilding an older immutable tag that does # not yet pin every hashed source file in .gitattributes. - name: Preserve source bytes on Windows @@ -232,6 +252,11 @@ jobs: with: ref: ${{ needs.prepare.outputs.checkout_ref }} + - name: Trust the Linux build checkout + if: runner.os == 'Linux' + shell: bash + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" + - name: Check Windows signing configuration if: runner.os == 'Windows' id: windows-signing @@ -281,49 +306,6 @@ jobs: where.exe makensis makensis /VERSION - - name: Install Linux system dependencies (Tauri bundler) - if: runner.os == 'Linux' - shell: bash - run: | - sudo apt-get update - - if apt-cache show libwebkit2gtk-4.1-dev >/dev/null 2>&1; then - WEBKIT_PKG=libwebkit2gtk-4.1-dev - else - WEBKIT_PKG=libwebkit2gtk-4.0-dev - fi - - if apt-cache show libappindicator3-dev >/dev/null 2>&1; then - APPINDICATOR_PKG=libappindicator3-dev - else - APPINDICATOR_PKG=libayatana-appindicator3-dev - fi - - # Tauri pins AppImage GTK input methods to its bundled cache, so the - # fcitx5 GTK3 bridge must be present before linuxdeploy builds it. - sudo apt-get install -y --no-install-recommends \ - pkg-config \ - xdg-utils \ - libglib2.0-dev \ - libgtk-3-dev \ - libgstreamer1.0-dev \ - libgstreamer-plugins-base1.0-dev \ - gstreamer1.0-pipewire \ - gstreamer1.0-plugins-base \ - gstreamer1.0-plugins-good \ - fcitx5-frontend-gtk3 \ - libxdo-dev \ - "$WEBKIT_PKG" \ - "$APPINDICATOR_PKG" \ - librsvg2-dev \ - patchelf \ - fakeroot \ - rpm \ - libleptonica-dev \ - libtesseract-dev \ - tesseract-ocr \ - tesseract-ocr-eng - - name: Setup pnpm uses: pnpm/action-setup@v5 @@ -376,6 +358,7 @@ jobs: uses: swatinem/rust-cache@v2 with: shared-key: "package-v2-${{ matrix.platform.name }}" + key: ${{ startsWith(matrix.platform.name, 'linux-') && 'ubuntu-22.04' || '' }} cache-bin: false - name: Install dependencies @@ -490,10 +473,24 @@ jobs: | tar -x -C "$verification_dir" bash "$verification_dir/scripts/ci/verify-macos-signing.sh" "${{ matrix.platform.target }}" - - name: Verify AppImage fcitx5 GTK module + - name: Verify Linux desktop package if: runner.os == 'Linux' shell: bash - run: bash scripts/ci/verify-appimage-fcitx.sh "${{ matrix.platform.target }}" + env: + WORKFLOW_SHA: ${{ github.workflow_sha }} + TARGET: ${{ matrix.platform.target }} + run: | + set -euo pipefail + # Apply the current packaging checks when rebuilding an older tag. + verification_dir="$(mktemp -d)" + trap 'rm -rf "$verification_dir"' EXIT + if ! git cat-file -e "$WORKFLOW_SHA^{commit}"; then + git fetch --no-tags --depth=1 origin "$WORKFLOW_SHA" + fi + git archive "$WORKFLOW_SHA" scripts/ci/verify-linux-desktop-package.sh \ + scripts/ci/check-glibc-floor.sh scripts/ci/linux-appimage-tray-libraries.json \ + | tar -x -C "$verification_dir" + bash "$verification_dir/scripts/ci/verify-linux-desktop-package.sh" "$TARGET" - name: Preserve macOS verification recovery bundles if: failure() && runner.os == 'macOS' && steps.apple_verification.outcome == 'failure' diff --git a/.github/workflows/nightly-artifacts.yml b/.github/workflows/nightly-artifacts.yml index a1334a061d..564a2c97bc 100644 --- a/.github/workflows/nightly-artifacts.yml +++ b/.github/workflows/nightly-artifacts.yml @@ -66,7 +66,9 @@ jobs: package: name: Package (${{ matrix.platform }}) if: ${{ inputs.build_desktop_packages }} - runs-on: ${{ fromJSON('{"linux-x64":"ubuntu-latest","linux-arm64":"ubuntu-24.04-arm","macos-arm64":"macos-15","macos-x64":"macos-15-intel","windows-x64":"windows-latest"}')[matrix.platform] }} + runs-on: ${{ fromJSON('{"linux-x64":"ubuntu-24.04","linux-arm64":"ubuntu-24.04-arm","macos-arm64":"macos-15","macos-x64":"macos-15-intel","windows-x64":"windows-latest"}')[matrix.platform] }} + # Use the same Linux build environment as Desktop Package. + container: ${{ startsWith(matrix.platform, 'linux-') && 'ubuntu:22.04' || '' }} env: NODE_OPTIONS: --max-old-space-size=6144 OPENBITFUN_RELEASE_CHANNEL: nightly @@ -85,52 +87,32 @@ jobs: platform: ${{ fromJSON(inputs.desktop_platforms) }} steps: + - name: Install Linux desktop build dependencies + if: runner.os == 'Linux' + shell: bash + env: + DEBIAN_FRONTEND: noninteractive + run: | + apt-get update + # linuxdeploy needs the fcitx5 GTK3 module when it builds the AppImage. + apt-get install -y --no-install-recommends \ + build-essential ca-certificates clang cmake curl file git jq \ + libclang-dev pkg-config python3 unzip xz-utils \ + xdg-utils libglib2.0-dev libgtk-3-dev libgstreamer1.0-dev \ + libgstreamer-plugins-base1.0-dev gstreamer1.0-pipewire \ + gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ + fcitx5-frontend-gtk3 libxdo-dev libwebkit2gtk-4.1-dev \ + libayatana-appindicator3-dev librsvg2-dev patchelf fakeroot rpm \ + libleptonica-dev libtesseract-dev tesseract-ocr tesseract-ocr-eng + - uses: actions/checkout@v5 with: ref: ${{ inputs.checkout_ref }} - - name: Install Linux system dependencies (Tauri bundler) + - name: Trust the Linux build checkout if: runner.os == 'Linux' shell: bash - run: | - sudo apt-get update - - if apt-cache show libwebkit2gtk-4.1-dev >/dev/null 2>&1; then - WEBKIT_PKG=libwebkit2gtk-4.1-dev - else - WEBKIT_PKG=libwebkit2gtk-4.0-dev - fi - - if apt-cache show libappindicator3-dev >/dev/null 2>&1; then - APPINDICATOR_PKG=libappindicator3-dev - else - APPINDICATOR_PKG=libayatana-appindicator3-dev - fi - - # Tauri pins AppImage GTK input methods to its bundled cache, so the - # fcitx5 GTK3 bridge must be present before linuxdeploy builds it. - sudo apt-get install -y --no-install-recommends \ - pkg-config \ - xdg-utils \ - libglib2.0-dev \ - libgtk-3-dev \ - libgstreamer1.0-dev \ - libgstreamer-plugins-base1.0-dev \ - gstreamer1.0-pipewire \ - gstreamer1.0-plugins-base \ - gstreamer1.0-plugins-good \ - fcitx5-frontend-gtk3 \ - libxdo-dev \ - "$WEBKIT_PKG" \ - "$APPINDICATOR_PKG" \ - librsvg2-dev \ - patchelf \ - fakeroot \ - rpm \ - libleptonica-dev \ - libtesseract-dev \ - tesseract-ocr \ - tesseract-ocr-eng + run: git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: Setup pnpm uses: pnpm/action-setup@v5 @@ -185,6 +167,7 @@ jobs: uses: swatinem/rust-cache@v2 with: shared-key: "nightly-v3-${{ github.base_ref || github.ref_name }}-${{ matrix.platform }}" + key: ${{ startsWith(matrix.platform, 'linux-') && 'ubuntu-22.04' || '' }} cache-bin: false # A PR merge ref can never become a reusable base cache. Even a # trusted caller cannot override this guard. @@ -312,10 +295,24 @@ jobs: "${{ steps.macos-cli.outputs.archive }}" \ "${{ steps.macos-cli.outputs.checksum }}" - - name: Verify AppImage fcitx5 GTK module + - name: Verify Linux desktop package if: runner.os == 'Linux' shell: bash - run: bash scripts/ci/verify-appimage-fcitx.sh "${{ env.PACKAGE_TARGET }}" + env: + WORKFLOW_SHA: ${{ github.workflow_sha }} + TARGET: ${{ env.PACKAGE_TARGET }} + run: | + set -euo pipefail + # Apply the current packaging checks when rebuilding an older tag. + verification_dir="$(mktemp -d)" + trap 'rm -rf "$verification_dir"' EXIT + if ! git cat-file -e "$WORKFLOW_SHA^{commit}"; then + git fetch --no-tags --depth=1 origin "$WORKFLOW_SHA" + fi + git archive "$WORKFLOW_SHA" scripts/ci/verify-linux-desktop-package.sh \ + scripts/ci/check-glibc-floor.sh scripts/ci/linux-appimage-tray-libraries.json \ + | tar -x -C "$verification_dir" + bash "$verification_dir/scripts/ci/verify-linux-desktop-package.sh" "$TARGET" # Keep output validation independent from artifact upload. PR callers do # not upload packages, but still need evidence that every selected From d26807396912bb457db224bd22ae525fe8050787 Mon Sep 17 00:00:00 2001 From: kev1n77 Date: Thu, 19 Nov 2026 21:19:43 +0800 Subject: [PATCH 5/5] fix(linux): initialize Xlib threading before GTK --- third_party/tao/src/platform_impl/linux/event_loop.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/third_party/tao/src/platform_impl/linux/event_loop.rs b/third_party/tao/src/platform_impl/linux/event_loop.rs index 349525db38..40b05fef34 100644 --- a/third_party/tao/src/platform_impl/linux/event_loop.rs +++ b/third_party/tao/src/platform_impl/linux/event_loop.rs @@ -220,6 +220,16 @@ impl EventLoop { } fn new_gtk(app_id: Option<&str>) -> Result, Box> { + // Tao also opens an X11 connection on its device event thread. Older + // libX11 versions need thread support initialized before GTK opens the + // first display. + #[cfg(feature = "x11")] + if let Ok(xlib) = x11_dl::xlib::Xlib::open() { + if unsafe { (xlib.XInitThreads)() } == 0 { + log::warn!("Failed to initialize Xlib thread support"); + } + } + // This should be done by gtk::Application::new, but does not work properly gtk::init()?; let context = MainContext::default();