You've already forked KernelSU
mirror of
https://github.com/tiann/KernelSU.git
synced 2025-08-27 23:46:34 +00:00
Add magiskboot to kernelsu working directory (#1684)
Add the magiskboot binary to the /data/adb/ksu/bin directory so that scripts/programs can call magiskboot to patch the boot/init_boot image. --------- Co-authored-by: weishu <twsxtd@gmail.com>
This commit is contained in:
@@ -84,7 +84,8 @@ fun execKsud(args: String, newShell: Boolean = false): Boolean {
|
|||||||
|
|
||||||
fun install() {
|
fun install() {
|
||||||
val start = SystemClock.elapsedRealtime()
|
val start = SystemClock.elapsedRealtime()
|
||||||
val result = execKsud("install", true)
|
val magiskboot = File(ksuApp.applicationInfo.nativeLibraryDir, "libmagiskboot.so").absolutePath
|
||||||
|
val result = execKsud("install --magiskboot $magiskboot", true)
|
||||||
Log.w(TAG, "install result: $result, cost: ${SystemClock.elapsedRealtime() - start}ms")
|
Log.w(TAG, "install result: $result, cost: ${SystemClock.elapsedRealtime() - start}ms")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,10 @@ enum Commands {
|
|||||||
BootCompleted,
|
BootCompleted,
|
||||||
|
|
||||||
/// Install KernelSU userspace component to system
|
/// Install KernelSU userspace component to system
|
||||||
Install,
|
Install {
|
||||||
|
#[arg(long, default_value = None)]
|
||||||
|
magiskboot: Option<PathBuf>,
|
||||||
|
},
|
||||||
|
|
||||||
/// Uninstall KernelSU modules and itself(LKM Only)
|
/// Uninstall KernelSU modules and itself(LKM Only)
|
||||||
Uninstall {
|
Uninstall {
|
||||||
@@ -307,7 +310,7 @@ pub fn run() -> Result<()> {
|
|||||||
Module::Shrink => module::shrink_ksu_images(),
|
Module::Shrink => module::shrink_ksu_images(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Commands::Install => utils::install(),
|
Commands::Install { magiskboot } => utils::install(magiskboot),
|
||||||
Commands::Uninstall { magiskboot } => utils::uninstall(magiskboot),
|
Commands::Uninstall { magiskboot } => utils::uninstall(magiskboot),
|
||||||
Commands::Sepolicy { command } => match command {
|
Commands::Sepolicy { command } => match command {
|
||||||
Sepolicy::Patch { sepolicy } => crate::sepolicy::live_patch(&sepolicy),
|
Sepolicy::Patch { sepolicy } => crate::sepolicy::live_patch(&sepolicy),
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ pub const PROFILE_TEMPLATE_DIR: &str = concatcp!(PROFILE_DIR, "templates/");
|
|||||||
pub const KSURC_PATH: &str = concatcp!(WORKING_DIR, ".ksurc");
|
pub const KSURC_PATH: &str = concatcp!(WORKING_DIR, ".ksurc");
|
||||||
pub const KSU_OVERLAY_SOURCE: &str = "KSU";
|
pub const KSU_OVERLAY_SOURCE: &str = "KSU";
|
||||||
pub const DAEMON_PATH: &str = concatcp!(ADB_DIR, "ksud");
|
pub const DAEMON_PATH: &str = concatcp!(ADB_DIR, "ksud");
|
||||||
|
pub const MAGISKBOOT_PATH: &str = concatcp!(BINARY_DIR, "magiskboot");
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
pub const DAEMON_LINK_PATH: &str = concatcp!(BINARY_DIR, "ksud");
|
pub const DAEMON_LINK_PATH: &str = concatcp!(BINARY_DIR, "ksud");
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ fn link_ksud_to_bin() -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn install() -> Result<()> {
|
pub fn install(magiskboot: Option<PathBuf>) -> Result<()> {
|
||||||
ensure_dir_exists(defs::ADB_DIR)?;
|
ensure_dir_exists(defs::ADB_DIR)?;
|
||||||
std::fs::copy("/proc/self/exe", defs::DAEMON_PATH)?;
|
std::fs::copy("/proc/self/exe", defs::DAEMON_PATH)?;
|
||||||
restorecon::lsetfilecon(defs::DAEMON_PATH, restorecon::ADB_CON)?;
|
restorecon::lsetfilecon(defs::DAEMON_PATH, restorecon::ADB_CON)?;
|
||||||
@@ -218,6 +218,11 @@ pub fn install() -> Result<()> {
|
|||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
link_ksud_to_bin()?;
|
link_ksud_to_bin()?;
|
||||||
|
|
||||||
|
if let Some(magiskboot) = magiskboot {
|
||||||
|
ensure_dir_exists(defs::BINARY_DIR)?;
|
||||||
|
let _ = std::fs::copy(magiskboot, defs::MAGISKBOOT_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user