Magisk/scripts/update_binary.sh
topjohnwu 23e5188422 Update scripts
1. Update build.py to use f-strings
2. Directly append busybox binaries to update-binary
3. Remove b64xz
2019-01-15 08:32:18 -05:00

38 lines
825 B
Bash

#!/sbin/sh
X86_CNT=__X86_CNT__
extract_bb() {
case `uname -m` in
x*) dd if="$0" of="$BBBIN" bs=1024 skip=1 count=$X86_CNT ;;
*) dd if="$0" of="$BBBIN" bs=1024 skip=$(($X86_CNT + 1));;
esac
chmod 755 "$BBBIN"
}
setup_bb() {
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