Add Android support (#749)

This commit is contained in:
Laurent le Beau-Martin
2021-09-02 16:54:31 +00:00
committed by GitHub
parent ad4648655f
commit ebb66e26a4
3 changed files with 36 additions and 0 deletions

View File

@@ -186,6 +186,9 @@ fn run() -> Result<()> {
freebsd::upgrade_packages(sudo.as_ref(), run_type)
})?;
#[cfg(target_os = "android")]
runner.execute(Step::Pkg, "Termux Packages", || android::upgrade_packages(&ctx))?;
let emacs = emacs::Emacs::new(&base_dirs);
if config.use_predefined_git_repos() {
if config.should_run(Step::Emacs) {

31
src/steps/os/android.rs Normal file
View File

@@ -0,0 +1,31 @@
use crate::execution_context::ExecutionContext;
use crate::terminal::print_separator;
use crate::utils::require;
use anyhow::Result;
pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
let pkg = require("pkg")?;
print_separator("Termux Packages");
let mut command = ctx.run_type().execute(&pkg);
command.arg("upgrade");
if ctx.config().yes() {
command.arg("-y");
}
command.check_run()?;
if ctx.config().cleanup() {
ctx.run_type().execute(&pkg).arg("clean").check_run()?;
let apt = require("apt")?;
let mut command = ctx.run_type().execute(&apt);
command.arg("autoremove");
if ctx.config().yes() {
command.arg("-y");
}
command.check_run()?;
}
Ok(())
}

View File

@@ -1,3 +1,5 @@
#[cfg(target_os = "android")]
pub mod android;
#[cfg(target_os = "dragonfly")]
pub mod dragonfly;
#[cfg(target_os = "freebsd")]