2
0
mirror of https://github.com/topjohnwu/Magisk synced 2025-08-31 12:05:12 +00:00

Update scripts to use BusyBox standalone mode

This commit is contained in:
topjohnwu
2020-03-08 22:25:06 -07:00
parent 409cb06ea0
commit db9a4b31f9
5 changed files with 59 additions and 58 deletions

View File

@@ -56,13 +56,20 @@ resolve_vars() {
SERVICED=$NVBASE/service.d
}
print_title() {
local len=$(echo -n $1 | wc -c)
len=$((len + 2))
local pounds=$(printf "%${len}s" | tr ' ' '*')
ui_print "$pounds"
ui_print " $1 "
ui_print "$pounds"
}
######################
# Environment Related
######################
setup_flashable() {
# Preserve environment varibles
OLD_PATH=$PATH
ensure_bb
$BOOTMODE && return
if [ -z $OUTFD ] || readlink /proc/$$/fd/$OUTFD | grep -q /tmp; then
@@ -79,18 +86,23 @@ setup_flashable() {
}
ensure_bb() {
if [ -x $MAGISKTMP/busybox/busybox ]; then
[ -z $BBDIR ] && BBDIR=$MAGISKTMP/busybox
elif [ -x $TMPDIR/bin/busybox ]; then
[ -z $BBDIR ] && BBDIR=$TMPDIR/bin
[ -o standalone ] && return
set -o standalone 2>/dev/null && return
# At this point, we are not running in BusyBox ash
# Find our busybox binary
local BUSYBOX
if [ -f $TMPDIR/busybox ]; then
BUSYBOX=$TMPDIR/busybox
elif [ -f $MAGISKBIN/busybox ]; then
BUSYBOX=$MAGISKBIN/busybox
else
# Construct the PATH
[ -z $BBDIR ] && BBDIR=$TMPDIR/bin
mkdir -p $BBDIR
ln -s $MAGISKBIN/busybox $BBDIR/busybox
$MAGISKBIN/busybox --install -s $BBDIR
abort "! Cannot find BusyBox"
fi
echo $PATH | grep -q "^$BBDIR" || export PATH=$BBDIR:$PATH
# Re-exec our script
chmod 755 $BUSYBOX
exec $BUSYBOX sh -o standalone $0 "$@"
}
recovery_actions() {
@@ -103,9 +115,6 @@ recovery_actions() {
unset LD_LIBRARY_PATH
unset LD_PRELOAD
unset LD_CONFIG_FILE
# Force our own busybox path to be in the front
# and do not use anything in recovery's sbin
export PATH=$BBDIR:/system/bin:/vendor/bin
}
recovery_cleanup() {