Skip to content

Commit baceee9

Browse files
committed
Don't try to build packages if deps are missing
1 parent 386633d commit baceee9

File tree

1 file changed

+58
-26
lines changed

1 file changed

+58
-26
lines changed

src/install.rs

+58-26
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,7 @@ fn do_install(
12231223
args.arg("noconfirm");
12241224
}
12251225

1226+
debug!("flushing install queue");
12261227
args.targets = install_queue.iter().map(|s| s.as_str()).collect();
12271228
exec::pacman(config, &args)?.success()?;
12281229

@@ -1374,6 +1375,52 @@ fn sign_pkg(config: &Config, paths: &[&str], delete_sig: bool) -> Result<()> {
13741375
Ok(())
13751376
}
13761377

1378+
fn deps_satisfied(config: &Config, base: &Base) -> Result<bool> {
1379+
let db = config.new_alpm()?;
1380+
let db = db.localdb().pkgs();
1381+
let res = base
1382+
.pkgs
1383+
.iter()
1384+
.flat_map(|pkg| {
1385+
let check = if config.no_check {
1386+
None
1387+
} else {
1388+
Some(&pkg.pkg.check_depends)
1389+
};
1390+
pkg.pkg
1391+
.depends
1392+
.iter()
1393+
.chain(&pkg.pkg.make_depends)
1394+
.chain(check.into_iter().flatten())
1395+
})
1396+
.all(|dep| db.find_satisfier(dep.as_str()).is_some());
1397+
1398+
Ok(res)
1399+
}
1400+
1401+
fn deps_satisfied_by_repo(config: &Config, base: &Base) -> Result<bool> {
1402+
let db = config.new_alpm()?;
1403+
let db = db.syncdbs();
1404+
let res = base
1405+
.pkgs
1406+
.iter()
1407+
.flat_map(|pkg| {
1408+
let check = if config.no_check {
1409+
None
1410+
} else {
1411+
Some(&pkg.pkg.check_depends)
1412+
};
1413+
pkg.pkg
1414+
.depends
1415+
.iter()
1416+
.chain(&pkg.pkg.make_depends)
1417+
.chain(check.into_iter().flatten())
1418+
})
1419+
.all(|dep| db.find_satisfier(dep.as_str()).is_some());
1420+
1421+
Ok(res)
1422+
}
1423+
13771424
#[allow(clippy::too_many_arguments)]
13781425
fn build_install_pkgbuild<'a>(
13791426
config: &mut Config,
@@ -1393,36 +1440,21 @@ fn build_install_pkgbuild<'a>(
13931440
let mut debug_paths = HashMap::new();
13941441
let dir = config.build_dir.join(base.package_base());
13951442

1396-
let mut satisfied = false;
1397-
if !config.chroot && config.batch_install {
1398-
let db = config.new_alpm()?;
1399-
let db = db.localdb().pkgs();
1400-
if base
1401-
.pkgs
1402-
.iter()
1403-
.flat_map(|pkg| {
1404-
let check = if config.no_check {
1405-
None
1406-
} else {
1407-
Some(&pkg.pkg.check_depends)
1408-
};
1409-
pkg.pkg
1410-
.depends
1411-
.iter()
1412-
.chain(&pkg.pkg.make_depends)
1413-
.chain(check.into_iter().flatten())
1414-
})
1415-
.all(|dep| db.find_satisfier(dep.as_str()).is_some())
1416-
{
1417-
satisfied = true
1418-
}
1419-
}
1420-
1421-
if !config.chroot && !satisfied {
1443+
if !config.chroot && config.batch_install && deps_satisfied(config, base)? {
14221444
do_install(config, deps, exp, install_queue, *conflict, devel_info)?;
14231445
*conflict = false;
14241446
}
14251447

1448+
let ok = if config.chroot {
1449+
deps_satisfied_by_repo(config, base)?
1450+
} else {
1451+
deps_satisfied(config, base)?
1452+
};
1453+
1454+
if !ok {
1455+
bail!(tr!("can't build {}, deps not satisfied", base));
1456+
}
1457+
14261458
if config.chroot {
14271459
chroot
14281460
.build(&dir, &["-cu"], &["-ofA"])

0 commit comments

Comments
 (0)