Differences between revisions 4 and 5
Revision 4 as of 2011-12-04 19:09:58
Size: 2589
Editor: ?KeesCook
Comment:
Revision 5 as of 2012-06-19 00:17:36
Size: 2797
Editor: ?KeesCook
Comment:
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
The first time you run `mk-sbuild` (found in the `ubuntu-dev-tools` package), it will add your user to the `sbuild` group, and install various needed packages. After that, you just need to request the release you want to create a chroot for: The first time you run `mk-sbuild` (found in the `ubuntu-dev-tools` package), it will add your user to the `sbuild` group, and install various needed packages. After that, you just need to request the release you want to create a chroot for. If you want to have "debuild" available in the chroot, include "devscripts" as an explicit additional package to install, otherwise the chroot will be as minimal as possible:
Line 10: Line 10:
mk-sbuild unstable mk-sbuild --debootstrap-include=devscripts unstable

using mk-sbuild, schroot, and sbuild

The mk-sbuild tool is designed to create a full sbuild-with-schroot environment to do builds. One benefit of this is that you also end up with functional chroot environments as well.

Initial Setup

The first time you run mk-sbuild (found in the ubuntu-dev-tools package), it will add your user to the sbuild group, and install various needed packages. After that, you just need to request the release you want to create a chroot for. If you want to have "debuild" available in the chroot, include "devscripts" as an explicit additional package to install, otherwise the chroot will be as minimal as possible:

mk-sbuild --debootstrap-include=devscripts unstable

The chroot would be configured in schroot (see /etc/schroot), and debootstrap will be run. One successful completion, it will report:

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

Where CHROOT_NAME is the release you gave, with the default architecture appended. For example, on an amd64 system, installing unstable, it would be named unstable-amd64. The name and architecture are selectable with command-line options. See man mk-sbuild for details.

To avoid needing sudo, you can adjust /etc/schroot/chroot.d/CHROOT_NAME.conf and uncomment the following line:

source-root-groups=root,sbuild,admin

This will let you enter the chroot as the root user. Use wisely, as root in a chroot is just as powerful as root outside a chroot.

Using schroot to build packages

To see the list of available chroots, run:

schroot -l

To enter a copy of the chroot, run:

schroot -u root -c CHROOT_NAME

where CHROOT_NAME is the chroot you created earlier (e.g. unstable-amd64, unstable-i386, etc). From here, you can install deps:

apt-get build-dep PACKAGE

where PACKAGE is the package you want to work on. When you're ready to build packages, switch to a non-root user, and do what you need to do outside the chroot:

apt-get source PACKAGE
cd PACKAGE-*
dch -i
edit!

And do the build inside the chroot:

su builder
debuild -uc -us

When you're ready for a source build, inside the chroot:

debuild -S -uc -us

This will generate a .dsc file, which you give to sbuild (see next section).

Using sbuild

To use sbuild, you'll need a source package (with a .dsc file -- see above). Outside your chroots, you can build using sbuild via:

sbuild -A -d CHROOT_NAME PACKAGE*.dsc

And everything will happen automatically.