I need to build debs for Ubuntus Lucid on. I know I can set up VMs/chroots, etc to make a distribution per build, but is there a mechanism from my Oneiric machine to do something like:
ubuntu-dpkg-buildpackage --distro=Lucid
and have a Lucid deb be generated?
As a quick note, this is for internal packages, and thus can not be farmed out to Launchpad or whereever.
There is no single-command solution to do this, but the tools definitely exist to make it relatively painless:
debootstrap
can create a pristine, minimal Ubuntu installation in a self-contained directoryschroot
allows you to manage multiple chroots, keeping them clean for later usemk-schroot
can be used to automate the schroot setup and managementdebuild -S
),sbuild
will chroot into your pristine chroot, install any dependent packages, and build your sources.this is basically what the launchpad build servers use to build source packages and put them in the Ubuntu archive.
In general, using a pristine chroot is good practice, as it ensures that the package does not depend on any customised setup on your build machine.
The setup process would involve creating a new schroot for each Ubuntu version you'd like to target. This is fairly straightforward: use
mk-sbuild
to build yourself a new chroot. Something like this is what you want:This will guide you to create a chroot called 'lucid-amd64', and prints out the following helpful information when it's done:
So, once your chroots are setup, the build process would be:
debuild -S
to create a source package, including<package>_<version>.dsc
sbuild -A -d lucid-amd64 ../<package>_<version>.dsc
For more info, the manpages for
mk-sbuild
,schroot
,sbuild
,debootstrap
anddebuild
are quite comprehensive. https://wiki.ubuntu.com/DebootstrapChroot has some good info about building and configuring the chroots. Also, there's #ubuntu-devel on irc.freenode.net if you need a hand.