mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4da922aa3b | ||
|
|
ecc9c9f09c | ||
|
|
b32002710b | ||
|
|
7b6d20a003 | ||
|
|
d27029fad8 | ||
|
|
1b488ba696 | ||
|
|
f78f7c9bc8 | ||
|
|
7e11693ce3 | ||
|
|
536a43773f |
No files matched your search
@@ -348,6 +348,13 @@ jobs:
|
|||||||
test -x result/bin/gpservice
|
test -x result/bin/gpservice
|
||||||
test -x result/bin/gpgui-helper
|
test -x result/bin/gpgui-helper
|
||||||
test -x result/bin/gpgui
|
test -x result/bin/gpgui
|
||||||
|
test ! -L result/bin/gpservice
|
||||||
|
head -n1 result/bin/gpclient | grep '^#!'
|
||||||
|
head -n1 result/bin/gpservice | grep '^#!'
|
||||||
|
grep -q '/run/wrappers/bin/pkexec' result/bin/gpclient
|
||||||
|
grep -q 'gpservice_public=.*/bin/gpservice' result/bin/gpclient
|
||||||
|
grep -q 'exec .*/bin/gpservice' result/bin/gpservice
|
||||||
|
! grep -q '@gpservice_public@\|@gpservice_fhs@\|\$out/bin/gpservice' result/bin/gpclient result/bin/gpservice
|
||||||
|
|
||||||
! grep -R '/usr/bin/gp' result/share
|
! grep -R '/usr/bin/gp' result/share
|
||||||
|
|
||||||
|
|||||||
@@ -274,6 +274,13 @@ jobs:
|
|||||||
uses: actions/download-artifact@v8
|
uses: actions/download-artifact@v8
|
||||||
with:
|
with:
|
||||||
path: gh-release
|
path: gh-release
|
||||||
|
- name: Generate release notes
|
||||||
|
id: release-notes
|
||||||
|
run: |
|
||||||
|
cd gh-release/gp
|
||||||
|
mkdir -p .build
|
||||||
|
scripts/release-notes.sh "${{ inputs.tag }}" > .build/release-notes.md
|
||||||
|
echo "path=$GITHUB_WORKSPACE/gh-release/gp/.build/release-notes.md" >> "$GITHUB_OUTPUT"
|
||||||
- name: Rename APK artifacts
|
- name: Rename APK artifacts
|
||||||
run: |
|
run: |
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
@@ -314,4 +321,5 @@ jobs:
|
|||||||
prerelease: ${{ contains(github.ref, 'snapshot') }}
|
prerelease: ${{ contains(github.ref, 'snapshot') }}
|
||||||
fail_on_unmatched_files: true
|
fail_on_unmatched_files: true
|
||||||
tag_name: ${{ inputs.tag }}
|
tag_name: ${{ inputs.tag }}
|
||||||
|
body_path: ${{ steps.release-notes.outputs.path }}
|
||||||
files: ${{ steps.release-assets.outputs.files }}
|
files: ${{ steps.release-assets.outputs.files }}
|
||||||
@@ -6,9 +6,6 @@ on:
|
|||||||
version:
|
version:
|
||||||
description: "Release version. Defaults to Cargo.toml workspace version."
|
description: "Release version. Defaults to Cargo.toml workspace version."
|
||||||
required: false
|
required: false
|
||||||
release:
|
|
||||||
types:
|
|
||||||
- published
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -26,7 +23,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Update flake hashes
|
- name: Update flake hashes
|
||||||
env:
|
env:
|
||||||
RELEASE_VERSION: ${{ github.event.release.tag_name || inputs.version }}
|
RELEASE_VERSION: ${{ inputs.version }}
|
||||||
run: |
|
run: |
|
||||||
if [[ -n "$RELEASE_VERSION" ]]; then
|
if [[ -n "$RELEASE_VERSION" ]]; then
|
||||||
scripts/update-flake-hashes.sh "$RELEASE_VERSION"
|
scripts/update-flake-hashes.sh "$RELEASE_VERSION"
|
||||||
@@ -37,33 +34,5 @@ jobs:
|
|||||||
- name: Open pull request
|
- name: Open pull request
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
RELEASE_VERSION: ${{ github.event.release.tag_name || inputs.version }}
|
RELEASE_VERSION: ${{ inputs.version }}
|
||||||
run: |
|
run: scripts/open-flake-hashes-pr.sh "$RELEASE_VERSION"
|
||||||
if git diff --quiet -- flake.nix; then
|
|
||||||
echo "flake.nix hashes are already up to date"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
version="${RELEASE_VERSION:-$(grep '^version' Cargo.toml | head -1 | sed 's/version *= *"\(.*\)"/\1/')}"
|
|
||||||
version="${version#v}"
|
|
||||||
branch="chore/update-flake-hashes-v${version}"
|
|
||||||
|
|
||||||
git config user.name "github-actions[bot]"
|
|
||||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
||||||
git switch -c "$branch"
|
|
||||||
git add flake.nix
|
|
||||||
git commit -m "chore: update flake hashes for v${version}"
|
|
||||||
git push --force-with-lease origin "$branch"
|
|
||||||
|
|
||||||
if gh pr view "$branch" --json number > /tmp/flake-pr.json 2> /dev/null; then
|
|
||||||
pr_number="$(jq -r '.number' /tmp/flake-pr.json)"
|
|
||||||
gh pr edit "$pr_number" \
|
|
||||||
--title "chore: update flake hashes for v${version}" \
|
|
||||||
--body "Updates the Nix flake fetchzip hashes for v${version} release assets."
|
|
||||||
else
|
|
||||||
gh pr create \
|
|
||||||
--title "chore: update flake hashes for v${version}" \
|
|
||||||
--body "Updates the Nix flake fetchzip hashes for v${version} release assets." \
|
|
||||||
--base main \
|
|
||||||
--head "$branch"
|
|
||||||
fi
|
|
||||||
Generated
+8
-8
@@ -214,7 +214,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "auth"
|
name = "auth"
|
||||||
version = "2.6.0"
|
version = "2.6.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"block2",
|
"block2",
|
||||||
@@ -705,7 +705,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "common"
|
name = "common"
|
||||||
version = "2.6.0"
|
version = "2.6.1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "compile-time"
|
name = "compile-time"
|
||||||
@@ -1732,7 +1732,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpapi"
|
name = "gpapi"
|
||||||
version = "2.6.0"
|
version = "2.6.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
@@ -1776,7 +1776,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpauth"
|
name = "gpauth"
|
||||||
version = "2.6.0"
|
version = "2.6.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"auth",
|
"auth",
|
||||||
@@ -1796,7 +1796,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpclient"
|
name = "gpclient"
|
||||||
version = "2.6.0"
|
version = "2.6.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"askama",
|
"askama",
|
||||||
@@ -1825,7 +1825,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpgui-helper"
|
name = "gpgui-helper"
|
||||||
version = "2.6.0"
|
version = "2.6.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
@@ -1843,7 +1843,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpservice"
|
name = "gpservice"
|
||||||
version = "2.6.0"
|
version = "2.6.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"axum",
|
"axum",
|
||||||
@@ -3191,7 +3191,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openconnect"
|
name = "openconnect"
|
||||||
version = "2.6.0"
|
version = "2.6.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autotools",
|
"autotools",
|
||||||
"cc",
|
"cc",
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ members = [
|
|||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
rust-version = "1.89"
|
rust-version = "1.89"
|
||||||
version = "2.6.0"
|
version = "2.6.1"
|
||||||
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"
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ gpauth <portal> --browser 2>/dev/null | sudo gpclient connect <portal> --cookie-
|
|||||||
```
|
```
|
||||||
|
|
||||||
**Browser Options:**
|
**Browser Options:**
|
||||||
|
- Use `--browser` to auto-select Chrome, Firefox, then the system default browser
|
||||||
|
- Use `--browser default` to use the system default browser
|
||||||
- Use `--browser <browser>` to specify a browser (e.g., `firefox`, `chrome`)
|
- Use `--browser <browser>` to specify a browser (e.g., `firefox`, `chrome`)
|
||||||
- Use `--browser remote` for headless servers – this provides a URL you can access from another machine to complete authentication
|
- Use `--browser remote` for headless servers – this provides a URL you can access from another machine to complete authentication
|
||||||
|
|
||||||
@@ -234,8 +236,11 @@ Add the flake input and package to your `flake.nix`:
|
|||||||
modules = [
|
modules = [
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
{
|
{
|
||||||
|
services.ayatana-indicators.enable = true;
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
globalprotect-openconnect.packages.${system}.default
|
globalprotect-openconnect.packages.${system}.default
|
||||||
|
nixpkgs.legacyPackages.${system}.gnomeExtensions.appindicator
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
@@ -248,6 +253,13 @@ Apply:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo nixos-rebuild switch
|
sudo nixos-rebuild switch
|
||||||
|
loginctl terminate-user "$USER"
|
||||||
|
```
|
||||||
|
|
||||||
|
After logging back in to GNOME, enable AppIndicator support if needed:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gnome-extensions enable [email protected]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Official Docker Image
|
### Official Docker Image
|
||||||
|
|||||||
+19
-2
@@ -69,8 +69,8 @@ struct Cli {
|
|||||||
|
|
||||||
#[arg(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
help = "The browser to use for authentication, e.g., `default`, `firefox`, `chrome`, `chromium`, or the path to the browser executable",
|
help = "Use external browser authentication. With no value, auto-select Chrome, Firefox, then system default. Use `default` for the system default browser.",
|
||||||
default_missing_value = "default",
|
default_missing_value = "auto",
|
||||||
num_args=0..=1
|
num_args=0..=1
|
||||||
)]
|
)]
|
||||||
browser: Option<String>,
|
browser: Option<String>,
|
||||||
@@ -250,6 +250,23 @@ mod tests {
|
|||||||
assert!(cli.external_browser_requested());
|
assert!(cli.external_browser_requested());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn browser_without_value_uses_auto_mode() {
|
||||||
|
let cli = Cli::try_parse_from(["gpauth", "portal.example.com", "--browser"]).expect("gpauth args should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.browser.as_deref(), Some("auto"));
|
||||||
|
assert!(cli.external_browser_requested());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn browser_default_keeps_system_default_mode() {
|
||||||
|
let cli =
|
||||||
|
Cli::try_parse_from(["gpauth", "portal.example.com", "--browser", "default"]).expect("gpauth args should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.browser.as_deref(), Some("default"));
|
||||||
|
assert!(cli.external_browser_requested());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn client_version_arg_sets_profile_client_version() {
|
fn client_version_arg_sets_profile_client_version() {
|
||||||
let cli = Cli::try_parse_from(["gpauth", "portal.example.com", "--client-version", "legacy-client"])
|
let cli = Cli::try_parse_from(["gpauth", "portal.example.com", "--client-version", "legacy-client"])
|
||||||
|
|||||||
@@ -141,8 +141,8 @@ pub(crate) struct ConnectArgs {
|
|||||||
|
|
||||||
#[arg(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
help = "Use the specified browser to authenticate, e.g., `default`, `firefox`, `chrome`, `chromium`, `remote`.\nOr the path to the browser executable.\nUse 'remote' for headless servers.",
|
help = "Use external browser authentication. With no value, auto-select Chrome, Firefox, then system default. Use `default` for the system default browser or `remote` for headless servers.",
|
||||||
default_missing_value = "default",
|
default_missing_value = "auto",
|
||||||
num_args=0..=1
|
num_args=0..=1
|
||||||
)]
|
)]
|
||||||
pub(super) browser: Option<String>,
|
pub(super) browser: Option<String>,
|
||||||
@@ -243,6 +243,26 @@ mod tests {
|
|||||||
assert_eq!(cli.args.gateway.as_deref(), Some("gw1"));
|
assert_eq!(cli.args.gateway.as_deref(), Some("gw1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn browser_without_value_uses_auto_mode() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--browser"])
|
||||||
|
.expect("--browser without value should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.args.browser.as_deref(), Some("auto"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn browser_default_keeps_system_default_mode() {
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
let cli = ConnectArgsTestCli::try_parse_from(["test", "portal.example.com", "--browser", "default"])
|
||||||
|
.expect("--browser default should parse");
|
||||||
|
|
||||||
|
assert_eq!(cli.args.browser.as_deref(), Some("default"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn os_defaults_to_runtime_os() {
|
fn os_defaults_to_runtime_os() {
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2.6.1
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Improved external browser authentication so `--browser` chooses Chrome first, then Firefox, then the system default browser.
|
||||||
|
- Improved NixOS prebuilt package integration for launching helper binaries and desktop services.
|
||||||
|
- Updated the release process to publish GitHub release notes from the changelog.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed NixOS GUI launch failures caused by package-local binary paths.
|
||||||
|
- Fixed NixOS tray icon setup documentation for GNOME desktops.
|
||||||
|
- Fixed release automation so Nix flake hash updates are run manually after release assets are available.
|
||||||
|
|
||||||
## 2.6.0
|
## 2.6.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use tokio::{
|
|||||||
use crate::browser::auth_server::AuthServer;
|
use crate::browser::auth_server::AuthServer;
|
||||||
|
|
||||||
pub enum Browser<'a> {
|
pub enum Browser<'a> {
|
||||||
|
Auto,
|
||||||
Default,
|
Default,
|
||||||
Chrome,
|
Chrome,
|
||||||
Firefox,
|
Firefox,
|
||||||
@@ -21,6 +22,7 @@ pub enum Browser<'a> {
|
|||||||
impl<'a> Browser<'a> {
|
impl<'a> Browser<'a> {
|
||||||
pub fn from_str(browser: &'a str) -> Self {
|
pub fn from_str(browser: &'a str) -> Self {
|
||||||
match browser.to_lowercase().as_str() {
|
match browser.to_lowercase().as_str() {
|
||||||
|
"auto" => Browser::Auto,
|
||||||
"default" => Browser::Default,
|
"default" => Browser::Default,
|
||||||
"chrome" => Browser::Chrome,
|
"chrome" => Browser::Chrome,
|
||||||
"firefox" => Browser::Firefox,
|
"firefox" => Browser::Firefox,
|
||||||
@@ -31,6 +33,7 @@ impl<'a> Browser<'a> {
|
|||||||
|
|
||||||
fn as_str(&self) -> &str {
|
fn as_str(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
|
Browser::Auto => "auto",
|
||||||
Browser::Default => "default",
|
Browser::Default => "default",
|
||||||
Browser::Chrome => "chrome",
|
Browser::Chrome => "chrome",
|
||||||
Browser::Firefox => "firefox",
|
Browser::Firefox => "firefox",
|
||||||
@@ -87,6 +90,15 @@ Note that the URL is only valid for a single use.
|
|||||||
info!("Launching the default browser...");
|
info!("Launching the default browser...");
|
||||||
webbrowser::open(&auth_url)?;
|
webbrowser::open(&auth_url)?;
|
||||||
}
|
}
|
||||||
|
Browser::Auto => {
|
||||||
|
if let Some(app) = find_auto_browser_path() {
|
||||||
|
info!("Launching browser: {}", app);
|
||||||
|
open::with_detached(&auth_url, app)?;
|
||||||
|
} else {
|
||||||
|
info!("No preferred browser found; launching the default browser...");
|
||||||
|
webbrowser::open(&auth_url)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let app = find_browser_path(&self.browser);
|
let app = find_browser_path(&self.browser);
|
||||||
|
|
||||||
@@ -124,19 +136,25 @@ async fn detect_local_ip() -> anyhow::Result<String> {
|
|||||||
|
|
||||||
fn find_browser_path(browser: &Browser) -> String {
|
fn find_browser_path(browser: &Browser) -> String {
|
||||||
match browser {
|
match browser {
|
||||||
Browser::Chrome => {
|
Browser::Chrome => find_chrome_path().unwrap_or_else(|| browser.as_str().to_string()),
|
||||||
const CHROME_VARIANTS: &[&str] = &["google-chrome-stable", "google-chrome", "chromium"];
|
|
||||||
|
|
||||||
CHROME_VARIANTS
|
|
||||||
.iter()
|
|
||||||
.find_map(|&browser_name| which::which(browser_name).ok())
|
|
||||||
.map(|path| path.to_string_lossy().to_string())
|
|
||||||
.unwrap_or_else(|| browser.as_str().to_string())
|
|
||||||
}
|
|
||||||
_ => browser.as_str().to_string(),
|
_ => browser.as_str().to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn find_auto_browser_path() -> Option<String> {
|
||||||
|
find_chrome_path().or_else(|| find_program_path("firefox"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn find_chrome_path() -> Option<String> {
|
||||||
|
["google-chrome-stable", "google-chrome", "chromium"]
|
||||||
|
.iter()
|
||||||
|
.find_map(|browser_name| find_program_path(browser_name))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn find_program_path(name: &str) -> Option<String> {
|
||||||
|
which::which(name).ok().map(|path| path.to_string_lossy().to_string())
|
||||||
|
}
|
||||||
|
|
||||||
async fn wait_auth_data() -> anyhow::Result<SamlAuthData> {
|
async fn wait_auth_data() -> anyhow::Result<SamlAuthData> {
|
||||||
// Start a local server to receive the browser authentication data
|
// Start a local server to receive the browser authentication data
|
||||||
let listener = TcpListener::bind("127.0.0.1:0").await?;
|
let listener = TcpListener::bind("127.0.0.1:0").await?;
|
||||||
@@ -176,3 +194,14 @@ fn read_auth_data_from_stdin() -> anyhow::Result<SamlAuthData> {
|
|||||||
let auth_data = SamlAuthData::from_gpcallback(data.trim())?;
|
let auth_data = SamlAuthData::from_gpcallback(data.trim())?;
|
||||||
Ok(auth_data)
|
Ok(auth_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn browser_auto_is_distinct_from_system_default() {
|
||||||
|
assert!(matches!(Browser::from_str("auto"), Browser::Auto));
|
||||||
|
assert!(matches!(Browser::from_str("default"), Browser::Default));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,41 +33,28 @@ mod platform {
|
|||||||
let session_env = collect(user_id);
|
let session_env = collect(user_id);
|
||||||
|
|
||||||
for key in DESKTOP_SESSION_ENV {
|
for key in DESKTOP_SESSION_ENV {
|
||||||
if let Some(value) = env_value(key).or_else(|| session_env.get(*key).cloned()) {
|
if let Some(value) = desktop_env_value(&session_env, key) {
|
||||||
command.env(key, value);
|
command.env(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let runtime_dir = env_value("XDG_RUNTIME_DIR")
|
let runtime_dir =
|
||||||
.or_else(|| session_env.get("XDG_RUNTIME_DIR").cloned())
|
desktop_env_value(&session_env, "XDG_RUNTIME_DIR").unwrap_or_else(|| format!("/run/user/{user_id}"));
|
||||||
.unwrap_or_else(|| format!("/run/user/{user_id}"));
|
|
||||||
command.env("XDG_RUNTIME_DIR", &runtime_dir);
|
command.env("XDG_RUNTIME_DIR", &runtime_dir);
|
||||||
|
|
||||||
if env_value("DBUS_SESSION_BUS_ADDRESS")
|
if desktop_env_value(&session_env, "DBUS_SESSION_BUS_ADDRESS").is_none() {
|
||||||
.or_else(|| session_env.get("DBUS_SESSION_BUS_ADDRESS").cloned())
|
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
command.env("DBUS_SESSION_BUS_ADDRESS", format!("unix:path={runtime_dir}/bus"));
|
command.env("DBUS_SESSION_BUS_ADDRESS", format!("unix:path={runtime_dir}/bus"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if env_value("XDG_DATA_HOME")
|
if desktop_env_value(&session_env, "XDG_DATA_HOME").is_none() {
|
||||||
.or_else(|| session_env.get("XDG_DATA_HOME").cloned())
|
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
command.env("XDG_DATA_HOME", home_dir.join(".local/share"));
|
command.env("XDG_DATA_HOME", home_dir.join(".local/share"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if env_value("XDG_CONFIG_HOME")
|
if desktop_env_value(&session_env, "XDG_CONFIG_HOME").is_none() {
|
||||||
.or_else(|| session_env.get("XDG_CONFIG_HOME").cloned())
|
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
command.env("XDG_CONFIG_HOME", home_dir.join(".config"));
|
command.env("XDG_CONFIG_HOME", home_dir.join(".config"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if env_value("XDG_DATA_DIRS")
|
if desktop_env_value(&session_env, "XDG_DATA_DIRS").is_none() {
|
||||||
.or_else(|| session_env.get("XDG_DATA_DIRS").cloned())
|
|
||||||
.is_none()
|
|
||||||
{
|
|
||||||
command.env("XDG_DATA_DIRS", default_xdg_data_dirs());
|
command.env("XDG_DATA_DIRS", default_xdg_data_dirs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,6 +147,10 @@ mod platform {
|
|||||||
non_empty(env::var(key).ok())
|
non_empty(env::var(key).ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn desktop_env_value(session_env: &HashMap<String, String>, key: &str) -> Option<String> {
|
||||||
|
session_env.get(key).cloned().or_else(|| env_value(key))
|
||||||
|
}
|
||||||
|
|
||||||
fn non_empty(value: Option<String>) -> Option<String> {
|
fn non_empty(value: Option<String>) -> Option<String> {
|
||||||
value.filter(|value| !value.trim().is_empty())
|
value.filter(|value| !value.trim().is_empty())
|
||||||
}
|
}
|
||||||
@@ -203,6 +194,16 @@ mod platform {
|
|||||||
assert_eq!(non_empty(Some(" ".to_string())), None);
|
assert_eq!(non_empty(Some(" ".to_string())), None);
|
||||||
assert_eq!(non_empty(Some("value".to_string())), Some("value".to_string()));
|
assert_eq!(non_empty(Some("value".to_string())), Some("value".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn desktop_env_value_prefers_collected_user_session() {
|
||||||
|
let env = HashMap::from([("XDG_DATA_DIRS".to_string(), "/run/current-system/sw/share".to_string())]);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
desktop_env_value(&env, "XDG_DATA_DIRS"),
|
||||||
|
Some("/run/current-system/sw/share".to_string())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
linuxRuntimeDependencies = with pkgs; [
|
linuxRuntimeDependencies = with pkgs; [
|
||||||
glib-networking
|
glib-networking
|
||||||
libappindicator-gtk3
|
libayatana-appindicator
|
||||||
];
|
];
|
||||||
|
|
||||||
linuxBuildInputs =
|
linuxBuildInputs =
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
glib-networking
|
glib-networking
|
||||||
openssl
|
openssl
|
||||||
libsecret
|
libsecret
|
||||||
libappindicator-gtk3
|
libayatana-appindicator
|
||||||
];
|
];
|
||||||
|
|
||||||
rewriteSourceInstallPaths = ''
|
rewriteSourceInstallPaths = ''
|
||||||
@@ -207,12 +207,18 @@
|
|||||||
name = binaryName;
|
name = binaryName;
|
||||||
targetPkgs =
|
targetPkgs =
|
||||||
pkgs:
|
pkgs:
|
||||||
[
|
[ prebuiltFiles ]
|
||||||
prebuiltFiles
|
|
||||||
]
|
|
||||||
++ linuxBuildInputs
|
++ linuxBuildInputs
|
||||||
++ linuxRuntimeDependencies;
|
++ linuxRuntimeDependencies;
|
||||||
runScript = "/usr/bin/${binaryName}";
|
runScript = "/usr/bin/${binaryName}";
|
||||||
|
profile = ''
|
||||||
|
export PATH=/run/wrappers/bin:$PATH
|
||||||
|
'';
|
||||||
|
extraBwrapArgs = [
|
||||||
|
"--bind-try"
|
||||||
|
"/run/wrappers"
|
||||||
|
"/run/wrappers"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
prebuiltCommands = {
|
prebuiltCommands = {
|
||||||
@@ -232,8 +238,83 @@
|
|||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
ln -s ${prebuiltCommands.gpclient}/bin/gpclient $out/bin/gpclient
|
cat > $out/bin/gpclient <<'EOF'
|
||||||
ln -s ${prebuiltCommands.gpservice}/bin/gpservice $out/bin/gpservice
|
#!${pkgs.runtimeShell}
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
gpclient_fhs='${prebuiltCommands.gpclient}/bin/gpclient'
|
||||||
|
gpservice_public='@gpservice_public@'
|
||||||
|
|
||||||
|
if [ "''${1:-}" = "launch-gui" ]; then
|
||||||
|
shift
|
||||||
|
|
||||||
|
auth_data=
|
||||||
|
minimized=
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--minimized)
|
||||||
|
minimized=--minimized
|
||||||
|
;;
|
||||||
|
--*)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
auth_data=$arg
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$auth_data" ]; then
|
||||||
|
if [ -n "''${XDG_DATA_HOME:-}" ]; then
|
||||||
|
data_home=$XDG_DATA_HOME
|
||||||
|
elif [ -n "''${HOME:-}" ]; then
|
||||||
|
data_home=$HOME/.local/share
|
||||||
|
else
|
||||||
|
data_home=/tmp
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_dir="$data_home/gpclient"
|
||||||
|
mkdir -p "$log_dir"
|
||||||
|
log_file="$log_dir/gpclient.log"
|
||||||
|
env_file=$(mktemp)
|
||||||
|
|
||||||
|
env > "$env_file"
|
||||||
|
printf 'GP_LOG_FILE=%s\n' "$log_file" >> "$env_file"
|
||||||
|
|
||||||
|
pkexec_bin=/run/wrappers/bin/pkexec
|
||||||
|
if [ ! -x "$pkexec_bin" ]; then
|
||||||
|
pkexec_bin=pkexec
|
||||||
|
fi
|
||||||
|
|
||||||
|
set +e
|
||||||
|
if [ -n "$minimized" ]; then
|
||||||
|
"$pkexec_bin" --user root "$gpservice_public" --minimized --env-file "$env_file" 2>"$log_file"
|
||||||
|
else
|
||||||
|
"$pkexec_bin" --user root "$gpservice_public" --env-file "$env_file" 2>"$log_file"
|
||||||
|
fi
|
||||||
|
status=$?
|
||||||
|
set -e
|
||||||
|
rm -f "$env_file"
|
||||||
|
exit "$status"
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -- launch-gui "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$gpclient_fhs" "$@"
|
||||||
|
EOF
|
||||||
|
substituteInPlace $out/bin/gpclient \
|
||||||
|
--replace-fail '@gpservice_public@' "$out/bin/gpservice"
|
||||||
|
chmod +x $out/bin/gpclient
|
||||||
|
|
||||||
|
cat > $out/bin/gpservice <<'EOF'
|
||||||
|
#!${pkgs.runtimeShell}
|
||||||
|
set -eu
|
||||||
|
exec '@gpservice_fhs@' "$@"
|
||||||
|
EOF
|
||||||
|
substituteInPlace $out/bin/gpservice \
|
||||||
|
--replace-fail '@gpservice_fhs@' '${prebuiltCommands.gpservice}/bin/gpservice'
|
||||||
|
chmod +x $out/bin/gpservice
|
||||||
|
|
||||||
ln -s ${prebuiltCommands.gpauth}/bin/gpauth $out/bin/gpauth
|
ln -s ${prebuiltCommands.gpauth}/bin/gpauth $out/bin/gpauth
|
||||||
ln -s ${prebuiltCommands.gpgui}/bin/gpgui $out/bin/gpgui
|
ln -s ${prebuiltCommands.gpgui}/bin/gpgui $out/bin/gpgui
|
||||||
ln -s ${prebuiltCommands."gpgui-helper"}/bin/gpgui-helper $out/bin/gpgui-helper
|
ln -s ${prebuiltCommands."gpgui-helper"}/bin/gpgui-helper $out/bin/gpgui-helper
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ REPO="yuezk/GlobalProtect-openconnect"
|
|||||||
TAG=${1:-}
|
TAG=${1:-}
|
||||||
|
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
||||||
|
|
||||||
RELEASE_NOTES="Release $TAG"
|
|
||||||
|
|
||||||
if [ -z "$TAG" ]; then
|
if [ -z "$TAG" ]; then
|
||||||
echo "Usage: ./scripts/gh-release.sh <tag>"
|
echo "Usage: ./scripts/gh-release.sh <tag>"
|
||||||
@@ -36,8 +33,6 @@ release_assets() {
|
|||||||
# For snapshot release, we don't create a release, just clear the existing assets and upload new ones.
|
# For snapshot release, we don't create a release, just clear the existing assets and upload new ones.
|
||||||
# This is to avoid notification spam.
|
# This is to avoid notification spam.
|
||||||
release_snapshot() {
|
release_snapshot() {
|
||||||
RELEASE_NOTES='**!!! DO NOT USE THIS RELEASE IN PRODUCTION !!!**'
|
|
||||||
|
|
||||||
while IFS= read -r asset; do
|
while IFS= read -r asset; do
|
||||||
if [ -n "$asset" ]; then
|
if [ -n "$asset" ]; then
|
||||||
gh -R "$REPO" release delete-asset "$TAG" "$asset" --yes
|
gh -R "$REPO" release delete-asset "$TAG" "$asset" --yes
|
||||||
@@ -55,11 +50,15 @@ release_tag() {
|
|||||||
gh -R "$REPO" release delete "$TAG" --yes --cleanup-tag || true
|
gh -R "$REPO" release delete "$TAG" --yes --cleanup-tag || true
|
||||||
|
|
||||||
echo "Creating release..."
|
echo "Creating release..."
|
||||||
|
local release_notes_file
|
||||||
|
release_notes_file="$(mktemp)"
|
||||||
|
"$SCRIPT_DIR/release-notes.sh" "$TAG" > "$release_notes_file"
|
||||||
|
|
||||||
# Upload source tarballs, GUI components, and BSD packages. Other Linux
|
# Upload source tarballs, GUI components, and BSD packages. Other Linux
|
||||||
# packages are built in `release.yml` from the standalone source tarball.
|
# packages are built in `release.yml` from the standalone source tarball.
|
||||||
gh -R "$REPO" release create "$TAG" \
|
gh -R "$REPO" release create "$TAG" \
|
||||||
--title "$TAG" \
|
--title "$TAG" \
|
||||||
--notes "$RELEASE_NOTES"
|
--notes-file "$release_notes_file"
|
||||||
|
|
||||||
mapfile -t files < <(release_assets)
|
mapfile -t files < <(release_assets)
|
||||||
upload_files "${files[@]}"
|
upload_files "${files[@]}"
|
||||||
|
|||||||
Executable
+33
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
release_version="${1:-}"
|
||||||
|
|
||||||
|
if git diff --quiet -- flake.nix; then
|
||||||
|
echo "flake.nix hashes are already up to date"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$release_version" ]]; then
|
||||||
|
release_version="$(grep '^version' Cargo.toml | head -1 | sed 's/version *= *"\(.*\)"/\1/')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
version="${release_version#v}"
|
||||||
|
branch="chore/update-flake-hashes-v${version}"
|
||||||
|
title="chore: update flake hashes for v${version}"
|
||||||
|
body="Updates the Nix flake fetchzip hashes for v${version} release assets."
|
||||||
|
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
|
git switch -C "$branch"
|
||||||
|
git add flake.nix
|
||||||
|
git commit -m "$title"
|
||||||
|
git push --force-with-lease origin "$branch"
|
||||||
|
|
||||||
|
if gh pr view "$branch" --json number > /tmp/flake-pr.json 2> /dev/null; then
|
||||||
|
pr_number="$(jq -r '.number' /tmp/flake-pr.json)"
|
||||||
|
gh pr edit "$pr_number" --title "$title" --body "$body"
|
||||||
|
else
|
||||||
|
gh pr create --title "$title" --body "$body" --base main --head "$branch"
|
||||||
|
fi
|
||||||
Executable
+30
@@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
tag="${1:-}"
|
||||||
|
|
||||||
|
if [[ -z "$tag" ]]; then
|
||||||
|
echo "Usage: $0 <tag>" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
version="${tag#v}"
|
||||||
|
|
||||||
|
awk -v version="$version" '
|
||||||
|
$0 == "## " version {
|
||||||
|
found = 1
|
||||||
|
next
|
||||||
|
}
|
||||||
|
found && /^## / {
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
found {
|
||||||
|
print
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
if (!found) {
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
' changelog.md
|
||||||
Reference in new issue
Block a user