<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>tolaris.com &#187; pbuilder</title>
	<atom:link href="http://www.tolaris.com/tag/pbuilder/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tolaris.com</link>
	<description>When the going gets tough, the tough sniff packets.</description>
	<lastBuildDate>Tue, 24 Jan 2012 17:47:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Adding a local respository to pbuilder</title>
		<link>http://www.tolaris.com/2009/04/09/adding-a-local-respository-to-pbuilder/</link>
		<comments>http://www.tolaris.com/2009/04/09/adding-a-local-respository-to-pbuilder/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 13:46:33 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[pbuilder]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=321</guid>
		<description><![CDATA[I recently posted about backporting packages with pbuilder. Someone asked about forward porting PHP4, which is a huge task. PHP4 is out of date, and the entire set of PHP4 libraries has a lot of build dependencies, including some packages you must build yourself. I&#8217;m not going to take you through the process of backporting [...]]]></description>
			<content:encoded><![CDATA[<p>I recently posted about <a href="/2009/03/31/backporting-debian-packages-with-pbuilder">backporting packages with pbuilder</a>.  Someone asked about forward porting PHP4, which is a huge task.  PHP4 is out of date, and the entire set of PHP4 libraries has a lot of build dependencies, including some packages you must build yourself.  I&#8217;m not going to take you through the process of backporting PHP4.  If you really need it, you can install php4-cgi and php4-* from Ubuntu dapper directly on hardy.  But I will show you how to enable a local repository in pbuilder.  This will allow you to build a package with pbuilder, and then use that package to satisfy any build-dependencies that other packages need.</p>
<p><span id="more-321"></span>First, see my <a href="/2009/03/31/backporting-debian-packages-with-pbuilder">previous post</a> and set up pbuilder using the .pbuilderrc there.  Now, add the following lines to the bottom of that file.</p>
<pre># use previously built packages as local respository
BINDMOUNTS="$BUILDRESULT"
OTHERMIRROR="deb file:$BUILDRESULT ./"

# create local repository if it doesn't already exist,
# such as during initial 'pbuilder create'
if [ ! -d $BUILDRESULT ] ; then
        mkdir -p $BUILDRESULT
        # set permissions so I can delete files
        chgrp admin $BUILDRESULT
        chmod g+rwx $BUILDRESULT
fi
if [ ! -e $BUILDRESULT/Packages ] ; then
        touch $BUILDRESULT/Packages
fi
if [ ! -e $BUILDRESULT/Release ] ; then
        cat << EOF > $BUILDRESULT/Release
Archive: $DIST
Component: main
Origin: pbuilder
Label: pbuilder
Architecture: $ARCH
EOF

fi</pre>
<p>These additions will cause pbuilder to add a new apt repository to each newly pbuilder base image, bind that repository into the chroot filesystem of the pbuilder environment, and create the initial apt files necessary for a basic local apt repository.  This repository will be your normal result directory, where pbuilder puts completed .deb files after building, such as /var/cache/pbuilder/hardy-amd64/result/.</p>
<p>I also find it convenient for my user to be able to delete files from /var/cache/pbuilder/hardy-amd64/result/ without sudo, so the above script adds write permission for the &#8220;admin&#8221; group (which you probably are, if you have sudo access) to that directory.</p>
<p>Any new pbuilder base images made with <code>sudo pbuilder create</code> will use the new settings above.  However, if you&#8217;ve previously created an image you&#8217;ll need to update it before proceeding.</p>
<p><code>sudo pbuilder update --override-config</code></p>
<p>Now, we need to update the /var/cache/pbuilder/hardy-amd64/result/Packages file every time we build a package.  For this, we need to use a hook script.  Create a script in $HOME/.pbuilder-hooks called D10apt-ftparchive, and make it executable.</p>
<p><code>touch $HOME/.pbuilder-hooks/D10apt-ftparchive<br />
chmod a+x $HOME/.pbuilder-hooks/D10apt-ftparchive</code></p>
<p>The script should contain:</p>
<pre>#!/bin/bash
# 2009-04-09 tyler - use previously built packages as an apt source
# http://blog.edseek.com/~jasonb/articles/pbuilder_backports/pbuilderbuild.html#pbuilderhook

echo Calling $0

: ${DIST:=$(lsb_release --short --codename)}
: ${ARCH:=$(dpkg --print-architecture)}
NAME="$DIST-$ARCH"
BUILDRESULT="/var/cache/pbuilder/$NAME/result/"

# create apt archive of previously built packages
( cd $BUILDRESULT ; apt-ftparchive packages . > $BUILDRESULT/Packages )

# see ~/.pbuilderrc for creation of $BUILDRESULT/Release

apt-get update</pre>
<p>Now each time we call <code>sudo pbuilder build package.dsc</code>, pbuilder will first update /var/cache/pbuilder/hardy-amd64/result/Packages with the contents of whatever packages are already there.</p>
<p>As an added bonus, this allows you to satisfy build-dependencies that may be provided by hardy-backports or hardy-updates (but which aren&#8217;t in plain hardy, which is all that pbuilder uses).  For instance, &#8220;debhelper >= 7&#8243; is often required for packages in intrepid or jaunty.  Stock hardy only offers debhelper 6, but hardy-backports contains debhelper 7.  So just download that .deb file, copy it to /var/cache/pbuilder/hardy-amd64/result/, and build your package.</p>
<p>pbuilder will display a warning message when using packages in your local repository, but will build anyway.</p>
<pre>WARNING: untrusted versions of the following packages will be installed!

Untrusted packages could compromise your system's security.
You should only proceed with the installation if you are certain that
this is what you want to do.

  debhelper

*** WARNING ***   Ignoring these trust violations because
                  aptitude::CmdLine::Ignore-Trust-Violations is 'true'!</pre>
<p>You can now build packages and meet dependencies from your local archive.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2009/04/09/adding-a-local-respository-to-pbuilder/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Backporting Debian packages with pbuilder</title>
		<link>http://www.tolaris.com/2009/03/31/backporting-debian-packages-with-pbuilder/</link>
		<comments>http://www.tolaris.com/2009/03/31/backporting-debian-packages-with-pbuilder/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 19:04:19 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[pbuilder]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=254</guid>
		<description><![CDATA[I frequently need to package software for install on Ubuntu systems. If you manage only one server, don&#8217;t upgrade often, and don&#8217;t need to uninstall, then you may be happy with the ancient &#8220;untar, make, make install&#8221; method. But if you&#8217;re like me you prefer to create .deb packages and install those. I run Ubuntu [...]]]></description>
			<content:encoded><![CDATA[<p>I frequently need to package software for install on Ubuntu systems.  If you manage only one server, don&#8217;t upgrade often, and don&#8217;t need to uninstall, then you may be happy with the ancient &#8220;untar, make, make install&#8221; method.  But if you&#8217;re like me you prefer to create .deb packages and install those.</p>
<p>I run Ubuntu 8.04 &#8220;hardy&#8221; on my servers.  Hardy is almost a year old now, and although it has up to date security fixes it no longer has the latest releases of software.  This is fine for most purpose, but sometimes I want an updated version of some software and I&#8217;m willing to risk the slight chance that it has bugs.</p>
<p>The best traceroute tool around is <a href="http://www.bitwizard.nl/mtr/">mtr</a>.  The version in Hardy is 0.72, but Jaunty now has a package for 0.75.  So let&#8217;s backport it with <a href="http://www.netfort.gr.jp/~dancer/software/pbuilder.html.en">pbuilder</a>.</p>
<p><span id="more-254"></span>pbuilder is by far the easiest way to backport existing packages to older releases.  The Ubuntu wiki provides an excellent <a href="https://wiki.ubuntu.com/PbuilderHowto">pbuilder HowTo</a>.  If you want to know more about Debian packages, I also advise you to read the <a href="https://wiki.ubuntu.com/PackagingGuide/Complete">Ubuntu Packaging Guide</a>.</p>
<p>Install pbuilder:</p>
<p><code>apt-get install pbuilder</code></p>
<p>Now configure it to support multiple distributions.  This means you can build packages for Dapper, Hardy, Debian Lenny, whatever; and you can build i386 packages on amd64.  Here is my ~/.pbuilderrc:</p>
<pre># 2008-08-13 tyler
# support building multiple distributions and architectures

: ${DIST:=$(lsb_release --short --codename)}
: ${ARCH:=$(dpkg --print-architecture)}
NAME="$DIST-$ARCH"
DISTRIBUTION="$DIST"
DEBOOTSTRAPOPTS=("--arch" "$ARCH" "${DEBOOTSTRAPOPTS[@]}")
BASETGZ="`dirname $BASETGZ`/$NAME-base.tgz"
BUILDRESULT="/var/cache/pbuilder/$NAME/result/"
APTCACHE="/var/cache/pbuilder/$NAME/aptcache/"
# Don't rebuild source files (.diff.gz, .dsc), or list them in .changes
# See Ubuntu bug 118181
DEBBUILDOPTS="-b"

case "$DIST" in
    karmic|jaunty|intrepid|hardy|dapper) # ubuntu specific
        MIRRORSITE="http://archive.ubuntu.com/ubuntu/"
        COMPONENTS="main restricted universe multiverse"
        ;;
    sid|squeeze|lenny|etch) # debian specific
        MIRRORSITE="http://mirrors.kernel.org/debian/"
        COMPONENTS="main contrib non-free"
        ;;
    *)
        echo "Unknown distribution: $DIST"
        exit 1
        ;;
esac

HOOKDIR=$HOME/.pbuilder-hooks</pre>
<p>Now create your initial pbuilder root images.  This will create a .tar.gz of a basic root image of that distribution, which pbuilder unpacks each time it builds packages.  Do this once for each distribution and architecture for which you want to build.  You select these with the DIST and ARCH environment variables.</p>
<p>The following builds environments for Hardy on amd64 and i386, and dapper on i386.</p>
<p><code>sudo DIST=hardy ARCH=amd64 pbuilder create<br />
sudo DIST=hardy ARCH=i386 pbuilder create<br />
sudo DIST=dapper ARCH=i386 pbuilder create</code></p>
<p>I run Hardy amd64 on my laptop, so I can run the first command without specifying DIST or ARCH.</p>
<p><code>sudo pbuilder create</code></p>
<p>You only need do the above once for each distribution/architecture combination you intend to support.  You do not need to do it each time you build packages.</p>
<p>We are now ready to build mtr packages.  Check the <a href="http://packages.ubuntu.com/search?searchon=names&#038;keywords=mtr">Ubuntu package archives for mtr</a>.  Note the updated mtr version for <a href="http://packages.ubuntu.com/jaunty/mtr">Jaunty</a>.</p>
<p>Load the Jaunty mtr page, and look on the left side of the page where is says &#8220;Download Source Package mtr&#8221;.  Download the three files there, ending in .dsc, orig.tar.gz, and .diff.gz.  Alternatively, right-click on the .dsc and &#8220;Copy Link Location&#8221;, and use the dget command (install the &#8220;devscripts&#8221; package:</p>
<p><code>dget http://archive.ubuntu.com/ubuntu/pool/main/m/mtr/mtr_0.75-2.dsc</code></p>
<p>This will download the three needed files to the current directory.  We&#8217;re now ready to build mtr with pbuilder.</p>
<p>sudo pbuilder build mtr_0.75-2.dsc</p>
<p>Or for another distribution and architecture:</p>
<p>sudo DIST=dapper ARCH=i386 pbuilder build mtr_0.75-2.dsc</p>
<p>pbuilder will now unpack the base tarball it created in /var/cache/pbuilder/hardy-amd64-base.tgz, download any packages mtr needs, and compile it, and create the .deb files.  Here is my <a href='http://www.tolaris.com/blog/wp-content/uploads/2009/03/pbuilder-mtr.txt'>pbuilder mtr build log</a>.</p>
<p>Results will be copied to /var/cache/pbuilder/DIST-ARCH/result.</p>
<pre>tyler@baal:~$ ls /var/cache/pbuilder/hardy-amd64/result/
mtr_0.75-2_amd64.changes
mtr_0.75-2_amd64.deb
mtr_0.75-2.diff.gz
mtr_0.75-2.dsc
mtr_0.75.orig.tar.gz
mtr-tiny_0.75-2_amd64.deb</pre>
<p>Now install .deb file, and you&#8217;re done!</p>
<p>mtr 0.75 for Ubuntu Hardy is now in the <a href="/apt-repository/">repository</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2009/03/31/backporting-debian-packages-with-pbuilder/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

