ksud: Add uninstall

This commit is contained in:
weishu
2024-04-22 20:41:42 +08:00
parent 4922d89823
commit 0697db618e
3 changed files with 30 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ use std::{
path::Path,
};
use crate::{assets, defs, ksucalls, restorecon};
use crate::{assets, boot_patch, defs, ksucalls, module, restorecon};
use std::fs::metadata;
#[allow(unused_imports)]
use std::fs::{set_permissions, Permissions};
@@ -217,6 +217,16 @@ pub fn install() -> Result<()> {
Ok(())
}
pub fn uninstall(magiskboot_path: Option<PathBuf>) -> Result<()> {
println!("- Uninstall modules..");
module::uninstall_all_modules()?;
module::prune_modules()?;
println!("- Removing directories..");
std::fs::remove_dir_all(defs::WORKING_DIR)?;
println!("- Uninstall KernelSU itself..");
boot_patch::restore(None, magiskboot_path, true)
}
// TODO: use libxcp to improve the speed if cross's MSRV is 1.70
pub fn copy_sparse_file<P: AsRef<Path>, Q: AsRef<Path>>(
src: P,