[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52155] trunk/blender/build_files: Initial implementation of a script for automatic dependencies installer/ builder

Sergey Sharybin sergey.vfx at gmail.com
Mon Nov 12 20:39:09 CET 2012


Revision: 52155
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52155
Author:   nazgul
Date:     2012-11-12 19:39:09 +0000 (Mon, 12 Nov 2012)
Log Message:
-----------
Initial implementation of a script for automatic dependencies installer/builder

This script will install all packages from the repositories and will compile
missing in repositories libraries.

It is supposed to replace pre-compiled libraries from our svn.

Tested script on Fedora 14 and 17, Ubuntu 10.04 and 12.10. All the dependencies
and manually built libraries seems to be fine. However, it's really annoying to
build blender in virtual machine to ensure there's no linking errors, i would
hope community will help testing and making needed tweaks to the script :)

To use the script, simple run it from your user name. It'll run installation
commands from a sudo, so you would likely be requested to type a password.

I've made tweaks to CMake FindLibs, so it should find OIIO, OCIO and python
libraries compiled by this script. Boost and FFmpeg would need to be specified
manually.

SCons currently would require manual paths specifications as well. Perhaps we
could make SCons smarter in the future.

All the parameters you need to pass to CMake/SCons would be printed when script
finishes to run.

Pretty much sure it's not production-ready script, but we need to start testing
at some point :)

Modified Paths:
--------------
    trunk/blender/build_files/cmake/Modules/FindOpenColorIO.cmake
    trunk/blender/build_files/cmake/Modules/FindOpenImageIO.cmake
    trunk/blender/build_files/cmake/Modules/FindPythonLibsUnix.cmake

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

Added: trunk/blender/build_files/build_environment/install_deps.sh
===================================================================
--- trunk/blender/build_files/build_environment/install_deps.sh	                        (rev 0)
+++ trunk/blender/build_files/build_environment/install_deps.sh	2012-11-12 19:39:09 UTC (rev 52155)
@@ -0,0 +1,500 @@
+#!/bin/bash
+
+DISTRO=""
+SRC="$HOME/src/blender-deps"
+CWD=$PWD
+
+THREADS=`cat /proc/cpuinfo | grep cores | uniq | sed -e "s/.*: *\(.*\)/\\1/"`
+
+PYTHON_VERSION="3.3.0"
+BOOST_VERSION="1_51_0"
+OIIO_VERSION="1.1.0"
+OCIO_VERSION="1.0.7"
+FFMPEG_VERSION="1.0"
+
+HASXVID=false
+HASVPX=false
+HASMP3LAME=false
+HASX264=false
+
+YUM="yum"
+
+ERROR() {
+  echo "${@}"
+}
+
+INFO() {
+  echo "${@}"
+}
+
+detect_distro() {
+  if [ -f /etc/debian_version ]; then
+    DISTRO="DEB"
+  elif [ -f /etc/redhat-release ]; then
+    if which yum > /dev/null 2>&1; then
+      DISTRO="RPM"
+      YUM="yum"
+    elif which zypper > /dev/null 2>&1; then
+      DISTRO="RPM"
+      YUM="zypper"
+    fi
+  fi
+}
+
+prepare_opt() {
+  INFO "Ensuring /opt/lib exists and vritabele by us"
+  sudo mkdir -p /opt/lib
+  sudo chown $USER /opt/lib
+  sudo chmod 775 /opt/lib
+}
+
+compile_Python() {
+  if [ ! -d /opt/lib/python-$PYTHON_VERSION ]; then
+    INFO "Building Python-$PYTHON_VERSION"
+
+    prepare_opt
+
+    if [ ! -d $SRC/Python-$PYTHON_VERSION ]; then
+      mkdir -p $SRC
+      wget -c http://python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.bz2 -P $SRC
+
+      INFO "Unpacking Python-$PYTHON_VERSION"
+      tar -C $SRC -xf $SRC/Python-$PYTHON_VERSION.tar.bz2
+    fi
+
+    cd $SRC/Python-$PYTHON_VERSION
+
+    ./configure --prefix=/opt/lib/python-$PYTHON_VERSION --enable-ipv6 \
+        --enable-loadable-sqlite-extensions --with-dbmliborder=bdb \
+        --with-computed-gotos --with-pymalloc
+
+    make -j$THREADS
+    make install
+    make clean
+
+    rm -f /opt/lib/python-3.3
+    ln -s python-$PYTHON_VERSION /opt/lib/python-3.3
+
+    cd $CWD
+  fi
+}
+
+compile_Boost() {
+  INFO "Building boost"
+
+  version_dots=`echo "$BOOST_VERSION" | sed -r 's/_/./g'`
+
+  if [ ! -d /opt/lib/boost-$version_dots ]; then
+    INFO "Building Boost-$version_dots"
+
+    prepare_opt
+
+    if [ ! -d $SRC/boost_$BOOST_VERSION ]; then
+      INFO "Downloading Boost-$version_dots"
+      mkdir -p $SRC
+      wget -c http://sourceforge.net/projects/boost/files/boost/$version_dots/boost_$BOOST_VERSION.tar.bz2/download \
+        -O $SRC/boost_$BOOST_VERSION.tar.bz2
+      tar -C $SRC -xf $SRC/boost_$BOOST_VERSION.tar.bz2
+    fi
+
+    cd $SRC/boost_$BOOST_VERSION
+    ./bootstrap.sh
+    ./b2 install --prefix=/opt/lib/boost-$version_dots
+    ./b2 --clean
+
+    rm -f /opt/lib/boost
+    ln -s boost-$BOOST_VERSION /opt/lib/boost
+
+    cd $CWD
+  fi
+}
+
+compile_OCIO() {
+  if [ ! -d /opt/lib/ocio-$OCIO_VERSION ]; then
+    INFO "Building OpenColorIO-$OCIO_VERSION"
+
+    prepare_opt
+
+    if [ ! -d $SRC/OpenColorIO-$OCIO_VERSION ]; then
+        INFO "Downloading OpenColorIO-$OCIO_VERSION"
+        mkdir -p $SRC
+        wget -c http://github.com/imageworks/OpenColorIO/tarball/v$OCIO_VERSION \
+          -O $SRC/OpenColorIO-$OCIO_VERSION.tar.gz
+
+        INFO "Unpacking OpenColorIO-$OCIO_VERSION"
+        tar -C "$SRC" -xf $SRC/OpenColorIO-$OCIO_VERSION.tar.gz
+        mv $SRC/imageworks-OpenColorIO* $SRC/OpenColorIO-$OCIO_VERSION
+    fi
+
+    cd $SRC/OpenColorIO-$OCIO_VERSION
+    mkdir build
+    cd build
+
+    if file /bin/cp | grep -q '32-bit'; then
+      cflags="-fPIC -m32 -march=i686"
+    else
+      cflags="-fPIC"
+    fi
+
+    cmake -D CMAKE_BUILD_TYPE=Release \
+        -D CMAKE_PREFIX_PATH=/opt/lib/ocio-$OCIO_VERSION \
+        -D CMAKE_INSTALL_PREFIX=/opt/lib/ocio-$OCIO_VERSION \
+        -D CMAKE_CXX_FLAGS="$cflags" \
+        -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \
+        ..
+
+    make -j$THREADS
+    make install
+
+    # Force linking against sttaic libs
+    rm -f /opt/lib/ocio-$OCIO_VERSION/lib/*.so*
+
+    # Additional depencencies
+    cp ext/dist/lib/libtinyxml.a /opt/lib/ocio-$OCIO_VERSION/lib
+    cp ext/dist/lib/libyaml-cpp.a /opt/lib/ocio-$OCIO_VERSION/lib
+
+    make clean
+
+    rm -f /opt/lib/ocio
+    ln -s ocio-$OCIO_VERSION /opt/lib/ocio
+
+    cd $CWD
+  fi
+}
+
+compile_OIIO() {
+  if [ ! -d /opt/lib/oiio-$OIIO_VERSION ]; then
+    INFO "Building OpenImageIO-$OIIO_VERSION"
+
+    prepare_opt
+
+    if [ ! -d $SRC/OpenImageIO-$OIIO_VERSION ]; then
+      wget -c https://github.com/OpenImageIO/oiio/tarball/Release-$OIIO_VERSION \
+          -O "$SRC/OpenImageIO-$OIIO_VERSION.tar.gz"
+
+      INFO "Unpacking OpenImageIO-$OIIO_VERSION"
+      tar -C $SRC -xf $SRC/OpenImageIO-$OIIO_VERSION.tar.gz
+      mv $SRC/OpenImageIO-oiio* $SRC/OpenImageIO-$OIIO_VERSION
+    fi
+
+    cd $SRC/OpenImageIO-$OIIO_VERSION
+    mkdir build
+    cd build
+
+    if [ -d /opt/lib/boost ]; then
+      boost_root="/opt/lib/boost"
+    else
+      boost_root="/usr"
+    fi
+
+    if file /bin/cp | grep -q '32-bit'; then
+      cflags="-fPIC -m32 -march=i686"
+    else
+      cflags="-fPIC"
+    fi
+
+    cmake -D CMAKE_BUILD_TYPE=Release \
+        -D CMAKE_PREFIX_PATH=/opt/lib/oiio-$OIIO_VERSION \
+        -D CMAKE_INSTALL_PREFIX=/opt/lib/oiio-$OIIO_VERSION \
+        -D BUILDSTATIC=ON \
+        -D CMAKE_CXX_FLAGS="$cflags" \
+        -D CMAKE_EXE_LINKER_FLAGS="-lgcc_s -lgcc" \
+        -D BOOST_ROOT="$boost_root" \
+        ../src
+
+    make -j$THREADS
+    make install
+    make clean
+
+    rm -f /opt/lib/oiio
+    ln -s oiio-$OIIO_VERSION /opt/lib/oiio
+
+    cd $CWD
+  fi
+}
+
+compile_FFmpeg() {
+  if [ ! -d /opt/lib/ffmpeg-$FFMPEG_VERSION ]; then
+    INFO "Building FFmpeg-$FFMPEG_VERSION"
+
+    prepare_opt
+
+    if [ ! -d $SRC/ffmpeg-$FFMPEG_VERSION ]; then
+      INFO "Downloading FFmpeg-$FFMPEG_VERSION"
+      wget -c http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 -P $SRC
+
+      INFO "Unpacking FFmpeg-$FFMPEG_VERSION"
+      tar -C $SRC -xf $SRC/ffmpeg-$FFMPEG_VERSION.tar.bz2
+    fi
+
+    cd $SRC/ffmpeg-$FFMPEG_VERSION
+
+    extra=""
+
+    if $HASXVID; then
+      extra="$extra --enable-libxvid"
+    fi
+
+    if $HASVPX; then
+      extra="$extra --enable-libvpx"
+    fi
+
+    if $HASMP3LAME; then
+      extra="$extra --enable-libmp3lame"
+    fi
+
+    if $HASX264; then
+      extra="$extra --enable-libx264"
+    fi
+
+    ./configure --cc="gcc -Wl,--as-needed" --extra-ldflags="-pthread -static-libgcc" \
+        --prefix=/opt/lib/ffmpeg-$FFMPEG_VERSION --enable-static --enable-avfilter --disable-vdpau \
+        --disable-bzlib --disable-libgsm --enable-libschroedinger --disable-libspeex --enable-libtheora \
+        --enable-libvorbis --enable-pthreads --enable-zlib --enable-stripping --enable-runtime-cpudetect \
+        --disable-vaapi --enable-libopenjpeg --disable-libfaac --disable-nonfree --enable-gpl \
+        --disable-postproc --disable-x11grab  --disable-librtmp  --disable-libopencore-amrnb \
+        --disable-libopencore-amrwb --disable-libdc1394 --disable-version3  --disable-outdev=sdl \
+        --disable-outdev=alsa --disable-indev=sdl --disable-indev=alsa --disable-indev=jack \
+        --disable-indev=lavfi $extra
+
+    make -j$THERADS
+    make install
+    make clean
+
+    rm -f /opt/lib/ffmpeg
+    ln -s ffmpeg-$FFMPEG_VERSION /opt/lib/ffmpeg
+
+    cd $CWD
+  fi
+}
+
+deb_version() {
+    dpkg-query -W -f '${Version}' $1 | sed -r 's/^([0-9]\.[0-9]+).*/\1/'
+}
+
+check_package_DEB() {
+  r=`apt-cache policy $1 | grep -c 'Candidate:'`
+
+  if [ $r -ge 1 ]; then
+    return 0
+  else
+    return 1
+  fi
+}
+
+install_DEB() {
+  INFO "Installing dependencies for DEB-based distributive"
+
+  sudo apt-get update
+  sudo apt-get -y upgrade
+
+  sudo apt-get install -y cmake scons gcc g++ libjpeg-dev libpng-dev libtiff-dev \
+    libfreetype6-dev libx11-dev libxi-dev wget libsqlite3-dev libbz2-dev libncurses5-dev \
+    libssl-dev liblzma-dev libreadline-dev libopenjpeg-dev libopenexr-dev libopenal-dev \
+    libglew-dev yasm libschroedinger-dev libtheora-dev libvorbis-dev libsdl1.2-dev \
+    libfftw3-dev libjack-dev python-dev patch
+
+  check_package_DEB libxvidcore4-dev
+  if [ $? -eq 0 ]; then
+    sudo apt-get install -y libxvidcore4-dev
+    HASXVID=true
+  fi
+
+  check_package_DEB libmp3lame-dev
+  if [ $? -eq 0 ]; then
+    sudo apt-get install -y libmp3lame-dev
+    HASMP3LAME=true
+  fi
+
+  check_package_DEB libx264-dev
+  if [ $? -eq 0 ]; then
+    sudo apt-get install -y libx264-dev
+    HASX264=true
+  fi
+
+  check_package_DEB libvpx-dev
+  if [ $? -eq 0 ]; then
+    sudo apt-get install -y libvpx-dev
+    vpx_version=`deb_version libvpx-dev`
+    if [ ! -z "$vpx_version" ]; then
+      if  dpkg --compare-versions $vpx_version gt 0.9.7; then
+        HASVPX=true
+      fi
+    fi
+  fi
+
+  check_package_DEB libspnav-dev
+  if [ $? -eq 0 ]; then
+    sudo apt-get install -y libspnav-dev
+  fi
+
+  check_package_DEB python3.3-dev
+  if [ $? -eq 0 ]; then
+    sudo apt-get install -y python3.3-dev
+  else
+    compile_Python
+  fi
+
+  check_package_DEB libboost-dev
+  if [ $? -eq 0 ]; then
+    sudo apt-get install -y libboost-dev
+
+    boost_version=`deb_version libboost-dev`
+
+    check_package_DEB libboost-locale$boost_version-dev
+    if [ $? -eq 0 ]; then
+      sudo apt-get install -y libboost-locale$boost_version-dev libboost-filesystem$boost_version-dev \
+        libboost-regex$boost_version-dev libboost-system$boost_version-dev libboost-thread$boost_version-dev
+    else
+      compile_Boost
+    fi
+  else
+    compile_Boost
+  fi
+
+  check_package_DEB libopencolorio-dev
+  if [ $? -eq 0 ]; then
+    sudo apt-get install -y libopencolorio-dev
+  else
+    compile_OCIO
+  fi
+
+  check_package_DEB libopenimageio-dev
+  if [ $? -eq 0 ]; then
+    sudo apt-get install -y libopenimageio-dev
+  else
+    compile_OIIO
+  fi
+
+  check_package_DEB ffmpeg
+  if [ $? -eq 0 ]; then
+    sudo apt-get install -y ffmpeg
+    ffmpeg_version=`deb_version ffmpeg`
+    if [ ! -z "$ffmpeg_version" ]; then
+      if  dpkg --compare-versions $ffmpeg_version gt 0.7.2; then
+        sudo apt-get install -y libavfilter-dev libavcodec-dev libavdevice-dev libavformat-dev libavutil-dev libswscale-dev
+      else
+        compile_FFmpeg
+      fi
+    fi
+  fi
+}
+
+check_package_RPM() {
+  r=`$YUM info $1 | grep -c 'Summary'`
+
+  if [ $r -ge 1 ]; then
+    return 0
+  else
+    return 1
+  fi
+}
+
+check_package_version_RPM() {
+  v=`yum info $1 | grep Version | tail -n 1 | sed -r 's/.*:\s+(([0-9]+\.?)+)/\1/'`
+

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list