Files
anykernel3-rhode/META-INF/com/google/android/update-binary
T

578 lines
19 KiB
Bash
Raw Normal View History

#!/sbin/sh
# AnyKernel3 Backend (DO NOT CHANGE)
# osm0sis @ xda-developers
2010-12-21 09:46:05 -08:00
export OUTFD=$2;
export ZIPFILE="$3";
BOOTMODE=false;
ps | grep zygote | grep -v grep >/dev/null && BOOTMODE=true;
$BOOTMODE || ps -A 2>/dev/null | grep zygote | grep -v grep >/dev/null && BOOTMODE=true;
DIR=/sdcard;
$BOOTMODE || DIR=$(dirname "$ZIPFILE");
[ $DIR == "/sideload" ] && DIR=/tmp;
2021-01-18 15:46:41 -04:00
[ -d /postinstall/tmp ] && POSTINSTALL=/postinstall;
2023-05-03 15:44:59 -03:00
[ "$AKHOME" ] || export AKHOME=$POSTINSTALL/tmp/anykernel;
2021-01-18 15:46:41 -04:00
[ "$ANDROID_ROOT" ] || ANDROID_ROOT=/system;
2010-12-21 09:46:05 -08:00
ui_print() {
until [ ! "$1" ]; do
2020-01-31 20:08:29 -04:00
echo "ui_print $1
ui_print" >> /proc/self/fd/$OUTFD;
shift;
done;
}
ui_printfile() {
local line losrpad;
$BOOTMODE || [ -e /twres ] || losrpad='| '; # work around LOS Recovery eating leading whitespace
while IFS='' read -r line || [[ -n "$line" ]]; do
ui_print "$losrpad$line";
done < $1;
}
show_progress() { echo "progress $1 $2" >> /proc/self/fd/$OUTFD; }
file_getprop() { grep "^$2=" "$1" | tail -n1 | cut -d= -f2-; }
2021-01-14 01:31:14 -04:00
find_slot() {
2021-01-13 23:33:08 -04:00
local slot=$(getprop ro.boot.slot_suffix 2>/dev/null);
[ "$slot" ] || slot=$(grep -o 'androidboot.slot_suffix=.*$' /proc/cmdline | cut -d\ -f1 | cut -d= -f2);
2021-01-13 23:33:08 -04:00
if [ ! "$slot" ]; then
slot=$(getprop ro.boot.slot 2>/dev/null);
[ "$slot" ] || slot=$(grep -o 'androidboot.slot=.*$' /proc/cmdline | cut -d\ -f1 | cut -d= -f2);
2021-01-18 15:46:41 -04:00
[ "$slot" ] && slot=_$slot;
2021-01-13 23:33:08 -04:00
fi;
[ "$slot" == "normal" ] && unset slot;
2021-01-18 15:46:41 -04:00
[ "$slot" ] && echo "$slot";
2021-01-13 23:33:08 -04:00
}
setup_mountpoint() {
[ -L $1 ] && mv -f $1 ${1}_link;
if [ ! -d $1 ]; then
rm -f $1;
mkdir -p $1;
fi;
}
is_mounted() { mount | grep -q " $1 "; }
2020-01-03 13:16:14 -05:00
mount_apex() {
2021-01-18 15:46:41 -04:00
[ -d /system_root/system/apex ] || return 1;
local apex dest loop minorx num shcon var;
2020-01-12 02:22:30 -04:00
setup_mountpoint /apex;
mount -t tmpfs tmpfs /apex -o mode=755 && touch /apex/apextmp;
shcon=$(cat /proc/self/attr/current);
echo "u:r:su:s0" > /proc/self/attr/current 2>/dev/null; # work around LOS Recovery not allowing loop mounts in recovery context
minorx=1;
[ -e /dev/block/loop1 ] && minorx=$(ls -l /dev/block/loop1 | awk '{ print $6 }');
2020-01-12 02:22:30 -04:00
num=0;
for apex in /system_root/system/apex/*; do
dest=/apex/$(basename $apex | sed -E -e 's;\.apex$|\.capex$;;' -e 's;\.current$|\.release$;;');
mkdir -p $dest;
2020-01-12 02:22:30 -04:00
case $apex in
*.apex|*.capex)
unzip -qo $apex original_apex -d /apex;
[ -f /apex/original_apex ] && apex=/apex/original_apex;
unzip -qo $apex apex_payload.img -d /apex;
mv -f /apex/original_apex $dest.apex 2>/dev/null;
mv -f /apex/apex_payload.img $dest.img;
mount -t ext4 -o ro,noatime $dest.img $dest 2>/dev/null && echo "$dest (direct)" >&2;
2020-01-12 02:22:30 -04:00
if [ $? != 0 ]; then
while [ $num -lt 64 ]; do
loop=/dev/block/loop$num;
[ -e $loop ] || mknod $loop b 7 $((num * minorx));
losetup $loop $dest.img 2>/dev/null;
2020-01-12 02:22:30 -04:00
num=$((num + 1));
losetup $loop | grep -q $dest.img && break;
2020-01-12 02:22:30 -04:00
done;
mount -t ext4 -o ro,loop,noatime $loop $dest && echo "$dest (loop)" >&2;
2020-01-12 02:22:30 -04:00
if [ $? != 0 ]; then
losetup -d $loop 2>/dev/null;
if [ $num -eq 64 -a $(losetup -f) == "/dev/block/loop0" ]; then
echo "Aborting apex mounts due to broken environment..." >&2;
break;
fi;
2020-01-12 02:22:30 -04:00
fi;
fi;
;;
*) mount -o bind $apex $dest && echo "$dest (bind)" >&2;;
2020-01-12 02:22:30 -04:00
esac;
done;
echo "$shcon" > /proc/self/attr/current 2>/dev/null;
for var in $(grep -o 'export .* /.*' /system_root/init.environ.rc | awk '{ print $2 }'); do
eval OLD_${var}=\$$var;
done;
$(grep -o 'export .* /.*' /system_root/init.environ.rc | sed 's; /;=/;'); unset export;
touch /apex/apexak3;
2020-01-03 13:16:14 -05:00
}
umount_apex() {
[ -f /apex/apexak3 ] || return 1;
echo "Unmounting apex..." >&2;
local dest loop var;
for var in $(grep -o 'export .* /.*' /system_root/init.environ.rc 2>/dev/null | awk '{ print $2 }'); do
if [ "$(eval echo \$OLD_$var)" ]; then
eval $var=\$OLD_${var};
else
eval unset $var;
fi;
unset OLD_${var};
done;
for dest in $(find /apex -type d -mindepth 1 -maxdepth 1); do
loop=$(mount | grep $dest | grep loop | cut -d\ -f1);
umount -l $dest;
losetup $loop >/dev/null 2>&1 && losetup -d $loop;
2020-01-12 02:22:30 -04:00
done;
[ -f /apex/apextmp ] && umount /apex;
rm -rf /apex/apexak3 /apex 2>/dev/null;
2020-01-03 13:16:14 -05:00
}
2020-01-24 09:39:29 -04:00
mount_all() {
local byname mount slot system;
echo "Mounting..." >&2;
2023-04-22 08:18:05 -03:00
byname=bootdevice/by-name;
[ -d /dev/block/$byname ] || byname=$(find /dev/block/platform -type d -name by-name 2>/dev/null | head -n1 | cut -d/ -f4-);
2023-04-22 08:18:05 -03:00
[ -e /dev/block/$byname/super -a -d /dev/block/mapper ] && byname=mapper;
[ -e /dev/block/$byname/system ] || slot=$(find_slot);
for mount in /cache /data /metadata /persist; do
if ! is_mounted $mount; then
mount $mount 2>/dev/null && echo "$mount (fstab)" >&2 && UMOUNTLIST="$UMOUNTLIST $mount";
2023-04-22 08:18:05 -03:00
if [ $? != 0 -a -e /dev/block/$byname$mount ]; then
setup_mountpoint $mount;
mount -o ro -t auto /dev/block/$byname$mount $mount && echo "$mount (direct)" >&2 && UMOUNTLIST="$UMOUNTLIST $mount";
2023-04-22 08:18:05 -03:00
fi;
fi;
done;
2020-01-24 09:39:29 -04:00
setup_mountpoint $ANDROID_ROOT;
if ! is_mounted $ANDROID_ROOT; then
mount -o ro -t auto $ANDROID_ROOT 2>/dev/null && echo "$ANDROID_ROOT (\$ANDROID_ROOT)" >&2;
2020-01-24 09:39:29 -04:00
fi;
case $ANDROID_ROOT in
/system_root) setup_mountpoint /system;;
/system)
if ! is_mounted /system && ! is_mounted /system_root; then
setup_mountpoint /system_root;
mount -o ro -t auto /system_root && echo "/system_root (fstab)" >&2;
elif [ -f /system/system/build.prop ]; then
2020-01-24 09:39:29 -04:00
setup_mountpoint /system_root;
mount --move /system /system_root && echo "/system_root (moved)" >&2;
fi;
if [ $? != 0 ]; then
(umount /system;
umount -l /system) 2>/dev/null;
mount -o ro -t auto /dev/block/$byname/system$slot /system_root && echo "/system_root (direct)" >&2;
2020-01-24 09:39:29 -04:00
fi;
;;
esac;
2021-09-15 00:02:22 -03:00
[ -f /system_root/system/build.prop ] && system=/system;
2021-09-14 16:56:46 -03:00
for mount in /vendor /product /system_ext; do
mount -o ro -t auto $mount 2>/dev/null && echo "$mount (fstab)" >&2;
2023-04-22 08:18:05 -03:00
if [ $? != 0 ] && [ -L /system$mount -o -L /system_root$system$mount ]; then
2021-09-14 16:56:46 -03:00
setup_mountpoint $mount;
mount -o ro -t auto /dev/block/$byname$mount$slot $mount && echo "$mount (direct)" >&2;
2021-09-14 16:56:46 -03:00
fi;
done;
2020-01-24 09:39:29 -04:00
if is_mounted /system_root; then
mount_apex;
mount -o bind /system_root$system /system && echo "/system (bind)" >&2;
2021-09-14 16:56:46 -03:00
fi;
echo " " >&2;
2020-01-24 09:39:29 -04:00
}
umount_all() {
2021-01-18 16:08:36 -04:00
local mount;
echo "Unmounting..." >&2;
(if [ ! -d /postinstall/tmp ]; then
umount /system;
umount -l /system;
fi) 2>/dev/null;
umount_apex;
(if [ ! -d /postinstall/tmp ]; then
umount /system_root;
umount -l /system_root;
fi;
PATH="$OLD_PATH" umount /vendor; # busybox umount /vendor breaks recovery on some hacky devices
PATH="$OLD_PATH" umount -l /vendor;
2023-04-22 08:18:05 -03:00
for mount in /mnt/system /mnt/vendor /product /mnt/product /system_ext /mnt/system_ext $UMOUNTLIST; do
umount $mount;
umount -l $mount;
2023-04-22 08:18:05 -03:00
done) 2>/dev/null;
2020-01-24 09:39:29 -04:00
}
setup_env() {
$BOOTMODE && return 1;
mount -o bind /dev/urandom /dev/random;
if [ -L /etc ]; then
setup_mountpoint /etc;
cp -af /etc_link/* /etc;
sed -i 's; / ; /system_root ;' /etc/fstab;
fi;
2020-01-24 09:39:29 -04:00
umount_all;
mount_all;
OLD_LD_PATH=$LD_LIBRARY_PATH;
OLD_LD_PRE=$LD_PRELOAD;
OLD_LD_CFG=$LD_CONFIG_FILE;
unset LD_LIBRARY_PATH LD_PRELOAD LD_CONFIG_FILE;
2020-01-24 09:39:29 -04:00
if [ ! "$(getprop 2>/dev/null)" ]; then
getprop() {
local propdir propfile propval;
for propdir in / /system_root /system /vendor /product /product/etc /system_ext/etc /odm/etc; do
2020-01-24 09:39:29 -04:00
for propfile in default.prop build.prop; do
if [ "$propval" ]; then
break 2;
else
propval="$(file_getprop $propdir/$propfile $1 2>/dev/null)";
fi;
2020-01-24 09:39:29 -04:00
done;
done;
echo "$propval";
2020-01-24 09:39:29 -04:00
}
elif [ ! "$(getprop ro.build.type 2>/dev/null)" ]; then
getprop() {
($(which getprop) | grep "$1" | cut -d[ -f3 | cut -d] -f1) 2>/dev/null;
2020-01-24 09:39:29 -04:00
}
fi;
}
restore_env() {
$BOOTMODE && return 1;
2020-01-21 06:16:45 -04:00
local dir;
2020-01-24 09:39:29 -04:00
unset -f getprop;
2021-01-18 15:46:41 -04:00
[ "$OLD_LD_PATH" ] && export LD_LIBRARY_PATH=$OLD_LD_PATH;
[ "$OLD_LD_PRE" ] && export LD_PRELOAD=$OLD_LD_PRE;
[ "$OLD_LD_CFG" ] && export LD_CONFIG_FILE=$OLD_LD_CFG;
unset OLD_LD_PATH OLD_LD_PRE OLD_LD_CFG;
sleep 1;
umount_all;
[ -L /etc_link ] && rm -rf /etc/*;
(for dir in /etc /apex /system_root /system /vendor /product /system_ext /metadata /persist; do
if [ -L "${dir}_link" ]; then
2020-01-21 06:16:45 -04:00
rmdir $dir;
mv -f ${dir}_link $dir;
2020-01-21 06:16:45 -04:00
fi;
done;
umount -l /dev/random) 2>/dev/null;
2020-01-24 09:39:29 -04:00
}
setup_bb() {
local arch32 bb;
for arch32 in x86 arm; do
if [ -d $AKHOME/tools/$arch32 ]; then
bb=$AKHOME/tools/$arch32/busybox;
chmod 755 $bb;
$bb >/dev/null 2>&1;
if [ $? == 0 ]; then
$bb mv -f $AKHOME/tools/$arch32/* $AKHOME/tools;
break;
fi;
fi;
done;
bb=$AKHOME/tools/busybox;
chmod 755 $bb;
$bb chmod -R 755 tools bin;
$bb --install -s bin;
}
debugging() {
local debug log path;
case $(basename "$ZIPFILE" .zip) in
*-debugging) debug=1;;
esac;
for path in /tmp /cache /metadata /persist; do
[ -f $path/.ak3-debugging ] && debug=1;
done;
if [ "$debug" ]; then
ui_print " " "Creating debugging archive in $DIR...";
[ -f /tmp/recovery.log ] && log=/tmp/recovery.log;
tar -czf "$DIR/anykernel3-$(date +%Y-%m-%d_%H%M%S)-debug.tgz" $AKHOME $log;
fi;
}
2020-01-24 09:39:29 -04:00
cleanup() {
cd $AKHOME/../;
2020-01-24 09:39:29 -04:00
rm -rf $AKHOME;
}
abort() {
2019-08-04 01:16:54 -03:00
ui_print "$@";
debugging;
2019-08-29 01:27:02 -03:00
restore_env;
2018-12-15 00:36:26 -04:00
if [ ! -f anykernel.sh -o "$(file_getprop anykernel.sh do.cleanuponabort 2>/dev/null)" == 1 ]; then
cleanup;
fi;
exit 1;
}
2020-01-24 09:39:29 -04:00
do_devicecheck() {
2021-01-18 15:46:41 -04:00
[ "$(file_getprop anykernel.sh do.devicecheck)" == 1 ] || return 1;
2020-01-24 09:39:29 -04:00
local device devicename match product testname vendordevice vendorproduct;
ui_print "Checking device...";
device=$(getprop ro.product.device 2>/dev/null);
product=$(getprop ro.build.product 2>/dev/null);
2019-10-29 17:22:08 -03:00
vendordevice=$(getprop ro.product.vendor.device 2>/dev/null);
vendorproduct=$(getprop ro.vendor.product.device 2>/dev/null);
for testname in $(grep '^device.name.*=' anykernel.sh | cut -d= -f2-); do
for devicename in $device $product $vendordevice $vendorproduct; do
if [ "$devicename" == "$testname" ]; then
ui_print "$testname" " ";
match=1;
break 2;
fi;
done;
done;
2018-12-16 18:31:53 -04:00
if [ ! "$match" ]; then
abort " " "Unsupported device. Aborting...";
fi;
2020-01-24 09:39:29 -04:00
}
int2ver() {
if [ "$1" -eq "$1" ] 2>/dev/null; then
2020-01-24 09:39:29 -04:00
echo "$1.0.0";
elif [ ! "$(echo "$1" | cut -d. -f3)" ]; then
2020-01-24 09:39:29 -04:00
echo "$1.0";
else
echo "$1";
fi;
}
do_versioncheck() {
2021-01-18 15:46:41 -04:00
[ "$(file_getprop anykernel.sh supported.versions)" ] || return 1;
2020-01-24 09:39:29 -04:00
local android_ver hi_ver lo_ver parsed_ver supported supported_ver;
2018-12-16 18:31:53 -04:00
ui_print "Checking Android version...";
supported_ver=$(file_getprop anykernel.sh supported.versions | tr -d '[:space:]');
android_ver=$(file_getprop /system/build.prop ro.build.version.release);
parsed_ver=$(int2ver $android_ver);
if echo $supported_ver | grep -q '-'; then
lo_ver=$(int2ver "$(echo $supported_ver | cut -d- -f1)");
hi_ver=$(int2ver "$(echo $supported_ver | cut -d- -f2)");
if echo -e "$hi_ver\n$lo_ver\n$parsed_ver" | sort -g | grep -n "$parsed_ver" | grep -q '^2:'; then
2018-12-16 18:31:53 -04:00
supported=1;
fi;
else
for ver in $(echo $supported_ver | sed 's;,; ;g'); do
if [ "$(int2ver $ver)" == "$parsed_ver" ]; then
2018-12-16 18:31:53 -04:00
supported=1;
break;
fi;
done;
fi;
if [ "$supported" ]; then
ui_print "$android_ver" " ";
2018-12-16 18:31:53 -04:00
else
abort " " "Unsupported Android version. Aborting...";
fi;
2020-01-24 09:39:29 -04:00
}
do_levelcheck() {
2021-01-18 15:46:41 -04:00
[ "$(file_getprop anykernel.sh supported.patchlevels)" ] || return 1;
2020-01-24 09:39:29 -04:00
local android_lvl hi_lvl lo_lvl parsed_lvl supported_lvl;
ui_print "Checking Android security patch level...";
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);
parsed_lvl=$(echo $android_lvl | grep -oE '[0-9]{4}-[0-9]{2}');
if echo $supported_lvl | grep -q '^\-'; then
lo_lvl=0000-00;
hi_lvl=$(echo $supported_lvl | awk '{ print $2 }');
elif echo $supported_lvl | grep -q ' - '; then
lo_lvl=$(echo $supported_lvl | awk '{ print $1 }');
hi_lvl=$(echo $supported_lvl | awk '{ print $3 }');
elif echo $supported_lvl | grep -q '\-$'; then
lo_lvl=$(echo $supported_lvl | awk '{ print $1 }');
hi_lvl=9999-99;
fi;
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" " ";
else
abort " " "Unsupported Android security patch level. Aborting...";
2018-12-16 18:31:53 -04:00
fi;
2020-01-24 09:39:29 -04:00
}
2023-08-22 01:51:39 -03:00
do_vendorlevelcheck() {
[ "$(file_getprop anykernel.sh supported.vendorpatchlevels)" ] || return 1;
local vendor_lvl hi_lvl lo_lvl parsed_lvl supported_lvl;
ui_print "Checking Vendor security patch level...";
supported_lvl=$(file_getprop anykernel.sh supported.vendorpatchlevels | grep -oE '[0-9]{4}-[0-9]{2}|-');
vendor_lvl=$(file_getprop /vendor/build.prop ro.vendor.build.security_patch);
parsed_lvl=$(echo $vendor_lvl | grep -oE '[0-9]{4}-[0-9]{2}');
if echo $supported_lvl | grep -q '^\-'; then
lo_lvl=0000-00;
hi_lvl=$(echo $supported_lvl | awk '{ print $2 }');
elif echo $supported_lvl | grep -q ' - '; then
lo_lvl=$(echo $supported_lvl | awk '{ print $1 }');
hi_lvl=$(echo $supported_lvl | awk '{ print $3 }');
elif echo $supported_lvl | grep -q '\-$'; then
lo_lvl=$(echo $supported_lvl | awk '{ print $1 }');
hi_lvl=9999-99;
fi;
if echo -e "$hi_lvl\n$lo_lvl\n$parsed_lvl" | sort -g | grep -n "$parsed_lvl" | grep -q '^2:'; then
ui_print "$vendor_lvl" " ";
else
abort " " "Unsupported Vendor security patch level. Aborting...";
fi;
}
2020-01-24 09:39:29 -04:00
dump_moduleinfo() {
cat <<EOF > $1;
id=ak3-helper
2020-01-24 09:39:29 -04:00
name=AK3 Helper Module
version=$(awk '{ print $3 }' $AKHOME/vertmp) $(grep -oE '#.[0-9]' $AKHOME/vertmp)
2020-01-24 09:39:29 -04:00
versionCode=1
author=AnyKernel3
description=$KERNEL_STRING
EOF
}
dump_moduleremover() {
cat <<'EOF' > $1;
2020-01-24 09:39:29 -04:00
#!/system/bin/sh
2020-02-08 20:16:30 -04:00
MODDIR=${0%/*};
if [ "$(cat /proc/version)" != "$(cat $MODDIR/version)" ]; then
rm -rf $MODDIR;
exit;
2018-12-16 18:31:53 -04:00
fi;
rm -f $MODDIR/update;
. $MODDIR/post-fs-data.2.sh;
2020-01-24 09:39:29 -04:00
EOF
}
do_modules() {
2021-01-18 15:46:41 -04:00
[ "$(file_getprop anykernel.sh do.modules)" == 1 ] || return 1;
local block modcon moddir modtarget module slot umask umountksu;
if [ "$(file_getprop anykernel.sh do.systemless)" == 1 ]; then
if [ ! -d /data/adb -o ! -d /data/data/android ]; then
ui_print " " "Warning: No /data access for kernel helper systemless module!";
return 1;
fi;
2020-01-24 09:39:29 -04:00
cd $AKHOME/modules;
ui_print " " "Creating kernel helper systemless module...";
if [ -d /data/adb/magisk -a -f $AKHOME/magisk_patched ] || [ -d /data/data/me.weishu.kernelsu -a -f $AKHOME/kernelsu_patched ]; then
2020-01-24 09:39:29 -04:00
umask=$(umask);
moddir=/data/adb/modules/ak3-helper;
# this may be the initial KernelSU install or first module so setup as needed
if [ -f $AKHOME/kernelsu_patched ]; then
umask 077;
if [ ! -d /data/adb/modules ]; then
mkdir -p /data/adb/modules;
chmod 777 /data/adb/modules;
fi;
[ -d /data/adb/modules_update ] || mkdir -p /data/adb/modules_update;
[ -d /data/adb/ksu ] || mkdir -p /data/adb/ksu;
[ -f /data/adb/ksu/modules.img ] && cp -f /data/adb/ksu/modules.img /data/adb/ksu/modules_update.img;
if [ ! -f /data/adb/ksu/modules_update.img ]; then
/system/bin/make_ext4fs -b 1024 -l 256M /data/adb/ksu/modules_update.img 2>/dev/null \
|| /system/bin/mke2fs -b 1024 -t ext4 /data/adb/ksu/modules_update.img 256M;
fi;
mount -t ext4 -o rw /data/adb/ksu/modules_update.img /data/adb/modules_update && umountksu=1;
touch /data/adb/ksu/update;
umask 022;
rm -rf $moddir;
mkdir -p $moddir;
dump_moduleinfo $moddir/module.prop;
touch $moddir/update;
moddir=/data/adb/modules_update/ak3-helper;
fi;
umask 022;
rm -rf $moddir;
mkdir -p system $moddir;
(mv -f product system;
mv -f vendor system;
mv -f system_ext system;
mv -f post-fs-data.sh post-fs-data.2.sh) 2>/dev/null;
cp -rLf * $moddir;
dump_moduleinfo $moddir/module.prop;
dump_moduleremover $moddir/post-fs-data.sh;
cp -f $AKHOME/vertmp $moddir/version;
touch $moddir/update;
2020-01-24 09:39:29 -04:00
umask $umask;
/system/bin/chcon -hR "u:object_r:system_file:s0" $moddir;
[ "$umountksu" ] && umount /data/adb/modules_update;
else
ui_print "Magisk/KernelSU installation not found. Skipped!";
2018-01-06 17:58:25 -07:00
fi;
else
2020-01-24 09:39:29 -04:00
cd $AKHOME/modules;
ui_print " " "Pushing modules...";
if [ -d /dev/block/mapper ]; then
2021-01-18 16:08:36 -04:00
for block in system vendor product; do
for slot in "" _a _b; do
blockdev --setrw /dev/block/mapper/$block$slot 2>/dev/null;
done;
done;
fi;
if [ ! -d /postinstall/tmp ]; then
mount -o rw,remount -t auto /system;
(mount -o rw,remount -t auto /vendor;
mount -o rw,remount -t auto /product) 2>/dev/null;
fi;
for module in $(find . -name '*.ko'); do
modtarget=$POSTINSTALL$(echo $module | cut -c2-);
if [ ! -e $modtarget ]; then
case $module in
*/vendor/*) modcon=vendor;;
2021-01-18 16:08:36 -04:00
*/product/*) modcon=product;;
*) modcon=system;;
esac;
fi;
if is_mounted $modtarget; then
mount -o rw,remount -t auto $modtarget;
fi;
mkdir -p $(dirname $modtarget);
cp -rLf $module $modtarget;
chown 0:0 $modtarget;
chmod 644 $modtarget;
if [ "$modcon" ]; then
/system/bin/chcon "u:object_r:${modcon}_file:s0" $modtarget;
fi;
if is_mounted $modtarget; then
mount -o ro,remount -t auto $modtarget;
fi;
done;
if [ ! -d /postinstall/tmp ]; then
mount -o ro,remount -t auto /system;
(mount -o ro,remount -t auto /vendor;
mount -o ro,remount -t auto /product) 2>/dev/null;
fi;
fi;
2020-01-24 09:39:29 -04:00
cd $AKHOME;
}
show_progress 1.34 25;
2020-01-24 09:39:29 -04:00
ui_print " ";
cleanup;
mkdir -p $AKHOME/bin;
cd $AKHOME;
unzip -o "$ZIPFILE";
if [ $? != 0 -o ! "$(ls tools)" ]; then
abort "Unzip failed. Aborting...";
fi;
setup_bb;
2020-01-24 09:39:29 -04:00
if [ $? != 0 -o -z "$(ls bin)" ]; then
abort "Busybox setup failed. Aborting...";
fi;
OLD_PATH="$PATH";
export PATH="$AKHOME/bin:$AKHOME/tools:$PATH";
2020-01-24 09:39:29 -04:00
if [ -f banner ]; then
ui_printfile banner;
ui_print " " " ";
fi;
KERNEL_STRING="$(file_getprop anykernel.sh kernel.string)";
ui_print "$KERNEL_STRING";
if [ -f version ]; then
ui_print " ";
ui_printfile version;
ui_print " ";
fi;
ui_print " " "AnyKernel3 by osm0sis @ xda-developers" " ";
grep -oE 'AK_BASE.*' META-INF/com/google/android/updater-script >&2;
ui_print " ";
2020-01-24 09:39:29 -04:00
setup_env;
do_devicecheck;
do_versioncheck;
do_levelcheck;
2023-08-22 01:51:39 -03:00
do_vendorlevelcheck;
2020-01-24 09:39:29 -04:00
ui_print "Installing...";
# hack to maintain support for anykernel.sh files that weren't updated correctly along with the AK core
CORE=$(grep -oE 'ak.*core.sh' anykernel.sh);
[ -f tools/$CORE ] || ln -s $AKHOME/tools/ak*-core.sh $AKHOME/tools/$CORE;
2023-05-03 15:44:59 -03:00
ash anykernel.sh;
2020-01-24 09:39:29 -04:00
if [ $? != 0 ]; then
abort;
fi;
do_modules;
2010-12-21 09:46:05 -08:00
debugging;
ui_print " ";
2019-08-29 01:27:02 -03:00
restore_env;
2018-12-15 00:36:26 -04:00
if [ "$(file_getprop anykernel.sh do.cleanup)" == 1 ]; then
cleanup;
fi;
2010-12-21 09:46:05 -08:00
ui_print " " "Done!";
export PATH="$OLD_PATH";
unset OLD_PATH OUTFD ZIPFILE;