~ubuntu-branches/ubuntu/saucy/blender/saucy-proposed

« back to all changes in this revision

Viewing changes to build_files/build_environment/prepare_release_env.sh

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
#
 
4
# This script will prepare build environment with the same settings as release environment
 
5
#
 
6
# It will install two chroot environments:
 
7
#   - /home/buildbot_squeeze_i686
 
8
#   - /home/buildbot_squeeze_x86_64
 
9
# which are used for 32bit and 64bit
 
10
#
 
11
# This sctipt will also create folder /home/sources where all dependent libraries sources are
 
12
# downloading and compiling.
 
13
#
 
14
# Release builder scripts are stored in /home/sources/release-builder
 
15
# See build_all.sh script for usage details
 
16
#
 
17
# This script was tested on debian squeeze and wheezy, should work on ubuntu as well
 
18
# It wouldn't work on other distros
 
19
#
 
20
# TODO:
 
21
# - It's still required manual copying of build configuration files to /home/sources/release-builder/config
 
22
# - OSL is not set up yet
 
23
#
 
24
 
 
25
set -e
 
26
 
 
27
NO_COLOR='\033[0m'
 
28
EWHITE='\033[1;37m'
 
29
ERED='\033[1;31m'
 
30
 
 
31
CONFIRM="--i-really-do-know-what-im-doing"
 
32
 
 
33
ERROR() {
 
34
  echo ${ERED}${@}${NO_COLOR}
 
35
}
 
36
 
 
37
INFO() {
 
38
  echo ${EWHITE}${@}${NO_COLOR}
 
39
}
 
40
 
 
41
if [ $# != 1 ]; then
 
42
  ERROR "Usage: $0 $CONFIRM"
 
43
  exit 1
 
44
fi
 
45
 
 
46
if [ "$1" != "$CONFIRM" ]; then
 
47
  ERROR "Usage: $0 $CONFIRM"
 
48
  exit 1
 
49
fi
 
50
 
 
51
DEBIAN_BRANCH="squeeze"
 
52
DEBIAN_MIRROR="http://ftp.de.debian.org/debian"
 
53
USER_ID=1000
 
54
 
 
55
# For now it's always /home, so we can setup schroot to map /sources to the same
 
56
# path at both host and chroot systems (which is currently needed for release building script)
 
57
ENV_PATH="/home"
 
58
 
 
59
AMD64_PATH="$ENV_PATH/buildbot_${DEBIAN_BRANCH}_x86_64"
 
60
I686_PATH="$ENV_PATH/buildbot_${DEBIAN_BRANCH}_i686"
 
61
SOURCES_PATH="$ENV_PATH/sources"
 
62
 
 
63
THREADS=`cat /proc/cpuinfo | grep cores | uniq | sed -e "s/.*: *\(.*\)/\\1/"`
 
64
 
 
65
# Force vpx be installed from the backports
 
66
VPX_V="1.0.0-2~bpo60+1"
 
67
 
 
68
BINUTILS_V="2.22"
 
69
BINUTILS_FV="2.22-7.1"
 
70
 
 
71
GCC_V="4.7_4.7.1"
 
72
GCC_FV="4.7_4.7.1-7"
 
73
 
 
74
OPENAL_V="1.14"
 
75
 
 
76
DPKG_V="1.16.8"
 
77
 
 
78
DEBHELPER_V="9"
 
79
DEBHELPER_FV="9.20120909"
 
80
 
 
81
JEMALLOC_V="3.1.0"
 
82
SPNAV_V="0.2.2"
 
83
FFMPEG_V="1.0"
 
84
BOOST_V="1_51_0"
 
85
PYTHON_V="3.3.0"
 
86
PYTHIN_V_SHORT="3.3"
 
87
OIIO_V="1.0.9"
 
88
OCIO_V="1.0.7"
 
89
MESA_V="8.0.5"
 
90
 
 
91
OPENSSL_V="0.9.8o"
 
92
OPENSSL_FV="0.9.8o-4squeeze13"
 
93
 
 
94
CUDA_V="4.2.9"
 
95
CUDA_DISTR="ubuntu10.04"
 
96
CUDA_32="cudatoolkit_${CUDA_V}_linux_32_${CUDA_DISTR}.run"
 
97
CUDA_64="cudatoolkit_${CUDA_V}_linux_64_${CUDA_DISTR}.run"
 
98
 
 
99
INSTALL_RELEASE_BUILDER() {
 
100
  SOURCES_PATH=$1
 
101
 
 
102
  RB=$SOURCES_PATH/release-builder
 
103
  if [ ! -d $RB ]; then
 
104
    INFO "Installing release building scripts"
 
105
 
 
106
    mkdir -p $RB
 
107
 
 
108
    cat << EOF > $RB/Readme.txt
 
109
This directory contains scrips needed for automated release archive preparation
 
110
 
 
111
config/: storage of scons configs for different platforms
 
112
 
 
113
build_all.sh: script asks version to add to archive name and revision to compile,
 
114
              when script finished, there'll be 32 and 64 bit archives in current directory
 
115
              better to run this script from this directory
 
116
 
 
117
do_build_all.sh: uses environment variables set by build_all.sh script (or other scripts)
 
118
                 and launches compilation inside chroot environments
 
119
 
 
120
chroot_compile.py: runs compilation process with giver parameters in chroots
 
121
compile.py: script runs inside chroot environment and prepares archive
 
122
 
 
123
blender-buildenv.tar.bz2: archive, received from Ken Hughes when i've been preparing
 
124
                          new environment to make it as close to old one as it's possible
 
125
 
 
126
Hope all this would help you.
 
127
 
 
128
-Sergey-
 
129
EOF
 
130
  
 
131
    cat << EOF > $RB/build_all.sh
 
132
#!/bin/sh
 
133
 
 
134
echo -n "version: "
 
135
read version
 
136
echo -n "svn revision (blank to latest, 0 to keep unchanged): "
 
137
read revision
 
138
 
 
139
export version
 
140
export revision
 
141
 
 
142
d=\`dirname \${0}\`
 
143
\${d}/do_build_all.sh
 
144
EOF
 
145
    chmod +x $RB/build_all.sh
 
146
 
 
147
    cat << EOF > $RB/build_all-test.sh
 
148
#!/bin/sh
 
149
 
 
150
d=\`dirname \${0}\`
 
151
\${d}/do_build_all.sh
 
152
EOF
 
153
    chmod +x $RB/build_all-test.sh
 
154
 
 
155
    cat << EOF > $RB/chroot-compile.py
 
156
#!/usr/bin/env python
 
157
 
 
158
import sys
 
159
import os
 
160
import platform
 
161
 
 
162
from optparse import OptionParser
 
163
 
 
164
# This could be passed through options, but does we actually need this?
 
165
bl_source = '/home/sources/blender'
 
166
build_dir = '/home/sources/blender-build/'
 
167
install_dir = '/home/sources/blender-install/'
 
168
with_player = True
 
169
 
 
170
# Default config
 
171
curr_arch = platform.architecture()[0]
 
172
def_arch = 'x86_64' if curr_arch == '64bit' else 'i686'
 
173
builder_dir = os.path.dirname(os.path.realpath(__file__))
 
174
 
 
175
# XXX: bad thing!
 
176
# builder_dir = builder_dir.replace("sources-new", "sources")
 
177
 
 
178
def_cores = 1
 
179
if hasattr(os, 'sysconf'):
 
180
    if 'SC_NPROCESSORS_ONLN' in os.sysconf_names:
 
181
        def_cores = os.sysconf('SC_NPROCESSORS_ONLN')
 
182
 
 
183
# Per-architecture chroot name
 
184
chroots = { 'i686': 'buildbot_squeeze_i686',
 
185
            'x86_64': 'buildbot_squeeze_x86_64'}
 
186
 
 
187
# Parse command line
 
188
op = OptionParser()
 
189
op.add_option('--tag', default = None)
 
190
op.add_option('--branch', default = None)
 
191
op.add_option('--arch', default = def_arch)
 
192
op.add_option('--cores', default = def_cores)
 
193
op.add_option('--bl-version', default = 'UNDEFINED')
 
194
op.add_option('--no-clean', default = False)
 
195
(opts, args) = op.parse_args()
 
196
 
 
197
if opts.arch not in chroots:
 
198
    print('Error: No configured machine gound to build ' + 
 
199
          '{0} version' . format(opts.arch))
 
200
    sys.exit(1)
 
201
 
 
202
chroot = chroots[opts.arch]
 
203
 
 
204
if opts.tag:
 
205
    bl_source = '/home/sources/blender-tags/' + opts.tag
 
206
elif opts.branch:
 
207
    bl_source = '/home/sources/blender-branches/' + opts.branch
 
208
 
 
209
if not os.path.isdir(bl_source):
 
210
    print('Uname to find directory with sources: ' + bl_source)
 
211
    sys.exit(1)
 
212
 
 
213
print('Building {0} version, machine is {1}' . format(opts.bl_version, opts.arch))
 
214
 
 
215
# Assume builder directory is binded to the same location in
 
216
# chroot environments
 
217
compiler = os.path.join(builder_dir, 'compile.py')
 
218
 
 
219
cmd = 'schroot -c %s -d /home/sources/release-builder --' % (chroot)
 
220
cmd += ' python %s' % (compiler)
 
221
cmd += ' --bl-version=%s' % (opts.bl_version)
 
222
cmd += ' --bl-source=%s' % (bl_source)
 
223
cmd += ' --arch=%s' % (opts.arch)
 
224
cmd += ' --build-dir=%s' % (build_dir)
 
225
cmd += ' --install-dir=%s' % (install_dir)
 
226
 
 
227
if opts.no_clean:
 
228
    cmd += ' --no-clean=1'
 
229
 
 
230
if with_player:
 
231
    cmd += ' --with-player=1'
 
232
 
 
233
#if opts.branch:
 
234
#    cmd += ' --use-new-ffmpeg=1'
 
235
 
 
236
result = os.system(cmd)
 
237
if result != 0:
 
238
    print('compiler script exited with errcode: %s' % (result))
 
239
    sys.exit(1)
 
240
EOF
 
241
    chmod +x $RB/chroot-compile.py
 
242
 
 
243
    cat << EOF > $RB/compile.py
 
244
#!/usr/bin/env python
 
245
 
 
246
import platform
 
247
import sys
 
248
import os
 
249
import shutil
 
250
 
 
251
from optparse import OptionParser
 
252
 
 
253
# Default config
 
254
curr_arch = platform.architecture()[0]
 
255
def_arch = 'x86_64' if curr_arch == '64bit' else 'i686'
 
256
builder_dir = os.path.dirname(os.path.realpath(__file__))
 
257
 
 
258
def_cores = 1
 
259
if hasattr(os, 'sysconf'):
 
260
    if 'SC_NPROCESSORS_ONLN' in os.sysconf_names:
 
261
        def_cores = os.sysconf('SC_NPROCESSORS_ONLN')
 
262
 
 
263
# Parse command line
 
264
op = OptionParser()
 
265
op.add_option('--arch', default = def_arch)
 
266
op.add_option('--cores', default = def_cores)
 
267
op.add_option('--no-clean', default = False)
 
268
op.add_option('--bl-version', default = 'UNKNOWN')
 
269
op.add_option('--bl-source', default = '')
 
270
op.add_option('--config-dir', default = '')
 
271
op.add_option('--build-dir', default = '')
 
272
op.add_option('--install-dir', default = '')
 
273
op.add_option('--with-player', default = False)
 
274
#op.add_option('--use-new-ffmpeg', default = False)
 
275
(opts, args) = op.parse_args()
 
276
 
 
277
if opts.config_dir == '':
 
278
    opts.config_dir = os.path.join(builder_dir, 'config')
 
279
 
 
280
# Initial directory checking (could be problems with permissions)
 
281
if not os.path.isdir(opts.bl_source):
 
282
    print('Blender\'s source tree not found: %s' % (opts.bl_source))
 
283
    sys.exit(1)
 
284
 
 
285
if not os.path.isdir(opts.config_dir):
 
286
    print('Directory with configuration files not found: %s' % (opts.config_dir))
 
287
    sys.exit(1)
 
288
 
 
289
if not os.path.isdir(os.path.dirname(opts.build_dir)):
 
290
    print('Build directory can\'t be reached: %s' % (opts.build_dir))
 
291
    sys.exit(1)
 
292
 
 
293
if not os.path.isdir(os.path.dirname(opts.install_dir)):
 
294
    print('Install directory can\'t be reached: %s' % (opts.install_dir))
 
295
    sys.exit(1)
 
296
 
 
297
# Detect glibc version
 
298
libc = [name for name in os.listdir('/lib') if 'libc.so.' in name]
 
299
if len(libc) == 0:
 
300
    print('Could not find "/lib/libc.so.*": cannot determine glibc version')
 
301
    sys.exit(-1)
 
302
 
 
303
if len(libc) > 1:
 
304
    print('warning: found more than one "/lib/libc.so.*": '+
 
305
          'using %s' % (libc[0]))
 
306
 
 
307
glibc = 'glibc' + os.readlink('/lib/' + libc[0])[5:][:-3].replace('.', '')
 
308
glibc = glibc[:8]
 
309
 
 
310
# Full name for archive
 
311
full_name = 'blender-%s-linux-%s-%s' % (opts.bl_version, glibc, opts.arch)
 
312
build_dir = os.path.join(opts.build_dir, full_name)
 
313
install_dir = os.path.join(opts.install_dir, full_name)
 
314
scons = os.path.join(opts.bl_source, 'scons', 'scons.py')
 
315
scons_cmd = 'python %s -C %s' % (scons, opts.bl_source)
 
316
config = os.path.join(opts.config_dir, 'user-config-' + glibc + '-' + opts.arch + '.py')
 
317
 
 
318
if not os.path.isfile(config):
 
319
    print('Configuration file not found: %s' % (config))
 
320
    sys.exit(1)
 
321
 
 
322
# Clean build directory
 
323
if not opts.no_clean:
 
324
    print('Cleaning up build directory...')
 
325
    os.system('%s BF_BUILDDIR=%s clean ' % (scons_cmd, build_dir))
 
326
 
 
327
# Clean install directory
 
328
if os.path.isdir(install_dir):
 
329
    shutil.rmtree(install_dir)
 
330
 
 
331
flags = ""
 
332
 
 
333
# Switch to newer libraries if needed
 
334
#if opts.use_new_ffmpeg:
 
335
#    print("Using new ffmpeg-0.8.1")
 
336
#    flags += " BF_FFMPEG='/home/sources/staticlibs/ffmpeg-0.8'"
 
337
 
 
338
# Build blenderplayer first
 
339
# (to be sure all stuff needed for blender would copied automatically)
 
340
if opts.with_player:
 
341
    player_config = os.path.join(opts.config_dir,
 
342
        'user-config-player-' + glibc + '-' + opts.arch + '.py')
 
343
 
 
344
    if not os.path.isfile(player_config):
 
345
        print('Player configuration file not found: %s' % (player_config))
 
346
        sys.exit(1)
 
347
 
 
348
    cmd  = '%s -j %d blenderplayer ' % (scons_cmd, opts.cores + 1)
 
349
    cmd += ' BF_BUILDDIR=%s' % (build_dir + '-player')
 
350
    cmd += ' BF_INSTALLDIR=%s' % (install_dir)
 
351
    cmd += ' BF_CONFIG=%s' % (player_config)
 
352
    cmd += flags
 
353
 
 
354
    result = os.system(cmd)
 
355
    if result != 0:
 
356
        print('Compilation failed, exit code is %d' % (result))
 
357
        sys.exit(-1)
 
358
 
 
359
# Build blender itself
 
360
cmd  = '%s -j %d  blender ' % (scons_cmd, opts.cores + 1)
 
361
cmd += ' BF_BUILDDIR=%s' % (build_dir)
 
362
cmd += ' BF_INSTALLDIR=%s' % (install_dir)
 
363
cmd += ' BF_CONFIG=%s' % (config)
 
364
cmd += flags
 
365
 
 
366
result = os.system(cmd)
 
367
if result != 0:
 
368
    print('Compilation failed, exit code is %d' % (result))
 
369
    sys.exit(-1)
 
370
 
 
371
blender = os.path.join(install_dir, 'blender')
 
372
blenderplayer = blender + 'player'
 
373
 
 
374
if not os.path.exists(blender):
 
375
    print('scons completed successfully but blender executable missing')
 
376
    sys.exit(1)
 
377
 
 
378
if opts.with_player and not os.path.exists(blenderplayer):
 
379
    print('scons completed successfully but blenderplayer executable missing')
 
380
    sys.exit(1)
 
381
 
 
382
# compile python modules
 
383
#result = os.system('%s --background --python %s/source/tools/compile_scripts.py' % (blender, opts.bl_source))
 
384
#if result != 0:
 
385
#    print('Python modules compilation failed, exit code is %d' % (result))
 
386
#    sys.exit(-1)
 
387
 
 
388
print('build successful')
 
389
 
 
390
os.system('strip -s %s %s' % (blender, blenderplayer))
 
391
 
 
392
# Copy all texts needed for release
 
393
release_texts = os.path.join(opts.bl_source, 'release', 'text', '*')
 
394
release_txt = os.path.join(install_dir, 'release_%s.txt' % (opts.bl_version))
 
395
 
 
396
os.system('cp -r %s %s' % (release_texts, install_dir))
 
397
 
 
398
if os.path.exists(release_txt):
 
399
    print 'RELEASE TEXT FOUND'
 
400
else:
 
401
    print 'WARNING! RELEASE TEXT NOT FOUND!'
 
402
 
 
403
# TODO: copy plugins data when ready
 
404
 
 
405
# Add software gl libraries and scripts
 
406
mesa_arch = None
 
407
 
 
408
if opts.arch == 'x86_64':
 
409
    mesa_arch = 'mesalibs64.tar.bz2'
 
410
elif opts.arch == 'i686':
 
411
    mesa_arch = 'mesalibs32.tar.bz2'
 
412
 
 
413
if mesa_arch is not None:
 
414
    mesalibs = os.path.join(builder_dir, 'extra', mesa_arch)
 
415
    software_gl = os.path.join(builder_dir, 'extra', 'blender-softwaregl')
 
416
 
 
417
    os.system('tar -xpf %s -C %s' % (mesalibs, install_dir))
 
418
    os.system('cp %s %s' % (software_gl, install_dir))
 
419
    os.system('chmod 755 %s' % (os.path.join(install_dir, 'blender-softwaregl')))
 
420
 
 
421
# Pack release archive
 
422
print("Building Dynamic Tarball")
 
423
os.system('tar -C %s -cjf %s.tar.bz2 %s ' % (opts.install_dir,
 
424
                                             full_name, full_name))
 
425
 
 
426
print('Done.')
 
427
EOF
 
428
    chmod +x $RB/compile.py
 
429
 
 
430
    cat << EOF > $RB/do_build_al.sh
 
431
#!/bin/sh
 
432
 
 
433
SOURCES="/home/sources"
 
434
 
 
435
#opts="--cores=1 "
 
436
opts=""
 
437
 
 
438
if [ "x\${tag}" != "x" ]; then
 
439
  echo "Getting tagged source tree..."
 
440
  d="\${SOURCES}/blender-tags/\${tag}"
 
441
  opts="\${opts} --tag=\${tag}"
 
442
  if [ ! -d \${d} ]; then
 
443
    svn co https://svn.blender.org/svnroot/bf-blender/tags/\${tag}/blender/@\${revision}  \${d}
 
444
  else
 
445
    svn up -r \${revision} \${d}
 
446
  fi
 
447
elif [ "x\${branch}" != "x" ]; then
 
448
  echo "Getting branched source tree..."
 
449
  d="\${SOURCES}/blender-branches/\${branch}"
 
450
  opts="\${opts} --branch=\${branch}"
 
451
  if [ ! -d \${d} ]; then
 
452
    if [ "x\${revision}" != "x" ]; then
 
453
      svn co https://svn.blender.org/svnroot/bf-blender/branches/\${branch}/@\${revision}  \${d}
 
454
    else
 
455
      svn co https://svn.blender.org/svnroot/bf-blender/branches/\${branch}/  \${d}
 
456
    fi
 
457
  else
 
458
    if [ "x\${revision}" != "x" ]; then
 
459
      svn up -r \${revision} \${d}
 
460
    else
 
461
      svn up \${d}
 
462
    fi
 
463
  fi
 
464
else
 
465
  if [ "x\${revision}" != "x" ]; then
 
466
    if [ "x\${revision}" != "x0" ]; then
 
467
      svn up -r \${revision} \${SOURCES}/blender
 
468
    else
 
469
      svn up \${SOURCES}/blender
 
470
    fi
 
471
  fi
 
472
fi
 
473
 
 
474
if [ "x\${tag}" != "x" ]; then
 
475
  b="\${SOURCES}/blender-tags/\${tag}"
 
476
elif [ "x\${branch}" != "x" ]; then
 
477
  b="\${SOURCES}/blender-branches/\${branch}"
 
478
else
 
479
  b="\${SOURCES}/blender"
 
480
fi
 
481
 
 
482
if [ "x\${addons_revision}" != "x" ]; then
 
483
  d="\${b}/release/scripts/addons"
 
484
 
 
485
  if [ "x\${addons_revision}" != "x0" ]; then
 
486
    svn up -r \${addons_revision} \${d}
 
487
  else
 
488
    svn up \${d}
 
489
  fi
 
490
fi
 
491
 
 
492
if [ "x\${locale_revision}" != "x" ]; then
 
493
  d="\${b}/release/datafiles/locale"
 
494
 
 
495
  if [ "x\${locale_revision}" != "x0" ]; then
 
496
    svn up -r \${locale_revision} \${d}
 
497
  else
 
498
    svn up \${d}
 
499
  fi
 
500
fi
 
501
 
 
502
if [ -z "\$version" ]; then
 
503
  version=r\`/usr/bin/svnversion \$SOURCES/blender\`
 
504
fi
 
505
 
 
506
cd extra
 
507
./update-libs.sh
 
508
cd ..
 
509
 
 
510
python chroot-compile.py \${opts} --arch=x86_64 --bl-version \${version}  # --no-clean=1
 
511
python chroot-compile.py \${opts} --arch=i686 --bl-version \${version}  # --no-clean=1
 
512
EOF
 
513
    chmod +x $RB/do_build_al.sh
 
514
 
 
515
    mkdir -p $RB/extra
 
516
 
 
517
    cat << EOF > $RB/extra/blender-softwaregl
 
518
#!/bin/sh
 
519
 
 
520
BF_DIST_BIN=\`dirname "\$0"\`
 
521
BF_PROGRAM="blender" # BF_PROGRAM=\`basename "\$0"\`-bin
 
522
exitcode=0
 
523
 
 
524
LD_LIBRARY_PATH=\${BF_DIST_BIN}/lib:\${LD_LIBRARY_PATH}
 
525
 
 
526
if [ -n "\$LD_LIBRARYN32_PATH" ]; then
 
527
    LD_LIBRARYN32_PATH=\${BF_DIST_BIN}/lib:\${LD_LIBRARYN32_PATH}
 
528
fi
 
529
if [ -n "\$LD_LIBRARYN64_PATH" ]; then
 
530
    LD_LIBRARYN64_PATH=\${BF_DIST_BIN}/lib:\${LD_LIBRARYN64_PATH}
 
531
fi
 
532
if [ -n "\$LD_LIBRARY_PATH_64" ]; then
 
533
    LD_LIBRARY_PATH_64=\${BF_DIST_BIN}/lib:\${LD_LIBRARY_PATH_64}
 
534
fi
 
535
 
 
536
# Workaround for half-transparent windows when compiz is enabled
 
537
XLIB_SKIP_ARGB_VISUALS=1
 
538
 
 
539
export LD_LIBRARY_PATH LD_LIBRARYN32_PATH LD_LIBRARYN64_PATH LD_LIBRARY_PATH_64 LD_PRELOAD XLIB_SKIP_ARGB_VISUALS
 
540
 
 
541
"\$BF_DIST_BIN/\$BF_PROGRAM" \${1+"\$@"}
 
542
exitcode=\$?
 
543
exit \$exitcode
 
544
EOF
 
545
    chmod +x $RB/extra/blender-softwaregl
 
546
 
 
547
    cat << EOF > $RB/extra/do_update-libs.sh
 
548
#!/bin/sh
 
549
 
 
550
BITS=\$1
 
551
V="\`readlink /opt/lib/mesa | sed -r 's/mesa-//'\`"
 
552
TMP=\`mktemp -d\`
 
553
N="mesalibs\$1-\$V"
 
554
 
 
555
if [ ! -f \$N.tar.bz2 ]; then
 
556
  mkdir -p \$TMP/lib
 
557
  cp -P /opt/lib/mesa/lib/libGL* \$TMP/lib
 
558
  strip -s \$TMP/lib/*
 
559
  tar -C \$TMP -cf \$N.tar lib
 
560
  bzip2 \$N.tar
 
561
 
 
562
  rm -f mesalibs\$BITS.tar,bz2
 
563
  ln -s \$N.tar.bz2 mesalibs\$BITS.tar.bz2
 
564
fi
 
565
 
 
566
rm -rf \$TMP
 
567
EOF
 
568
    chmod +x $RB/extra/do_update-libs.sh
 
569
 
 
570
    cat << EOF > $RB/extra/update-libs.sh
 
571
#!/bin/sh
 
572
 
 
573
P="/home/sources/release-builder/extra"
 
574
CHROOT_PREFIX="buildbot_squeeze_"
 
575
CHROOT32="\${CHROOT_PREFIX}i686"
 
576
CHROOT64="\${CHROOT_PREFIX}x86_64"
 
577
RUN32="schroot -c \$CHROOT32 -d \$P"
 
578
RUN64="schroot -c \$CHROOT64 -d \$P"
 
579
 
 
580
\$RUN64 ./do_update-libs.sh 64
 
581
\$RUN32 ./do_update-libs.sh 32
 
582
EOF
 
583
    chmod +x $RB/extra/update-libs.sh
 
584
 
 
585
    mkdir -p $RB/config
 
586
    cp $SOURCES_PATH/blender/build_files/buildbot/config/* $RB/config
 
587
 
 
588
  fi
 
589
}
 
590
 
 
591
INSTALL_SOURCES() {
 
592
  SOURCES_PATH=$1
 
593
 
 
594
  if [ ! -d "$SOURCES_PATH" ]; then
 
595
    INFO "Creating sources directory"
 
596
    mkdir -p "$SOURCES_PATH"
 
597
  fi
 
598
 
 
599
  if [ ! -d "$SOURCES_PATH/backport/binutils" ]; then
 
600
    INFO "Downloading binutils"
 
601
    mkdir -p "$SOURCES_PATH/backport/binutils"
 
602
    wget -c $DEBIAN_MIRROR/pool/main/b/binutils/binutils_$BINUTILS_FV.diff.gz \
 
603
            $DEBIAN_MIRROR/pool/main/b/binutils/binutils_$BINUTILS_FV.dsc \
 
604
            $DEBIAN_MIRROR/pool/main/b/binutils/binutils_$BINUTILS_V.orig.tar.gz \
 
605
        -P "$SOURCES_PATH/backport/binutils"
 
606
  fi
 
607
 
 
608
  if [ ! -d "$SOURCES_PATH/backport/gcc-4.7" ]; then
 
609
    INFO "Downloading gcc-4.7"
 
610
    mkdir -p "$SOURCES_PATH/backport/gcc-4.7"
 
611
    wget -c $DEBIAN_MIRROR/pool/main/g/gcc-4.7/gcc-$GCC_FV.diff.gz \
 
612
            $DEBIAN_MIRROR/pool/main/g/gcc-4.7/gcc-$GCC_FV.dsc \
 
613
            $DEBIAN_MIRROR/pool/main/g/gcc-4.7/gcc-$GCC_V.orig.tar.gz \
 
614
        -P "$SOURCES_PATH/backport/gcc-4.7"
 
615
  fi
 
616
 
 
617
  if [ ! -d "$SOURCES_PATH/backport/openssl" ]; then
 
618
    INFO "Downloading openssl"
 
619
    mkdir -p "$SOURCES_PATH/backport/openssl"
 
620
    wget -c $DEBIAN_MIRROR/pool/main/o/openssl/openssl_$OPENSSL_FV.debian.tar.gz \
 
621
            $DEBIAN_MIRROR/pool/main/o/openssl/openssl_$OPENSSL_FV.dsc \
 
622
            $DEBIAN_MIRROR/pool/main/o/openssl/openssl_$OPENSSL_V.orig.tar.gz \
 
623
        -P "$SOURCES_PATH/backport/openssl"
 
624
  fi
 
625
 
 
626
  # JeMalloc
 
627
  J="$SOURCES_PATH/packages/jemalloc-$JEMALLOC_V"
 
628
  if [ ! -d "$J" ]; then
 
629
    INFO "Downloading jemalloc-$JEMALLOC_V"
 
630
    wget -c http://www.canonware.com/download/jemalloc/jemalloc-$JEMALLOC_V.tar.bz2 -P "$SOURCES_PATH/packages"
 
631
    tar -C "$SOURCES_PATH/packages" -xf "$J.tar.bz2"
 
632
    cat << EOF > "$J/0config.sh"
 
633
#!/bin/sh
 
634
 
 
635
./configure CC="gcc-4.7 -Wl,--as-needed" CXX="g++-4.7 -Wl,--as-needed" LDFLAGS="-pthread -static-libgcc" --prefix=/opt/lib/jemalloc-$JEMALLOC_V
 
636
EOF
 
637
    chmod +x "$J/0config.sh"
 
638
  fi
 
639
 
 
640
  # Spnav
 
641
  S="$SOURCES_PATH/packages/libspnav-$SPNAV_V"
 
642
  if [ ! -d "$S" ]; then
 
643
    wget -c http://downloads.sourceforge.net/project/spacenav/spacenav%20library%20%28SDK%29/libspnav%200.2.2/libspnav-$SPNAV_V.tar.gz \
 
644
        -P "$SOURCES_PATH/packages"
 
645
    tar -C "$SOURCES_PATH/packages" -xf "$S.tar.gz"
 
646
    cat << EOF > "$S/0config.sh"
 
647
#!/bin/sh
 
648
 
 
649
./configure --prefix=/opt/lib/libspnav-$SPNAV_V
 
650
EOF
 
651
    chmod +x "$S/0config.sh"
 
652
  fi
 
653
 
 
654
  # FFmpeg
 
655
  F="$SOURCES_PATH/packages/ffmpeg-$FFMPEG_V"
 
656
  if [ ! -d "$F" ]; then
 
657
    INFO "Downloading FFmpeg-$FFMPEG_V"
 
658
    wget -c http://ffmpeg.org/releases/ffmpeg-$FFMPEG_V.tar.bz2 -P "$SOURCES_PATH/packages"
 
659
    tar -C "$SOURCES_PATH/packages" -xf "$F.tar.bz2"
 
660
    cat << EOF > "$F/0config.sh"
 
661
#!/bin/sh
 
662
 
 
663
./configure \\
 
664
    --cc="/usr/bin/gcc-4.7 -Wl,--as-needed" \\
 
665
    --extra-ldflags="-pthread -static-libgcc" \\
 
666
    --prefix=/opt/lib/ffmpeg-$FFMPEG_V \\
 
667
    --enable-static \\
 
668
    --enable-avfilter \\
 
669
    --disable-vdpau \\
 
670
    --disable-bzlib \\
 
671
    --disable-libgsm \\
 
672
    --enable-libschroedinger \\
 
673
    --disable-libspeex \\
 
674
    --enable-libtheora \\
 
675
    --enable-libvorbis \\
 
676
    --enable-pthreads \\
 
677
    --enable-zlib \\
 
678
    --enable-libvpx \\
 
679
    --enable-stripping \\
 
680
    --enable-runtime-cpudetect  \\
 
681
    --disable-vaapi \\
 
682
    --enable-libopenjpeg \\
 
683
    --disable-libfaac \\
 
684
    --disable-nonfree \\
 
685
    --enable-gpl \\
 
686
    --disable-postproc \\
 
687
    --disable-x11grab \\
 
688
    --enable-libmp3lame \\
 
689
    --disable-librtmp \\
 
690
    --enable-libx264 \\
 
691
    --enable-libxvid \\
 
692
    --disable-libopencore-amrnb \\
 
693
    --disable-libopencore-amrwb \\
 
694
    --disable-libdc1394 \\
 
695
    --disable-version3 \\
 
696
    --disable-outdev=sdl \\
 
697
    --disable-outdev=alsa \\
 
698
    --disable-indev=sdl \\
 
699
    --disable-indev=alsa \\
 
700
    --disable-indev=jack \\
 
701
    --disable-indev=lavfi
 
702
 
 
703
#    --enable-debug
 
704
#    --disable-optimizations
 
705
#    --disable-ffplay
 
706
EOF
 
707
    chmod +x "$F/0config.sh"
 
708
  fi
 
709
 
 
710
  # Boost
 
711
  B="$SOURCES_PATH/packages/boost_$BOOST_V"
 
712
  if [ ! -d "$B" ]; then
 
713
    INFO "Downloading Boost-$BOOST_V"
 
714
    b_d=`echo "$BOOST_V" | sed -r 's/_/./g'`
 
715
    wget -c http://sourceforge.net/projects/boost/files/boost/$b_d/boost_$BOOST_V.tar.bz2/download -O "$B.tar.bz2"
 
716
    tar -C "$SOURCES_PATH/packages" -xf "$B.tar.bz2"
 
717
  fi
 
718
 
 
719
  # Python
 
720
  P="$SOURCES_PATH/packages/Python-$PYTHON_V"
 
721
  if [ ! -d "$P" ]; then
 
722
    INFO "Downloading Python-$PYTHON_V"
 
723
    wget -c http://python.org/ftp/python/$PYTHON_V/Python-$PYTHON_V.tar.bz2 -P "$SOURCES_PATH/packages"
 
724
    tar -C "$SOURCES_PATH/packages" -xf "$P.tar.bz2"
 
725
    cat << EOF > "$P/0config.sh"
 
726
#!/bin/sh
 
727
 
 
728
# NOTE: this sounds strange, but make sure /dev/shm/ is writable by your user,
 
729
#        otherwise syncronization primitives wouldn't be included into python
 
730
if [[ "\`stat -c '%a' /dev/shm/\`" != "777" ]]; then
 
731
  echo "Error checking syncronization primitives"
 
732
  exit 1
 
733
fi
 
734
 
 
735
./configure --prefix=/opt/lib/python-$PYTHON_V \\
 
736
  --enable-ipv6 \\
 
737
  --enable-loadable-sqlite-extensions \\
 
738
  --with-dbmliborder=bdb \\
 
739
  --with-wide-unicode \\
 
740
  --with-computed-gotos \\
 
741
  --with-pymalloc
 
742
EOF
 
743
    chmod +x "$P/0config.sh"
 
744
  fi
 
745
 
 
746
  # OpenImageIO
 
747
  O="$SOURCES_PATH/packages/OpenImageIO-$OIIO_V"
 
748
  if [ ! -d "$O" ]; then
 
749
    INFO "Downloading OpenImageIO-$OIIO_V"
 
750
    wget -c https://github.com/OpenImageIO/oiio/tarball/Release-$OIIO_V -O "$O.tar.gz"
 
751
    tar -C "$SOURCES_PATH/packages" -xf "$O.tar.gz"
 
752
    mv $SOURCES_PATH/packages/OpenImageIO-oiio* $O
 
753
    mkdir $O/build
 
754
    cat << EOF > "$O/build/prepare.sh"
 
755
#!/bin/sh
 
756
 
 
757
if file /bin/cp | grep -q '32-bit'; then
 
758
  cflags="-fPIC -m32 -march=i686"
 
759
else
 
760
  cflags="-fPIC"
 
761
fi
 
762
 
 
763
cmake \\
 
764
    -D CMAKE_BUILD_TYPE=Release \\
 
765
    -D CMAKE_PREFIX_PATH=/opt/lib/oiio-$OIIO_V \\
 
766
    -D CMAKE_INSTALL_PREFIX=/opt/lib/oiio-$OIIO_V \\
 
767
    -D BUILDSTATIC=ON \\
 
768
    -D USE_JASPER=OFF \\
 
769
    -D CMAKE_CXX_FLAGS:STRING="\${cflags}" \\
 
770
    -D CMAKE_C_FLAGS:STRING="\${cflags}" \\
 
771
    -D CMAKE_EXE_LINKER_FLAGS='-lgcc_s -lgcc' \\
 
772
    -D BOOST_ROOT=/opt/lib/boost \\
 
773
    ../src
 
774
EOF
 
775
    chmod +x "$O/build/prepare.sh"
 
776
  fi
 
777
 
 
778
  # OpenColorIO
 
779
  O="$SOURCES_PATH/packages/OpenColorIO-$OCIO_V"
 
780
  if [ ! -d "$O" ]; then
 
781
    INFO "Downloading OpenColorIO-$OCIO_V"
 
782
    wget -c http://github.com/imageworks/OpenColorIO/tarball/v$OCIO_V -O "$O.tar.gz"
 
783
    tar -C "$SOURCES_PATH/packages" -xf "$O.tar.gz"
 
784
    mv $SOURCES_PATH/packages/imageworks-OpenColorIO* $O
 
785
    mkdir $O/build
 
786
    cat << EOF > "$O/build/prepare.sh"
 
787
#!/bin/sh
 
788
 
 
789
if file /bin/cp | grep -q '32-bit'; then
 
790
  cflags="-fPIC -m32 -march=i686"
 
791
else
 
792
  cflags="-fPIC"
 
793
fi
 
794
 
 
795
cmake \\
 
796
  -D CMAKE_BUILD_TYPE=Release \\
 
797
  -D CMAKE_PREFIX_PATH=/opt/lib/ocio-1.0.7 \\
 
798
  -D CMAKE_INSTALL_PREFIX=/opt/lib/ocio-1.0.7 \\
 
799
  -D BUILDSTATIC=ON \\
 
800
  -D CMAKE_CXX_FLAGS:STRING="\${cflags}" \\
 
801
  -D CMAKE_C_FLAGS:STRING="\${cflags}" \\
 
802
  -D CMAKE_EXE_LINKER_FLAGS='-lgcc_s -lgcc' \\
 
803
  ..
 
804
EOF
 
805
 
 
806
    chmod +x "$O/build/prepare.sh"
 
807
  fi
 
808
 
 
809
  # Mesa
 
810
  M="$SOURCES_PATH/packages/Mesa-$MESA_V"
 
811
  if [ ! -d "$M" ]; then
 
812
    INFO "Downloading Mesa-$MESA_V"
 
813
    wget -c ftp://ftp.freedesktop.org/pub/mesa/$MESA_V/MesaLib-$MESA_V.tar.bz2 -P "$SOURCES_PATH/packages"
 
814
    tar -C "$SOURCES_PATH/packages" -xf "$SOURCES_PATH/packages/MesaLib-$MESA_V.tar.bz2"
 
815
    cat << EOF > "$M/0config.sh"
 
816
#!/bin/sh
 
817
 
 
818
OPTS="--with-driver=xlib \\
 
819
  --disable-driglx-direct \\
 
820
  --disable-egl \\
 
821
  --enable-gallium-gbm=no \\
 
822
  --enable-gallium-egl=no \\
 
823
  --enable-gallium-llvm=no \\
 
824
  --with-gallium-drivers=swrast \\
 
825
  --with-dri-drivers=swrast \\
 
826
  --prefix=/opt/lib/mesa-$MESA_V"
 
827
 
 
828
if file /bin/cp | grep -q '32-bit'; then
 
829
  ./configure CC="gcc-4.7 -Wl,--as-needed" CXX="g++-4.7 -Wl,--as-needed" LDFLAGS="-pthread -static-libgcc" \${OPTS} --enable-32-bit #--build=i486-linux-gnu
 
830
else
 
831
  ./configure CC="gcc-4.7 -Wl,--as-needed" CXX="g++-4.7 -Wl,--as-needed" LDFLAGS="-pthread -static-libgcc" \${OPTS}
 
832
fi
 
833
 
 
834
EOF
 
835
    chmod +x "$M/0config.sh"
 
836
  fi
 
837
 
 
838
  # OpenAL
 
839
  O="$SOURCES_PATH/packages/openal-soft-$OPENAL_V"
 
840
  if [ ! -d "$O" ]; then
 
841
    INFO "Downloading OpenAL-$OPENAL_V"
 
842
    wget -c http://kcat.strangesoft.net/openal-releases/openal-soft-$OPENAL_V.tar.bz2 -P "$SOURCES_PATH/packages"
 
843
    tar -C "$SOURCES_PATH/packages" -xf "$SOURCES_PATH/packages/openal-soft-$OPENAL_V.tar.bz2"
 
844
    cat << EOF > "$O/build-openal.sh"
 
845
#!/bin/sh
 
846
 
 
847
DEB_CMAKE_OPTIONS="-DCMAKE_VERBOSE_MAKEFILE=ON \\
 
848
    -DCMAKE_INSTALL_PREFIX=/opt/lib/openal-$OPENAL_V \\
 
849
    -DCMAKE_BUILD_TYPE:String=Release \\
 
850
    -DALSOFT_CONFIG=ON \\
 
851
    -DLIBTYPE=STATIC .. "
 
852
 
 
853
BUILD_TREE=./build-tree
 
854
 
 
855
rm -rf "\${BUILD_TREE}"
 
856
mkdir -p "\${BUILD_TREE}"
 
857
cd "\${BUILD_TREE}"
 
858
 
 
859
sh -c "cmake \`echo \$DEB_CMAKE_OPTIONS\`"
 
860
make -j$THREADS
 
861
make install
 
862
EOF
 
863
    chmod +x "$O/build-openal.sh"
 
864
  fi
 
865
 
 
866
  # OpenCollada
 
867
  O="$SOURCES_PATH/packages/opencollada"
 
868
  if [ ! -d "$O" ]; then
 
869
    INFO "Checking out OpenCollada sources"
 
870
    svn co http://opencollada.googlecode.com/svn/trunk $O
 
871
 
 
872
    cat << EOF > "$O/build_all.sh"
 
873
#!/bin/sh
 
874
 
 
875
scons RELEASE=0 NOVALIDATION=1 XMLPARSER=libxmlnative PCRENATIVE=1 SHAREDLIB=0 -j ${THREADS} --clean
 
876
scons RELEASE=1 NOVALIDATION=1 XMLPARSER=libxmlnative PCRENATIVE=1 SHAREDLIB=0 -j ${THREADS} --clean
 
877
 
 
878
scons RELEASE=0 NOVALIDATION=1 XMLPARSER=libxmlnative PCRENATIVE=1 SHAREDLIB=0 -j ${THREADS}
 
879
scons RELEASE=1 NOVALIDATION=1 XMLPARSER=libxmlnative PCRENATIVE=1 SHAREDLIB=0 -j ${THREADS}
 
880
EOF
 
881
 
 
882
    cat << EOF > "$O/prepare_lib-libxml.sh"
 
883
#!/bin/bash
 
884
 
 
885
src="./COLLADAStreamWriter/include
 
886
./COLLADABaseUtils/include
 
887
./COLLADABaseUtils/include/Math
 
888
./COLLADAFramework/include
 
889
./GeneratedSaxParser/include
 
890
./COLLADASaxFrameworkLoader/include
 
891
./COLLADASaxFrameworkLoader/include/generated14
 
892
./COLLADASaxFrameworkLoader/include/generated15"
 
893
 
 
894
if [ -z \$1 ]; then
 
895
  arch="x86_64"
 
896
else
 
897
  arch=\$1
 
898
fi
 
899
 
 
900
libs="./GeneratedSaxParser/lib/posix/\${arch}/releaselibxml/libGeneratedSaxParser.a
 
901
./Externals/MathMLSolver/lib/posix/\${arch}/release/libMathMLSolver.a
 
902
./COLLADABaseUtils/lib/posix/\${arch}/release/libOpenCOLLADABaseUtils.a
 
903
./COLLADAFramework/lib/posix/\${arch}/release/libOpenCOLLADAFramework.a
 
904
./COLLADASaxFrameworkLoader/lib/posix/\${arch}/releaselibxmlNovalidation/libOpenCOLLADASaxFrameworkLoader.a
 
905
./COLLADAStreamWriter/lib/posix/\${arch}/release/libOpenCOLLADAStreamWriter.a
 
906
./Externals/UTF/lib/posix/\${arch}/release/libUTF.a
 
907
./common/libBuffer/lib/posix/\${arch}/release/libbuffer.a
 
908
./common/libftoa/lib/posix/\${arch}/release/libftoa.a"
 
909
 
 
910
#./Externals/pcre/lib/posix/\${arch}/release/libpcre.a
 
911
#./Externals/LibXML/lib/posix/\${arch}/release/libxml.a
 
912
 
 
913
debug_libs="./GeneratedSaxParser/lib/posix/\${arch}/debuglibxml/libGeneratedSaxParser.a
 
914
./Externals/MathMLSolver/lib/posix/\${arch}/debug/libMathMLSolver.a
 
915
./COLLADABaseUtils/lib/posix/\${arch}/debug/libOpenCOLLADABaseUtils.a
 
916
./COLLADAFramework/lib/posix/\${arch}/debug/libOpenCOLLADAFramework.a
 
917
./COLLADASaxFrameworkLoader/lib/posix/\${arch}/debuglibxmlNovalidation/libOpenCOLLADASaxFrameworkLoader.a
 
918
./COLLADAStreamWriter/lib/posix/\${arch}/debug/libOpenCOLLADAStreamWriter.a
 
919
./Externals/UTF/lib/posix/\${arch}/debug/libUTF.a
 
920
./common/libBuffer/lib/posix/\${arch}/debug/libbuffer.a
 
921
./common/libftoa/lib/posix/\${arch}/debug/libftoa.a"
 
922
 
 
923
#./Externals/pcre/lib/posix/\${arch}/debug/libpcre.a
 
924
#./Externals/LibXML/lib/posix/\${arch}/debug/libxml.a
 
925
 
 
926
d="opencollada-libxml"
 
927
rm -rf \${d}
 
928
mkdir -p \${d}/include
 
929
 
 
930
for i in \${src}; do
 
931
  mkdir -p \${d}/include/\${i}
 
932
  cp \${i}/*.h \${d}/include/\${i}
 
933
done
 
934
 
 
935
mkdir \${d}/lib
 
936
for i in \${libs}; do
 
937
  echo "" > /dev/null
 
938
  cp \${i} \${d}/lib
 
939
done
 
940
 
 
941
for i in \${debug_libs}; do
 
942
  f=\`basename \${i}\`
 
943
  o=\${f/\\.a/_d.a}
 
944
  cp \${i} \${d}/lib/\${o}
 
945
done
 
946
 
 
947
rm -rf /opt/lib/opencollada
 
948
mv \${d} /opt/lib/opencollada
 
949
chown -R root:staff /opt/lib/opencollada
 
950
EOF
 
951
 
 
952
    chmod +x "$O/build_all.sh"
 
953
    chmod +x "$O/prepare_lib-libxml.sh"
 
954
  fi
 
955
 
 
956
  # Blender
 
957
  B="$SOURCES_PATH/blender"
 
958
  if [ ! -d "$B" ]; then
 
959
    INFO "Checking out Blender sources"
 
960
    svn co https://svn.blender.org/svnroot/bf-blender/trunk/blender $B
 
961
  fi
 
962
 
 
963
  # CUDA Toolkit
 
964
  C=$SOURCES_PATH/cudatoolkit
 
965
  if [ ! -f "$C/$CUDA_32" ]; then
 
966
    INFO "Downloading CUDA 32bit toolkit"
 
967
    mkdir -p $C
 
968
    wget -c http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/$CUDA_32 -P $C
 
969
  fi
 
970
 
 
971
  if [ ! -f "$C/$CUDA_64" ]; then
 
972
    INFO "Downloading CUDA 64bit toolkit"
 
973
    mkdir -p $C
 
974
    wget -c http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/$CUDA_64 -P $C
 
975
  fi
 
976
 
 
977
  if [ ! -f $SOURCES_PATH/Readme.txt ]; then
 
978
 
 
979
    cat << EOF > $SOURCES_PATH/Readme.txt
 
980
This directory contains different things needed for Blender builds
 
981
 
 
982
blender/: directory with blender's svnsnapshot
 
983
 
 
984
blender-build/, blender-install/: build and install directories for
 
985
                                  automated release creation
 
986
 
 
987
buildbot-i686-slave/,
 
988
buildbot-x86_64-slave/: buildbot slave environments for automated builds
 
989
                        (maybe it'll be better to move them to /home?)
 
990
 
 
991
staticlibs/: set of static libs. Mostly needed to make static linking prioretized
 
992
             under dynamic linking
 
993
 
 
994
release-builder/: all stuff needed for release archives preparation
 
995
 
 
996
Hope all this would help you.
 
997
 
 
998
-Sergey-
 
999
EOF
 
1000
  fi
 
1001
 
 
1002
  INSTALL_RELEASE_BUILDER $SOURCES_PATH
 
1003
}
 
1004
 
 
1005
DO_BACKPORT() {
 
1006
  CHROOT_ARCH=$1
 
1007
  CHROOT_PATH=$2
 
1008
 
 
1009
  RUN="chroot $CHROOT_PATH"
 
1010
  P="/home/sources/backport"
 
1011
 
 
1012
  # Backport fresh binutils
 
1013
  if [ `$RUN dpkg-query -W -f='${Version}\n' binutils | grep -c $BINUTILS_V` -eq "0" ]; then
 
1014
    INFO "Backporting binutils"
 
1015
    B="$P/binutils/binutils-$BINUTILS_V"
 
1016
    pkg="$P/binutils/binutils_${BINUTILS_FV}_amd64.deb"
 
1017
 
 
1018
    if [ ! -d "$CHROOT_PATH/$B" ]; then
 
1019
      INFO "Unpacking binutils"
 
1020
      $RUN dpkg-source -x "$P/binutils/binutils_$BINUTILS_FV.dsc" "$B"
 
1021
    fi
 
1022
 
 
1023
    if [ "$CHROOT_ARCH" = "i386" ]; then
 
1024
      pkg=`echo "$pkg" | sed -r 's/amd64/i386/g'`
 
1025
    fi
 
1026
 
 
1027
    if [ ! -f "$CHROOT_PATH/$pkg" ]; then
 
1028
      INFO "Compiling binutils"
 
1029
      sed -ie 's/with_check := yes/with_check := no/' "$CHROOT_PATH/$B/debian/rules"
 
1030
      $RUN sh -c "cd '$B' && dpkg-buildpackage -rfakeroot -j$THREADS"
 
1031
    fi
 
1032
 
 
1033
    INFO "Installing binutils"
 
1034
    $RUN dpkg -i "$pkg"
 
1035
 
 
1036
    INFO "Cleaning binutils"
 
1037
    $RUN sh -c "cd '$B' && fakeroot debian/rules clean"
 
1038
  fi
 
1039
 
 
1040
  # Install fresh gcc
 
1041
  if [ `$RUN dpkg-query -W -f='${Status}\n' gcc-4.7 2> /dev/null | grep -c installed` -eq "0" ]; then
 
1042
    INFO "Backporting gcc-4.7"
 
1043
    G="$P/gcc-4.7/gcc-$GCC_V"
 
1044
 
 
1045
    pkg="cpp-4.7_4.7.1-7_amd64.deb  gcc-4.7-base_4.7.1-7_amd64.deb \
 
1046
          libstdc++6-4.7-dev_4.7.1-7_amd64.deb libstdc++6_4.7.1-7_amd64.deb libgcc1_4.7.1-7_amd64.deb \
 
1047
          libgomp1_4.7.1-7_amd64.deb libitm1_4.7.1-7_amd64.deb libquadmath0_4.7.1-7_amd64.deb \
 
1048
          gcc-4.7_4.7.1-7_amd64.deb g++-4.7_4.7.1-7_amd64.deb"
 
1049
 
 
1050
    if [ ! -d "$CHROOT_PATH/$G" ]; then
 
1051
      INFO "Unpacking gcc-4.7"
 
1052
      $RUN dpkg-source -x "$P/gcc-4.7/gcc-$GCC_FV.dsc" "$G"
 
1053
    fi
 
1054
 
 
1055
    if [ "$CHROOT_ARCH" = "i386" ]; then
 
1056
      pkg=`echo "$pkg" | sed -r 's/amd64/i386/g'`
 
1057
    fi
 
1058
 
 
1059
    ok=true
 
1060
    for x in `echo "$pkg"`; do
 
1061
      if [ ! -f "$CHROOT_PATH/$P/gcc-4.7/$x" ]; then
 
1062
        ok=false
 
1063
        break;
 
1064
      fi
 
1065
    done
 
1066
 
 
1067
    if ! $ok; then
 
1068
      INFO "Compiling gcc-4.7"
 
1069
      sed -ie 's/#with_check := disabled by hand/with_check := disabled by hand/' "$CHROOT_PATH/$G/debian/rules.defs"
 
1070
      sed -ie 's/dpkg-dev (>= 1.16.0~ubuntu4)/dpkg-dev (>= 1.15.8)/' "$CHROOT_PATH/$G/debian/control"
 
1071
      sed -ie 's/doxygen (>= 1.7.2)/doxygen (>= 1.7.1)/' "$CHROOT_PATH/$G/debian/control"
 
1072
      sed -ie 's/libmpfr-dev (>= 3.0.0-9~)/libmpfr-dev (>= 3.0.0)/' "$CHROOT_PATH/$G/debian/control"
 
1073
      sed -ie 's/libc6-dev (>= 2.13-5)/libc6-dev (>= 2.11.3)/' "$CHROOT_PATH/$G/debian/control"
 
1074
      sed -ie 's/libgmp-dev (>= 2:5.0.1~)/libgmp3-dev (>= 2:4.3.2)/' "$CHROOT_PATH/$G/debian/control"
 
1075
      $RUN sh -c "cd '$G' && dpkg-buildpackage -rfakeroot"
 
1076
    fi
 
1077
 
 
1078
    inst=""
 
1079
    for x in `echo "$pkg"`; do
 
1080
      inst="$inst $P/gcc-4.7/$x"
 
1081
    done
 
1082
 
 
1083
    INFO "Installing gcc-4.7"
 
1084
    $RUN dpkg -i $inst
 
1085
 
 
1086
    INFO "Cleaning gcc-4.7"
 
1087
    $RUN sh -c "cd '$G' && fakeroot debian/rules clean"
 
1088
  fi
 
1089
 
 
1090
  # Backport OpenSSL
 
1091
  if [ ! -f $CHROOT_PATH/usr/lib/libssl_pic.a ]; then
 
1092
    INFO "Backporting OpenSSL"
 
1093
    O="$P/openssl/openssl-$OPENSSL_V"
 
1094
 
 
1095
    pkg="libssl-dev_0.9.8o-4squeeze13_amd64.deb libssl0.9.8_0.9.8o-4squeeze13_amd64.deb  openssl_0.9.8o-4squeeze13_amd64.deb"
 
1096
 
 
1097
    if [ ! -d "$CHROOT_PATH/$O" ]; then
 
1098
      INFO "Unpacking OpenSSL"
 
1099
      $RUN dpkg-source -x "$P/openssl/openssl_$OPENSSL_FV.dsc" "$O"
 
1100
    fi
 
1101
 
 
1102
    if [ "$CHROOT_ARCH" = "i386" ]; then
 
1103
      pkg=`echo "$pkg" | sed -r 's/amd64/i386/g'`
 
1104
    fi
 
1105
 
 
1106
    ok=true
 
1107
    for x in `echo "$pkg"`; do
 
1108
      if [ ! -f "$CHROOT_PATH/$P/openssl/$x" ]; then
 
1109
        ok=false
 
1110
        break;
 
1111
      fi
 
1112
    done
 
1113
 
 
1114
    if ! $ok; then
 
1115
      INFO "Compiling OpenSSL"
 
1116
      sed -ie 's/#\s*mv debian\/tmp\/usr\/lib\/libcrypto.a debian\/tmp\/usr\/lib\/libcrypto_pic.a/      mv debian\/tmp\/usr\/lib\/libcrypto.a debian\/tmp\/usr\/lib\/libcrypto_pic.a/' "$CHROOT_PATH/$O/debian/rules"
 
1117
      sed -ie 's/#\s*mv debian\/tmp\/usr\/lib\/libssl.a debian\/tmp\/usr\/lib\/libssl_pic.a/    mv debian\/tmp\/usr\/lib\/libssl.a debian\/tmp\/usr\/lib\/libssl_pic.a/' "$CHROOT_PATH/$O/debian/rules"
 
1118
      cat << EOF > $CHROOT_PATH/$O/debian/libssl-dev.files
 
1119
usr/lib/libssl.so
 
1120
usr/lib/libcrypto.so
 
1121
usr/lib/libssl.a
 
1122
usr/lib/libcrypto.a
 
1123
usr/lib/libssl_pic.a
 
1124
usr/lib/libcrypto_pic.a
 
1125
usr/lib/pkgconfig
 
1126
usr/include
 
1127
usr/share/man/man3
 
1128
EOF
 
1129
      $RUN sh -c "cd '$O' && dpkg-buildpackage -rfakeroot -j$THREADS"
 
1130
    fi
 
1131
 
 
1132
    inst=""
 
1133
    for x in `echo "$pkg"`; do
 
1134
      inst="$inst $P/openssl/$x"
 
1135
    done
 
1136
 
 
1137
    INFO "Installing OpenSSL"
 
1138
    $RUN dpkg -i $inst
 
1139
 
 
1140
    echo "openssl hold" | $RUN dpkg --set-selections
 
1141
    echo "libssl-dev hold" | $RUN dpkg --set-selections
 
1142
    echo "libssl0.9.8 hold" | $RUN dpkg --set-selections
 
1143
 
 
1144
    INFO "Cleaning OpenSSL"
 
1145
    $RUN sh -c "cd '$O' && fakeroot debian/rules clean"
 
1146
  fi
 
1147
}
 
1148
 
 
1149
DO_COMPILE() {
 
1150
  CHROOT_ARCH=$1
 
1151
  CHROOT_PATH=$2
 
1152
 
 
1153
  RUN="chroot $CHROOT_PATH"
 
1154
  P="/home/sources/packages"
 
1155
  L="$CHROOT_PATH/opt/lib"
 
1156
 
 
1157
  # JeMalloc
 
1158
  if [ ! -d "$L/jemalloc-$JEMALLOC_V" ]; then
 
1159
    INFO "Copmiling jemalloc-$JEMALLOC_V"
 
1160
    $RUN sh -c "cd '$P/jemalloc-$JEMALLOC_V' && ./0config.sh && make clean && make -j$THREADS && make install && make clean"
 
1161
 
 
1162
    rm -f "$L/jemalloc"
 
1163
    ln -s "jemalloc-$JEMALLOC_V" "$L/jemalloc"
 
1164
  fi
 
1165
 
 
1166
  # libspnav
 
1167
  if [ ! -d "$L/libspnav-$SPNAV_V" ]; then
 
1168
    INFO "Copmiling libspnav-$SPNAV_V"
 
1169
    mkdir -p "$L/libspnav-$SPNAV_V/lib"
 
1170
    mkdir -p "$L/libspnav-$SPNAV_V/include"
 
1171
    $RUN sh -c "cd '$P/libspnav-$SPNAV_V' && ./0config.sh && make clean && make -j$THREADS && make install && make clean"
 
1172
 
 
1173
    rm -f "$L/libspnav"
 
1174
    ln -s "libspnav-$SPNAV_V" "$L/libspnav"
 
1175
  fi
 
1176
 
 
1177
  # FFmpeg
 
1178
  if [ ! -d "$L/ffmpeg-$FFMPEG_V" ]; then
 
1179
    INFO "Copmiling ffmpeg-$FFMPEG_V"
 
1180
    $RUN sh -c "cd '$P/ffmpeg-$FFMPEG_V' && ./0config.sh && make clean && make -j$THREADS && make install && make clean"
 
1181
 
 
1182
    rm -f "$L/ffmpeg"
 
1183
    ln -s "ffmpeg-$FFMPEG_V" "$L/ffmpeg"
 
1184
  fi
 
1185
 
 
1186
  # Boost
 
1187
  V=`echo $BOOST_V | sed -r 's/_/./g'`
 
1188
  if [ ! -d "$L/boost-$V" ]; then
 
1189
    INFO "Copmiling boost-$V"
 
1190
    $RUN sh -c "cd '$P/boost_$BOOST_V' && ./bootstrap.sh && ./b2 --clean && ./b2 install --prefix='/opt/lib/boost-$V' && ./b2 --clean"
 
1191
 
 
1192
    rm -f "$L/boost"
 
1193
    ln -s "boost-$V" "$L/boost"
 
1194
  fi
 
1195
 
 
1196
  # OCIO
 
1197
  if [ ! -d "$L/ocio-$OCIO_V" ]; then
 
1198
    INFO "Copmiling ocio-$OCIO_V"
 
1199
    $RUN sh -c "cd '$P/OpenColorIO-$OCIO_V/build' && ./prepare.sh && make clean && make -j$THREADS && make install && make clean"
 
1200
 
 
1201
    # Force linking against sttaic libs
 
1202
    rm -f $L/ocio-$OCIO_V/lib/*.so*
 
1203
 
 
1204
    # Additional depencencies
 
1205
    cp $CHROOT_PATH/$P/OpenColorIO-$OCIO_V/build/ext/dist/lib/libtinyxml.a $L/ocio-$OCIO_V/lib
 
1206
    cp $CHROOT_PATH/$P/OpenColorIO-$OCIO_V/build/ext/dist/lib/libyaml-cpp.a $L/ocio-$OCIO_V/lib
 
1207
 
 
1208
    rm -f "$L/ocio"
 
1209
    ln -s "ocio-$OCIO_V" "$L/ocio"
 
1210
  fi
 
1211
 
 
1212
  # OIIO
 
1213
  if [ ! -d "$L/oiio-$OIIO_V" ]; then
 
1214
    INFO "Copmiling oiio-$OIIO_V"
 
1215
    $RUN sh -c "cd '$P/OpenImageIO-$OIIO_V/build' && ./prepare.sh && make clean && make -j$THREADS && make install && make clean"
 
1216
 
 
1217
    rm -f "$L/oiio"
 
1218
    ln -s "oiio-$OIIO_V" "$L/oiio"
 
1219
  fi
 
1220
 
 
1221
  # Python
 
1222
  if [ ! -d "$L/python-$PYTHON_V" ]; then
 
1223
    INFO "Copmiling Python-$PYTHON_V"
 
1224
 
 
1225
    cat << EOF > $CHROOT_PATH/$P/Python-$PYTHON_V/Modules/Setup.local
 
1226
_md5 md5module.c
 
1227
 
 
1228
_sha1 sha1module.c
 
1229
_sha256 sha256module.c
 
1230
_sha512 sha512module.c
 
1231
EOF
 
1232
 
 
1233
    sed -ie "s/libraries = \['ssl', 'crypto'\]/libraries = ['ssl_pic', 'crypto_pic', 'z']/" "$P/Python-$PYTHON_V/setup.py"
 
1234
 
 
1235
    $RUN sh -c "cd '$P/Python-$PYTHON_V' && ./0config.sh && make clean && make -j$THREADS && make install && make clean"
 
1236
 
 
1237
    rm -f "$L/python-$PYTHIN_V_SHORT"
 
1238
    ln -s "python-$PYTHON_V" "$L/python-$PYTHIN_V_SHORT"
 
1239
  fi
 
1240
 
 
1241
  # Mesa
 
1242
  if [ ! -d "$L/mesa-$MESA_V" ]; then
 
1243
    INFO "Copmiling Mesa-$MESA_V"
 
1244
 
 
1245
    $RUN sh -c "cd '$P/Mesa-$MESA_V' && ./0config.sh && make clean && make -j$THREADS && make install && make clean"
 
1246
 
 
1247
    rm -f "$L/mesa"
 
1248
    ln -s "mesa-$MESA_V" "$L/mesa"
 
1249
  fi
 
1250
 
 
1251
  # OpenAL
 
1252
  if [ ! -d "$L/openal-$OPENAL_V" ]; then
 
1253
    INFO "Copmiling openal-$OPENAL_V"
 
1254
 
 
1255
    $RUN sh -c "cd '$P/openal-soft-$OPENAL_V' && ./build-openal.sh"
 
1256
 
 
1257
    rm -f "$L/openal"
 
1258
    ln -s "openal-$OPENAL_V" "$L/openal"
 
1259
  fi
 
1260
 
 
1261
  # OpenCollada
 
1262
  if [ ! -d "$L/opencollada" ]; then
 
1263
    INFO "Copmiling opencollada"
 
1264
 
 
1265
    cat << EOF > "$CHROOT_PATH/$P/opencollada/collada.patch"
 
1266
Index: common/libBuffer/include/CommonBuffer.h
 
1267
===================================================================
 
1268
--- common/libBuffer/include/CommonBuffer.h     (revision 876)
 
1269
+++ common/libBuffer/include/CommonBuffer.h     (working copy)
 
1270
@@ -12,6 +12,7 @@
 
1271
 #define __COMMON_BUFFER_H__
 
1272
 
 
1273
 #include "CommonIBufferFlusher.h"
 
1274
+#include "COLLADABUPlatform.h"
 
1275
 
 
1276
 namespace Common
 
1277
 {
 
1278
Index: common/libBuffer/src/CommonLogFileBufferFlusher.cpp
 
1279
===================================================================
 
1280
--- common/libBuffer/src/CommonLogFileBufferFlusher.cpp (revision 876)
 
1281
+++ common/libBuffer/src/CommonLogFileBufferFlusher.cpp (working copy)
 
1282
@@ -10,6 +10,34 @@
 
1283
 
 
1284
 #include "CommonLogFileBufferFlusher.h"
 
1285
 
 
1286
+#include <stdio.h>
 
1287
+#include <errno.h>
 
1288
+
 
1289
+#ifndef _WIN32
 
1290
+FILE *_wfopen(const wchar_t *path, const char *mode)
 
1291
+{
 
1292
+       const wchar_t *src = path;
 
1293
+       char *path_mbs;
 
1294
+       int n;
 
1295
+       FILE *file;
 
1296
+
 
1297
+       n = (int)wcsrtombs(NULL, &src, 0, NULL);
 
1298
+
 
1299
+       if (n < 0)
 
1300
+               return NULL;
 
1301
+
 
1302
+       path_mbs = (char *)malloc(n + 1);
 
1303
+       wcsrtombs(path_mbs, &path, n, NULL);
 
1304
+       path_mbs[n] = 0;
 
1305
+
 
1306
+       file = fopen(path_mbs, mode);
 
1307
+
 
1308
+       free(path_mbs);
 
1309
+
 
1310
+       return file;
 
1311
+}
 
1312
+#endif
 
1313
+
 
1314
 namespace Common
 
1315
 {
 
1316
        //--------------------------------------------------------------------
 
1317
@@ -35,7 +63,7 @@
 
1318
 #ifdef _WIN32
 
1319
                mError = (int)_wfopen_s( &stream, fileName, L"wb" );
 
1320
 #else
 
1321
-               stream = _wfopen( fileName, L"wb" );
 
1322
+               stream = _wfopen( fileName, "wb" );
 
1323
                mError = stream ? 0 : errno;
 
1324
 #endif
 
1325
                if ( !mError )
 
1326
@@ -65,7 +93,7 @@
 
1327
 #else
 
1328
                if ( mUseWideFileName )
 
1329
                {
 
1330
-                       stream = _wfopen( mWideFileName.c_str(), L"a" );
 
1331
+                       stream = _wfopen( mWideFileName.c_str(), "a" );
 
1332
                }
 
1333
                else
 
1334
                {
 
1335
Index: common/libBuffer/SConscript
 
1336
===================================================================
 
1337
--- common/libBuffer/SConscript (revision 876)
 
1338
+++ common/libBuffer/SConscript (working copy)
 
1339
@@ -11,7 +11,7 @@
 
1340
 targetPath = outputDir + libName
 
1341
 
 
1342
 
 
1343
-incDirs = ['include/', '../libftoa/include']
 
1344
+incDirs = ['include/', '../libftoa/include', '../../COLLADABaseUtils/include/', '../../Externals/UTF/include']
 
1345
 
 
1346
 
 
1347
 src = []
 
1348
EOF
 
1349
 
 
1350
    # We're building in a chroot, architecture of host system would be used by scons
 
1351
    collada_arch="x86_64"
 
1352
 
 
1353
    $RUN sh -c "cd '$P/opencollada' && svn revert . -R && cat collada.patch | patch -p0 && ./build_all.sh && ./prepare_lib-libxml.sh  $collada_arch"
 
1354
  fi
 
1355
}
 
1356
 
 
1357
ADD_REPO() {
 
1358
  CHROOT_PATH=$1
 
1359
  DESC=$2
 
1360
  REPO=$3
 
1361
  C="$CHROOT_PATH/etc/apt/sources.list"
 
1362
  RUN="chroot $CHROOT_PATH"
 
1363
 
 
1364
  if [ `cat "$C" | grep -c "$REPO"` -eq "0" ]; then
 
1365
    INFO "Adding repo $DESC"
 
1366
    echo "" >> $C
 
1367
    echo "deb $REPO" >> $C
 
1368
    echo "deb-src $REPO" >> $C
 
1369
 
 
1370
    INFO "Updating packages list"
 
1371
    $RUN apt-get update
 
1372
  fi
 
1373
}
 
1374
 
 
1375
INSTALL_CHROOT() {
 
1376
  CHROOT_ARCH=$1
 
1377
  CHROOT_PATH=$2
 
1378
 
 
1379
  RUN="chroot $CHROOT_PATH"
 
1380
 
 
1381
  # Install fresh debian to a chroot
 
1382
  if [ ! -d "$CHROOT_PATH" ]; then
 
1383
 
 
1384
    INFO "Installing Debian ${DEBIAN_BRANCH} to ${CHROOT_PATH}"
 
1385
    debootstrap --arch "${CHROOT_ARCH}" "${DEBIAN_BRANCH}" "${CHROOT_PATH}" "${DEBIAN_MIRROR}"
 
1386
  fi
 
1387
 
 
1388
  # Configure users and groups
 
1389
 
 
1390
  if [ `cat ${CHROOT_PATH}/etc/group | grep -c developers` -eq "0" ]; then
 
1391
    INFO "Creating gorup 'developers'"
 
1392
    $RUN groupadd -g 7001 developers
 
1393
  fi
 
1394
 
 
1395
  if [ `mount | grep -c "$CHROOT_PATH/dev"` -eq "0" ]; then
 
1396
    INFO "Mounting devices from host system to chroot"
 
1397
 
 
1398
    mount -t proc none $CHROOT_PATH/proc
 
1399
    mount -t auto -o bind /dev $CHROOT_PATH/dev
 
1400
    mount -t devpts -o mode=0620 none $CHROOT_PATH/dev/pts
 
1401
  fi
 
1402
 
 
1403
  # Configure apt and install packages
 
1404
 
 
1405
  if [ ! -f ${CHROOT_PATH}/etc/apt/apt.conf ]; then
 
1406
    INFO "Setting up apt to not use recommended packages (saves disk space)"
 
1407
 
 
1408
    cat << EOF > "${CHROOT_PATH}/etc/apt/apt.conf"
 
1409
APT {
 
1410
  Default-Release "${DEBIAN_BRANCH}";
 
1411
  Install-Recommends "0";
 
1412
};
 
1413
EOF
 
1414
  fi
 
1415
 
 
1416
  ADD_REPO $CHROOT_PATH "mirror.yandex.ru" "http://mirror.yandex.ru/debian-multimedia/ squeeze main non-free"
 
1417
  ADD_REPO $CHROOT_PATH "backports.debian.org" "http://backports.debian.org/debian-backports squeeze-backports main non-free"
 
1418
 
 
1419
  $RUN apt-get upgrade
 
1420
 
 
1421
  $RUN apt-get install -y --force-yes deb-multimedia-keyring libx264-dev libxvidcore4-dev libmp3lame-dev
 
1422
 
 
1423
  if [ `$RUN dpkg-query -W -f='${Status}\n' locales | grep -c not-installed` -eq "1" ]; then
 
1424
    INFO "Configuring locales"
 
1425
    $RUN apt-get install -y locales
 
1426
    $RUN localedef -i en_US -f UTF-8 en_US.UTF-8
 
1427
  fi
 
1428
 
 
1429
  INFO "Installing packages from repository"
 
1430
 
 
1431
  $RUN apt-get install -y mc gcc g++ cmake python dpkg-dev build-essential autoconf bison \
 
1432
      flex gettext texinfo dejagnu quilt file lsb-release zlib1g-dev fakeroot debhelper \
 
1433
      g++-multilib  libtool autoconf2.64 automake  gawk lzma patchutils gperf sharutils \
 
1434
      libcloog-ppl-dev libmpc-dev libmpfr-dev libgmp3-dev autogen realpath chrpath doxygen \
 
1435
      graphviz gsfonts-x11 texlive-latex-base libelfg0-dev libx11-dev yasm libopenjpeg-dev \
 
1436
      libschroedinger-dev libtheora-dev libvorbis-dev libvpx-dev=$VPX_V \
 
1437
      libopenexr-dev libpng-dev libjpeg-dev libtiff-dev python-dev libbz2-dev libreadline-dev \
 
1438
      libsqlite3-dev liblzma-dev libncurses5-dev xutils-dev libxext-dev python-libxml2 \
 
1439
      libglu1-mesa-dev libfftw3-dev libfreetype6-dev libsdl1.2-dev libopenal-dev libjack-dev \
 
1440
      libxi-dev portaudio19-dev po4a subversion scons libpcre3-dev libexpat1-dev sudo \
 
1441
      expect bc
 
1442
 
 
1443
  if [ $CHROOT_ARCH = "amd64" ]; then
 
1444
    $RUN apt-get install -y libc6-dev-i386 lib32gcc1
 
1445
  fi
 
1446
 
 
1447
  # Configure sources directory
 
1448
  if [ ! -d "$CHROOT_PATH/home/sources" ]; then
 
1449
    INFO "Creating sources directory"
 
1450
    $RUN mkdir "/home/sources"
 
1451
    $RUN chmod 775 /home/sources
 
1452
    $RUN chown root:developers /home/sources
 
1453
  fi
 
1454
 
 
1455
  # Bind directory from host system
 
1456
  if [ ! -d "$CHROOT_PATH/home/sources/backport" ]; then
 
1457
    INFO "Binding sources directory from host system to chroot"
 
1458
    mount -o bind "$SOURCES_PATH" "$CHROOT_PATH/home/sources"
 
1459
  fi
 
1460
 
 
1461
  if [ "`$RUN getent passwd $USER_ID`" = "" ]; then
 
1462
    INFO "Adding default user to chroot"
 
1463
    login=`getent passwd $USER_ID | cut -d : -f 1`
 
1464
    $RUN useradd -d "/home/$login" -G developers,sudo -m -u $USER_ID "$login"
 
1465
  fi
 
1466
 
 
1467
  # Backport packages
 
1468
  DO_BACKPORT "$CHROOT_ARCH" "$CHROOT_PATH"
 
1469
 
 
1470
  # Set default compiler to gcc-4.7
 
1471
  if [ `readlink "$CHROOT_PATH/usr/bin/gcc"` != "gcc-4.7" ]; then
 
1472
    INFO "Setting gcc-4.7 as default compiler"
 
1473
    rm -f $CHROOT_PATH/usr/bin/gcc
 
1474
    rm -f $CHROOT_PATH/usr/bin/g++
 
1475
    ln -s gcc-4.7 $CHROOT_PATH/usr/bin/gcc
 
1476
    ln -s g++-4.7 $CHROOT_PATH/usr/bin/g++
 
1477
  fi
 
1478
 
 
1479
  # Compile packages
 
1480
  DO_COMPILE "$CHROOT_ARCH" "$CHROOT_PATH"
 
1481
 
 
1482
  # Install CUDA toolkit
 
1483
  if [ ! -d "$CHROOT_PATH/usr/local/cuda-$CUDA_V" ]; then
 
1484
        INFO "Installing CUDA toolkit"
 
1485
 
 
1486
        if [ "$CHROOT_ARCH" = "amd64" ]; then
 
1487
          C="cudatoolkit_${CUDA_V}_linux_64_${CUDA_DISTR}.run"
 
1488
        else
 
1489
          C="cudatoolkit_${CUDA_V}_linux_32_${CUDA_DISTR}.run"
 
1490
        fi
 
1491
 
 
1492
        rm -f $CHROOT_PATH/usr/local/cuda
 
1493
 
 
1494
        chmod +x $CHROOT_PATH//home/sources/cudatoolkit/$C
 
1495
 
 
1496
        $RUN /usr/bin/expect <<EOF
 
1497
        spawn /home/sources/cudatoolkit/$C
 
1498
        expect "Enter install path"
 
1499
        send "\n"
 
1500
        expect "Installation Complete"
 
1501
EOF
 
1502
 
 
1503
    mv $CHROOT_PATH/usr/local/cuda $CHROOT_PATH/usr/local/cuda-$CUDA_V
 
1504
    ln -s cuda-$CUDA_V $CHROOT_PATH/usr/local/cuda
 
1505
    sudo ln -s /usr/bin/gcc-4.4 $CHROOT_PATH/usr/local/cuda/bin/gcc
 
1506
  fi
 
1507
 
 
1508
  # Change permissions
 
1509
  INFO "Changing permissions on sources"
 
1510
  login=`$RUN getent passwd $USER_ID | cut -d : -f 1`
 
1511
  for x in /home/sources /opt/lib; do
 
1512
    $RUN chmod g+w -R $x
 
1513
    $RUN chown "$login:developers" -R $x
 
1514
  done
 
1515
}
 
1516
 
 
1517
if ! which debootstrap > /dev/null 2>&1; then
 
1518
  ERROR "debootstrap command not found, can not create chroot environment"
 
1519
  ERROR "Use apt-get install debootstrap to install debootstrap"
 
1520
  exit 1
 
1521
fi
 
1522
 
 
1523
if [ -z "$ENV_PATH" ]; then
 
1524
  ERROR "Incorrect environment directory is set"
 
1525
  exit 1
 
1526
fi
 
1527
 
 
1528
INSTALL_SOURCES "$SOURCES_PATH"
 
1529
INSTALL_CHROOT amd64 "$AMD64_PATH"
 
1530
INSTALL_CHROOT i386 "$I686_PATH"
 
1531
 
 
1532
INFO "Configurtion of build environment is completed!"
 
1533
echo "Add this lines to your /etc/fstab:"
 
1534
echo
 
1535
 
 
1536
for x in $I686_PATH $AMD64_PATH; do
 
1537
  echo "none           $x/proc         proc      auto              0    0"
 
1538
  echo "/dev           $x/dev          auto      bind,auto         0    0"
 
1539
  echo "none           $x/dev/pts      devpts    mode=0620,auto    0    0"
 
1540
  echo "/home/sources  $x/home/sources auto      bind,auto         0    0"
 
1541
  echo
 
1542
done
 
1543
 
 
1544
echo "Add this lines to your /etc/schroot/schroot.conf:"
 
1545
echo
 
1546
login=`getent passwd $USER_ID | cut -d : -f 1`
 
1547
 
 
1548
for x in $I686_PATH $AMD64_PATH; do
 
1549
  echo [`basename $x`]
 
1550
  echo "description=Linux buildbot environment"
 
1551
  echo "directory=$x"
 
1552
  echo "users=$login"
 
1553
  echo "root-groups=root"
 
1554
  echo
 
1555
done