Simple way to synchronize a MakeHuman/Blender installation

Less technically astute people following the latest updates from MakeHuman/Blender are probably finding it a chore to keep everything synchronized. The basic steps are:

  • Update MakeHuman nightly

  • Update Blender-SVN

  • Install the new add-ons from MakeHuman into Blender

  • Copy the “make_cothes.py” script into their scripts folder

  • etc etc

Gurus have long been aware that there is a simple way of doing this using so called batch files, (.bat extension.) Essentially this is a list of text based instructions to the operating system that automate a given task and allow it be launched either manually with a single click or automatically at pre-determined time each day.

I use Linux, where a batch file is called a “shell” or a “bash”, but the principles are the same. In my example the “bash” operates exactly as indicated above and is split into easily identifiable individual sections that can be copied or modified to suit individual tastes.

The basics:

I am using SVN versions for both MakeHuman and Blender installed in my home folder. The reasons for this are:

  • It is faster

  • Any updates are immediately available

  • It is easier to automate

  • It uses significantly less bandwidth

  • It is technically more secure

  • If installed in the users home directory, the MakeHuman-SVN can co-exist with the stable alpha release. This is not possible with MakeHuman-nightly

The Blender-SVN documentation is simple, easy to follow and can be found here. I found Cmake to be the easiest to use, (remember to install Python 3.2)

The MakeHuman-SVN documentation is less sophisticated, (though the installation is very, very easy, simply navigate to the downloaded SVN folder using either the terminal or command prompt and type: scons [return]) The documentation can be found here and here. For the initial download use: “svn co http://makehuman.googlecode.com/svn/trunk/ makehuman-read-only” in the terminal.

Once you have working SVN installations, it is just a case of copying the following bash into a text editor, saving and changing the saved file permissions to allow execution as program. At that point, execute the bash and a minute later, you have the most up-to-date MakeHuman/Blender installation possible with all the latest MHX add-ons pre-installed into Blender and ready for use.

If there is an interest, I will see about translating the bash for Windows users.


#!/bin/bash

# This bash updates both the MakeHuman-SVN and Blender-SVN installations
# it also updates into Blender the add-ons supplied with MakeHuman

##########################
# Update the MakeHuman-SVN
##########################
# see http://makehuman.blogspot.com/2010/08/update-your-nightly-build-smart-way.html
# see http://sites.google.com/site/makehumandocs/developers-guide

echo "changing to MakeHuman directory"

cd ~/makehuman-svn/makehuman
echo "Updating MakeHuman-SVN"

svn update

echo "MakeHuman_SVN update done"

# The "update-linux32.sh" script supplied by MakeHuman
# uses line below to copy the binary into the main folder

# cp -f ./bin/linux/32bit/* ./

# However you can also recompile from scratch using

echo "running scons"

scons

echo "scons done"

# End Update the MakeHuman-SVN



#####################
# Update Blender-SVN
# http://wiki.blender.org/index.php/Dev:2.5/Doc/Building_Blender/Linux/Ubuntu/CMake
# http://wiki.blender.org/index.php/Dev:2.5/Doc/Building_Blender/Linux/Ubuntu/Scons 
# I originally installed Blender-SVN using Cmake, if 'Scons' was used, then replace as indicated
####################

echo "starting Blender-SVN update"

cd ~/blender-svn/build          # for scons use:  cd ~/blender-svn/blender
svn up ../blender

echo "Blender-SVN update done"

echo "Starting Blender-SVN 'make'"

make -j2                        # for scons use:  python scons/scons.py

echo "Blender-SVN update done, starting 'make install'"

make install                    # for scons skip this line

echo "done 'make install'"


# End Update Blender-SVN


##################################################
# Update into Blender the add-ons supplied by MakeHuman
##################################################


# if the directory "latest-blender-import-scripts" does
# not exist, we need to create it
echo "checking directory 'latest-blender-import-scripts' exists"
cd ~/makehuman
mkdir -p latest-blender-import-scripts

#  we dont want the make_clothes script to end up in Blender add-ons
#  it is not strictly an add-on, but a script run from the text editor
echo "deleting old make_clothes.py"
cd ~/makehuman/latest-blender-import-scripts
rm -f make_clothes.py


#  Update the importers into users makehuman folder this is so 
#  that we can easily see what utils are currently available
echo "updating MHX importers into 'latest-blender-import-scripts' directory"
cd ~/makehuman-svn/makehuman/importers/mhx/blender25x
cp -f *.* ~/makehuman/latest-blender-import-scripts


#  Update all scripts into the Blender add-ons folder.
echo "updating MHX add-ons into the Blender"
cd ~/makehuman/latest-blender-import-scripts
cp -f *.* ~/blender-svn/build/bin/2.56/scripts/addons


#  Restore the updated  make_clothes util into users makehuman folder 
echo "updating 'make_clothes.py' into the 'latest-blender-import-scripts' directory"
cd ~/makehuman-svn/makehuman/utils/mhx
cp -f make_clothes.py ~/makehuman/latest-blender-import-scripts

# End Update the Blender add-ons supplied by MakeHuman

##########
# End bash
##########


Notes:

  1. Blender-SVN is installed in a folder called Blender-SVN in the users home directory

  2. MakeHuman-read-only is downloaded into the users home directory and then renamed MakeHuman-SVN (pedantic I know)

  3. If there is not a pre-existing MakeHuman installation then, in addition to the MakeHuman-SVN folder, you need to create a folder called MakeHuman in the users home directory. It is normally created when you first run MakeHuman and is used to store saved meshes, exports and renders. My bash creates a folder in this directory called “latest-blender-import-scripts” its purpose is to list all the MHX add-ons, (along with any other scripts such as make_clothes.py,) in one place so that I can easily see if there are any new add-ons and at the same time allow me easy access to the “make_clothes” script.

I hope people find this useful and that I am not thought to be over-presumptuous in submitting it.

If you are using Blender-SVN, then you have probably noticed that the “user preferences” are lost when SVN version is updated. This is because, unlike the normal releases, the “config” directory is a sub directory of the build directory.

The way to save your preferences is to add two short short sections to the above bash to save the preferences in a temporary cache in the Blender-SVN directory and then restore them after the update.

So, the very first section of the above bash should now be

#########################################
# Backing up the blender user preferences
#########################################

echo "checking for temporary blender 'user-preference' cache"

cd ~/blender-svn/
mkdir -p temp-preference-cache
cd ~/blender-svn/temp-preference-cache
 
echo "cleaning temporary blender 'user preference' cache"

rm -f startup.blend 
rm -f recent-files.txt 
rm -f bookmarks.txt 

echo "backing up blender 'user-preference' cache"

cd ~/blender-svn/build/bin/2.56/config
cp -f startup.blend ~/blender-svn/temp-preference-cache
cp -f recent-files.txt ~/blender-svn/temp-preference-cache
cp -f bookmarks.txt ~/blender-svn/temp-preference-cache 

echo "done backing up blender 'user-preference' cache"

# End Backing up the blender user preferences

This should come before the section updating Blender-SVN

To restore the user preferences, the following section should be added to the very end of my original bash

##############################
# Restore the user preferences
##############################
 
echo "restoring user preference cache"

cd ~/blender-svn/temp-preference-cache
cp -f startup.blend ~/blender-svn/build/bin/2.56/config
cp -f recent-files.txt ~/blender-svn/build/bin/2.56/config
cp -f bookmarks.txt ~/blender-svn/build/bin/2.56/config

echo "done restoring user preference cache"

# End restoring the user preferences

Note: if, like me, you like to test scripts before setting up a final version and you have no pre-existing preferences, bookmarks or recent-files, then you may notice an error message in the terminal. It is nothing and can be safely ignored, it just means that you have not saved any preferences. The “-f” option prevents, (among other things,) the script from crashing when it cannot find a particular file.