From 453ad231c8aa8dfae1edfb6f5892de01dff41ded Mon Sep 17 00:00:00 2001 From: Gabriele Musco Date: Fri, 23 Jun 2023 19:51:17 +0200 Subject: [PATCH] feat: skip setcap if pkexec isn't found --- src/dependencies/mod.rs | 1 + src/dependencies/pkexec_dep.rs | 9 +++++++++ src/ui/app.rs | 25 ++++++++++++++++--------- 3 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 src/dependencies/pkexec_dep.rs diff --git a/src/dependencies/mod.rs b/src/dependencies/mod.rs index f4b219f..5a364e1 100644 --- a/src/dependencies/mod.rs +++ b/src/dependencies/mod.rs @@ -3,3 +3,4 @@ pub mod libsurvive_deps; pub mod basalt_deps; pub mod wivrn_deps; pub mod adb_dep; +pub mod pkexec_dep; diff --git a/src/dependencies/pkexec_dep.rs b/src/dependencies/pkexec_dep.rs new file mode 100644 index 0000000..f227e69 --- /dev/null +++ b/src/dependencies/pkexec_dep.rs @@ -0,0 +1,9 @@ +use crate::depcheck::{DepType, Dependency}; + +pub fn pkexec_dep() -> Dependency { + Dependency { + name: "pkexec".into(), + dep_type: DepType::Executable, + filename: "pkexec".into(), + } +} diff --git a/src/ui/app.rs b/src/ui/app.rs index d8498ba..5f25d9f 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -10,9 +10,11 @@ use crate::builders::build_opencomposite::get_build_opencomposite_runner; use crate::builders::build_wivrn::get_build_wivrn_runner; use crate::config::Config; use crate::constants::APP_NAME; +use crate::depcheck::check_dependency; use crate::dependencies::basalt_deps::get_missing_basalt_deps; use crate::dependencies::libsurvive_deps::get_missing_libsurvive_deps; use crate::dependencies::monado_deps::get_missing_monado_deps; +use crate::dependencies::pkexec_dep::pkexec_dep; use crate::dependencies::wivrn_deps::get_missing_wivrn_deps; use crate::file_utils::setcap_cap_sys_nice_eip; use crate::profile::{Profile, XRServiceType}; @@ -306,15 +308,20 @@ impl SimpleComponent for App { self.build_pipeline = Some(pipeline); } Msg::RunSetCap => { - let profile = self.get_selected_profile(); - setcap_cap_sys_nice_eip(match profile.xrservice_type { - XRServiceType::Monado => { - format!("{pfx}/bin/monado-service", pfx = profile.prefix) - } - XRServiceType::Wivrn => { - format!("{pfx}/bin/wivrn-serer", pfx = profile.prefix) - } - }); + if !check_dependency(pkexec_dep()) { + println!("pkexec not found, skipping setcap"); + } + else { + let profile = self.get_selected_profile(); + setcap_cap_sys_nice_eip(match profile.xrservice_type { + XRServiceType::Monado => { + format!("{pfx}/bin/monado-service", pfx = profile.prefix) + } + XRServiceType::Wivrn => { + format!("{pfx}/bin/wivrn-serer", pfx = profile.prefix) + } + }); + } } Msg::ProfileSelected(prof_name) => { if prof_name == self.config.selected_profile_name {