Pages

Tuesday 24 January 2012

Pacman Package Manager on Debian

Getting it on Debian

This part is kind of weird. We want to get pacman on Debian. There isn't an apt package, so what now? Well, we can build a .deb file that installs pacman so we can use PKGBUILDs. Basically, we use a package management system to install a package management system.

There's gotta be a "Yo Dawg" in there somewhere.

Get it pacman arch and be sure to get its dependency libdownload.

A look at some PKGBUILDs

Let's take a look some PKGBUILDs that we use at Kickball Labs.
The first is a simple PKGBUILD for ltrace, a program like strace but for library calls. It just downloads the source, passes in some custom options to configure, builds the binary, and then installs to the package directory.

pkgname=ltrace
pkgver=0.5.1
pkgrel=1
pkgdesc="ltrace is a debugging program which runs a specified command until it exits"
url="http://packages.debian.org/unstable/utils/ltrace"
arch=('x86_64')
source=(http://ftp.debian.org/debian/pool/main/l/ltrace/${pkgname}_${pkgver}.orig.tar.gz)

build()
{
  cd $startdir/src/$pkgname-$pkgver
  ./configure --prefix=/custom --sysconfdir=/custom/etc
  make || return 1
  make DESTDIR=$startdir/pkg install

Conclusion

Package management is painful. If you have any plans on building a service that scales to multiple machines, you had better have a good solution for creating and distributing packages. pacman is good for this because:
  1. It's easy to learn and use, encouraging you to make everything (from libraries to configuration files and more) a PKGBUILD.
  2. The simple plain text file format works great with your source control system of choice.
  3. Applied a patch you didn't like? Just roll the PKGBUILD file back with your package manager.
  4. Create a PKGBUILD repository by just putting the tarballs generated from your PKGBUILD files in a directory and pointing a web server at it. This is great for bringing up new hardware in a datacenter - just install pacman, point it at your repository, and install your base package which sets up the all your passwd, host, or other config files. 
When patching a Debian package, you do not have to get the original source and add all the Debian meta-stuff to it. You can just use apt-get source to get hold of Debian's source package, do the stuff you want to change and then run dpkg-buildpackage