AK3+Backend: use busybox as much as possible + OLD_PATH for exceptions
This commit is contained in:
3 files changed
+122
-119
No files matched your search
@@ -2,8 +2,8 @@
|
|||||||
# AnyKernel3 Backend (DO NOT CHANGE)
|
# AnyKernel3 Backend (DO NOT CHANGE)
|
||||||
# osm0sis @ xda-developers
|
# osm0sis @ xda-developers
|
||||||
|
|
||||||
OUTFD=/proc/self/fd/$2;
|
export OUTFD=$2;
|
||||||
ZIPFILE="$3";
|
export ZIPFILE="$3";
|
||||||
|
|
||||||
BOOTMODE=false;
|
BOOTMODE=false;
|
||||||
ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true;
|
ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true;
|
||||||
@@ -11,9 +11,7 @@ $BOOTMODE || ps -A 2>/dev/null | grep zygote | grep -v grep >/dev/null && BOOTMO
|
|||||||
|
|
||||||
DIR=/sdcard;
|
DIR=/sdcard;
|
||||||
$BOOTMODE || DIR=$(dirname "$ZIPFILE");
|
$BOOTMODE || DIR=$(dirname "$ZIPFILE");
|
||||||
case $DIR in
|
[ $DIR == "/sideload" ] && DIR=/tmp;
|
||||||
/sideload) DIR=/tmp;;
|
|
||||||
esac;
|
|
||||||
|
|
||||||
[ -d /postinstall/tmp ] && POSTINSTALL=/postinstall;
|
[ -d /postinstall/tmp ] && POSTINSTALL=/postinstall;
|
||||||
[ "$AKHOME" ] || AKHOME=$POSTINSTALL/tmp/anykernel;
|
[ "$AKHOME" ] || AKHOME=$POSTINSTALL/tmp/anykernel;
|
||||||
@@ -22,85 +20,85 @@ esac;
|
|||||||
ui_print() {
|
ui_print() {
|
||||||
until [ ! "$1" ]; do
|
until [ ! "$1" ]; do
|
||||||
echo "ui_print $1
|
echo "ui_print $1
|
||||||
ui_print" >> $OUTFD;
|
ui_print" >> /proc/self/fd/$OUTFD;
|
||||||
shift;
|
shift;
|
||||||
done;
|
done;
|
||||||
}
|
}
|
||||||
ui_printfile() {
|
ui_printfile() {
|
||||||
local line losrpad;
|
local line losrpad;
|
||||||
$BOOTMODE || [ -e /twres ] || losrpad='| '; # work around LOS Recovery eating leading whitespace
|
$BOOTMODE || [ -e /twres ] || losrpad='| '; # work around LOS Recovery eating leading whitespace
|
||||||
while IFS='' read -r line || $BB [[ -n "$line" ]]; do
|
while IFS='' read -r line || [[ -n "$line" ]]; do
|
||||||
ui_print "$losrpad$line";
|
ui_print "$losrpad$line";
|
||||||
done < $1;
|
done < $1;
|
||||||
}
|
}
|
||||||
show_progress() { echo "progress $1 $2" >> $OUTFD; }
|
show_progress() { echo "progress $1 $2" >> /proc/self/fd/$OUTFD; }
|
||||||
file_getprop() { $BB grep "^$2=" "$1" | $BB tail -n1 | $BB cut -d= -f2-; }
|
file_getprop() { grep "^$2=" "$1" | tail -n1 | cut -d= -f2-; }
|
||||||
find_slot() {
|
find_slot() {
|
||||||
local slot=$(getprop ro.boot.slot_suffix 2>/dev/null);
|
local slot=$(getprop ro.boot.slot_suffix 2>/dev/null);
|
||||||
[ "$slot" ] || slot=$($BB grep -o 'androidboot.slot_suffix=.*$' /proc/cmdline | $BB cut -d\ -f1 | $BB 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=$($BB grep -o 'androidboot.slot=.*$' /proc/cmdline | $BB cut -d\ -f1 | $BB 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;
|
||||||
[ "$slot" ] && echo "$slot";
|
[ "$slot" ] && echo "$slot";
|
||||||
}
|
}
|
||||||
setup_mountpoint() {
|
setup_mountpoint() {
|
||||||
[ -L $1 ] && $BB mv -f $1 ${1}_link;
|
[ -L $1 ] && mv -f $1 ${1}_link;
|
||||||
if [ ! -d $1 ]; then
|
if [ ! -d $1 ]; then
|
||||||
$BB rm -f $1;
|
rm -f $1;
|
||||||
$BB mkdir -p $1;
|
mkdir -p $1;
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
is_mounted() { $BB mount | $BB grep -q " $1 "; }
|
is_mounted() { mount | grep -q " $1 "; }
|
||||||
mount_apex() {
|
mount_apex() {
|
||||||
[ -d /system_root/system/apex ] || return 1;
|
[ -d /system_root/system/apex ] || return 1;
|
||||||
local apex dest loop minorx num var;
|
local apex dest loop minorx num var;
|
||||||
setup_mountpoint /apex;
|
setup_mountpoint /apex;
|
||||||
$BB mount -t tmpfs tmpfs /apex -o mode=755 && $BB touch /apex/apextmp;
|
mount -t tmpfs tmpfs /apex -o mode=755 && touch /apex/apextmp;
|
||||||
minorx=1;
|
minorx=1;
|
||||||
[ -e /dev/block/loop1 ] && minorx=$($BB ls -l /dev/block/loop1 | $BB awk '{ print $6 }');
|
[ -e /dev/block/loop1 ] && minorx=$(ls -l /dev/block/loop1 | awk '{ print $6 }');
|
||||||
num=0;
|
num=0;
|
||||||
for apex in /system_root/system/apex/*; do
|
for apex in /system_root/system/apex/*; do
|
||||||
dest=/apex/$($BB basename $apex | $BB sed -E -e 's;\.apex$|\.capex$;;' -e 's;\.current$|\.release$;;');
|
dest=/apex/$(basename $apex | sed -E -e 's;\.apex$|\.capex$;;' -e 's;\.current$|\.release$;;');
|
||||||
$BB mkdir -p $dest;
|
mkdir -p $dest;
|
||||||
case $apex in
|
case $apex in
|
||||||
*.apex|*.capex)
|
*.apex|*.capex)
|
||||||
$BB unzip -qo $apex original_apex -d /apex;
|
unzip -qo $apex original_apex -d /apex;
|
||||||
[ -f /apex/original_apex ] && apex=/apex/original_apex;
|
[ -f /apex/original_apex ] && apex=/apex/original_apex;
|
||||||
$BB unzip -qo $apex apex_payload.img -d /apex;
|
unzip -qo $apex apex_payload.img -d /apex;
|
||||||
$BB mv -f /apex/original_apex $dest.apex 2>/dev/null;
|
mv -f /apex/original_apex $dest.apex 2>/dev/null;
|
||||||
$BB mv -f /apex/apex_payload.img $dest.img;
|
mv -f /apex/apex_payload.img $dest.img;
|
||||||
$BB mount -t ext4 -o ro,noatime $dest.img $dest 2>/dev/null && echo "$dest (direct)" >&2;
|
mount -t ext4 -o ro,noatime $dest.img $dest 2>/dev/null && echo "$dest (direct)" >&2;
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
while [ $num -lt 64 ]; do
|
while [ $num -lt 64 ]; do
|
||||||
loop=/dev/block/loop$num;
|
loop=/dev/block/loop$num;
|
||||||
[ -e $loop ] || $BB mknod $loop b 7 $((num * minorx));
|
[ -e $loop ] || mknod $loop b 7 $((num * minorx));
|
||||||
$BB losetup $loop $dest.img 2>/dev/null;
|
losetup $loop $dest.img 2>/dev/null;
|
||||||
num=$((num + 1));
|
num=$((num + 1));
|
||||||
$BB losetup $loop | $BB grep -q $dest.img && break;
|
losetup $loop | grep -q $dest.img && break;
|
||||||
done;
|
done;
|
||||||
$BB mount -t ext4 -o ro,loop,noatime $loop $dest && echo "$dest (loop)" >&2;
|
mount -t ext4 -o ro,loop,noatime $loop $dest && echo "$dest (loop)" >&2;
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
$BB losetup -d $loop 2>/dev/null;
|
losetup -d $loop 2>/dev/null;
|
||||||
fi;
|
fi;
|
||||||
fi;
|
fi;
|
||||||
;;
|
;;
|
||||||
*) $BB mount -o bind $apex $dest && echo "$dest (bind)" >&2;;
|
*) mount -o bind $apex $dest && echo "$dest (bind)" >&2;;
|
||||||
esac;
|
esac;
|
||||||
done;
|
done;
|
||||||
for var in $($BB grep -o 'export .* /.*' /system_root/init.environ.rc | $BB awk '{ print $2 }'); do
|
for var in $(grep -o 'export .* /.*' /system_root/init.environ.rc | awk '{ print $2 }'); do
|
||||||
eval OLD_${var}=\$$var;
|
eval OLD_${var}=\$$var;
|
||||||
done;
|
done;
|
||||||
$($BB grep -o 'export .* /.*' /system_root/init.environ.rc | $BB sed 's; /;=/;'); unset export;
|
$(grep -o 'export .* /.*' /system_root/init.environ.rc | sed 's; /;=/;'); unset export;
|
||||||
$BB touch /apex/apexak3;
|
touch /apex/apexak3;
|
||||||
}
|
}
|
||||||
umount_apex() {
|
umount_apex() {
|
||||||
[ -f /apex/apexak3 ] || return 1;
|
[ -f /apex/apexak3 ] || return 1;
|
||||||
echo "Unmounting apex..." >&2;
|
echo "Unmounting apex..." >&2;
|
||||||
local dest loop var;
|
local dest loop var;
|
||||||
for var in $($BB grep -o 'export .* /.*' /system_root/init.environ.rc 2>/dev/null | $BB awk '{ print $2 }'); do
|
for var in $(grep -o 'export .* /.*' /system_root/init.environ.rc 2>/dev/null | awk '{ print $2 }'); do
|
||||||
if [ "$(eval echo \$OLD_$var)" ]; then
|
if [ "$(eval echo \$OLD_$var)" ]; then
|
||||||
eval $var=\$OLD_${var};
|
eval $var=\$OLD_${var};
|
||||||
else
|
else
|
||||||
@@ -108,62 +106,62 @@ umount_apex() {
|
|||||||
fi;
|
fi;
|
||||||
unset OLD_${var};
|
unset OLD_${var};
|
||||||
done;
|
done;
|
||||||
for dest in $($BB find /apex -type d -mindepth 1 -maxdepth 1); do
|
for dest in $(find /apex -type d -mindepth 1 -maxdepth 1); do
|
||||||
loop=$($BB mount | $BB grep $dest | $BB grep loop | $BB cut -d\ -f1);
|
loop=$(mount | grep $dest | grep loop | cut -d\ -f1);
|
||||||
$BB umount -l $dest;
|
umount -l $dest;
|
||||||
[ "$loop" ] && $BB losetup -d $loop;
|
[ "$loop" ] && losetup -d $loop;
|
||||||
done;
|
done;
|
||||||
[ -f /apex/apextmp ] && $BB umount /apex;
|
[ -f /apex/apextmp ] && umount /apex;
|
||||||
$BB rm -rf /apex/apexak3 /apex 2>/dev/null;
|
rm -rf /apex/apexak3 /apex 2>/dev/null;
|
||||||
}
|
}
|
||||||
mount_all() {
|
mount_all() {
|
||||||
local byname mount slot system;
|
local byname mount slot system;
|
||||||
echo "Mounting..." >&2;
|
echo "Mounting..." >&2;
|
||||||
byname=bootdevice/by-name;
|
byname=bootdevice/by-name;
|
||||||
[ -d /dev/block/$byname ] || byname=$($BB find /dev/block/platform -type d -name by-name 2>/dev/null | $BB head -n1 | $BB cut -d/ -f4-);
|
[ -d /dev/block/$byname ] || byname=$(find /dev/block/platform -type d -name by-name 2>/dev/null | head -n1 | cut -d/ -f4-);
|
||||||
[ -e /dev/block/$byname/super -a -d /dev/block/mapper ] && byname=mapper;
|
[ -e /dev/block/$byname/super -a -d /dev/block/mapper ] && byname=mapper;
|
||||||
[ -e /dev/block/$byname/system ] || slot=$(find_slot);
|
[ -e /dev/block/$byname/system ] || slot=$(find_slot);
|
||||||
for mount in /cache /data /metadata /persist; do
|
for mount in /cache /data /metadata /persist; do
|
||||||
if ! is_mounted $mount; then
|
if ! is_mounted $mount; then
|
||||||
$BB mount $mount 2>/dev/null && echo "$mount (fstab)" >&2 && UMOUNTLIST="$UMOUNTLIST $mount";
|
mount $mount 2>/dev/null && echo "$mount (fstab)" >&2 && UMOUNTLIST="$UMOUNTLIST $mount";
|
||||||
if [ $? != 0 -a -e /dev/block/$byname$mount ]; then
|
if [ $? != 0 -a -e /dev/block/$byname$mount ]; then
|
||||||
setup_mountpoint $mount;
|
setup_mountpoint $mount;
|
||||||
$BB mount -o ro -t auto /dev/block/$byname$mount $mount && echo "$mount (direct)" >&2 && UMOUNTLIST="$UMOUNTLIST $mount";
|
mount -o ro -t auto /dev/block/$byname$mount $mount && echo "$mount (direct)" >&2 && UMOUNTLIST="$UMOUNTLIST $mount";
|
||||||
fi;
|
fi;
|
||||||
fi;
|
fi;
|
||||||
done;
|
done;
|
||||||
setup_mountpoint $ANDROID_ROOT;
|
setup_mountpoint $ANDROID_ROOT;
|
||||||
if ! is_mounted $ANDROID_ROOT; then
|
if ! is_mounted $ANDROID_ROOT; then
|
||||||
$BB mount -o ro -t auto $ANDROID_ROOT 2>/dev/null && echo "$ANDROID_ROOT (\$ANDROID_ROOT)" >&2;
|
mount -o ro -t auto $ANDROID_ROOT 2>/dev/null && echo "$ANDROID_ROOT (\$ANDROID_ROOT)" >&2;
|
||||||
fi;
|
fi;
|
||||||
case $ANDROID_ROOT in
|
case $ANDROID_ROOT in
|
||||||
/system_root) setup_mountpoint /system;;
|
/system_root) setup_mountpoint /system;;
|
||||||
/system)
|
/system)
|
||||||
if ! is_mounted /system && ! is_mounted /system_root; then
|
if ! is_mounted /system && ! is_mounted /system_root; then
|
||||||
setup_mountpoint /system_root;
|
setup_mountpoint /system_root;
|
||||||
$BB mount -o ro -t auto /system_root && echo "/system_root (fstab)" >&2;
|
mount -o ro -t auto /system_root && echo "/system_root (fstab)" >&2;
|
||||||
elif [ -f /system/system/build.prop ]; then
|
elif [ -f /system/system/build.prop ]; then
|
||||||
setup_mountpoint /system_root;
|
setup_mountpoint /system_root;
|
||||||
$BB mount --move /system /system_root && echo "/system_root (moved)" >&2;
|
mount --move /system /system_root && echo "/system_root (moved)" >&2;
|
||||||
fi;
|
fi;
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
($BB umount /system;
|
(umount /system;
|
||||||
$BB umount -l /system) 2>/dev/null;
|
umount -l /system) 2>/dev/null;
|
||||||
$BB mount -o ro -t auto /dev/block/$byname/system$slot /system_root && echo "/system_root (direct)" >&2;
|
mount -o ro -t auto /dev/block/$byname/system$slot /system_root && echo "/system_root (direct)" >&2;
|
||||||
fi;
|
fi;
|
||||||
;;
|
;;
|
||||||
esac;
|
esac;
|
||||||
[ -f /system_root/system/build.prop ] && system=/system;
|
[ -f /system_root/system/build.prop ] && system=/system;
|
||||||
for mount in /vendor /product /system_ext; do
|
for mount in /vendor /product /system_ext; do
|
||||||
$BB mount -o ro -t auto $mount 2>/dev/null && echo "$mount (fstab)" >&2;
|
mount -o ro -t auto $mount 2>/dev/null && echo "$mount (fstab)" >&2;
|
||||||
if [ $? != 0 ] && [ -L /system$mount -o -L /system_root$system$mount ]; then
|
if [ $? != 0 ] && [ -L /system$mount -o -L /system_root$system$mount ]; then
|
||||||
setup_mountpoint $mount;
|
setup_mountpoint $mount;
|
||||||
$BB mount -o ro -t auto /dev/block/$byname$mount$slot $mount && echo "$mount (direct)" >&2;
|
mount -o ro -t auto /dev/block/$byname$mount$slot $mount && echo "$mount (direct)" >&2;
|
||||||
fi;
|
fi;
|
||||||
done;
|
done;
|
||||||
if is_mounted /system_root; then
|
if is_mounted /system_root; then
|
||||||
mount_apex;
|
mount_apex;
|
||||||
$BB mount -o bind /system_root$system /system && echo "/system (bind)" >&2;
|
mount -o bind /system_root$system /system && echo "/system (bind)" >&2;
|
||||||
fi;
|
fi;
|
||||||
echo " " >&2;
|
echo " " >&2;
|
||||||
}
|
}
|
||||||
@@ -171,28 +169,28 @@ umount_all() {
|
|||||||
local mount;
|
local mount;
|
||||||
echo "Unmounting..." >&2;
|
echo "Unmounting..." >&2;
|
||||||
(if [ ! -d /postinstall/tmp ]; then
|
(if [ ! -d /postinstall/tmp ]; then
|
||||||
$BB umount /system;
|
umount /system;
|
||||||
$BB umount -l /system;
|
umount -l /system;
|
||||||
fi) 2>/dev/null;
|
fi) 2>/dev/null;
|
||||||
umount_apex;
|
umount_apex;
|
||||||
(if [ ! -d /postinstall/tmp ]; then
|
(if [ ! -d /postinstall/tmp ]; then
|
||||||
$BB umount /system_root;
|
umount /system_root;
|
||||||
$BB umount -l /system_root;
|
umount -l /system_root;
|
||||||
fi;
|
fi;
|
||||||
umount /vendor; # busybox umount /vendor breaks recovery on some hacky devices
|
PATH="$OLD_PATH" umount /vendor; # busybox umount /vendor breaks recovery on some hacky devices
|
||||||
umount -l /vendor;
|
PATH="$OLD_PATH" umount -l /vendor;
|
||||||
for mount in /mnt/system /mnt/vendor /product /mnt/product /system_ext /mnt/system_ext $UMOUNTLIST; do
|
for mount in /mnt/system /mnt/vendor /product /mnt/product /system_ext /mnt/system_ext $UMOUNTLIST; do
|
||||||
$BB umount $mount;
|
umount $mount;
|
||||||
$BB umount -l $mount;
|
umount -l $mount;
|
||||||
done) 2>/dev/null;
|
done) 2>/dev/null;
|
||||||
}
|
}
|
||||||
setup_env() {
|
setup_env() {
|
||||||
$BOOTMODE && return 1;
|
$BOOTMODE && return 1;
|
||||||
$BB mount -o bind /dev/urandom /dev/random;
|
mount -o bind /dev/urandom /dev/random;
|
||||||
if [ -L /etc ]; then
|
if [ -L /etc ]; then
|
||||||
setup_mountpoint /etc;
|
setup_mountpoint /etc;
|
||||||
$BB cp -af /etc_link/* /etc;
|
cp -af /etc_link/* /etc;
|
||||||
$BB sed -i 's; / ; /system_root ;' /etc/fstab;
|
sed -i 's; / ; /system_root ;' /etc/fstab;
|
||||||
fi;
|
fi;
|
||||||
umount_all;
|
umount_all;
|
||||||
mount_all;
|
mount_all;
|
||||||
@@ -220,7 +218,7 @@ setup_env() {
|
|||||||
}
|
}
|
||||||
elif [ ! "$(getprop ro.build.type 2>/dev/null)" ]; then
|
elif [ ! "$(getprop ro.build.type 2>/dev/null)" ]; then
|
||||||
getprop() {
|
getprop() {
|
||||||
($(which getprop) | $BB grep "$1" | $BB cut -d[ -f3 | $BB cut -d] -f1) 2>/dev/null;
|
($(which getprop) | grep "$1" | cut -d[ -f3 | cut -d] -f1) 2>/dev/null;
|
||||||
}
|
}
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
@@ -232,20 +230,20 @@ restore_env() {
|
|||||||
[ "$OLD_LD_PRE" ] && export LD_PRELOAD=$OLD_LD_PRE;
|
[ "$OLD_LD_PRE" ] && export LD_PRELOAD=$OLD_LD_PRE;
|
||||||
[ "$OLD_LD_CFG" ] && export LD_CONFIG_FILE=$OLD_LD_CFG;
|
[ "$OLD_LD_CFG" ] && export LD_CONFIG_FILE=$OLD_LD_CFG;
|
||||||
unset OLD_LD_PATH OLD_LD_PRE OLD_LD_CFG;
|
unset OLD_LD_PATH OLD_LD_PRE OLD_LD_CFG;
|
||||||
$BB sleep 1;
|
sleep 1;
|
||||||
umount_all;
|
umount_all;
|
||||||
[ -L /etc_link ] && $BB rm -rf /etc/*;
|
[ -L /etc_link ] && rm -rf /etc/*;
|
||||||
(for dir in /etc /apex /system_root /system /vendor /product /system_ext /metadata /persist; do
|
(for dir in /etc /apex /system_root /system /vendor /product /system_ext /metadata /persist; do
|
||||||
if [ -L "${dir}_link" ]; then
|
if [ -L "${dir}_link" ]; then
|
||||||
rmdir $dir;
|
rmdir $dir;
|
||||||
$BB mv -f ${dir}_link $dir;
|
mv -f ${dir}_link $dir;
|
||||||
fi;
|
fi;
|
||||||
done;
|
done;
|
||||||
$BB umount -l /dev/random) 2>/dev/null;
|
umount -l /dev/random) 2>/dev/null;
|
||||||
}
|
}
|
||||||
debugging() {
|
debugging() {
|
||||||
local debug log path;
|
local debug log path;
|
||||||
case $($BB basename "$ZIPFILE" .zip) in
|
case $(basename "$ZIPFILE" .zip) in
|
||||||
*-debugging) debug=1;;
|
*-debugging) debug=1;;
|
||||||
esac;
|
esac;
|
||||||
for path in /tmp /cache /metadata /persist; do
|
for path in /tmp /cache /metadata /persist; do
|
||||||
@@ -254,7 +252,7 @@ debugging() {
|
|||||||
if [ "$debug" ]; then
|
if [ "$debug" ]; then
|
||||||
ui_print " " "Creating debugging archive in $DIR...";
|
ui_print " " "Creating debugging archive in $DIR...";
|
||||||
[ -f /tmp/recovery.log ] && log=/tmp/recovery.log;
|
[ -f /tmp/recovery.log ] && log=/tmp/recovery.log;
|
||||||
PATH="$AKHOME/bin:$PATH" $BB tar -czf "$DIR/anykernel3-$(date +%Y-%m-%d_%H%M%S)-debug.tgz" $AKHOME $log;
|
tar -czf "$DIR/anykernel3-$(date +%Y-%m-%d_%H%M%S)-debug.tgz" $AKHOME $log;
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
cleanup() {
|
cleanup() {
|
||||||
@@ -278,7 +276,7 @@ do_devicecheck() {
|
|||||||
product=$(getprop ro.build.product 2>/dev/null);
|
product=$(getprop ro.build.product 2>/dev/null);
|
||||||
vendordevice=$(getprop ro.product.vendor.device 2>/dev/null);
|
vendordevice=$(getprop ro.product.vendor.device 2>/dev/null);
|
||||||
vendorproduct=$(getprop ro.vendor.product.device 2>/dev/null);
|
vendorproduct=$(getprop ro.vendor.product.device 2>/dev/null);
|
||||||
for testname in $($BB grep '^device.name.*=' anykernel.sh | $BB cut -d= -f2-); do
|
for testname in $(grep '^device.name.*=' anykernel.sh | cut -d= -f2-); do
|
||||||
for devicename in $device $product $vendordevice $vendorproduct; do
|
for devicename in $device $product $vendordevice $vendorproduct; do
|
||||||
if [ "$devicename" == "$testname" ]; then
|
if [ "$devicename" == "$testname" ]; then
|
||||||
ui_print "$testname" " ";
|
ui_print "$testname" " ";
|
||||||
@@ -292,9 +290,9 @@ do_devicecheck() {
|
|||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
int2ver() {
|
int2ver() {
|
||||||
if $BB [ "$1" -eq "$1" ] 2>/dev/null; then
|
if [ "$1" -eq "$1" ] 2>/dev/null; then
|
||||||
echo "$1.0.0";
|
echo "$1.0.0";
|
||||||
elif [ ! "$(echo "$1" | $BB cut -d. -f3)" ]; then
|
elif [ ! "$(echo "$1" | cut -d. -f3)" ]; then
|
||||||
echo "$1.0";
|
echo "$1.0";
|
||||||
else
|
else
|
||||||
echo "$1";
|
echo "$1";
|
||||||
@@ -304,17 +302,17 @@ do_versioncheck() {
|
|||||||
[ "$(file_getprop anykernel.sh supported.versions)" ] || return 1;
|
[ "$(file_getprop anykernel.sh supported.versions)" ] || return 1;
|
||||||
local android_ver hi_ver lo_ver parsed_ver supported supported_ver;
|
local android_ver hi_ver lo_ver parsed_ver supported supported_ver;
|
||||||
ui_print "Checking Android version...";
|
ui_print "Checking Android version...";
|
||||||
supported_ver=$(file_getprop anykernel.sh supported.versions | $BB tr -d '[:space:]');
|
supported_ver=$(file_getprop anykernel.sh supported.versions | tr -d '[:space:]');
|
||||||
android_ver=$(file_getprop /system/build.prop ro.build.version.release);
|
android_ver=$(file_getprop /system/build.prop ro.build.version.release);
|
||||||
parsed_ver=$(int2ver $android_ver);
|
parsed_ver=$(int2ver $android_ver);
|
||||||
if echo $supported_ver | $BB grep -q '-'; then
|
if echo $supported_ver | grep -q '-'; then
|
||||||
lo_ver=$(int2ver "$(echo $supported_ver | $BB cut -d- -f1)");
|
lo_ver=$(int2ver "$(echo $supported_ver | cut -d- -f1)");
|
||||||
hi_ver=$(int2ver "$(echo $supported_ver | $BB cut -d- -f2)");
|
hi_ver=$(int2ver "$(echo $supported_ver | cut -d- -f2)");
|
||||||
if echo -e "$hi_ver\n$lo_ver\n$parsed_ver" | $BB sort -g | $BB grep -n "$parsed_ver" | $BB grep -q '^2:'; then
|
if echo -e "$hi_ver\n$lo_ver\n$parsed_ver" | sort -g | grep -n "$parsed_ver" | grep -q '^2:'; then
|
||||||
supported=1;
|
supported=1;
|
||||||
fi;
|
fi;
|
||||||
else
|
else
|
||||||
for ver in $(echo $supported_ver | $BB sed 's;,; ;g'); do
|
for ver in $(echo $supported_ver | sed 's;,; ;g'); do
|
||||||
if [ "$(int2ver $ver)" == "$parsed_ver" ]; then
|
if [ "$(int2ver $ver)" == "$parsed_ver" ]; then
|
||||||
supported=1;
|
supported=1;
|
||||||
break;
|
break;
|
||||||
@@ -331,37 +329,37 @@ do_levelcheck() {
|
|||||||
[ "$(file_getprop anykernel.sh supported.patchlevels)" ] || return 1;
|
[ "$(file_getprop anykernel.sh supported.patchlevels)" ] || return 1;
|
||||||
local android_lvl hi_lvl lo_lvl parsed_lvl supported_lvl;
|
local android_lvl hi_lvl lo_lvl parsed_lvl supported_lvl;
|
||||||
ui_print "Checking Android security patch level...";
|
ui_print "Checking Android security patch level...";
|
||||||
supported_lvl=$(file_getprop anykernel.sh supported.patchlevels | $BB grep -oE '[0-9]{4}-[0-9]{2}|-');
|
supported_lvl=$(file_getprop anykernel.sh supported.patchlevels | grep -oE '[0-9]{4}-[0-9]{2}|-');
|
||||||
android_lvl=$(file_getprop /system/build.prop ro.build.version.security_patch);
|
android_lvl=$(file_getprop /system/build.prop ro.build.version.security_patch);
|
||||||
parsed_lvl=$(echo $android_lvl | $BB grep -oE '[0-9]{4}-[0-9]{2}');
|
parsed_lvl=$(echo $android_lvl | grep -oE '[0-9]{4}-[0-9]{2}');
|
||||||
if echo $supported_lvl | $BB grep -q '^\-'; then
|
if echo $supported_lvl | grep -q '^\-'; then
|
||||||
lo_lvl=0000-00;
|
lo_lvl=0000-00;
|
||||||
hi_lvl=$(echo $supported_lvl | $BB awk '{ print $2 }');
|
hi_lvl=$(echo $supported_lvl | awk '{ print $2 }');
|
||||||
elif echo $supported_lvl | $BB grep -q ' - '; then
|
elif echo $supported_lvl | grep -q ' - '; then
|
||||||
lo_lvl=$(echo $supported_lvl | $BB awk '{ print $1 }');
|
lo_lvl=$(echo $supported_lvl | awk '{ print $1 }');
|
||||||
hi_lvl=$(echo $supported_lvl | $BB awk '{ print $3 }');
|
hi_lvl=$(echo $supported_lvl | awk '{ print $3 }');
|
||||||
elif echo $supported_lvl | $BB grep -q '\-$'; then
|
elif echo $supported_lvl | grep -q '\-$'; then
|
||||||
lo_lvl=$(echo $supported_lvl | $BB awk '{ print $1 }');
|
lo_lvl=$(echo $supported_lvl | awk '{ print $1 }');
|
||||||
hi_lvl=9999-99;
|
hi_lvl=9999-99;
|
||||||
fi;
|
fi;
|
||||||
if echo -e "$hi_lvl\n$lo_lvl\n$parsed_lvl" | $BB sort -g | $BB grep -n "$parsed_lvl" | $BB grep -q '^2:'; then
|
if echo -e "$hi_lvl\n$lo_lvl\n$parsed_lvl" | sort -g | grep -n "$parsed_lvl" | grep -q '^2:'; then
|
||||||
ui_print "$android_lvl" " ";
|
ui_print "$android_lvl" " ";
|
||||||
else
|
else
|
||||||
abort " " "Unsupported Android security patch level. Aborting...";
|
abort " " "Unsupported Android security patch level. Aborting...";
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
dump_moduleinfo() {
|
dump_moduleinfo() {
|
||||||
$BB cat <<EOF > $1;
|
cat <<EOF > $1;
|
||||||
id=ak3-helper
|
id=ak3-helper
|
||||||
name=AK3 Helper Module
|
name=AK3 Helper Module
|
||||||
version=$($BB awk '{ print $3 }' $AKHOME/vertmp) $($BB grep -oE '#.[0-9]' $AKHOME/vertmp)
|
version=$(awk '{ print $3 }' $AKHOME/vertmp) $(grep -oE '#.[0-9]' $AKHOME/vertmp)
|
||||||
versionCode=1
|
versionCode=1
|
||||||
author=AnyKernel3
|
author=AnyKernel3
|
||||||
description=$KERNEL_STRING
|
description=$KERNEL_STRING
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
dump_moduleremover() {
|
dump_moduleremover() {
|
||||||
$BB cat <<'EOF' > $1;
|
cat <<'EOF' > $1;
|
||||||
#!/system/bin/sh
|
#!/system/bin/sh
|
||||||
MODDIR=${0%/*};
|
MODDIR=${0%/*};
|
||||||
if [ "$(cat /proc/version)" != "$(cat $MODDIR/version)" ]; then
|
if [ "$(cat /proc/version)" != "$(cat $MODDIR/version)" ]; then
|
||||||
@@ -379,14 +377,14 @@ do_modules() {
|
|||||||
umask=$(umask);
|
umask=$(umask);
|
||||||
umask 022;
|
umask 022;
|
||||||
moddir=/data/adb/modules/ak3-helper;
|
moddir=/data/adb/modules/ak3-helper;
|
||||||
$BB rm -rf $moddir;
|
rm -rf $moddir;
|
||||||
$BB mkdir -p system $moddir;
|
mkdir -p system $moddir;
|
||||||
($BB mv -f product system;
|
(mv -f product system;
|
||||||
$BB mv -f vendor system) 2>/dev/null;
|
mv -f vendor system) 2>/dev/null;
|
||||||
$BB cp -rLf * $moddir;
|
cp -rLf * $moddir;
|
||||||
dump_moduleinfo $moddir/module.prop;
|
dump_moduleinfo $moddir/module.prop;
|
||||||
dump_moduleremover $moddir/post-fs-data.sh;
|
dump_moduleremover $moddir/post-fs-data.sh;
|
||||||
$BB cp -f $AKHOME/vertmp $moddir/version;
|
cp -f $AKHOME/vertmp $moddir/version;
|
||||||
umask $umask;
|
umask $umask;
|
||||||
else
|
else
|
||||||
ui_print "Magisk installation not found. Skipped!";
|
ui_print "Magisk installation not found. Skipped!";
|
||||||
@@ -397,17 +395,17 @@ do_modules() {
|
|||||||
if [ -d /dev/block/mapper ]; then
|
if [ -d /dev/block/mapper ]; then
|
||||||
for block in system vendor product; do
|
for block in system vendor product; do
|
||||||
for slot in "" _a _b; do
|
for slot in "" _a _b; do
|
||||||
$BB blockdev --setrw /dev/block/mapper/$block$slot 2>/dev/null;
|
blockdev --setrw /dev/block/mapper/$block$slot 2>/dev/null;
|
||||||
done;
|
done;
|
||||||
done;
|
done;
|
||||||
fi;
|
fi;
|
||||||
if [ ! -d /postinstall/tmp ]; then
|
if [ ! -d /postinstall/tmp ]; then
|
||||||
$BB mount -o rw,remount -t auto /system;
|
mount -o rw,remount -t auto /system;
|
||||||
($BB mount -o rw,remount -t auto /vendor;
|
(mount -o rw,remount -t auto /vendor;
|
||||||
$BB mount -o rw,remount -t auto /product) 2>/dev/null;
|
mount -o rw,remount -t auto /product) 2>/dev/null;
|
||||||
fi;
|
fi;
|
||||||
for module in $($BB find . -name '*.ko'); do
|
for module in $(find . -name '*.ko'); do
|
||||||
modtarget=$POSTINSTALL$(echo $module | $BB cut -c2-);
|
modtarget=$POSTINSTALL$(echo $module | cut -c2-);
|
||||||
if [ ! -e $modtarget ]; then
|
if [ ! -e $modtarget ]; then
|
||||||
case $module in
|
case $module in
|
||||||
*/vendor/*) modcon=vendor;;
|
*/vendor/*) modcon=vendor;;
|
||||||
@@ -416,23 +414,23 @@ do_modules() {
|
|||||||
esac;
|
esac;
|
||||||
fi;
|
fi;
|
||||||
if is_mounted $modtarget; then
|
if is_mounted $modtarget; then
|
||||||
$BB mount -o rw,remount -t auto $modtarget;
|
mount -o rw,remount -t auto $modtarget;
|
||||||
fi;
|
fi;
|
||||||
$BB mkdir -p $($BB dirname $modtarget);
|
mkdir -p $(dirname $modtarget);
|
||||||
$BB cp -rLf $module $modtarget;
|
cp -rLf $module $modtarget;
|
||||||
$BB chown 0:0 $modtarget;
|
chown 0:0 $modtarget;
|
||||||
$BB chmod 644 $modtarget;
|
chmod 644 $modtarget;
|
||||||
if [ "$modcon" ]; then
|
if [ "$modcon" ]; then
|
||||||
chcon "u:object_r:${modcon}_file:s0" $modtarget;
|
chcon "u:object_r:${modcon}_file:s0" $modtarget;
|
||||||
fi;
|
fi;
|
||||||
if is_mounted $modtarget; then
|
if is_mounted $modtarget; then
|
||||||
$BB mount -o ro,remount -t auto $modtarget;
|
mount -o ro,remount -t auto $modtarget;
|
||||||
fi;
|
fi;
|
||||||
done;
|
done;
|
||||||
if [ ! -d /postinstall/tmp ]; then
|
if [ ! -d /postinstall/tmp ]; then
|
||||||
$BB mount -o ro,remount -t auto /system;
|
mount -o ro,remount -t auto /system;
|
||||||
($BB mount -o ro,remount -t auto /vendor;
|
(mount -o ro,remount -t auto /vendor;
|
||||||
$BB mount -o ro,remount -t auto /product) 2>/dev/null;
|
mount -o ro,remount -t auto /product) 2>/dev/null;
|
||||||
fi;
|
fi;
|
||||||
fi;
|
fi;
|
||||||
cd $AKHOME;
|
cd $AKHOME;
|
||||||
@@ -465,6 +463,8 @@ $BB --install -s bin;
|
|||||||
if [ $? != 0 -o -z "$(ls bin)" ]; then
|
if [ $? != 0 -o -z "$(ls bin)" ]; then
|
||||||
abort "Busybox setup failed. Aborting...";
|
abort "Busybox setup failed. Aborting...";
|
||||||
fi;
|
fi;
|
||||||
|
OLD_PATH="$PATH";
|
||||||
|
export PATH="$AKHOME/bin:$PATH";
|
||||||
|
|
||||||
if [ -f banner ]; then
|
if [ -f banner ]; then
|
||||||
ui_printfile banner;
|
ui_printfile banner;
|
||||||
@@ -479,7 +479,7 @@ if [ -f version ]; then
|
|||||||
ui_print " ";
|
ui_print " ";
|
||||||
fi;
|
fi;
|
||||||
ui_print " " "AnyKernel3 by osm0sis @ xda-developers" " ";
|
ui_print " " "AnyKernel3 by osm0sis @ xda-developers" " ";
|
||||||
$BB grep -oE 'AK_BASE.*' META-INF/com/google/android/updater-script >&2;
|
grep -oE 'AK_BASE.*' META-INF/com/google/android/updater-script >&2;
|
||||||
ui_print " ";
|
ui_print " ";
|
||||||
|
|
||||||
setup_env;
|
setup_env;
|
||||||
@@ -489,9 +489,10 @@ do_versioncheck;
|
|||||||
do_levelcheck;
|
do_levelcheck;
|
||||||
|
|
||||||
ui_print "Installing...";
|
ui_print "Installing...";
|
||||||
CORE=$($BB grep -oE 'ak.*core.sh' anykernel.sh);
|
# hack to maintain support for anykernel.sh files that weren't updated correctly along with the AK core
|
||||||
[ -f tools/$CORE ] || $BB ln -s $AKHOME/tools/ak*-core.sh $AKHOME/tools/$CORE;
|
CORE=$(grep -oE 'ak.*core.sh' anykernel.sh);
|
||||||
PATH="$AKHOME/bin:$PATH" ZIPFILE="$3" home=$AKHOME $BB ash anykernel.sh $2;
|
[ -f tools/$CORE ] || ln -s $AKHOME/tools/ak*-core.sh $AKHOME/tools/$CORE;
|
||||||
|
home=$AKHOME ash anykernel.sh;
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
abort;
|
abort;
|
||||||
fi;
|
fi;
|
||||||
@@ -502,6 +503,8 @@ debugging;
|
|||||||
ui_print " ";
|
ui_print " ";
|
||||||
restore_env;
|
restore_env;
|
||||||
|
|
||||||
|
export PATH="$OLD_PATH";
|
||||||
|
unset OLD_PATH;
|
||||||
if [ "$(file_getprop anykernel.sh do.cleanup)" == 1 ]; then
|
if [ "$(file_getprop anykernel.sh do.cleanup)" == 1 ]; then
|
||||||
cleanup;
|
cleanup;
|
||||||
fi;
|
fi;
|
||||||
|
|||||||
@@ -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=20230422
|
# AK_BASE_VERSION=20230423
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
### AnyKernel methods (DO NOT CHANGE)
|
### AnyKernel methods (DO NOT CHANGE)
|
||||||
## osm0sis @ xda-developers
|
## osm0sis @ xda-developers
|
||||||
|
|
||||||
OUTFD=$1;
|
[ "$OUTFD" ] || OUTFD=$1;
|
||||||
|
|
||||||
# set up working directory variables
|
# set up working directory variables
|
||||||
[ "$home" ] || home=$PWD;
|
[ "$home" ] || home=$PWD;
|
||||||
|
|||||||
Reference in new issue
Block a user