Welcome to AK3: AnyKernel2 + Magisk = AnyKernel3!

- abstract out execution directory as $home to fascilitate testing individual scripts (defaults to /tmp/anykernel)
- general script clean ups for uniformity, readability, speed and simplicity
- simplify consecutive `ui_print` commands where possible

Backend only fixes:
- use busybox umount and mount whenever possible to avoid linker warnings in stderr during system-as-root setup
- use `busybox --install -s` for bin/* setup
- consolidate setup to abort earlier if there are issues
- add backwards compatible symlinks for those who might not have updated their anykernel.sh with ak3-core.sh (to be renamed in subsequent commit)

Tools only fixes:
- add magiskboot to replace separate support for AOSP and PXA-AOSP formats, with MTK headers, BLOB, DHTB, SEAndroid and Nook signing
- add magiskpolicy to allow for easy sepolicy patching
- remove xz and lz4 since magiskboot supports these

AK3 Core only fixes:
- use full `ui_print` function implementation like the backend
- add `abort` function to simplify exit on errors
- fix $patch directory being excluded from `reset_ak`
- update $ramdisk_compression handling for magiskboot
- magiskboot also resolves long-standing request for built-in Bump support (#18)
- update Sony ELF and related support for initial repack as AOSP by using mkbootimg as plug-and-play optional add-in binary
- update Sony ELF MTK header support using mkmtkhdr only when ELF is initially unpacked by unpackelf
- add support for MTK RECOVERY ramdisk header type with Sony ELF
- simplify U-Boot dumpimage/mkimage and Sony ELF unpackelf/mkbootimg split_img file handling
- update patch_cmdline to handle both magiskboot as header prop file, and unpackelf or mboot as cmdline.txt
- use `cp -fp` for `backup_file` and `restore_file` to hopefully better preserve attributes if used outside of the ramdisk
- refactor setup into `setup_ak` to simplify `reset_ak` trigger to find slot and block again
- add fallback to busybox for compression formats (i.e. lzop) which magiskboot cannot handle

IMPORTANT NOTES:
1) forcing repack with uncompressed cpio ramdisk is not currently supported by magiskboot
2) forcing repack with lzop ramdisk when previously another format is not currently supported by magiskboot
This commit is contained in:
osm0sis committed 2019-05-31 23:49:19 -03:00
1 parent 6672e75f54
commit 6986821230
8 files changed
+429 -451

No files matched your search

+34 -40
View File
@@ -1,10 +1,13 @@
#!/sbin/sh
# AnyKernel2 Backend (DO NOT CHANGE)
# AnyKernel3 Backend (DO NOT CHANGE)
# osm0sis @ xda-developers
OUTFD=/proc/self/fd/$2;
ZIPFILE="$3";
DIR=`dirname "$ZIPFILE"`;
DIR=$(dirname "$ZIPFILE");
test "$home" || home=/tmp/anykernel;
parent=$(dirname $home);
ui_print() {
until [ ! "$1" ]; do
@@ -24,27 +27,26 @@ int2ver() {
fi;
}
cleanup() {
cd /tmp;
rm -rf /tmp/anykernel;
cd $parent;
rm -rf $home;
}
debugging() {
case $(basename "$ZIPFILE" .zip) in
*-debugging)
ui_print " ";
ui_print "Creating debugging archive in zip directory...";
$bb tar -czvf "$DIR/anykernel2-$(date +%Y-%m-%d_%H%M%S)-debug.tgz" /tmp/*;
ui_print " " "Creating debugging archive in zip directory...";
$bb tar -czvf "$DIR/anykernel3-$(date +%Y-%m-%d_%H%M%S)-debug.tgz" $parent/*;
;;
esac;
}
is_mounted() { $bb mount | $bb grep " $1 "; }
unmount_all() {
(umount /system;
($bb umount /system;
if [ -d /system_root -a ! -f /system/build.prop ]; then
umount /system_root;
$bb umount /system_root;
fi;
umount /system;
umount /vendor;
umount /data) 2>/dev/null;
$bb umount /system;
$bb umount /vendor;
$bb umount /data) 2>/dev/null;
}
abort() {
ui_print "$*";
@@ -59,22 +61,25 @@ abort() {
show_progress 1.34 4;
ui_print " ";
cleanup;
mkdir -p /tmp/anykernel/bin;
cd /tmp/anykernel;
mkdir -p $home/bin;
cd $home;
unzip -o "$ZIPFILE";
if [ $? != 0 -o -z "$(ls tools)" ]; then
if [ $? != 0 -o ! "$(ls tools)" ]; then
abort "Unzip failed. Aborting...";
fi;
bb=/tmp/anykernel/tools/busybox;
bb=$home/tools/busybox;
chmod 755 $bb;
$bb chmod -R 755 tools bin;
$bb --install -s bin;
if [ $? != 0 -o -z "$(ls bin)" ]; then
abort "Busybox setup failed. Aborting...";
fi;
if [ -f banner ]; then
while IFS='' read -r line || $bb [[ -n "$line" ]]; do
ui_print "$line";
done < banner;
ui_print " ";
ui_print " ";
ui_print " " " ";
fi;
ui_print "$(file_getprop anykernel.sh kernel.string)";
@@ -85,10 +90,7 @@ if [ -f version ]; then
done < version;
ui_print " ";
fi;
ui_print " ";
ui_print "AnyKernel2 by osm0sis @ xda-developers";
ui_print " ";
ui_print " ";
ui_print " " "AnyKernel3 by osm0sis @ xda-developers" " " " ";
unmount_all;
if [ ! "$(is_mounted /system)" ]; then
@@ -97,8 +99,8 @@ fi;
($bb mount -o ro -t auto /vendor;
$bb mount /data) 2>/dev/null;
if [ -f /system/system/build.prop ]; then
umount /system;
(umount /system;
$bb umount /system;
($bb umount /system;
mkdir /system_root) 2>/dev/null;
$bb mount -o ro -t auto /dev/block/bootdevice/by-name/system /system_root;
$bb mount -o bind /system_root/system /system;
@@ -156,8 +158,7 @@ if [ "$supported_ver" ]; then
done;
fi;
if [ "$supported" ]; then
ui_print "$android_ver";
ui_print " ";
ui_print "$android_ver" " ";
else
ui_print " ";
abort "Unsupported Android version. Aborting...";
@@ -165,23 +166,18 @@ if [ "$supported_ver" ]; then
fi;
ui_print "Installing...";
for i in $($bb --list); do
$bb ln -s $bb bin/$i;
done;
if [ $? != 0 -o -z "$(ls bin)" ]; then
abort "Recovery busybox setup failed. Aborting...";
fi;
PATH="/tmp/anykernel/bin:$PATH" $bb ash anykernel.sh $2;
core=$($bb grep -oE 'ak.*core.sh' anykernel.sh);
test -f tools/$core || $bb ln -s $home/tools/ak*-core.sh $home/tools/$core;
PATH="$home/bin:$PATH" home=$home $bb ash anykernel.sh $2;
if [ $? != 0 ]; then
abort;
fi;
if [ "$(file_getprop anykernel.sh do.modules)" == 1 ]; then
ui_print " ";
ui_print "Pushing modules...";
ui_print " " "Pushing modules...";
$bb mount -o rw,remount -t auto /system;
$bb mount -o rw,remount -t auto /vendor 2>/dev/null;
cd /tmp/anykernel/modules;
cd $home/modules;
for module in $(find . -name '*.ko'); do
modtarget=$(echo $module | $bb cut -c2-);
if [ ! -e $modtarget ]; then
@@ -204,7 +200,7 @@ if [ "$(file_getprop anykernel.sh do.modules)" == 1 ]; then
$bb mount -o ro,remount -t auto $modtarget;
fi;
done;
cd /tmp/anykernel;
cd $home;
$bb mount -o ro,remount -t auto /system;
$bb mount -o ro,remount -t auto /vendor 2>/dev/null;
fi;
@@ -220,6 +216,4 @@ test "$savedpre" && export LD_PRELOAD="$savedpre";
unmount_all;
ui_print " ";
ui_print " ";
ui_print "Done!";
ui_print " " " " "Done!";
+395 -411
View File
File diff suppressed because it is too large. Load diff
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.