BOOST WIKI | RecentChanges | Preferences | Page List | Links List

by ZakElep?

This page describes a way to install the latest release of the Boost libraries on the Debian GNU/Linux? system release 3.1 (Sarge.)

I produced this page to document my process of getting a packaged version of Boost 1.33.1 with Boost::Asio running on a Debian 3.1r2 system. While Debian 3.1r2 has the `libboost-dev' set of packages already available from the Debian archive, it was rather outdated and unacceptable (a working Boost 1.33.1 with Boost::Asio was needed.)

Before we begin

Ideally we need to set up a Sarge chroot environment first and build the packages inside there. Even more ideal is creating a pbuilder setup inside the chroot environment to ensure that the binaries build cleanly and the dependencies are fully met (without the extra stuff appearing in a regular working environment.)

We also need disk space and RAM: lots of it. Anyhow even if we're going to just build Boost without packaging it, we'll still need lots of space. ;)

We can set up a `dchroot' environment by following the instructions borrowed from the Ubuntu wiki.[0] A `dchroot' environment makes it easy for even casual (non-root) users to use a chroot environment.

[0] https://wiki.ubuntu.com/DebootstrapChroot

After setting up the dchroot, grab the `pbuilder' and `fakeroot' packages from the Debian archive and follow the PbuilderHowto?[1] (again from the Ubuntu wiki.) This will allow us to have a minimal environment to build Boost in.

[1] https://wiki.ubuntu.com/PbuilderHowto

Finally, be sure to include this line in _both_ your dchroot's and your pbuilder's /etc/apt/sources.list :

  deb-src http://ftp.debian.org/debian/ sid main

This line tells your chroot's APT the location to fetch source packages for package building. For our purpose, we will be using Debian Sid (aka Still In Development, Unstable) as our repository of source packages, since this repository already has a packaged version of Boost 1.33.1.

Getting Started

Checking the Build Setup

If you've set up a `sarge' chroot in, say, /chroots/sarge , add this line in your /etc/dchroot.conf :

  sarge /chroots/sarge

Hence, to bring up a `sarge' chroot, you would just say at the command line:

  $ dchroot -c sarge

to bring up a `sarge' shell.

To exit the chroot environment, just log out as you would in an ordinary terminal/console.

Grab and Unpack Boost Sources

Log in to the `sarge' dchroot, and get the Boost 1.33.1 Debian source packages:

  $ dchroot -c sarge
  (sarge)$ mkdir -p debian-pkg/boost/ && cd debian-pkg/boost
  (sarge)$ apt-get source boost

This will fetch Boost from the Debian sid archive (version 1.33.1-5 as of this writing), containing the original unmodified source (boost_1.33.1.orig.tar.gz), the Debian-specific changes (boost_1.33.1-5.diff.gz) and Debian source control (boost_1.33.1-5.dsc). `apt-get' will automatically set up the source tree at debian-pkg/boost/boost-1.33.1 , and apply the Debian patches.

Rebuild the `orig.tar.gz' (Optional)

In my particular case, I needed to have a Boost 1.33.1 installation on Debian Sarge with Boost.Asio (>= 0.3.7) installed. In order to do this, I have two choices:

  (a) Package the Boost.Asio library as a separate library package,
      {build-,}depending on libboost-dev; or

  (b) Include Boost.Asio inside the Boost source distribution itself.

Option (a) would have probably made a much more modular setup (and perhaps, allowing a separate Boost.Asio package to be included into the Debian archive later on,) but I opted to go for Option (b) because it was faster, and had the least hassle (I didn't have to add a new Package stanza in debian/control , for instance.)

To do Option (b), first unpack the boost_1.33.1.orig.tar.gz somewhere not in the current directory:

  (sarge)$ pushd /tmp
  /tmp ~/debian-pkg/boost
  (sarge)$ tar xzf ~1/boost_1.33.1.orig.tar.gz

Then get the Boost.Asio sources from the Boost Vault, and copy the files inside it to boost-1.33.1 :

  (sarge)$ wget http://www.boost-consulting.com/vault/index.php?action=downloadfile&filename=boost_asio_20060724.zip&directory=Input%20-%20Output&;
  (sarge)$ unzip boost_asio_20060724.zip
  (sarge)$ cp -a boost_asio_20060724/* boost-1.33.1/

Now rename the boost source directory to something else. This is optional, but I do this to differentiate between the original Debian source package and my modified version (so I can control whether future releases of `libboost-dev' from Debian can supersede or be overriden my package:)

  (sarge)$ mv boost-1.33.1 boost-onb-1.33.1

Then create a new .orig.tar.gz using boost-onb-1.33.1, and move it back to your working directory tree (thank $DEITY for directory stacks ;). Also copy the expanded boost-onb-1.33.1 tree to the working directory:

  (sarge)$ tar czvf boost-onb_1.33.1.orig.tar.gz boost-onb-1.33.1
  (sarge)$ mv boost-onb_1.33.1.orig.tar.gz ~1/
  (sarge)$ cp -a boost-onb-1.33.1 ~1/
  (sarge)$ popd

By the end of that last command, we should now be back at the working tree (~/debian-pkg/boost), with both the new orig.tar.gz and expanded tree in it. Grab a Coke and rest for a while ;)

Fix Build-Dependencies

Done resting? Ok, get into boost-onb-1.33.1 and apply the Debian-specific patch from the original source package (it should apply cleanly:)

  (sarge)$ cd boost-onb-1.33.1
  (sarge)$ zcat ../boost_1.33.1-5.diff.gz | patch -p1

Once done you should now have a ./debian directory inside boost-onb-1.33.1/ . Now update the debian/control file to reflect the new source package:

  (sarge)$ perl -pe's/^Source:.*boost$/Source?: boost-onb/g' debian/control

Ok, so we're all set. Right? Well, not just yet; as I found out later...

Digression: Backporting `icu'

(Consider this as a large footnote.)

Before we get ourselves to build Boost, we will need to backport the `icu' library from Debian Sid, because the icu in Debian Sarge provides the `libicu28' set of library packages, but for Boost 1.33.1 to work correctly it must be linked against the newer `libicu34' packages. Fortunately for us, Debian Sid already has this available, so backporting this to Sarge is rather straightforward.

First, move somewhere else off the boost working tree:

  (sarge)$ mkdir ~/debian-pkg/icu
  (sarge)$ pushd ~/debian-pkg/icu
  ~/debian-pkg/icu ~/debian-pkg/boost/boost-onb-1.33.1 ~

Then get the `icu' source package (version 3.4.1a-1 as of this writing) via apt-get, cd to the expanded source tree, get the build-dependencies via pbuilder-satisfydepends (you did install `pbuilder', right?) and build the package:

  (sarge)$ apt-get source icu
  (sarge)$ mkdir result
  (sarge)$ cd icu-3.4.1a
  (sarge)$ sudo /usr/lib/pbuilder/pbuilder-satisfydepends
  (sarge)$ pdebuild --buildresult ../result

`pdebuild' may prompt you to enter your user password as it calls `sudo' to unpack the base build environment. Note that in the actual build process, Boost will be compiled under your regular user, and will be packaged under `fakeroot' privileges.

Now go to the result directory, and install the debs:

  (sarge)$ cd ../result
  (sarge)$ sudo dpkg --install libicu34_3.4.1a-1_i386.deb libicu34-dev_3.4.1a-1_i386.deb

You should now have the correct `icu' libraries installed for your chroot. We still need these installed in our pbuilder base, however, so login there and install:

  (sarge)$ sudo pbuilder login --save-after-login --bindmounts /home
  (sarge-pbuilder)# cd /home/zakame/debian-pkg/icu/result
  (sarge-pbuilder)# dpkg --install libicu34_3.4.1a-1_i386.deb libicu34-dev_3.4.1a-1_i386.deb
  (sarge-pbuilder)# exit

By now, we should have the correct `icu' libraries installed in both our dchroot and in our pbuilder.

Now, go back to the boost-onb-1.33.1 working tree and update debian/control to use the new libicu34 set:

  (sarge)$ popd
  ~/debian-pkg/boost/boost-onb-1.33.1 ~
  (sarge)$ perl -ie's/libicu28/libicu34/g' debian/control

Document our Changes

Just before starting to build, update the debian/changelog to reflect our changes. Make sure the source package debian/changelog documents now reflect your new name (in this case, boost-onb:)

  (sarge)$ dch -i

The `dch' tool prepares debian/changelog for appending change notes, and passes it to an external editor (such as vim, if you've set EDITOR=vim .) Make a note about our changes (changing the .orig.tar.gz , and using the new `icu'.)

When you're done, just save the buffer and exit the editor.

Build the Packages

Ok, time for the moment of truth. Make sure you're now on the top build tree, and grab the build-dependencies:

  (sarge)$ pwd
  (sarge)$ sudo /usr/lib/pbuilder/pbuilder-satisfydepends

Now build using `pdebuild':

And grab another Coke, and wait. ;) As already noted above, `pdebuild' may require your user password.

Check the Packages

If the package build is successful, you will find lots of debs in the `../result' directory. Once you have your shell back, go to that directory and find out:

  (sarge)$ pushd ../result
  ~/debian-pkg/boost/result ~/debian-pkg/boost/boost-onb-1.33.1 ~
  (sarge)$ ls *.deb

Got a lot of debs? Now, try installing them all:

  (sarge)$ sudo dpkg --install *.deb

Now try building a Boost app. If it builds and works correctly, congratulations! You've now managed to package Boost 1.33.1 for Debian Sarge!

Deploying the new Boost

Now, since we built all of these packages inside a chroot environment, our next task would be to deploy the new Boost into a pristine Debian Sarge system, and continue our work from there.

A daunting task? No! The fact that we did build Debian packages for Boost and `icu' allows us to surmise that, to deploy, we simply just copy all the built debs over to the target machine:

  (sarge)$ dirs
  ~/debian-pkg/boost/result ~/debian-pkg/boost/boost-onb-1.33.1 ~
  (sarge)$ ssh zak@sarge.zakame.net mkdir -p ~/boost-on-sarge/boost/
  (sarge)$ scp *.deb zak@sarge.zakame.net:~/boost-on-sarge/boost/

Don't forget to copy the new `icu' packages too:

  (sarge)$ pushd ~/debian-pkg/icu/result
  ~/debian-pkg/icu/result ~/debian-pkg/boost/result ~/debian-pkg/boost/boost-onb-1.33.1 ~
  (sarge)$ ssh zak@sarge.zakame.net mkdir -p ~/boost-on-sarge/icu/
  (sarge)$ scp *.deb zak@sarge.zakame.net:~/boost-on-sarge/icu/

Now, get out of the dchroot, dive in to the real Sarge, and install:

  (sarge)$ exit
  $ ssh zak@sarge.zakame.net
  (zak@sarge.zakame.net)$ cd boost-on-sarge
  (zak@sarge.zakame.net)$ find -regex '.*deb$' | xargs sudo dpkg -i

Now, go to dinner :P

BOOST WIKI | RecentChanges | Preferences | Page List | Links List
Edit text of this page | View other revisions
Last edited September 19, 2006 2:51 am (diff)
Disclaimer: This site not officially maintained by Boost Developers