-
Notifications
You must be signed in to change notification settings - Fork 5
/
build_plugin.sh
513 lines (386 loc) · 11.3 KB
/
build_plugin.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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
base=/chroot
mirror=http://old-releases.ubuntu.com/ubuntu/
distro=precise
branch=`git branch | awk '/\*/{print $2}'`
if ! git status | awk '$1=="modified:"{exit 1}'
then
echo "There are uncommitted changes. This means that the build"
echo "Will not represent a sane version. Please commit all changes"
echo "before building."
exit 7
fi
doxyproj=`awk '$1=="PROJECT_NUMBER"{print $3}' Doxyfile`
autoproj=`awk -F'[,)]' '/AC_INIT/{print $2}' configure.ac`
if [ "$doxyproj" != "$autoproj" ]
then
echo "Fatal Error: inconsistent project number!"
echo "Doxygen: $doxyproj"
echo "Autoconf: $autoproj"
echo "Please update the project number in one or both of those files."
fi
git_hash=`git rev-parse HEAD`
if echo $autoproj | grep -q dev
then
autoproj="$autoproj-`echo $git_hash| head -c 6`"
fi
threebdir=threeB-$autoproj
threebversion=${threebdir}.tar.gz
downloaddir=$PWD/build-downloads/
echo "Starting 3B build"
echo "Building verson $threebdir"
echo "Creating tar ball..."
#######################
#
# Now create a tar gz file.
# Shove in a version specific About file.
#
mkdir "$threebdir" || exit 9
mkdir "$threebdir"/jar || exit 9
cp jar/about.txt "$threebdir/jar"
echo "Version: $threebdir" >> "$threebdir/jar/about.txt"
echo "git hash: $git_hash" >> "$threebdir/jar/about.txt"
echo "#define BUILDVERSION \"$threebdir\"" >> "$threebdir/version.cc"
echo "#define BUILDHASH \"$git_hash\"" >> "$threebdir/version.cc"
echo "#define BUILDDATE \"$(date +'%Y:%m:%d-%T%z %s')\"" >> "$threebdir/version.cc"
echo "#define BUILDHOST \"$(uname -a)\"" >> "$threebdir/version.cc"
git archive --prefix $threebdir/ $git_hash > $threebdir.tar
tar -rf $threebdir.tar "$threebdir/jar/about.txt"
tar -rf $threebdir.tar "$threebdir/version.cc"
gzip -9 $threebdir.tar
if ! [ -e $threebversion ]
then
echo Error: $threebversion missing.
exit 5
fi
CVDNAME=libcvd-20121025
GVARSNAME=gvars-3.0
TOONNAME=TooN-2.0
CVD=$CVDNAME.tar.gz
TOON=$TOONNAME.tar.gz
GVARS=$GVARSNAME.tar.gz
set -ex
mkdir -p $base
function check()
{
if test $? != 0
then
echo Failure: $aarch $arch $variant
exit
fi
}
export arch
export aarch
export variant
#Fetch all the required source files, if they're not already here.
mkdir -p $downloaddir
(
cd $downloaddir
[ -f $TOON ] || wget http://www.edwardrosten.com/cvd/$TOON
check
[ -f $CVD ] || wget http://www.edwardrosten.com/cvd/$CVD
check
[ -f $GVARS ] || wget http://www.edwardrosten.com/cvd/$GVARS
check
[ -f clapack.tgz ] || wget http://www.netlib.org/clapack/clapack.tgz
check
[ -f ij145.zip ] || wget http://rsbweb.nih.gov/ij/download/zips/ij145.zip
check
[ -f jpegsrc.v9a.tar.gz ] || wget http://www.ijg.org/files/jpegsrc.v9a.tar.gz
check
[ -f libpng-1.6.18.tar.xz ] || wget https://download.sourceforge.net/libpng/libpng-1.6.18.tar.xz
check
[ -f tiff-3.9.7.tar.gz ] || wget https://download.osgeo.org/libtiff/tiff-3.9.7.tar.gz
check
[ -f zlib-1.2.8.tar.gz ] || wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.8.tar.gz
check
)
#list="i386 amd64 amd64_mingw32 amd64_mingw64 amd64_static i386_static"
#Create an output directory
dist=dist-$branch-$git_hash/ThreeB
mkdir -p $dist
check
function execute_build()
{
#Order of things
#
# First create i386_base and amd64_base if they do not exist.
# These are base systems.
#
# Then create ${list}_dev if they do not exist. Start by copying
# the appropriate base system. These are pristine development
# environments
#
# Then, copy ${list}_dev to ${list}_build
# And build all but 3B. These are 3B build environments with all
# but 3B built. Start by copying these from ${list}_dev
#
# Then nuke ${list}_3b, copy ${list}_built to ${list}_3b
# This makes the _3b directory a full system with all the custom
# libraries built. All that is required is to then copy over and
# build 3B.
#
# The build of 3B is very well behaved and doesn't ever
# escape its own directory, so we can probably avoid the rather slow
# copy which now dominates the build time. I.e. ro rebuild, if it exists
# just nuke the 3B directory inside _build.
#First, create the base images if they do not exist.
echo "Creating base systems..."
arch=amd64 # i386
target=$base/${distro}_${arch}_base
if ! [ -e "$target" ]
then
echo "Need to install " $target
sleep 1
sudo debootstrap --no-check-gpg --variant=buildd --arch $arch ${distro} $target $mirror
check
sudo mount -o bind /proc $target/proc
check
sudo cp /etc/resolv.conf $target/etc/resolv.conf
check
sudo chroot $target locale-gen en_GB.UTF-8
check
sudo chroot $target apt-get install -y --force-yes openjdk-6-jre-headless
check
sudo chroot $target apt-get install -y --force-yes openjdk-6-jdk cvs wget zip vim
check
sudo umount $target/proc
check
else
echo "$target already exists. Yay!"
fi
echo "Done with base system"
sleep 1
echo "Creating the individual development systems..."
for aarch in $list
do
{
arch=${aarch%_*}
variant=${aarch#*_}
target=$base/${distro}_${aarch}_dev
source=$base/${distro}_${arch}_base
if ! [ -e "$target" ]
then
echo YYY INSTALLING $aarch
echo Getting $aarch from $source
sleep 1
cp -a "$source" "$target"
#sudo mount -o bind /proc $target/proc
#check
#Build static exe, rather than plugin
if [ x$variant == xstatic ]
then
echo deb $mirror ${distro} main restricted universe | sudo tee $target/etc/apt/sources.list.d/asdf.list
check
sudo chroot $target apt-get update
check
sudo chroot $target apt-get install -y --force-yes libjpeg-dev libpng-dev libtiff-dev
check
fi
if [ x$variant == xmingw32 ]
then
echo deb $mirror ${distro} main restricted universe | sudo tee $target/etc/apt/sources.list.d/asdf.list
check
sudo chroot $target apt-get update
check
sudo chroot $target apt-get install -y --force-yes mingw-w64 g++-mingw-w64-i686
check
fi
if [ x$variant == xmingw64 ]
then
echo deb $mirror ${distro} main restricted universe | sudo tee $target/etc/apt/sources.list.d/asdf.list
check
sudo chroot $target apt-get update
check
sudo chroot $target apt-get install -y --force-yes mingw-w64 g++-mingw-w64-x86-64
check
fi
#sudo umount $target/proc
#check
else
echo $target already exists. Yay.
fi
}&
done
wait
echo "Done creating individual development systems"
sleep 1
for aarch in $list
do
arch=${aarch%_*}
variant=${aarch#*_}
target=$base/${distro}_${aarch}_build
source=$base/${distro}_${aarch}_dev
if ! [ -e "$target" ]
then
echo Copying to $target
sudo cp -a "${source}" "${target}"
echo ZZZ GETTING $aarch $target
sleep 1
(
cp build_and_install.sh \
setup_build_env.sh \
build_3b.sh \
clapack_mingw.patch \
$target/tmp
check
cd $target/tmp
check
if true
then
cp $downloaddir/$TOON .
check
cp $downloaddir/$CVD .
check
cp $downloaddir/$GVARS .
check
cp $downloaddir/clapack.tgz .
check
cp $downloaddir/ij145.zip .
check
tar -xzf $TOON
check
tar -xzf $GVARS
check
tar -xzf $CVD
check
tar -xzf clapack.tgz
check
unzip ij145.zip
if [ x$variant == xmingw32 ] || [ x$variant == xmingw64 ]
then
cp $downloaddir/jpegsrc.v9a.tar.gz .
check
tar -xzf jpegsrc.v9a.tar.gz
check
cp $downloaddir/libpng-1.6.18.tar.xz .
check
tar -xJf libpng-1.6.18.tar.xz
check
cp $downloaddir/tiff-3.9.7.tar.gz .
check
tar -xzf tiff-3.9.7.tar.gz
check
cp $downloaddir/zlib-1.2.8.tar.gz .
check
tar -xvf zlib-1.2.8.tar.gz
check
mkdir java-win
check
cp ../usr/lib/jvm/java-6-openjdk-amd64/include/jni.h java-win
check
#The JNI interface is very, VERY stable. Here is the machine dependent
#file for 32 bit java 1.7.0.2 on Win32
#
# Note that the Java types are the same length on any platform,
# i.e. jlong is _always_ 64 bit.
#
# The Windows API is also quite stable, i.e. long is
# 32 bits on 32 or 64 bit systems
cat > java-win/jni_md.h << FOO
#ifndef _JAVASOFT_JNI_MD_H_
#define _JAVASOFT_JNI_MD_H_
#define JNIEXPORT __declspec(dllexport)
#define JNIIMPORT __declspec(dllimport)
#define JNICALL __stdcall
typedef long jint;
typedef __int64 jlong;
typedef signed char jbyte;
#endif /* !_JAVASOFT_JNI_MD_H_ */
FOO
fi
fi
sudo chroot $target bash /tmp/build_and_install.sh $variant $threebdir $TOONNAME $CVDNAME $GVARSNAME
check
)
else
echo "Build env $target already exists."
fi
done
for aarch in $list
do
arch=${aarch%_*}
variant=${aarch#*_}
target=$base/${distro}_${aarch}_build
echo Nuking 3B in $target
sudo rm -rf "$target"/tmp/$threebdir
#This is astonishingly required to use java under ubuntu, now!
sudo mount -o bind /proc $target/proc
check
(
cp $threebversion $target/tmp
check
cp build_and_install.sh \
setup_build_env.sh \
build_3b.sh \
clapack_mingw.patch \
$target/tmp
check
cd $target/tmp
check
tar -xzf $threebversion
check
sudo chroot $target bash /tmp/build_3b.sh $variant $threebdir $TOONNAME $CVDNAME $GVARSNAME
check
echo done1
)
check
sudo umount $target/proc
echo done2
done
if echo $list | tr ' ' '\n' | grep -q amd64_static
then
cp $base/${distro}_amd64_static_build/tmp/$threebdir/multispot5_static $dist/multispot5_static_amd64_linux
cp $base/${distro}_amd64_static_build/tmp/$threebdir/make_grid_markup_static $dist/make_grid_markup_static_amd64_linux
check
fi
if echo $list | tr ' ' '\n' | grep -q i386_static
then
cp $base/${distro}_i386_static_build/tmp/$threebdir/multispot5_static $dist/multispot5_static_i386_linux
cp $base/${distro}_i386_static_build/tmp/$threebdir/make_grid_markup_static $dist/make_grid_markup_static_i386_linux
check
fi
if echo $list | tr ' ' '\n' | grep -q 'i386$'
then
cp $base/${distro}_i386_build/tmp/$threebdir/libthreeB_jni.so $dist/libthreeB_jni_32.so
check
cp $base/${distro}_i386_build/tmp/$threebdir/three_B.jar $dist/
check
fi
if echo $list | tr ' ' '\n' | grep -q 'amd64$'
then
cp $base/${distro}_amd64_build/tmp/$threebdir/libthreeB_jni.so $dist/libthreeB_jni_64.so
check
cp $base/${distro}_amd64_build/tmp/$threebdir/three_B.jar $dist/
check
fi
if echo $list | tr ' ' '\n' | grep -q 'mingw32$'
then
cp $base/${distro}_amd64_mingw32_build/tmp/$threebdir/threeB_jni.dll $dist/threeB_jni_32.dll
cp $base/${distro}_amd64_mingw32_build/tmp/$threebdir/multispot5_static $dist/multispot5_static_i386_win32.exe
check
fi
if echo $list | tr ' ' '\n' | grep -q 'mingw64$'
then
cp $base/${distro}_amd64_mingw64_build/tmp/$threebdir/threeB_jni.dll $dist/threeB_jni_64.dll
cp $base/${distro}_amd64_mingw64_build/tmp/$threebdir/multispot5_static $dist/multispot5_static_amd64_win64.exe
check
fi
}
export distro=precise
#export list="i386 amd64_mingw64" #i386 required for JAR file
export list="amd64 amd64_mingw64"
execute_build
export list="amd64_static"
export distro=lucid
execute_build
#export distro=precise
#export list="amd64_mingw64"
#execute_build
echo $dist
cd $dist/..
zip -r ThreeB.zip ThreeB/
tar -cvzf ThreeB.tar.gz ThreeB/
tar -cvjf ThreeB.tar.bz2 ThreeB/
tar -cvJf ThreeB.tar.xz ThreeB/
cd ..
echo $dist