Developing Linux applications has a few pains. One pain is the the variety of Linux distributions: there are many popular distributions which release new versions frequently. That requires a lot of testing and packaging effort. Though I prefer Linux overall, Microsoft Windows is attractive because Windows desktop application development is focused on one "distribution" (Windows desktop series) which releases new versions infrequently (a joy for testing!), so today that means only two environments: XP and Vista. The second pain is each distribution has its own particular packaging requirements. For the last BleachBit release, I single-handedly produced 18 installation packages for seven Linux distributions. This volume could not be accomplished without special tools and automation.
To develop, test, and package BleachBit, I run nine virtual machines in Sun Microsystem's VirtualBox. Though a long-time Fedora user, I quickly realized most BleachBit users (roughly 90%) use Ubuntu, so now six of my VMs run Ubuntu 6.06 through 9.04. I also build many packages using Novell's openSUSE Build Service (OBS): it builds .rpm and .deb files for CentOS, Debian, Fedora, Mandriva, openSUSE, Red Hat, and Ubuntu. Regrettably the Ubuntu 8.10 build always fails on OBS—either because of a bug in OBS or maybe because of my own fault—so I build Ubuntu 8.10 locally.
Furthermore, I often restore the virtual machines to a pristine state (using VirtualBox snapshots) which destroys build environment, so I developed the following scripts which accelerate restoration of the build environment.
First, I install sshfs (which makes it easy to run the build scripts stored on my physical machine):
sudo apt-get install sshfs
Then, I mount my VM sharing directory (which contains build scripts and the BleachBit source code):
mkdir ~/tmp
sshfs andrew@10.0.2.2:/home/andrew/tmp ~/tmp
Then, I run a script from ~/tmp which installs the build software dependencies:
# necessary
apt-get install build-essential dh-make debhelper devscripts fakeroot
# nice to have
apt-get install mc vim-full
Finally, I run the following script which extracts the BleachBit source tarball, creates the build environment, sets up some compatibility between openSUSE Build Service and Ubuntu, and builds the package.
#!/bin/bash
# Handle fatal errors.
function fail {
echo $1
notify-send -u critical $1
exit 1
}
# Check which version of Ubuntu is running.
RELEASE=`grep DISTRIB_RELEASE /etc/lsb-release | cut -b17-`
echo "Detected version distribution version $RELEASE"
mkdir ~/bleachbit
cd ~/bleachbit
# Extract the source code tarball.
tar xjvf ~/tmp/vm/bleachbit*.tar.bz2 || fail "tar failed"
cd ~/bleachbit/bleachbit-?.?.? || fail "'cd' failed"
# Create .deb packaging directory.
mkdir debian
cd debian
# Copy .deb packaging files.
cp ~/tmp/vm/debian/* .
# Create links because openSUSE Build Service and dpkg like different names.
ln -s debian.control control
ln -s debian.rules rules
ln -s debian.changelog changelog
cd ~/bleachbit/bleachbit-?.?.?
# Ubuntu 6.06 doesn't have Python central, so remove it.
if [[ "x$RELEASE" == "x6.06" ]];
then
echo "Applying Ubuntu 6.06 changes"
cd debian
sed -i -e 's/, python-central//g' control
sed -i -e 's/, python-central//g' bleachbit.dsc
sed -i -e 's/dh_pycentral//g' rules
cd ..
fi
# Build.
debuild
# Check build.
cd ~/bleachbit
[[ ! -e *deb ]] || fail "no .deb files"
# Lintian performs checks against a database of packaging rules.
lintian *deb
That save a lot of time, and I am glad to be developing for Linux!