Build a package

To build a package foo, just go in foo/pkg directory and run make deb and/or make rpm.

The resulting package(s) are located in the out directory. Source package(s) are in the src-out directory.

Cleaning cache, out and src-out directories

Example with with package python-asciigraph:

# go inside the component directory
$ cd python-asciigraph

# optionnally, clean cache/ and out/ directory
$ make clean

Build rpm package

Example with with package python-asciigraph:

# go inside the component directory
$ cd python-asciigraph

# build rpm package
$ make rpm

Here are the results:

# output packages:
$ ls out/
python-asciigraph-1.1.3-1.unk.noarch.rpm

# output source package
$ ls src-out/
python-asciigraph-1.1.3-1.unk.src.rpm

Build rpm inside a clean chroot

Warning

Not implemented yet

Build deb package

Example with with package python-asciigraph:

# go inside the component directory
$ cd python-asciigraph

# build deb package
$ make deb

Here are the results:

# output packages:
$ ls out/
python-asciigraph_1.1.3-1_all.deb

# output source package
$ ls src-out/
python-asciigraph_1.1.3-1.debian.tar.xz  python-asciigraph_1.1.3.orig.tar.gz
python-asciigraph_1.1.3-1.dsc

Build deb package inside a clean chroot

This build system can leverage cowbuilder from Debian to build in a clean chroot.

This is the recommended way to build packages targeted to be used in production.

Building in chroot is heavier but has multiple gains:

  • It permits to build in a clean environment every time
  • It rapidly exits in error if the build dependencies are not properly declared
  • It permits to target different version of Debian (stretch, jessie, wheezy)
  • It manages build dependencies, installing them automatically (if properly declared)
  • It permits to avoid having to install all build dependencies on your main system
# go inside the component directory
$ cd python-asciigraph

# build deb package for dist jessie
$ make deb_chroot DIST=jessie

Note

Building the chroot can be a long and heavy step but there are several way to accelerate it.

The first is to used a local mirror, this can be done using the DEB_MIRROR option when calling deb_chroot:

make deb_chroot DEB_MIRROR=http://your.local.mirror/debian

The second is to use a tmpfs for building, it requires a few GB of RAM however (at least 1.5GB per distro version targeted, but this may vary depending on the number packages and the size of their dependencies):

# as root
mount -t tmpfs -o size=16G tmpfs /var/cache/pbuilder/
# in fstab
tmpfs /var/cache/pbuilder/ tmpfs defaults,size=16G 0 0

Warning

Building in chroot requires root permission (it’s necessary for creating the chroot environment).

If make deb_chroot is run as a standard user, sudo will be used for cowbuilder calls.

The only command that needs to be white listed in sudoers configuration is cowbuilder:

# replace build-user with the user used to generate the packages
build-user ALL=(ALL) NOPASSWD: /usr/sbin/cowbuilder