-
Notifications
You must be signed in to change notification settings - Fork 235
/
url2SGSI.sh
executable file
·105 lines (90 loc) · 1.93 KB
/
url2SGSI.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
# Inspired from url2GSI from ErfanGSIs tool at https://github.com/erfanoabdi/ErfanGSIs
# Rebased: Rahul at https://github.com/rahulkhatri137
# Final change: Xiaoxindada at https://github.com/xiaoxindada
LOCALDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
source ./bin.sh
fixbug=true
build="--ab"
usage() {
cat <<EOT
Usage:
$0 <Firmware link> <Firmware type> <Build Type> <Fixbug>
Firmware link: Firmware download link or local path
Firmware type: Firmware source type
Build Type: ab or a
Fixbug: [fb|--fb|-fb] to disable Fixbug
EOT
exit 1
}
if [ $# -lt 2 ];then
usage
fi
case "$1" in
--help|-h|-?)
usage
;;
esac
URL=$1
shift
TYPE=$1
shift
if ! (cat $COMPONENT/rom_support_list.txt | tr " " "\n" | grep -qo ^$TYPE$); then
echo "Current rom type not support"
echo "List of supported:"
cat $COMPONENT/rom_support_list.txt
exit 1
fi
build="$1"
case $build in
ab|AB|--ab|-ab|--AB|-AB)
build="--ab"
shift
;;
a|A|--a|-a|-A|--A)
build="-a"
shift
;;
*)
build="--ab"
;;
esac
fixbug="$1"
case $fixbug in
fb|--fb|--FB|-fb|-FB)
fixbug=false
shift
;;
*)
fixbug=true
shift
;;
esac
rm -rf tmp output workspace SGSI
LEAVE() {
echo "SGSI failed! Exiting..."
rm -rf "$LOCALDIR/output" "$LOCALDIR/workspace" "$LOCALDIR/tmp" "$LOCALDIR/SGSI"
exit 1
}
if [[ "$URL" == "http"* ]]; then
echo "Downloading firmware..."
mkdir -p "$LOCALDIR/tmp"
ZIP="$LOCALDIR/tmp/update.zip"
ZIP_NAME="update.zip"
aria2c -x16 -j$(nproc) -U "Mozilla/5.0" -d "$LOCALDIR/tmp" -o "$ZIP_NAME" ${URL}
else
echo "Url not support!"
exit 1
fi
if [ $fixbug == true ]; then
"$LOCALDIR"/make.sh $build $TYPE $ZIP --fix-bug || LEAVE
elif [ $fixbug == false ] ; then
"$LOCALDIR"/make.sh $build $TYPE $ZIP || LEAVE
fi
rm -rf "$LOCALDIR/tmp"
rm -rf "$LOCALDIR/workspace"
if [ -d "$LOCALDIR/SGSI" ]; then
echo "Porting SGSI done!"
else
LEAVE
fi