Skip to content

Commit

Permalink
feat: Add remote ref option to flatpak
Browse files Browse the repository at this point in the history
Signed-off-by: innocentzero <[email protected]>
  • Loading branch information
InnocentZero committed Nov 19, 2024
1 parent 6c1b844 commit 565174f
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions src/backends/flatpak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand All @@ -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,
)?;
}
Expand Down

0 comments on commit 565174f

Please sign in to comment.