mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-21 10:48:29 +00:00
Always include boot image when processing tar
Credits: @BlackMesa123 Fix #7132, close #7133
This commit is contained in:
parent
4856da1584
commit
4caed73fe0
@ -232,32 +232,40 @@ abstract class MagiskInstallImpl protected constructor(
|
|||||||
val boot = installDir.getChildFile("boot.img")
|
val boot = installDir.getChildFile("boot.img")
|
||||||
val initBoot = installDir.getChildFile("init_boot.img")
|
val initBoot = installDir.getChildFile("init_boot.img")
|
||||||
val recovery = installDir.getChildFile("recovery.img")
|
val recovery = installDir.getChildFile("recovery.img")
|
||||||
if (Config.recovery && recovery.exists() && boot.exists()) {
|
|
||||||
// Repack boot image to prevent auto restore
|
fun ExtendedFile.copyToTar() {
|
||||||
arrayOf(
|
newInputStream().use {
|
||||||
"cd $installDir",
|
tarOut.putNextEntry(newTarEntry(name, length()))
|
||||||
"chmod -R 755 .",
|
|
||||||
"./magiskboot unpack boot.img",
|
|
||||||
"./magiskboot repack boot.img",
|
|
||||||
"cat new-boot.img > boot.img",
|
|
||||||
"./magiskboot cleanup",
|
|
||||||
"rm -f new-boot.img",
|
|
||||||
"cd /").sh()
|
|
||||||
boot.newInputStream().use {
|
|
||||||
tarOut.putNextEntry(newTarEntry("boot.img", boot.length()))
|
|
||||||
it.copyTo(tarOut)
|
it.copyTo(tarOut)
|
||||||
}
|
}
|
||||||
boot.delete()
|
delete()
|
||||||
// Install to recovery
|
}
|
||||||
return recovery
|
|
||||||
} else {
|
// Patch priority: recovery > init_boot > boot
|
||||||
return when {
|
return when {
|
||||||
initBoot.exists() -> initBoot
|
recovery.exists() -> {
|
||||||
boot.exists() -> boot
|
if (boot.exists()) {
|
||||||
else -> {
|
// Repack boot image to prevent auto restore
|
||||||
throw NoBootException()
|
arrayOf(
|
||||||
|
"cd $installDir",
|
||||||
|
"chmod -R 755 .",
|
||||||
|
"./magiskboot unpack boot.img",
|
||||||
|
"./magiskboot repack boot.img",
|
||||||
|
"cat new-boot.img > boot.img",
|
||||||
|
"./magiskboot cleanup",
|
||||||
|
"rm -f new-boot.img",
|
||||||
|
"cd /").sh()
|
||||||
|
boot.copyToTar()
|
||||||
}
|
}
|
||||||
|
recovery
|
||||||
}
|
}
|
||||||
|
initBoot.exists() -> {
|
||||||
|
if (boot.exists())
|
||||||
|
boot.copyToTar()
|
||||||
|
initBoot
|
||||||
|
}
|
||||||
|
boot.exists() -> boot
|
||||||
|
else -> throw NoBootException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user