Files
topgrade/src/steps/os/android.rs

39 lines
1.0 KiB
Rust
Raw Normal View History

2022-11-13 07:29:33 -03:00
use crate::command::CommandExt;
2021-09-02 16:54:31 +00:00
use crate::execution_context::ExecutionContext;
use crate::terminal::print_separator;
use crate::utils::require;
use crate::utils::which;
2021-12-13 16:04:21 -05:00
use crate::Step;
2022-11-11 09:39:29 -05:00
use color_eyre::eyre::Result;
2021-09-02 16:54:31 +00:00
pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
2022-11-01 22:20:47 +00:00
//let pkg = require("pkg")?;
let pkg = which("nala").or_else(|| which("pkg")).unwrap();
2021-09-02 16:54:31 +00:00
print_separator("Termux Packages");
let is_nala = pkg.ends_with("nala");
2022-11-01 22:20:47 +00:00
2021-09-02 16:54:31 +00:00
let mut command = ctx.run_type().execute(&pkg);
command.arg("upgrade");
2022-11-01 22:20:47 +00:00
2021-12-13 16:04:21 -05:00
if ctx.config().yes(Step::System) {
2021-09-02 16:54:31 +00:00
command.arg("-y");
}
command.status_checked()?;
2022-11-13 07:29:33 -03:00
if !is_nala && ctx.config().cleanup() {
ctx.run_type().execute(&pkg).arg("clean").status_checked()?;
let apt = require("apt")?;
let mut command = ctx.run_type().execute(&apt);
command.arg("autoremove");
if ctx.config().yes(Step::System) {
command.arg("-y");
2021-09-02 16:54:31 +00:00
}
2022-11-13 07:29:33 -03:00
command.status_checked()?;
2021-09-02 16:54:31 +00:00
}
Ok(())
}