fix: fix Mist (#466)

This commit is contained in:
SteveLauC
2023-06-05 14:38:14 +08:00
committed by GitHub
parent 470231c9d1
commit a7ddf4575a

View File

@@ -439,25 +439,37 @@ fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
} }
fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> { fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> {
if let Some(sudo) = &ctx.sudo() { let apt = which("apt-fast")
let apt = which("apt-fast") .or_else(|| {
.or_else(|| { if which("mist").is_some() {
if which("mist").is_some() { Some(PathBuf::from("mist"))
Some(PathBuf::from("mist")) } else {
} else { None
None }
} })
}) .or_else(|| {
.or_else(|| { if Path::new("/usr/bin/nala").exists() {
if Path::new("/usr/bin/nala").exists() { Some(Path::new("/usr/bin/nala").to_path_buf())
Some(Path::new("/usr/bin/nala").to_path_buf()) } else {
} else { None
None }
} })
}) .unwrap_or_else(|| PathBuf::from("apt-get"));
.unwrap_or_else(|| PathBuf::from("apt-get"));
let is_nala = apt.ends_with("nala"); let is_mist = apt.ends_with("mist");
let is_nala = apt.ends_with("nala");
// MIST does not require `sudo`
if is_mist {
ctx.run_type().execute(&apt).arg("update").status_checked()?;
ctx.run_type().execute(&apt).arg("upgrade").status_checked()?;
// Simply return as MIST does not have `clean` and `autoremove`
// subcommands, neither the `-y` option (for now maybe?).
return Ok(());
}
if let Some(sudo) = &ctx.sudo() {
if !is_nala { if !is_nala {
ctx.run_type() ctx.run_type()
.execute(sudo) .execute(sudo)