From 6f10c789eb1925dae3eb2430dd26098c73a39726 Mon Sep 17 00:00:00 2001 From: teackot Date: Tue, 16 May 2023 18:32:29 +0300 Subject: [PATCH] Add flatpak_systemwide option --- crates/pacdef_core/src/backend/actual/flatpak.rs | 2 ++ crates/pacdef_core/src/config.rs | 3 +++ crates/pacdef_core/src/core.rs | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/crates/pacdef_core/src/backend/actual/flatpak.rs b/crates/pacdef_core/src/backend/actual/flatpak.rs index 8235e1a..100f595 100644 --- a/crates/pacdef_core/src/backend/actual/flatpak.rs +++ b/crates/pacdef_core/src/backend/actual/flatpak.rs @@ -10,6 +10,7 @@ use crate::{impl_backend_constants, Group, Package}; #[derive(Debug, Clone)] pub struct Flatpak { pub(crate) packages: HashSet, + pub(crate) systemwide: bool, } const BINARY: Text = "flatpak"; @@ -43,6 +44,7 @@ impl Flatpak { pub(crate) fn new() -> Self { Self { packages: HashSet::new(), + systemwide: true, } } diff --git a/crates/pacdef_core/src/config.rs b/crates/pacdef_core/src/config.rs index e0e39f8..d791425 100644 --- a/crates/pacdef_core/src/config.rs +++ b/crates/pacdef_core/src/config.rs @@ -13,6 +13,8 @@ pub struct Config { pub aur_helper: String, /// Additional arguments to pass to `aur_helper` when removing a package. pub aur_rm_args: Option>, + /// Install Flatpak packages system-wide + pub flatpak_systemwide: bool, /// Warn the user when a group is not a symlink. pub warn_not_symlinks: bool, /// Backends the user does not want to use even though the binary exists. @@ -68,6 +70,7 @@ impl Default for Config { Self { aur_helper: "paru".into(), aur_rm_args: None, + flatpak_systemwide: true, warn_not_symlinks: true, disabled_backends: vec![], } diff --git a/crates/pacdef_core/src/core.rs b/crates/pacdef_core/src/core.rs index 7a1cb67..dcda504 100644 --- a/crates/pacdef_core/src/core.rs +++ b/crates/pacdef_core/src/core.rs @@ -128,6 +128,13 @@ impl Pacdef { arch.aur_rm_args = self.config.aur_rm_args.take(); } } + + #[cfg(feature = "flatpak")] + { + if let Some(flatpak) = backend.as_any_mut().downcast_mut::() { + flatpak.systemwide = self.config.flatpak_systemwide; + } + } } fn install_packages(&mut self, args: &ArgMatches) -> Result<()> {