- fix insert_line to perform more as expected by adding a newline automatically - add updated arm mkbootimg+unpackbootimg binaries from my AIK Build Farm, see my repos for changes - rewrite backend to use proper exit codes from anykernel.sh now that it is shell - fix ui_print and specific error messages by passing the outfd to anykernel.sh from the backend - add error messages for unpacking and repacking ramdisk, and make resulting image size check into its own error message - fix for cpio overwriting AK2 ramdisk files on some recoveries by using a tmp directory - add further ramdisk unpack verification by checking that there are actually files in the ramdisk directory prior to moving the tmp files back - add insert_file function to make multi-line additions easier - add patch_fstab function to greatly simplify mount option/flag changes (thanks @Khaon for the idea)
68 lines
3.5 KiB
Plaintext
68 lines
3.5 KiB
Plaintext
AnyKernel2 - Flashable Zip Template for Kernel Releases with Ramdisk Modifications
|
|
by osm0sis @ xda-developers
|
|
|
|
"AnyKernel is a template for an update.zip that can apply any kernel to any ROM, regardless of ramdisk." - Koush
|
|
|
|
AnyKernel2 pushes the format even further by allowing kernel developers to modify the underlying ramdisk for kernel feature support easily using a number of included command methods along with properties and variables.
|
|
|
|
A working script based on DirtyV Kernel for Galaxy Nexus (tuna) is included for reference.
|
|
|
|
// Properties / Variables
|
|
|
|
kernel.string=KernelName by YourName @ xda-developers
|
|
do.devicecheck=1
|
|
do.initd=1
|
|
do.modules=1
|
|
do.cleanup=1
|
|
device.name1=maguro
|
|
device.name2=toro
|
|
device.name3=toroplus
|
|
block=/dev/block/platform/omap/omap_hsmmc.0/by-name/boot;
|
|
|
|
do.devicecheck=1 specified requires at least device.name1 to be present. This should match ro.product.device or ro.build.product for your device. There is support for up to 5 device.name# properties.
|
|
|
|
do.initd=1 will create the init.d directory in /system/etc/init.d/ and apply 755 permissions.
|
|
|
|
do.modules=1 will push the contents of the module directory to /system/lib/modules/ and apply 644 permissions.
|
|
|
|
do.cleanup=0 will keep the zip from removing it's working directory in /tmp/anykernel - this can be useful if trying to debug in adb shell whether the patches worked correctly.
|
|
|
|
// Command Methods
|
|
|
|
dump_boot
|
|
backup_file <file>
|
|
replace_string <file> <if search string> <original string> <replacement string>
|
|
insert_line <file> <if search string> <before|after> <line match string> <inserted line>
|
|
replace_line <file> <line replace string> <replacement line>
|
|
remove_line <file> <line match string>
|
|
prepend_file <file> <if search string> <patch file>
|
|
insert_file <file> <if search string> <before|after> <line match string> <patch file>
|
|
append_file <file> <if search string> <patch file>
|
|
replace_file <file> <permissions> <patch file>
|
|
patch_fstab <fstab file> <mount match name> <fs match type> <block|mount|fstype|options|flags> <if search string> <replacement string>
|
|
write_boot
|
|
|
|
"if search string" is the string it looks for to decide whether it needs to add the tweak or not, so generally something to indicate the tweak already exists.
|
|
|
|
Similarly, "line match string" and "line replace string" are the search strings that locate where the modification needs to be made for those commands, and "mount match name" and "fs match type" are both required to narrow the patch_fstab command down to the correct entry.
|
|
|
|
"before|after" requires you simply specify "before" or "after" for the placement of the inserted line, in relation to "line match string".
|
|
|
|
"block|mount|fstype|options|flags" requires you specify which part (listed in order) of the fstab entry you want to check and alter.
|
|
|
|
You may also use ui_print "<text>" to write messages back to the recovery during the modification process.
|
|
|
|
// Instructions
|
|
|
|
1- Place zImage in the root (dtb should also go here for devices that require a custom one, both will fallback to the original if not included)
|
|
2- Place any required ramdisk files in /ramdisk
|
|
3- Place any required patch files (generally partial files which go with commands) in /patch
|
|
4- Modify the anykernel.sh to add your kernel's name, boot partition location, permissions for included ramdisk files, and use methods for any required ramdisk modifications
|
|
5- zip -r9 UPDATE-AnyKernel2.zip * -x README UPDATE-AnyKernel2.zip
|
|
|
|
Not required, but any tweaks you can't hardcode into the source should be added with a bootscript.sh like is done in the example provided.
|
|
|
|
|
|
Have fun!
|
|
|