forked from seba76/virtualbox4dsm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.sh
executable file
·251 lines (234 loc) · 7.32 KB
/
config.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
#!/bin/sh
VirtualBoxVersion=6.1.4-136177
VirtualBoxBase=https://download.virtualbox.org/virtualbox/6.1.4/
VirtualBoxFile=VirtualBox-${VirtualBoxVersion}-Linux_amd64.run
ExtensionPackFile=Oracle_VM_VirtualBox_Extension_Pack-${VirtualBoxVersion}.vbox-extpack
# If files don't exist they need to be downloaded
VirtualBoxUrl=${VirtualBoxBase}${VirtualBoxFile}
ExtensionPackUrl=${VirtualBoxBase}${ExtensionPackFile}
WGET=$(which wget)
UNZIP=$(which unzip)
if [ "$WGET" == "" ]; then
WGET=./wget
fi
if [ "$UNZIP" == "" ]; then
UNZIP="./unzip"
fi
function prompt_for_source()
{
DSM_VER=dsm62
DSM_BRANCH=22259
DSM_PLAT=bromolow
PS3='Please select DSM varsion: '
options=("DSM 6.1 (15152)" "DSM 6.2 (22259)" "Quit")
select opt in "${options[@]}"
do
case $opt in
"DSM 6.1 (15152)")
DSM_VER=dsm61
DSM_BRANCH=15152
break
;;
"DSM 6.2 (22259)")
DSM_VER=dsm62
DSM_BRANCH=22259
break
;;
"Quit")
exit 1
break
;;
*) echo "invalid option $REPLY";;
esac
done
# when you add new platform you need to add it to build, install and vboxdrv.sh
PS3='Please select platform: '
options=("bromolow" "x64" "broadwell" "braswell" "cedarview" "avoton" "Quit")
select opt in "${options[@]}"
do
case $opt in
"bromolow")
DSM_PLAT=bromolow
break
;;
"x64")
DSM_PLAT=x64
break
;;
"broadwell")
DSM_PLAT=broadwell
break
;;
"braswell")
DSM_PLAT=braswell
break
;;
"cedarview")
DSM_PLAT=cedarview
break
;;
"avoton")
DSM_PLAT=avoton
break
;;
"Quit")
exit 1
break
;;
*) echo "invalid option $REPLY";;
esac
done
if [ "$DSM_VER" == "dsm61" ]; then
case $DSM_PLAT in
bromolow)
echo "Setting kernel download link for branch $DSM_BRANCH, $DSM_PLAT platform"
KernelTar=https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/15152branch/bromolow-source/linux-3.10.x.txz/download
;;
x64)
echo "Setting kernel download link for branch $DSM_BRANCH, $DSM_PLAT platform"
KernelTar=https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/15152branch/x64-source/linux-3.10.x.txz/download
;;
broadwell)
echo "Setting kernel download link for branch $DSM_BRANCH, $DSM_PLAT platform"
KernelTar=https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/15152branch/broadwell-source/linux-3.10.x.txz/download
;;
braswell)
echo "Setting kernel download link for branch $DSM_BRANCH, $DSM_PLAT platform"
KernelTar=https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/15152branch/braswell-source/linux-3.10.x.txz/download
;;
cedarview)
echo "Setting kernel download link for branch $DSM_BRANCH, $DSM_PLAT platform"
KernelTar=https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/15152branch/cedarview-source/linux-3.10.x.txz/download
;;
avoton)
echo "Setting kernel download link for branch $DSM_BRANCH, $DSM_PLAT platform"
KernelTar=https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/15152branch/avoton-source/linux-3.10.x.txz/download
;;
*)
echo "Unexpected platform: $DSM_PLAT";
exit 1
;;
esac
fi
if [ "$DSM_VER" == "dsm62" ]; then
case $DSM_PLAT in
bromolow)
echo "Setting kernel download link for branch 22259, bromolow platform"
KernelTar=https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/22259branch/bromolow-source/linux-3.10.x.txz/download
;;
x64)
echo "Setting kernel download link for branch $DSM_BRANCH, $DSM_PLAT platform"
KernelTar=https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/22259branch/x64-source/linux-3.10.x.txz/download
;;
broadwell)
echo "Setting kernel download link for branch $DSM_BRANCH, $DSM_PLAT platform"
KernelTar=https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/22259branch/broadwell-source/linux-3.10.x.txz/download
;;
braswell)
echo "Setting kernel download link for branch $DSM_BRANCH, $DSM_PLAT platform"
KernelTar=https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/22259branch/braswell-source/linux-3.10.x.txz/download
;;
cedarview)
echo "Setting kernel download link for branch $DSM_BRANCH, $DSM_PLAT platform"
KernelTar=https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/22259branch/cedarview-source/linux-3.10.x.txz/download
;;
avoton)
echo "Setting kernel download link for branch $DSM_BRANCH, $DSM_PLAT platform"
KernelTar=https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/22259branch/avoton-source/linux-3.10.x.txz/download
;;
*)
echo "Unexpected platform: $DSM_PLAT";
exit 1
;;
esac
fi
}
function download_vbox()
{
if [ ! -f ./${VirtualBoxFile} ]; then
echo "Downloading ${VirtualBoxFile}"
$WGET ${VirtualBoxUrl} -O ${VirtualBoxFile}
chmod 755 ${VirtualBoxFile}
fi
if [ ! -f ./${ExtensionPackFile} ]; then
echo "Downloading ${ExtensionPackFile}"
$WGET ${ExtensionPackUrl} -O ${ExtensionPackFile}
fi
}
function download_linux()
{
if [ ! -d ../linux-3.10.x ]; then
echo "Downloading ${KernalTar}"
$WGET $KernelTar -O linux-3.10.x.txz
tar xf linux-3.10.x.txz -C ../
rm linux-3.10.x.txz
else
echo "Kernel exists, delete to download again."
fi
}
function generate_config()
{
echo "Generating .config"
echo "# platform: ${DSM_PLAT}" > .config
echo "VirtualBoxVersion=${VirtualBoxVersion}" >> .config
echo "VirtualBoxFile=${VirtualBoxFile}" >> .config
echo "ExtensionPackFile=${ExtensionPackFile}" >> .config
}
function generate_packge_config()
{
if [ -f ../linux-3.10.x/Makefile ]; then
VERSION=$(awk "/^VERSION = / {print \$3}" ../linux-3.10.x/Makefile)
PATCHLEVEL=$(awk "/^PATCHLEVEL = / {print \$3}" ../linux-3.10.x/Makefile)
SUBLEVEL=$(awk "/^SUBLEVEL = / {print \$3}" ../linux-3.10.x/Makefile)
KVER=${VERSION}.${PATCHLEVEL}.${SUBLEVEL}
echo "Kernal version from Makefile ... ${KVER}"
else
KVER=3.10.105
fi
echo "Generating .config in package folder"
echo "KVER=${KVER}" > package/.config
}
function update_info()
{
echo "Update version in INFO.sh"
sed -i -e "s|^version=.*|version=\"${VirtualBoxVersion}\"|g" INFO.sh
}
function update_vboxcfg()
{
echo "Update version in vbox.cfg"
INSTALL_VER=`echo ${VirtualBoxVersion} | cut -d'-' -f 1`
INSTALL_REV=`echo ${VirtualBoxVersion} | cut -d'-' -f 2`
sed -i -e "s|^INSTALL_VER=.*|INSTALL_VER='${INSTALL_VER}'|g" package/etc/vbox/vbox.cfg
sed -i -e "s|^INSTALL_REV=.*|INSTALL_REV='${INSTALL_REV}'|g" package/etc/vbox/vbox.cfg
}
case $1 in
prep)
prompt_for_source
download_vbox
download_linux
generate_config
generate_packge_config
update_info
update_vboxcfg
echo "Ready to exec:"
echo " 'sudo ./pkgscripts-ng/PkgCreate.py --print-log -I -S -p ${DSM_PLAT} -v 6.2 linux-3.10.x'"
echo " 'sudo ./pkgscripts-ng/PkgCreate.py --print-log -c -I -S -p ${DSM_PLAT} -v 6.2 -x0 -c virtualbox4dsm'"
;;
clean)
rm $VirtualBoxFile
rm $ExtensionPackFile
rm -rf package/.config
rm -rf package/www/phpvirtualbox
rm .config
;;
cleanall)
rm $VirtualBoxFile
rm $ExtensionPackFile
rm -rf package/.config
rm -rf package/www/phpvirtualbox ../linux-3.10.x
rm .config
;;
*)
echo "Usage: ./config.sh prep|clean|cleanall";
;;
esac