From ed7e560849b8b12004819dedc6fa819773feed51 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 19 Mar 2020 03:48:23 -0700 Subject: [PATCH] Fix ensure_bb implementation Close #2549, close #2560 --- scripts/util_functions.sh | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index c659a95ec..499b05d59 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -86,23 +86,40 @@ setup_flashable() { } ensure_bb() { - [ -o standalone ] && return - set -o standalone 2>/dev/null && return + if set -o | grep -q standalone; then + # We are definitely in busybox ash + set -o standalone + return + fi - # At this point, we are not running in BusyBox ash # Find our busybox binary - local BUSYBOX + local bb if [ -f $TMPDIR/busybox ]; then - BUSYBOX=$TMPDIR/busybox + bb=$TMPDIR/busybox elif [ -f $MAGISKBIN/busybox ]; then - BUSYBOX=$MAGISKBIN/busybox + bb=$MAGISKBIN/busybox else abort "! Cannot find BusyBox" fi + chmod 755 $bb + + # Find our current arguments + # Run in busybox environment to ensure consistent results + # /proc//cmdline shall be