ksud: only backup stock boot if flashing (#1626)
This commit is contained in:
@@ -282,8 +282,10 @@ fn do_patch(
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
println!(include_str!("banner"));
|
println!(include_str!("banner"));
|
||||||
|
|
||||||
if image.is_none() {
|
let patch_file = image.is_some();
|
||||||
#[cfg(target_os = "android")]
|
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
if !patch_file {
|
||||||
ensure_gki_kernel()?;
|
ensure_gki_kernel()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,20 +374,20 @@ fn do_patch(
|
|||||||
if status.is_ok() {
|
if status.is_ok() {
|
||||||
do_cpio_cmd(&magiskboot, workding_dir.path(), "mv init init.real")?;
|
do_cpio_cmd(&magiskboot, workding_dir.path(), "mv init init.real")?;
|
||||||
}
|
}
|
||||||
println!("- Backup stock boot image");
|
|
||||||
// magiskboot cpio ramdisk.cpio 'add 0755 orig.ksu'
|
|
||||||
let output = Command::new(&magiskboot)
|
|
||||||
.current_dir(workding_dir.path())
|
|
||||||
.arg("sha1")
|
|
||||||
.arg(&bootimage)
|
|
||||||
.output()?;
|
|
||||||
ensure!(
|
|
||||||
output.status.success(),
|
|
||||||
"Cannot calculate sha1 of original boot!"
|
|
||||||
);
|
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
{
|
if flash {
|
||||||
|
println!("- Backup stock boot image");
|
||||||
|
// magiskboot cpio ramdisk.cpio 'add 0755 orig.ksu'
|
||||||
|
let output = Command::new(&magiskboot)
|
||||||
|
.current_dir(workding_dir.path())
|
||||||
|
.arg("sha1")
|
||||||
|
.arg(&bootimage)
|
||||||
|
.output()?;
|
||||||
|
ensure!(
|
||||||
|
output.status.success(),
|
||||||
|
"Cannot calculate sha1 of original boot!"
|
||||||
|
);
|
||||||
let output = String::from_utf8(output.stdout)?;
|
let output = String::from_utf8(output.stdout)?;
|
||||||
let output = output.trim();
|
let output = output.trim();
|
||||||
let output = format!("{KSU_BACKUP_FILE_PREFIX}{output}");
|
let output = format!("{KSU_BACKUP_FILE_PREFIX}{output}");
|
||||||
@@ -423,7 +425,7 @@ fn do_patch(
|
|||||||
ensure!(status.success(), "magiskboot repack failed");
|
ensure!(status.success(), "magiskboot repack failed");
|
||||||
let new_boot = workding_dir.path().join("new-boot.img");
|
let new_boot = workding_dir.path().join("new-boot.img");
|
||||||
|
|
||||||
if image.is_some() {
|
if patch_file {
|
||||||
// if image is specified, write to output file
|
// if image is specified, write to output file
|
||||||
let output_dir = out.unwrap_or(std::env::current_dir()?);
|
let output_dir = out.unwrap_or(std::env::current_dir()?);
|
||||||
let now = chrono::Utc::now();
|
let now = chrono::Utc::now();
|
||||||
|
|||||||
Reference in New Issue
Block a user