Version 18 (modified by solj, 12 years ago) (diff)

mention the patch in a relevant spot

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:

Install packages necessary for building bcfg2

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 the Bcfg2 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 bcfg2-trunk

Configure the Bcfg2 working copy

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 script from within the debian subdirectory. You must pass it an argument <PYTHON_VERSION> that is one of the following values:

for Debian sarge.
for Ubuntu breezy, dapper, and Nexenta <= Alpha 6.
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

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:


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:

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.
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.
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.
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 Bcfg2 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.

Python SSL Backport Packaging

As of Bcfg2 1.0, Bcfg2 has switched to the in-tree ssl module included with python 2.6. A backport exists for 2.3, 2.4, and 2.5. With this, M2Crypto is not needed, and tlslite is no longer included with bcfg2 sources. The ssl module can be found here. See Authentication? for details.

To build a package of the ssl backport for .deb based distributions that don't ship with python 2.6, you can follow these instructions, which use stdeb. Alternatively if you happen to have .deb packaging skills, it would be great to get policy-complaint .debs into the major deb-based distributions.

NOTE: To build the module on Debian (lenny) and Ubuntu (hardy), I had to apply this patch to remove bluetooth references.

sudo aptitude install python-all-dev fakeroot python-setuptools libssl-dev debhelper python-support
sudo easy_install stdeb
tar xvfz ssl-1.14.tar.gz
cd ssl-1.14
cd deb_dist/ssl-1.14
dpkg-buildpackage -rfakeroot -uc -us
sudo dpkg -i ../python-ssl_1.14-1_amd64.deb

For complete bcfg2 goodness, you'll also want to package stdeb using stdeb:

sudo aptitude install apt-file
tar xvfz stdeb-0.3.tar.gz
cd stdeb-0.3
cd deb_dist/stdeb-0.3
dpkg-buildpackage -rfakeroot -uc -us
sudo dpkg -i ../python-stdeb_0.3-1_all.deb