From BlenderWiki

Jump to: navigation, search

Autopackage & Blender in Linux

This is a some tests making an autopackage for blender, with the steps to make your own.

if your interested in trying out the one Iv built, here it is. http://graphicall.org/builds/builds/showbuild.php?action=show&id=418

first of all, get the autopackage tools.

You'll only need the Autopackage Development Environment and APBuild. http://autopackage.org/download-tools.html


Here is the main spec file that manages building and generating the package. It needs to be saved in ./autopackage/default.apspec relative to the root of your blender source tree.

# -*- shell-script -*-
[Meta]
ShortName: Blender3D
SoftwareVersion: 2.44
DisplayName: Blender3D
RootName: @blender.org/blender:$SOFTWAREVERSION
Summary: Blender is an open source software 3D animation program.
Maintainer: ideasman42@gmail.com
Packager: ideasman42@gmail.com
PackageVersion: 1
CPUArchitectures: x86
AutopackageTarget: 1.2
Type: Application
License: GNU General Public License (GPL)
URL: blender.org
Compression: lzma # requires v1.2 of AutopackageTarget

[Description]
Blender is a 3D application with a robust feature set similar in scope and depth
to other high-end 3D software such as Softimage|XSI, Cinema 4D, 3ds Max and Maya.
These features include advanced simulation tools such as rigid body dynamics,
fluid dynamics, and softbody dynamics, modifier based modeling tools,
powerful character animation tools,
a node based material and compositing system and an embedded scripting engine based on Python.

[BuildPrepare]
# If you're using autotools, the default should be enough.
# prepareBuild will set up apbuild and run configure for you. If you
# need to pass arguments to configure, just add them to prepareBuild:
# prepareBuild --enable-foo --disable-bar

# prepareBuild assumes ./configure; make; make install
# use scons instead, disable most things to get maximum compatibility
export APBUILD_STATIC="png jpeg z python2.5"
export CFLAGS=-Os -pipe 

scons \
	CC=apgcc \
	CXX=apg++ \
	REL_CFLAGS="-Os" \
	REL_CFLAGS="-Os" \
	BF_INSTALLDIR=$build_root/build \
	BF_PYTHON_VERSION="2.5" \
	WITH_BF_OPENAL=false \
	WITH_BF_GAMEENGINE=false \
	WITH_BF_OPENEXR=false \
	WITH_FFMPEG=false \
	WITH_FREETYPE2=false \
	WITH_BF_INTERNATIONAL=false \
	WITH_BF_BULLET=false \
	WITH_BF_YAFRAY=false

# copy python scripts into our own defined PYTHONHOME
PYLIB_FROM=/usr/lib/python2.5
PYLIB_TO=$build_root/build/.blender/pymodules

# os
copyFiles $PYLIB_FROM/os.py			$PYLIB_TO/
 copyFiles $PYLIB_FROM/posixpath.py		$PYLIB_TO/
 copyFiles $PYLIB_FROM/posixfile.py		$PYLIB_TO/
 copyFiles $PYLIB_FROM/stat.py			$PYLIB_TO/
 copyFiles $PYLIB_FROM/UserDict.py		$PYLIB_TO/
 copyFiles $PYLIB_FROM/copy_reg.py		$PYLIB_TO/

copyFiles $PYLIB_FROM/random.py			$PYLIB_TO/
 copyFiles $PYLIB_FROM/warnings.py		$PYLIB_TO/
 copyFiles $PYLIB_FROM/linecache.py		$PYLIB_TO/

copyFiles $PYLIB_FROM/webbrowser.py		$PYLIB_TO/
 copyFiles $PYLIB_FROM/subprocess.py		$PYLIB_TO/
 copyFiles $PYLIB_FROM/shlex.py			$PYLIB_TO/
 copyFiles $PYLIB_FROM/traceback.py		$PYLIB_TO/

copyFiles $PYLIB_FROM/chunk.py			$PYLIB_TO/
copyFiles $PYLIB_FROM/struct.py			$PYLIB_TO/
copyFiles $PYLIB_FROM/types.py			$PYLIB_TO/
copyFiles $PYLIB_FROM/re.py			$PYLIB_TO/
copyFiles $PYLIB_FROM/sre.py			$PYLIB_TO/
copyFiles $PYLIB_FROM/sre_compile.py		$PYLIB_TO/
copyFiles $PYLIB_FROM/sre_parse.py		$PYLIB_TO/
copyFiles $PYLIB_FROM/sre_constants.py		$PYLIB_TO/
copyFiles $PYLIB_FROM/StringIO.py		$PYLIB_TO/


echo '<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
  <mime-type type="application/blender3d">
    <comment>Blender 3D file</comment>
    <magic priority="50">
      <match offset="0" type="string" value="BLENDER" />
    </magic>
    <glob pattern="*.blend*" />
  </mime-type>
</mime-info>' > $build_root/blend.xml


# copy icons, hicolor is a freedesktop standard location for icons.
copyFiles ./release/freedesktop/icons/16x16/blender.png $build_root/icons/hicolor/16x16/apps/
copyFiles ./release/freedesktop/icons/22x22/blender.png $build_root/icons/hicolor/22x22/apps/
copyFiles ./release/freedesktop/icons/32x32/blender.png $build_root/icons/hicolor/32x32/apps/
copyFiles ./release/freedesktop/icons/scalable/blender.svg $build_root/icons/hicolor/scalable/apps/

# Remove unneeded files
# Since I use blenders CVS repo for running scripts,
# there may be some files here.
rm $build_root/build/.blender/scripts/bpydata/config/*.cfg
rm $build_root/build/.blender/scripts/*.pyc
rm $build_root/build/.blender/scripts/bpymodules/*.pyc

# Warning, since we have international disabled, remove language files
# this should be removed before release
rm -rf $build_root/build/.blender/locale

[BuildUnprepare]
# If you're using prepareBuild above, there is no need to change this!
unprepareBuild

[Globals]

[Prepare]
# add some libs here SDL would be good

[Imports]
# This command will tell makeinstaller what to include in the package.
# The selection comes from the files created by 'make install' or equivalent.
# Usually, you can leave this at the default
echo '*' | import

[Install]
# See http://www.autopackage.org/api/ for details
# MYPREFIX="$HOME/.local/" # use instead of $PREFIX, so we are never installed globaly.
copyFiles build/* "$PREFIX/share/blender_dev"

# dot files dont copy??
copyFiles build/.blender/* "$PREFIX/share/blender_dev/.blender/"


# Make a shell script
# This script sets the HOME dir so we can have our own scripts.
# Keep this so you can launch from the command line with a system wide install
echo "#!/bin/sh
HOME=$PREFIX/share/blender_dev
PYTHONHOME=$PREFIX/share/blender_dev/pymodules
exec $PREFIX/share/blender_dev/blender
" > build/blender_dev # so we can use copyFile and track the change, create bin if its not there

copyFile build/blender_dev $PREFIX/bin/blender_dev
chmod +x $PREFIX/bin/blender_dev


# make a desktop file, this should be in blender alredy, HACK!
echo "[Desktop Entry]
Name=Blender3D dev
Comment=Blender is an open source software 3D animation program.
Encoding=UTF-8
Version=1.0
Type=Application
Categories=Graphics;3DGraphics;Art;
MimeType=application/blender3d			
Exec=env HOME='$PREFIX/share/blender_dev/' PYTHONHOME='$PREFIX/share/blender_dev/pymodules' '$PREFIX/share/blender_dev/blender' %F
TryExec='$PREFIX/share/blender_dev/blender'
Terminal=true
StartupNotify=true
Icon=blender.svg" > build/blender_dev.desktop

copyFile build/blender_dev.desktop $HOME/Desktop/blender_dev.desktop

installIcon icons/*
installMenuItem "Graphics" build/blender_dev.desktop
installMime blend.xml

[Uninstall]
# Leaving this at the default is safe unless you use custom commands in
# "Install" to create files. By default, all autopackage API functions are
# logged.
uninstallFromLog

in your blender root (where youd normaly run make or scons) run

makeinstaller

This will run scons with some alternative options.

if all goes well youll end up with a file "Blender3D-2.44.x86.package" in the same directory. you should be able to run this on another system with minimal chance of linking errors etc.

you can do a

chmod +x Blender3D\ 2.44.package
./Blender3D\ 2.44.package

or once you have autopackage

package install Blender3D\ 2.44.package

to install the package.

I want this to be able to coexist with an existing install of blender, so Iv made it install to """~/.local/share/blender_dev/""" and the binary is accessed from """~/.local/bin/blender_dev"""

This can be changed to suit out needs.

Static Linking

Python

Python needs to be built so libpython.a is created.

extract Python-2.5.1.tar.bz2

run

./configure --enable-shared

edit ./Modules/Setup

uncomment "#*shared*" around line 152 and rename to "*static*" The following modules are built into libpython2.5.a

uncomment: array, math, time, operator, itertools, cStringIO, cPickle, zlib, _struct, _weakref, _random, binascii, collections, fcntl, spwd, grp, select


Example:

#array arraymodule.c	# array objects

to

array arraymodule.c	# array objects

python in blender will be able to import these modules without python being on the system.

run

make
make install

Note make CC=apgcc CXX=apg++ does not work, gives errors linking at the end of the build.


Now there will be a libpython2.5.a in ./ that you can copy to /usr/lib

Known Problems (Autopackage)

1) The GUI installer dosnt work in ubuntu feisty + autopackage 1.22 (it does on my PC which is slackware), The gui loads but before installing it hangs with a progress bar moving from side to side. - With debug enabled, I see an error "Cannot open Display" - as if X is not open, is this a known problem? (installing via command line works)