feat: prepare 3.0.0 release

This commit is contained in:
Kevin Yue committed 2026-10-09 18:21:44 +08:00
1 parent e98fd7894a
commit b7b708e9cd
252 files changed
+26210 -7457

No files matched your search

+79 -1
View File
@@ -3,6 +3,15 @@ use std::{
path::{Path, PathBuf},
};
#[cfg(all(
not(debug_assertions),
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")
))]
use crate::constants::GP_DOWNLOADED_GUI_BINARY;
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
use crate::constants::GP_HIP_SCRIPT_INSTALLER_BINARY;
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
use crate::constants::GP_VPNC_SCRIPT_INSTALLER_BINARY;
use crate::constants::{GP_AUTH_BINARY, GP_CLIENT_BINARY, GP_GUI_BINARY, GP_GUI_HELPER_BINARY, GP_SERVICE_BINARY};
pub fn gpclient() -> PathBuf {
@@ -13,6 +22,24 @@ pub fn gpservice() -> PathBuf {
resolve("GP_SERVICE_BINARY", "gpservice", GP_SERVICE_BINARY)
}
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
pub fn gp_vpnc_script_installer() -> PathBuf {
resolve(
"GP_VPNC_SCRIPT_INSTALLER_BINARY",
"gp-vpnc-script-installer",
GP_VPNC_SCRIPT_INSTALLER_BINARY,
)
}
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))]
pub fn gp_hip_script_installer() -> PathBuf {
resolve(
"GP_HIP_SCRIPT_INSTALLER_BINARY",
"gp-hip-script-installer",
GP_HIP_SCRIPT_INSTALLER_BINARY,
)
}
pub fn gpauth() -> PathBuf {
resolve("GP_AUTH_BINARY", "gpauth", GP_AUTH_BINARY)
}
@@ -21,6 +48,24 @@ pub fn gpgui() -> PathBuf {
resolve("GP_GUI_BINARY", "gpgui", GP_GUI_BINARY)
}
pub fn gpgui_update_target() -> PathBuf {
#[cfg(all(
not(debug_assertions),
any(target_os = "linux", target_os = "freebsd", target_os = "openbsd")
))]
{
PathBuf::from(GP_DOWNLOADED_GUI_BINARY)
}
#[cfg(any(
debug_assertions,
not(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))
))]
{
gpgui()
}
}
pub fn gpgui_helper() -> PathBuf {
resolve("GP_GUI_HELPER_BINARY", "gpgui-helper", GP_GUI_HELPER_BINARY)
}
@@ -37,8 +82,27 @@ fn sibling_binary(binary_name: &str) -> Option<PathBuf> {
let current_exe = env::current_exe().ok()?;
let bin_dir = current_exe.parent()?;
let binary = bin_dir.join(binary_name);
if is_file(&binary) {
return Some(binary);
}
#[cfg(target_os = "macos")]
if let Some(binary) = bundled_helper_path(&current_exe, binary_name)
&& is_file(&binary)
{
return Some(binary);
}
None
}
is_file(&binary).then_some(binary)
#[cfg(target_os = "macos")]
fn bundled_helper_path(executable: &Path, binary_name: &str) -> Option<PathBuf> {
let bin_dir = executable.parent()?;
let contents = bin_dir.parent()?;
let bundle = contents.parent()?;
if bin_dir.file_name()? != "MacOS" || contents.file_name()? != "Contents" || bundle.extension()? != "app" {
return None;
}
Some(contents.join("Helpers").join(binary_name))
}
fn is_file(path: &Path) -> bool {
@@ -49,6 +113,20 @@ fn is_file(path: &Path) -> bool {
mod tests {
use super::*;
#[test]
#[cfg(target_os = "macos")]
fn desktop_resolves_helpers_in_the_actual_app_bundle_layout() {
assert_eq!(
bundled_helper_path(
Path::new("/Applications/GP Connect.app/Contents/MacOS/gpgui"),
"gpclient"
),
Some(PathBuf::from("/Applications/GP Connect.app/Contents/Helpers/gpclient"))
);
assert!(bundled_helper_path(Path::new("/usr/local/bin/gpgui"), "gpclient").is_none());
assert!(bundled_helper_path(Path::new("/tmp/Contents/MacOS/gpgui"), "gpclient").is_none());
}
#[test]
fn default_path_is_used_when_no_sibling_exists() {
let path = resolve("GP_TEST_BINARY", "missing-gp-test-binary", "/usr/bin/gp-test");
+22 -1
View File
@@ -3,7 +3,24 @@ pub const GP_CLIENT_VERSION_LINUX: &str = "6.3.3-619";
pub const GP_CLIENT_VERSION_WINDOWS: &str = "6.3.3-650";
pub const GP_CLIENT_VERSION_MACOS: &str = "6.3.3-915";
pub const GP_SERVICE_LOCK_FILE: &str = "/var/run/gpservice.lock";
pub const GP_CALLBACK_PORT_FILENAME: &str = "gpcallback.port";
#[cfg(target_os = "linux")]
pub const GP_VPNC_SCRIPT_INSTALLER_BINARY: &str = "/usr/libexec/gpclient/gp-vpnc-script-installer";
#[cfg(target_os = "linux")]
pub const GP_HIP_SCRIPT_INSTALLER_BINARY: &str = "/usr/libexec/gpclient/gp-hip-script-installer";
#[cfg(any(target_os = "freebsd", target_os = "openbsd"))]
pub const GP_HIP_SCRIPT_INSTALLER_BINARY: &str = "/usr/local/libexec/gpclient/gp-hip-script-installer";
#[cfg(target_os = "linux")]
pub const INSTALLED_VPNC_SCRIPT: &str = "/var/lib/gpclient/scripts/vpnc-script";
#[cfg(target_os = "linux")]
pub const INSTALLED_VPNC_SCRIPT_METADATA: &str = "/var/lib/gpclient/scripts/vpnc-script.metadata";
#[cfg(any(target_os = "freebsd", target_os = "openbsd"))]
pub const GP_VPNC_SCRIPT_INSTALLER_BINARY: &str = "/usr/local/libexec/gpclient/gp-vpnc-script-installer";
#[cfg(any(target_os = "freebsd", target_os = "openbsd"))]
pub const INSTALLED_VPNC_SCRIPT: &str = "/var/db/gpclient/scripts/vpnc-script";
#[cfg(any(target_os = "freebsd", target_os = "openbsd"))]
pub const INSTALLED_VPNC_SCRIPT_METADATA: &str = "/var/db/gpclient/scripts/vpnc-script.metadata";
pub const MAX_VPNC_SCRIPT_SIZE: usize = 1024 * 1024;
pub const MAX_HIP_SCRIPT_SIZE: usize = 1024 * 1024;
// Release binaries - macOS (Apple Silicon Homebrew)
#[cfg(all(not(debug_assertions), target_os = "macos", target_arch = "aarch64"))]
@@ -36,6 +53,8 @@ pub const GP_CLIENT_BINARY: &str = "/usr/local/bin/gpclient";
pub const GP_SERVICE_BINARY: &str = "/usr/local/bin/gpservice";
#[cfg(all(not(debug_assertions), any(target_os = "freebsd", target_os = "openbsd")))]
pub const GP_GUI_BINARY: &str = "/usr/local/bin/gpgui";
#[cfg(any(target_os = "freebsd", target_os = "openbsd"))]
pub const GP_DOWNLOADED_GUI_BINARY: &str = "/usr/local/libexec/gpclient/gpgui";
#[cfg(all(not(debug_assertions), any(target_os = "freebsd", target_os = "openbsd")))]
pub const GP_GUI_HELPER_BINARY: &str = "/usr/local/bin/gpgui-helper";
#[cfg(all(not(debug_assertions), any(target_os = "freebsd", target_os = "openbsd")))]
@@ -57,6 +76,8 @@ pub const GP_SERVICE_BINARY: &str = "/usr/bin/gpservice";
not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd"))
))]
pub const GP_GUI_BINARY: &str = "/usr/bin/gpgui";
#[cfg(target_os = "linux")]
pub const GP_DOWNLOADED_GUI_BINARY: &str = "/var/lib/gpclient/gpgui";
#[cfg(all(
not(debug_assertions),
not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd"))