AK3: clean up old style tic

This commit is contained in:
osm0sis committed 2021-01-20 15:02:52 -04:00
1 parent 02329ba5a5
commit 630f926617
1 file changed
+33 -33
+33 -33
View File
@@ -4,7 +4,7 @@
OUTFD=$1;
# set up working directory variables
test "$home" || home=$PWD;
[ "$home" ] || home=$PWD;
bootimg=$home/boot.img;
bin=$home/tools;
patch=$home/patch;
@@ -29,7 +29,7 @@ abort() {
# contains <string> <substring>
contains() {
test "${1#*$2}" != "$1";
[ "${1#*$2}" != "$1" ];
}
# file_getprop <file> <property>
@@ -81,7 +81,7 @@ split_boot() {
else
dd if=$block of=$bootimg $customdd;
fi;
test $? != 0 && dumpfail=1;
[ $? != 0 ] && dumpfail=1;
mkdir -p $split_img;
cd $split_img;
@@ -91,7 +91,7 @@ split_boot() {
$bin/elftool unpack -i $bootimg -o elftool_out;
fi;
$bin/unpackelf -i $bootimg;
test $? != 0 && dumpfail=1;
[ $? != 0 ] && dumpfail=1;
mv -f boot.img-zImage kernel.gz;
mv -f boot.img-ramdisk.cpio.gz ramdisk.cpio.gz;
mv -f boot.img-cmdline cmdline.txt 2>/dev/null;
@@ -118,7 +118,7 @@ split_boot() {
grep "Address:" header | cut -c15- > boot.img-addr;
grep "Point:" header | cut -c15- > boot.img-ep;
$bin/dumpimage -p 0 -o kernel.gz boot-trimmed.img;
test $? != 0 && dumpfail=1;
[ $? != 0 ] && dumpfail=1;
case $(cat boot.img-type) in
Multi) $bin/dumpimage -p 1 -o ramdisk.cpio.gz boot-trimmed.img;;
RAMDisk) mv -f kernel.gz ramdisk.cpio.gz;;
@@ -166,7 +166,7 @@ unpack_ramdisk() {
fi;
fi;
test -d $ramdisk && mv -f $ramdisk $home/rdtmp;
[ -d $ramdisk ] && mv -f $ramdisk $home/rdtmp;
mkdir -p $ramdisk;
chmod 755 $ramdisk;
@@ -208,18 +208,18 @@ repack_ramdisk() {
cd $ramdisk;
find . | cpio -H newc -o > $home/ramdisk-new.cpio;
fi;
test $? != 0 && packfail=1;
[ $? != 0 ] && packfail=1;
cd $home;
$bin/magiskboot cpio ramdisk-new.cpio test;
magisk_patched=$?;
test $((magisk_patched & 3)) -eq 1 && $bin/magiskboot cpio ramdisk-new.cpio "extract .backup/.magisk $split_img/.magisk";
[ $((magisk_patched & 3)) -eq 1 ] && $bin/magiskboot cpio ramdisk-new.cpio "extract .backup/.magisk $split_img/.magisk";
if [ "$comp" ]; then
$bin/magiskboot compress=$comp ramdisk-new.cpio;
if [ $? != 0 ]; then
echo "Attempting ramdisk repack with busybox $comp..." >&2;
$comp -9c ramdisk-new.cpio > ramdisk-new.cpio.$comp;
test $? != 0 && packfail=1;
[ $? != 0 ] && packfail=1;
rm -f ramdisk-new.cpio;
fi;
fi;
@@ -285,7 +285,7 @@ flash_boot() {
cd $split_img;
if [ -f "$bin/mkimage" ]; then
test "$comp" == "uncompressed" && comp=none;
[ "$comp" == "uncompressed" ] && comp=none;
part0=$kernel;
case $type in
Multi) part1=":$ramdisk";;
@@ -293,8 +293,8 @@ flash_boot() {
esac;
$bin/mkimage -A $arch -O $os -T $type -C $comp -a $addr -e $ep -n "$name" -d $part0$part1 $home/boot-new.img;
elif [ -f "$bin/elftool" ]; then
test "$dt" && dt="$dt,rpm";
test -f cmdline.txt && cmdline="cmdline.txt@cmdline";
[ "$dt" ] && dt="$dt,rpm";
[ -f cmdline.txt ] && cmdline="cmdline.txt@cmdline";
$bin/elftool pack -o $home/boot-new.img header=elftool_out/header $kernel $ramdisk,ramdisk $dt $cmdline;
elif [ -f "$bin/mboot" ]; then
cp -f $kernel kernel;
@@ -303,14 +303,14 @@ flash_boot() {
elif [ -f "$bin/rkcrc" ]; then
$bin/rkcrc -k $ramdisk $home/boot-new.img;
elif [ -f "$bin/mkbootimg" -a -f "$bin/unpackelf" -a -f boot.img-base ]; then
test "$dt" && dt="--dt $dt";
[ "$dt" ] && dt="--dt $dt";
$bin/mkbootimg --kernel $kernel --ramdisk $ramdisk --cmdline "$cmdline" --base $home --pagesize $pagesize --kernel_offset $kernel_offset --ramdisk_offset $ramdisk_offset --tags_offset "$tags_offset" $dt --output $home/boot-new.img;
else
test "$kernel" && cp -f $kernel kernel;
test "$ramdisk" && cp -f $ramdisk ramdisk.cpio;
test "$dt" -a -f extra && cp -f $dt extra;
[ "$kernel" ] && cp -f $kernel kernel;
[ "$ramdisk" ] && cp -f $ramdisk ramdisk.cpio;
[ "$dt" -a -f extra ] && cp -f $dt extra;
for i in dtb recovery_dtbo; do
test "$(eval echo \$$i)" -a -f $i && cp -f $(eval echo \$$i) $i;
[ "$(eval echo \$$i)" -a -f $i ] && cp -f $(eval echo \$$i) $i;
done;
case $kernel in
*Image*)
@@ -338,11 +338,11 @@ flash_boot() {
fi;
mv -f kernel.$comp kernel;
fi;
test ! -f .magisk && $bin/magiskboot cpio ramdisk.cpio "extract .backup/.magisk .magisk";
[ ! -f .magisk ] && $bin/magiskboot cpio ramdisk.cpio "extract .backup/.magisk .magisk";
export $(cat .magisk);
test $((magisk_patched & 8)) -ne 0 && export TWOSTAGEINIT=true;
[ $((magisk_patched & 8)) -ne 0 ] && export TWOSTAGEINIT=true;
for fdt in dtb extra kernel_dtb recovery_dtbo; do
test -f $fdt && $bin/magiskboot dtb $fdt patch;
[ -f $fdt ] && $bin/magiskboot dtb $fdt patch;
done;
else
case $kernel in
@@ -367,7 +367,7 @@ flash_boot() {
echo "Signing with CHROMEOS..." >&2;
$bin/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;
test $? != 0 && signfail=1;
[ $? != 0 ] && signfail=1;
fi;
if [ -f "$bin/boot_signer-dexed.jar" -a -d "$bin/avb" ]; then
pk8=$(ls $bin/avb/*.pk8);
@@ -448,14 +448,14 @@ write_boot() {
### file editing functions:
# backup_file <file>
backup_file() { test ! -f $1~ && cp -fp $1 $1~; }
backup_file() { [ ! -f $1~ ] && cp -fp $1 $1~; }
# restore_file <file>
restore_file() { test -f $1~ && cp -fp $1~ $1; rm -f $1~; }
restore_file() { [ -f $1~ ] && cp -fp $1~ $1; rm -f $1~; }
# replace_string <file> <if search string> <original string> <replacement string> <scope>
replace_string() {
test "$5" == "global" && local scope=g;
[ "$5" == "global" ] && local scope=g;
if ! grep -q "$2" $1; then
sed -i "s;${3};${4};${scope}" $1;
fi;
@@ -475,7 +475,7 @@ replace_section() {
for end in $(grep -n "$endstr" $1 | cut -d: -f1) $last; do
if [ "$end" ] && [ "$begin" -lt "$end" ]; then
sed -i "${begin},${end}d" $1;
test "$end" == "$last" && echo >> $1;
[ "$end" == "$last" ] && echo >> $1;
sed -i "${begin}s;^;${4}\n;" $1;
break;
fi;
@@ -648,14 +648,14 @@ reset_ak() {
if [ -d "$current" ]; then
rm -rf $current/ramdisk;
for i in $bootimg boot-new.img; do
test -e $i && cp -af $i $current;
[ -e $i ] && cp -af $i $current;
done;
fi;
test -d $split_img && rm -rf $ramdisk;
[ -d $split_img ] && rm -rf $ramdisk;
rm -rf $bootimg $split_img $home/*-new* $home/*-files/current;
if [ "$1" == "keep" ]; then
test -d $home/rdtmp && mv -f $home/rdtmp $ramdisk;
[ -d $home/rdtmp ] && mv -f $home/rdtmp $ramdisk;
else
rm -rf $patch $home/rdtmp;
fi;
@@ -681,11 +681,11 @@ setup_ak() {
case $is_slot_device in
1|auto)
slot=$(getprop ro.boot.slot_suffix 2>/dev/null);
test "$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
slot=$(getprop ro.boot.slot 2>/dev/null);
test "$slot" || slot=$(grep -o 'androidboot.slot=.*$' /proc/cmdline | cut -d\ -f1 | cut -d= -f2);
test "$slot" && slot=_$slot;
[ "$slot" ] || slot=$(grep -o 'androidboot.slot=.*$' /proc/cmdline | cut -d\ -f1 | cut -d= -f2);
[ "$slot" ] && slot=_$slot;
fi;
if [ "$slot" ]; then
if [ -d /postinstall/tmp -a ! "$slot_select" ]; then
@@ -740,7 +740,7 @@ setup_ak() {
elif [ -e /dev/$part ]; then
target=/dev/$part;
fi;
test "$target" && break 2;
[ "$target" ] && break 2;
done;
done;
if [ "$target" ]; then
@@ -751,7 +751,7 @@ setup_ak() {
;;
*)
if [ "$slot" ]; then
test -e "$block$slot" && block=$block$slot;
[ -e "$block$slot" ] && block=$block$slot;
fi;
;;
esac;