[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51892] trunk/blender/build_files: Script to configure release build environment

Sergey Sharybin sergey.vfx at gmail.com
Mon Nov 5 10:58:09 CET 2012


Revision: 51892
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51892
Author:   nazgul
Date:     2012-11-05 09:58:05 +0000 (Mon, 05 Nov 2012)
Log Message:
-----------
Script to configure release build environment

This script was used to initialize build environment currently used
for glibc-2.11 builds.

It's supposed to be used on debian-based distros.

Usage is described in the top comment of the script.

It is highly recommended to use this script in the virtual machine
to prevent possible conflicts with your own configuration.

TODO:
- Add OSL configuration
- Script requires manual copying of some scripts still (see comments
  at the top of the script)

I would prefer this script be edited only in cases when it's really
needed, meaning i wouldn't be fan of changes like "just use latest
version of library XXX". It's not so safe to do such changes and it's
easy to upgrade libraries after environment was set up.

Added Paths:
-----------
    trunk/blender/build_files/build_environment/
    trunk/blender/build_files/build_environment/prepare_release_env.sh

Added: trunk/blender/build_files/build_environment/prepare_release_env.sh
===================================================================
--- trunk/blender/build_files/build_environment/prepare_release_env.sh	                        (rev 0)
+++ trunk/blender/build_files/build_environment/prepare_release_env.sh	2012-11-05 09:58:05 UTC (rev 51892)
@@ -0,0 +1,1483 @@
+#!/bin/sh
+
+#
+# This script will prepare build environment with the same settings as release environment
+#
+# It will install two chroot environments:
+#   - /home/buildbot_squeeze_i686
+#   - /home/buildbot_squeeze_x86_64
+# which are used for 32bit and 64bit
+#
+# This sctipt will also create folder /home/sources where all dependent libraries sources are
+# downloading and compiling.
+#
+# Release builder scripts are stored in /home/sources/release-builder
+# See build_all.sh script for usage details
+#
+# This script was tested on debian squeeze and wheezy, should work on ubuntu as well
+# It wouldn't work on other distros
+#
+# TODO:
+# - It's still required manual copying of build configuration files to /home/sources/release-builder/config
+# - OSL is not set up yet
+#
+
+set -e
+
+NO_COLOR='\033[0m'
+EWHITE='\033[1;37m'
+ERED='\033[1;31m'
+
+CONFIRM="--i-really-do-know-what-im-doing"
+
+ERROR() {
+  echo ${ERED}${@}${NO_COLOR}
+}
+
+INFO() {
+  echo ${EWHITE}${@}${NO_COLOR}
+}
+
+if [ $# != 1 ]; then
+  ERROR "Usage: $0 $CONFIRM"
+  exit 1
+fi
+
+if [ "$1" != "$CONFIRM" ]; then
+  ERROR "Usage: $0 $CONFIRM"
+  exit 1
+fi
+
+DEBIAN_BRANCH="squeeze"
+DEBIAN_MIRROR="http://ftp.de.debian.org/debian"
+USER_ID=1000
+
+# For now it's always /home, so we can setup schroot to map /sources to the same
+# path at both host and chroot systems (which is currently needed for release building script)
+ENV_PATH="/home"
+
+AMD64_PATH="$ENV_PATH/buildbot_${DEBIAN_BRANCH}_x86_64"
+I686_PATH="$ENV_PATH/buildbot_${DEBIAN_BRANCH}_i686"
+SOURCES_PATH="$ENV_PATH/sources"
+
+THREADS=`cat /proc/cpuinfo | grep cores | uniq | sed -e "s/.*: *\(.*\)/\\1/"`
+
+# Force vpx be installed from the backports
+VPX_V="1.0.0-2~bpo60+1"
+
+BINUTILS_V="2.22"
+BINUTILS_FV="2.22-7.1"
+
+GCC_V="4.7_4.7.1"
+GCC_FV="4.7_4.7.1-7"
+
+OPENAL_V="1.14"
+
+DPKG_V="1.16.8"
+
+DEBHELPER_V="9"
+DEBHELPER_FV="9.20120909"
+
+JEMALLOC_V="3.1.0"
+SPNAV_V="0.2.2"
+FFMPEG_V="1.0"
+BOOST_V="1_51_0"
+PYTHON_V="3.3.0"
+PYTHIN_V_SHORT="3.3"
+OIIO_V="1.0.9"
+OCIO_V="1.0.7"
+MESA_V="8.0.5"
+
+CUDA_V="4.2.9"
+CUDA_DISTR="ubuntu10.04"
+CUDA_32="cudatoolkit_${CUDA_V}_linux_32_${CUDA_DISTR}.run"
+CUDA_64="cudatoolkit_${CUDA_V}_linux_64_${CUDA_DISTR}.run"
+
+INSTALL_RELEASE_BUILDER() {
+  SOURCES_PATH=$1
+
+  RB=$SOURCES_PATH/release-builder
+  if [ ! -d $RB ]; then
+    INFO "Installing release building scripts"
+
+    mkdir -p $RB
+
+    cat << EOF > $RB/Readme.txt
+This directory contains scrips needed for automated release archive preparation
+
+config/: storage of scons configs for different platforms
+
+build_all.sh: script asks version to add to archive name and revision to compile,
+              when script finished, there'll be 32 and 64 bit archives in current directory
+              better to run this script from this directory
+
+do_build_all.sh: uses environment variables set by build_all.sh script (or other scripts)
+                 and launches compilation inside chroot environments
+
+chroot_compile.py: runs compilation process with giver parameters in chroots
+compile.py: script runs inside chroot environment and prepares archive
+
+blender-buildenv.tar.bz2: archive, received from Ken Hughes when i've been preparing
+                          new environment to make it as close to old one as it's possible
+
+Hope all this would help you.
+
+-Sergey-
+EOF
+  
+    cat << EOF > $RB/build_all.sh
+#!/bin/sh
+
+echo -n "version: "
+read version
+echo -n "svn revision (blank to latest, 0 to keep unchanged): "
+read revision
+
+export version
+export revision
+
+d=\`dirname \${0}\`
+\${d}/do_build_all.sh
+EOF
+    chmod +x $RB/build_all.sh
+
+    cat << EOF > $RB/build_all-test.sh
+#!/bin/sh
+
+d=\`dirname \${0}\`
+\${d}/do_build_all.sh
+EOF
+    chmod +x $RB/build_all-test.sh
+
+    cat << EOF > $RB/chroot-compile.py
+#!/usr/bin/env python
+
+import sys
+import os
+import platform
+
+from optparse import OptionParser
+
+# This could be passed through options, but does we actually need this?
+bl_source = '/home/sources/blender'
+build_dir = '/home/sources/blender-build/'
+install_dir = '/home/sources/blender-install/'
+with_player = True
+
+# Default config
+curr_arch = platform.architecture()[0]
+def_arch = 'x86_64' if curr_arch == '64bit' else 'i686'
+builder_dir = os.path.dirname(os.path.realpath(__file__))
+
+# XXX: bad thing!
+# builder_dir = builder_dir.replace("sources-new", "sources")
+
+def_cores = 1
+if hasattr(os, 'sysconf'):
+    if 'SC_NPROCESSORS_ONLN' in os.sysconf_names:
+        def_cores = os.sysconf('SC_NPROCESSORS_ONLN')
+
+# Per-architecture chroot name
+chroots = { 'i686': 'buildbot_squeeze_i686',
+            'x86_64': 'buildbot_squeeze_x86_64'}
+
+# Parse command line
+op = OptionParser()
+op.add_option('--tag', default = None)
+op.add_option('--branch', default = None)
+op.add_option('--arch', default = def_arch)
+op.add_option('--cores', default = def_cores)
+op.add_option('--bl-version', default = 'UNDEFINED')
+op.add_option('--no-clean', default = False)
+(opts, args) = op.parse_args()
+
+if opts.arch not in chroots:
+    print('Error: No configured machine gound to build ' + 
+          '{0} version' . format(opts.arch))
+    sys.exit(1)
+
+chroot = chroots[opts.arch]
+
+if opts.tag:
+    bl_source = '/home/sources/blender-tags/' + opts.tag
+elif opts.branch:
+    bl_source = '/home/sources/blender-branches/' + opts.branch
+
+if not os.path.isdir(bl_source):
+    print('Uname to find directory with sources: ' + bl_source)
+    sys.exit(1)
+
+print('Building {0} version, machine is {1}' . format(opts.bl_version, opts.arch))
+
+# Assume builder directory is binded to the same location in
+# chroot environments
+compiler = os.path.join(builder_dir, 'compile.py')
+
+cmd = 'schroot -c %s -d /home/sources/release-builder --' % (chroot)
+cmd += ' python %s' % (compiler)
+cmd += ' --bl-version=%s' % (opts.bl_version)
+cmd += ' --bl-source=%s' % (bl_source)
+cmd += ' --arch=%s' % (opts.arch)
+cmd += ' --build-dir=%s' % (build_dir)
+cmd += ' --install-dir=%s' % (install_dir)
+
+if opts.no_clean:
+    cmd += ' --no-clean=1'
+
+if with_player:
+    cmd += ' --with-player=1'
+
+#if opts.branch:
+#    cmd += ' --use-new-ffmpeg=1'
+
+result = os.system(cmd)
+if result != 0:
+    print('compiler script exited with errcode: %s' % (result))
+    sys.exit(1)
+EOF
+    chmod +x $RB/chroot-compile.py
+
+    cat << EOF > $RB/compile.py
+#!/usr/bin/env python
+
+import platform
+import sys
+import os
+import shutil
+
+from optparse import OptionParser
+
+# Default config
+curr_arch = platform.architecture()[0]
+def_arch = 'x86_64' if curr_arch == '64bit' else 'i686'
+builder_dir = os.path.dirname(os.path.realpath(__file__))
+
+def_cores = 1
+if hasattr(os, 'sysconf'):
+    if 'SC_NPROCESSORS_ONLN' in os.sysconf_names:
+        def_cores = os.sysconf('SC_NPROCESSORS_ONLN')
+
+# Parse command line
+op = OptionParser()
+op.add_option('--arch', default = def_arch)
+op.add_option('--cores', default = def_cores)
+op.add_option('--no-clean', default = False)
+op.add_option('--bl-version', default = 'UNKNOWN')
+op.add_option('--bl-source', default = '')
+op.add_option('--config-dir', default = '')
+op.add_option('--build-dir', default = '')
+op.add_option('--install-dir', default = '')
+op.add_option('--with-player', default = False)
+#op.add_option('--use-new-ffmpeg', default = False)
+(opts, args) = op.parse_args()
+
+if opts.config_dir == '':
+    opts.config_dir = os.path.join(builder_dir, 'config')
+
+# Initial directory checking (could be problems with permissions)
+if not os.path.isdir(opts.bl_source):
+    print('Blender\'s source tree not found: %s' % (opts.bl_source))
+    sys.exit(1)
+
+if not os.path.isdir(opts.config_dir):
+    print('Directory with configuration files not found: %s' % (opts.config_dir))
+    sys.exit(1)
+
+if not os.path.isdir(os.path.dirname(opts.build_dir)):
+    print('Build directory can\'t be reached: %s' % (opts.build_dir))
+    sys.exit(1)
+
+if not os.path.isdir(os.path.dirname(opts.install_dir)):
+    print('Install directory can\'t be reached: %s' % (opts.install_dir))
+    sys.exit(1)
+
+# Detect glibc version
+libc = [name for name in os.listdir('/lib') if 'libc.so.' in name]
+if len(libc) == 0:
+    print('Could not find "/lib/libc.so.*": cannot determine glibc version')
+    sys.exit(-1)
+
+if len(libc) > 1:
+    print('warning: found more than one "/lib/libc.so.*": '+
+          'using %s' % (libc[0]))
+
+glibc = 'glibc' + os.readlink('/lib/' + libc[0])[5:][:-3].replace('.', '')
+glibc = glibc[:8]
+
+# Full name for archive
+full_name = 'blender-%s-linux-%s-%s' % (opts.bl_version, glibc, opts.arch)
+build_dir = os.path.join(opts.build_dir, full_name)
+install_dir = os.path.join(opts.install_dir, full_name)
+scons = os.path.join(opts.bl_source, 'scons', 'scons.py')
+scons_cmd = 'python %s -C %s' % (scons, opts.bl_source)
+config = os.path.join(opts.config_dir, 'user-config-' + glibc + '-' + opts.arch + '.py')
+
+if not os.path.isfile(config):
+    print('Configuration file not found: %s' % (config))
+    sys.exit(1)
+
+# Clean build directory
+if not opts.no_clean:
+    print('Cleaning up build directory...')
+    os.system('%s BF_BUILDDIR=%s clean ' % (scons_cmd, build_dir))
+
+# Clean install directory
+if os.path.isdir(install_dir):
+    shutil.rmtree(install_dir)
+
+flags = ""
+
+# Switch to newer libraries if needed
+#if opts.use_new_ffmpeg:
+#    print("Using new ffmpeg-0.8.1")
+#    flags += " BF_FFMPEG='/home/sources/staticlibs/ffmpeg-0.8'"
+
+# Build blenderplayer first
+# (to be sure all stuff needed for blender would copied automatically)
+if opts.with_player:
+    player_config = os.path.join(opts.config_dir,
+        'user-config-player-' + glibc + '-' + opts.arch + '.py')
+
+    if not os.path.isfile(player_config):
+        print('Player configuration file not found: %s' % (player_config))
+        sys.exit(1)
+
+    cmd  = '%s -j %d blenderplayer ' % (scons_cmd, opts.cores + 1)
+    cmd += ' BF_BUILDDIR=%s' % (build_dir + '-player')
+    cmd += ' BF_INSTALLDIR=%s' % (install_dir)
+    cmd += ' BF_CONFIG=%s' % (player_config)
+    cmd += flags
+
+    result = os.system(cmd)
+    if result != 0:

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list