forked from FreedomBen/rtl8188ce-linux-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify_branch.sh
executable file
·127 lines (117 loc) · 5.47 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
#/bin/sh
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/# 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 "3.15" > /dev/null); then
doSwitch "arch"
elif $(uname -r | grep "3.14" > /dev/null); then
doSwitch "fedora-20"
elif $(uname -r | grep "3.13" > /dev/null); then
doSwitch "ubuntu-14.04"
elif $(uname -r | grep "3.12" > /dev/null); then
doSwitch "fedora-20"
elif $(uname -r | grep "3.11" > /dev/null); then
if runningFedora; then
doSwitch "fedora-20"
else
doSwitch "ubuntu-13.10"
fi
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 "3.15" > /dev/null) && ! $(echo "$base" | grep "arch" > /dev/null) ) || \
( $(uname -r | grep "3.14" > /dev/null) && ! $(echo "$base" | grep "fedora-20" > /dev/null) ) || \
( $(uname -r | grep "3.13" > /dev/null) && ! $(echo "$base" | grep "ubuntu-14.04" > /dev/null) ) || \
( $(uname -r | grep "3.12" > /dev/null) && ! $(echo "$base" | grep "fedora-20" > /dev/null) ) || \
( $(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