Backend: fixes for booted flashing and addon.d-v2

- only do setup_env and restore_env when in recovery to prevent environment/mount issues post-install
- use busybox [ for simple integer test to ensure known numerical operator behavior
This commit is contained in:
osm0sis committed 2020-02-14 13:33:41 -04:00
1 parent 5bec49dc98
commit 273384db04
1 file changed
+12 -12
+12 -12
View File
@@ -120,18 +120,16 @@ mount_all() {
$BB mount -o bind /system_root/system /system; $BB mount -o bind /system_root/system /system;
fi; fi;
fi; fi;
$BOOTMODE || mount_apex; mount_apex;
} }
umount_all() { umount_all() {
(if ! $BOOTMODE; then (umount_apex;
umount_apex; if [ ! -d /postinstall/tmp ]; then
if [ ! -d /postinstall/tmp ]; then $BB umount /system;
$BB umount /system; $BB umount -l /system;
$BB umount -l /system; if [ -e /system_root ]; then
if [ -e /system_root ]; then $BB umount /system_root;
$BB umount /system_root; $BB umount -l /system_root;
$BB umount -l /system_root;
fi;
fi; fi;
fi; fi;
umount /vendor; umount /vendor;
@@ -142,7 +140,8 @@ umount_all() {
fi) 2>/dev/null; fi) 2>/dev/null;
} }
setup_env() { setup_env() {
$BOOTMODE || $BB mount -o bind /dev/urandom /dev/random; $BOOTMODE && return 1;
$BB mount -o bind /dev/urandom /dev/random;
umount_all; umount_all;
mount_all; mount_all;
OLD_LD_PATH=$LD_LIBRARY_PATH; OLD_LD_PATH=$LD_LIBRARY_PATH;
@@ -166,6 +165,7 @@ setup_env() {
fi; fi;
} }
restore_env() { restore_env() {
$BOOTMODE && return 1;
local dir; local dir;
unset -f getprop; unset -f getprop;
test "$OLD_LD_PATH" && export LD_LIBRARY_PATH=$OLD_LD_PATH; test "$OLD_LD_PATH" && export LD_LIBRARY_PATH=$OLD_LD_PATH;
@@ -224,7 +224,7 @@ do_devicecheck() {
fi; fi;
} }
int2ver() { int2ver() {
if [ "$1" -eq "$1" ] 2>/dev/null; then if $BB [ "$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" | $BB cut -d. -f3)" ]; then
echo "$1.0"; echo "$1.0";