forked from MediaArea/MediaArea-Utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrepareSource.sh
executable file
·269 lines (216 loc) · 8.37 KB
/
PrepareSource.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
# DVAnalyzer/Release/PrepareSource.sh
# Prepare the source of DVAnalyzer
# Copyright (c) MediaArea.net SARL. All Rights Reserved.
# Use of this source code is governed by a BSD-style license that
# can be found in the License.txt file in the root of the source
# tree.
function _get_source () {
cd "$WDir"
if ! b.path.dir? repos; then
mkdir repos
fi
# Determine where are the sources of DVAnalyzer
if [ $(b.opt.get_opt --source-path) ]; then
Source="$SDir"
else
Source="$WDir"/repos/DVAnalyzer
getRepo $Repo "$Source"
# We ask a specific git state (a tag, a branch, a commit)
if [ $(b.opt.get_opt --git-state) ]; then
cd "$Source"
git checkout $(sanitize_arg $(b.opt.get_opt --git-state))
fi
fi
MIL_gs=""
if [ $(b.opt.get_opt --mil-gs) ]; then
MIL_gs="-gs $(sanitize_arg $(b.opt.get_opt --mil-gs))"
fi
ZL_gs=""
if [ $(b.opt.get_opt --zl-gs) ]; then
ZL_gs="--zl-gs $(sanitize_arg $(b.opt.get_opt --zl-gs))"
fi
MIL_repo=""
if [ $(b.opt.get_opt --mil-repo) ]; then
MIL_repo="--repo $(sanitize_arg $(b.opt.get_opt --mil-repo))"
fi
ZL_repo=""
if [ $(b.opt.get_opt --zl-repo) ]; then
ZL_repo="--zl-repo $(sanitize_arg $(b.opt.get_opt --zl-repo))"
fi
# MediaInfoLib (will also bring ZenLib and zlib)
cd "$(dirname ${BASH_SOURCE[0]})/../prepare_source"
if b.path.dir? "$WDir/../upgrade_version/MediaInfoLib" ; then
$(b.get bang.src_path)/bang run PrepareSource.sh -p MediaInfoLib -sp "$WDir/../upgrade_version/MediaInfoLib" -wp "$WDir" $ZL_repo $ZL_gs -${Target} -na
else
$(b.get bang.src_path)/bang run PrepareSource.sh -p MediaInfoLib -wp "$WDir" $MIL_repo $MIL_gs $ZL_repo $ZL_gs -${Target} -na
fi
}
function _unix_cli () {
echo
echo "Generate the DA CLI directory for compilation under Unix:"
echo "1: copy what is wanted..."
cd "$WDir"/DA
mkdir DVAnalyzer_CLI_GNU_FromSource
cd DVAnalyzer_CLI_GNU_FromSource
cp -r "$Source" DVAnalyzer
mv DVAnalyzer/Project/GNU/CLI/AddThisToRoot_CLI_compile.sh CLI_Compile.sh
chmod +x CLI_Compile.sh
chmod +x DVAnalyzer/Project/GNU/CLI/autogen.sh
chmod +x DVAnalyzer/Project/Mac/BR_extension_CLI.sh
chmod +x DVAnalyzer/Project/Mac/mkdmg.sh
# ZenLib and MediaInfoLib
cp -r "$WDir"/MIL/MediaInfo_DLL_GNU_FromSource/ZenLib .
cp -r "$WDir"/MIL/MediaInfo_DLL_GNU_FromSource/MediaInfoLib .
# Dependency : zlib
cp -r "$WDir"/MIL/MediaInfo_DLL_GNU_FromSource/Shared .
echo "2: remove what isn’t wanted..."
cd DVAnalyzer
rm -fr .cvsignore .git*
rm -f History_GUI.txt
rm -fr debian
cd Project
rm -fr GNU/GUI Mac/*_GUI.sh
rm -f GNU/dvanalyzer.dsc GNU/dvanalyzer.spec GNU/PKGBUILD
rm -fr MSVC2008 MSVC2010 MSVC2015
cd ..
rm -fr Source/GUI
cd ..
echo "3: Autotools..."
cd DVAnalyzer/Project/GNU/CLI
./autogen.sh > /dev/null 2>&1
if $MakeArchives; then
echo "4: compressing..."
cd "$WDir"/DA
if ! b.path.dir? ../archives; then
mkdir ../archives
fi
(GZIP=-9 tar -cz --owner=root --group=root -f ../archives/DVAnalyzer_CLI${Version}_GNU_FromSource.tar.gz DVAnalyzer_CLI_GNU_FromSource)
(BZIP=-9 tar -cj --owner=root --group=root -f ../archives/DVAnalyzer_CLI${Version}_GNU_FromSource.tar.bz2 DVAnalyzer_CLI_GNU_FromSource)
(XZ_OPT=-9e tar -cJ --owner=root --group=root -f ../archives/DVAnalyzer_CLI${Version}_GNU_FromSource.tar.xz DVAnalyzer_CLI_GNU_FromSource)
fi
}
function _unix_gui () {
echo
echo "Generate the DA GUI directory for compilation under Unix:"
echo "1: copy what is wanted..."
cd "$WDir"/DA
mkdir DVAnalyzer_GUI_GNU_FromSource
cd DVAnalyzer_GUI_GNU_FromSource
cp -r "$Source" DVAnalyzer
mv DVAnalyzer/Project/QtCreator/AddThisToRoot_GUI_compile.sh GUI_Compile.sh
chmod +x GUI_Compile.sh
chmod +x DVAnalyzer/Project/GNU/GUI/autogen.sh
chmod +x DVAnalyzer/Project/Mac/BR_extension_GUI.sh
chmod +x DVAnalyzer/Project/Mac/mkdmg.sh
# ZenLib and MediaInfoLib
cp -r "$WDir"/MIL/MediaInfo_DLL_GNU_FromSource/ZenLib .
cp -r "$WDir"/MIL/MediaInfo_DLL_GNU_FromSource/MediaInfoLib .
# Dependency : zlib
cp -r "$WDir"/MIL/MediaInfo_DLL_GNU_FromSource/Shared .
echo "2: remove what isn’t wanted..."
cd DVAnalyzer
rm -fr .cvsignore .git*
rm -f History_CLI.txt
rm -fr debian
cd Project
rm -fr GNU/CLI Mac/*_CLI.sh
rm -f GNU/dvanalyzer.dsc GNU/dvanalyzer.spec GNU/PKGBUILD
rm -fr MSVC2008 MSVC2010 MSVC2015
cd ..
cd ..
if $MakeArchives; then
echo "3: compressing..."
cd "$WDir"/DA
if ! b.path.dir? ../archives; then
mkdir ../archives
fi
(GZIP=-9 tar -cz --owner=root --group=root -f ../archives/DVAnalyzer_GUI${Version}_GNU_FromSource.tar.gz DVAnalyzer_GUI_GNU_FromSource)
(BZIP=-9 tar -cj --owner=root --group=root -f ../archives/DVAnalyzer_GUI${Version}_GNU_FromSource.tar.bz2 DVAnalyzer_GUI_GNU_FromSource)
(XZ_OPT=-9e tar -cJ --owner=root --group=root -f ../archives/DVAnalyzer_GUI${Version}_GNU_FromSource.tar.xz DVAnalyzer_GUI_GNU_FromSource)
fi
}
function _all_inclusive () {
echo
echo "Generate the DA all inclusive tarball:"
echo "1: copy what is wanted..."
cd "$WDir"/DA
mkdir dvanalyzer_AllInclusive
cd dvanalyzer_AllInclusive
cp -r "$Source" DVAnalyzer
# Dependencies
cp -r "$WDir"/MIL/libmediainfo_AllInclusive/ZenLib .
cp -r "$WDir"/MIL/libmediainfo_AllInclusive/MediaInfoLib .
cp -r "$WDir"/MIL/libmediainfo_AllInclusive/zlib .
echo "2: configure dependencies for use static runtime..."
find zlib ZenLib MediaInfoLib -type f -name "*.vcxproj" -exec \
sed -i \
-e 's/MultiThreadedDebugDLL/MultiThreadedDebug/g' \
-e 's/MultiThreadedDLL/MultiThreaded/g' {} \;
echo "3: remove what isn’t wanted..."
rm -fr dvanalyzer/.git*
rm -fr dvanalyzer/.cvs*
rm -fr dvanalyzer/debian
if $MakeArchives; then
echo "4: compressing..."
cd "$WDir"/DA
if ! b.path.dir? ../archives; then
mkdir ../archives
fi
7za a -t7z -mx=9 -bd ../archives/dvanalyzer${Version}_AllInclusive.7z dvanalyzer_AllInclusive >/dev/null
fi
}
function _source_package () {
echo
echo "Generate the DA directory for the source package:"
echo "1: copy what is wanted..."
cd "$WDir"/DA
cp -r "$Source" DVAnalyzer
echo "2: remove what isn’t wanted..."
rm -fr dvanalyzer/.git*
rm -fr dvanalyzer/.cvs*
if $MakeArchives; then
echo "3: compressing..."
cd "$WDir"/DA
if ! b.path.dir? ../archives; then
mkdir ../archives
fi
(GZIP=-9 tar -cz --owner=root --group=root -f ../archives/dvanalyzer${Version}.tar.gz DVAnalyzer)
(BZIP=-9 tar -cj --owner=root --group=root -f ../archives/dvanalyzer${Version}.tar.bz2 DVAnalyzer)
(XZ_OPT=-9e tar -cJ --owner=root --group=root -f ../archives/dvanalyzer${Version}.tar.xz DVAnalyzer)
mkdir ../archives/obs
cp ../archives/dvanalyzer${Version}.tar.gz ../archives/obs/dvanalyzer${Version}-1.tar.gz
cp ../archives/dvanalyzer${Version}.tar.xz ../archives/obs/dvanalyzer${Version}.orig.tar.xz
cp "$WDir/DA/DVAnalyzer/Project/GNU/dvanalyzer.spec" ../archives/obs
cp "$WDir/DA/DVAnalyzer/Project/GNU/PKGBUILD" ../archives/obs
update_pkgbuild ../archives/obs/dvanalyzer${Version}-1.tar.gz ../archives/obs/PKGBUILD
deb_obs dvanalyzer "$WDir/DA/DVAnalyzer" "$WDir/archives/obs/dvanalyzer${Version}.orig.tar.xz"
fi
}
function btask.PrepareSource.run () {
local Source
cd "$WDir"
# Clean up
rm -fr archives
rm -fr repos/DVAnalyzer
rm -fr "$WDir"/DA
mkdir "$WDir"/DA
_get_source
if [ -z "$Version" ] ; then
Version=_$(cat "$Source/Project/version.txt")
fi
if [ "$Target" = "sa" ] || [ "$Target" = "all" ]; then
_source_package
fi
if [ "$Target" = "cu" ] || [ "$Target" = "all" ]; then
_unix_cli
_unix_gui
fi
if [ "$Target" = "ai" ] || [ "$Target" = "all" ]; then
_all_inclusive
fi
if $CleanUp; then
cd "$WDir"
rm -fr repos
rm -fr DA
fi
}