From a538782c925849b16db226100d0f4434f9acfcc6 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Sun, 19 Apr 2026 15:07:38 -0400 Subject: [PATCH 1/2] Fix -B --noconfirm conflict check --- src/install.rs | 57 +++++++++++++++++++++++-------- testdata/clone/devel-bin/PKGBUILD | 5 +++ tests/common/tests.rs | 6 ++++ 3 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 testdata/clone/devel-bin/PKGBUILD diff --git a/src/install.rs b/src/install.rs index 4e7bbed1..96914437 100644 --- a/src/install.rs +++ b/src/install.rs @@ -1380,26 +1380,54 @@ fn check_actions( ); } + let build_only_targets = if install_targets { + None + } else { + let mut build_only_targets = HashSet::new(); + + for base in &actions.build { + match base { + Base::Aur(base) => build_only_targets.extend( + base.pkgs + .iter() + .filter(|pkg| pkg.target) + .map(|pkg| pkg.pkg.name.clone()), + ), + Base::Pkgbuild(base) => build_only_targets.extend( + base.pkgs + .iter() + .filter(|pkg| pkg.target) + .map(|pkg| pkg.pkg.pkgname.clone()), + ), + } + } + + Some(build_only_targets) + }; + + let filter_build_only_targets = |conflicts: &mut Vec| { + if let Some(build_only_targets) = build_only_targets.as_ref() { + conflicts.retain_mut(|conflict| { + if build_only_targets.contains(&conflict.pkg) { + return false; + } + + conflict + .conflicting + .retain(|pkg| !build_only_targets.contains(&pkg.pkg)); + !conflict.conflicting.is_empty() + }); + } + }; + let conflicts = if !config.chroot || install_targets { println!( "{} {}", c.action.paint("::"), c.bold.paint(tr!("Calculating conflicts...")) ); - // Hack to ignore conflicts on -B - // Only ignores conflicts for the last package instead of all targets - // As in theory one target could depend on another and thus must be installed let mut conflicts = actions.calculate_conflicts(!config.chroot); - if !install_targets { - if let Some(build) = actions.build.last() { - let pkgs = build.packages().map(|s| s.to_string()).collect::>(); - conflicts.retain(|c| { - !c.conflicting - .iter() - .all(|conflicting| pkgs.contains(&conflicting.pkg)) - }); - } - } + filter_build_only_targets(&mut conflicts); conflicts } else { Vec::new() @@ -1409,7 +1437,8 @@ fn check_actions( c.action.paint("::"), c.bold.paint(tr!("Calculating inner conflicts...")) ); - let inner_conflicts = actions.calculate_inner_conflicts(!config.chroot); + let mut inner_conflicts = actions.calculate_inner_conflicts(!config.chroot); + filter_build_only_targets(&mut inner_conflicts); if !conflicts.is_empty() || !inner_conflicts.is_empty() { eprintln!(); diff --git a/testdata/clone/devel-bin/PKGBUILD b/testdata/clone/devel-bin/PKGBUILD new file mode 100644 index 00000000..db79bfc9 --- /dev/null +++ b/testdata/clone/devel-bin/PKGBUILD @@ -0,0 +1,5 @@ +pkgname=devel-bin +pkgver=1 +pkgrel=1 +arch=(any) +conflicts=(devel) diff --git a/tests/common/tests.rs b/tests/common/tests.rs index 49cab992..3f678e8c 100644 --- a/tests/common/tests.rs +++ b/tests/common/tests.rs @@ -199,3 +199,9 @@ async fn devel() { let a = db.pkg("devel").unwrap(); assert_eq!(a.version().as_str(), "2-1"); } + +#[tokio::test] +async fn build_only_conflict_with_installed_pkg() { + let (_, ret) = run(&["-B", "testdata/clone/devel-bin"]).await.unwrap(); + assert_eq!(ret, 0); +} From ac3bef22ab9ae9967e260af5c0be7714e6edfec0 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Thu, 23 Apr 2026 14:53:05 -0400 Subject: [PATCH 2/2] Add missing .SRCINFO to devel-bin test data --- testdata/clone/devel-bin/.SRCINFO | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 testdata/clone/devel-bin/.SRCINFO diff --git a/testdata/clone/devel-bin/.SRCINFO b/testdata/clone/devel-bin/.SRCINFO new file mode 100644 index 00000000..67ba546d --- /dev/null +++ b/testdata/clone/devel-bin/.SRCINFO @@ -0,0 +1,6 @@ +pkgbase = devel-bin + pkgver = 1 + pkgrel = 1 + arch = any + +pkgname = devel-bin \ No newline at end of file