2017-08-02 12:23:42 +02:00
|
|
|
# EX_ARM, EX_X86, BB_ARM, and BB_X86 should be generated in build.py
|
2018-05-13 08:26:28 +02:00
|
|
|
extract_bb() {
|
|
|
|
EXBIN=$BBDIR/b64xz; BBBIN=$BBDIR/busybox
|
|
|
|
touch $EXBIN; touch $BBBIN; chmod 755 $EXBIN $BBBIN
|
|
|
|
echo -ne $EX_ARM > $EXBIN
|
|
|
|
if $EXBIN --test 2>/dev/null; then
|
|
|
|
echo $BB_ARM | $EXBIN > $BBBIN
|
|
|
|
else
|
|
|
|
echo -ne $EX_X86 > $EXBIN
|
|
|
|
echo $BB_X86 | $EXBIN > $BBBIN
|
|
|
|
fi
|
|
|
|
rm $EXBIN
|
|
|
|
}
|
|
|
|
setup_bb() {
|
|
|
|
BBDIR=$TMPDIR/bin; mkdir -p $BBDIR 2>/dev/null
|
|
|
|
extract_bb
|
|
|
|
$BBBIN --install -s $BBDIR
|
|
|
|
export PATH=$BBDIR:$PATH
|
|
|
|
}
|
|
|
|
case "$1" in
|
|
|
|
"extract")
|
|
|
|
[ -z "$2" ] && BBDIR=. || BBDIR="$2"
|
|
|
|
extract_bb
|
|
|
|
;;
|
|
|
|
"indep")
|
2018-07-09 20:44:58 +02:00
|
|
|
TMPDIR=.; setup_bb; shift
|
|
|
|
exec /system/bin/sh "$@"
|
2018-05-13 08:26:28 +02:00
|
|
|
;;
|
|
|
|
*)
|
2018-07-09 20:44:58 +02:00
|
|
|
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 "$@"
|
2018-05-13 08:26:28 +02:00
|
|
|
;;
|
|
|
|
esac
|