A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
build(desktop): fetch linux electron from a pinned release
Hampus233715446f4b
diff --git a/.github/workflows/build-desktop-electron.yaml b/.github/workflows/build-desktop-electron.yamlindex 7ad53631a..b041d17e2 100644--- a/.github/workflows/build-desktop-electron.yaml+++ b/.github/workflows/build-desktop-electron.yaml@@ -2,12 +2,6 @@ name: build desktop Electronon:workflow_dispatch:- inputs:- prebuilt_release_tag:- description: Draft release containing prebuilt Electron distributions. Leave empty to compile Electron on the build runner instead.- required: false- default: desktop-electron-runtime-44.9.1-fluxer.1- type: stringpermissions:contents: read@@ -19,7 +13,6 @@ concurrency:jobs:build:name: Build patched Electron (linux-${{ matrix.arch }})- if: inputs.prebuilt_release_tag == ''runs-on: [self-hosted, Linux, X64, fluxer-electron-build]timeout-minutes: 1440strategy:@@ -48,61 +41,8 @@ jobs:with:name: desktop-electron-linux-${{ matrix.arch }}path: |- ${{ runner.temp }}/fluxer-electron-artifacts/electron-v44.9.1-linux-${{ matrix.arch }}.zip- ${{ runner.temp }}/fluxer-electron-artifacts/electron-v44.9.1-linux-${{ matrix.arch }}.fluxer.json- if-no-files-found: error- retention-days: 30- compression-level: 0-- import:- name: Import patched Electron (linux-${{ matrix.arch }})- if: inputs.prebuilt_release_tag != ''- runs-on: ubuntu-24.04- timeout-minutes: 30- permissions:- contents: write- strategy:- fail-fast: false- matrix:- arch: [x64, arm64]- steps:- - name: Checkout source- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1-- - name: Set up Node.js- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020- with:- node-version: 26-- - name: Download and verify build artifacts- env:- GH_TOKEN: ${{ github.token }}- PREBUILT_RELEASE_TAG: ${{ inputs.prebuilt_release_tag }}- ELECTRON_ARCH: ${{ matrix.arch }}- FLUXER_ELECTRON_DIST: ${{ runner.temp }}/fluxer-electron-artifacts- shell: bash- run: |- set -euo pipefail- gh release view "$PREBUILT_RELEASE_TAG" --repo "$GITHUB_REPOSITORY" \- --json isDraft --jq '.isDraft' | grep -qx true- gh release download "$PREBUILT_RELEASE_TAG" --repo "$GITHUB_REPOSITORY" \- --pattern "electron-v44.9.1-linux-$ELECTRON_ARCH.zip" \- --pattern "electron-v44.9.1-linux-$ELECTRON_ARCH.fluxer.json" \- --dir "$FLUXER_ELECTRON_DIST"- node <<'NODE'- const {verifyLinuxElectronArchive} = require('./fluxer_desktop/scripts/custom-electron.cjs');- verifyLinuxElectronArchive(process.env.FLUXER_ELECTRON_DIST, process.env.ELECTRON_ARCH)- .then(() => console.log('Patched Electron artifact verified.'))- .catch((error) => { console.error(error); process.exitCode = 1; });- NODE-- - name: Upload patched Electron distribution- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02- with:- name: desktop-electron-linux-${{ matrix.arch }}- path: |- ${{ runner.temp }}/fluxer-electron-artifacts/electron-v44.9.1-linux-${{ matrix.arch }}.zip- ${{ runner.temp }}/fluxer-electron-artifacts/electron-v44.9.1-linux-${{ matrix.arch }}.fluxer.json+ ${{ runner.temp }}/fluxer-electron-artifacts/electron-v*-linux-${{ matrix.arch }}.zip+ ${{ runner.temp }}/fluxer-electron-artifacts/electron-v*-linux-${{ matrix.arch }}.fluxer.jsonif-no-files-found: errorretention-days: 30compression-level: 0diff --git a/.github/workflows/build-desktop.yaml b/.github/workflows/build-desktop.yamlindex dabc1ec7b..59a7fc2c6 100644--- a/.github/workflows/build-desktop.yaml+++ b/.github/workflows/build-desktop.yaml@@ -21,11 +21,6 @@ on:required: falsedefault: ""type: string- electron_build_run_id:- description: Successful manual main-branch build desktop Electron workflow run supplying the patched Linux Electron distributions. Required when building Linux.- required: false- default: ""- type: stringshell_contract:description: "Did the shell contract change since the oldest shell these modules still reach? unchanged refuses if it did. compatible keeps older shells on these modules because the renderer still works on them. raise stops sending these modules to shells without the new contract: Linux and managed shells keep their current renderer, Windows and macOS update their shell first."required: true@@ -70,30 +65,6 @@ jobs:ref: mainfetch-depth: 0- - name: Validate patched Electron build- env:- ELECTRON_BUILD_RUN_ID: ${{ inputs.electron_build_run_id }}- SKIP_TARGETS: ${{ inputs.skip_targets }}- GH_TOKEN: ${{ github.token }}- shell: bash- run: |- set -euo pipefail- skipped=",$(printf '%s' "$SKIP_TARGETS" | tr '[:space:]' ','),"- if [[ "$skipped" == *,linux,* ]] || \- { [[ "$skipped" == *,linux-x64,* ]] && [[ "$skipped" == *,linux-arm64,* ]]; }; then- exit 0- fi- if ! [[ "$ELECTRON_BUILD_RUN_ID" =~ ^[1-9][0-9]*$ ]]; then- echo 'Provide electron_build_run_id from a successful build desktop Electron workflow.' >&2- exit 1- fi- if ! gh api "repos/$GITHUB_REPOSITORY/actions/runs/$ELECTRON_BUILD_RUN_ID" \- --jq 'select(.status == "completed" and .conclusion == "success" and .event == "workflow_dispatch" and .head_branch == "main" and .repository.full_name != null and .head_repository.full_name == .repository.full_name and .path == ".github/workflows/build-desktop-electron.yaml") | .id' \- | grep -qx "$ELECTRON_BUILD_RUN_ID"; then- echo 'Use a successful manual build desktop Electron run from this repository on main.' >&2- exit 1- fi-- name: Set up Rust toolchain (CI helpers)uses: dtolnay/rust-toolchain@02cb101ec7c40f2c49e1d9714d64511d8e1b74dewith:@@ -645,12 +616,20 @@ jobs:- name: Download patched Electron distribution (Linux)if: matrix.platform == 'linux'- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093- with:- github-token: ${{ github.token }}- run-id: ${{ inputs.electron_build_run_id }}- name: desktop-electron-linux-${{ matrix.arch }}- path: ${{ runner.temp }}/fluxer-electron-dist+ working-directory: ${{ env.WORKDIR }}/fluxer_desktop+ env:+ GH_TOKEN: ${{ github.token }}+ ELECTRON_ARCH: ${{ matrix.arch }}+ FLUXER_ELECTRON_DIST: ${{ runner.temp }}/fluxer-electron-dist+ shell: bash+ run: |+ set -euo pipefail+ release_tag=$(jq -er .releaseTag electron/runtime.json)+ version=$(jq -er .electronVersion electron/runtime.json)+ gh release download "$release_tag" --repo "$GITHUB_REPOSITORY" \+ --pattern "electron-v$version-linux-$ELECTRON_ARCH.zip" \+ --pattern "electron-v$version-linux-$ELECTRON_ARCH.fluxer.json" \+ --dir "$FLUXER_ELECTRON_DIST"- name: Build Electron app (Linux)if: matrix.platform == 'linux'diff --git a/fluxer_desktop/electron/build-linux.sh b/fluxer_desktop/electron/build-linux.shindex e1f20e459..3f69a69fb 100755--- a/fluxer_desktop/electron/build-linux.sh+++ b/fluxer_desktop/electron/build-linux.sh@@ -1,25 +1,39 @@#!/usr/bin/env bashset -euo pipefail-readonly ELECTRON_VERSION=44.9.1-readonly ELECTRON_REVISION=e02265be96c5e13ae43644ef482b718e1e800499-readonly DEPOT_TOOLS_REVISION=889099791deff38466d471fa6590951c91a1d8ab-readonly BUILD_IMAGE='ghcr.io/electron/build:daad061f4b99a0ae1c841be4aa09188280a9c8a4@sha256:7a161ad561103ebbfb5ff18eaf47cb579ca0c528bb7ec9ed8cad30a41d5fa63e'-readonly PATCH_NAME=fix_synchronize_vaapi_surfaces_before_output.patchSCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)readonly SCRIPT_DIR+runtime_field() { python3 -c 'import json, sys; print(json.load(open(sys.argv[1]))[sys.argv[2]])' "$SCRIPT_DIR/runtime.json" "$1"; }+ELECTRON_VERSION=$(runtime_field electronVersion)+ELECTRON_REVISION=$(runtime_field electronRevision)+readonly ELECTRON_VERSION ELECTRON_REVISION+readonly DEPOT_TOOLS_REVISION=889099791deff38466d471fa6590951c91a1d8ab+readonly BUILD_IMAGE='ghcr.io/electron/build:daad061f4b99a0ae1c841be4aa09188280a9c8a4@sha256:7a161ad561103ebbfb5ff18eaf47cb579ca0c528bb7ec9ed8cad30a41d5fa63e'+PATCH_NAME=$(python3 - "$SCRIPT_DIR" <<'PY'+import hashlib, json, pathlib, sys+root = pathlib.Path(sys.argv[1])+patches = json.loads((root / "runtime.json").read_text())["patches"]+if len(patches) != 1 or patches[0]["series"] != "chromium":+ raise SystemExit("runtime.json must list exactly one Chromium patch")+patch = root / patches[0]["file"]+if patch.parent != root / "patches" or hashlib.sha256(patch.read_bytes()).hexdigest() != patches[0]["sha256"]:+ raise SystemExit(f"{patch.name} does not match the sha256 pinned in runtime.json")+print(patch.name)+PY+)+readonly PATCH_NAMEdie() { printf 'Error: %s\n' "$*" >&2; exit 1; }usage() {cat <<'USAGE'-Build patched Electron 44.9.1 on a Linux x64 host with Podman or Docker.+Build the patched Electron pinned in runtime.json on a Linux x64 host with Podman or Docker.Usage: build-linux.sh [--arch x64|arm64|all] [--build-root PATH] [--output-dir PATH] [--check]--arch Target architecture; all builds x64 then arm64 (default: all).--build-root Dedicated persistent cache, source and output tree.- Default: ${XDG_CACHE_HOME:-$HOME/.cache}/fluxer/electron-44.9.1+ Default: ${XDG_CACHE_HOME:-$HOME/.cache}/fluxer/electron-VERSION--output-dir Distribution ZIPs and .fluxer.json manifests (default: BUILD_ROOT/artifacts).--check Validate host resources and configuration without pulling or compiling.diff --git a/fluxer_desktop/electron/runtime.json b/fluxer_desktop/electron/runtime.jsonnew file mode 100644index 000000000..9e5e6596b--- /dev/null+++ b/fluxer_desktop/electron/runtime.json@@ -0,0 +1,20 @@+{+ "releaseTag": "desktop-electron-runtime-44.9.1-fluxer.1",+ "electronVersion": "44.9.1",+ "electronRevision": "e02265be96c5e13ae43644ef482b718e1e800499",+ "patches": [+ {+ "file": "patches/fix_synchronize_vaapi_surfaces_before_output.patch",+ "series": "chromium",+ "sha256": "21ea23b8a566f3f2dbdb69d0b361039dd9128c5e34a7ae89a8a61d7099808b8e"+ }+ ],+ "linux": {+ "x64": {+ "archiveSha256": "ae36cae3dd723d94b414302598014beb6230a0c596ac6dc7a2dc95a6198a2568"+ },+ "arm64": {+ "archiveSha256": "b9160781a6f06038ad96aff2c3d3d677162281e95bbe8572f2c8b3408f769df0"+ }+ }+}diff --git a/fluxer_desktop/scripts/custom-electron.cjs b/fluxer_desktop/scripts/custom-electron.cjsindex 7aaae6036..700ecefaa 100644--- a/fluxer_desktop/scripts/custom-electron.cjs+++ b/fluxer_desktop/scripts/custom-electron.cjs@@ -6,12 +6,14 @@ const path = require('node:path');const {promisify} = require('node:util');const execFileAsync = promisify(execFile);-const expectedElectronVersion = '44.9.1';-const expectedElectronRevision = 'e02265be96c5e13ae43644ef482b718e1e800499';-const chromiumPatchPath = path.join(- __dirname,- '../electron/patches/fix_synchronize_vaapi_surfaces_before_output.patch',-);+const runtime = require('../electron/runtime.json');+const expectedElectronVersion = runtime.electronVersion;+const expectedElectronRevision = runtime.electronRevision;+const [chromiumPatch, ...otherPatches] = runtime.patches;+if (chromiumPatch?.series !== 'chromium' || otherPatches.length > 0) {+ throw new Error('electron/runtime.json must list exactly one Chromium patch.');+}+const chromiumPatchPath = path.join(__dirname, '../electron', chromiumPatch.file);function resolveLinuxElectronDist() {const configuredDirectory = process.env.FLUXER_ELECTRON_DIST?.trim();@@ -89,11 +91,17 @@ async function verifyLinuxElectronArchive(directory, arch) {throw new Error(`Custom Electron manifest ${field} must be ${JSON.stringify(expected)}: ${manifestPath}`);}}- if ((await sha256File(chromiumPatchPath)) !== manifest?.chromiumPatchSha256) {- throw new Error(`Custom Electron manifest chromiumPatchSha256 does not match the current patch: ${manifestPath}`);+ if ((await sha256File(chromiumPatchPath)) !== chromiumPatch.sha256) {+ throw new Error(`${chromiumPatch.file} does not match the sha256 pinned in electron/runtime.json.`);+ }+ if (manifest?.chromiumPatchSha256 !== chromiumPatch.sha256) {+ throw new Error(`Custom Electron manifest chromiumPatchSha256 does not match the pinned patch: ${manifestPath}`);}- if (!/^[a-f0-9]{64}$/.test(manifest.archiveSha256)) {- throw new Error(`Custom Electron manifest has no valid archiveSha256: ${manifestPath}`);+ const pinnedArchiveSha256 = runtime.linux[arch].archiveSha256;+ if (manifest.archiveSha256 !== pinnedArchiveSha256) {+ throw new Error(+ `Custom Electron manifest archiveSha256 must be the ${runtime.releaseTag} archive pinned in electron/runtime.json: ${manifestPath}`,+ );}const archivePath = path.join(directory, archiveName);if ((await sha256File(archivePath)) !== manifest.archiveSha256) {diff --git a/fluxer_desktop/src/main/DesktopChromiumSPKIBlocklist.ts b/fluxer_desktop/src/main/DesktopChromiumSPKIBlocklist.tsindex 79e9d7316..64adbace0 100644--- a/fluxer_desktop/src/main/DesktopChromiumSPKIBlocklist.ts+++ b/fluxer_desktop/src/main/DesktopChromiumSPKIBlocklist.ts@@ -1,6 +1,7 @@// SPDX-License-Identifier: AGPL-3.0-or-later-export const CHROMIUM_SPKI_BLOCKLIST_SOURCE = 'chromium 152.0.7977.78 net/cert/cert_verify_proc_blocklist.inc';+export const CHROMIUM_SPKI_BLOCKLIST_SOURCE =+ 'chromium 152.0.7977.78 net/cert/cert_verify_proc_blocklist.inc and electron 44.9.1 add_entries_to_the_spki_blocklist.patch';export const CHROMIUM_SPKI_BLOCKLIST: ReadonlySet<string> = new Set(['04dde9aa9a79f61498682325fa0870276707fb9ca95384120b46893268494fc9',@@ -106,4 +107,12 @@ export const CHROMIUM_SPKI_BLOCKLIST: ReadonlySet<string> = new Set(['36ce75edea806f0985145683294e54dbdff02fc821870cf5067a308d1504be3a','a4e9af01416e3a029b5d35e5b119de00cfe156c5cf95fc823cf6d05e3c1a8237','3472e4f16c570e0dd388aaaa4a64a34a4b939f1ca770996b5be0037c1aded9c1',+ 'ebed6475c2c2d80fcb199f3fe8dd6e6b3ce60b77eb15d4e42c3dec0c6f5b5105',+ '43bffa19d6ef651451f6841e019931e96f6f2eaeff28ab4b6f1ce4576de2717b',+ 'e0254c7fcdc265e2f0f8a428dabb75ab4ae039b4872d62f5ee57f0877d5a8a41',+ '49dd353dc2b919a3770645117d0e60c16115e7d1bc259eefe734b00ea434fe5f',+ '63ecefee431d49523bc1136c4e72d0206a477086caf606cd5cf025686c109cf8',+ '5c0660a2b164910d8ff589c18e14552e9e0ec237dcefe2cb736d41a4811f81a0',+ 'ec4ffa1ad0ac88081314b7aaffef6a91f97cd57291bb5ba686c5415f5eb4f6b6',+ '92c063d67e8f14db71d288e11266ffdaf69cbf115f7bab14f3bc2f68d25e0e30',]);