Skip to content

Commit

Permalink
fix: add warning when arch packages are not found
Browse files Browse the repository at this point in the history
  • Loading branch information
ripytide committed Nov 19, 2024
1 parent 6c1b844 commit 85308a9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 13 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ walkdir = "2.5.0"
toml_edit = "0.22.22"
tempfile = "3.14.0"
strum = {version = "0.26.3", features = ["derive"]}
indoc = "2.0.5"

[dev-dependencies]
assert_cmd = "2.0.16"
Expand Down
64 changes: 51 additions & 13 deletions src/backends/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,67 @@ impl Backend for Arch {
}
}

let mut final_packages = BTreeMap::new();
let mut packages = {
let mut final_packages = BTreeMap::new();

for (main_package, opts) in packages {
let overridden = final_packages
.insert(main_package.clone(), Self::InstallOptions::default())
.is_some();

if overridden {
log::warn!("Package {main_package} overwrote another entry");
}

for package in opts.optional_deps.iter() {
for (package, install_options) in packages {
let overridden = final_packages
.insert(package.clone(), Self::InstallOptions::default())
.is_some();

if overridden {
log::warn!("Dependency {package} of {main_package} overwrote another entry");
log::warn!("Package {package} overwrote another entry");
}

for dependency in install_options.optional_deps.iter() {
let overridden = final_packages
.insert(dependency.clone(), Self::InstallOptions::default())
.is_some();

if overridden {
log::warn!("arch package {dependency} has been overridden by a dependency of the {package} package");
}
}
}

final_packages
};

let packages_cloned = packages.keys().cloned().collect::<Vec<_>>();

for package in packages_cloned {
let is_real_package = run_command(
[
config.arch_package_manager.as_command(),
"--sync",
"--info",
&package,
],
Perms::Same,
)
.is_ok();

if !is_real_package {
packages.remove(&package);

log::warn!(
"{}",
indoc::formatdoc! {"
arch package {package} was not found as an available package and so was ignored, it may be due to one of the following issues:
- the package name has a typo as written in your group files
- the package is a virtual package (https://wiki.archlinux.org/title/Pacman#Virtual_packages)
and so is ambiguous. You can run `pacman -S {package}` to list non-virtual packages which
which supply the virtual package
- the package was removed from the repositories
- the package was renamed to a different name
- the local package database is out of date and so doesn't yet contain the package:
update it with `sudo pacman -Sy`
"}
);
}
}

Ok(final_packages)
Ok(packages)
}

fn query_installed_packages(config: &Config) -> Result<BTreeMap<String, Self::QueryInfo>> {
Expand Down

0 comments on commit 85308a9

Please sign in to comment.