mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-20 15:06:14 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7384fb3f4 |
No files matched your search
@@ -27,13 +27,14 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
platform:
|
||||||
- runner: ubuntu-24.04
|
- runner: ubuntu-24.04
|
||||||
arch: x86_64
|
arch: x86_64
|
||||||
- runner: ubuntu-24.04-arm
|
- runner: ubuntu-24.04-arm
|
||||||
arch: aarch64
|
arch: aarch64
|
||||||
runs-on: ${{ matrix.runner }}
|
suffix: ['', '-musl']
|
||||||
name: build (${{ matrix.arch }})
|
runs-on: ${{ matrix.platform.runner }}
|
||||||
|
name: build (${{ matrix.platform.arch }}${{ matrix.suffix }})
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
env:
|
env:
|
||||||
CARGO_INCREMENTAL: '0'
|
CARGO_INCREMENTAL: '0'
|
||||||
@@ -62,6 +63,7 @@ jobs:
|
|||||||
ref: ${{ inputs.gpgui_ref }}
|
ref: ${{ inputs.gpgui_ref }}
|
||||||
path: source/gpgui
|
path: source/gpgui
|
||||||
- name: Install Ubuntu 24.04 dependencies
|
- name: Install Ubuntu 24.04 dependencies
|
||||||
|
if: matrix.suffix == ''
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y autoconf automake gettext libtool pkg-config \
|
sudo apt-get install -y autoconf automake gettext libtool pkg-config \
|
||||||
@@ -69,8 +71,10 @@ jobs:
|
|||||||
libgnutls28-dev liblz4-dev libwayland-dev libxkbcommon-dev libdbus-1-dev
|
libgnutls28-dev liblz4-dev libwayland-dev libxkbcommon-dev libdbus-1-dev
|
||||||
pkg-config --exists gtk4 gnutls dbus-1 wayland-client xkbcommon
|
pkg-config --exists gtk4 gnutls dbus-1 wayland-client xkbcommon
|
||||||
- name: Install the NSH compiler
|
- name: Install the NSH compiler
|
||||||
|
if: matrix.suffix == ''
|
||||||
run: rustup toolchain install 1.97.0 --profile minimal
|
run: rustup toolchain install 1.97.0 --profile minimal
|
||||||
- name: Cache public crate downloads
|
- name: Cache public crate downloads
|
||||||
|
if: matrix.suffix == ''
|
||||||
uses: actions/cache@v5
|
uses: actions/cache@v5
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
@@ -79,33 +83,39 @@ jobs:
|
|||||||
key: nsh-crates-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('source/gpgui/apps/desktop-nsh/Cargo.lock') }}
|
key: nsh-crates-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('source/gpgui/apps/desktop-nsh/Cargo.lock') }}
|
||||||
restore-keys: nsh-crates-${{ runner.os }}-${{ runner.arch }}-
|
restore-keys: nsh-crates-${{ runner.os }}-${{ runner.arch }}-
|
||||||
- name: Build and package Native Shell
|
- name: Build and package Native Shell
|
||||||
|
env:
|
||||||
|
LIBC_SUFFIX: ${{ matrix.suffix }}
|
||||||
run: |
|
run: |
|
||||||
trap 'code=$?; if [ "$code" -ne 0 ]; then echo "::error::Native Shell build failed; diagnostics suppressed."; fi' EXIT
|
trap 'code=$?; if [ "$code" -ne 0 ]; then echo "::error::Native Shell build failed; diagnostics suppressed."; fi' EXIT
|
||||||
(
|
(
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd source/gpgui
|
if [[ "$LIBC_SUFFIX" == "-musl" ]]; then
|
||||||
cargo +1.97.0 build --manifest-path apps/desktop-nsh/Cargo.toml --locked \
|
docker run --rm --user root -v "$PWD/source:/source" -w /source/gpgui \
|
||||||
--release --bin gpgui-nsh --target-dir target
|
-e GPGUI_BUILD_VERSION -e GPGUI_GIT_COMMIT -e GPGUI_UPDATE_CHANNEL \
|
||||||
target/release/gpgui-nsh --version
|
-e GPGUI_LICENSE_SIGNING_KEYS -e CARGO_INCREMENTAL -e CARGO_BUILD_JOBS \
|
||||||
version="$(cargo +1.97.0 metadata --manifest-path apps/desktop-nsh/Cargo.toml --no-deps --format-version 1 \
|
yuezk/gpdev:gpgui-alpine-builder-tauri2 bash -ec '
|
||||||
| jq -r '.packages[] | select(.name == "gpgui-nsh") | .version')"
|
apk add --no-cache clang clang-dev gtk4.0-dev dbus-dev wayland-dev libxkbcommon-dev
|
||||||
directory="gpgui-nsh_$version"
|
rustup toolchain install 1.97.0 --profile minimal
|
||||||
archive="gpgui-nsh_$(uname -m).bin.tar.xz"
|
../gp/scripts/build-linux-nsh.sh
|
||||||
mkdir -p ".build/package/$directory"
|
'
|
||||||
cp target/release/gpgui-nsh ".build/package/$directory/"
|
else
|
||||||
cp apps/desktop-nsh/ICU4X-LICENSE.txt ".build/package/$directory/ICU4X-LICENSE.txt"
|
cd source/gpgui
|
||||||
if ldd target/release/gpgui-nsh | grep -q 'libicu'; then
|
../gp/scripts/build-linux-nsh.sh
|
||||||
echo "The release executable must not depend on ICU4C." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
tar -cJf ".build/package/$archive" -C .build/package "$directory"
|
|
||||||
sha256sum ".build/package/$archive" | cut -d ' ' -f 1 > ".build/package/$archive.sha256"
|
|
||||||
) >/dev/null 2>&1
|
) >/dev/null 2>&1
|
||||||
echo "Native Shell build and version check passed."
|
echo "Native Shell build and version check passed."
|
||||||
|
- name: Verify musl archive on Alpine
|
||||||
|
if: matrix.suffix == '-musl'
|
||||||
|
run: |
|
||||||
|
docker run --rm -v "$PWD/source/gpgui/.build/package:/assets:ro" alpine:3.23 sh -ec '
|
||||||
|
apk add --no-cache gtk4.0 gnutls dbus-libs libgcc xz
|
||||||
|
tar -xJf "/assets/gpgui-nsh_$(uname -m)-musl.bin.tar.xz"
|
||||||
|
./gpgui-nsh_*/gpgui-nsh --version >/dev/null 2>&1
|
||||||
|
'
|
||||||
- name: Upload Native Shell
|
- name: Upload Native Shell
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: artifact-gpgui-nsh-${{ matrix.arch }}
|
name: artifact-gpgui-nsh${{ matrix.suffix }}-${{ matrix.platform.arch }}
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
path: |
|
path: |
|
||||||
source/gpgui/.build/package/*.bin.tar.xz
|
source/gpgui/.build/package/*.bin.tar.xz
|
||||||
|
|||||||
@@ -311,14 +311,19 @@ jobs:
|
|||||||
if: ${{ !(startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.channel == 'stable')) }}
|
if: ${{ !(startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.channel == 'stable')) }}
|
||||||
needs:
|
needs:
|
||||||
- tarball
|
- tarball
|
||||||
|
- build-gpgui-glibc
|
||||||
|
- build-gpgui-musl
|
||||||
|
- build-gpgui-nsh
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
- runner: ubuntu-latest
|
- runner: ubuntu-latest
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
uname: x86_64
|
||||||
- runner: ubuntu-24.04-arm
|
- runner: ubuntu-24.04-arm
|
||||||
arch: ubuntu-24.04-arm
|
arch: ubuntu-24.04-arm
|
||||||
|
uname: aarch64
|
||||||
package: [deb, rpm, pkg, apk, binary, ubuntu-rolling]
|
package: [deb, rpm, pkg, apk, binary, ubuntu-rolling]
|
||||||
runs-on: ${{ matrix.os.runner }}
|
runs-on: ${{ matrix.os.runner }}
|
||||||
name: build-gp (${{ matrix.package }}, ${{ matrix.os.arch }})
|
name: build-gp (${{ matrix.package }}, ${{ matrix.os.arch }})
|
||||||
@@ -332,22 +337,41 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: artifact-source
|
name: artifact-source
|
||||||
path: build-gp-${{ matrix.package }}
|
path: build-gp-${{ matrix.package }}
|
||||||
|
- name: Download Tauri for this package
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: artifact-gpgui${{ matrix.package == 'apk' && '-musl' || '' }}-${{ matrix.os.arch }}
|
||||||
|
path: gui-assets
|
||||||
|
- name: Download Native Shell for this package
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: artifact-gpgui-nsh${{ matrix.package == 'apk' && '-musl' || '' }}-${{ matrix.os.uname }}
|
||||||
|
path: gui-assets
|
||||||
- name: Build ${{ matrix.package }} package in Docker
|
- name: Build ${{ matrix.package }} package in Docker
|
||||||
# LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros
|
# LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros
|
||||||
run: |
|
run: |
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||||
-e LIBXML2_STATIC=1 \
|
-e LIBXML2_STATIC=1 \
|
||||||
-v $(pwd)/build-gp-${{ matrix.package }}:/workspace \
|
-e INCLUDE_GUI=1 \
|
||||||
|
-e GUI_ASSET_BASE=file:///gui-assets \
|
||||||
|
-v "$PWD/gui-assets:/gui-assets:ro" \
|
||||||
|
-v "$PWD/build-gp-${{ matrix.package }}:/workspace" \
|
||||||
yuezk/gpdev:${{ matrix.package }}-builder-tauri2
|
yuezk/gpdev:${{ matrix.package }}-builder-tauri2
|
||||||
|
- name: Checkout package verification script
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
path: .ci
|
||||||
|
sparse-checkout: scripts
|
||||||
|
persist-credentials: false
|
||||||
- name: Install ${{ matrix.package }} package in Docker
|
- name: Install ${{ matrix.package }} package in Docker
|
||||||
run: |
|
run: |
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
|
-v "$PWD/.ci/scripts/verify-linux-package.sh:/verify-linux-package.sh:ro" \
|
||||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||||
-e GPGUI_INSTALLED=0 \
|
-v "$PWD/build-gp-${{ matrix.package }}:/workspace" \
|
||||||
-v $(pwd)/build-gp-${{ matrix.package }}:/workspace \
|
|
||||||
yuezk/gpdev:${{ matrix.package }}-builder-tauri2 \
|
yuezk/gpdev:${{ matrix.package }}-builder-tauri2 \
|
||||||
bash install.sh
|
bash -ec 'bash install.sh && bash /verify-linux-package.sh "$1"' _ "${{ matrix.package }}"
|
||||||
# Don't upload package for ubuntu-rolling because it's duplicate of deb package
|
# Don't upload package for ubuntu-rolling because it's duplicate of deb package
|
||||||
- name: Upload ${{ matrix.package }} package
|
- name: Upload ${{ matrix.package }} package
|
||||||
if: ${{ matrix.package != 'ubuntu-rolling' }}
|
if: ${{ matrix.package != 'ubuntu-rolling' }}
|
||||||
@@ -498,16 +522,18 @@ jobs:
|
|||||||
WINDOWS_UPDATE_PRIVATE_KEY: ${{ secrets.WINDOWS_UPDATE_PRIVATE_KEY }}
|
WINDOWS_UPDATE_PRIVATE_KEY: ${{ secrets.WINDOWS_UPDATE_PRIVATE_KEY }}
|
||||||
|
|
||||||
nix-source:
|
nix-source:
|
||||||
needs: [validate-inputs, build-gpgui-glibc]
|
needs: [validate-inputs, build-gpgui-glibc, build-gpgui-nsh]
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
platform:
|
platform:
|
||||||
- runner: ubuntu-latest
|
- runner: ubuntu-latest
|
||||||
system: x86_64-linux
|
system: x86_64-linux
|
||||||
|
nsh_arch: x86_64
|
||||||
artifact_arch: amd64
|
artifact_arch: amd64
|
||||||
- runner: ubuntu-24.04-arm
|
- runner: ubuntu-24.04-arm
|
||||||
system: aarch64-linux
|
system: aarch64-linux
|
||||||
|
nsh_arch: aarch64
|
||||||
artifact_arch: ubuntu-24.04-arm
|
artifact_arch: ubuntu-24.04-arm
|
||||||
runs-on: ${{ matrix.platform.runner }}
|
runs-on: ${{ matrix.platform.runner }}
|
||||||
name: nix-source (${{ matrix.platform.system }})
|
name: nix-source (${{ matrix.platform.system }})
|
||||||
@@ -527,6 +553,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: artifact-gpgui-${{ matrix.platform.artifact_arch }}
|
name: artifact-gpgui-${{ matrix.platform.artifact_arch }}
|
||||||
path: nix-artifacts/gui
|
path: nix-artifacts/gui
|
||||||
|
- name: Download current Native Shell artifact
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: artifact-gpgui-nsh-${{ matrix.platform.nsh_arch }}
|
||||||
|
path: nix-artifacts/nsh
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: cachix/install-nix-action@v31
|
uses: cachix/install-nix-action@v31
|
||||||
- name: Configure current source and GUI inputs
|
- name: Configure current source and GUI inputs
|
||||||
@@ -535,6 +566,9 @@ jobs:
|
|||||||
gui_archive=$(find "$PWD/nix-artifacts/gui" -name '*.bin.tar.xz' -type f)
|
gui_archive=$(find "$PWD/nix-artifacts/gui" -name '*.bin.tar.xz' -type f)
|
||||||
test -f "$gui_archive"
|
test -f "$gui_archive"
|
||||||
echo "GP_GUI_ARCHIVE=$gui_archive" >> "$GITHUB_ENV"
|
echo "GP_GUI_ARCHIVE=$gui_archive" >> "$GITHUB_ENV"
|
||||||
|
nsh_archive="$PWD/nix-artifacts/nsh/gpgui-nsh_${{ matrix.platform.nsh_arch }}.bin.tar.xz"
|
||||||
|
test -f "$nsh_archive"
|
||||||
|
echo "GP_NSH_ARCHIVE=$nsh_archive" >> "$GITHUB_ENV"
|
||||||
- name: Build source package
|
- name: Build source package
|
||||||
run: |
|
run: |
|
||||||
nix build --impure --file gp/nix/ci.nix source \
|
nix build --impure --file gp/nix/ci.nix source \
|
||||||
@@ -547,16 +581,18 @@ jobs:
|
|||||||
--extra-experimental-features "nix-command flakes" --print-build-logs
|
--extra-experimental-features "nix-command flakes" --print-build-logs
|
||||||
|
|
||||||
nix-prebuilt:
|
nix-prebuilt:
|
||||||
needs: [validate-inputs, build-gp, build-gpgui-glibc]
|
needs: [validate-inputs, build-gp, build-gpgui-glibc, build-gpgui-nsh]
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
platform:
|
platform:
|
||||||
- runner: ubuntu-latest
|
- runner: ubuntu-latest
|
||||||
system: x86_64-linux
|
system: x86_64-linux
|
||||||
|
nsh_arch: x86_64
|
||||||
artifact_arch: amd64
|
artifact_arch: amd64
|
||||||
- runner: ubuntu-24.04-arm
|
- runner: ubuntu-24.04-arm
|
||||||
system: aarch64-linux
|
system: aarch64-linux
|
||||||
|
nsh_arch: aarch64
|
||||||
artifact_arch: ubuntu-24.04-arm
|
artifact_arch: ubuntu-24.04-arm
|
||||||
nixpkgs: [locked, nixos-25.11, nixos-26.05, nixpkgs-unstable]
|
nixpkgs: [locked, nixos-25.11, nixos-26.05, nixpkgs-unstable]
|
||||||
runs-on: ${{ matrix.platform.runner }}
|
runs-on: ${{ matrix.platform.runner }}
|
||||||
@@ -582,6 +618,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: artifact-gpgui-${{ matrix.platform.artifact_arch }}
|
name: artifact-gpgui-${{ matrix.platform.artifact_arch }}
|
||||||
path: nix-artifacts/gui
|
path: nix-artifacts/gui
|
||||||
|
- name: Download current Native Shell artifact
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: artifact-gpgui-nsh-${{ matrix.platform.nsh_arch }}
|
||||||
|
path: nix-artifacts/nsh
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: cachix/install-nix-action@v31
|
uses: cachix/install-nix-action@v31
|
||||||
- name: Configure current artifact inputs
|
- name: Configure current artifact inputs
|
||||||
@@ -593,6 +634,9 @@ jobs:
|
|||||||
test -f "$gui_archive"
|
test -f "$gui_archive"
|
||||||
echo "GP_BINARY_ARCHIVE=$binary_archive" >> "$GITHUB_ENV"
|
echo "GP_BINARY_ARCHIVE=$binary_archive" >> "$GITHUB_ENV"
|
||||||
echo "GP_GUI_ARCHIVE=$gui_archive" >> "$GITHUB_ENV"
|
echo "GP_GUI_ARCHIVE=$gui_archive" >> "$GITHUB_ENV"
|
||||||
|
nsh_archive="$PWD/nix-artifacts/nsh/gpgui-nsh_${{ matrix.platform.nsh_arch }}.bin.tar.xz"
|
||||||
|
test -f "$nsh_archive"
|
||||||
|
echo "GP_NSH_ARCHIVE=$nsh_archive" >> "$GITHUB_ENV"
|
||||||
- name: Build package through host NixOS module
|
- name: Build package through host NixOS module
|
||||||
run: |
|
run: |
|
||||||
nix build --impure --file gp/nix/ci.nix module \
|
nix build --impure --file gp/nix/ci.nix module \
|
||||||
@@ -603,10 +647,20 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
nix build --impure --file gp/nix/ci.nix prebuilt \
|
nix build --impure --file gp/nix/ci.nix prebuilt \
|
||||||
--extra-experimental-features "nix-command flakes" --print-build-logs
|
--extra-experimental-features "nix-command flakes" --print-build-logs
|
||||||
|
- name: Install and run downloaded Native Shell through the Nix installer
|
||||||
|
if: matrix.nixpkgs == 'locked'
|
||||||
|
run: |
|
||||||
|
gui_archive="$GP_NSH_ARCHIVE"
|
||||||
|
target="$RUNNER_TEMP/nix-gui-install/gpgui-nsh"
|
||||||
|
mkdir -p "$(dirname "$target")"
|
||||||
|
checksum=$(sha256sum "$gui_archive" | cut -d ' ' -f1)
|
||||||
|
result/libexec/gpclient/gp-gui-installer "$gui_archive" "$checksum" "$target"
|
||||||
|
test -L "$target"
|
||||||
|
test "$("$target" --version)" = "$(result/bin/gpgui-nsh --version)"
|
||||||
- name: Test prebuilt runtime in NixOS
|
- name: Test prebuilt runtime in NixOS
|
||||||
if: matrix.nixpkgs == 'locked' && matrix.platform.system == 'x86_64-linux'
|
if: matrix.nixpkgs == 'locked' && matrix.platform.system == 'x86_64-linux'
|
||||||
run: |
|
run: |
|
||||||
nix build --impure --file gp/nix/ci.nix runtime-prebuilt \
|
nix build --impure --file gp/nix/ci.nix runtime-prebuilt graphical-prebuilt \
|
||||||
--extra-experimental-features "nix-command flakes" --print-build-logs
|
--extra-experimental-features "nix-command flakes" --print-build-logs
|
||||||
|
|
||||||
build-macos:
|
build-macos:
|
||||||
|
|||||||
@@ -127,19 +127,26 @@ jobs:
|
|||||||
# LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros
|
# LIBXML2_STATIC is needed to avoid the dynamic linking issue on different distros
|
||||||
run: |
|
run: |
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
-v $(pwd)/build-${{ matrix.package }}:/workspace \
|
-v "$PWD/build-${{ matrix.package }}:/workspace" \
|
||||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||||
-e LIBXML2_STATIC=1 \
|
-e LIBXML2_STATIC=1 \
|
||||||
-e INCLUDE_GUI=1 \
|
-e INCLUDE_GUI=1 \
|
||||||
yuezk/gpdev:${{ matrix.package }}-builder-tauri2
|
yuezk/gpdev:${{ matrix.package }}-builder-tauri2
|
||||||
|
|
||||||
|
- name: Checkout package verification script
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
path: .ci
|
||||||
|
sparse-checkout: scripts
|
||||||
|
persist-credentials: false
|
||||||
- name: Install ${{ matrix.package }} package in Docker
|
- name: Install ${{ matrix.package }} package in Docker
|
||||||
run: |
|
run: |
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
|
-v "$PWD/.ci/scripts/verify-linux-package.sh:/verify-linux-package.sh:ro" \
|
||||||
-e COREPACK_INTEGRITY_KEYS=0 \
|
-e COREPACK_INTEGRITY_KEYS=0 \
|
||||||
-v $(pwd)/build-${{ matrix.package }}:/workspace \
|
-v "$PWD/build-${{ matrix.package }}:/workspace" \
|
||||||
yuezk/gpdev:${{ matrix.package }}-builder-tauri2 \
|
yuezk/gpdev:${{ matrix.package }}-builder-tauri2 \
|
||||||
bash install.sh
|
bash -ec 'bash install.sh && bash /verify-linux-package.sh "$1"' _ "${{ matrix.package }}"
|
||||||
|
|
||||||
- name: Upload ${{ matrix.package }} package
|
- name: Upload ${{ matrix.package }} package
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
|
|||||||
@@ -62,6 +62,15 @@ jobs:
|
|||||||
}, indent=2) + '\n')
|
}, indent=2) + '\n')
|
||||||
PYRELEASE
|
PYRELEASE
|
||||||
|
|
||||||
|
- name: Verify all published Native Shell downloads before promotion
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
RELEASE_TAG: ${{ steps.release.outputs.release_tag }}
|
||||||
|
run: |
|
||||||
|
gh release download "$RELEASE_TAG" --repo yuezk/GlobalProtect-openconnect \
|
||||||
|
--pattern 'gpgui-nsh_*.bin.tar.xz*' --dir "$RUNNER_TEMP/nsh-release"
|
||||||
|
scripts/verify-linux-nsh-assets.sh "$RUNNER_TEMP/nsh-release"
|
||||||
|
|
||||||
- name: Install Nix
|
- name: Install Nix
|
||||||
uses: cachix/install-nix-action@v31
|
uses: cachix/install-nix-action@v31
|
||||||
|
|
||||||
|
|||||||
Generated
+13
-13
@@ -292,7 +292,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "auth"
|
name = "auth"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"block2",
|
"block2",
|
||||||
@@ -554,7 +554,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "browser-launcher"
|
name = "browser-launcher"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"log",
|
"log",
|
||||||
@@ -919,7 +919,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "common"
|
name = "common"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
]
|
||||||
@@ -2133,7 +2133,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gp-xml"
|
name = "gp-xml"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"url",
|
"url",
|
||||||
"xmltree",
|
"xmltree",
|
||||||
@@ -2141,7 +2141,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpapi"
|
name = "gpapi"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64 0.23.1",
|
"base64 0.23.1",
|
||||||
@@ -2205,7 +2205,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpauth"
|
name = "gpauth"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"auth",
|
"auth",
|
||||||
@@ -2223,7 +2223,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpclient"
|
name = "gpclient"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -2254,7 +2254,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpgui-helper"
|
name = "gpgui-helper"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -2275,7 +2275,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gphip"
|
name = "gphip"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"askama",
|
"askama",
|
||||||
@@ -2294,7 +2294,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpservice"
|
name = "gpservice"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -2332,7 +2332,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gptunnel"
|
name = "gptunnel"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gpapi",
|
"gpapi",
|
||||||
"log",
|
"log",
|
||||||
@@ -2344,7 +2344,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpvpnc"
|
name = "gpvpnc"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.23.1",
|
"base64 0.23.1",
|
||||||
"ipnet",
|
"ipnet",
|
||||||
@@ -3860,7 +3860,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openconnect"
|
name = "openconnect"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autotools",
|
"autotools",
|
||||||
"cc",
|
"cc",
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ members = [
|
|||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
rust-version = "1.91"
|
rust-version = "1.91"
|
||||||
version = "3.6.0"
|
version = "3.7.0"
|
||||||
authors = ["Kevin Yue <[email protected]>"]
|
authors = ["Kevin Yue <[email protected]>"]
|
||||||
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
|
homepage = "https://github.com/yuezk/GlobalProtect-openconnect"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ SOURCE_COMMIT_VALUE := $(shell \
|
|||||||
git rev-parse --short=9 HEAD 2>/dev/null || printf unknown; \
|
git rev-parse --short=9 HEAD 2>/dev/null || printf unknown; \
|
||||||
fi)
|
fi)
|
||||||
GUI_LIBC_SUFFIX ?= $(shell ldd --version 2>&1 | grep -qi musl && echo -musl || true)
|
GUI_LIBC_SUFFIX ?= $(shell ldd --version 2>&1 | grep -qi musl && echo -musl || true)
|
||||||
|
GUI_ASSET_BASE ?= https://github.com/yuezk/GlobalProtect-openconnect/releases/download/$(RELEASE_TAG)
|
||||||
REVISION ?= 1
|
REVISION ?= 1
|
||||||
RPM_SOURCE ?= %{name}.tar.gz
|
RPM_SOURCE ?= %{name}.tar.gz
|
||||||
|
|
||||||
@@ -33,16 +34,21 @@ PUBLISH ?= 0
|
|||||||
# Indicates whether to build the GUI components
|
# Indicates whether to build the GUI components
|
||||||
BUILD_GUI_HELPER ?= 1
|
BUILD_GUI_HELPER ?= 1
|
||||||
|
|
||||||
# Indicates whether to build embedded webview auth support into gpauth
|
# Build embedded webview authentication support into gpclient and gpauth
|
||||||
BUILD_WEBVIEW_AUTH ?= 1
|
BUILD_WEBVIEW_AUTH ?= 1
|
||||||
|
ifneq ($(BUILD_WEBVIEW_AUTH),1)
|
||||||
|
AUTH_FEATURE_ARGS = --no-default-features
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(shell uname -s),Linux)
|
ifeq ($(shell uname -s),Linux)
|
||||||
PREFIX ?= /usr
|
PREFIX ?= /usr
|
||||||
GPGUI_BINARY ?= $(wildcard .build/gpgui/gpgui_*/gpgui)
|
GPGUI_BINARY ?= .build/gpgui/gpgui_$(VERSION)/gpgui
|
||||||
else ifeq ($(shell uname -s)-$(shell uname -m),Darwin-arm64)
|
else ifeq ($(shell uname -s)-$(shell uname -m),Darwin-arm64)
|
||||||
PREFIX ?= /opt/homebrew
|
PREFIX ?= /opt/homebrew
|
||||||
else
|
else
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
endif
|
endif
|
||||||
|
NSH_BUNDLE_DIR = .build/gpgui/gpgui-nsh_$(VERSION)
|
||||||
BSD_FLAVOR ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
BSD_FLAVOR ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
GPGUI_BINARY ?= ../gpgui/target/release/gpgui
|
GPGUI_BINARY ?= ../gpgui/target/release/gpgui
|
||||||
|
|
||||||
@@ -109,9 +115,14 @@ download-gui:
|
|||||||
if [ $(INCLUDE_GUI) -eq 1 ]; then \
|
if [ $(INCLUDE_GUI) -eq 1 ]; then \
|
||||||
echo "Downloading GlobalProtect GUI..."; \
|
echo "Downloading GlobalProtect GUI..."; \
|
||||||
mkdir -p .build/gpgui; \
|
mkdir -p .build/gpgui; \
|
||||||
curl -sSL https://github.com/yuezk/GlobalProtect-openconnect/releases/download/$(RELEASE_TAG)/gpgui_$(shell uname -m)$(GUI_LIBC_SUFFIX).bin.tar.xz \
|
set -e; cd .build/gpgui; \
|
||||||
-o .build/gpgui/gpgui_$(shell uname -m)$(GUI_LIBC_SUFFIX).bin.tar.xz; \
|
for gui in gpgui gpgui-nsh; do \
|
||||||
tar -xJf .build/gpgui/*.tar.xz -C .build/gpgui; \
|
archive="$${gui}_$(shell uname -m)$(GUI_LIBC_SUFFIX).bin.tar.xz"; \
|
||||||
|
curl -fsSL "$(GUI_ASSET_BASE)/$$archive" -o "$$archive"; \
|
||||||
|
digest=$$(curl -fsSL "$(GUI_ASSET_BASE)/$$archive.sha256"); \
|
||||||
|
printf '%s %s\n' "$$digest" "$$archive" | sha256sum -c -; \
|
||||||
|
tar -xJf "$$archive"; \
|
||||||
|
done; \
|
||||||
else \
|
else \
|
||||||
echo "Skipping GlobalProtect GUI download (INCLUDE_GUI=0)"; \
|
echo "Skipping GlobalProtect GUI download (INCLUDE_GUI=0)"; \
|
||||||
fi
|
fi
|
||||||
@@ -128,14 +139,7 @@ build-rs:
|
|||||||
rm -vf rust-toolchain.toml; \
|
rm -vf rust-toolchain.toml; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpclient -p gpservice
|
$(CARGO) build $(CARGO_BUILD_ARGS) $(AUTH_FEATURE_ARGS) -p gpclient -p gpservice -p gpauth
|
||||||
|
|
||||||
# Build gpauth with or without embedded webview auth support
|
|
||||||
if [ $(BUILD_WEBVIEW_AUTH) -eq 1 ]; then \
|
|
||||||
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpauth; \
|
|
||||||
else \
|
|
||||||
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpauth --no-default-features; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Only build the GUI components if BUILD_GUI_HELPER is set to 1
|
# Only build the GUI components if BUILD_GUI_HELPER is set to 1
|
||||||
if [ $(BUILD_GUI_HELPER) -eq 1 ]; then \
|
if [ $(BUILD_GUI_HELPER) -eq 1 ]; then \
|
||||||
@@ -197,6 +201,12 @@ install-unix: install-gpclient-unix
|
|||||||
done
|
done
|
||||||
|
|
||||||
install-linux: install-unix
|
install-linux: install-unix
|
||||||
|
ifeq ($(INCLUDE_GUI),1)
|
||||||
|
test -x "$(GPGUI_BINARY)"
|
||||||
|
install -m 755 "$(NSH_BUNDLE_DIR)/gpgui-nsh" "$(DESTDIR)$(PREFIX)/bin/gpgui-nsh"
|
||||||
|
install -d "$(DESTDIR)$(PREFIX)/share/licenses/$(PKG_NAME)"
|
||||||
|
install -m 644 "$(NSH_BUNDLE_DIR)/ICU4X-LICENSE.txt" "$(DESTDIR)$(PREFIX)/share/licenses/$(PKG_NAME)/"
|
||||||
|
endif
|
||||||
@echo "Installing Linux integration under $(PREFIX)..."
|
@echo "Installing Linux integration under $(PREFIX)..."
|
||||||
set -e; for file in share/applications/gpgui.desktop \
|
set -e; for file in share/applications/gpgui.desktop \
|
||||||
share/applications/gpgui-helper.desktop \
|
share/applications/gpgui-helper.desktop \
|
||||||
@@ -327,6 +337,8 @@ uninstall-unix:
|
|||||||
rmdir "$(DESTDIR)$(PREFIX)/libexec/gpclient" 2>/dev/null || true
|
rmdir "$(DESTDIR)$(PREFIX)/libexec/gpclient" 2>/dev/null || true
|
||||||
|
|
||||||
uninstall-linux: uninstall-unix
|
uninstall-linux: uninstall-unix
|
||||||
|
rm -f "$(DESTDIR)$(PREFIX)/bin/gpgui-nsh" "$(DESTDIR)$(PREFIX)/share/licenses/$(PKG_NAME)/ICU4X-LICENSE.txt"
|
||||||
|
rmdir "$(DESTDIR)$(PREFIX)/share/licenses/$(PKG_NAME)" 2>/dev/null || true
|
||||||
rm -f "$(DESTDIR)$(PREFIX)/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down" \
|
rm -f "$(DESTDIR)$(PREFIX)/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down" \
|
||||||
"$(DESTDIR)$(PREFIX)/lib/NetworkManager/dispatcher.d/gpclient-nm-hook"
|
"$(DESTDIR)$(PREFIX)/lib/NetworkManager/dispatcher.d/gpclient-nm-hook"
|
||||||
rm -f "$(DESTDIR)/var/lib/gpclient/gpgui" \
|
rm -f "$(DESTDIR)/var/lib/gpclient/gpgui" \
|
||||||
@@ -429,7 +441,7 @@ rpm: init-rpm tarball
|
|||||||
rpmdev-setuptree
|
rpmdev-setuptree
|
||||||
|
|
||||||
cp .build/tarball/${PKG}.tar.gz $(HOME)/rpmbuild/SOURCES/${PKG_NAME}.tar.gz
|
cp .build/tarball/${PKG}.tar.gz $(HOME)/rpmbuild/SOURCES/${PKG_NAME}.tar.gz
|
||||||
rpmbuild -ba .build/rpm/globalprotect-openconnect.spec
|
rpmbuild --define "include_gui $(INCLUDE_GUI)" -ba .build/rpm/globalprotect-openconnect.spec
|
||||||
|
|
||||||
# Copy RPM package from build directory
|
# Copy RPM package from build directory
|
||||||
cp $(HOME)/rpmbuild/RPMS/$(shell uname -m)/$(PKG_NAME)*.rpm .build/rpm
|
cp $(HOME)/rpmbuild/RPMS/$(shell uname -m)/$(PKG_NAME)*.rpm .build/rpm
|
||||||
@@ -499,7 +511,7 @@ binary: clean-binary tarball
|
|||||||
mkdir -p .build/binary/$(PKG_NAME)_$(VERSION)/artifacts
|
mkdir -p .build/binary/$(PKG_NAME)_$(VERSION)/artifacts
|
||||||
|
|
||||||
make -C .build/binary/${PKG} build INCLUDE_GUI=$(INCLUDE_GUI)
|
make -C .build/binary/${PKG} build INCLUDE_GUI=$(INCLUDE_GUI)
|
||||||
make -C .build/binary/${PKG} install DESTDIR=$(PWD)/.build/binary/$(PKG_NAME)_$(VERSION)/artifacts
|
make -C .build/binary/${PKG} install INCLUDE_GUI=$(INCLUDE_GUI) DESTDIR=$(PWD)/.build/binary/$(PKG_NAME)_$(VERSION)/artifacts
|
||||||
|
|
||||||
cp packaging/binary/Makefile.in .build/binary/$(PKG_NAME)_$(VERSION)/Makefile
|
cp packaging/binary/Makefile.in .build/binary/$(PKG_NAME)_$(VERSION)/Makefile
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,9 @@ Run `gpclient --help` or `gpclient <command> --help` to view all available comma
|
|||||||
```
|
```
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> **On Linux, try Native Shell for lower memory usage.** Switch between Native Shell and Tauri in **Settings → General → Interface**.
|
> On Linux, GP Connect uses Native Shell when your system supports it. Your saved interface choice takes priority. Switch while disconnected in **Settings → General → Interface**.
|
||||||
|
>
|
||||||
|
> If the window stays blank, fully quit GP Connect and run `gpclient launch-gui --interface tauri`. To select Native Shell, use `--interface nsh`. The choice is saved when the interface starts.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -252,7 +254,7 @@ sudo make install
|
|||||||
|
|
||||||
- [Rust](https://www.rust-lang.org/tools/install) 1.91 or later
|
- [Rust](https://www.rust-lang.org/tools/install) 1.91 or later
|
||||||
- Build tools: `make`, `pkg-config`, `autoconf`, `automake`, `libtool`, `gettext`
|
- Build tools: `make`, `pkg-config`, `autoconf`, `automake`, `libtool`, `gettext`
|
||||||
- Libraries: `gmp`, `gnutls`, `nettle`, `libxml2`, `zlib`, `lz4`, `p11-kit`, `libsecret`, and `webkit2gtk-4.1` (or GTK 4 for Native Shell)
|
- Libraries: `gmp`, `gnutls`, `nettle`, `libxml2`, `zlib`, `lz4`, `p11-kit`, `libsecret`, and `webkit2gtk-4.1` for the embedded sign-in window and download helper. Native Shell also requires GTK 4.14 or later. The generic glibc build requires glibc 2.39 or later
|
||||||
- Polkit (`pkexec`) for privileged tunnel setup
|
- Polkit (`pkexec`) for privileged tunnel setup
|
||||||
|
|
||||||
*(For FreeBSD and OpenBSD instructions, see [Building from Source on FreeBSD and OpenBSD](docs/bsd-source-build.md)).*
|
*(For FreeBSD and OpenBSD instructions, see [Building from Source on FreeBSD and OpenBSD](docs/bsd-source-build.md)).*
|
||||||
@@ -269,7 +271,7 @@ sudo make install
|
|||||||
**Build Options:**
|
**Build Options:**
|
||||||
|
|
||||||
- `INCLUDE_GUI=1` – Download and install the matching desktop application bundle.
|
- `INCLUDE_GUI=1` – Download and install the matching desktop application bundle.
|
||||||
- `BUILD_WEBVIEW_AUTH=0` – Build `gpauth` without embedded browser authentication (uses external browser or manual mode).
|
- `BUILD_WEBVIEW_AUTH=0` – Disable embedded browser authentication in both `gpclient` and `gpauth`. External-browser and manual sign-in remain available.
|
||||||
- `BUILD_GUI_HELPER=0` – Skip building the helper UI.
|
- `BUILD_GUI_HELPER=0` – Skip building the helper UI.
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|||||||
@@ -486,6 +486,25 @@ mod tests {
|
|||||||
assert!(cli.can_run_alongside_client());
|
assert!(cli.can_run_alongside_client());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
fn launch_gui_interface_accepts_minimized_launch_but_not_an_auth_callback() {
|
||||||
|
for variant in ["tauri", "nsh"] {
|
||||||
|
assert!(Cli::try_parse_from(["gpclient", "launch-gui", "--interface", variant, "--minimized"]).is_ok());
|
||||||
|
assert!(
|
||||||
|
Cli::try_parse_from([
|
||||||
|
"gpclient",
|
||||||
|
"launch-gui",
|
||||||
|
"--interface",
|
||||||
|
variant,
|
||||||
|
"globalprotectcallback:token"
|
||||||
|
])
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
assert!(Cli::try_parse_from(["gpclient", "launch-gui", "--interface", "unknown"]).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
|
||||||
fn launch_gui_rejects_callback_with_minimized() {
|
fn launch_gui_rejects_callback_with_minimized() {
|
||||||
|
|||||||
@@ -24,6 +24,14 @@ pub(crate) struct LaunchGuiArgs {
|
|||||||
help = "The external-browser authentication callback URL"
|
help = "The external-browser authentication callback URL"
|
||||||
)]
|
)]
|
||||||
callback: Option<String>,
|
callback: Option<String>,
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
value_enum,
|
||||||
|
conflicts_with = "callback",
|
||||||
|
help = "Launch this interface and remember it for future launches"
|
||||||
|
)]
|
||||||
|
interface: Option<gpapi::gui::GuiVariant>,
|
||||||
#[arg(long, help = "Launch the GUI minimized")]
|
#[arg(long, help = "Launch the GUI minimized")]
|
||||||
minimized: bool,
|
minimized: bool,
|
||||||
}
|
}
|
||||||
@@ -61,7 +69,10 @@ impl<'a> LaunchGuiHandler<'a> {
|
|||||||
return forward_auth_callback(callback);
|
return forward_auth_callback(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
if DesktopLauncher::activate_existing().await.is_ok() {
|
let launcher = DesktopLauncher::new(env!("CARGO_PKG_VERSION")).minimized(self.args.minimized);
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
let launcher = launcher.interface(self.args.interface);
|
||||||
|
if launcher.activate_or_reject_existing().await? {
|
||||||
info!("The GUI is already running");
|
info!("The GUI is already running");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -71,11 +82,7 @@ impl<'a> LaunchGuiHandler<'a> {
|
|||||||
|
|
||||||
info!("Log file: {}", log_file_path);
|
info!("Log file: {}", log_file_path);
|
||||||
|
|
||||||
let exit_status = DesktopLauncher::new(env!("CARGO_PKG_VERSION"))
|
let exit_status = launcher.log_file(&log_file_path).launch().await?;
|
||||||
.minimized(self.args.minimized)
|
|
||||||
.log_file(&log_file_path)
|
|
||||||
.launch()
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
info!("Service exited with status: {}", exit_status);
|
info!("Service exited with status: {}", exit_status);
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use std::{io::Read, sync::Arc};
|
|||||||
use anyhow::{Context, bail};
|
use anyhow::{Context, bail};
|
||||||
use gpapi::{
|
use gpapi::{
|
||||||
clap::InfoLevelVerbosity,
|
clap::InfoLevelVerbosity,
|
||||||
gui::GuiTheme,
|
gui::{GuiTheme, GuiVariant, NATIVE_SHELL_SUPPORTED},
|
||||||
service::transport::{MAX_CREDENTIAL_FRAME, SessionCredential},
|
service::transport::{MAX_CREDENTIAL_FRAME, SessionCredential},
|
||||||
utils::env_utils,
|
utils::env_utils,
|
||||||
};
|
};
|
||||||
@@ -30,8 +30,8 @@ struct Cli {
|
|||||||
|
|
||||||
#[arg(long, default_value = env!("CARGO_PKG_VERSION"), help = "The version of the GUI")]
|
#[arg(long, default_value = env!("CARGO_PKG_VERSION"), help = "The version of the GUI")]
|
||||||
gui_version: String,
|
gui_version: String,
|
||||||
#[arg(long, default_value = "tauri", value_parser = ["tauri", "nsh"])]
|
#[arg(long, value_enum, default_value_t = GuiVariant::Tauri)]
|
||||||
gui_variant: String,
|
gui_variant: GuiVariant,
|
||||||
|
|
||||||
#[arg(long, value_enum, default_value = "system", help = "Window appearance")]
|
#[arg(long, value_enum, default_value = "system", help = "Window appearance")]
|
||||||
theme: GuiTheme,
|
theme: GuiTheme,
|
||||||
@@ -44,20 +44,15 @@ impl Cli {
|
|||||||
fn run(&self) -> anyhow::Result<()> {
|
fn run(&self) -> anyhow::Result<()> {
|
||||||
let credential = self.read_credential()?;
|
let credential = self.read_credential()?;
|
||||||
let credential_lease = monitor_credential_lease().context("Failed to monitor service credential lifetime")?;
|
let credential_lease = monitor_credential_lease().context("Failed to monitor service credential lifetime")?;
|
||||||
let variant = if self.gui_variant == "nsh" {
|
|
||||||
gpapi::gui::GuiVariant::Nsh
|
|
||||||
} else {
|
|
||||||
gpapi::gui::GuiVariant::Tauri
|
|
||||||
};
|
|
||||||
anyhow::ensure!(
|
anyhow::ensure!(
|
||||||
variant != gpapi::gui::GuiVariant::Nsh || cfg!(target_os = "linux"),
|
self.gui_variant != GuiVariant::Nsh || NATIVE_SHELL_SUPPORTED,
|
||||||
"Native Shell is available only on Linux"
|
"Native Shell is unavailable for this platform"
|
||||||
);
|
);
|
||||||
let app = App::new(
|
let app = App::new(
|
||||||
Arc::new(credential),
|
Arc::new(credential),
|
||||||
credential_lease,
|
credential_lease,
|
||||||
&self.gui_version,
|
&self.gui_version,
|
||||||
variant,
|
self.gui_variant,
|
||||||
self.theme,
|
self.theme,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -42,22 +42,17 @@ const GUI_LIBC_SUFFIX: &str = "-musl";
|
|||||||
const GUI_LIBC_SUFFIX: &str = "";
|
const GUI_LIBC_SUFFIX: &str = "";
|
||||||
|
|
||||||
fn gui_asset_name(variant: gpapi::gui::GuiVariant) -> Option<String> {
|
fn gui_asset_name(variant: gpapi::gui::GuiVariant) -> Option<String> {
|
||||||
|
gui_asset_name_for(variant, std::env::consts::OS, std::env::consts::ARCH, GUI_LIBC_SUFFIX)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn gui_asset_name_for(variant: gpapi::gui::GuiVariant, os: &str, arch: &str, libc_suffix: &str) -> Option<String> {
|
||||||
|
if os == "linux" && matches!(arch, "x86_64" | "aarch64") {
|
||||||
|
return Some(format!("{}_{arch}{libc_suffix}.bin.tar.xz", variant.binary_name()));
|
||||||
|
}
|
||||||
if variant == gpapi::gui::GuiVariant::Nsh {
|
if variant == gpapi::gui::GuiVariant::Nsh {
|
||||||
return nsh_asset_name_for(std::env::consts::OS, std::env::consts::ARCH);
|
return None;
|
||||||
}
|
}
|
||||||
gui_asset_name_for(std::env::consts::OS, std::env::consts::ARCH, GUI_LIBC_SUFFIX)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn nsh_asset_name_for(os: &str, arch: &str) -> Option<String> {
|
|
||||||
match (os, arch) {
|
|
||||||
("linux", "x86_64" | "aarch64") => Some(format!("gpgui-nsh_{arch}.bin.tar.xz")),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn gui_asset_name_for(os: &str, arch: &str, libc_suffix: &str) -> Option<String> {
|
|
||||||
let name = match (os, arch) {
|
let name = match (os, arch) {
|
||||||
("linux", "x86_64" | "aarch64") => format!("gpgui_{arch}{libc_suffix}.bin.tar.xz"),
|
|
||||||
("freebsd", "x86_64") => "gpgui_freebsd_amd64.bin.tar.xz".to_owned(),
|
("freebsd", "x86_64") => "gpgui_freebsd_amd64.bin.tar.xz".to_owned(),
|
||||||
("freebsd", "aarch64") => "gpgui_freebsd_arm64.bin.tar.xz".to_owned(),
|
("freebsd", "aarch64") => "gpgui_freebsd_arm64.bin.tar.xz".to_owned(),
|
||||||
("openbsd", "x86_64") => "gpgui_openbsd_amd64.bin.tar.xz".to_owned(),
|
("openbsd", "x86_64") => "gpgui_openbsd_amd64.bin.tar.xz".to_owned(),
|
||||||
@@ -506,6 +501,7 @@ impl GuiUpdater {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use gpapi::gui::GuiVariant;
|
||||||
use gpapi::service::{
|
use gpapi::service::{
|
||||||
transport::{ClientPrelude, NoiseResponder},
|
transport::{ClientPrelude, NoiseResponder},
|
||||||
vpn_env::{HostInfo, VpnEnv},
|
vpn_env::{HostInfo, VpnEnv},
|
||||||
@@ -519,36 +515,36 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn selects_platform_specific_gui_assets() {
|
fn selects_platform_specific_gui_assets() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
gui_asset_name_for("linux", "x86_64", ""),
|
gui_asset_name_for(GuiVariant::Tauri, "linux", "x86_64", ""),
|
||||||
Some("gpgui_x86_64.bin.tar.xz".to_owned())
|
Some("gpgui_x86_64.bin.tar.xz".to_owned())
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
gui_asset_name_for("linux", "aarch64", "-musl"),
|
gui_asset_name_for(GuiVariant::Tauri, "linux", "aarch64", "-musl"),
|
||||||
Some("gpgui_aarch64-musl.bin.tar.xz".to_owned())
|
Some("gpgui_aarch64-musl.bin.tar.xz".to_owned())
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
gui_asset_name_for("freebsd", "x86_64", ""),
|
gui_asset_name_for(GuiVariant::Tauri, "freebsd", "x86_64", ""),
|
||||||
Some("gpgui_freebsd_amd64.bin.tar.xz".to_owned())
|
Some("gpgui_freebsd_amd64.bin.tar.xz".to_owned())
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
gui_asset_name_for("openbsd", "aarch64", ""),
|
gui_asset_name_for(GuiVariant::Tauri, "openbsd", "aarch64", ""),
|
||||||
Some("gpgui_openbsd_arm64.bin.tar.xz".to_owned())
|
Some("gpgui_openbsd_arm64.bin.tar.xz".to_owned())
|
||||||
);
|
);
|
||||||
assert_eq!(gui_asset_name_for("macos", "aarch64", ""), None);
|
assert_eq!(gui_asset_name_for(GuiVariant::Tauri, "macos", "aarch64", ""), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn nsh_assets_are_linux_only_and_use_the_nsh_binary_archive() {
|
fn nsh_assets_are_linux_only_and_use_the_nsh_binary_archive() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
nsh_asset_name_for("linux", "x86_64"),
|
gui_asset_name_for(GuiVariant::Nsh, "linux", "x86_64", ""),
|
||||||
Some("gpgui-nsh_x86_64.bin.tar.xz".into())
|
Some("gpgui-nsh_x86_64.bin.tar.xz".into())
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
nsh_asset_name_for("linux", "aarch64"),
|
gui_asset_name_for(GuiVariant::Nsh, "linux", "aarch64", "-musl"),
|
||||||
Some("gpgui-nsh_aarch64.bin.tar.xz".into())
|
Some("gpgui-nsh_aarch64-musl.bin.tar.xz".into())
|
||||||
);
|
);
|
||||||
for os in ["freebsd", "openbsd", "macos"] {
|
for os in ["freebsd", "openbsd", "macos"] {
|
||||||
assert_eq!(nsh_asset_name_for(os, "x86_64"), None);
|
assert_eq!(gui_asset_name_for(GuiVariant::Nsh, os, "x86_64", ""), None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 3.7.0
|
||||||
|
|
||||||
|
- Linux now opens Native Shell by default on supported systems, including Alpine. Upgrades keep your saved interface choice.
|
||||||
|
- To choose an interface after quitting GP Connect, run `gpclient launch-gui --interface tauri` or `gpclient launch-gui --interface nsh`.
|
||||||
|
- Linux packages include both Native Shell and Tauri so you can switch interfaces without a separate download.
|
||||||
|
- The README now documents source and prebuilt installation from the Gentoo overlay.
|
||||||
|
- Source builds with `BUILD_WEBVIEW_AUTH=0` disable embedded browser sign-in in both `gpclient` and `gpauth`.
|
||||||
|
|
||||||
## 3.6.0
|
## 3.6.0
|
||||||
|
|
||||||
- Added command-line VPN connections on Windows x64 and ARM64.
|
- Added command-line VPN connections on Windows x64 and ARM64.
|
||||||
|
|||||||
+17
-14
@@ -4,6 +4,7 @@ use specta::Type;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Type)]
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||||
|
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
pub enum GuiVariant {
|
pub enum GuiVariant {
|
||||||
#[default]
|
#[default]
|
||||||
@@ -77,21 +78,23 @@ fn preference_path(name: &str) -> anyhow::Result<PathBuf> {
|
|||||||
Ok(dirs.config_dir().join(name))
|
Ok(dirs.config_dir().join(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn preferred() -> anyhow::Result<GuiVariant> {
|
pub const NATIVE_SHELL_SUPPORTED: bool = cfg!(all(
|
||||||
#[cfg(target_os = "linux")]
|
target_os = "linux",
|
||||||
{
|
any(target_arch = "x86_64", target_arch = "aarch64"),
|
||||||
match std::fs::read_to_string(preference_path("gui")?) {
|
any(target_env = "gnu", target_env = "musl")
|
||||||
Ok(value) => match value.trim() {
|
));
|
||||||
"gpgui" => Ok(GuiVariant::Tauri),
|
|
||||||
"gpgui-nsh" => Ok(GuiVariant::Nsh),
|
#[cfg(target_os = "linux")]
|
||||||
_ => anyhow::bail!("Invalid GUI preference"),
|
pub(crate) fn saved_preference() -> anyhow::Result<Option<GuiVariant>> {
|
||||||
},
|
match std::fs::read_to_string(preference_path("gui")?) {
|
||||||
Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(GuiVariant::Tauri),
|
Ok(value) => match value.trim() {
|
||||||
Err(error) => Err(error.into()),
|
"gpgui" => Ok(Some(GuiVariant::Tauri)),
|
||||||
}
|
"gpgui-nsh" => Ok(Some(GuiVariant::Nsh)),
|
||||||
|
_ => anyhow::bail!("Invalid GUI preference"),
|
||||||
|
},
|
||||||
|
Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(None),
|
||||||
|
Err(error) => Err(error.into()),
|
||||||
}
|
}
|
||||||
#[cfg(not(target_os = "linux"))]
|
|
||||||
Ok(GuiVariant::Tauri)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use super::{
|
|||||||
is_crash_exit,
|
is_crash_exit,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use crate::service::transport::SessionCredential;
|
use crate::{gui::GuiVariant, service::transport::SessionCredential};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use std::{
|
use std::{
|
||||||
cell::Cell,
|
cell::Cell,
|
||||||
@@ -23,10 +23,11 @@ pub(super) async fn launch_desktop_child(
|
|||||||
envs: Option<&HashMap<String, String>>,
|
envs: Option<&HashMap<String, String>>,
|
||||||
credential: &SessionCredential,
|
credential: &SessionCredential,
|
||||||
cancellation: &CancellationToken,
|
cancellation: &CancellationToken,
|
||||||
detect_gbm_failure: bool,
|
interface: Option<GuiVariant>,
|
||||||
) -> anyhow::Result<ExitStatus> {
|
) -> anyhow::Result<ExitStatus> {
|
||||||
let retry_eligible = eligible_with_inheritance(&command, envs.is_none());
|
let retry_eligible = interface != Some(GuiVariant::Nsh) && eligible_with_inheritance(&command, envs.is_none());
|
||||||
let detect_gbm_failure = detect_gbm_failure && allows_shared_memory_override(&command, envs.is_none());
|
let detect_gbm_failure =
|
||||||
|
interface == Some(GuiVariant::Tauri) && allows_shared_memory_override(&command, envs.is_none());
|
||||||
let log_file = match envs {
|
let log_file = match envs {
|
||||||
Some(envs) => envs.get("GP_LOG_FILE").map(PathBuf::from),
|
Some(envs) => envs.get("GP_LOG_FILE").map(PathBuf::from),
|
||||||
None => std::env::var_os("GP_LOG_FILE").map(PathBuf::from),
|
None => std::env::var_os("GP_LOG_FILE").map(PathBuf::from),
|
||||||
|
|||||||
@@ -24,26 +24,48 @@ use crate::service::transport::{MAX_CREDENTIAL_FRAME, SessionCredential};
|
|||||||
/// Owns the desktop GUI and its privileged service without leaving the desktop session.
|
/// Owns the desktop GUI and its privileged service without leaving the desktop session.
|
||||||
pub struct DesktopLauncher<'a> {
|
pub struct DesktopLauncher<'a> {
|
||||||
version: &'a str,
|
version: &'a str,
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
interface: Option<crate::gui::GuiVariant>,
|
||||||
minimized: bool,
|
minimized: bool,
|
||||||
log_file: Option<String>,
|
log_file: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DesktopLauncher<'a> {
|
impl<'a> DesktopLauncher<'a> {
|
||||||
/// Bring an already-running GUI to the foreground through its service.
|
/// Plain launches raise the existing window. Explicit selections require a cold launch.
|
||||||
pub async fn activate_existing() -> anyhow::Result<()> {
|
pub async fn activate_or_reject_existing(&self) -> anyhow::Result<bool> {
|
||||||
let endpoint = crate::utils::endpoint::http_endpoint().await?;
|
let Ok(endpoint) = crate::utils::endpoint::http_endpoint().await else {
|
||||||
crate::utils::request::client_builder()
|
return Ok(false);
|
||||||
.build()?
|
};
|
||||||
.post(format!("{endpoint}/active-gui"))
|
let client = crate::utils::request::client_builder().no_proxy().build()?;
|
||||||
.send()
|
#[cfg(target_os = "linux")]
|
||||||
.await?
|
if self.interface.is_some() {
|
||||||
.error_for_status()?;
|
let response = client.get(format!("{endpoint}/health")).send().await;
|
||||||
Ok(())
|
ensure!(
|
||||||
|
!response.is_ok_and(|r| r.status().is_success()),
|
||||||
|
"GP Connect is already running. Quit GP Connect and run this command again."
|
||||||
|
);
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
Ok(
|
||||||
|
client
|
||||||
|
.post(format!("{endpoint}/active-gui"))
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
.is_ok_and(|r| r.status().is_success()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
pub fn interface(mut self, interface: Option<crate::gui::GuiVariant>) -> Self {
|
||||||
|
self.interface = interface;
|
||||||
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(version: &'a str) -> Self {
|
pub fn new(version: &'a str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
version,
|
version,
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
interface: None,
|
||||||
minimized: false,
|
minimized: false,
|
||||||
log_file: None,
|
log_file: None,
|
||||||
}
|
}
|
||||||
@@ -87,6 +109,8 @@ impl<'a> DesktopLauncher<'a> {
|
|||||||
let result = {
|
let result = {
|
||||||
let operation = async {
|
let operation = async {
|
||||||
let mut minimized = self.minimized;
|
let mut minimized = self.minimized;
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
let mut explicit_interface = self.interface;
|
||||||
let mut expecting_renewal = false;
|
let mut expecting_renewal = false;
|
||||||
loop {
|
loop {
|
||||||
let credential = tokio::select! {
|
let credential = tokio::select! {
|
||||||
@@ -119,15 +143,27 @@ impl<'a> DesktopLauncher<'a> {
|
|||||||
if let Some(path) = &self.log_file {
|
if let Some(path) = &self.log_file {
|
||||||
envs.insert("GP_LOG_FILE".into(), path.clone());
|
envs.insert("GP_LOG_FILE".into(), path.clone());
|
||||||
}
|
}
|
||||||
let launcher = GuiLauncher::new(self.version, Arc::new(credential), crate::gui::preferred()?)
|
|
||||||
.envs(envs)
|
|
||||||
.minimized(minimized);
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
let mut unexpected = [0];
|
let mut unexpected = [0];
|
||||||
// Program resolution may launch the WebKit download helper. Keep it under
|
// Program resolution may launch the WebKit download helper. Keep it under
|
||||||
// the same cancellation, service ownership and recovery budget as gpgui.
|
// the same cancellation, service ownership and recovery budget as gpgui.
|
||||||
let outcome = {
|
let outcome = {
|
||||||
let attempt = async {
|
let attempt = async {
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
let variant = {
|
||||||
|
let requested = match explicit_interface {
|
||||||
|
Some(variant) => Some(variant),
|
||||||
|
None => crate::gui::saved_preference()?,
|
||||||
|
};
|
||||||
|
super::nsh_runtime::select(requested, &mut input, &mut output)
|
||||||
|
.await
|
||||||
|
.context(super::nsh_runtime::TAURI_RECOVERY)?
|
||||||
|
};
|
||||||
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
let variant = crate::gui::GuiVariant::Tauri;
|
||||||
|
let launcher = GuiLauncher::new(self.version, Arc::new(credential), variant)
|
||||||
|
.envs(envs)
|
||||||
|
.minimized(minimized);
|
||||||
let program = launcher
|
let program = launcher
|
||||||
.resolve_program(&cancellation, crate::gui::GuiTheme::System)
|
.resolve_program(&cancellation, crate::gui::GuiTheme::System)
|
||||||
.await?;
|
.await?;
|
||||||
@@ -137,6 +173,7 @@ impl<'a> DesktopLauncher<'a> {
|
|||||||
&program,
|
&program,
|
||||||
&cancellation,
|
&cancellation,
|
||||||
&switch_listener.listener,
|
&switch_listener.listener,
|
||||||
|
&mut explicit_interface,
|
||||||
&mut input,
|
&mut input,
|
||||||
&mut output,
|
&mut output,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ impl<'a> GuiHelperLauncher<'a> {
|
|||||||
self.envs,
|
self.envs,
|
||||||
self.credential,
|
self.credential,
|
||||||
cancellation,
|
cancellation,
|
||||||
false,
|
None,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ use std::{
|
|||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
use anyhow::Context;
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use log::info;
|
use log::info;
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
@@ -113,12 +115,12 @@ impl<'a> GuiLauncher<'a> {
|
|||||||
}
|
}
|
||||||
info!("Launching {}", program.display());
|
info!("Launching {}", program.display());
|
||||||
super::desktop_child::launch_desktop_child(
|
super::desktop_child::launch_desktop_child(
|
||||||
"gpgui",
|
self.variant.binary_name(),
|
||||||
cmd.into_std(),
|
cmd.into_std(),
|
||||||
self.envs.as_ref(),
|
self.envs.as_ref(),
|
||||||
&self.credential,
|
&self.credential,
|
||||||
cancellation,
|
cancellation,
|
||||||
self.variant == crate::gui::GuiVariant::Tauri,
|
Some(self.variant),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
@@ -172,6 +174,7 @@ impl<'a> GuiLauncher<'a> {
|
|||||||
program: &Path,
|
program: &Path,
|
||||||
cancellation: &CancellationToken,
|
cancellation: &CancellationToken,
|
||||||
listener: &tokio::net::UnixListener,
|
listener: &tokio::net::UnixListener,
|
||||||
|
explicit_interface: &mut Option<crate::gui::GuiVariant>,
|
||||||
service_input: &mut (impl tokio::io::AsyncWrite + Unpin),
|
service_input: &mut (impl tokio::io::AsyncWrite + Unpin),
|
||||||
service_output: &mut (impl tokio::io::AsyncRead + Unpin),
|
service_output: &mut (impl tokio::io::AsyncRead + Unpin),
|
||||||
) -> anyhow::Result<ExitStatus> {
|
) -> anyhow::Result<ExitStatus> {
|
||||||
@@ -179,119 +182,111 @@ impl<'a> GuiLauncher<'a> {
|
|||||||
use crate::gui::GuiSwitchOutcome;
|
use crate::gui::GuiSwitchOutcome;
|
||||||
use crate::service::transport::{DESKTOP_SWITCH_BEGIN, DESKTOP_SWITCH_CANCEL, DESKTOP_SWITCH_COMMIT};
|
use crate::service::transport::{DESKTOP_SWITCH_BEGIN, DESKTOP_SWITCH_CANCEL, DESKTOP_SWITCH_COMMIT};
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
let mut current = Some(self.start_owned(program.to_owned(), cancellation.child_token()));
|
let mut cold_nsh = self.variant == crate::gui::GuiVariant::Nsh;
|
||||||
|
let first = if explicit_interface.is_some() {
|
||||||
|
let started = self.start_and_save(program, cancellation).await;
|
||||||
|
let child = if cold_nsh {
|
||||||
|
started.context(super::nsh_runtime::TAURI_RECOVERY)?
|
||||||
|
} else {
|
||||||
|
started?
|
||||||
|
};
|
||||||
|
*explicit_interface = None;
|
||||||
|
child
|
||||||
|
} else {
|
||||||
|
self.start_owned(program, cancellation.child_token(), None)
|
||||||
|
};
|
||||||
|
let mut current = Some(first);
|
||||||
let mut retired = Vec::new();
|
let mut retired = Vec::new();
|
||||||
let mut unexpected = [0];
|
let mut unexpected = [0];
|
||||||
let result = async { loop {
|
let result = async {
|
||||||
tokio::select! {
|
loop {
|
||||||
biased;
|
tokio::select! {
|
||||||
outcome = &mut current.as_mut().unwrap().task => {
|
biased;
|
||||||
current.take();
|
outcome = &mut current.as_mut().unwrap().task => {
|
||||||
break outcome?;
|
current.take();
|
||||||
}
|
break if cold_nsh {
|
||||||
accepted = listener.accept() => {
|
outcome?.context(super::nsh_runtime::TAURI_RECOVERY)
|
||||||
let (mut socket, _) = accepted?;
|
} else {
|
||||||
let mut pending = false;
|
outcome?
|
||||||
let replacement = async {
|
};
|
||||||
let command = gui_switch::receive(&mut socket).await?;
|
}
|
||||||
let selection = command.selection;
|
accepted = listener.accept() => {
|
||||||
let variant = selection.variant;
|
let (mut socket, _) = accepted?;
|
||||||
let candidate = Self::new(self.version, self.credential.clone(), variant).envs(self.envs.clone());
|
let mut pending = false;
|
||||||
let program = candidate.find_compatible_program(cancellation).await?;
|
let replacement = async {
|
||||||
if program.is_none() && variant == crate::gui::GuiVariant::Nsh {
|
let command = gui_switch::receive(&mut socket).await?;
|
||||||
use crate::service::transport::DESKTOP_GUI_INSTALLER;
|
let selection = command.selection;
|
||||||
service_input.write_all(&[DESKTOP_GUI_INSTALLER]).await?;
|
let variant = selection.variant;
|
||||||
let supplies_runtime = match service_output.read_u8().await? {
|
super::nsh_runtime::select(Some(variant), service_input, service_output).await?;
|
||||||
0 => false,
|
let candidate = Self::new(self.version, self.credential.clone(), variant).envs(self.envs.clone());
|
||||||
1 => true,
|
let program = candidate.find_compatible_program(cancellation).await?;
|
||||||
_ => anyhow::bail!("Invalid GUI installer capability response"),
|
if program.is_none() && !selection.allow_download {
|
||||||
};
|
gui_switch::reply(&mut socket, Ok(GuiSwitchOutcome::DownloadRequired)).await?;
|
||||||
if !supplies_runtime {
|
return Ok(None);
|
||||||
super::nsh_runtime::check()?;
|
|
||||||
}
|
}
|
||||||
}
|
use super::rendering_recovery::{GbmBufferFailure, RecoveryState};
|
||||||
if program.is_none() && !selection.allow_download {
|
let mut recovery = RecoveryState::default();
|
||||||
gui_switch::reply(&mut socket, Ok(GuiSwitchOutcome::DownloadRequired)).await?;
|
let mut program = program;
|
||||||
return Ok(None);
|
let child = loop {
|
||||||
}
|
service_input.write_all(&[DESKTOP_SWITCH_BEGIN]).await?;
|
||||||
use super::rendering_recovery::{GbmBufferFailure, RecoveryState};
|
pending = true;
|
||||||
let mut recovery = RecoveryState::default();
|
let credential = super::desktop_launcher::read_credential(service_output).await?
|
||||||
let mut program = program;
|
.ok_or_else(|| anyhow::anyhow!("Service closed before issuing the switch credential"))?;
|
||||||
let (child, start_result) = loop {
|
anyhow::ensure!(credential.product_version() == self.version, "Service product version mismatch");
|
||||||
service_input.write_all(&[DESKTOP_SWITCH_BEGIN]).await?;
|
let launcher = Self::new(self.version, Arc::new(credential), variant).envs(self.envs.clone());
|
||||||
pending = true;
|
let executable = match &program {
|
||||||
let credential = super::desktop_launcher::read_credential(service_output).await?
|
Some(program) => program.clone(),
|
||||||
.ok_or_else(|| anyhow::anyhow!("Service closed before issuing the switch credential"))?;
|
None => launcher.resolve_program(cancellation, command.theme).await?,
|
||||||
anyhow::ensure!(credential.product_version() == self.version, "Service product version mismatch");
|
};
|
||||||
let ready = gui_switch::SwitchListener::new()?;
|
match launcher.start_and_save(&executable, cancellation).await {
|
||||||
let mut envs = self.envs.clone().unwrap_or_else(|| std::env::vars().collect());
|
Ok(child) => break child,
|
||||||
envs.insert(gui_switch::READY_ENV.into(), ready.path().to_string_lossy().into_owned());
|
Err(error) if error.is::<GbmBufferFailure>() && recovery.recover(&error) => {
|
||||||
let launcher = Self::new(self.version, Arc::new(credential), variant)
|
log::warn!("{error}; restarting the selected GUI with compatibility graphics");
|
||||||
.envs(envs)
|
service_input.write_all(&[DESKTOP_SWITCH_CANCEL]).await?;
|
||||||
.minimized(false);
|
pending = false;
|
||||||
let executable = match &program {
|
program = Some(executable);
|
||||||
Some(program) => program.clone(),
|
|
||||||
None => launcher.resolve_program(cancellation, command.theme).await?,
|
|
||||||
};
|
|
||||||
let mut child = launcher.start_owned(executable.clone(), cancellation.child_token());
|
|
||||||
let start_result = tokio::select! {
|
|
||||||
result = tokio::time::timeout(std::time::Duration::from_secs(30), ready.ready()) => {
|
|
||||||
result.map_err(|_| anyhow::anyhow!("The selected GUI did not finish starting" )).and_then(|result| result)
|
|
||||||
},
|
|
||||||
outcome = &mut child.task => {
|
|
||||||
match outcome? {
|
|
||||||
Ok(status) => return Err(anyhow::anyhow!("The selected GUI exited during startup: {status}")),
|
|
||||||
Err(error) if error.is::<GbmBufferFailure>() && recovery.recover(&error) => {
|
|
||||||
log::warn!("{error}; restarting the selected GUI with compatibility graphics");
|
|
||||||
service_input.write_all(&[DESKTOP_SWITCH_CANCEL]).await?;
|
|
||||||
pending = false;
|
|
||||||
program = Some(executable);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Err(error) => return Err(recovery.terminal(error)),
|
|
||||||
}
|
}
|
||||||
|
Err(error) => return Err(recovery.terminal(error)),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
break (child, start_result);
|
if let Err(error) = gui_switch::reply(&mut socket, Ok(GuiSwitchOutcome::Switched)).await {
|
||||||
};
|
child.cancel.cancel();
|
||||||
if let Err(error) = start_result.and_then(|()| crate::gui::save_preference(variant)) {
|
let _ = child.task.await;
|
||||||
child.cancel.cancel();
|
return Err(error);
|
||||||
let _ = child.task.await;
|
}
|
||||||
return Err(error);
|
if let Err(error) = service_input.write_all(&[DESKTOP_SWITCH_COMMIT]).await {
|
||||||
}
|
child.cancel.cancel();
|
||||||
if let Err(error) = gui_switch::reply(&mut socket, Ok(GuiSwitchOutcome::Switched)).await {
|
let _ = child.task.await;
|
||||||
child.cancel.cancel();
|
return Err(error.into());
|
||||||
let _ = child.task.await;
|
}
|
||||||
return Err(error);
|
pending = false;
|
||||||
}
|
Ok(Some(child))
|
||||||
if let Err(error) = service_input.write_all(&[DESKTOP_SWITCH_COMMIT]).await {
|
}.await;
|
||||||
child.cancel.cancel();
|
match replacement {
|
||||||
let _ = child.task.await;
|
Ok(Some(child)) => {
|
||||||
return Err(error.into());
|
cold_nsh = false;
|
||||||
}
|
retired.push(current.replace(child).unwrap());
|
||||||
pending = false;
|
}
|
||||||
Ok(Some(child))
|
Ok(None) => {},
|
||||||
}.await;
|
Err(error) => {
|
||||||
match replacement {
|
if pending {
|
||||||
Ok(Some(child)) => retired.push(current.replace(child).unwrap()),
|
service_input.write_all(&[DESKTOP_SWITCH_CANCEL]).await?;
|
||||||
Ok(None) => {},
|
}
|
||||||
Err(error) => {
|
let _ = gui_switch::reply(&mut socket, Err(format!("{error:#}"))).await;
|
||||||
if pending {
|
|
||||||
service_input.write_all(&[DESKTOP_SWITCH_CANCEL]).await?;
|
|
||||||
}
|
}
|
||||||
let _ = gui_switch::reply(&mut socket, Err(format!("{error:#}"))).await;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
result = service_output.read(&mut unexpected) => {
|
||||||
result = service_output.read(&mut unexpected) => {
|
break match result {
|
||||||
break match result {
|
Ok(0) => Err(anyhow::anyhow!("The privileged service closed its credential channel")),
|
||||||
Ok(0) => Err(anyhow::anyhow!("The privileged service closed its credential channel")),
|
Ok(_) => Err(anyhow::anyhow!("Unexpected service credential data while the GUI is running")),
|
||||||
Ok(_) => Err(anyhow::anyhow!("Unexpected service credential data while the GUI is running")),
|
Err(error) => Err(error.into()),
|
||||||
Err(error) => Err(error.into()),
|
};
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}.await;
|
}
|
||||||
|
.await;
|
||||||
// Every GUI remains owned by this supervisor until it is reaped. The retiring
|
// Every GUI remains owned by this supervisor until it is reaped. The retiring
|
||||||
// GUI exits after the successful switch reply; cancellation also joins it.
|
// GUI exits after the successful switch reply; cancellation also joins it.
|
||||||
if let Some(child) = current {
|
if let Some(child) = current {
|
||||||
@@ -307,11 +302,38 @@ impl<'a> GuiLauncher<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
fn start_owned(&self, program: PathBuf, cancel: CancellationToken) -> RunningGui {
|
/// Cold CLI selection and a Settings switch commit the preference after native readiness.
|
||||||
|
async fn start_and_save(&self, program: &Path, cancellation: &CancellationToken) -> anyhow::Result<RunningGui> {
|
||||||
|
let ready = super::gui_switch::SwitchListener::new()?;
|
||||||
|
let mut child = self.start_owned(program, cancellation.child_token(), Some(&ready.path()));
|
||||||
|
let started = tokio::select! {
|
||||||
|
biased;
|
||||||
|
_ = cancellation.cancelled() => Err(anyhow::anyhow!("GUI startup cancelled")),
|
||||||
|
status = &mut child.task => bail!("The selected GUI exited during startup: {}", status??),
|
||||||
|
result = tokio::time::timeout(std::time::Duration::from_secs(30), ready.ready()) => {
|
||||||
|
result.context("The selected GUI did not finish starting").and_then(|result| result)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if let Err(error) = started.and_then(|()| crate::gui::save_preference(self.variant)) {
|
||||||
|
child.cancel.cancel();
|
||||||
|
let _ = child.task.await;
|
||||||
|
return Err(error);
|
||||||
|
}
|
||||||
|
Ok(child)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
fn start_owned(&self, program: &Path, cancel: CancellationToken, ready: Option<&Path>) -> RunningGui {
|
||||||
|
let program = program.to_owned();
|
||||||
let version = self.version.to_owned();
|
let version = self.version.to_owned();
|
||||||
let variant = self.variant;
|
let variant = self.variant;
|
||||||
let credential = self.credential.clone();
|
let credential = self.credential.clone();
|
||||||
let envs = self.envs.clone();
|
let mut envs = self.envs.clone();
|
||||||
|
if let Some(path) = ready {
|
||||||
|
envs
|
||||||
|
.get_or_insert_with(|| std::env::vars().collect())
|
||||||
|
.insert(super::gui_switch::READY_ENV.into(), path.to_string_lossy().into_owned());
|
||||||
|
}
|
||||||
let minimized = self.minimized;
|
let minimized = self.minimized;
|
||||||
let task_cancel = cancel.clone();
|
let task_cancel = cancel.clone();
|
||||||
let task = tokio::spawn(async move {
|
let task = tokio::spawn(async move {
|
||||||
@@ -501,30 +523,6 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn nsh_version_mismatch_cannot_select_a_compatible_tauri_binary() {
|
|
||||||
let dir = TempDir::new().unwrap();
|
|
||||||
let _tauri = executable(&dir, "gpgui", "gpgui test-version", 0);
|
|
||||||
let nsh = executable(&dir, "gpgui-nsh", "gpgui-nsh old-version", 0);
|
|
||||||
let mut selected = launcher(VERSION, vec![nsh.clone()]);
|
|
||||||
selected.variant = crate::gui::GuiVariant::Nsh;
|
|
||||||
assert!(
|
|
||||||
selected
|
|
||||||
.find_compatible_program(&CancellationToken::new())
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.is_none()
|
|
||||||
);
|
|
||||||
executable(&dir, "gpgui-nsh", "gpgui-nsh test-version", 0);
|
|
||||||
assert_eq!(
|
|
||||||
selected
|
|
||||||
.find_compatible_program(&CancellationToken::new())
|
|
||||||
.await
|
|
||||||
.unwrap(),
|
|
||||||
Some(nsh)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
fn supervisor_switch_success_and_failure_preserve_child_ownership() {
|
fn supervisor_switch_success_and_failure_preserve_child_ownership() {
|
||||||
@@ -535,6 +533,11 @@ mod tests {
|
|||||||
"incompatible",
|
"incompatible",
|
||||||
"runtime-too-old",
|
"runtime-too-old",
|
||||||
"runtime-too-old-confirmed",
|
"runtime-too-old-confirmed",
|
||||||
|
"cold-default",
|
||||||
|
"cold-explicit",
|
||||||
|
"cold-explicit-failure",
|
||||||
|
"cold-explicit-clean-exit",
|
||||||
|
"cold-default-failure",
|
||||||
] {
|
] {
|
||||||
let directory = TempDir::new().unwrap();
|
let directory = TempDir::new().unwrap();
|
||||||
let executable = std::env::current_exe().unwrap();
|
let executable = std::env::current_exe().unwrap();
|
||||||
@@ -542,7 +545,7 @@ mod tests {
|
|||||||
let gtk = super::super::nsh_runtime::tests::gtk_fixture(directory.path(), 12);
|
let gtk = super::super::nsh_runtime::tests::gtk_fixture(directory.path(), 12);
|
||||||
fs::rename(gtk, directory.path().join("libgtk-4.so.1")).unwrap();
|
fs::rename(gtk, directory.path().join("libgtk-4.so.1")).unwrap();
|
||||||
for name in ["gpgui", "gpgui-nsh"] {
|
for name in ["gpgui", "gpgui-nsh"] {
|
||||||
if (scenario == "missing" || scenario.starts_with("runtime-too-old")) && name == "gpgui-nsh" {
|
if (scenario == "missing" || scenario == "runtime-too-old") && name == "gpgui-nsh" {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let version = if scenario == "incompatible" && name == "gpgui-nsh" {
|
let version = if scenario == "incompatible" && name == "gpgui-nsh" {
|
||||||
@@ -631,7 +634,7 @@ mod tests {
|
|||||||
async fn upgrade_fixture() {
|
async fn upgrade_fixture() {
|
||||||
crate::gui::save_preference(crate::gui::GuiVariant::Nsh).unwrap();
|
crate::gui::save_preference(crate::gui::GuiVariant::Nsh).unwrap();
|
||||||
let credential = Arc::new(SessionCredential::generate(Uuid::new_v4(), VERSION).unwrap());
|
let credential = Arc::new(SessionCredential::generate(Uuid::new_v4(), VERSION).unwrap());
|
||||||
let selected = GuiLauncher::new(VERSION, credential, crate::gui::preferred().unwrap());
|
let selected = GuiLauncher::new(VERSION, credential, crate::gui::saved_preference().unwrap().unwrap());
|
||||||
let program = selected
|
let program = selected
|
||||||
.resolve_program(&CancellationToken::new(), crate::gui::GuiTheme::System)
|
.resolve_program(&CancellationToken::new(), crate::gui::GuiTheme::System)
|
||||||
.await
|
.await
|
||||||
@@ -670,8 +673,14 @@ mod tests {
|
|||||||
input.read_exact(&mut frame).unwrap();
|
input.read_exact(&mut frame).unwrap();
|
||||||
let directory = PathBuf::from(std::env::var_os("GP_SWITCH_DIRECTORY").unwrap());
|
let directory = PathBuf::from(std::env::var_os("GP_SWITCH_DIRECTORY").unwrap());
|
||||||
let variant = std::env::var("GP_SWITCH_GUI_VARIANT").unwrap();
|
let variant = std::env::var("GP_SWITCH_GUI_VARIANT").unwrap();
|
||||||
if variant == "gpgui-nsh" && std::env::var("GP_SWITCH_SCENARIO").unwrap() == "failure" {
|
if variant == "gpgui-nsh" {
|
||||||
panic!("fixture: native host failed to initialize");
|
let scenario = std::env::var("GP_SWITCH_SCENARIO").unwrap();
|
||||||
|
if scenario.ends_with("failure") {
|
||||||
|
panic!("fixture: native host failed to initialize");
|
||||||
|
}
|
||||||
|
if scenario.ends_with("clean-exit") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
super::super::gui_switch::notify_ready().unwrap();
|
super::super::gui_switch::notify_ready().unwrap();
|
||||||
fs::write(directory.join(format!("{variant}-started")), "").unwrap();
|
fs::write(directory.join(format!("{variant}-started")), "").unwrap();
|
||||||
@@ -719,13 +728,64 @@ mod tests {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
let envs = std::env::vars().collect::<HashMap<_, _>>();
|
let envs = std::env::vars().collect::<HashMap<_, _>>();
|
||||||
let launcher = launcher(VERSION, vec![]).envs(envs);
|
let mut launcher = launcher(VERSION, vec![]).envs(envs);
|
||||||
let cancel = CancellationToken::new();
|
let cancel = CancellationToken::new();
|
||||||
|
if runtime_too_old {
|
||||||
|
assert_eq!(
|
||||||
|
super::super::nsh_runtime::select(None, &mut service_input, &mut service_output)
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
crate::gui::GuiVariant::Tauri
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if scenario.starts_with("cold-") {
|
||||||
|
use crate::gui::{GuiVariant, saved_preference};
|
||||||
|
let mut explicit = scenario.contains("explicit").then_some(GuiVariant::Nsh);
|
||||||
|
if explicit.is_some() {
|
||||||
|
crate::gui::save_preference(GuiVariant::Tauri).unwrap();
|
||||||
|
}
|
||||||
|
launcher.variant = super::super::nsh_runtime::select(explicit, &mut service_input, &mut service_output)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(launcher.variant, GuiVariant::Nsh);
|
||||||
|
let program = directory.join(launcher.variant.binary_name());
|
||||||
|
let run = launcher.launch_with_switches(
|
||||||
|
&program,
|
||||||
|
&cancel,
|
||||||
|
&listener.listener,
|
||||||
|
&mut explicit,
|
||||||
|
&mut service_input,
|
||||||
|
&mut service_output,
|
||||||
|
);
|
||||||
|
if scenario.ends_with("failure") || scenario.ends_with("clean-exit") {
|
||||||
|
assert!(run.await.unwrap_err().to_string().contains("--interface tauri"));
|
||||||
|
let original = explicit.map(|_| GuiVariant::Tauri);
|
||||||
|
assert_eq!(saved_preference().unwrap(), original);
|
||||||
|
} else {
|
||||||
|
let expected = scenario.contains("explicit").then_some(GuiVariant::Nsh);
|
||||||
|
let stop = async {
|
||||||
|
while !directory.join("gpgui-nsh-started").exists() || saved_preference().unwrap() != expected {
|
||||||
|
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
|
||||||
|
}
|
||||||
|
fs::write(directory.join("stop-gpgui-nsh"), "").unwrap();
|
||||||
|
};
|
||||||
|
let (status, ()) = tokio::time::timeout(std::time::Duration::from_secs(10), async { tokio::join!(run, stop) })
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert!(status.unwrap().success());
|
||||||
|
assert!(explicit.is_none());
|
||||||
|
assert_eq!(saved_preference().unwrap(), expected);
|
||||||
|
}
|
||||||
|
service.abort();
|
||||||
|
return;
|
||||||
|
}
|
||||||
let program = directory.join("gpgui");
|
let program = directory.join("gpgui");
|
||||||
|
let mut explicit = None;
|
||||||
let run = launcher.launch_with_switches(
|
let run = launcher.launch_with_switches(
|
||||||
&program,
|
&program,
|
||||||
&cancel,
|
&cancel,
|
||||||
&listener.listener,
|
&listener.listener,
|
||||||
|
&mut explicit,
|
||||||
&mut service_input,
|
&mut service_input,
|
||||||
&mut service_output,
|
&mut service_output,
|
||||||
);
|
);
|
||||||
@@ -756,6 +816,12 @@ mod tests {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
anyhow::ensure!(result.is_ok() == success, "Unexpected switch result: {result:?}");
|
anyhow::ensure!(result.is_ok() == success, "Unexpected switch result: {result:?}");
|
||||||
|
if let Err(error) = &result {
|
||||||
|
anyhow::ensure!(
|
||||||
|
!error.to_string().contains("--interface tauri"),
|
||||||
|
"Unexpected CLI recovery hint"
|
||||||
|
);
|
||||||
|
}
|
||||||
if success {
|
if success {
|
||||||
anyhow::ensure!(
|
anyhow::ensure!(
|
||||||
result? == crate::gui::GuiSwitchOutcome::Switched,
|
result? == crate::gui::GuiSwitchOutcome::Switched,
|
||||||
@@ -779,7 +845,7 @@ mod tests {
|
|||||||
);
|
);
|
||||||
if success {
|
if success {
|
||||||
anyhow::ensure!(
|
anyhow::ensure!(
|
||||||
crate::gui::preferred()? == crate::gui::GuiVariant::Nsh,
|
crate::gui::saved_preference()? == Some(crate::gui::GuiVariant::Nsh),
|
||||||
"Successful switch did not save preference"
|
"Successful switch did not save preference"
|
||||||
);
|
);
|
||||||
fs::write(directory.join("stop-gpgui"), "")?;
|
fs::write(directory.join("stop-gpgui"), "")?;
|
||||||
@@ -788,7 +854,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
anyhow::ensure!(
|
anyhow::ensure!(
|
||||||
crate::gui::preferred()? == crate::gui::GuiVariant::Tauri,
|
crate::gui::saved_preference()?.is_none(),
|
||||||
"Failed switch changed preference"
|
"Failed switch changed preference"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//! Checks the generic Linux NSH runtime before offering a download.
|
//! Selects the Linux GUI using its installed or package-managed runtime.
|
||||||
//! Runs in the desktop supervisor, which does not load either GUI's GTK runtime.
|
//! Runs in the desktop supervisor, which does not load either GUI's GTK runtime.
|
||||||
use std::{ffi::OsStr, os::raw::c_uint};
|
use std::{ffi::OsStr, os::raw::c_uint};
|
||||||
|
|
||||||
@@ -11,14 +11,70 @@ use libloading::{
|
|||||||
// Match nsh-platform-linux's gtk4/v4_14 feature when changing the NSH build.
|
// Match nsh-platform-linux's gtk4/v4_14 feature when changing the NSH build.
|
||||||
const MIN_GTK_MINOR: u32 = 14;
|
const MIN_GTK_MINOR: u32 = 14;
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
pub(super) const TAURI_RECOVERY: &str = "To use Tauri, run: gpclient launch-gui --interface tauri";
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
pub(super) async fn select(
|
||||||
|
requested: Option<crate::gui::GuiVariant>,
|
||||||
|
service_input: &mut (impl tokio::io::AsyncWrite + Unpin),
|
||||||
|
service_output: &mut (impl tokio::io::AsyncRead + Unpin),
|
||||||
|
) -> anyhow::Result<crate::gui::GuiVariant> {
|
||||||
|
use crate::{gui::GuiVariant, service::transport::DESKTOP_GUI_INSTALLER};
|
||||||
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
|
|
||||||
|
if requested == Some(GuiVariant::Tauri) {
|
||||||
|
return Ok(GuiVariant::Tauri);
|
||||||
|
}
|
||||||
|
|
||||||
|
let runtime = if crate::gui::NATIVE_SHELL_SUPPORTED {
|
||||||
|
service_input.write_all(&[DESKTOP_GUI_INSTALLER]).await?;
|
||||||
|
match service_output.read_u8().await? {
|
||||||
|
0 => check(),
|
||||||
|
// The package installer provides and wraps NSH's dependencies (e.g. NixOS).
|
||||||
|
1 => Ok(()),
|
||||||
|
_ => anyhow::bail!("Invalid GUI installer capability response"),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Err(anyhow::anyhow!("Native Shell is unavailable for this platform."))
|
||||||
|
};
|
||||||
|
|
||||||
|
match runtime {
|
||||||
|
Ok(()) => Ok(GuiVariant::Nsh),
|
||||||
|
Err(err) if requested.is_some() => Err(err),
|
||||||
|
Err(err) => {
|
||||||
|
log::info!("Selecting Tauri: {err:#}");
|
||||||
|
Ok(GuiVariant::Tauri)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub(super) fn check() -> anyhow::Result<()> {
|
pub(super) fn check() -> anyhow::Result<()> {
|
||||||
check_gtk(OsStr::new("libgtk-4.so.1"))?;
|
check_gtk(OsStr::new("libgtk-4.so.1"))?;
|
||||||
|
#[cfg(target_env = "gnu")]
|
||||||
|
{
|
||||||
|
// glibc returns a static, NUL-terminated runtime version string.
|
||||||
|
let version = unsafe { std::ffi::CStr::from_ptr(nix::libc::gnu_get_libc_version()) };
|
||||||
|
check_glibc_version(version.to_str()?)?;
|
||||||
|
}
|
||||||
load_library(OsStr::new("libgnutls.so.30"), "GnuTLS 3")?;
|
load_library(OsStr::new("libgnutls.so.30"), "GnuTLS 3")?;
|
||||||
load_library(OsStr::new("libdbus-1.so.3"), "D-Bus")?;
|
load_library(OsStr::new("libdbus-1.so.3"), "D-Bus")?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(all(target_os = "linux", target_env = "gnu"), test))]
|
||||||
|
fn check_glibc_version(version: &str) -> anyhow::Result<()> {
|
||||||
|
let mut parts = version.split('.');
|
||||||
|
let major = parts.next().and_then(|part| part.parse::<u32>().ok());
|
||||||
|
let minor = parts.next().and_then(|part| part.parse::<u32>().ok());
|
||||||
|
ensure!(
|
||||||
|
major.zip(minor).is_some_and(|version| version >= (2, 39)),
|
||||||
|
"Native Shell requires glibc 2.39 or later. This system reports glibc {version}."
|
||||||
|
);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn load_library(path: &OsStr, name: &str) -> anyhow::Result<Library> {
|
fn load_library(path: &OsStr, name: &str) -> anyhow::Result<Library> {
|
||||||
// Resolve symbols now as well as transitive dependencies, without initializing GTK.
|
// Resolve symbols now as well as transitive dependencies, without initializing GTK.
|
||||||
let library = unsafe { libloading::os::unix::Library::open(Some(path), RTLD_LOCAL | RTLD_NOW) };
|
let library = unsafe { libloading::os::unix::Library::open(Some(path), RTLD_LOCAL | RTLD_NOW) };
|
||||||
@@ -55,6 +111,21 @@ pub(super) mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use std::{fs, process::Command};
|
use std::{fs, process::Command};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn requires_glibc_2_39_or_later() {
|
||||||
|
for version in ["2.9", "2.38", "unknown"] {
|
||||||
|
assert!(
|
||||||
|
check_glibc_version(version)
|
||||||
|
.unwrap_err()
|
||||||
|
.to_string()
|
||||||
|
.contains("glibc 2.39")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
for version in ["2.39", "2.39.1", "2.40", "3.0"] {
|
||||||
|
check_glibc_version(version).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(in crate::process) fn gtk_fixture(directory: &std::path::Path, minor: u32) -> std::path::PathBuf {
|
pub(in crate::process) fn gtk_fixture(directory: &std::path::Path, minor: u32) -> std::path::PathBuf {
|
||||||
let source = directory.join(format!("gtk-{minor}.c"));
|
let source = directory.join(format!("gtk-{minor}.c"));
|
||||||
let library = directory.join(format!("gtk-{minor}.so"));
|
let library = directory.join(format!("gtk-{minor}.so"));
|
||||||
|
|||||||
@@ -69,6 +69,30 @@
|
|||||||
archive = gpguiArchive;
|
archive = gpguiArchive;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nshHashes = {
|
||||||
|
x86_64 = "sha256-HWQ7Lh0NA6lEjLIPjmvqsB1DhzUPMeZ6NPpyUTfLbng=";
|
||||||
|
aarch64 = "sha256-GT6arWaFyZNDCMrK676+JlPJnCAJ0DhDugcCMQlPmIM=";
|
||||||
|
};
|
||||||
|
|
||||||
|
nshArchive = pkgs.fetchurl {
|
||||||
|
url = "https://github.com/yuezk/GlobalProtect-openconnect/releases/download/${releaseTag}/gpgui-nsh_${cpu}.bin.tar.xz";
|
||||||
|
hash = nshHashes.${cpu};
|
||||||
|
};
|
||||||
|
|
||||||
|
installNativeShell = archive: version:
|
||||||
|
let nsh = import ./nix/gui-package.nix {
|
||||||
|
inherit pkgs version;
|
||||||
|
src = archive;
|
||||||
|
binaryName = "gpgui-nsh";
|
||||||
|
};
|
||||||
|
in ''
|
||||||
|
# A direct invocation hands off to gpclient in the enclosing package.
|
||||||
|
makeWrapper ${nsh}/bin/gpgui-nsh "$out/bin/gpgui-nsh" \
|
||||||
|
--set-default GP_CLIENT_BINARY "$out/bin/gpclient"
|
||||||
|
install -Dm644 ${nsh}/share/licenses/gpgui-nsh/ICU4X-LICENSE.txt \
|
||||||
|
"$out/share/licenses/globalprotect-openconnect/ICU4X-LICENSE.txt"
|
||||||
|
'';
|
||||||
|
|
||||||
binaryHashes = {
|
binaryHashes = {
|
||||||
x86_64 = "sha256-gK8VWHw1VbXE7wHU1wGYw4fQ0khk24JWUwAQk+47WF8=";
|
x86_64 = "sha256-gK8VWHw1VbXE7wHU1wGYw4fQ0khk24JWUwAQk+47WF8=";
|
||||||
aarch64 = "sha256-nqSuIW1fz742+2rF0QpnN8hswFm5lezC9JEOMs/8OHM=";
|
aarch64 = "sha256-nqSuIW1fz742+2rF0QpnN8hswFm5lezC9JEOMs/8OHM=";
|
||||||
@@ -99,7 +123,13 @@
|
|||||||
config = {};
|
config = {};
|
||||||
overlays = [];
|
overlays = [];
|
||||||
};
|
};
|
||||||
inherit archive checksum binaryName;
|
inherit binaryName;
|
||||||
|
src = builtins.path {
|
||||||
|
path = builtins.toPath archive;
|
||||||
|
name = "''${binaryName}.tar.xz";
|
||||||
|
recursive = false;
|
||||||
|
sha256 = checksum;
|
||||||
|
};
|
||||||
version = "${version}";
|
version = "${version}";
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
@@ -191,7 +221,7 @@
|
|||||||
EOF
|
EOF
|
||||||
'';
|
'';
|
||||||
|
|
||||||
fromSource = lib.makeOverridable ({ gui ? gpgui }: naersk'.buildPackage {
|
fromSource = lib.makeOverridable ({ gui ? gpgui, nativeShellArchive ? nshArchive }: naersk'.buildPackage {
|
||||||
inherit pname version;
|
inherit pname version;
|
||||||
SNAPSHOT = lib.boolToString (releaseTag == "snapshot");
|
SNAPSHOT = lib.boolToString (releaseTag == "snapshot");
|
||||||
src = assert lib.assertMsg
|
src = assert lib.assertMsg
|
||||||
@@ -238,6 +268,7 @@
|
|||||||
runtimeDependencies = lib.optionals pkgs.stdenv.isLinux linuxRuntimeDependencies;
|
runtimeDependencies = lib.optionals pkgs.stdenv.isLinux linuxRuntimeDependencies;
|
||||||
|
|
||||||
preFixup = nativeRuntimeWrapping;
|
preFixup = nativeRuntimeWrapping;
|
||||||
|
postFixup = lib.optionalString pkgs.stdenv.isLinux (installNativeShell nativeShellArchive version);
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
make install PREFIX="$out" ${lib.optionalString pkgs.stdenv.isLinux ''GPGUI_BINARY="${gui}/gpgui"''}
|
make install PREFIX="$out" ${lib.optionalString pkgs.stdenv.isLinux ''GPGUI_BINARY="${gui}/gpgui"''}
|
||||||
@@ -253,6 +284,7 @@
|
|||||||
|
|
||||||
prebuilt = lib.makeOverridable ({
|
prebuilt = lib.makeOverridable ({
|
||||||
binaries ? binaryPackage,
|
binaries ? binaryPackage,
|
||||||
|
nativeShellArchive ? nshArchive,
|
||||||
gui ? gpgui,
|
gui ? gpgui,
|
||||||
version ? releaseVersion,
|
version ? releaseVersion,
|
||||||
}: pkgs.stdenv.mkDerivation {
|
}: pkgs.stdenv.mkDerivation {
|
||||||
@@ -269,6 +301,7 @@
|
|||||||
buildInputs = linuxBuildInputs;
|
buildInputs = linuxBuildInputs;
|
||||||
runtimeDependencies = linuxRuntimeDependencies;
|
runtimeDependencies = linuxRuntimeDependencies;
|
||||||
preFixup = nativeRuntimeWrapping;
|
preFixup = nativeRuntimeWrapping;
|
||||||
|
postFixup = installNativeShell nativeShellArchive version;
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
@@ -282,6 +315,8 @@
|
|||||||
cp -r artifacts/usr/lib $out/lib
|
cp -r artifacts/usr/lib $out/lib
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# The Native Shell archive gets its own GTK4 wrapper in postFixup.
|
||||||
|
rm -f "$out/bin/gpgui-nsh"
|
||||||
install -Dm755 ${gui}/gpgui $out/bin/gpgui
|
install -Dm755 ${gui}/gpgui $out/bin/gpgui
|
||||||
|
|
||||||
${rewriteVpncScriptToolPaths}
|
${rewriteVpncScriptToolPaths}
|
||||||
|
|||||||
+11
-2
@@ -18,9 +18,13 @@ let
|
|||||||
'';
|
'';
|
||||||
binaries = unpack "gp-ci-binaries" "GP_BINARY_ARCHIVE";
|
binaries = unpack "gp-ci-binaries" "GP_BINARY_ARCHIVE";
|
||||||
gui = unpack "gp-ci-gui" "GP_GUI_ARCHIVE";
|
gui = unpack "gp-ci-gui" "GP_GUI_ARCHIVE";
|
||||||
sourcePackage = gp.packages.${system}.fromSource.override { inherit gui; };
|
nativeShellArchive = builtins.path {
|
||||||
|
path = builtins.toPath (builtins.getEnv "GP_NSH_ARCHIVE");
|
||||||
|
name = "gpgui-nsh.tar.xz";
|
||||||
|
};
|
||||||
|
sourcePackage = gp.packages.${system}.fromSource.override { inherit gui nativeShellArchive; };
|
||||||
prebuiltInputs = {
|
prebuiltInputs = {
|
||||||
inherit binaries gui;
|
inherit binaries gui nativeShellArchive;
|
||||||
version = sourcePackage.version;
|
version = sourcePackage.version;
|
||||||
};
|
};
|
||||||
prebuiltPackage = gp.packages.${system}.prebuilt.override prebuiltInputs;
|
prebuiltPackage = gp.packages.${system}.prebuilt.override prebuiltInputs;
|
||||||
@@ -52,6 +56,11 @@ in {
|
|||||||
package = sourcePackage;
|
package = sourcePackage;
|
||||||
module = gp.nixosModules.default;
|
module = gp.nixosModules.default;
|
||||||
};
|
};
|
||||||
|
graphical-prebuilt = import ./tests/desktop-interfaces.nix {
|
||||||
|
inherit pkgs;
|
||||||
|
package = prebuiltPackage;
|
||||||
|
module = gp.nixosModules.default;
|
||||||
|
};
|
||||||
runtime-prebuilt = import ./tests/native-runtime.nix {
|
runtime-prebuilt = import ./tests/native-runtime.nix {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
package = prebuiltPackage;
|
package = prebuiltPackage;
|
||||||
|
|||||||
+5
-9
@@ -1,23 +1,19 @@
|
|||||||
{ pkgs, archive, checksum, binaryName, version }:
|
{ pkgs, src, binaryName, version }:
|
||||||
let
|
let
|
||||||
nativeShell = binaryName == "gpgui-nsh";
|
nativeShell = binaryName == "gpgui-nsh";
|
||||||
in
|
in
|
||||||
assert builtins.elem binaryName [ "gpgui" "gpgui-nsh" ];
|
assert builtins.elem binaryName [ "gpgui" "gpgui-nsh" ];
|
||||||
|
assert pkgs.lib.assertMsg (!nativeShell || pkgs.lib.versionAtLeast pkgs.gtk4.version "4.14")
|
||||||
|
"Native Shell requires GTK 4.14 or later.";
|
||||||
pkgs.stdenv.mkDerivation {
|
pkgs.stdenv.mkDerivation {
|
||||||
pname = binaryName;
|
pname = binaryName;
|
||||||
inherit version;
|
inherit src version;
|
||||||
src = builtins.path {
|
|
||||||
path = builtins.toPath archive;
|
|
||||||
name = "${binaryName}.tar.xz";
|
|
||||||
recursive = false;
|
|
||||||
sha256 = checksum;
|
|
||||||
};
|
|
||||||
dontBuild = true;
|
dontBuild = true;
|
||||||
nativeBuildInputs = [ pkgs.autoPatchelfHook ] ++ (
|
nativeBuildInputs = [ pkgs.autoPatchelfHook ] ++ (
|
||||||
if nativeShell then [ pkgs.wrapGAppsHook4 ] else [ pkgs.wrapGAppsHook3 ]
|
if nativeShell then [ pkgs.wrapGAppsHook4 ] else [ pkgs.wrapGAppsHook3 ]
|
||||||
);
|
);
|
||||||
buildInputs = with pkgs;
|
buildInputs = with pkgs;
|
||||||
[ gnutls ] ++ (if nativeShell then [ gtk4 ] else [
|
[ gnutls ] ++ (if nativeShell then [ gtk4 dbus ] else [
|
||||||
gtk3 webkitgtk_4_1 libsoup_3 glib-networking libsecret
|
gtk3 webkitgtk_4_1 libsoup_3 glib-networking libsecret
|
||||||
]);
|
]);
|
||||||
runtimeDependencies = [ pkgs.libglvnd ] ++ pkgs.lib.optionals (!nativeShell) [
|
runtimeDependencies = [ pkgs.libglvnd ] ++ pkgs.lib.optionals (!nativeShell) [
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
{ pkgs, package, module }:
|
||||||
|
let
|
||||||
|
testPython = pkgs.python3.withPackages (ps: [ ps.pyatspi ps.pygobject3 ]);
|
||||||
|
typelibs = pkgs.lib.makeSearchPath "lib/girepository-1.0" [
|
||||||
|
pkgs.at-spi2-core
|
||||||
|
pkgs.glib.out
|
||||||
|
pkgs.gobject-introspection
|
||||||
|
];
|
||||||
|
chooseTauri = pkgs.writeScript "choose-tauri" ''
|
||||||
|
#!${testPython}/bin/python3
|
||||||
|
import pyatspi
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
desktop = pyatspi.Registry.getDesktop(0)
|
||||||
|
target = pyatspi.findDescendant(desktop, lambda node: node.name == "Interface: Tauri")
|
||||||
|
if target is None:
|
||||||
|
raise SystemExit("The Tauri control is not visible yet")
|
||||||
|
# GTK4 exposes bounds relative to the window, even on X11.
|
||||||
|
rect = target.queryComponent().getExtents(pyatspi.WINDOW_COORDS)
|
||||||
|
if rect.width <= 0 or rect.height <= 0:
|
||||||
|
raise SystemExit("The Tauri control has no visible bounds")
|
||||||
|
window = subprocess.check_output(["xdotool", "search", "--onlyvisible", "--name",
|
||||||
|
"^GP Connect Settings$"], text=True).splitlines()[-1]
|
||||||
|
subprocess.run(["xdotool", "mousemove", "--window", window, str(rect.x + rect.width // 2),
|
||||||
|
str(rect.y + rect.height // 2), "click", "1"], check=True)
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
pkgs.testers.runNixOSTest {
|
||||||
|
name = "gp-offline-desktop-interfaces";
|
||||||
|
nodes.machine = {
|
||||||
|
imports = [ module (pkgs.path + "/nixos/tests/common/x11.nix") ];
|
||||||
|
programs.globalprotect-openconnect = { enable = true; inherit package; };
|
||||||
|
test-support.displayManager.auto.user = "alice";
|
||||||
|
users.users.alice = { isNormalUser = true; uid = 1000; };
|
||||||
|
services.gnome.at-spi2-core.enable = true;
|
||||||
|
environment.systemPackages = [ pkgs.xdotool ];
|
||||||
|
security.polkit.extraConfig = ''
|
||||||
|
polkit.addRule(function(action, subject) {
|
||||||
|
if (subject.user == "alice" && action.id == "com.yuezk.gpgui.service") {
|
||||||
|
return polkit.Result.YES;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
'';
|
||||||
|
virtualisation.memorySize = 4096;
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
from datetime import timedelta
|
||||||
|
import shlex
|
||||||
|
|
||||||
|
machine.start()
|
||||||
|
machine.wait_for_unit("display-manager.service")
|
||||||
|
def as_alice(command):
|
||||||
|
environment = "export DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/1000 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus GTK_A11Y=atspi; "
|
||||||
|
return "su - alice -c " + shlex.quote(environment + command)
|
||||||
|
|
||||||
|
accessibility_env = "GI_TYPELIB_PATH=${typelibs} "
|
||||||
|
machine.succeed(as_alice(accessibility_env + "${testPython}/bin/python3 -c 'import pyatspi'"))
|
||||||
|
machine.wait_until_succeeds(as_alice("xdotool getdisplaygeometry"))
|
||||||
|
# Leave loopback available for the local privileged service.
|
||||||
|
machine.succeed("for dev in /sys/class/net/*; do dev=$(basename \"$dev\"); [ \"$dev\" = lo ] || ip link set \"$dev\" down; done")
|
||||||
|
|
||||||
|
def launch():
|
||||||
|
machine.succeed(as_alice("gpclient launch-gui > ~/gp-launch.log 2>&1 & echo $! > ~/gp-launch.pid"))
|
||||||
|
|
||||||
|
def wait_for_gui(name):
|
||||||
|
# Identify the process which owns the mapped main window, including Nix's executable wrapper.
|
||||||
|
machine.wait_until_succeeds(as_alice(
|
||||||
|
"pid=$(xdotool search --onlyvisible --name '^GP Connect$' | tail -n 1 | xargs xdotool getwindowpid) && "
|
||||||
|
"readlink /proc/$pid/exe | grep -E '/[.]?" + name + "(-wrapped)?$'"
|
||||||
|
))
|
||||||
|
|
||||||
|
launch()
|
||||||
|
wait_for_gui("gpgui-nsh")
|
||||||
|
machine.succeed(as_alice("test ! -e ~/.config/gpclient/gui"))
|
||||||
|
machine.succeed(as_alice("${pkgs.glib.bin}/bin/gapplication action com.yuezk.gpgui settings"))
|
||||||
|
machine.wait_until_succeeds(
|
||||||
|
as_alice("xdotool search --onlyvisible --name '^GP Connect Settings$'"),
|
||||||
|
timeout=timedelta(seconds=60),
|
||||||
|
)
|
||||||
|
machine.screenshot("native-shell-settings")
|
||||||
|
machine.wait_until_succeeds(as_alice(accessibility_env + "${chooseTauri}"), timeout=timedelta(seconds=60))
|
||||||
|
wait_for_gui("gpgui")
|
||||||
|
machine.succeed(as_alice("grep -Fx gpgui ~/.config/gpclient/gui"))
|
||||||
|
machine.succeed(as_alice("kill -TERM $(cat ~/gp-launch.pid)"))
|
||||||
|
machine.wait_until_succeeds("test ! -e /var/run/gpservice.lock")
|
||||||
|
|
||||||
|
launch()
|
||||||
|
wait_for_gui("gpgui")
|
||||||
|
machine.screenshot("tauri-relaunch")
|
||||||
|
'';
|
||||||
|
}
|
||||||
@@ -61,6 +61,7 @@ pkgs.testers.runNixOSTest {
|
|||||||
return machine.succeed("su - alice -c " + shlex.quote(command))
|
return machine.succeed("su - alice -c " + shlex.quote(command))
|
||||||
|
|
||||||
# Exercise real host pkexec, private credential pipes and launcher cancellation.
|
# Exercise real host pkexec, private credential pipes and launcher cancellation.
|
||||||
|
as_alice("mkdir -p ~/.config/gpclient && echo gpgui > ~/.config/gpclient/gui")
|
||||||
command = "GP_GUI_BINARY=${guiProbe} " + package + "/bin/gpclient --lock-file /tmp/gp-client.lock launch-gui"
|
command = "GP_GUI_BINARY=${guiProbe} " + package + "/bin/gpclient --lock-file /tmp/gp-client.lock launch-gui"
|
||||||
as_alice(command + " > /tmp/gp-client-output 2>&1 & echo $! > /tmp/gp-client-pid")
|
as_alice(command + " > /tmp/gp-client-output 2>&1 & echo $! > /tmp/gp-client-pid")
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ source="$pkgname-$pkgver.tar.gz"
|
|||||||
builddir="$srcdir/$pkgname-$pkgver"
|
builddir="$srcdir/$pkgname-$pkgver"
|
||||||
install="$pkgname.post-deinstall"
|
install="$pkgname.post-deinstall"
|
||||||
options="!check"
|
options="!check"
|
||||||
|
# GTK4 is loaded only by the optional Native Shell. Keep dependency tracing for the rest of the package.
|
||||||
|
somask="libgtk-4.so.1 libgraphene-1.0.so.0"
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
cd "$builddir"
|
cd "$builddir"
|
||||||
@@ -64,6 +66,7 @@ package() {
|
|||||||
|
|
||||||
make install \
|
make install \
|
||||||
DESTDIR="$pkgdir" \
|
DESTDIR="$pkgdir" \
|
||||||
|
INCLUDE_GUI="${INCLUDE_GUI:-0}" \
|
||||||
BUILD_GUI_HELPER="${BUILD_GUI_HELPER:-1}"
|
BUILD_GUI_HELPER="${BUILD_GUI_HELPER:-1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ install:
|
|||||||
install -Dm755 artifacts/usr/bin/gpgui-helper $(DESTDIR)/usr/bin/gpgui-helper
|
install -Dm755 artifacts/usr/bin/gpgui-helper $(DESTDIR)/usr/bin/gpgui-helper
|
||||||
|
|
||||||
if [ -f artifacts/usr/bin/gpgui ]; then \
|
if [ -f artifacts/usr/bin/gpgui ]; then \
|
||||||
install -Dm755 artifacts/usr/bin/gpgui $(DESTDIR)/usr/bin/gpgui; \
|
install -Dm755 artifacts/usr/bin/gpgui $(DESTDIR)/usr/bin/gpgui && \
|
||||||
|
install -Dm755 artifacts/usr/bin/gpgui-nsh $(DESTDIR)/usr/bin/gpgui-nsh && \
|
||||||
|
install -Dm644 artifacts/usr/share/licenses/globalprotect-openconnect/ICU4X-LICENSE.txt $(DESTDIR)/usr/share/licenses/globalprotect-openconnect/ICU4X-LICENSE.txt; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
install -Dm755 artifacts/usr/libexec/gpclient/vpnc-script $(DESTDIR)/usr/libexec/gpclient/vpnc-script
|
install -Dm755 artifacts/usr/libexec/gpclient/vpnc-script $(DESTDIR)/usr/libexec/gpclient/vpnc-script
|
||||||
@@ -37,6 +39,7 @@ uninstall:
|
|||||||
rm -f $(DESTDIR)/usr/bin/gpauth
|
rm -f $(DESTDIR)/usr/bin/gpauth
|
||||||
rm -f $(DESTDIR)/usr/bin/gpgui-helper
|
rm -f $(DESTDIR)/usr/bin/gpgui-helper
|
||||||
rm -f $(DESTDIR)/usr/bin/gpgui
|
rm -f $(DESTDIR)/usr/bin/gpgui
|
||||||
|
rm -f $(DESTDIR)/usr/bin/gpgui-nsh $(DESTDIR)/usr/share/licenses/globalprotect-openconnect/ICU4X-LICENSE.txt
|
||||||
|
|
||||||
rm -f $(DESTDIR)/usr/libexec/gpclient/vpnc-script
|
rm -f $(DESTDIR)/usr/libexec/gpclient/vpnc-script
|
||||||
rm -f $(DESTDIR)/usr/libexec/gpclient/gp-vpnc-script-installer
|
rm -f $(DESTDIR)/usr/libexec/gpclient/gp-vpnc-script-installer
|
||||||
|
|||||||
@@ -11,3 +11,7 @@ export PATH := /usr/lib/rust-@RUST_VERSION@/bin:/usr/local/cargo/bin:$(PATH)
|
|||||||
which cargo
|
which cargo
|
||||||
which rustc
|
which rustc
|
||||||
dh $@ --no-parallel
|
dh $@ --no-parallel
|
||||||
|
|
||||||
|
# Native Shell checks its optional runtime on launch.
|
||||||
|
override_dh_shlibdeps:
|
||||||
|
dh_shlibdeps -X/bin/gpgui-nsh
|
||||||
@@ -35,6 +35,7 @@ Requires: xdg-utils
|
|||||||
Conflicts: globalprotect-openconnect-snapshot
|
Conflicts: globalprotect-openconnect-snapshot
|
||||||
|
|
||||||
%global debug_package %{nil}
|
%global debug_package %{nil}
|
||||||
|
%global __requires_exclude_from ^%{_bindir}/gpgui-nsh$
|
||||||
|
|
||||||
%description
|
%description
|
||||||
A GUI for GlobalProtect VPN, based on OpenConnect, supports the SSO authentication method.
|
A GUI for GlobalProtect VPN, based on OpenConnect, supports the SSO authentication method.
|
||||||
@@ -57,14 +58,17 @@ fi
|
|||||||
%build
|
%build
|
||||||
# The injected RUSTFLAGS could fail the build
|
# The injected RUSTFLAGS could fail the build
|
||||||
unset RUSTFLAGS
|
unset RUSTFLAGS
|
||||||
make build
|
make build INCLUDE_GUI=%{?include_gui}%{!?include_gui:0}
|
||||||
|
|
||||||
%install
|
%install
|
||||||
%make_install
|
%make_install INCLUDE_GUI=%{?include_gui}%{!?include_gui:0}
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%defattr(-,root,root)
|
%defattr(-,root,root)
|
||||||
%{_bindir}/*
|
%{_bindir}/*
|
||||||
|
%if 0%{?include_gui}
|
||||||
|
%license %{_datadir}/licenses/%{name}/ICU4X-LICENSE.txt
|
||||||
|
%endif
|
||||||
%{_libexecdir}/gpclient/vpnc-script
|
%{_libexecdir}/gpclient/vpnc-script
|
||||||
%{_libexecdir}/gpclient/gp-hip-script-installer
|
%{_libexecdir}/gpclient/gp-hip-script-installer
|
||||||
%{_libexecdir}/gpclient/gp-vpnc-script-installer
|
%{_libexecdir}/gpclient/gp-vpnc-script-installer
|
||||||
|
|||||||
Executable
+38
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Run in the gpgui checkout with its matching gp sibling on a native Linux builder.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
manifest=apps/desktop-nsh/Cargo.toml
|
||||||
|
toolchain=1.97.0
|
||||||
|
host=$(rustc "+$toolchain" -vV | sed -n 's/^host: //p')
|
||||||
|
case "$host" in
|
||||||
|
x86_64-unknown-linux-gnu|aarch64-unknown-linux-gnu) suffix= ;;
|
||||||
|
x86_64-unknown-linux-musl|aarch64-unknown-linux-musl)
|
||||||
|
suffix=-musl
|
||||||
|
export RUSTFLAGS="-C target-feature=-crt-static"
|
||||||
|
;;
|
||||||
|
*) echo "Unsupported Linux NSH build target: $host" >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
pkg-config --exists 'gtk4 >= 4.14' gnutls dbus-1 wayland-client xkbcommon
|
||||||
|
cargo "+$toolchain" build --manifest-path "$manifest" --locked --release --bin gpgui-nsh \
|
||||||
|
--target "$host" --target-dir target
|
||||||
|
binary="target/$host/release/gpgui-nsh"
|
||||||
|
"$binary" --version
|
||||||
|
needed=$(readelf -d "$binary")
|
||||||
|
if grep -q 'NEEDED.*libicu' <<<"$needed"; then
|
||||||
|
echo 'The release executable must not depend on ICU4C.' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ $suffix == -musl ]]; then
|
||||||
|
readelf -lW "$binary" | grep 'Requesting program interpreter: /lib/ld-musl-' >/dev/null
|
||||||
|
fi
|
||||||
|
version=$(cargo "+$toolchain" metadata --manifest-path "$manifest" --no-deps --format-version 1 \
|
||||||
|
| jq -er '.packages[] | select(.name == "gpgui-nsh") | .version')
|
||||||
|
directory="gpgui-nsh_$version"
|
||||||
|
archive="gpgui-nsh_$(uname -m)$suffix.bin.tar.xz"
|
||||||
|
mkdir -p ".build/package/$directory"
|
||||||
|
cp "$binary" apps/desktop-nsh/ICU4X-LICENSE.txt ".build/package/$directory/"
|
||||||
|
cd .build/package
|
||||||
|
tar -cJf "$archive" "$directory"
|
||||||
|
sha256sum "$archive" | cut -d ' ' -f 1 > "$archive.sha256"
|
||||||
@@ -47,10 +47,6 @@ upload_files() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
release_assets() {
|
|
||||||
"$SCRIPT_DIR/release-assets.sh" "$TAG"
|
|
||||||
}
|
|
||||||
|
|
||||||
release_assets_json() {
|
release_assets_json() {
|
||||||
retry_gh gh -R "$REPO" release view "$TAG" --json assets
|
retry_gh gh -R "$REPO" release view "$TAG" --json assets
|
||||||
}
|
}
|
||||||
@@ -134,7 +130,6 @@ upload_file() {
|
|||||||
# Keep its tag fixed; only release assets advance with subsequent builds.
|
# Keep its tag fixed; only release assets advance with subsequent builds.
|
||||||
# Preserve its macOS update assets when the current run does not replace them.
|
# Preserve its macOS update assets when the current run does not replace them.
|
||||||
release_snapshot() {
|
release_snapshot() {
|
||||||
mapfile -t files < <(release_assets)
|
|
||||||
local existing_assets
|
local existing_assets
|
||||||
local is_current
|
local is_current
|
||||||
local asset
|
local asset
|
||||||
@@ -201,11 +196,13 @@ release_tag() {
|
|||||||
--notes-file "$release_notes_file"
|
--notes-file "$release_notes_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mapfile -t files < <(release_assets)
|
|
||||||
GITHUB_REPOSITORY="$REPO" "$SCRIPT_DIR/upload-release-assets.sh" "$TAG" "${files[@]}"
|
GITHUB_REPOSITORY="$REPO" "$SCRIPT_DIR/upload-release-assets.sh" "$TAG" "${files[@]}"
|
||||||
gh -R "$REPO" release edit "$TAG" --prerelease=false
|
gh -R "$REPO" release edit "$TAG" --prerelease=false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asset_list=$("$SCRIPT_DIR/release-assets.sh" "$TAG")
|
||||||
|
mapfile -t files <<<"$asset_list"
|
||||||
|
|
||||||
if [[ $TAG == *"snapshot" ]]; then
|
if [[ $TAG == *"snapshot" ]]; then
|
||||||
release_snapshot
|
release_snapshot
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ path = Path('flake.nix')
|
|||||||
promoted = path.read_text()
|
promoted = path.read_text()
|
||||||
fields = [(name, rf'(\b{name}\s*=\s*")([^"]+)(")')
|
fields = [(name, rf'(\b{name}\s*=\s*")([^"]+)(")')
|
||||||
for name in ('releaseTag', 'releaseVersion')]
|
for name in ('releaseTag', 'releaseVersion')]
|
||||||
for block in ('gpguiHashes', 'binaryHashes'):
|
for block in ('gpguiHashes', 'nshHashes', 'binaryHashes'):
|
||||||
for arch in ('x86_64', 'aarch64'):
|
for arch in ('x86_64', 'aarch64'):
|
||||||
fields.append((f'{block}.{arch}', rf'(\b{block}\s*=\s*\{{[^}}]*?\b{arch}\s*=\s*")([^"]+)(")'))
|
fields.append((f'{block}.{arch}', rf'(\b{block}\s*=\s*\{{[^}}]*?\b{arch}\s*=\s*")([^"]+)(")'))
|
||||||
for name, pattern in fields:
|
for name, pattern in fields:
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ elif [ "$SELECTION" != "all" ]; then
|
|||||||
SELECTION=tag
|
SELECTION=tag
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# The follow-up distro-package workflow uses "all" for its own package artifacts.
|
||||||
|
if [[ "$SELECTION" != "all" ]]; then
|
||||||
|
"$SCRIPT_DIR/verify-linux-nsh-assets.sh" "$ARTIFACT_DIR" --actions
|
||||||
|
fi
|
||||||
|
|
||||||
case "$SELECTION" in
|
case "$SELECTION" in
|
||||||
snapshot|all)
|
snapshot|all)
|
||||||
printf '%s\n' "$ARTIFACT_DIR"/artifact-*/*
|
printf '%s\n' "$ARTIFACT_DIR"/artifact-*/*
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ cd "$root"
|
|||||||
temp=$(mktemp -d)
|
temp=$(mktemp -d)
|
||||||
trap 'rm -rf "$temp"' EXIT HUP INT TERM
|
trap 'rm -rf "$temp"' EXIT HUP INT TERM
|
||||||
mkdir -p "$temp/release"
|
mkdir -p "$temp/release"
|
||||||
for binary in gpclient gpauth gpservice gpgui gpgui-helper gp-vpnc-script-installer gp-hip-script-installer; do
|
for binary in gpclient gpauth gpservice gpgui gpgui-nsh gpgui-helper gp-vpnc-script-installer gp-hip-script-installer; do
|
||||||
printf '#!/bin/sh\nexit 0\n' > "$temp/release/$binary"
|
printf '#!/bin/sh\nexit 0\n' > "$temp/release/$binary"
|
||||||
chmod 755 "$temp/release/$binary"
|
chmod 755 "$temp/release/$binary"
|
||||||
done
|
done
|
||||||
|
echo 'ICU4X license fixture' > "$temp/release/ICU4X-LICENSE.txt"
|
||||||
mkdir -p "$temp/client-release"
|
mkdir -p "$temp/client-release"
|
||||||
cp "$temp/release/gpclient" "$temp/client-release/"
|
cp "$temp/release/gpclient" "$temp/client-release/"
|
||||||
make install-gpclient-unix PREFIX='/custom/gp install' DESTDIR="$temp/client-stage" \
|
make install-gpclient-unix PREFIX='/custom/gp install' DESTDIR="$temp/client-stage" \
|
||||||
@@ -19,7 +20,7 @@ test -x "$installed/libexec/gpclient/vpnc-script"
|
|||||||
test "$(find "$installed" -type f | wc -l | tr -d ' ')" = 2
|
test "$(find "$installed" -type f | wc -l | tr -d ' ')" = 2
|
||||||
for platform in linux bsd; do
|
for platform in linux bsd; do
|
||||||
stage="$temp/$platform-stage"
|
stage="$temp/$platform-stage"
|
||||||
make "install-$platform" PREFIX=/custom/gp DESTDIR="$stage" \
|
make "install-$platform" PREFIX=/custom/gp DESTDIR="$stage" INCLUDE_GUI=1 NSH_BUNDLE_DIR="$temp/release" \
|
||||||
CARGO_RELEASE_DIR="$temp/release" GPGUI_BINARY="$temp/release/gpgui" > "$temp/$platform.log"
|
CARGO_RELEASE_DIR="$temp/release" GPGUI_BINARY="$temp/release/gpgui" > "$temp/$platform.log"
|
||||||
installed="$stage/custom/gp"
|
installed="$stage/custom/gp"
|
||||||
test -x "$installed/bin/gpclient"
|
test -x "$installed/bin/gpclient"
|
||||||
@@ -35,8 +36,11 @@ for platform in linux bsd; do
|
|||||||
! grep -F "$stage" "$installed/share/applications/gpgui.desktop"
|
! grep -F "$stage" "$installed/share/applications/gpgui.desktop"
|
||||||
if [ "$platform" = bsd ]; then
|
if [ "$platform" = bsd ]; then
|
||||||
test ! -d "$installed/lib/NetworkManager"
|
test ! -d "$installed/lib/NetworkManager"
|
||||||
|
test ! -e "$installed/bin/gpgui-nsh"
|
||||||
else
|
else
|
||||||
test -x "$installed/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down"
|
test -x "$installed/lib/NetworkManager/dispatcher.d/pre-down.d/gpclient.down"
|
||||||
|
test -x "$installed/bin/gpgui-nsh"
|
||||||
|
cmp "$temp/release/ICU4X-LICENSE.txt" "$installed/share/licenses/globalprotect-openconnect/ICU4X-LICENSE.txt"
|
||||||
fi
|
fi
|
||||||
runtime="$stage/var/lib/gpclient"
|
runtime="$stage/var/lib/gpclient"
|
||||||
if [ "$platform" = bsd ]; then
|
if [ "$platform" = bsd ]; then
|
||||||
@@ -60,6 +64,12 @@ for platform in linux bsd; do
|
|||||||
test -f "$installed/libexec/gpclient/unrelated"
|
test -f "$installed/libexec/gpclient/unrelated"
|
||||||
test -f "$runtime/scripts/unrelated"
|
test -f "$runtime/scripts/unrelated"
|
||||||
done
|
done
|
||||||
|
if make install-linux INCLUDE_GUI=1 PREFIX=/usr DESTDIR="$temp/missing-nsh" \
|
||||||
|
GPGUI_BINARY="$temp/release/gpgui" NSH_BUNDLE_DIR="$temp/absent" \
|
||||||
|
CARGO_RELEASE_DIR="$temp/release" > "$temp/missing-nsh.log" 2>&1; then
|
||||||
|
echo 'FAIL: bundled package installation succeeded without Native Shell' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
mv "$temp/release/gpclient" "$temp/release/gpclient.saved"
|
mv "$temp/release/gpclient" "$temp/release/gpclient.saved"
|
||||||
if make install-linux PREFIX=/custom/gp DESTDIR="$temp/missing-client-stage" \
|
if make install-linux PREFIX=/custom/gp DESTDIR="$temp/missing-client-stage" \
|
||||||
CARGO_RELEASE_DIR="$temp/release" > "$temp/missing-client.log" 2>&1; then
|
CARGO_RELEASE_DIR="$temp/release" > "$temp/missing-client.log" 2>&1; then
|
||||||
|
|||||||
@@ -45,3 +45,4 @@ check_authorization() {
|
|||||||
check_authorization "$package_path/bin/gpclient" launch-gui --minimized
|
check_authorization "$package_path/bin/gpclient" launch-gui --minimized
|
||||||
check_authorization "$package_path/bin/gpclient" --lock-file "$test_workspace/client.lock" launch-gui
|
check_authorization "$package_path/bin/gpclient" --lock-file "$test_workspace/client.lock" launch-gui
|
||||||
check_authorization "$package_path/bin/gpgui" --minimized
|
check_authorization "$package_path/bin/gpgui" --minimized
|
||||||
|
check_authorization "$package_path/bin/gpgui-nsh" --minimized
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import hashlib
|
||||||
import importlib.util
|
import importlib.util
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
@@ -80,7 +81,7 @@ class ReleaseVersionTests(unittest.TestCase):
|
|||||||
write_version(root, '3.2.0')
|
write_version(root, '3.2.0')
|
||||||
package = root / 'result'
|
package = root / 'result'
|
||||||
(package / 'bin').mkdir(parents=True)
|
(package / 'bin').mkdir(parents=True)
|
||||||
for name in ('gpclient', 'gpservice', 'gpauth', 'gpgui'):
|
for name in ('gpclient', 'gpservice', 'gpauth', 'gpgui', 'gpgui-nsh'):
|
||||||
tool = package / 'bin' / name
|
tool = package / 'bin' / name
|
||||||
tool.write_text(f'#!/bin/sh\necho "{name} 3.2.0 (PRIVATE_IDENTITY)"\n')
|
tool.write_text(f'#!/bin/sh\necho "{name} 3.2.0 (PRIVATE_IDENTITY)"\n')
|
||||||
tool.chmod(0o755)
|
tool.chmod(0o755)
|
||||||
@@ -90,6 +91,44 @@ class ReleaseVersionTests(unittest.TestCase):
|
|||||||
versions.validate(root, package=package)
|
versions.validate(root, package=package)
|
||||||
|
|
||||||
|
|
||||||
|
class LinuxNshAssetsTests(unittest.TestCase):
|
||||||
|
def test_releases_require_both_architectures_and_libcs_with_matching_checksums(self):
|
||||||
|
with tempfile.TemporaryDirectory() as temp:
|
||||||
|
root = Path(temp)
|
||||||
|
assets = []
|
||||||
|
for arch in ('x86_64', 'aarch64'):
|
||||||
|
for suffix in ('', '-musl'):
|
||||||
|
directory = root / f'artifact-gpgui-nsh{suffix}-{arch}'
|
||||||
|
directory.mkdir()
|
||||||
|
archive = directory / f'gpgui-nsh_{arch}{suffix}.bin.tar.xz'
|
||||||
|
archive.write_bytes(archive.name.encode())
|
||||||
|
sidecar = archive.with_name(archive.name + '.sha256')
|
||||||
|
sidecar.write_text(hashlib.sha256(archive.read_bytes()).hexdigest() + '\n')
|
||||||
|
assets.extend((archive, sidecar))
|
||||||
|
|
||||||
|
for channel in ('snapshot', 'v3.7.0'):
|
||||||
|
command = [ROOT / 'scripts/release-assets.sh', channel, root]
|
||||||
|
valid = subprocess.run(command, capture_output=True, text=True, check=True)
|
||||||
|
self.assertEqual(set(valid.stdout.splitlines()), {str(asset) for asset in assets})
|
||||||
|
for asset in assets:
|
||||||
|
data = asset.read_bytes()
|
||||||
|
asset.unlink()
|
||||||
|
self.assertNotEqual(subprocess.run(command, capture_output=True).returncode, 0, asset.name)
|
||||||
|
asset.write_bytes(data)
|
||||||
|
archive = assets[0]
|
||||||
|
data = archive.read_bytes()
|
||||||
|
archive.write_bytes(b'corrupt')
|
||||||
|
self.assertNotEqual(subprocess.run(command, capture_output=True).returncode, 0)
|
||||||
|
archive.write_bytes(data)
|
||||||
|
|
||||||
|
for asset in assets:
|
||||||
|
asset.rename(root / asset.name)
|
||||||
|
verify_published = [ROOT / 'scripts/verify-linux-nsh-assets.sh', root]
|
||||||
|
subprocess.run(verify_published, capture_output=True, check=True)
|
||||||
|
(root / assets[-1].name).unlink()
|
||||||
|
self.assertNotEqual(subprocess.run(verify_published, capture_output=True).returncode, 0)
|
||||||
|
|
||||||
|
|
||||||
class BuildIdentityTests(unittest.TestCase):
|
class BuildIdentityTests(unittest.TestCase):
|
||||||
def test_retry_uses_original_sources_after_both_branches_advance(self):
|
def test_retry_uses_original_sources_after_both_branches_advance(self):
|
||||||
with tempfile.TemporaryDirectory() as temp:
|
with tempfile.TemporaryDirectory() as temp:
|
||||||
@@ -145,6 +184,7 @@ class PromotionTests(unittest.TestCase):
|
|||||||
initialize(repo)
|
initialize(repo)
|
||||||
write_version(repo)
|
write_version(repo)
|
||||||
hashes = 'gpguiHashes = { x86_64 = "old-gui-x64"; aarch64 = "old-gui-arm64"; };\n' \
|
hashes = 'gpguiHashes = { x86_64 = "old-gui-x64"; aarch64 = "old-gui-arm64"; };\n' \
|
||||||
|
'nshHashes = { x86_64 = "old-nsh-x64"; aarch64 = "old-nsh-arm64"; };\n' \
|
||||||
'binaryHashes = { x86_64 = "old-cli-x64"; aarch64 = "old-cli-arm64"; };\n'
|
'binaryHashes = { x86_64 = "old-cli-x64"; aarch64 = "old-cli-arm64"; };\n'
|
||||||
with (repo / 'flake.nix').open('a') as flake:
|
with (repo / 'flake.nix').open('a') as flake:
|
||||||
flake.write('packageSetting = "original";\n' + hashes)
|
flake.write('packageSetting = "original";\n' + hashes)
|
||||||
|
|||||||
@@ -81,11 +81,15 @@ release_url() {
|
|||||||
|
|
||||||
gpgui_x86_64_hash="$(prefetch_hash "$(release_url "gpgui_x86_64.bin.tar.xz")")"
|
gpgui_x86_64_hash="$(prefetch_hash "$(release_url "gpgui_x86_64.bin.tar.xz")")"
|
||||||
gpgui_aarch64_hash="$(prefetch_hash "$(release_url "gpgui_aarch64.bin.tar.xz")")"
|
gpgui_aarch64_hash="$(prefetch_hash "$(release_url "gpgui_aarch64.bin.tar.xz")")"
|
||||||
|
nsh_x86_64_hash="$(prefetch_hash "$(release_url "gpgui-nsh_x86_64.bin.tar.xz")")"
|
||||||
|
nsh_aarch64_hash="$(prefetch_hash "$(release_url "gpgui-nsh_aarch64.bin.tar.xz")")"
|
||||||
binary_x86_64_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect_${version}_x86_64.bin.tar.xz")")"
|
binary_x86_64_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect_${version}_x86_64.bin.tar.xz")")"
|
||||||
binary_aarch64_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect_${version}_aarch64.bin.tar.xz")")"
|
binary_aarch64_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect_${version}_aarch64.bin.tar.xz")")"
|
||||||
|
|
||||||
GPGUI_X86_64_HASH="$gpgui_x86_64_hash" \
|
GPGUI_X86_64_HASH="$gpgui_x86_64_hash" \
|
||||||
GPGUI_AARCH64_HASH="$gpgui_aarch64_hash" \
|
GPGUI_AARCH64_HASH="$gpgui_aarch64_hash" \
|
||||||
|
NSH_X86_64_HASH="$nsh_x86_64_hash" \
|
||||||
|
NSH_AARCH64_HASH="$nsh_aarch64_hash" \
|
||||||
BINARY_X86_64_HASH="$binary_x86_64_hash" \
|
BINARY_X86_64_HASH="$binary_x86_64_hash" \
|
||||||
BINARY_AARCH64_HASH="$binary_aarch64_hash" \
|
BINARY_AARCH64_HASH="$binary_aarch64_hash" \
|
||||||
RELEASE_TAG="$release_tag" \
|
RELEASE_TAG="$release_tag" \
|
||||||
@@ -95,12 +99,16 @@ perl -0pi -e '
|
|||||||
s|(releaseVersion = ")[^"]+(";)|$1 . $ENV{"RELEASE_VERSION"} . $2|e;
|
s|(releaseVersion = ")[^"]+(";)|$1 . $ENV{"RELEASE_VERSION"} . $2|e;
|
||||||
s|(gpguiHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_X86_64_HASH"} . $2|e;
|
s|(gpguiHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_X86_64_HASH"} . $2|e;
|
||||||
s|(gpguiHashes = \{\n\s*x86_64 = "[^"]+";\n\s*aarch64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_AARCH64_HASH"} . $2|e;
|
s|(gpguiHashes = \{\n\s*x86_64 = "[^"]+";\n\s*aarch64 = ")[^"]+(";)|$1 . $ENV{"GPGUI_AARCH64_HASH"} . $2|e;
|
||||||
|
s|(nshHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"NSH_X86_64_HASH"} . $2|e;
|
||||||
|
s|(nshHashes = \{\n\s*x86_64 = "[^"]+";\n\s*aarch64 = ")[^"]+(";)|$1 . $ENV{"NSH_AARCH64_HASH"} . $2|e;
|
||||||
s|(binaryHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"BINARY_X86_64_HASH"} . $2|e;
|
s|(binaryHashes = \{\n\s*x86_64 = ")[^"]+(";)|$1 . $ENV{"BINARY_X86_64_HASH"} . $2|e;
|
||||||
s|(binaryHashes = \{\n\s*x86_64 = "[^"]+";\n\s*aarch64 = ")[^"]+(";)|$1 . $ENV{"BINARY_AARCH64_HASH"} . $2|e;
|
s|(binaryHashes = \{\n\s*x86_64 = "[^"]+";\n\s*aarch64 = ")[^"]+(";)|$1 . $ENV{"BINARY_AARCH64_HASH"} . $2|e;
|
||||||
' "$FLAKE_FILE"
|
' "$FLAKE_FILE"
|
||||||
|
|
||||||
grep -F "$gpgui_x86_64_hash" "$FLAKE_FILE" > /dev/null
|
grep -F "$gpgui_x86_64_hash" "$FLAKE_FILE" > /dev/null
|
||||||
grep -F "$gpgui_aarch64_hash" "$FLAKE_FILE" > /dev/null
|
grep -F "$gpgui_aarch64_hash" "$FLAKE_FILE" > /dev/null
|
||||||
|
grep -F "$nsh_x86_64_hash" "$FLAKE_FILE" > /dev/null
|
||||||
|
grep -F "$nsh_aarch64_hash" "$FLAKE_FILE" > /dev/null
|
||||||
grep -F "$binary_x86_64_hash" "$FLAKE_FILE" > /dev/null
|
grep -F "$binary_x86_64_hash" "$FLAKE_FILE" > /dev/null
|
||||||
grep -F "$binary_aarch64_hash" "$FLAKE_FILE" > /dev/null
|
grep -F "$binary_aarch64_hash" "$FLAKE_FILE" > /dev/null
|
||||||
grep -F "releaseTag = \"$release_tag\";" "$FLAKE_FILE" > /dev/null
|
grep -F "releaseTag = \"$release_tag\";" "$FLAKE_FILE" > /dev/null
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ def validate(root, version=None, release_tag=None, package=None, base_ref=None):
|
|||||||
if tuple(map(int, expected.split("."))) < tuple(map(int, base.split("."))):
|
if tuple(map(int, expected.split("."))) < tuple(map(int, base.split("."))):
|
||||||
raise ValueError("candidate release is older than the main base")
|
raise ValueError("candidate release is older than the main base")
|
||||||
if package:
|
if package:
|
||||||
for name in ("gpclient", "gpservice", "gpauth", "gpgui"):
|
for name in ("gpclient", "gpservice", "gpauth", "gpgui", "gpgui-nsh"):
|
||||||
result = subprocess.run([str(package / "bin" / name), "--version"],
|
result = subprocess.run([str(package / "bin" / name), "--version"],
|
||||||
capture_output=True, text=True, check=True)
|
capture_output=True, text=True, check=True)
|
||||||
# Keep private source identity and other command output out of logs.
|
# Keep private source identity and other command output out of logs.
|
||||||
|
|||||||
Executable
+19
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
root="${1:?Expected a release download directory or Actions artifact directory}"
|
||||||
|
for arch in x86_64 aarch64; do
|
||||||
|
for suffix in '' '-musl'; do
|
||||||
|
directory="$root"
|
||||||
|
if [[ ${2:-} == --actions ]]; then
|
||||||
|
directory="$root/artifact-gpgui-nsh${suffix}-$arch"
|
||||||
|
fi
|
||||||
|
archive="$directory/gpgui-nsh_${arch}${suffix}.bin.tar.xz"
|
||||||
|
digest=$(cat "$archive.sha256")
|
||||||
|
if [[ ! $digest =~ ^[[:xdigit:]]{64}$ ]]; then
|
||||||
|
echo "Invalid SHA-256 sidecar: $archive.sha256" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf '%s %s\n' "$digest" "$archive" | sha256sum -c - >&2
|
||||||
|
done
|
||||||
|
done
|
||||||
Executable
+43
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Run inside the distro builder after install.sh installs the newly built package.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
package=globalprotect-openconnect
|
||||||
|
notice=/usr/share/licenses/$package/ICU4X-LICENSE.txt
|
||||||
|
for path in /usr/bin/gpgui /usr/bin/gpgui-nsh; do
|
||||||
|
test -x "$path"
|
||||||
|
done
|
||||||
|
test -s "$notice"
|
||||||
|
|
||||||
|
case "${1:?Expected a package format}" in
|
||||||
|
binary) exit 0 ;;
|
||||||
|
deb|ubuntu-rolling)
|
||||||
|
files=$(dpkg-query -L "$package")
|
||||||
|
requires=$(dpkg-query -W -f='${Pre-Depends} ${Depends}\n' "$package")
|
||||||
|
;;
|
||||||
|
rpm)
|
||||||
|
files=$(rpm -ql "$package")
|
||||||
|
requires=$(rpm -q --requires "$package")
|
||||||
|
;;
|
||||||
|
apk)
|
||||||
|
files=$(apk info -L "$package")
|
||||||
|
requires=$(apk info -R "$package")
|
||||||
|
;;
|
||||||
|
pkg)
|
||||||
|
files=$(pacman -Qlq "$package")
|
||||||
|
requires=$(bsdtar -xOf /workspace/artifacts/*.pkg.tar.zst .PKGINFO | sed -n 's/^depend = //p')
|
||||||
|
;;
|
||||||
|
*) echo "Unknown package format: $1" >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# apk emits paths relative to /. Other package managers use absolute paths.
|
||||||
|
for path in /usr/bin/gpgui /usr/bin/gpgui-nsh "$notice"; do
|
||||||
|
if ! grep -Fxq -e "$path" -e "${path#/}" <<<"$files"; then
|
||||||
|
echo "$package does not own $path" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if grep -Eq '(^|[[:space:],:(|])(lib)?gtk-?4([^[:alnum:]_]|$)' <<<"$requires"; then
|
||||||
|
echo "Package metadata makes GTK4 mandatory: $requires" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Reference in new issue
Block a user