diff --git a/Cargo.toml b/Cargo.toml index 4fd6047..6e2c0aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/ripytide/metapac" readme = "README.md" keywords = ["package-manager", "linux", "declarative", "cli"] categories = ["command-line-utilities"] -authors = ["James Forster "] +authors = ["James Forster ", "Md Isfarul Haque >(); + )?; + let sys_explicit = sys_explicit_out + .lines() + .map(|x| (x.trim().to_owned(), FlatpakQueryInfo { systemwide: true })); - let user_explicit_btree = run_command_for_stdout( + let user_explicit_out = run_command_for_stdout( [ "flatpak", "list", @@ -56,19 +57,74 @@ impl Backend for Flatpak { "--columns=application", ], Perms::Same, - )? - .lines() - .map(String::from) - .collect::>(); + )?; + let user_explicit = user_explicit_out + .lines() + .map(|x| (x.trim().to_owned(), FlatpakQueryInfo { systemwide: false })); - let sys_explicit = sys_explicit_btree - .iter() - .map(|x| (x.clone(), FlatpakQueryInfo { systemwide: true })); - let user_explicit = user_explicit_btree - .iter() - .map(|x| (x.clone(), FlatpakQueryInfo { systemwide: false })); - - let all = sys_explicit.chain(user_explicit).collect(); + let sys_explicit_runtimes_installed = run_command_for_stdout( + [ + "flatpak", + "list", + "--system", + "--runtime", + "--columns=application", + ], + Perms::Same, + )?; + let sys_explicit_runtimes_out = + run_command_for_stdout(["flatpak", "pin", "--system"], Perms::Same)?; + let sys_explicit_runtimes = sys_explicit_runtimes_out + .lines() + .skip(1) + .map(|x| { + ( + x.trim().split('/').nth(1).unwrap().to_owned(), + FlatpakQueryInfo { systemwide: true }, + ) + }) + .filter(|(runtime, _)| { + sys_explicit_runtimes_installed + .lines() + .skip(1) + .map(|x| x.trim()) + .contains(&runtime.as_str()) + }); + + let user_explicit_runtimes_installed = run_command_for_stdout( + [ + "flatpak", + "list", + "--user", + "--runtime", + "--columns=application", + ], + Perms::Same, + )?; + let user_explicit_runtimes_out = + run_command_for_stdout(["flatpak", "pin", "--user"], Perms::Same)?; + let user_explicit_runtimes = user_explicit_runtimes_out + .lines() + .skip(1) + .map(|x| { + ( + x.trim().split('/').nth(1).unwrap().to_owned(), + FlatpakQueryInfo { systemwide: false }, + ) + }) + .filter(|(runtime, _)| { + user_explicit_runtimes_installed + .lines() + .skip(1) + .map(|x| x.trim()) + .contains(&runtime.as_str()) + }); + + let all = sys_explicit + .chain(user_explicit) + .chain(sys_explicit_runtimes) + .chain(user_explicit_runtimes) + .collect(); Ok(all) } @@ -92,7 +148,7 @@ impl Backend for Flatpak { .into_iter() .chain(Some("--assumeyes").filter(|_| no_confirm)) .chain(packages.keys().map(String::as_str)), - Perms::Sudo, + Perms::Same, )?; }