Skip to content

Commit

Permalink
Take repo package conflicts into account
Browse files Browse the repository at this point in the history
Fixes #1278
  • Loading branch information
Morganamilo committed Dec 27, 2024
1 parent 1003495 commit 5472d2f
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,14 @@ impl Installer {
}

let conflicts = check_actions(config, actions, !config.chroot || self.install_targets)?;

self.conflicts = conflicts
.0
.iter()
.map(|c| c.pkg.clone())
.chain(conflicts.1.iter().map(|c| c.pkg.clone()))
.collect::<HashSet<_>>();

let c = config.color;

print_warnings(config, cache, Some(actions));
Expand Down Expand Up @@ -1110,7 +1118,7 @@ impl Installer {

if actions.build.is_empty() {
if !config.chroot {
repo_install(config, &actions.install)?;
repo_install(config, &actions.install, &self.conflicts)?;
}
return Ok(());
}
Expand Down Expand Up @@ -1193,15 +1201,8 @@ impl Installer {
check_pgp_keys(config, actions, &self.srcinfos)?;
}

self.conflicts = conflicts
.0
.iter()
.map(|c| c.pkg.clone())
.chain(conflicts.1.iter().map(|c| c.pkg.clone()))
.collect::<HashSet<_>>();

if !config.chroot {
repo_install(config, &actions.install)?;
repo_install(config, &actions.install, &self.conflicts)?;
} else {
return Ok(());
}
Expand Down Expand Up @@ -1367,10 +1368,6 @@ fn check_actions(
);
}

if actions.build.is_empty() {
return Ok((Vec::new(), Vec::new()));
}

let conflicts = if check_conflicts {
println!(
"{} {}",
Expand Down Expand Up @@ -1452,7 +1449,11 @@ fn check_actions(
Ok((conflicts, inner_conflicts))
}

fn repo_install(config: &Config, install: &[RepoPackage]) -> Result<i32> {
fn repo_install(
config: &Config,
install: &[RepoPackage],
conflicts: &HashSet<String>,
) -> Result<i32> {
if install.is_empty() {
return Ok(0);
}
Expand All @@ -1472,8 +1473,11 @@ fn repo_install(config: &Config, install: &[RepoPackage]) -> Result<i32> {
.remove("asexp")
.remove("y")
.remove("i")
.remove("refresh")
.arg("noconfirm");
.remove("refresh");

if !install.iter().any(|pkg| conflicts.contains(pkg.pkg.name())) {
args.arg("noconfirm");
}
args.targets = targets.iter().map(|s| s.as_str()).collect();

if !config.combined_upgrade || !config.mode.repo() {
Expand Down

0 comments on commit 5472d2f

Please sign in to comment.