Building FOSSology Debian packages

NOTE These notes were taken from Matt Taggart's page called building_debian_packages on this wiki. Those notes were left intact and changes were made here.

These notes are specific to the setup we have on our build/package machine cranky. Cranky is in the external FO ring. On cranky there is a user called build. That account should be used when executing the package process described below. On cranky there is an area created for doing package work. The area has the following directories: packaging pbuilder svn tmp. The notes below will be making references to these directories. There is a link to this area in the build account. The build account has a lot of aliases set up in the shell. These aliases will also be referenced in the steps below.

Building Test Packages

This is what the fossology team does to create our debian packages we use for testing and local release.

Prepare the source
  1. SVN Update the branch that is going to be packaged. Make sure that the sources are at the svn Rev/Tag you expect.
  2. update VERSION in Makefile.conf to an SVN prerelease version, example: 1.0.0~20081106
  3. FIXME! Use debchange to edit the change log. Create or update the top entry in debian/changelog to match that version, with a -1 debian version, with a single bullet saying “unofficial svn testing”. There should only ever be one entry of this type and it should be at the top and will not remain in the file for any releases. (example?)

Here is what is being done for internal rc's at the moment.

  1. cd to the debian directory in the sources
  2. use debchange to edit the changelog
  3. Increment the rc number
  4. In the future, we will start using dates. Once dates are used you don't stop using them till you have an rc and from then on you use the rc. I think this is how Matt expected things to work.
  1. commit Makefile.conf and debian/changelog
  2. Make a tarball from the sources. From the top of the svn tree, make sure the tree is the way you want it, up to date, no outstanding files reported by “svn status”, etc. Then run “utils/fo-mktar”, this will generate a tarball in ../
  3. create a packaging directory somewhere. On cranky packages are stored at: /srv/build/packaging.
  4. untar the tarball into the the packaging directory and move the result to the same name plus .orig
    • tar zxvf <pathtosvn>/../fossology-1.0.0~20081106.tar.gz /srv/build/packaging
      for example 
      mv fossology-1.0.0~20081106 fossology-1.0.0~20081106.orig
  5. untar it again
    • tar zxvf fossology-1.0.0~20081106.tar.gz
    • at this point there should be two fossology trees one with .orig and one without it in the /srv/build/packaging directory.
  6. export the debian directory from the svn tree to the new directory (not the .orig copy).
    • svn export <pathtosvn>/debian fossology-1.0.0~20081106/debian

At this point you could just cd into the directory and do “debuild -rfakeroot” however for our official process we use pbuilder http://www.netfort.gr.jp/~dancer/software/pbuilder-doc/pbuilder-doc.html#introduction for building packages in clean chroots. (This document assumes you already have pbuilder setup)

Build the releases and architechures
  1. cd into the directory /srv/build/packaging/<release>/<name of fossology tar ball> For example, /srv/build/packaging/lenny/fossology-1.1.0~rc5/

For each arch/release target you want to generate debs for(currently we do 4. lenny and etch/i386 and lenny etch/amd64) Using lenny and rc5 as an example:

  1. For additional targets use pbuilder with ”–binary-arch” so you won't build the source and binary-indep packages. This is already in the alias, so just use the alias.
  2. For this alias you must also supply a *.dsc file. Use the one in parent directory e.g. ../*.dsc
    • pbuilder-lenny-amd64-only ../*.dsc
Build Issues

So far there have been few. For release 1.2 the tarballs needed to be updated. This is done using the –extrapackages option to pbuilder. The tarballs needed the following added to them for 1.2:

For example:

sudo pbuilder --update --basetgz /srv/build/pbuilder/tarballs/lenny-amd64.tar.gz --extrapackages python python-pyrex

Copy the Packages

  1. copy the packages from the pbuilder results/arch directory, (/srv/build/pbuilder/{etch|lenny}/results) to the location you want to serve them from.
  2. on the system DOC where we serve the packges from:
    • create a release/rc dir in: /var/www/fossology.org/debian
    •  cd /var/www/fossology.org/debian; sudo mkdir 1.1.0~rc5;sudo chown me:me 1.1.0~rc5
    • create release directories under the directory above for each release.
    • mkdir 1.1.0~rc5/etch 1.1.0~rc5/lenny
    • copy over the mkpackages script from the previous rc or release to this one.
    • cd to the appropriate directory and copy over the files:
    • cd lenny
    • scp cranky:~build/build/pbuilder/result/lenny-i386/* .
      scp cranky:~build/build/pbuilder/result/lenny-amd64/*amd64* .

NOTE: that there are duplicate files between architectures. So the second copy must only grab the architecture specific files.

On the system you want to use the packages, add something like this to sources.list

General Instructions for Building packages for Release

Same as above but:

environment). Also, pbuilder enables you to build for target releases and architectures other than the that of your build system.

Below is an example using the pbuilder –build option using the file package to build from a source package.

sudo pbuilder --build --basetgz /srv/build/pbuilder/tarballs/etch-i386.tar.gz file_4.17-5etch3.dsc

Results go to /var/cache/pbuilder/result/ (or you can specify alternate destination with –buildresult)

FOSSology specific deb package build instructions

  1. checkout the source tree you wish to package:
    • svn co https://fossology.svn.sourceforge.net/svnroot/fossology/trunk/fossology/
  2. update VERSION in Makefile.conf to a release version, example: 1.0.0
  3. Create or update the top entry in debian/changelog to match the release version.
  4. svn co Makefile.conf and debian/changelog
  5. from the top of the svn tree, make sure the tree is the way you want it, up to date, no outstanding files reported by “svn status”, etc.
  6. run “utils/fo-mktar”, this will generate a tarball in ../
  7. create a packaging directory somewhere
  8. untar the tarball and move the result to the same name plus .orig
    • tar zxvf <pathtosvn>/../fossology-1.0.0~20081106.tar.gz
      mv fossology-1.0.0~20081106 fossology-1.0.0~20081106.orig
  9. untar it again
    • tar zxvf fossology-1.0.0~20081106.tar.gz
  10. export the debian directory from the svn tree to the new directory
    • svn export <pathtosvn>/debian fossology-1.0.0~20081106/debian

For each arch/release target you want to generate debs for(currently we do etch/i386 and etch/amd64)

  1. update the pbuilder image
    • sudo pbuilder update
  2. use pbuilder to build the source, binary-indep debs, and binary-arch debs for the first target
    • pdebuild
  3. for additional targets use pbuilder with ”–binary-arch” so you won't build the source and binary-indep packages.
    • sudo pbuilder --binary-arch --build *.dsc
  4. sign the built packages
    • debsign *.changes
  5. copy the packages from the pbuilder results directory to the location you want to serve them from.
  6. In the location you want to serve them from run
    • apt-ftparchive packages . > Packages
      cat Packages | gzip -9 >Packages.gz
  1. On the system you want to use the packages, add something like this to sources.list
    • deb http://fossology.org/~taggart/debian/ ./
  2. Run “apt-get update”
  3. Install how you want