Using BuildBot can be useful to automate OpenXT builds.
Let's assume you're running a 32bits installation of Debian Squeeze, which is the recommended configuration for building OpenXT.
Installing BuildBot is as easy as "apt-get install buildbot". The Squeeze version is quite outdated, but it does the job.
BuildBot works in 2 parts, the slave(s) that build, and the master that control the slave(s).
In the following, I'm describing a setup with just one master and one slave, both on the same machine.
Disclaimer: everything here is done in a pretty dummy way, there's a lot of room for improvement.
Creating the master and the slave
The configuration happens in /var/lib/buildbot for the master/slave configuration, and in /etc/default/buildbot for the deamon configuration.
To get started, "cd /var/lib/buildbot" as root (or as buildbot, after enabling its shell), and create a master and a slave:
# buildbot create-master master
# cd master
# mv master.cfg.sample master.cfg
# cd ..
# buildbot create-slave slave 127.0.0.1:9989 slave password
# cd master
Configuring the master
master.cfg is the main BuildBot file. That's where you define projects, steps and schedulers. Here's some modifications I made to it:
- Renaming the "BuildSlave" from "bot1name" to "slave", and changing the password from "bot1passwd" to "password".
- Disable the scheduler by commenting out the
c['schedulers'].append
line(s). Fix the factory steps (the scripts are detailed in the "Creating the build scripts" section):
f1.addStep(Compile(command=["bash", "-e", "./fetch.sh"], name="Fetch", description="Fetch", descriptionDone="Fetched")) f1.addStep(Compile(command=["bash", "-e", "./clean.sh"], name="Clean", description="Clean", descriptionDone="Cleaned")) f1.addStep(Compile(command=["bash", "-e", "./build.sh"], name="Build", description="Build", descriptionDone="Built")) f1.addStep(Compile(command=["bash", "-e", "./copy.sh"], name="Copy", description="Copy", descriptionDone="Copied"))
In b1, the builder, fix the name ("openxt") the slavename ("slave"), and the builddir ("/home/buildbot")
- Set allowForce=true, as described in a comment
- Fix the project name and URL
Configuring the initscript
Below is the content of my /etc/default/buildbot
# buildbots to manage # add a new set of variables for each buildbot to start BB_NUMBER[0]=0 # index for the other values; negative disables the bot BB_NAME[0]="master" # short name printed on startup / stop BB_USER[0]="buildbot" # user to run as BB_BASEDIR[0]="/var/lib/buildbot/master" # basedir argument to buildbot (absolute path) BB_OPTIONS[0]="" # buildbot options BB_PREFIXCMD[0]="" # prefix command, i.e. nice, linux32, dchroot BB_NUMBER[1]=1 # index for the other values; negative disables the bot BB_NAME[1]="slave" # short name printed on startup / stop BB_USER[1]="buildbot" # user to run as BB_BASEDIR[1]="/var/lib/buildbot/slave" # basedir argument to buildbot (absolute path) BB_OPTIONS[1]="" # buildbot options BB_PREFIXCMD[1]="" # prefix command, i.e. nice, linux32, dchroot
Creating the build scripts
In /home/buildbot/build, I created the scripts corresponding to the steps added to the factory:
#!/bin/bash umask 0022 rm -rf build mkdir build
That removes the whole build tree and create an empty folder for the new build.
If the previous build finished, or at least lasted for a while, this step could take more than 60 minutes...
One way to speed this up which is left out here for clarity is to put the build on a filesystem on a block device which is unmounted, reformatted and mounted for each build.
#!/bin/bash for i in git/*.git; do echo "Fetching `basename $i`..." cd $i git fetch --all cd - > /dev/null done