π Boot Patch v1.0.0
Allows unpacking and packing the boot.img
or recovery.img
of most Android devices.
You can design your own plugins. Check this.
Installationβ
- Download the plugin here.
- Add
boot-patch
file in yourMETA-INF/addons
. - Import it:
import_module "$addons/boot-patch"
- Enjoy your new functions!
unpack_bootβ
Unpacks an existing IMG/Partition.
Argument | Description |
---|---|
IMG/Partition | Path to the IMG file or partition to extract |
FOLDER | Directory where the extracted contents will be saved |
NUMBER | Optional: Set to 1 to skip unpacking the ramdisk |
# Unpack some existing IMG
unpack_boot "$TMP/boot.img" "$TMP/first_boot"
# Unpack from some Partition
unpack_boot $(find_block boot) "$TMP/second_boot"
# Unpack without unpacking the Ramdisk
unpack_boot $(find_block boot) "$TMP/second_boot" 1
You can check if there were any problems during unpacking:
if unpack_boot $(find_block boot) "$TMP/first_boot"; then
ui_print "Success"
else
abort "Some error"
fi
repack_bootβ
Rebuilds the IMG unpacked by unpack_boot
.
Argument | Description |
---|---|
FOLDER | Directory containing the unpacked contents |
OUTPUT | Path to save the rebuilt IMG or partition to write to |
OPTION | Optional: Set to recovery to use AVB1 signing for recovery images |
# Repack some unpacked IMG
repack_boot "$TMP/first_boot" "$TMP/result.img"
# Repack and send it to some Partition
repack_boot "$TMP/second_boot" $(find_block boot)
# Repack some unpacked Recovery image
repack_boot "$TMP/second_boot" $(find_block recovery) recovery
Automatic Behaviors:
- If
Magisk
is detected in the original boot.img, a restore will be attempted. - If the restore fails (for example, due to complete Ramdisk replacement),
Magisk
will be completely removed.
You can check if the resulting IMG lost Magisk
. Verification of other ROOT methods is not supported.
repack_boot "$TMP/first_boot" $(find_block boot)
result=$?
if is_equal $result 0; then
ui_print "No error and Magisk ensured"
elif is_equal $result 1; then
ui_print "Some fatal problem! and no changes were made"
elif is_equal $result 2; then
ui_print "No error but Magisk is not present"
fi
update_ramdiskβ
Updates the ramdisk of an existing IMG or partition.
Argument | Description |
---|---|
NEW RAMDISK | Path to the new ramdisk file |
IMG/Partition | Path to the IMG file or partition to update |
# Update the Ramdisk in some existing IMG
update_ramdisk "$TMP/new_ramdisk.cpio" "$TMP/boot.img"
# Update the Ramdisk in some Partition
update_ramdisk "$TMP/new_ramdisk.cpio" $(find_block boot)
You can save the error code to know if the IMG lost Magisk. Check repack_boot.
update_kernelβ
Updates the kernel of an existing IMG or partition.
Argument | Description |
---|---|
NEW KERNEL | Path to the new kernel file |
IMG/Partition | Path to the IMG file or partition to update |
# Update the Kernel in some existing IMG
update_kernel "$TMP/new_kernel" "$TMP/boot.img"
# Update the Kernel in some Partition
update_kernel "$TMP/new_kernel" $(find_block boot)
You can save the error code to know if the IMG lost Magisk. Check repack_boot.
patch_cmdlineβ
Patches properties of the cmdline
of an IMG unpacked by unpack_boot
.
Argument | Description |
---|---|
PROPERTY | Property to add or replace (Multiple allowed) |
# It is necessary to be in the directory
cd "$TMP/first_boot"
patch_cmdline androidboot.selinux=permissive
Automatically replaces or adds props (if you patch the same prop twice, it wonβt repeat).
remove_cmdlineβ
Removes properties of the cmdline
of an IMG unpacked by unpack_boot
.
Argument | Description |
---|---|
PROPERTY | Property to remove (Multiple allowed) |
# It is necessary to be in the directory
cd "$TMP/first_boot"
remove_cmdline skip_override
flash_imageβ
Installs an IMG to a partition or saves it to a file.
Argument | Description |
---|---|
IMG | Path to the IMG file to install |
OUTPUT | Partition to write to or file to save |
flash_image "$TMP/boot.img" $(find_block boot)
This function is provisional for this plugin, it is not strictly necessary to use it. DI already provides specific functions to do the same.