mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-20 15:06:14 -05:00
Prefer Native Shell on supported Linux installations
This commit is contained in:
37 files changed
+869
-250
No files matched your search
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
|
||||
}
|
||||
|
||||
release_assets() {
|
||||
"$SCRIPT_DIR/release-assets.sh" "$TAG"
|
||||
}
|
||||
|
||||
release_assets_json() {
|
||||
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.
|
||||
# Preserve its macOS update assets when the current run does not replace them.
|
||||
release_snapshot() {
|
||||
mapfile -t files < <(release_assets)
|
||||
local existing_assets
|
||||
local is_current
|
||||
local asset
|
||||
@@ -201,11 +196,13 @@ release_tag() {
|
||||
--notes-file "$release_notes_file"
|
||||
fi
|
||||
|
||||
mapfile -t files < <(release_assets)
|
||||
GITHUB_REPOSITORY="$REPO" "$SCRIPT_DIR/upload-release-assets.sh" "$TAG" "${files[@]}"
|
||||
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
|
||||
release_snapshot
|
||||
else
|
||||
|
||||
@@ -47,7 +47,7 @@ path = Path('flake.nix')
|
||||
promoted = path.read_text()
|
||||
fields = [(name, rf'(\b{name}\s*=\s*")([^"]+)(")')
|
||||
for name in ('releaseTag', 'releaseVersion')]
|
||||
for block in ('gpguiHashes', 'binaryHashes'):
|
||||
for block in ('gpguiHashes', 'nshHashes', 'binaryHashes'):
|
||||
for arch in ('x86_64', 'aarch64'):
|
||||
fields.append((f'{block}.{arch}', rf'(\b{block}\s*=\s*\{{[^}}]*?\b{arch}\s*=\s*")([^"]+)(")'))
|
||||
for name, pattern in fields:
|
||||
|
||||
@@ -20,6 +20,11 @@ elif [ "$SELECTION" != "all" ]; then
|
||||
SELECTION=tag
|
||||
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
|
||||
snapshot|all)
|
||||
printf '%s\n' "$ARTIFACT_DIR"/artifact-*/*
|
||||
|
||||
@@ -5,10 +5,11 @@ cd "$root"
|
||||
temp=$(mktemp -d)
|
||||
trap 'rm -rf "$temp"' EXIT HUP INT TERM
|
||||
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"
|
||||
chmod 755 "$temp/release/$binary"
|
||||
done
|
||||
echo 'ICU4X license fixture' > "$temp/release/ICU4X-LICENSE.txt"
|
||||
mkdir -p "$temp/client-release"
|
||||
cp "$temp/release/gpclient" "$temp/client-release/"
|
||||
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
|
||||
for platform in linux bsd; do
|
||||
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"
|
||||
installed="$stage/custom/gp"
|
||||
test -x "$installed/bin/gpclient"
|
||||
@@ -35,8 +36,11 @@ for platform in linux bsd; do
|
||||
! grep -F "$stage" "$installed/share/applications/gpgui.desktop"
|
||||
if [ "$platform" = bsd ]; then
|
||||
test ! -d "$installed/lib/NetworkManager"
|
||||
test ! -e "$installed/bin/gpgui-nsh"
|
||||
else
|
||||
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
|
||||
runtime="$stage/var/lib/gpclient"
|
||||
if [ "$platform" = bsd ]; then
|
||||
@@ -60,6 +64,12 @@ for platform in linux bsd; do
|
||||
test -f "$installed/libexec/gpclient/unrelated"
|
||||
test -f "$runtime/scripts/unrelated"
|
||||
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"
|
||||
if make install-linux PREFIX=/custom/gp DESTDIR="$temp/missing-client-stage" \
|
||||
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" --lock-file "$test_workspace/client.lock" launch-gui
|
||||
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 json
|
||||
import os
|
||||
@@ -80,7 +81,7 @@ class ReleaseVersionTests(unittest.TestCase):
|
||||
write_version(root, '3.2.0')
|
||||
package = root / 'result'
|
||||
(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.write_text(f'#!/bin/sh\necho "{name} 3.2.0 (PRIVATE_IDENTITY)"\n')
|
||||
tool.chmod(0o755)
|
||||
@@ -90,6 +91,44 @@ class ReleaseVersionTests(unittest.TestCase):
|
||||
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):
|
||||
def test_retry_uses_original_sources_after_both_branches_advance(self):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
@@ -145,6 +184,7 @@ class PromotionTests(unittest.TestCase):
|
||||
initialize(repo)
|
||||
write_version(repo)
|
||||
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'
|
||||
with (repo / 'flake.nix').open('a') as flake:
|
||||
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_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_aarch64_hash="$(prefetch_hash "$(release_url "globalprotect-openconnect_${version}_aarch64.bin.tar.xz")")"
|
||||
|
||||
GPGUI_X86_64_HASH="$gpgui_x86_64_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_AARCH64_HASH="$binary_aarch64_hash" \
|
||||
RELEASE_TAG="$release_tag" \
|
||||
@@ -95,12 +99,16 @@ perl -0pi -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 = "[^"]+";\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 = "[^"]+";\n\s*aarch64 = ")[^"]+(";)|$1 . $ENV{"BINARY_AARCH64_HASH"} . $2|e;
|
||||
' "$FLAKE_FILE"
|
||||
|
||||
grep -F "$gpgui_x86_64_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_aarch64_hash" "$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("."))):
|
||||
raise ValueError("candidate release is older than the main base")
|
||||
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"],
|
||||
capture_output=True, text=True, check=True)
|
||||
# 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