Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

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 directory
  • schroot allows you to manage multiple chroots, keeping them clean for later use
  • mk-schroot can be used to automate the schroot setup and management
  • Given a .dsc file (generated with debuild -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:

mk-sbuild --arch=amd64 --name=lucid lucid

This will guide you to create a chroot called 'lucid-amd64', and prints out the following helpful information when it's done:

Done building lucid-amd64.

 To CHANGE the golden image: sudo schroot -c lucid-amd64-source -u root
 To ENTER an image snapshot: schroot -c lucid-amd64
 To BUILD within a snapshot: sbuild -A -d lucid-amd64 PACKAGE*.dsc

So, once your chroots are setup, the build process would be:

  1. From your source pacakge's top-level directory, debuild -S to create a source package, including <package>_<version>.dsc
  2. Run the build: sbuild -A -d lucid-amd64 ../<package>_<version>.dsc

For more info, the manpages for mk-sbuild, schroot, sbuild, debootstrap and debuild 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.

share|improve this answer
1  
I agree that sbuild is the way to go. However, you've got a bunch of unnecessary steps in there. mk-sbuild does all the schroot setup for you, and you don't need to run sbuild as root. –  RAOF Feb 14 '12 at 2:34
    
Thanks RAOF, will update accordingly. –  Jeremy Kerr Feb 14 '12 at 2:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.