forked from Deevad/compilscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vc-install.sh
executable file
·244 lines (214 loc) · 6.2 KB
/
vc-install.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
#!/bin/sh
#
#: Title : Vc-install
#: Author : David REVOY < info@davidrevoy.com >
#: License : GPL ; read LICENSE
# Inspired by : Spell script : http://pastebin.com/KkT9SvTs , Kubuntiac script : http://forum.kde.org/viewtopic.php?f=139&t=92880
# Script version
scriptversion="v0.3"
# Project name
project=vc
# Version to build
vcVersion=0.7.0
# Help page
helppage=https://github.com/Deevad/compilscripts
# Root directory
directory=$HOME/Software
# Subfolder
srcDir=$directory/$project/src
buildDir=$directory/$project/build
# CPU available
numCores=$((`cat /proc/cpuinfo | grep processor | wc -l`))
# Git repository adress
gitRepo=git://gitorious.org/vc/vc.git
# Color lib
PINK="\033[1;35m"
BLACK="\033[1;0m"
BLUE="\033[1;34m"
GREEN="\033[1;32m"
RED="\033[1;31m"
_separators()
{
echo " "
echo "${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLUE}-${PINK}=${BLACK}"
echo " "
}
_setup_dir()
{
mkdir -p $srcDir
mkdir -p $buildDir
}
_done()
{
echo " "
echo "${GREEN}------------------------------------------------------------"
echo " All task requested are now done"
echo "-----------------------------------------------------------"
echo " Note : this doesn't mean everything was fine, check the log for more info.${BLACK}"
echo " "
}
_install_dependencies()
{
echo "${RED}<<>><<>><<>><<>><<>><<>><<>> WARNING <<>><<>><<>><<>><<>><<>><<>>"
echo " "
echo "IMPORTANT : TO-READ AND TO-DO"
echo " "
echo "This part will do an attempt to auto-install all the dependencies "
echo "for building $project. Around 150MB will be necessary to perform it"
echo " "
echo "Also ; a full system update/upgrade will be done"
echo " "
echo "<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>${BLACK}"
echo -n " press [Enter] when your system is setup and ready, or [Ctrl+C] to exit"
read CHOICE
echo "${BLUE}------------------------------------------------------"
echo "UPDATING SYSTEM"
echo "------------------------------------------------------${BLACK}"
echo " "
sudo apt-get -y update
sudo apt-get -y upgrade
echo "${BLUE}------------------------------------------------------"
echo "INSTALLING DEPENDENCIES"
echo "------------------------------------------------------${BLACK}"
echo " "
sudo apt-get -y install build-essential git cmake
echo "${BLUE}------------------------------------------------------"
echo "CHECK BROKEN PACKAGES"
echo "------------------------------------------------------${BLACK}"
echo " "
sudo apt-get -f install
}
_get_sources()
{
cd $directory/$project/
_separators
echo "${BLUE} Now, updating $project source with GIT ${BLACK}"
git clone -b $vcVersion $gitRepo src
}
_compile_sources()
{
cd $buildDir
_separators
echo "${BLUE} Now, configuring, compiling, installing ... this is the main part of the script, error are important to read ${BLACK}"
echo "${BLUE} [ Note: this part can take from 2min to 30min depending of your CPU and disk speed access ] ${BLACK}"
echo " "
cmake ../src
make -j$numCores
_separators
echo "${BLUE} Now, installing $project direcly into your system ${BLACK}"
echo "${BLUE} [ Note: to install it, the script will ask you probably your password ] ${BLACK}"
echo " "
sudo make install -j$numCores
}
_update_sources()
{
cd $srcDir
_separators
echo "${BLUE} Now, updating $project source with GIT ${BLACK}"
git pull
}
_user_reset_master()
{
echo "${BLUE}------------------------------------------------------"
echo "RESET TO MASTER"
echo "------------------------------------------------------${BLACK}"
echo " "
cd $srcDir
git reset --hard $vcVersion
git checkout $vcVersion
git pull
git clean -dfx
_compile_sources
_done
}
_user_install()
{
echo "${BLUE}------------------------------------------------------"
echo "INSTALLATION"
echo "------------------------------------------------------${BLACK}"
echo " "
_setup_dir
_install_dependencies
_get_sources
_update_sources
_compile_sources
_done
}
_user_compile_only()
{
echo "${BLUE}------------------------------------------------------"
echo "COMPILE ONLY"
echo "------------------------------------------------------${BLACK}"
echo " "
_compile_sources
_done
}
_user_update()
{
echo "${BLUE}------------------------------------------------------"
echo "UPDATE"
echo "------------------------------------------------------${BLACK}"
echo " "
_update_sources
_compile_sources
_done
}
_endkey()
{
# a key to exit
echo -n "Press [enter] to exit"
read END
}
#######
# UI #
#######
clear
echo "${PINK} "
echo " _ "
echo " \/(_ "
echo " "
echo "${BLACK} "
echo " Welcome, this script will help you to compile and update $project"
echo " "
echo "${GREEN} *Infos*${BLACK} "
echo " - script version : "$scriptversion
echo " - source path : "$srcDir
echo " - build path : "$buildDir
echo " - install path : installed in your system"
echo " "
# menu
echo "${BLUE}------------------------------------------------------------${BLACK}"
echo "${BLUE} MENU ${BLACK}"
echo " "
echo " (1) Install"
echo " (2) Update"
echo " (3) Compile only"
echo " (4) Reset to master"
echo " (5) Online manual "
echo " (6) Exit"
echo " "
echo "${BLUE}------------------------------------------------------------${BLACK}"
echo -n " Enter your choice (1-7) then press [enter] :${PINK}"
read mainmenu
echo " "
echo " ${BLACK}"
clear
if [ "$mainmenu" = 1 ]; then
_user_install
_endkey
elif [ "$mainmenu" = 2 ]; then
_user_update
_endkey
elif [ "$mainmenu" = 3 ]; then
_user_compile_only
_endkey
elif [ "$mainmenu" = 4 ]; then
_user_reset_master
_endkey
elif [ "$mainmenu" = 5 ]; then
xdg-open $helppage
elif [ "$mainmenu" = 6 ]; then
echo " ${PINK}Bye Bye ! ${BLACK} "
else
echo "the script couldn't understand your choice, try again...";
fi;