From 565174ffb91d5d26e629e2352555d317ac717eba Mon Sep 17 00:00:00 2001 From: innocentzero Date: Tue, 19 Nov 2024 06:47:04 +0530 Subject: [PATCH 1/2] feat: Add remote ref option to flatpak Signed-off-by: innocentzero --- src/backends/flatpak.rs | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/backends/flatpak.rs b/src/backends/flatpak.rs index 64ea542..7a71bb4 100644 --- a/src/backends/flatpak.rs +++ b/src/backends/flatpak.rs @@ -16,7 +16,9 @@ pub struct FlatpakQueryInfo { } #[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] -pub struct FlatpakInstallOptions {} +pub struct FlatpakInstallOptions { + pub remote: String, +} impl Backend for Flatpak { type QueryInfo = FlatpakQueryInfo; @@ -138,7 +140,35 @@ impl Backend for Flatpak { no_confirm: bool, config: &Config, ) -> Result<()> { - if !packages.is_empty() { + let mut no_remotes = Vec::new(); + let mut remote_packages = BTreeMap::new(); + for (package, remote) in packages { + if remote.remote.is_empty() { + no_remotes.push(package); + } else { + remote_packages.insert(package, remote); + } + } + + if !no_remotes.is_empty() { + run_command( + [ + "flatpak", + "install", + if config.flatpak_systemwide { + "--system" + } else { + "--user" + }, + ] + .into_iter() + .chain(Some("--assumeyes").filter(|_| no_confirm)) + .chain(no_remotes.into_iter().map(String::as_str)), + Perms::Same, + )?; + } + + for (package, remote) in remote_packages { run_command( [ "flatpak", @@ -151,7 +181,8 @@ impl Backend for Flatpak { ] .into_iter() .chain(Some("--assumeyes").filter(|_| no_confirm)) - .chain(packages.keys().map(String::as_str)), + .chain([remote.remote.as_str()]) + .chain([package.as_str()]), Perms::Same, )?; } From c5436e4106c0cc494b6972854fb06b9f0ac956cf Mon Sep 17 00:00:00 2001 From: innocentzero Date: Tue, 19 Nov 2024 06:55:27 +0530 Subject: [PATCH 2/2] Update README Signed-off-by: innocentzero --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b9867cb..66b96ec 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,7 @@ dnf = [ ] flatpak = [ "metapac", - { package = "metapac" } + { package = "metapac", remote = "flathub" } ] pipx = [ "metapac",