AnyKernel 2.0: add new features

- add new do.modules property
- add new remove_line method
- update insert_line with ability to change insertion point to before or after the matched line
- rearrange properties into the order they are executed
- fix minor cpio warnings (only visible when run manually)
- clean up sed syntax formatting
- README updates for new features and fix zip command to exclude README and any previous zip present.
This commit is contained in:
osm0sis committed 2014-08-27 02:22:53 -03:00
1 parent dc43d6cde5
commit b7a0960e1d
4 files changed
+40 -14

No files matched your search

@@ -23,6 +23,13 @@ ifelse(file_getprop("/tmp/anykernel/anykernel.sh", "do.initd") == 1,
);
ui_print("Installing kernel...");
assert(run_program("/sbin/sh", "/tmp/anykernel/anykernel.sh"));
ifelse(file_getprop("/tmp/anykernel/anykernel.sh", "do.modules") == 1,
(ui_print("Pushing modules...");
ui_print(" ");
assert(package_extract_dir("modules", "/system/lib/modules"),
set_perm_recursive(0, 0, 0755, 0644, "/system/lib/modules"));
)
);
ifelse(file_getprop("/tmp/anykernel/anykernel.sh", "do.cleanup") == 1,
(delete_recursive("/tmp/anykernel");
)
+12 -6
View File
@@ -10,17 +10,20 @@ A working script based on DirtyV Kernel for Galaxy Nexus (tuna) is included for
// Properties / Variables
kernel.string=KernelName by YourName @ xda-developers
do.initd=1
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.
do.initd=1 will create the init.d directory in /system/etc/init.d/ and apply 755 permissions.
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.
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.
@@ -29,8 +32,9 @@ do.cleanup=0 will keep the zip from removing it's working directory in /tmp/anyk
dump_boot
backup_file <file>
replace_string <file> <if search string> <original string> <replacement string>
insert_line <file> <if search string> <line before string> <inserted line>
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>
append_file <file> <if search string> <patch file>
replace_file <file> <permissions> <patch file>
@@ -38,15 +42,17 @@ 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 before string" and "line replace string" are the search strings that locate where the modification needs to be made for those commands.
Similarly, "line match string" and "line replace string" are the search strings that locate where the modification needs to be made for those commands.
"before/after" requires you simply specify "before" or "after" for the placement of the inserted line, in relation to "line match string".
// Instructions
1- Place zImage in the root
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 your.zip *
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.
+21 -8
View File
@@ -4,8 +4,9 @@
## AnyKernel setup
# EDIFY properties
kernel.string=DirtyV by bsmitty83 @ xda-developers
do.initd=1
do.devicecheck=1
do.initd=1
do.modules=0
do.cleanup=1
device.name1=maguro
device.name2=toro
@@ -56,7 +57,7 @@ write_boot() {
dtb="--dt $split_img/$dtb";
fi;
cd $ramdisk;
find . | cpio -o -H newc | gzip > /tmp/anykernel/ramdisk-new.cpio.gz;
find . | cpio -H newc -o | gzip > /tmp/anykernel/ramdisk-new.cpio.gz;
$bin/mkbootimg --kernel /tmp/anykernel/zImage --ramdisk /tmp/anykernel/ramdisk-new.cpio.gz $second --cmdline "$cmdline" --board "$board" --base $base --pagesize $pagesize --kernel_offset $kerneloff --ramdisk_offset $ramdiskoff $secondoff --tags_offset $tagsoff $dtb --output /tmp/anykernel/boot-new.img;
dd if=/tmp/anykernel/boot-new.img of=$block;
}
@@ -71,11 +72,15 @@ replace_string() {
fi;
}
# insert_line <file> <if search string> <line before string> <inserted line>
# insert_line <file> <if search string> <before/after> <line match string> <inserted line>
insert_line() {
if [ -z "$(grep "$2" $1)" ]; then
line=$((`grep -n "$3" $1 | cut -d: -f1` + 1));
sed -i $line"s;^;${4};" $1;
case $3 in
before) offset=0;;
after) offset=1;;
esac;
line=$((`grep -n "$4" $1 | cut -d: -f1` + offset));
sed -i "${line}s;^;${5};" $1;
fi;
}
@@ -83,7 +88,15 @@ insert_line() {
replace_line() {
if [ ! -z "$(grep "$2" $1)" ]; then
line=`grep -n "$2" $1 | cut -d: -f1`;
sed -i $line"s;.*;${3};" $1;
sed -i "${line}s;.*;${3};" $1;
fi;
}
# remove_line <file> <line match string>
remove_line() {
if [ ! -z "$(grep "$2" $1)" ]; then
line=`grep -n "$2" $1 | cut -d: -f1`;
sed -i "${line}d" $1;
fi;
}
@@ -130,7 +143,7 @@ append_file init.rc "run-parts" init;
# init.tuna.rc
backup_file init.tuna.rc;
insert_line init.tuna.rc "nodiratime barrier=0" "mount_all /fstab.tuna" "\tmount ext4 /dev/block/platform/omap/omap_hsmmc.0/by-name/userdata /data remount nosuid nodev noatime nodiratime barrier=0\n";
insert_line init.tuna.rc "nodiratime barrier=0" after "mount_all /fstab.tuna" "\tmount ext4 /dev/block/platform/omap/omap_hsmmc.0/by-name/userdata /data remount nosuid nodev noatime nodiratime barrier=0\n";
append_file init.tuna.rc "dvbootscript" init.tuna;
# init.superuser.rc
@@ -140,7 +153,7 @@ if [ -f init.superuser.rc ]; then
prepend_file init.superuser.rc "SuperSU daemonsu" init.superuser;
else
replace_file init.superuser.rc 750 init.superuser.rc;
insert_line init.rc "init.superuser.rc" "on post-fs-data" " import /init.superuser.rc\n\n";
insert_line init.rc "init.superuser.rc" after "on post-fs-data" " import /init.superuser.rc\n";
fi;
# fstab.tuna
View File
Whitespace-only changes.