AK3: replace remaining variables
- all working directory variables - all user set variables - add backwards compat so devs have time to update anykernel.sh - overdue core variable cleanup, part 3/x
This commit is contained in:
2 files changed
+144
-129
No files matched your search
@@ -3,4 +3,4 @@
|
|||||||
# Dummy file; update-binary is a shell script (DO NOT CHANGE)
|
# Dummy file; update-binary is a shell script (DO NOT CHANGE)
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# AK_BASE_VERSION=20240203
|
# AK_BASE_VERSION=20240509
|
||||||
+143
-128
@@ -5,11 +5,11 @@
|
|||||||
|
|
||||||
# set up working directory variables
|
# set up working directory variables
|
||||||
[ "$AKHOME" ] || AKHOME=$PWD;
|
[ "$AKHOME" ] || AKHOME=$PWD;
|
||||||
bootimg=$AKHOME/boot.img;
|
BOOTIMG=$AKHOME/boot.img;
|
||||||
BIN=$AKHOME/tools;
|
BIN=$AKHOME/tools;
|
||||||
patch=$AKHOME/patch;
|
PATCH=$AKHOME/patch;
|
||||||
ramdisk=$AKHOME/ramdisk;
|
RAMDISK=$AKHOME/ramdisk;
|
||||||
split_img=$AKHOME/split_img;
|
SPLITIMG=$AKHOME/split_img;
|
||||||
|
|
||||||
### output/testing functions:
|
### output/testing functions:
|
||||||
# ui_print "<text>" [...]
|
# ui_print "<text>" [...]
|
||||||
@@ -67,32 +67,32 @@ set_perm_recursive() {
|
|||||||
split_boot() {
|
split_boot() {
|
||||||
local splitfail;
|
local splitfail;
|
||||||
|
|
||||||
if [ ! -e "$(echo $block | cut -d\ -f1)" ]; then
|
if [ ! -e "$(echo "$BLOCK" | cut -d\ -f1)" ]; then
|
||||||
abort "Invalid partition. Aborting...";
|
abort "Invalid partition. Aborting...";
|
||||||
fi;
|
fi;
|
||||||
if [ "$(echo $block | grep ' ')" ]; then
|
if echo "$BLOCK" | grep -q ' '; then
|
||||||
block=$(echo $block | cut -d\ -f1);
|
BLOCK=$(echo "$BLOCK" | cut -d\ -f1);
|
||||||
customdd=$(echo $block | cut -d\ -f2-);
|
CUSTOMDD=$(echo "$BLOCK" | cut -d\ -f2-);
|
||||||
elif [ ! "$customdd" ]; then
|
elif [ ! "$CUSTOMDD" ]; then
|
||||||
local customdd="bs=1048576";
|
CUSTOMDD="bs=1048576";
|
||||||
fi;
|
fi;
|
||||||
if [ -f "$BIN/nanddump" ]; then
|
if [ -f "$BIN/nanddump" ]; then
|
||||||
nanddump -f $bootimg $block;
|
nanddump -f $BOOTIMG $BLOCK;
|
||||||
else
|
else
|
||||||
dd if=$block of=$bootimg $customdd;
|
dd if=$BLOCK of=$BOOTIMG $CUSTOMDD;
|
||||||
fi;
|
fi;
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
abort "Dumping image failed. Aborting...";
|
abort "Dumping image failed. Aborting...";
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
mkdir -p $split_img;
|
mkdir -p $SPLITIMG;
|
||||||
cd $split_img;
|
cd $SPLITIMG;
|
||||||
if [ -f "$BIN/unpackelf" ] && unpackelf -i $bootimg -h -q 2>/dev/null; then
|
if [ -f "$BIN/unpackelf" ] && unpackelf -i $BOOTIMG -h -q 2>/dev/null; then
|
||||||
if [ -f "$BIN/elftool" ]; then
|
if [ -f "$BIN/elftool" ]; then
|
||||||
mkdir elftool_out;
|
mkdir elftool_out;
|
||||||
elftool unpack -i $bootimg -o elftool_out;
|
elftool unpack -i $BOOTIMG -o elftool_out;
|
||||||
fi;
|
fi;
|
||||||
unpackelf -i $bootimg;
|
unpackelf -i $BOOTIMG;
|
||||||
[ $? != 0 ] && splitfail=1;
|
[ $? != 0 ] && splitfail=1;
|
||||||
mv -f boot.img-kernel kernel.gz;
|
mv -f boot.img-kernel kernel.gz;
|
||||||
mv -f boot.img-ramdisk ramdisk.cpio.gz;
|
mv -f boot.img-ramdisk ramdisk.cpio.gz;
|
||||||
@@ -108,9 +108,9 @@ split_boot() {
|
|||||||
esac;
|
esac;
|
||||||
fi;
|
fi;
|
||||||
elif [ -f "$BIN/mboot" ]; then
|
elif [ -f "$BIN/mboot" ]; then
|
||||||
mboot -u -f $bootimg;
|
mboot -u -f $BOOTIMG;
|
||||||
elif [ -f "$BIN/dumpimage" ]; then
|
elif [ -f "$BIN/dumpimage" ]; then
|
||||||
dd bs=$(($(printf '%d\n' 0x$(hexdump -n 4 -s 12 -e '16/1 "%02x""\n"' $bootimg)) + 64)) count=1 conv=notrunc if=$bootimg of=boot-trimmed.img;
|
dd bs=$(($(printf '%d\n' 0x$(hexdump -n 4 -s 12 -e '16/1 "%02x""\n"' $BOOTIMG)) + 64)) count=1 conv=notrunc if=$BOOTIMG of=boot-trimmed.img;
|
||||||
dumpimage -l boot-trimmed.img > header;
|
dumpimage -l boot-trimmed.img > header;
|
||||||
grep "Name:" header | cut -c15- > boot.img-name;
|
grep "Name:" header | cut -c15- > boot.img-name;
|
||||||
grep "Type:" header | cut -c15- | cut -d\ -f1 > boot.img-arch;
|
grep "Type:" header | cut -c15- | cut -d\ -f1 > boot.img-arch;
|
||||||
@@ -126,9 +126,9 @@ split_boot() {
|
|||||||
RAMDisk) mv -f kernel.gz ramdisk.cpio.gz;;
|
RAMDisk) mv -f kernel.gz ramdisk.cpio.gz;;
|
||||||
esac;
|
esac;
|
||||||
elif [ -f "$BIN/rkcrc" ]; then
|
elif [ -f "$BIN/rkcrc" ]; then
|
||||||
dd bs=4096 skip=8 iflag=skip_bytes conv=notrunc if=$bootimg of=ramdisk.cpio.gz;
|
dd bs=4096 skip=8 iflag=skip_bytes conv=notrunc if=$BOOTIMG of=ramdisk.cpio.gz;
|
||||||
else
|
else
|
||||||
(set -o pipefail; magiskboot unpack -h $bootimg 2>&1 | tee infotmp >&2);
|
(set -o pipefail; magiskboot unpack -h $BOOTIMG 2>&1 | tee infotmp >&2);
|
||||||
case $? in
|
case $? in
|
||||||
1) splitfail=1;;
|
1) splitfail=1;;
|
||||||
2) touch chromeos;;
|
2) touch chromeos;;
|
||||||
@@ -145,7 +145,7 @@ split_boot() {
|
|||||||
unpack_ramdisk() {
|
unpack_ramdisk() {
|
||||||
local comp;
|
local comp;
|
||||||
|
|
||||||
cd $split_img;
|
cd $SPLITIMG;
|
||||||
if [ -f ramdisk.cpio.gz ]; then
|
if [ -f ramdisk.cpio.gz ]; then
|
||||||
if [ -f "$BIN/mkmtkhdr" ]; then
|
if [ -f "$BIN/mkmtkhdr" ]; then
|
||||||
mv -f ramdisk.cpio.gz ramdisk.cpio.gz-mtk;
|
mv -f ramdisk.cpio.gz ramdisk.cpio.gz-mtk;
|
||||||
@@ -168,12 +168,12 @@ unpack_ramdisk() {
|
|||||||
fi;
|
fi;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
[ -d $ramdisk ] && mv -f $ramdisk $AKHOME/rdtmp;
|
[ -d $RAMDISK ] && mv -f $RAMDISK $AKHOME/rdtmp;
|
||||||
mkdir -p $ramdisk;
|
mkdir -p $RAMDISK;
|
||||||
chmod 755 $ramdisk;
|
chmod 755 $RAMDISK;
|
||||||
|
|
||||||
cd $ramdisk;
|
cd $RAMDISK;
|
||||||
EXTRACT_UNSAFE_SYMLINKS=1 cpio -d -F $split_img/ramdisk.cpio -i;
|
EXTRACT_UNSAFE_SYMLINKS=1 cpio -d -F $SPLITIMG/ramdisk.cpio -i;
|
||||||
if [ $? != 0 -o ! "$(ls)" ]; then
|
if [ $? != 0 -o ! "$(ls)" ]; then
|
||||||
abort "Unpacking ramdisk failed. Aborting...";
|
abort "Unpacking ramdisk failed. Aborting...";
|
||||||
fi;
|
fi;
|
||||||
@@ -194,34 +194,34 @@ repack_ramdisk() {
|
|||||||
local comp packfail mtktype;
|
local comp packfail mtktype;
|
||||||
|
|
||||||
cd $AKHOME;
|
cd $AKHOME;
|
||||||
if [ "$ramdisk_compression" != "auto" ] && [ "$(grep HEADER_VER $split_img/infotmp | sed -n 's;.*\[\(.*\)\];\1;p')" -gt 3 ]; then
|
if [ "$RAMDISK_COMPRESSION" != "auto" ] && [ "$(grep HEADER_VER $SPLITIMG/infotmp | sed -n 's;.*\[\(.*\)\];\1;p')" -gt 3 ]; then
|
||||||
ui_print " " "Warning: Only lz4-l ramdisk compression is allowed with hdr v4+ images. Resetting to auto...";
|
ui_print " " "Warning: Only lz4-l ramdisk compression is allowed with hdr v4+ images. Resetting to auto...";
|
||||||
ramdisk_compression=auto;
|
RAMDISK_COMPRESSION=auto;
|
||||||
fi;
|
fi;
|
||||||
case $ramdisk_compression in
|
case $RAMDISK_COMPRESSION in
|
||||||
auto|"") comp=$(ls $split_img/ramdisk.cpio.* 2>/dev/null | grep -v 'mtk' | rev | cut -d. -f1 | rev);;
|
auto|"") comp=$(ls $SPLITIMG/ramdisk.cpio.* 2>/dev/null | grep -v 'mtk' | rev | cut -d. -f1 | rev);;
|
||||||
none|cpio) comp="";;
|
none|cpio) comp="";;
|
||||||
gz) comp=gzip;;
|
gz) comp=gzip;;
|
||||||
lzo) comp=lzop;;
|
lzo) comp=lzop;;
|
||||||
bz2) comp=bzip2;;
|
bz2) comp=bzip2;;
|
||||||
lz4-l) comp=lz4_legacy;;
|
lz4-l) comp=lz4_legacy;;
|
||||||
*) comp=$ramdisk_compression;;
|
*) comp=$RAMDISK_COMPRESSION;;
|
||||||
esac;
|
esac;
|
||||||
|
|
||||||
if [ -f "$BIN/mkbootfs" ]; then
|
if [ -f "$BIN/mkbootfs" ]; then
|
||||||
mkbootfs $ramdisk > ramdisk-new.cpio;
|
mkbootfs $RAMDISK > ramdisk-new.cpio;
|
||||||
else
|
else
|
||||||
cd $ramdisk;
|
cd $RAMDISK;
|
||||||
find . | cpio -H newc -o > $AKHOME/ramdisk-new.cpio;
|
find . | cpio -H newc -o > $AKHOME/ramdisk-new.cpio;
|
||||||
fi;
|
fi;
|
||||||
[ $? != 0 ] && packfail=1;
|
[ $? != 0 ] && packfail=1;
|
||||||
|
|
||||||
cd $AKHOME;
|
cd $AKHOME;
|
||||||
if [ ! "$no_magisk_check" ]; then
|
if [ ! "$NO_MAGISK_CHECK" ]; then
|
||||||
magiskboot cpio ramdisk-new.cpio test;
|
magiskboot cpio ramdisk-new.cpio test;
|
||||||
magisk_patched=$?;
|
magisk_patched=$?;
|
||||||
fi;
|
fi;
|
||||||
[ $((magisk_patched & 3)) -eq 1 ] && magiskboot cpio ramdisk-new.cpio "extract .backup/.magisk $split_img/.magisk";
|
[ $((magisk_patched & 3)) -eq 1 ] && magiskboot cpio ramdisk-new.cpio "extract .backup/.magisk $SPLITIMG/.magisk";
|
||||||
if [ "$comp" ]; then
|
if [ "$comp" ]; then
|
||||||
magiskboot compress=$comp ramdisk-new.cpio;
|
magiskboot compress=$comp ramdisk-new.cpio;
|
||||||
if [ $? != 0 ] && $comp --help 2>/dev/null; then
|
if [ $? != 0 ] && $comp --help 2>/dev/null; then
|
||||||
@@ -235,8 +235,8 @@ repack_ramdisk() {
|
|||||||
abort "Repacking ramdisk failed. Aborting...";
|
abort "Repacking ramdisk failed. Aborting...";
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
if [ -f "$BIN/mkmtkhdr" -a -f "$split_img/boot.img-base" ]; then
|
if [ -f "$BIN/mkmtkhdr" -a -f "$SPLITIMG/boot.img-base" ]; then
|
||||||
mtktype=$(od -ta -An -N8 -j8 $split_img/ramdisk.cpio.gz-mtk | sed -e 's/ nul//g' -e 's/ //g' | tr '[:upper:]' '[:lower:]');
|
mtktype=$(od -ta -An -N8 -j8 $SPLITIMG/ramdisk.cpio.gz-mtk | sed -e 's/ nul//g' -e 's/ //g' | tr '[:upper:]' '[:lower:]');
|
||||||
case $mtktype in
|
case $mtktype in
|
||||||
rootfs|recovery) mkmtkhdr --$mtktype ramdisk-new.cpio*;;
|
rootfs|recovery) mkmtkhdr --$mtktype ramdisk-new.cpio*;;
|
||||||
esac;
|
esac;
|
||||||
@@ -247,10 +247,10 @@ repack_ramdisk() {
|
|||||||
flash_boot() {
|
flash_boot() {
|
||||||
local varlist i kernel ramdisk fdt cmdline comp part0 part1 nocompflag signfail pk8 cert avbtype;
|
local varlist i kernel ramdisk fdt cmdline comp part0 part1 nocompflag signfail pk8 cert avbtype;
|
||||||
|
|
||||||
cd $split_img;
|
cd $SPLITIMG;
|
||||||
if [ -f "$BIN/mkimage" ]; then
|
if [ -f "$BIN/mkimage" ]; then
|
||||||
varlist="name arch os type comp addr ep";
|
varlist="name arch os type comp addr ep";
|
||||||
elif [ -f "$BIN/mkbootimg" -a -f "$BIN/unpackelf" -a -f boot.img-base ]; then
|
elif [ -f "$BIN/mk" -a -f "$BIN/unpackelf" -a -f boot.img-base ]; then
|
||||||
mv -f cmdline.txt boot.img-cmdline 2>/dev/null;
|
mv -f cmdline.txt boot.img-cmdline 2>/dev/null;
|
||||||
varlist="cmdline base pagesize kernel_offset ramdisk_offset tags_offset";
|
varlist="cmdline base pagesize kernel_offset ramdisk_offset tags_offset";
|
||||||
fi;
|
fi;
|
||||||
@@ -268,22 +268,22 @@ flash_boot() {
|
|||||||
fi;
|
fi;
|
||||||
done;
|
done;
|
||||||
if [ "$kernel" ]; then
|
if [ "$kernel" ]; then
|
||||||
if [ -f "$BIN/mkmtkhdr" -a -f "$split_img/boot.img-base" ]; then
|
if [ -f "$BIN/mkmtkhdr" -a -f "$SPLITIMG/boot.img-base" ]; then
|
||||||
mkmtkhdr --kernel $kernel;
|
mkmtkhdr --kernel $kernel;
|
||||||
kernel=$kernel-mtk;
|
kernel=$kernel-mtk;
|
||||||
fi;
|
fi;
|
||||||
elif [ "$(ls $split_img/kernel* 2>/dev/null)" ]; then
|
elif [ "$(ls $SPLITIMG/kernel* 2>/dev/null)" ]; then
|
||||||
kernel=$(ls $split_img/kernel* | grep -v 'kernel_dtb' | tail -n1);
|
kernel=$(ls $SPLITIMG/kernel* | grep -v 'kernel_dtb' | tail -n1);
|
||||||
fi;
|
fi;
|
||||||
if [ "$(ls ramdisk-new.cpio* 2>/dev/null)" ]; then
|
if [ "$(ls ramdisk-new.cpio* 2>/dev/null)" ]; then
|
||||||
ramdisk=$AKHOME/$(ls ramdisk-new.cpio* | tail -n1);
|
ramdisk=$AKHOME/$(ls ramdisk-new.cpio* | tail -n1);
|
||||||
elif [ -f "$BIN/mkmtkhdr" -a -f "$split_img/boot.img-base" ]; then
|
elif [ -f "$BIN/mkmtkhdr" -a -f "$SPLITIMG/boot.img-base" ]; then
|
||||||
ramdisk=$split_img/ramdisk.cpio.gz-mtk;
|
ramdisk=$SPLITIMG/ramdisk.cpio.gz-mtk;
|
||||||
else
|
else
|
||||||
ramdisk=$(ls $split_img/ramdisk.cpio* 2>/dev/null | tail -n1);
|
ramdisk=$(ls $SPLITIMG/ramdisk.cpio* 2>/dev/null | tail -n1);
|
||||||
fi;
|
fi;
|
||||||
for fdt in dt recovery_dtbo dtb; do
|
for fdt in dt recovery_dtbo dtb; do
|
||||||
for i in $AKHOME/$fdt $AKHOME/$fdt.img $split_img/$fdt; do
|
for i in $AKHOME/$fdt $AKHOME/$fdt.img $SPLITIMG/$fdt; do
|
||||||
if [ -f $i ]; then
|
if [ -f $i ]; then
|
||||||
eval local $fdt=$i;
|
eval local $fdt=$i;
|
||||||
break;
|
break;
|
||||||
@@ -291,7 +291,7 @@ flash_boot() {
|
|||||||
done;
|
done;
|
||||||
done;
|
done;
|
||||||
|
|
||||||
cd $split_img;
|
cd $SPLITIMG;
|
||||||
if [ -f "$BIN/mkimage" ]; then
|
if [ -f "$BIN/mkimage" ]; then
|
||||||
[ "$comp" == "uncompressed" ] && comp=none;
|
[ "$comp" == "uncompressed" ] && comp=none;
|
||||||
part0=$kernel;
|
part0=$kernel;
|
||||||
@@ -307,7 +307,7 @@ flash_boot() {
|
|||||||
elif [ -f "$BIN/mboot" ]; then
|
elif [ -f "$BIN/mboot" ]; then
|
||||||
cp -f $kernel kernel;
|
cp -f $kernel kernel;
|
||||||
cp -f $ramdisk ramdisk.cpio.gz;
|
cp -f $ramdisk ramdisk.cpio.gz;
|
||||||
mboot -d $split_img -f $AKHOME/boot-new.img;
|
mboot -d $SPLITIMG -f $AKHOME/boot-new.img;
|
||||||
elif [ -f "$BIN/rkcrc" ]; then
|
elif [ -f "$BIN/rkcrc" ]; then
|
||||||
rkcrc -k $ramdisk $AKHOME/boot-new.img;
|
rkcrc -k $ramdisk $AKHOME/boot-new.img;
|
||||||
elif [ -f "$BIN/mkbootimg" -a -f "$BIN/unpackelf" -a -f boot.img-base ]; then
|
elif [ -f "$BIN/mkbootimg" -a -f "$BIN/unpackelf" -a -f boot.img-base ]; then
|
||||||
@@ -322,7 +322,7 @@ flash_boot() {
|
|||||||
done;
|
done;
|
||||||
case $kernel in
|
case $kernel in
|
||||||
*Image*)
|
*Image*)
|
||||||
if [ ! "$magisk_patched" -a ! "$no_magisk_check" ]; then
|
if [ ! "$magisk_patched" -a ! "$NO_MAGISK_CHECK" ]; then
|
||||||
magiskboot cpio ramdisk.cpio test;
|
magiskboot cpio ramdisk.cpio test;
|
||||||
magisk_patched=$?;
|
magisk_patched=$?;
|
||||||
fi;
|
fi;
|
||||||
@@ -364,7 +364,7 @@ flash_boot() {
|
|||||||
if grep -q -E '^/data/adb/ksud$' stringstmp; then
|
if grep -q -E '^/data/adb/ksud$' stringstmp; then
|
||||||
touch $AKHOME/kernelsu_patched;
|
touch $AKHOME/kernelsu_patched;
|
||||||
grep -E -m1 'Linux version.*#' stringstmp > $AKHOME/vertmp;
|
grep -E -m1 'Linux version.*#' stringstmp > $AKHOME/vertmp;
|
||||||
[ -d $ramdisk/overlay.d ] && ui_print " " "Warning: overlay.d detected in ramdisk but not currently supported by KernelSU!";
|
[ -d $RAMDISK/overlay.d ] && ui_print " " "Warning: overlay.d detected in ramdisk but not currently supported by KernelSU!";
|
||||||
else
|
else
|
||||||
ui_print " " "Warning: No KernelSU support detected in kernel!";
|
ui_print " " "Warning: No KernelSU support detected in kernel!";
|
||||||
fi;
|
fi;
|
||||||
@@ -385,15 +385,15 @@ flash_boot() {
|
|||||||
unset magisk_patched KEEPVERITY KEEPFORCEENCRYPT RECOVERYMODE PREINITDEVICE SHA1 RANDOMSEED; # leave PATCHVBMETAFLAG set for repack
|
unset magisk_patched KEEPVERITY KEEPFORCEENCRYPT RECOVERYMODE PREINITDEVICE SHA1 RANDOMSEED; # leave PATCHVBMETAFLAG set for repack
|
||||||
;;
|
;;
|
||||||
esac;
|
esac;
|
||||||
case $ramdisk_compression in
|
case $RAMDISK_COMPRESSION in
|
||||||
none|cpio) nocompflag="-n";;
|
none|cpio) nocompflag="-n";;
|
||||||
esac;
|
esac;
|
||||||
case $patch_vbmeta_flag in
|
case $PATCH_VBMETA_FLAG in
|
||||||
auto|"") [ "$PATCHVBMETAFLAG" ] || export PATCHVBMETAFLAG=false;;
|
auto|"") [ "$PATCHVBMETAFLAG" ] || export PATCHVBMETAFLAG=false;;
|
||||||
1) export PATCHVBMETAFLAG=true;;
|
1) export PATCHVBMETAFLAG=true;;
|
||||||
*) export PATCHVBMETAFLAG=false;;
|
*) export PATCHVBMETAFLAG=false;;
|
||||||
esac;
|
esac;
|
||||||
magiskboot repack $nocompflag $bootimg $AKHOME/boot-new.img;
|
magiskboot repack $nocompflag $BOOTIMG $AKHOME/boot-new.img;
|
||||||
fi;
|
fi;
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
abort "Repacking image failed. Aborting...";
|
abort "Repacking image failed. Aborting...";
|
||||||
@@ -403,7 +403,7 @@ flash_boot() {
|
|||||||
|
|
||||||
cd $AKHOME;
|
cd $AKHOME;
|
||||||
if [ -f "$BIN/futility" -a -d "$BIN/chromeos" ]; then
|
if [ -f "$BIN/futility" -a -d "$BIN/chromeos" ]; then
|
||||||
if [ -f "$split_img/chromeos" ]; then
|
if [ -f "$SPLITIMG/chromeos" ]; then
|
||||||
echo "Signing with CHROMEOS..." >&2;
|
echo "Signing with CHROMEOS..." >&2;
|
||||||
futility vbutil_kernel --pack boot-new-signed.img --keyblock $BIN/chromeos/kernel.keyblock --signprivate $BIN/chromeos/kernel_data_key.vbprivk --version 1 --vmlinuz boot-new.img --bootloader $BIN/chromeos/empty --config $BIN/chromeos/empty --arch arm --flags 0x1;
|
futility vbutil_kernel --pack boot-new-signed.img --keyblock $BIN/chromeos/kernel.keyblock --signprivate $BIN/chromeos/kernel_data_key.vbprivk --version 1 --vmlinuz boot-new.img --bootloader $BIN/chromeos/empty --config $BIN/chromeos/empty --arch arm --flags 0x1;
|
||||||
fi;
|
fi;
|
||||||
@@ -412,7 +412,7 @@ flash_boot() {
|
|||||||
if [ -d "$BIN/avb" ]; then
|
if [ -d "$BIN/avb" ]; then
|
||||||
pk8=$(ls $BIN/avb/*.pk8);
|
pk8=$(ls $BIN/avb/*.pk8);
|
||||||
cert=$(ls $BIN/avb/*.x509.*);
|
cert=$(ls $BIN/avb/*.x509.*);
|
||||||
case $block in
|
case $BLOCK in
|
||||||
*recovery*|*RECOVERY*|*SOS*) avbtype=recovery;;
|
*recovery*|*RECOVERY*|*SOS*) avbtype=recovery;;
|
||||||
*) avbtype=boot;;
|
*) avbtype=boot;;
|
||||||
esac;
|
esac;
|
||||||
@@ -438,15 +438,15 @@ flash_boot() {
|
|||||||
elif [ "$(wc -c < boot-new.img)" -gt "$(wc -c < boot.img)" ]; then
|
elif [ "$(wc -c < boot-new.img)" -gt "$(wc -c < boot.img)" ]; then
|
||||||
abort "New image larger than target partition. Aborting...";
|
abort "New image larger than target partition. Aborting...";
|
||||||
fi;
|
fi;
|
||||||
blockdev --setrw $block 2>/dev/null;
|
blockdev --setrw $BLOCK 2>/dev/null;
|
||||||
if [ -f "$BIN/flash_erase" -a -f "$BIN/nandwrite" ]; then
|
if [ -f "$BIN/flash_erase" -a -f "$BIN/nandwrite" ]; then
|
||||||
flash_erase $block 0 0;
|
flash_erase $BLOCK 0 0;
|
||||||
nandwrite -p $block boot-new.img;
|
nandwrite -p $BLOCK boot-new.img;
|
||||||
elif [ "$customdd" ]; then
|
elif [ "$CUSTOMDD" ]; then
|
||||||
dd if=/dev/zero of=$block $customdd 2>/dev/null;
|
dd if=/dev/zero of=$BLOCK $CUSTOMDD 2>/dev/null;
|
||||||
dd if=boot-new.img of=$block $customdd;
|
dd if=boot-new.img of=$BLOCK $CUSTOMDD;
|
||||||
else
|
else
|
||||||
cat boot-new.img /dev/zero > $block 2>/dev/null || true;
|
cat boot-new.img /dev/zero > $BLOCK 2>/dev/null || true;
|
||||||
fi;
|
fi;
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
abort "Flashing image failed. Aborting...";
|
abort "Flashing image failed. Aborting...";
|
||||||
@@ -467,7 +467,7 @@ flash_generic() {
|
|||||||
|
|
||||||
if [ "$img" -a ! -f ${1}_flashed ]; then
|
if [ "$img" -a ! -f ${1}_flashed ]; then
|
||||||
for path in /dev/block/mapper /dev/block/by-name /dev/block/bootdevice/by-name; do
|
for path in /dev/block/mapper /dev/block/by-name /dev/block/bootdevice/by-name; do
|
||||||
for file in $1 $1$slot; do
|
for file in $1 $1$SLOT; do
|
||||||
if [ -e $path/$file ]; then
|
if [ -e $path/$file ]; then
|
||||||
imgblock=$path/$file;
|
imgblock=$path/$file;
|
||||||
break 2;
|
break 2;
|
||||||
@@ -477,7 +477,7 @@ flash_generic() {
|
|||||||
if [ ! "$imgblock" ]; then
|
if [ ! "$imgblock" ]; then
|
||||||
abort "$1 partition could not be found. Aborting...";
|
abort "$1 partition could not be found. Aborting...";
|
||||||
fi;
|
fi;
|
||||||
if [ ! "$no_block_display" ]; then
|
if [ ! "$NO_BLOCK_DISPLAY" ]; then
|
||||||
ui_print " " "$imgblock";
|
ui_print " " "$imgblock";
|
||||||
fi;
|
fi;
|
||||||
if [ "$path" == "/dev/block/mapper" ]; then
|
if [ "$path" == "/dev/block/mapper" ]; then
|
||||||
@@ -489,7 +489,7 @@ flash_generic() {
|
|||||||
if [ "$flags" == "enabled" ]; then
|
if [ "$flags" == "enabled" ]; then
|
||||||
ui_print " " "dm-verity detected! Patching $avb...";
|
ui_print " " "dm-verity detected! Patching $avb...";
|
||||||
for avbpath in /dev/block/mapper /dev/block/by-name /dev/block/bootdevice/by-name; do
|
for avbpath in /dev/block/mapper /dev/block/by-name /dev/block/bootdevice/by-name; do
|
||||||
for file in $avb $avb$slot; do
|
for file in $avb $avb$SLOT; do
|
||||||
if [ -e $avbpath/$file ]; then
|
if [ -e $avbpath/$file ]; then
|
||||||
avbblock=$avbpath/$file;
|
avbblock=$avbpath/$file;
|
||||||
break 2;
|
break 2;
|
||||||
@@ -503,9 +503,9 @@ flash_generic() {
|
|||||||
fi
|
fi
|
||||||
imgsz=$(wc -c < $img);
|
imgsz=$(wc -c < $img);
|
||||||
if [ "$imgsz" != "$(wc -c < $imgblock)" ]; then
|
if [ "$imgsz" != "$(wc -c < $imgblock)" ]; then
|
||||||
if [ -d /postinstall/tmp -a "$slot_select" == "inactive" ]; then
|
if [ -d /postinstall/tmp -a "$SLOT_SELECT" == "inactive" ]; then
|
||||||
echo "Resizing $1$slot snapshot..." >&2;
|
echo "Resizing $1$SLOT snapshot..." >&2;
|
||||||
snapshotupdater_static update $1 $imgsz || abort "Resizing $1$slot snapshot failed. Aborting...";
|
snapshotupdater_static update $1 $imgsz || abort "Resizing $1$SLOT snapshot failed. Aborting...";
|
||||||
else
|
else
|
||||||
echo "Removing any existing $1_ak3..." >&2;
|
echo "Removing any existing $1_ak3..." >&2;
|
||||||
lptools_static remove $1_ak3;
|
lptools_static remove $1_ak3;
|
||||||
@@ -513,21 +513,21 @@ flash_generic() {
|
|||||||
lptools_static clear-cow;
|
lptools_static clear-cow;
|
||||||
echo "Attempting to create $1_ak3..." >&2;
|
echo "Attempting to create $1_ak3..." >&2;
|
||||||
if lptools_static create $1_ak3 $imgsz; then
|
if lptools_static create $1_ak3 $imgsz; then
|
||||||
echo "Replacing $1$slot with $1_ak3..." >&2;
|
echo "Replacing $1$SLOT with $1_ak3..." >&2;
|
||||||
lptools_static unmap $1_ak3 || abort "Unmapping $1_ak3 failed. Aborting...";
|
lptools_static unmap $1_ak3 || abort "Unmapping $1_ak3 failed. Aborting...";
|
||||||
lptools_static map $1_ak3 || abort "Mapping $1_ak3 failed. Aborting...";
|
lptools_static map $1_ak3 || abort "Mapping $1_ak3 failed. Aborting...";
|
||||||
lptools_static replace $1_ak3 $1$slot || abort "Replacing $1$slot failed. Aborting...";
|
lptools_static replace $1_ak3 $1$SLOT || abort "Replacing $1$SLOT failed. Aborting...";
|
||||||
imgblock=/dev/block/mapper/$1_ak3;
|
imgblock=/dev/block/mapper/$1_ak3;
|
||||||
ui_print " " "Warning: $1$slot replaced in super. Reboot before further logical partition operations.";
|
ui_print " " "Warning: $1$SLOT replaced in super. Reboot before further logical partition operations.";
|
||||||
else
|
else
|
||||||
echo "Creating $1_ak3 failed. Attempting to resize $1$slot..." >&2;
|
echo "Creating $1_ak3 failed. Attempting to resize $1$SLOT..." >&2;
|
||||||
httools_static umount $1 || abort "Unmounting $1 failed. Aborting...";
|
httools_static umount $1 || abort "Unmounting $1 failed. Aborting...";
|
||||||
if [ -e $path/$1-verity ]; then
|
if [ -e $path/$1-verity ]; then
|
||||||
lptools_static unmap $1-verity || abort "Unmapping $1-verity failed. Aborting...";
|
lptools_static unmap $1-verity || abort "Unmapping $1-verity failed. Aborting...";
|
||||||
fi
|
fi
|
||||||
lptools_static unmap $1$slot || abort "Unmapping $1$slot failed. Aborting...";
|
lptools_static unmap $1$SLOT || abort "Unmapping $1$SLOT failed. Aborting...";
|
||||||
lptools_static resize $1$slot $imgsz || abort "Resizing $1$slot failed. Aborting...";
|
lptools_static resize $1$SLOT $imgsz || abort "Resizing $1$SLOT failed. Aborting...";
|
||||||
lptools_static map $1$slot || abort "Mapping $1$slot failed. Aborting...";
|
lptools_static map $1$SLOT || abort "Mapping $1$SLOT failed. Aborting...";
|
||||||
isunmounted=1;
|
isunmounted=1;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -540,7 +540,7 @@ flash_generic() {
|
|||||||
if [ -f "$BIN/flash_erase" -a -f "$BIN/nandwrite" ]; then
|
if [ -f "$BIN/flash_erase" -a -f "$BIN/nandwrite" ]; then
|
||||||
flash_erase $imgblock 0 0;
|
flash_erase $imgblock 0 0;
|
||||||
nandwrite -p $imgblock $img;
|
nandwrite -p $imgblock $img;
|
||||||
elif [ "$customdd" ]; then
|
elif [ "$CUSTOMDD" ]; then
|
||||||
dd if=/dev/zero of=$imgblock 2>/dev/null;
|
dd if=/dev/zero of=$imgblock 2>/dev/null;
|
||||||
dd if=$img of=$imgblock;
|
dd if=$img of=$imgblock;
|
||||||
else
|
else
|
||||||
@@ -675,7 +675,7 @@ remove_line() {
|
|||||||
# prepend_file <file> <if search string> <patch file>
|
# prepend_file <file> <if search string> <patch file>
|
||||||
prepend_file() {
|
prepend_file() {
|
||||||
if ! grep -q "$2" $1; then
|
if ! grep -q "$2" $1; then
|
||||||
echo "$(cat $patch/$3 $1)" > $1;
|
echo "$(cat $PATCH/$3 $1)" > $1;
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -689,7 +689,7 @@ insert_file() {
|
|||||||
esac;
|
esac;
|
||||||
line=$((`grep -n -m1 "$4" $1 | cut -d: -f1` + offset));
|
line=$((`grep -n -m1 "$4" $1 | cut -d: -f1` + offset));
|
||||||
sed -i "${line}s;^;\n;" $1;
|
sed -i "${line}s;^;\n;" $1;
|
||||||
sed -i "$((line - 1))r $patch/$5" $1;
|
sed -i "$((line - 1))r $PATCH/$5" $1;
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -697,14 +697,14 @@ insert_file() {
|
|||||||
append_file() {
|
append_file() {
|
||||||
if ! grep -q "$2" $1; then
|
if ! grep -q "$2" $1; then
|
||||||
echo -ne "\n" >> $1;
|
echo -ne "\n" >> $1;
|
||||||
cat $patch/$3 >> $1;
|
cat $PATCH/$3 >> $1;
|
||||||
echo -ne "\n" >> $1;
|
echo -ne "\n" >> $1;
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
|
|
||||||
# replace_file <file> <permissions> <patch file>
|
# replace_file <file> <permissions> <patch file>
|
||||||
replace_file() {
|
replace_file() {
|
||||||
cp -pf $patch/$3 $1;
|
cp -pf $PATCH/$3 $1;
|
||||||
chmod $2 $1;
|
chmod $2 $1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -729,11 +729,11 @@ patch_fstab() {
|
|||||||
# patch_cmdline <cmdline entry name> <replacement string>
|
# patch_cmdline <cmdline entry name> <replacement string>
|
||||||
patch_cmdline() {
|
patch_cmdline() {
|
||||||
local cmdfile cmdtmp match;
|
local cmdfile cmdtmp match;
|
||||||
if [ -f "$split_img/cmdline.txt" ]; then
|
if [ -f "$SPLITIMG/cmdline.txt" ]; then
|
||||||
cmdfile=$split_img/cmdline.txt;
|
cmdfile=$SPLITIMG/cmdline.txt;
|
||||||
else
|
else
|
||||||
cmdfile=$AKHOME/cmdtmp;
|
cmdfile=$AKHOME/cmdtmp;
|
||||||
grep "^cmdline=" $split_img/header | cut -d= -f2- > $cmdfile;
|
grep "^cmdline=" $SPLITIMG/header | cut -d= -f2- > $cmdfile;
|
||||||
fi;
|
fi;
|
||||||
if ! grep -q "$1" $cmdfile; then
|
if ! grep -q "$1" $cmdfile; then
|
||||||
cmdtmp=$(cat $cmdfile);
|
cmdtmp=$(cat $cmdfile);
|
||||||
@@ -744,7 +744,7 @@ patch_cmdline() {
|
|||||||
sed -i -e "s;${match};${2};" -e 's;^[ \t]*;;' -e 's; *; ;g' -e 's;[ \t]*$;;' $cmdfile;
|
sed -i -e "s;${match};${2};" -e 's;^[ \t]*;;' -e 's; *; ;g' -e 's;[ \t]*$;;' $cmdfile;
|
||||||
fi;
|
fi;
|
||||||
if [ -f "$AKHOME/cmdtmp" ]; then
|
if [ -f "$AKHOME/cmdtmp" ]; then
|
||||||
sed -i "s|^cmdline=.*|cmdline=$(cat $cmdfile)|" $split_img/header;
|
sed -i "s|^cmdline=.*|cmdline=$(cat $cmdfile)|" $SPLITIMG/header;
|
||||||
rm -f $cmdfile;
|
rm -f $cmdfile;
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
@@ -780,24 +780,28 @@ patch_ueventd() {
|
|||||||
reset_ak() {
|
reset_ak() {
|
||||||
local current i;
|
local current i;
|
||||||
|
|
||||||
|
# Backwards compatibility for old API
|
||||||
|
[ "$no_block_display" ] && NO_BLOCK_DISPLAY="$no_block_display";
|
||||||
|
unset no_block_display;
|
||||||
|
|
||||||
current=$(dirname $AKHOME/*-files/current);
|
current=$(dirname $AKHOME/*-files/current);
|
||||||
if [ -d "$current" ]; then
|
if [ -d "$current" ]; then
|
||||||
for i in $bootimg $AKHOME/boot-new.img; do
|
for i in $BOOTIMG $AKHOME/boot-new.img; do
|
||||||
[ -e $i ] && cp -af $i $current;
|
[ -e $i ] && cp -af $i $current;
|
||||||
done;
|
done;
|
||||||
for i in $current/*; do
|
for i in $current/*; do
|
||||||
[ -f $i ] && rm -f $AKHOME/$(basename $i);
|
[ -f $i ] && rm -f $AKHOME/$(basename $i);
|
||||||
done;
|
done;
|
||||||
fi;
|
fi;
|
||||||
[ -d $split_img ] && rm -rf $ramdisk;
|
[ -d $SPLITIMG ] && rm -rf $RAMDISK;
|
||||||
rm -rf $bootimg $split_img $AKHOME/*-new* $AKHOME/*-files/current;
|
rm -rf $BOOTIMG $SPLITIMG $AKHOME/*-new* $AKHOME/*-files/current;
|
||||||
|
|
||||||
if [ "$1" == "keep" ]; then
|
if [ "$1" == "keep" ]; then
|
||||||
[ -d $AKHOME/rdtmp ] && mv -f $AKHOME/rdtmp $ramdisk;
|
[ -d $AKHOME/rdtmp ] && mv -f $AKHOME/rdtmp $RAMDISK;
|
||||||
else
|
else
|
||||||
rm -rf $patch $AKHOME/rdtmp;
|
rm -rf $PATCH $AKHOME/rdtmp;
|
||||||
fi;
|
fi;
|
||||||
if [ ! "$no_block_display" ]; then
|
if [ ! "$NO_BLOCK_DISPLAY" ]; then
|
||||||
ui_print " ";
|
ui_print " ";
|
||||||
fi;
|
fi;
|
||||||
setup_ak;
|
setup_ak;
|
||||||
@@ -807,31 +811,42 @@ reset_ak() {
|
|||||||
setup_ak() {
|
setup_ak() {
|
||||||
local blockfiles plistboot plistinit plistreco parttype name part mtdmount mtdpart mtdname target;
|
local blockfiles plistboot plistinit plistreco parttype name part mtdmount mtdpart mtdname target;
|
||||||
|
|
||||||
# slot detection enabled by is_slot_device=1 or auto (from anykernel.sh)
|
# Backwards compatibility for old API
|
||||||
case $is_slot_device in
|
[ "$block" ] && BLOCK="$block";
|
||||||
|
[ "$is_slot_device" ] && IS_SLOT_DEVICE="$is_slot_device";
|
||||||
|
[ "$ramdisk_compression" ] && RAMDISK_COMPRESSION="$ramdisk_compression";
|
||||||
|
[ "$patch_vbmeta_flag" ] && PATCH_VBMETA_FLAG="$patch_vbmeta_flag";
|
||||||
|
[ "$customdd" ] && CUSTOMDD="$customdd";
|
||||||
|
[ "$slot_select" ] && SLOT_SELECT="$slot_select";
|
||||||
|
[ "$no_block_display" ] && NO_BLOCK_DISPLAY="$no_block_display";
|
||||||
|
[ "$no_magisk_check" ] && NO_MAGISK_CHECK="$no_magisk_check";
|
||||||
|
unset block is_slot_device ramdisk_compression patch_vbmeta_flag customdd slot_select no_block_display no_magisk_check;
|
||||||
|
|
||||||
|
# slot detection enabled by IS_SLOT_DEVICE=1 or auto (from anykernel.sh)
|
||||||
|
case $IS_SLOT_DEVICE in
|
||||||
1|auto)
|
1|auto)
|
||||||
slot=$(getprop ro.boot.slot_suffix 2>/dev/null);
|
SLOT=$(getprop ro.boot.slot_suffix 2>/dev/null);
|
||||||
[ "$slot" ] || slot=$(grep -o 'androidboot.slot_suffix=.*$' /proc/cmdline | cut -d\ -f1 | cut -d= -f2);
|
[ "$SLOT" ] || SLOT=$(grep -o 'androidboot.slot_suffix=.*$' /proc/cmdline | cut -d\ -f1 | cut -d= -f2);
|
||||||
if [ ! "$slot" ]; then
|
if [ ! "$SLOT" ]; then
|
||||||
slot=$(getprop ro.boot.slot 2>/dev/null);
|
SLOT=$(getprop ro.boot.slot 2>/dev/null);
|
||||||
[ "$slot" ] || slot=$(grep -o 'androidboot.slot=.*$' /proc/cmdline | cut -d\ -f1 | cut -d= -f2);
|
[ "$SLOT" ] || SLOT=$(grep -o 'androidboot.slot=.*$' /proc/cmdline | cut -d\ -f1 | cut -d= -f2);
|
||||||
[ "$slot" ] && slot=_$slot;
|
[ "$SLOT" ] && SLOT=_$SLOT;
|
||||||
fi;
|
fi;
|
||||||
[ "$slot" == "normal" ] && unset slot;
|
[ "$SLOT" == "normal" ] && unset SLOT;
|
||||||
if [ "$slot" ]; then
|
if [ "$SLOT" ]; then
|
||||||
if [ -d /postinstall/tmp -a ! "$slot_select" ]; then
|
if [ -d /postinstall/tmp -a ! "$SLOT_SELECT" ]; then
|
||||||
slot_select=inactive;
|
SLOT_SELECT=inactive;
|
||||||
fi;
|
fi;
|
||||||
case $slot_select in
|
case $SLOT_SELECT in
|
||||||
inactive)
|
inactive)
|
||||||
case $slot in
|
case $SLOT in
|
||||||
_a) slot=_b;;
|
_a) SLOT=_b;;
|
||||||
_b) slot=_a;;
|
_b) SLOT=_a;;
|
||||||
esac;
|
esac;
|
||||||
;;
|
;;
|
||||||
esac;
|
esac;
|
||||||
fi;
|
fi;
|
||||||
if [ ! "$slot" -a "$is_slot_device" == 1 ]; then
|
if [ ! "$SLOT" -a "$IS_SLOT_DEVICE" == 1 ]; then
|
||||||
abort "Unable to determine active slot. Aborting...";
|
abort "Unable to determine active slot. Aborting...";
|
||||||
fi;
|
fi;
|
||||||
;;
|
;;
|
||||||
@@ -843,7 +858,7 @@ setup_ak() {
|
|||||||
rmdir -p modules patch ramdisk 2>/dev/null;
|
rmdir -p modules patch ramdisk 2>/dev/null;
|
||||||
|
|
||||||
# automate simple multi-partition setup for hdr_v4 boot + init_boot + vendor_kernel_boot (for dtb only until magiskboot supports hdr v4 vendor_ramdisk unpack/repack)
|
# automate simple multi-partition setup for hdr_v4 boot + init_boot + vendor_kernel_boot (for dtb only until magiskboot supports hdr v4 vendor_ramdisk unpack/repack)
|
||||||
if [ -e "/dev/block/bootdevice/by-name/init_boot$slot" -a ! -f init_v4_setup ] && [ -f dtb -o -d vendor_ramdisk -o -d vendor_patch ]; then
|
if [ -e "/dev/block/bootdevice/by-name/init_boot$SLOT" -a ! -f init_v4_setup ] && [ -f dtb -o -d vendor_ramdisk -o -d vendor_patch ]; then
|
||||||
echo "Setting up for simple automatic init_boot flashing..." >&2;
|
echo "Setting up for simple automatic init_boot flashing..." >&2;
|
||||||
(mkdir boot-files;
|
(mkdir boot-files;
|
||||||
mv -f Image* boot-files;
|
mv -f Image* boot-files;
|
||||||
@@ -855,7 +870,7 @@ setup_ak() {
|
|||||||
mv -f vendor_patch vendor_kernel_boot-files/patch) 2>/dev/null;
|
mv -f vendor_patch vendor_kernel_boot-files/patch) 2>/dev/null;
|
||||||
touch init_v4_setup;
|
touch init_v4_setup;
|
||||||
# automate simple multi-partition setup for hdr_v3+ boot + vendor_boot with dtb/dlkm (for v3 only until magiskboot supports hdr v4 vendor_ramdisk unpack/repack)
|
# automate simple multi-partition setup for hdr_v3+ boot + vendor_boot with dtb/dlkm (for v3 only until magiskboot supports hdr v4 vendor_ramdisk unpack/repack)
|
||||||
elif [ -e "/dev/block/bootdevice/by-name/vendor_boot$slot" -a ! -f vendor_v3_setup ] && [ -f dtb -o -d vendor_ramdisk -o -d vendor_patch ]; then
|
elif [ -e "/dev/block/bootdevice/by-name/vendor_boot$SLOT" -a ! -f vendor_v3_setup ] && [ -f dtb -o -d vendor_ramdisk -o -d vendor_patch ]; then
|
||||||
echo "Setting up for simple automatic vendor_boot flashing..." >&2;
|
echo "Setting up for simple automatic vendor_boot flashing..." >&2;
|
||||||
(mkdir boot-files;
|
(mkdir boot-files;
|
||||||
mv -f Image* ramdisk patch boot-files;
|
mv -f Image* ramdisk patch boot-files;
|
||||||
@@ -866,13 +881,13 @@ setup_ak() {
|
|||||||
touch vendor_v3_setup;
|
touch vendor_v3_setup;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
# target block partition detection enabled by block=<partition filename> or auto (from anykernel.sh)
|
# target block partition detection enabled by BLOCK=<partition filename> or auto (from anykernel.sh)
|
||||||
case $block in
|
case $BLOCK in
|
||||||
/dev/*)
|
/dev/*)
|
||||||
if [ "$slot" ] && [ -e "$block$slot" ]; then
|
if [ "$SLOT" ] && [ -e "$BLOCK$SLOT" ]; then
|
||||||
target=$block$slot;
|
target=$BLOCK$SLOT;
|
||||||
elif [ -e "$block" ]; then
|
elif [ -e "$BLOCK" ]; then
|
||||||
target=$block;
|
target=$BLOCK;
|
||||||
fi;
|
fi;
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@@ -880,22 +895,22 @@ setup_ak() {
|
|||||||
plistboot="boot BOOT LNX android_boot bootimg KERN-A kernel KERNEL";
|
plistboot="boot BOOT LNX android_boot bootimg KERN-A kernel KERNEL";
|
||||||
plistreco="recovery RECOVERY SOS android_recovery recovery_ramdisk";
|
plistreco="recovery RECOVERY SOS android_recovery recovery_ramdisk";
|
||||||
plistinit="init_boot ramdisk";
|
plistinit="init_boot ramdisk";
|
||||||
case $block in
|
case $BLOCK in
|
||||||
auto) parttype="$plistinit $plistboot";;
|
auto) parttype="$plistinit $plistboot";;
|
||||||
boot|kernel) parttype=$plistboot;;
|
boot|kernel) parttype=$plistboot;;
|
||||||
recovery|recovery_ramdisk) parttype=$plistreco;;
|
recovery|recovery_ramdisk) parttype=$plistreco;;
|
||||||
init_boot|ramdisk) parttype=$plistinit;;
|
init_boot|ramdisk) parttype=$plistinit;;
|
||||||
*) parttype=$block;;
|
*) parttype=$BLOCK;;
|
||||||
esac;
|
esac;
|
||||||
for name in $parttype; do
|
for name in $parttype; do
|
||||||
for part in $name$slot $name; do
|
for part in $name$SLOT $name; do
|
||||||
if [ "$(grep -w "$part" /proc/mtd 2>/dev/null)" ]; then
|
if [ "$(grep -w "$part" /proc/mtd 2>/dev/null)" ]; then
|
||||||
mtdmount=$(grep -w "$part" /proc/mtd);
|
mtdmount=$(grep -w "$part" /proc/mtd);
|
||||||
mtdpart=$(echo $mtdmount | cut -d\" -f2);
|
mtdpart=$(echo "$mtdmount" | cut -d\" -f2);
|
||||||
if [ "$mtdpart" == "$part" ]; then
|
if [ "$mtdpart" == "$part" ]; then
|
||||||
mtdname=$(echo $mtdmount | cut -d: -f1);
|
mtdname=$(echo "$mtdmount" | cut -d: -f1);
|
||||||
else
|
else
|
||||||
abort "Unable to determine mtd $block partition. Aborting...";
|
abort "Unable to determine mtd $BLOCK partition. Aborting...";
|
||||||
fi;
|
fi;
|
||||||
[ -e /dev/mtd/$mtdname ] && target=/dev/mtd/$mtdname;
|
[ -e /dev/mtd/$mtdname ] && target=/dev/mtd/$mtdname;
|
||||||
elif [ -e /dev/block/by-name/$part ]; then
|
elif [ -e /dev/block/by-name/$part ]; then
|
||||||
@@ -915,17 +930,17 @@ setup_ak() {
|
|||||||
;;
|
;;
|
||||||
esac;
|
esac;
|
||||||
if [ "$target" ]; then
|
if [ "$target" ]; then
|
||||||
block=$(ls $target 2>/dev/null);
|
BLOCK=$(ls $target 2>/dev/null);
|
||||||
else
|
else
|
||||||
abort "Unable to determine $block partition. Aborting...";
|
abort "Unable to determine $BLOCK partition. Aborting...";
|
||||||
fi;
|
fi;
|
||||||
if [ ! "$no_block_display" ]; then
|
if [ ! "$NO_BLOCK_DISPLAY" ]; then
|
||||||
ui_print "$block";
|
ui_print "$BLOCK";
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
# allow multi-partition ramdisk modifying configurations (using reset_ak)
|
# allow multi-partition ramdisk modifying configurations (using reset_ak)
|
||||||
name=$(basename $block | sed -e 's/_a$//' -e 's/_b$//');
|
name=$(basename $BLOCK | sed -e 's/_a$//' -e 's/_b$//');
|
||||||
if [ "$block" ] && [ ! -d "$ramdisk" -a ! -d "$patch" ]; then
|
if [ "$BLOCK" ] && [ ! -d "$RAMDISK" -a ! -d "$PATCH" ]; then
|
||||||
blockfiles=$AKHOME/$name-files;
|
blockfiles=$AKHOME/$name-files;
|
||||||
if [ "$(ls $blockfiles 2>/dev/null)" ]; then
|
if [ "$(ls $blockfiles 2>/dev/null)" ]; then
|
||||||
cp -af $blockfiles/* $AKHOME;
|
cp -af $blockfiles/* $AKHOME;
|
||||||
|
|||||||
Reference in new issue
Block a user