Replace the apt step with nala if installed. (#914)

This commit is contained in:
Roey Darwish Dror 2022-05-09 06:44:39 +03:00 committed by GitHub
parent c166d51fb8
commit 1e25926999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -283,11 +283,22 @@ fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = &ctx.sudo() {
let apt = which("apt-fast").unwrap_or_else(|| PathBuf::from("apt-get"));
ctx.run_type().execute(&sudo).arg(&apt).arg("update").check_run()?;
let apt = which("apt-fast")
.or_else(|| which("nala"))
.unwrap_or_else(|| PathBuf::from("apt-get"));
let is_nala = apt.ends_with("nala");
if !is_nala {
ctx.run_type().execute(&sudo).arg(&apt).arg("update").check_run()?;
}
let mut command = ctx.run_type().execute(&sudo);
command.arg(&apt).arg("dist-upgrade");
command.arg(&apt);
if is_nala {
command.arg("upgrade");
} else {
command.arg("dist-upgrade");
};
if ctx.config().yes(Step::System) {
command.arg("-y");
}