From 08b7e036b4831c01bcefe62b26c686ac2fe9573f Mon Sep 17 00:00:00 2001 From: rustdesk Date: Wed, 1 May 2024 12:58:27 +0800 Subject: [PATCH] test vcpkg new in android --- .github/workflows/build-macos-arm64.yml | 22 ++++----- libs/scrap/src/wayland/pipewire.rs | 5 +- src/platform/linux.rs | 61 +++++++++++++++---------- 3 files changed, 50 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build-macos-arm64.yml b/.github/workflows/build-macos-arm64.yml index 508d8969b..69e2dfc39 100644 --- a/.github/workflows/build-macos-arm64.yml +++ b/.github/workflows/build-macos-arm64.yml @@ -10,26 +10,24 @@ env: RUST_VERSION: "1.75" # https://github.com/rustdesk/rustdesk/discussions/7503 CARGO_NDK_VERSION: "3.1.2" LLVM_VERSION: "15.0.6" - FLUTTER_VERSION: "3.16.9" + FLUTTER_VERSION: "3.19.6" FLUTTER_RUST_BRIDGE_VERSION: "1.80.1" # for arm64 linux because official Dart SDK does not work FLUTTER_ELINUX_VERSION: "3.16.9" - FLUTTER_ELINUX_COMMIT_ID: "c02bd16e1630f5bd690b85c5c2456ac1920e25af" - TAG_NAME: "nightly" + TAG_NAME: "${{ inputs.upload-tag }}" VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" - # vcpkg version: 2023.10.19 - # for multiarch gcc compatibility - VCPKG_COMMIT_ID: "8eb57355a4ffb410a2e94c07b4dca2dffbee8e50" + # vcpkg version: 2024.03.25 + VCPKG_COMMIT_ID: "a34c873a9717a888f58dc05268dea15592c2f0ff" VERSION: "1.2.4" NDK_VERSION: "r26b" #signing keys env variable checks - ANDROID_SIGNING_KEY: '${{ secrets.ANDROID_SIGNING_KEY }}' - MACOS_P12_BASE64: '${{ secrets.MACOS_P12_BASE64 }}' + ANDROID_SIGNING_KEY: "${{ secrets.ANDROID_SIGNING_KEY }}" + MACOS_P12_BASE64: "${{ secrets.MACOS_P12_BASE64 }}" # To make a custom build with your own servers set the below secret values - RS_PUB_KEY: '${{ secrets.RS_PUB_KEY }}' - RENDEZVOUS_SERVER: '${{ secrets.RENDEZVOUS_SERVER }}' - API_SERVER: '${{ secrets.API_SERVER }}' - UPLOAD_ARTIFACT: true + RS_PUB_KEY: "${{ secrets.RS_PUB_KEY }}" + RENDEZVOUS_SERVER: "${{ secrets.RENDEZVOUS_SERVER }}" + API_SERVER: "${{ secrets.API_SERVER }}" + UPLOAD_ARTIFACT: "${{ inputs.upload-artifact }}" SIGN_BASE_URL: "${{ secrets.SIGN_BASE_URL }}" jobs: diff --git a/libs/scrap/src/wayland/pipewire.rs b/libs/scrap/src/wayland/pipewire.rs index 88c556557..ff86e6e6e 100644 --- a/libs/scrap/src/wayland/pipewire.rs +++ b/libs/scrap/src/wayland/pipewire.rs @@ -778,9 +778,10 @@ pub fn get_capturables() -> Result, Box> { } fn is_server_running() -> bool { + let app_name = config::APP_NAME.read().unwrap().clone().to_lowercase(); let output = match Command::new("sh") .arg("-c") - .arg("ps aux | grep rustdesk") + .arg(&format!("ps aux | grep {}", app_name)) .output() { Ok(output) => output, @@ -790,6 +791,6 @@ fn is_server_running() -> bool { }; let output_str = String::from_utf8_lossy(&output.stdout); - let is_running = output_str.contains("rustdesk --server"); + let is_running = output_str.contains(&format!("{} --server", app_name)); is_running } diff --git a/src/platform/linux.rs b/src/platform/linux.rs index aac7033da..67be40269 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -326,17 +326,20 @@ fn set_x11_env(desktop: &Desktop) { #[inline] fn stop_rustdesk_servers() { let _ = run_cmds(&format!( - r##"ps -ef | grep -E 'rustdesk +--server' | awk '{{printf("kill -9 %d\n", $2)}}' | bash"##, + r##"ps -ef | grep -E '{} +--server' | awk '{{printf("kill -9 %d\n", $2)}}' | bash"##, + crate::get_app_name().to_lowercase(), )); } #[inline] fn stop_subprocess() { let _ = run_cmds(&format!( - r##"ps -ef | grep '/etc/rustdesk/xorg.conf' | grep -v grep | awk '{{printf("kill -9 %d\n", $2)}}' | bash"##, + r##"ps -ef | grep '/etc/{}/xorg.conf' | grep -v grep | awk '{{printf("kill -9 %d\n", $2)}}' | bash"##, + crate::get_app_name().to_lowercase(), )); let _ = run_cmds(&format!( - r##"ps -ef | grep -E 'rustdesk +--cm-no-ui' | grep -v grep | awk '{{printf("kill -9 %d\n", $2)}}' | bash"##, + r##"ps -ef | grep -E '{} +--cm-no-ui' | grep -v grep | awk '{{printf("kill -9 %d\n", $2)}}' | bash"##, + crate::get_app_name().to_lowercase(), )); } @@ -771,10 +774,13 @@ pub fn exec_privileged(args: &[&str]) -> ResultType { } pub fn check_super_user_permission() -> ResultType { - let file = "/usr/share/rustdesk/files/polkit"; + let file = format!( + "/usr/share/{}/files/polkit", + crate::get_app_name().to_lowercase() + ); let arg; - if Path::new(file).is_file() { - arg = file; + if Path::new(&file).is_file() { + arg = &file; } else { arg = "echo"; } @@ -988,7 +994,6 @@ mod desktop { const IBUS_DAEMON: &str = "ibus-daemon"; const PLASMA_KDED: &str = "kded[0-9]+"; const GNOME_GOA_DAEMON: &str = "goa-daemon"; - const RUSTDESK_TRAY: &str = "rustdesk +--tray"; #[derive(Debug, Clone, Default)] pub struct Desktop { @@ -1020,14 +1025,10 @@ mod desktop { } fn get_display_xauth_xwayland(&mut self) { + let tray = format!("{} +--tray", crate::get_app_name().to_lowercase()); for _ in 0..5 { - let display_proc = vec![ - XWAYLAND, - IBUS_DAEMON, - GNOME_GOA_DAEMON, - PLASMA_KDED, - RUSTDESK_TRAY, - ]; + let display_proc = + vec![XWAYLAND, IBUS_DAEMON, GNOME_GOA_DAEMON, PLASMA_KDED, &tray]; for proc in display_proc { self.display = get_env("DISPLAY", &self.uid, proc); self.xauth = get_env("XAUTHORITY", &self.uid, proc); @@ -1124,6 +1125,7 @@ mod desktop { fn get_xauth_x11(&mut self) { // try by direct access to window manager process by name + let tray = format!("{} +--tray", crate::get_app_name().to_lowercase()); for _ in 0..10 { let display_proc = vec![ XWAYLAND, @@ -1132,7 +1134,7 @@ mod desktop { PLASMA_KDED, XFCE4_PANEL, SDDM_GREETER, - RUSTDESK_TRAY, + &tray, ]; for proc in display_proc { self.xauth = get_env("XAUTHORITY", &self.uid, proc); @@ -1217,8 +1219,11 @@ mod desktop { fn set_is_subprocess(&mut self) { self.is_rustdesk_subprocess = false; - let cmd = "ps -ef | grep 'rustdesk/xorg.conf' | grep -v grep | wc -l"; - if let Ok(res) = run_cmds(cmd) { + let cmd = format!( + "ps -ef | grep '{}/xorg.conf' | grep -v grep | wc -l", + crate::get_app_name().to_lowercase() + ); + if let Ok(res) = run_cmds(&cmd) { if res.trim() != "0" { self.is_rustdesk_subprocess = true; } @@ -1350,7 +1355,9 @@ fn switch_service(stop: bool) -> String { let home = std::env::var("HOME").unwrap_or_default(); Config::set_option("stop-service".into(), if stop { "Y" } else { "" }.into()); if home != "/root" && !Config::get().is_empty() { - format!("cp -f {home}/.config/rustdesk/RustDesk.toml /root/.config/rustdesk/; cp -f {home}/.config/rustdesk/RustDesk2.toml /root/.config/rustdesk/;") + let app_name0 = crate::get_app_name().to_lowercase(); + let app_name = crate::get_app_name(); + format!("cp -f {home}/.config/{app_name}/{app_name0}.toml /root/.config/{app_name}/; cp -f {home}/.config/{app_name}/{app_name0}2.toml /root/.config/{app_name}/;") } else { "".to_owned() } @@ -1362,8 +1369,9 @@ pub fn uninstall_service(show_new_window: bool, _: bool) -> bool { } log::info!("Uninstalling service..."); let cp = switch_service(true); + let app_name = crate::get_app_name().to_lowercase(); if !run_cmds_pkexec(&format!( - "systemctl disable rustdesk; systemctl stop rustdesk; {cp}" + "systemctl disable {app_name}; systemctl stop {app_name}; {cp}" )) { Config::set_option("stop-service".into(), "".into()); return true; @@ -1381,8 +1389,9 @@ pub fn install_service() -> bool { } log::info!("Installing service..."); let cp = switch_service(false); + let app_name = crate::get_app_name().to_lowercase(); if !run_cmds_pkexec(&format!( - "{cp} systemctl enable rustdesk; systemctl start rustdesk;" + "{cp} systemctl enable {app_name}; systemctl start {app_name};" )) { Config::set_option("stop-service".into(), "Y".into()); return true; @@ -1393,27 +1402,31 @@ pub fn install_service() -> bool { fn check_if_stop_service() { if Config::get_option("stop-service".into()) == "Y" { + let app_name = crate::get_app_name().to_lowercase(); allow_err!(run_cmds( - "systemctl disable rustdesk; systemctl stop rustdesk" + "systemctl disable {app_name}; systemctl stop {app_name}" )); } } pub fn check_autostart_config() -> ResultType<()> { let home = std::env::var("HOME").unwrap_or_default(); + let app_name = crate::get_app_name().to_lowercase(); let path = format!("{home}/.config/autostart"); - let file = format!("{path}/rustdesk.desktop"); + let file = format!("{path}/{app_name}.desktop"); std::fs::create_dir_all(&path).ok(); if !Path::new(&file).exists() { // write text to the desktop file let mut file = std::fs::File::create(&file)?; file.write_all( - " + format!( + " [Desktop Entry] Type=Application -Exec=rustdesk --tray +Exec={app_name} --tray NoDisplay=false " + ) .as_bytes(), )?; }