-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmfastboot.sh
executable file
·79 lines (68 loc) · 1.4 KB
/
mfastboot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#! /bin/bash
#
# fastboot wrapper
#
PRO=$(basename "$0")
# fastboot
FASTBOOT='/opt/bin/fastboot'
if [[ ! -x $FASTBOOT ]]; then
echo "$PRO: error: invalid $FASTBOOT."
exit 1
fi
# root permission
if [[ $UID != 0 ]]; then
FASTBOOT="sudo $FASTBOOT"
fi
# if argc>0, call fastboot directly
if [[ -n $1 ]]; then
exec $FASTBOOT "$@"
fi
# dir
if [[ -d $ANDROID_PRODUCT_OUT ]]; then
IMAGE_DIR=$ANDROID_PRODUCT_OUT
else
IMAGE_DIR=$PWD
fi
# name partition map
declare -A ntop
for img in "$IMAGE_DIR"/*.{img,ext4}; do
name=${img##*/}
case $name in
boot.img|boot.2knand.img)
ntop[$name]='boot'
;;
userdata.img.ext4|userdata.2knand.img|userdata.img)
ntop[$name]='userdata'
;;
system.img.ext4|system.2knand.img|system.img)
ntop[$name]='system'
;;
custpack.img.ext4|custpack.2knand.img|custpack.img)
ntop[$name]='custpack'
;;
recovery.img|recovery.2knand.img)
ntop[$name]='recovery'
;;
cache.img.ext4|cache.img)
ntop[$name]='cache'
;;
persist.img)
ntop[$name]='persist'
;;
*)
continue
;;
esac
all="$all $name"
done
if [[ -z $all ]]; then
echo "$PRO: warning: no image in $IMAGE_DIR."
exit 1
fi
select img in $all; do
$FASTBOOT flash ${ntop[$img]} "$IMAGE_DIR/$img"
done
if [[ -n $($FASTBOOT devices) ]]; then
$FASTBOOT reboot
fi
exit $?