wiki:BuildingDebianPackages

Version 38 (modified by dclark, 8 years ago) (diff)

--

Building Debian Packages

Bcfg2 Packaging

The Bcfg2 project provides a debian subdirectory with the project's source that enables users to create their own Debian/Ubuntu? compatible packages (.deb files). The steps to do this, assuming that you are running on a Debian/Ubuntu? system, are as follows:

Build deps

If the distribution you are building on already has packaged bcfg2 (even an older version), the following command will likely install the necessary packages to enable it to be built:

apt-get build-dep bcfg2 bcfg2-server

Or, if the available repositories do not have any version of bcfg2, try something like:

apt-get install cdbs docbook-xsl libxslt1.1 python-dev python2.4-dev sgml-base xml-core xsltproc fakeroot

Install source code

Depending on which version of bcfg2 you want build, you can obtain the source code from Download or from the project's Subversion repository. To create a local anonymous working copy of the latest version of the bcfg2 source code, use a command like the following:

svn co https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2 bcfg2-trunk

Configure for python version

This step is only needed in Bcfg2 1.0.0rc1 and earlier.

Once you have a copy of the source code, there are a couple of final steps.

First, Bcfg2 as packaged for Debian supports several different versions of Python. To select the appropriate version you will need to run the buildsys-select.sh script from within the debian subdirectory. You must pass it an argument <PYTHON_VERSION> that is one of the following values:

2.3
for Debian sarge.
2.4
for Ubuntu breezy, dapper, and Nexenta <= Alpha 6.
pycentral
for Debian etch or newer; Ubuntu edgy, feisty, gutsy, and hardy or newer.

As Debian and other related distributions have matured, many of these are fading from use and the correct choice for <PYTHON_VERSION> is almost always pycentral.

Once you have figured out the correct value for <PYTHON_VERSION>, run the following command:

cd bcfg2-trunk/debian
./buildsys-select.sh <PYTHON_VERSION>

Update the changelog

The next step is to update the Debian changelog file with an appropriate package version string. Debian packages contain a version that is extracted from the latest entry in the changelog file. An appropriate version will help you distinguish your locally built package from one provided by your distribution. It also helps the packaging system know when a newer version of the package is available to install.

It is possible to skip this step, but the packages you build will have the same version as the source distribution and will be easy to confuse with other similarly named (but maybe not equivalent) packages.

The basic format of the package version string to use is this:

<UPSTREAM VER>~<UPSTREAM PRE-VER>+r<UPSTREAM SVN REV>-0.1+<LOCAL VER>

NOTE: The '~', '+', and '-' characters have significance in determining when one package is newer than another. The following format is believed to do the right thing in all common situations.

The components of the package version string are explained below:

<UPSTREAM VER>
This is the version of the Bcfg source code you are working from. It will likely be something like 0.9.6 or 1.0.
~<UPSTREAM PRE-VER>
If you are using a published pre-release of Bcfg2, it will have a name like pre1 or rc1. Use that string here, otherwise drop this component and the preceding tilde (~) character from the package version string.
+<UPSTREAM SVN REV>
If you are building from a local working copy of the Subversion repository, it is useful to include the repository revision in the package version. It will be a number like '5464'. If you are building from a downloaded copy of the source, drop this component (including the preceding plus-sign (+) from the package version string.
+<LOCAL VER>
This is a locally relevant name like your last name or your domain name, plus the digit 1. For example, if your family name is Smith, you could use smith1. If you work for Example Inc, you could use example1.

Here are some examples:

  • If you are building packages for revision 5463 of the Subversion trunk, and the latest published version is 1.0pre5, the version string should be 1.0~pre5+r5463-0.1+example1.
  • If you are building packages for the published 1.0 rc1 version, the version string should be 1.0~rc1-0.1+example1.
  • If you are building packages for the published 1.0 version, the version string should be 1.0-0.1+example1.

If you are working on a Subversion working copy of 1.0 pre5 and have the devscripts package installed, the following command is a convenient way to create a well formatted changelog entry:

REV=$(svn info|grep '^Revision' |cut -d' ' -f2)
debchange --force-bad-version --preserve --newversion "1.0~pre5+r${REV}-0.1+example1" SVN revision $REV

Building the package

With the preliminaries out of the way, building the package is simple.

cd ..  # Change into the top level of the source directory
fakeroot dpkg-buildpackage -uc -us

The freshly built packages will be deposited in the parent of the current directory (..). Examine the output of dpkg-buildpackage for details.

Backport Packaging

Bcfg2 uses some newer packages which need to be backported to most debian-based GNU/Linux distributions. In most cases you'll need to have these working before doing the above Bcfg2 packaging.

debhelper

Bcfg2 1.0.0rc2 and later require a very recent debhelper, which in turn requires a very recent po4a.

Versions that work are in:

  • debian: lenny-backports, squeeze, sid
  • ubuntu: karmic

No special steps are needed to do these backports.

sqlalchemy

For the standard Bcfg2 1.0 Snapshots reporting feature, you need SQLAlchemy 0.5 or later, which in turn requires a recent version of sphinx. No special steps need to be taken to do these backports.

External build systems

This section describes how to build bcfg2 and deps via external build system. Currently only a PPA. Some other possibilities are:

Launchpad PPA

To upload to the PPA you need to be on the active member list of Bcfg2 in Launchpad.

Note that after each successful upload, you should wait until the PPA is built, and then install it locally using "aptitude update; aptitude install (packagename)" so the next build doesn't fail on your local machine. If you don't want to wait for a PPA binary build to complete, you can "apt-get source (packagename)" and do a local build before the PPA build is done.

setup gpg-agent

So you won't be prompted for your passphrase a whole bunch of times...

sudo aptitude install gnupg-agent
# replace 0xAA95C349 with your GPG Key ID
export GPGKEY=0xAA95C349
killall -q gpg-agent
eval $(gpg-agent --daemon)

setup debuild

Tell dpkg-buildpackage who you are, for example:

export DEBEMAIL="dclark@pobox.com"
export DEBFULLNAME="Daniel Joseph Barnhart Clark"

setup dput

Make a ~/.dput.cf file:

[bcfg2]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~bcfg2/ppa/ubuntu
login = anonymous
allow_unsigned_uploads = 0

[bcfg2-force-dapper]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~bcfg2/ppa/ubuntu/dapper
login = anonymous
allow_unsigned_uploads = 0

[bcfg2-force-hardy]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~bcfg2/ppa/ubuntu/hardy
login = anonymous
allow_unsigned_uploads = 0

[bcfg2-force-intrepid]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~bcfg2/ppa/ubuntu/intrepid
login = anonymous
allow_unsigned_uploads = 0

[bcfg2-force-jaunty]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~bcfg2/ppa/ubuntu/jaunty
login = anonymous
allow_unsigned_uploads = 0

[bcfg2-force-karmic]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~bcfg2/ppa/ubuntu/karmic
login = anonymous
allow_unsigned_uploads = 0

[bcfg2-testing]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~bcfg2/testing/ubuntu
login = anonymous
allow_unsigned_uploads = 0

[bcfg2-testing-force-dapper]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~bcfg2/testing/ubuntu/dapper
login = anonymous
allow_unsigned_uploads = 0

[bcfg2-testing-force-hardy]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~bcfg2/testing/ubuntu/hardy
login = anonymous
allow_unsigned_uploads = 0

[bcfg2-testing-force-intrepid]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~bcfg2/testing/ubuntu/intrepid
login = anonymous
allow_unsigned_uploads = 0

[bcfg2-testing-force-jaunty]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~bcfg2/testing/ubuntu/jaunty
login = anonymous
allow_unsigned_uploads = 0

[bcfg2-testing-force-karmic]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~bcfg2/testing/ubuntu/karmic
login = anonymous
allow_unsigned_uploads = 0

upload po4a

Upload:

#!/bin/sh -x

sudo apt-get build-dep po4a

wget http://archive.ubuntu.com/ubuntu/pool/main/p/po4a/po4a_0.36.1-1.dsc
wget http://archive.ubuntu.com/ubuntu/pool/main/p/po4a/po4a_0.36.1.orig.tar.gz
wget http://archive.ubuntu.com/ubuntu/pool/main/p/po4a/po4a_0.36.1-1.diff.gz
dpkg-source -x po4a_0.36.1-1.dsc
cd po4a-0.36.1
cp debian/changelog debian/changelog.orig
ppa="testing" # "testing" or "ppa" (for stable)
try="1"

for dist in dapper hardy intrepid jaunty karmic; do
cp debian/changelog.orig debian/changelog
(cd debian && debchange --force-bad-version --preserve --newversion \
"0.36.1-1~${ppa}${try}~${dist}${try}" \
backport to ppa ${ppa}, dist ${dist}, try ${try})
# Replace 0xAA95C349 to your GnuPG Key ID
debuild -S -k0xAA95C349
dput bcfg2-testing-force-${dist} ../po4a_0.36.1-1~${ppa}${try}~${dist}${try}_source.changes
done

And then make sure it's installed locally for the next step.

upload debhelper

Upload:

#!/bin/sh -x

sudo apt-get build-dep debhelper

wget http://archive.ubuntu.com/ubuntu/pool/main/d/debhelper/debhelper_7.3.15ubuntu3.dsc
wget http://archive.ubuntu.com/ubuntu/pool/main/d/debhelper/debhelper_7.3.15ubuntu3.tar.gz
dpkg-source -x debhelper_7.3.15ubuntu3.dsc
cd debhelper-7.3.15ubuntu3
cp debian/changelog debian/changelog.orig
ppa="testing" # "testing" or "ppa" (for stable)
try="1"

for dist in dapper hardy intrepid jaunty karmic; do
cp debian/changelog.orig debian/changelog
(cd debian && debchange --force-bad-version --preserve --newversion \
"7.3.15ubuntu3~${ppa}${try}~${dist}${try}" \
backport to ppa ${ppa}, dist ${dist}, try ${try})
# Replace 0xAA95C349 to your GnuPG Key ID
debuild -S -k0xAA95C349
dput bcfg2-testing-force-${dist} ../debhelper_7.3.15ubuntu3~${ppa}${try}~${dist}${try}_source.changes
done

And then make sure it's installed locally for the next step.

upload sphinx

Upload:

#!/bin/sh -x

sudo apt-get build-dep sphinx

wget http://archive.ubuntu.com/ubuntu/pool/main/s/sphinx/sphinx_0.6.2-1.dsc
wget http://archive.ubuntu.com/ubuntu/pool/main/s/sphinx/sphinx_0.6.2.orig.tar.gz
wget http://archive.ubuntu.com/ubuntu/pool/main/s/sphinx/sphinx_0.6.2-1.diff.gz
dpkg-source -x sphinx_0.6.2-1.dsc
cd sphinx-0.6.2
cp debian/changelog debian/changelog.orig
ppa="testing" # "testing" or "ppa" (for stable)
try="1"

for dist in dapper hardy intrepid jaunty karmic; do
cp debian/changelog.orig debian/changelog
(cd debian && debchange --force-bad-version --preserve --newversion \
"0.6.2-1~${ppa}${try}~${dist}${try}" \
backport to ppa ${ppa}, dist ${dist}, try ${try})
# Replace 0xAA95C349 to your GnuPG Key ID
debuild -S -k0xAA95C349
dput bcfg2-testing-force-${dist} ../sphinx_0.6.2-1~${ppa}${try}~${dist}${try}_source.changes
done

And then make sure it's installed locally for the next step.

upload sqlalchemy

Upload:

#!/bin/sh -x

sudo apt-get build-dep sqlalchemy

wget http://archive.ubuntu.com/ubuntu/pool/universe/s/sqlalchemy/sqlalchemy_0.5.5-1.dsc
wget http://archive.ubuntu.com/ubuntu/pool/universe/s/sqlalchemy/sqlalchemy_0.5.5.orig.tar.gz
wget http://archive.ubuntu.com/ubuntu/pool/universe/s/sqlalchemy/sqlalchemy_0.5.5-1.diff.gz
dpkg-source -x sqlalchemy_0.5.5-1.dsc
cd sqlalchemy-0.5.5
cp debian/changelog debian/changelog.orig
ppa="testing" # "testing" or "ppa" (for stable)
try="1"

for dist in dapper hardy intrepid jaunty karmic; do
cp debian/changelog.orig debian/changelog
(cd debian && debchange --force-bad-version --preserve --newversion \
"0.5.5-1~${ppa}${try}~${dist}${try}" \
backport to ppa ${ppa}, dist ${dist}, try ${try})
# Replace 0xAA95C349 to your GnuPG Key ID
debuild -S -k0xAA95C349
dput bcfg2-testing-force-${dist} ../sqlalchemy_0.5.5-1~${ppa}${try}~${dist}${try}_source.changes
done

And then make sure it's installed locally for the next step.

upload bcfg2

Upload:

#!/bin/sh -x

sudo apt-get build-dep bcfg2 bcfg2-server

# Trunk, or specify a revision; also something was said about being able
# to build right from svn with the new debian packaging...
svn co https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2 bcfg2-trunk
cd bcfg2-trunk
cp debian/changelog debian/changelog.orig
ppa="testing" # "testing" or "ppa" (for stable)
try="1"
REV=$(svn info|grep '^Revision' |cut -d' ' -f2)

for dist in dapper hardy intrepid jaunty karmic; do
cp debian/changelog.orig debian/changelog
(cd debian && debchange --force-bad-version --preserve --newversion \
"1.0.0pre1-0.1+r${REV}~${ppa}${try}~${dist}${try}" \
backport to ppa ${ppa}, dist ${dist}, try ${try}, svn revision $REV)
# Replace 0xAA95C349 to your GnuPG Key ID
debuild -S -k0xAA95C349
dput bcfg2-testing-force-${dist} ../bcfg2_1.0.0pre1-0.1+r${REV}~${ppa}${try}~${dist}${try}_source.changes
done

Or if doing a build from tarball (no local changes):

#!/bin/sh -x

sudo apt-get build-dep bcfg2 bcfg2-server

ppa="testing" # "testing" or "ppa" (for stable)

for dist in dapper hardy intrepid jaunty karmic; do
# Replace 0xAA95C349 to your GnuPG Key ID
debuild -S -k0xAA95C349
dput bcfg2-testing-force-${dist} ../bcfg2*_source.changes
done

And then make sure it's installed locally for the next step.