At $WORK I need to package stuff up. Most of the time, I've worked with RPMs. Those are easy; it took, I dunno, an hour? to come up with my first spec file, and it's been pretty simple after that -- even with oddball software that uses "make configure" to mean "make build" and "make" to actually install it. But deb files...man, these are hard. There is a lot more policy built into making a deb file than there ever was in an RPM, and you overlook/override/ignore it at your peril. I want to do the right thing -- which means, since I'm stubborn and have thought idly about becoming a Debian developer someday, I bang my head against the deb files until it works. Except, that as Jordan Sissel has so rightly pointed out, sometimes I just don't have time.
So Jordan Sissel, being Jordan Sissel, has put together fpm, the Effing Package Management. And it's awesome: take your source files, point fpm at them, and you get rpms AND debs. But I want more: the pbuilder system is truly awesome in its you're-gonna-compile-on-an-empty-chroot-or-you're-borked brutish stubbornness, and I want that for fpm. So I'm using vagrant for this. My approach is not as nice as debuild or pbuilder, but it is so far working for me.
It's actually pretty trivial; I'm mainly putting it up here so that I remember it. Hopefully it's useful to someone else, too.
The heart is a dirt-simple shell script; here's what I've got for vmd:
#!/bin/bash
# Bail on error; want this to be as hands-off as possible
set -e
# Add build-essential
sudo apt-get update
sudo apt-get install -y build-essential
# Install fpm. FIXME: That check is borken; not sure about using vagrant_ruby to install it.
which fpm || sudo /opt/vagrant_ruby/bin/gem install fpm
# Where to look for stuff
ORIGIN=/vagrant
INSTALLROOT=/opt
BUILDDIR=/tmp/vmd
TARBALL=vmd-1.9.1.bin.LINUXAMD64.opengl.tar.gz
BUILDDEPS=
# FIXME: gotta put in all the "--depends" by hand.
DEPS="--depends libgl1-mesa-dev --depends libglu1-mesa --depends libxinerama1 --depends libxi6"
[ -d $BUILDDIR ] || mkdir $BUILDDIR
cd $BUILDDIR
tar xvzf ${ORIGIN}/$TARBALL
cd vmd-1.9.1
export VMDINSTALLBINDIR=${INSTALLROOT}/bin
export VMDINSTALLLIBRARYDIR=${INSTALLROOT}/vmd
./configure
sudo make -C src install
# And here's the fpm magic. FIXME: Note the stupid assumptions about opt.
/opt/vagrant_ruby/bin/fpm -s dir -t deb -n vmd -v 1.9.1 -f $DEPS -p ${ORIGIN}/vmd-VERSION_ARCH.deb -x opt/vagrant_ruby -x opt/VBoxGuestAdditions* -C / opt
Drop this in a directory along with the vmd tarball:
-rwxr-xr-x 1 hugh hugh 1153 Sep 12 14:40 build_vmd.sh
-rw-r--r-- 1 hugh hugh 22916955 Sep 12 10:05 vmd-1.9.1.bin.LINUXAMD64.opengl.tar.gz
Vagrant up, then build:
$ vagrant init precise64 # That's Ubuntu 12.04, yo.
$ vagrant up
$ vagrant ssh -- /vagrant/build_vmd.sh
If all goes well, you now have a deb in that directory:
$ ls -l *deb
-rw-rw-r-- 1 hugh hugh 22396738 Sep 12 14:41 vmd-1.9.1_amd64.deb
Like I say, it's dirt-simple -- but it does make stuff a lot easier. Thanks, Mitchell and Jordan!
While setting up mini-dinstall today, I tripped over this error:
$ mini-dinstall -b
Traceback (most recent call last):
File "/usr/bin/mini-dinstall", line 205, in <module>
configp.read(configfile_names)
File "/usr/lib/python2.7/ConfigParser.py", line 305, in read
self._read(fp, filename)
File "/usr/lib/python2.7/ConfigParser.py", line 546, in _read
raise e
ConfigParser.ParsingError: File contains parsing errors: /home/hugh/.mini-dinstall.conf
[line 2]: ' mail_to = sysadmin@example.com\n'
[line 3]: ' incoming_permissions = 0755\n'
[line 4]: ' architectures = all, amd64\n'
[line 5]: ' archive_style = simple-subdir\n'
[line 6]: ' dynamic_reindex = 1\n'
[line 7]: ' archivedir = /home/hugh/public_html/debian/\n'
Eventually, I figured out the reason: leading spaces in each line. I'd assumed I could write the config file like so:
[section]
# Notice the indentation!
key = value
otherkey = othervalue
but that's incorrect; it needs to be like so:
[section]
# Indentation is for suckers and chumps. Apparently.
key = value
otherkey = othervalue
Hopefully that saves someone half an hour...
Yesterday I finally moved the monitoring machine at work from SuSE 9.1
to Debian Etch. It still amazes me how easy Debian makes it to install
things like Nagios, Apache 2 and RT (!). I hadn't paid attention
before to the way Debian handles loading websites and modules in
Apache, and that's just elegant…the same mess o' symlinks that you use
for /etc/rc?.d
. Nice.
Of course, that didn't prevent some silly problems with Nagios from cropping up, but it was stricly PEBKAC. By the end of the day Nagios was watching everything again, RT was moved from my desktop machine (with tickets intact), and all was well.