mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-29 18:07:39 +00:00
dca3fe396f
- Magisk Manager installs have busybox in the $PATH before extracting busybox from update-binary so an error from busybox ash (as sh) attempting to parse the x86 busybox like a shell script would be shown: ./bin/busybox: line 1: syntax error: unexpected "(" - this will only occur when ash tries to run a binary it can't handle, so basically only with x86 binary on an arm* device
39 lines
840 B
Bash
39 lines
840 B
Bash
#!/sbin/sh
|
|
X86_CNT=__X86_CNT__
|
|
extract_bb() {
|
|
touch "$BBBIN"
|
|
chmod 755 "$BBBIN"
|
|
dd if="$0" of="$BBBIN" bs=1024 skip=1 count=$X86_CNT
|
|
"$BBBIN" >/dev/null 2>&1 || dd if="$0" of="$BBBIN" bs=1024 skip=$(($X86_CNT + 1))
|
|
}
|
|
setup_bb() {
|
|
export BBDIR=$TMPDIR/bin
|
|
BBBIN=$BBDIR/busybox
|
|
mkdir -p $BBDIR 2>/dev/null
|
|
extract_bb
|
|
$BBBIN --install -s $BBDIR
|
|
export PATH=$BBDIR:$PATH
|
|
}
|
|
case "$1" in
|
|
"extract"|"-x")
|
|
[ -z "$2" ] && BBBIN=./busybox || BBBIN="$2"
|
|
extract_bb
|
|
;;
|
|
"indep"|"sh")
|
|
TMPDIR=.
|
|
setup_bb
|
|
shift
|
|
exec /system/bin/sh "$@"
|
|
;;
|
|
*)
|
|
export TMPDIR=/dev/tmp
|
|
rm -rf $TMPDIR 2>/dev/null
|
|
setup_bb
|
|
export INSTALLER=$TMPDIR/install
|
|
mkdir -p $INSTALLER
|
|
unzip -o "$3" -d $INSTALLER >&2
|
|
exec sh $INSTALLER/META-INF/com/google/android/updater-script "$@"
|
|
;;
|
|
esac
|
|
exit
|