-
Notifications
You must be signed in to change notification settings - Fork 109
/
verify_branch.sh
executable file
·303 lines (293 loc) · 17.8 KB
/
verify_branch.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
#!/bin/bash
if [ ! -f "functions.sh" ]; then
echo "Error: Required file functions.sh not present" >&2
exit 1
else
. "$(readlink -f functions.sh)"
fi
doSwitch ()
{
BRANCH="$1"
CUR_BRANCH="$(git status --branch | head -1 | sed 's/#//g' | sed 's/On branch //g')"
if $(git status | grep "$BRANCH" > /dev/null); then
echo "Yes"
else
echo "No (Current branch $CUR_BRANCH)"
echo "Recommended branch is $BRANCH based on your kernel version ($(uname -r))"
read -p "Should I switch it to $BRANCH for you? (y/n): " input
if [ "$input" = "y" ]; then
git checkout -f $BRANCH
else
echo "OK, but if the build fails come back here and try again."
read -p "Continue with the build? (Y/N): " input
if ! [ "$input" = "Y" -o "$input" = "y" ]; then
exit 1
fi
fi
fi
}
echo "Verifying a sane branch for your kernel version..."
if inGitRepo; then
if $(uname -r | grep "6.0" > /dev/null); then
doSwitch "generic-6.0.x"
elif $(uname -r | grep "5.19" > /dev/null); then
doSwitch "generic-5.19.x"
elif $(uname -r | grep "5.18" > /dev/null); then
doSwitch "generic-5.18.x"
elif $(uname -r | grep "5.17" > /dev/null); then
doSwitch "generic-5.17.x"
elif $(uname -r | grep "5.16" > /dev/null); then
doSwitch "generic-5.16.x"
elif $(uname -r | grep "5.15" > /dev/null); then
doSwitch "generic-5.15.x"
elif $(uname -r | grep "5.14" > /dev/null); then
doSwitch "generic-5.14.x"
elif $(uname -r | grep "5.13" > /dev/null); then
doSwitch "generic-5.13.x"
elif $(uname -r | grep "5.12" > /dev/null); then
doSwitch "generic-5.12.x"
elif $(uname -r | grep "5.11" > /dev/null); then
doSwitch "generic-5.11.x"
elif $(uname -r | grep "5.10" > /dev/null); then
doSwitch "generic-5.10.x"
elif $(uname -r | grep "5.9" > /dev/null); then
doSwitch "generic-5.9.x"
elif $(uname -r | grep "5.8" > /dev/null); then
doSwitch "generic-5.8.x"
elif $(uname -r | grep "5.7" > /dev/null); then
doSwitch "generic-5.7.x"
elif $(uname -r | grep "5.6" > /dev/null); then
doSwitch "generic-5.6.x"
elif $(uname -r | grep "5.5" > /dev/null); then
doSwitch "generic-5.5.x"
elif $(uname -r | grep "5.4" > /dev/null); then
if runningUbuntuKernel; then
doSwitch "ubuntu-20.04"
else
doSwitch "generic-5.4.x"
fi
elif $(uname -r | grep "5.3" > /dev/null); then
doSwitch "generic-5.3.x"
elif $(uname -r | grep "5.2" > /dev/null); then
doSwitch "generic-5.2.x"
elif $(uname -r | grep "5.1" > /dev/null); then
doSwitch "generic-5.1.x"
elif $(uname -r | grep "5.0" > /dev/null); then
doSwitch "generic-5.0.x"
elif $(uname -r | grep "4.20" > /dev/null); then
doSwitch "generic-4.20.x"
elif $(uname -r | grep "4.19" > /dev/null); then
doSwitch "generic-4.19.x"
elif $(uname -r | grep "4.18" > /dev/null); then
doSwitch "generic-4.18.x"
elif $(uname -r | grep "4.17" > /dev/null); then
doSwitch "generic-4.17.x"
elif $(uname -r | grep "4.16" > /dev/null); then
doSwitch "generic-4.16.x"
elif $(uname -r | grep "4.15" > /dev/null); then
if runningUbuntuKernel; then
doSwitch "ubuntu-18.04"
else
doSwitch "generic-4.15.x"
fi
elif $(uname -r | grep "4.14" > /dev/null); then
doSwitch "generic-4.14.x"
elif $(uname -r | grep "4.13" > /dev/null); then
if runningUbuntuKernel; then
doSwitch "ubuntu-17.10"
else
doSwitch "generic-4.13.x"
fi
elif $(uname -r | grep "4.12" > /dev/null); then
doSwitch "generic-4.12.x"
elif $(uname -r | grep "4.11" > /dev/null); then
doSwitch "generic-4.11.x"
elif $(uname -r | grep "4.10" > /dev/null); then
if runningUbuntuKernel; then
doSwitch "ubuntu-17.04"
else
doSwitch "generic-4.10.x"
fi
elif $(uname -r | grep "4.9" > /dev/null); then
doSwitch "generic-4.9.x"
elif $(uname -r | grep "4.8" > /dev/null); then
if runningUbuntuKernel; then
doSwitch "ubuntu-16.10"
else
doSwitch "generic-4.8.x"
fi
elif $(uname -r | grep "4.7" > /dev/null); then
doSwitch "generic-4.7.x"
elif $(uname -r | grep "4.6" > /dev/null); then
doSwitch "generic-4.6.x"
elif $(uname -r | grep "4.5" > /dev/null); then
doSwitch "generic-4.5.x"
elif $(uname -r | grep "4.4" > /dev/null); then
if runningUbuntuKernel; then
doSwitch "ubuntu-16.04"
else
doSwitch "generic-4.4.x"
fi
elif $(uname -r | grep "4.3" > /dev/null); then
doSwitch "generic-4.3.x"
elif $(uname -r | grep "4.2" > /dev/null); then
if runningUbuntuKernel; then
doSwitch "ubuntu-15.10"
else
doSwitch "generic-4.2.x"
fi
elif $(uname -r | grep "4.1" > /dev/null); then
doSwitch "generic-4.1.x"
elif $(uname -r | grep "4.0" > /dev/null); then
doSwitch "generic-4.0.x"
elif $(uname -r | grep "3.19" > /dev/null); then
if runningUbuntuKernel; then
doSwitch "ubuntu-15.04"
else
doSwitch "generic-3.19.x"
fi
elif $(uname -r | grep "3.18" > /dev/null); then
doSwitch "generic-3.18.x"
elif $(uname -r | grep "3.17" > /dev/null); then
doSwitch "generic-3.17.x"
elif $(uname -r | grep "3.16" > /dev/null); then
if runningUbuntuKernel; then
doSwitch "ubuntu-14.10"
else
doSwitch "generic-3.16.x"
fi
elif $(uname -r | grep "3.15" > /dev/null); then
doSwitch "generic-3.15.x"
elif $(uname -r | grep "3.14" > /dev/null); then
doSwitch "generic-3.14.x"
elif $(uname -r | grep "3.13" > /dev/null); then
if runningMint171; then
doSwitch "mint-17.1"
elif runningMint; then
doSwitch "mint-17"
elif runningUbuntuKernel; then
doSwitch "ubuntu-14.04"
else
doSwitch "generic-3.13.x"
fi
elif $(uname -r | grep "3.11" > /dev/null); then
doSwitch "ubuntu-13.10"
elif $(uname -r | grep "3.8" > /dev/null); then
doSwitch "ubuntu-13.04"
elif $(uname -r | grep "3.2" > /dev/null); then
doSwitch "ubuntu-12.04"
else
echo "You are running kernel $(uname -r), which is not well supported."
echo "See the README.md for recommended branch."
read -p "Continue with the build? (Y/N): " input
if ! [ "$input" = "Y" -o "$input" = "y" ]; then
exit 1
fi
fi
else
base="$(basename $(pwd))"
if ( $(uname -r | grep "6.0" > /dev/null) && ! $(echo "$base" | grep "generic-6.0.x" > /dev/null) ) || \
( $(uname -r | grep "5.19" > /dev/null) && ! $(echo "$base" | grep "generic-5.19.x" > /dev/null) ) || \
( $(uname -r | grep "5.18" > /dev/null) && ! $(echo "$base" | grep "generic-5.18.x" > /dev/null) ) || \
( $(uname -r | grep "5.17" > /dev/null) && ! $(echo "$base" | grep "generic-5.17.x" > /dev/null) ) || \
( $(uname -r | grep "5.16" > /dev/null) && ! $(echo "$base" | grep "generic-5.16.x" > /dev/null) ) || \
( $(uname -r | grep "5.15" > /dev/null) && ! $(echo "$base" | grep "generic-5.15.x" > /dev/null) ) || \
( $(uname -r | grep "5.14" > /dev/null) && ! $(echo "$base" | grep "generic-5.14.x" > /dev/null) ) || \
( $(uname -r | grep "5.13" > /dev/null) && ! $(echo "$base" | grep "generic-5.13.x" > /dev/null) ) || \
( $(uname -r | grep "5.12" > /dev/null) && ! $(echo "$base" | grep "generic-5.12.x" > /dev/null) ) || \
( $(uname -r | grep "5.11" > /dev/null) && ! $(echo "$base" | grep "generic-5.11.x" > /dev/null) ) || \
( $(uname -r | grep "5.10" > /dev/null) && ! $(echo "$base" | grep "generic-5.10.x" > /dev/null) ) || \
( $(uname -r | grep "5.9" > /dev/null) && ! $(echo "$base" | grep "generic-5.9.x" > /dev/null) ) || \
( $(uname -r | grep "5.8" > /dev/null) && ! $(echo "$base" | grep "generic-5.8.x" > /dev/null) ) || \
( $(uname -r | grep "5.7" > /dev/null) && ! $(echo "$base" | grep "generic-5.7.x" > /dev/null) ) || \
( $(uname -r | grep "5.6" > /dev/null) && ! $(echo "$base" | grep "generic-5.6.x" > /dev/null) ) || \
( $(uname -r | grep "5.5" > /dev/null) && ! $(echo "$base" | grep "generic-5.5.x" > /dev/null) ) || \
( $(uname -r | grep "5.4" > /dev/null) && ! $(echo "$base" | grep "generic-5.4.x" > /dev/null) ) && ! $(echo "$base" | grep "ubuntu-20.04" > /dev/null) || \
( $(uname -r | grep "5.3" > /dev/null) && ! $(echo "$base" | grep "generic-5.3.x" > /dev/null) ) || \
( $(uname -r | grep "5.2" > /dev/null) && ! $(echo "$base" | grep "generic-5.2.x" > /dev/null) ) || \
( $(uname -r | grep "5.1" > /dev/null) && ! $(echo "$base" | grep "generic-5.1.x" > /dev/null) ) || \
( $(uname -r | grep "5.0" > /dev/null) && ! $(echo "$base" | grep "generic-5.0.x" > /dev/null) ) || \
( $(uname -r | grep "4.20" > /dev/null) && ! $(echo "$base" | grep "generic-4.20.x" > /dev/null) ) || \
( $(uname -r | grep "4.19" > /dev/null) && ! $(echo "$base" | grep "generic-4.19.x" > /dev/null) ) || \
( $(uname -r | grep "4.18" > /dev/null) && ! $(echo "$base" | grep "generic-4.18.x" > /dev/null) ) || \
( $(uname -r | grep "4.17" > /dev/null) && ! $(echo "$base" | grep "generic-4.17.x" > /dev/null) ) || \
( $(uname -r | grep "4.16" > /dev/null) && ! $(echo "$base" | grep "generic-4.16.x" > /dev/null) ) || \
( $(uname -r | grep "4.15" > /dev/null) && ! $(echo "$base" | grep "generic-4.15.x" > /dev/null) ) && ! $(echo "$base" | grep "ubuntu-18.04" > /dev/null) || \
( $(uname -r | grep "4.14" > /dev/null) && ! $(echo "$base" | grep "generic-4.14.x" > /dev/null) ) || \
( $(uname -r | grep "4.13" > /dev/null) && ! $(echo "$base" | grep "generic-4.13.x" > /dev/null) ) && ! $(echo "$base" | grep "ubuntu-17.10" > /dev/null) || \
( $(uname -r | grep "4.12" > /dev/null) && ! $(echo "$base" | grep "generic-4.12.x" > /dev/null) ) || \
( $(uname -r | grep "4.11" > /dev/null) && ! $(echo "$base" | grep "generic-4.11.x" > /dev/null) ) || \
( $(uname -r | grep "4.10" > /dev/null) && ! $(echo "$base" | grep "generic-4.10.x" > /dev/null) ) && ! $(echo "$base" | grep "ubuntu-17.04" > /dev/null) || \
( $(uname -r | grep "4.9" > /dev/null) && ! $(echo "$base" | grep "generic-4.9.x" > /dev/null) ) || \
( $(uname -r | grep "4.8" > /dev/null) && ! $(echo "$base" | grep "generic-4.8.x" > /dev/null) ) && ! $(echo "$base" | grep "ubuntu-16.10" > /dev/null) || \
( $(uname -r | grep "4.7" > /dev/null) && ! $(echo "$base" | grep "generic-4.7.x" > /dev/null) ) || \
( $(uname -r | grep "4.6" > /dev/null) && ! $(echo "$base" | grep "generic-4.6.x" > /dev/null) ) || \
( $(uname -r | grep "4.5" > /dev/null) && ! $(echo "$base" | grep "generic-4.5.x" > /dev/null) ) || \
( $(uname -r | grep "4.4" > /dev/null) && ! $(echo "$base" | grep "generic-4.4.x" > /dev/null) ) && ! $(echo "$base" | grep "ubuntu-16.04" > /dev/null) || \
( $(uname -r | grep "4.3" > /dev/null) && ! $(echo "$base" | grep "generic-4.3.x" > /dev/null) ) || \
( $(uname -r | grep "4.2" > /dev/null) && ! $(echo "$base" | grep "generic-4.2.x" > /dev/null) ) && ! $(echo "$base" | grep "ubuntu-15.10" > /dev/null) || \
( $(uname -r | grep "4.1" > /dev/null) && ! $(echo "$base" | grep "generic-4.1.x" > /dev/null) ) || \
( $(uname -r | grep "4.0" > /dev/null) && ! $(echo "$base" | grep "generic-4.0.x" > /dev/null) ) || \
( $(uname -r | grep "3.19" > /dev/null) && ! $(echo "$base" | grep "generic-3.19.x" > /dev/null) ) && ! $(echo "$base" | grep "ubuntu-15.04" > /dev/null) || \
( $(uname -r | grep "3.18" > /dev/null) && ! $(echo "$base" | grep "generic-3.18.x" > /dev/null) ) || \
( $(uname -r | grep "3.17" > /dev/null) && ! $(echo "$base" | grep "generic-3.17.x" > /dev/null) ) || \
( $(uname -r | grep "3.16" > /dev/null) && ! $(echo "$base" | grep "ubuntu-14.10" > /dev/null) ) && ! $(echo "$base" | grep "generic-3.16.x" > /dev/null) || \
( $(uname -r | grep "3.15" > /dev/null) && ! $(echo "$base" | grep "arch" > /dev/null) ) && ! $(echo "$base" | grep "fedora-20" > /dev/null) || \
( $(uname -r | grep "3.14" > /dev/null) && ! $(echo "$base" | grep "generic-3.14.x" > /dev/null) ) || \
( $(uname -r | grep "3.13" > /dev/null) && ! $(echo "$base" | grep "ubuntu-14.04" > /dev/null) ) && ! $(echo "$base" | grep "generic-3.13.x" > /dev/null) || \
# Add a check for mint-17 and mint-17.1 branches
( $(uname -r | grep "3.11" > /dev/null) && ! $(echo "$base" | grep "fedora-20" > /dev/null) ) && ! $(echo "$base" | grep "ubuntu-13.10" > /dev/null) || \
( $(uname -r | grep "3.8" > /dev/null) && ! $(echo "$base" | grep "ubuntu-13.04" > /dev/null) ) || \
( $(uname -r | grep "3.2" > /dev/null) && ! $(echo "$base" | grep "ubuntu-12.04" > /dev/null) )
then
echo "No (current branch $base)"
echo -e "\nYou don't appear to be in a Git checkout.\nThis means branch information is not available.\nYou can still proceed to build, but you might be using unstable code."
read -p "Would you like me to try and get a git checkout for you? (Y/N): " checkout
if [ "$checkout" = "y" -o "$checkout" = "Y" ]; then
installBuildDependencies
dirname="rtl8188ce-linux-driver"
deleteok="NOT_ASKED"
if [ -d "$dirname" ]; then
echo ""
read -p "The target directory already exists. Is it ok if I delete it? (I'll be replacing it) (Y/N): " deleteok
if [ "$deleteok" = "Y" -o "$deleteok" = "y" ]; then
rm -rf "$dirname"
fi
fi
if [ ! -d "$dirname" ]; then
git clone https://github.com/FreedomBen/rtl8188ce-linux-driver.git
if [ -d "$dirname" ]; then
rm -rf *.c *.o *.h *.bz2 *.ko compat/ firmware/ Kconfig Makefile modules.order Module.symvers rtl8188ee/ rtl8188ce/ rtl8192* rtl8723e
echo -e "\nLooks like the clone was successful (new folder is $(readlink -f $dirname))"
echo -e "Kicking off the build...\n"
cd "$dirname" && make
if (( $? )); then
echo -e "\nBuild exited with success status."
else
echo -e "\nBuild exited with failure status (Exit code $?)."
fi
echo "To install, cd over to $dirname and run \"sudo make install\""
else
echo -e "\nSomething went wrong and I couldn't clone the repo."
read -p "Continue with the build? (Y/N): " input
if ! [ "$input" = "Y" -o "$input" = "y" ]; then
exit 1
fi
fi
else
echo -e "\nDid not clone the git repo because the target already exists"
read -p "Continue with the build? (Y/N): " input
if ! [ "$input" = "Y" -o "$input" = "y" ]; then
exit 1
fi
fi
else
read -p "Continue with the build? (Y/N): " input
if ! [ "$input" = "Y" -o "$input" = "y" ]; then
exit 1
fi
fi
else
echo "Yes"
fi
fi