mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 02:25:28 +00:00
Add extract feature to update-binary
This commit is contained in:
parent
c3c78428c4
commit
9b445d89a1
@ -1,16 +1,12 @@
|
|||||||
# EX_ARM, EX_X86, BB_ARM, and BB_X86 should be generated in build.py
|
# EX_ARM, EX_X86, BB_ARM, and BB_X86 should be generated in build.py
|
||||||
dirname_wrap() {
|
getdir() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
*/*) dir=${1%/*}; [ -z $dir ] && echo "/" || echo $dir ;;
|
*/*) dir=${1%/*}; [ -z $dir ] && echo "/" || echo $dir ;;
|
||||||
*) echo "." ;;
|
*) echo "." ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
[ "$1" = "indep" ] && INDEP=true || INDEP=false
|
extract_bb() {
|
||||||
$INDEP && TMPDIR="`dirname_wrap "${BASH_SOURCE:-$0}"`" || TMPDIR=/dev/tmp
|
|
||||||
INSTALLER=$TMPDIR/install; BBDIR=$TMPDIR/bin
|
|
||||||
EXBIN=$BBDIR/b64xz; BBBIN=$BBDIR/busybox
|
EXBIN=$BBDIR/b64xz; BBBIN=$BBDIR/busybox
|
||||||
$INDEP || rm -rf $TMPDIR 2>/dev/null;
|
|
||||||
mkdir -p $BBDIR 2>/dev/null
|
|
||||||
touch $EXBIN; touch $BBBIN; chmod 755 $EXBIN $BBBIN
|
touch $EXBIN; touch $BBBIN; chmod 755 $EXBIN $BBBIN
|
||||||
echo -ne $EX_ARM > $EXBIN
|
echo -ne $EX_ARM > $EXBIN
|
||||||
if $EXBIN --test 2>/dev/null; then
|
if $EXBIN --test 2>/dev/null; then
|
||||||
@ -19,13 +15,26 @@ else
|
|||||||
echo -ne $EX_X86 > $EXBIN
|
echo -ne $EX_X86 > $EXBIN
|
||||||
echo $BB_X86 | $EXBIN > $BBBIN
|
echo $BB_X86 | $EXBIN > $BBBIN
|
||||||
fi
|
fi
|
||||||
$BBBIN --install -s $TMPDIR/bin
|
rm $EXBIN
|
||||||
|
}
|
||||||
|
setup_bb() {
|
||||||
|
BBDIR=$TMPDIR/bin; mkdir -p $BBDIR 2>/dev/null
|
||||||
|
extract_bb
|
||||||
|
$BBBIN --install -s $BBDIR
|
||||||
export PATH=$BBDIR:$PATH
|
export PATH=$BBDIR:$PATH
|
||||||
if $INDEP; then
|
}
|
||||||
shift
|
case "$1" in
|
||||||
exec sh "$@"
|
"extract")
|
||||||
else
|
[ -z "$2" ] && BBDIR=. || BBDIR="$2"
|
||||||
mkdir -p $INSTALLER
|
extract_bb
|
||||||
unzip -o "$3" -d $INSTALLER
|
;;
|
||||||
|
"indep")
|
||||||
|
TMPDIR="`getdir "${BASH_SOURCE:-$0}"`"; setup_bb
|
||||||
|
shift; exec sh "$@"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
TMPDIR=/dev/tmp; rm -rf $TMPDIR 2>/dev/null; setup_bb
|
||||||
|
INSTALLER=$TMPDIR/install; mkdir -p $INSTALLER; unzip -o "$3" -d $INSTALLER
|
||||||
exec sh $INSTALLER/META-INF/com/google/android/updater-script $@
|
exec sh $INSTALLER/META-INF/com/google/android/updater-script $@
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user