ReleaseEngineering/PuppetAgain/HowTo/Build DEBs
Within PuppetAgain, Debian packages are built from an expanded debian/ directory kept in version control and an .orig.tar.bz2 kept in the data directories. This surfaces changes to the debian build scripts as diffs in the puppetagain repo, although it also requires some custom build scripts.
Those build scripts, however, are implemented on hosts with the toplevel::server::pkgbuilder class. This class helpfully creates a cowbuilder image and provides the pupppetagain-build-deb script to build a package from a debian directory.
Building
Log in to a builder host as yourself (not root), and get a checkout of the puppetagain repo.
For the package you want, find or create the appropriately-named orig tarball in the same directory as the package-debian dir, e.g., modules/packages/manifests/mozilla. Then run puppetagain-build-deb with the path to the package-debian dir:
puppetagain-build-deb modules/packages/manifests/mozilla/nodejs-debian
This will build the package using cowbuilder and tell you the location of the results at the end.
Modifying
To modify an existing package, do the same, but make the necessary changes in the package-debian directory beforehand. Note that you will need to update package-debian/changelog to update the version number.
To modify an existing package that is not already part of PuppetAgain, copy its debian/ directory into the source tree, make any necessary modifications, and build it.
Note: Do not check in the orig tarball, but do be sure to copy the orig tarball into the data tree along with the .deb packages!)
Dependencies
Note that the chroot environment only pulls dependencies from the active PuppetAgain repositories. If you are building a chain of dependent packages, you'll need to either adjust the chroot to include a temporary directory, or add each dependent package to the repositories before proceeding.
Creating
To create a brand-new package with no base package, it's probably easiest to begin with a "normal" debian packaging process, and copy the resulting debian/ directory into the PuppetAgain source tree. Then proceed as above.
Old Stuff
Building
At the moment we don't have any shared resources to build Debian packages. You need to use Ubuntu 12.04 based VM on your laptop.
To build a package in clean-room environment use pbuilder. It uses precreated images to build DEBs in chroot.
Create pbuilder images
Use the following command to create environments.
- 64 bit
sudo pbuilder --create --distribution precise --architecture amd64 \ --components "main restricted universe multiverse" \ --debootstrapopts --variant=buildd \ --basetgz /var/cache/pbuilder/base-precise-amd64.tgz \ --mirror http://archive.ubuntu.com/ubuntu \ --othermirror "deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse" \ --othermirror "deb http://archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse"
- 32 bit
sudo pbuilder --create --distribution precise --architecture i386 \ --components "main restricted universe multiverse" \ --debootstrapopts --variant=buildd \ --basetgz /var/cache/pbuilder/base-precise-i386.tgz \ --mirror http://archive.ubuntu.com/ubuntu \ --othermirror "deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse" \ --othermirror "deb http://archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse"
Building a package
There are some different ways to build a binary package
Building from orig.tar.gz, debian.tar.gz and dsc
sudo pbuilder --build --distribution precise --architecture amd64 --basetgz /var/cache/pbuilder/base-precise-amd64.tgz\ --buildresult ./out *.dsc
"out" directory will be populated with files you'll need to import into the repo.
By default if the same upstream version has 2 entries in debian/changelog, packaging tools don't add orig.tar.gz in the *.changes files (used when you import the package). If for some reason you need to add the upstream source into the "changes" file (for example, when you backport some package) pass "-sa" to the packaging tools:
sudo pbuilder --build --distribution precise --architecture amd64 --basetgz /var/cache/pbuilder/base-precise-amd64.tgz \ --buildresult out --debbuildopts "-sa" *.dsc
Building using git-buildpackage
git-buildpackage allows you to have everything related to a package under version control. Your git checkout contains the following branches needed to build the package:
- upstream: upstream sources
- debian: debianization work
- pristine-tar (optional): binary information needed to recreate orig.tar.gz from git with a proper final checksum
The following config (~/.gbp.conf) file is used:
[DEFAULT] cleaner = fakeroot debian/rules clean pristine-tar = True color = auto [git-buildpackage] export-dir = ../build-area/ tarball-dir = ../tarballs/ pbuilder = True dist = precise [git-import-orig] dch = False
The following scenario used to rebuild puppet-2.7.17:
# get Debian's package (apt-cache showsrc puppet|grep ^Vcs-Git:) git clone git://git.debian.org/git/pkg-puppet/puppet.git cd puppet git co -b pristine-tar origin/pristine-tar git co -b mozilla upstream/2.7.17 # checkout upstream version we need, by tag git merge debian/2.7.17-1 # merge debian changes for that version, by tag dch --local mozilla --distribution precise # bump debian/changelog with proper version suffix git commit -va # biuld it ARCH=amd64 BUILDER=pbuilder git-buildpackage --git-upstream-branch=origin/upstream --git-debian-branch=mozilla # add -sa to include source) # once you're happy with the package, tag it ARCH=amd64 BUILDER=pbuilder git-buildpackage --git-upstream-branch=origin/upstream --git-debian-branch=mozilla --git-tag # to build i386 specific package you need to pass -B to avoid adding orig/debian.tar/gz files into the changes file ARCH=i386 BUILDER=pbuilder git-buildpackage --git-upstream-branch=origin/upstream --git-debian-branch=mozilla -B
Building multiple dependent packages
Sometimes you may need to build a package which requires a fresher dependency (library). In this case you need to build the library first and use a temporary local repo. Packaging nodejs is a good example.
Pbuilder can use hooks to run some actions.
- Add the following entries to your ~/.pbuilderrc
HOOKDIR="$HOME/.pbuilder-hooks" OTHERMIRROR="deb file://$HOME/debs/packages ./" BINDMOUNTS="$HOME/debs/packages" EXTRAPACKAGES="apt-utils"
- Add a hook to generate package indexes
mkdir ~/.pbuilder-hooks
- .pbuilder-hooks/D05deps contents:
#!/bin/sh (cd /home/rail/debs/packages && apt-ftparchive packages . > Packages) apt-get update
- chmod 755 .pbuilder-hooks/D05deps
- edit existing images
sudo pbuilder --login --basetgz /var/cache/pbuilder/base-precise-amd64.tgz --save-after-login # inside the subshell apt-get install apt-utils echo "deb file:///home/rail/debs/packages ./" >> /etc/apt/sources.list echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/90mozilla
- repeat for the i386 image
- build the library
- copy the resulting debs into $HOME/debs/packages
- build the application
Testing
At the moment there is no testing repo. You need to manually install packages to test them.