<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    
    <title>Kathenas - Advanced</title>
    <link>https://blog.kathenas.org/</link>
    <description>Development, Engineering, Software, Hardware, Freedom and Openness</description>
    <dc:language>en</dc:language>
    <admin:errorReportsTo rdf:resource="mailto:philip.wyett@kathenas.org" />
    <generator>Serendipity 2.5.0 - http://www.s9y.org/</generator>
    <pubDate>Sun, 03 Aug 2025 07:02:47 GMT</pubDate>

    <image>
    <url>https://blog.kathenas.org/kathenas_logo_text_gold.png</url>
    <title>RSS: Kathenas - Advanced - Development, Engineering, Software, Hardware, Freedom and Openness</title>
    <link>https://blog.kathenas.org/</link>
    <width></width>
    <height></height>
</image>

<item>
    <title>Debian - Installing and using pbuilder</title>
    <link>https://blog.kathenas.org/index.php?/archives/11-Debian-Installing-and-using-pbuilder.html</link>
            <category>Advanced</category>
            <category>Debian</category>
            <category>Difficulty</category>
            <category>OS</category>
            <category>Ubuntu</category>
    
    <comments>https://blog.kathenas.org/index.php?/archives/11-Debian-Installing-and-using-pbuilder.html#comments</comments>
    <wfw:comment>https://blog.kathenas.org/wfwcomment.php?cid=11</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>https://blog.kathenas.org/rss.php?version=2.0&amp;type=comments&amp;cid=11</wfw:commentRss>
    

    <author>philip.wyett@kathenas.org (Phil Wyett)</author>
    <content:encoded>
    Though &lt;strong&gt;sbuild&lt;/strong&gt; is the primary build agent for Debian, &lt;strong&gt;pbuilder&lt;/strong&gt; is still very popular and has some features yet to be found in &lt;strong&gt;sbuild&lt;/strong&gt;, the &lt;strong&gt;--twice&lt;/strong&gt; switch for example.&lt;br /&gt;
&lt;br /&gt;
This tutorial will detail the installation, configuration and use of &lt;strong&gt;pbuilder&lt;/strong&gt;.&lt;br /&gt;
&lt;br /&gt;
First we install &lt;strong&gt;pbuilder.&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;sudo apt install pbuilder&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Now we will generate the pbuilder base system tarball for Debian &lt;strong&gt;unstable&lt;/strong&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;sudo pbuilder create --debootstrapopts --variant=buildd --distribution unstable&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
That simple... Let&#039;s build a package.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;dget https://deb.debian.org/debian/pool/main/d/ddcutil/ddcutil_2.2.0-2.dsc&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;sudo pbuilder build ddcutil_2.2.0-2.dsc&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
The build should complete with success. Let&#039;s check below.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;ls -1 /var/cache/pbuilder/result/&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;philwyett@debian:~$ ls -1 /var/cache/pbuilder/result/&lt;br /&gt;
ddcutil_2.2.0-2_amd64.buildinfo&lt;br /&gt;
ddcutil_2.2.0-2_amd64.changes&lt;br /&gt;
ddcutil_2.2.0-2_amd64.deb&lt;br /&gt;
ddcutil_2.2.0-2.debian.tar.xz&lt;br /&gt;
ddcutil_2.2.0-2.dsc&lt;br /&gt;
ddcutil_2.2.0-2_source.changes&lt;br /&gt;
ddcutil-dbgsym_2.2.0-2_amd64.deb&lt;br /&gt;
libddcutil5_2.2.0-2_amd64.deb&lt;br /&gt;
libddcutil5-dbgsym_2.2.0-2_amd64.deb&lt;br /&gt;
libddcutil-dev_2.2.0-2_amd64.deb&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Updating your base system tarball&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
To update your the &lt;strong&gt;pbuilder&lt;/strong&gt; base system tarball with the latest package versions, you can simply run the command below.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;sudo pbuilder update&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
These are the basics.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Building the package for i386&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
First we clean up after our previous build.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;sudo pbuilder clean all&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;sudo rm -f /var/cache/pbuilder/result/*&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Now we remove our previously generated &lt;strong&gt;unstable&lt;/strong&gt; base.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;sudo rm -f /var/cache/pbuilder/base.tgz&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Now we will generate our &lt;strong&gt;unstable i386&lt;/strong&gt; base system tarball.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;sudo pbuilder create --debootstrapopts --variant=buildd --distribution unstable --architecture i386&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Let&#039;s now do the &lt;strong&gt;i386&lt;/strong&gt; build of the package we previously built.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;sudo pbuilder build ddcutil_2.2.0-2.dsc&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
The build should complete with success. Let&#039;s check below.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;ls -1 /var/cache/pbuilder/result/&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
&lt;br /&gt;
philwyett@debian:~$ ls -1 /var/cache/pbuilder/result/&lt;br /&gt;
ddcutil_2.2.0-2.debian.tar.xz&lt;br /&gt;
ddcutil_2.2.0-2.dsc&lt;br /&gt;
ddcutil_2.2.0-2_i386.buildinfo&lt;br /&gt;
ddcutil_2.2.0-2_i386.changes&lt;br /&gt;
ddcutil_2.2.0-2_i386.deb&lt;br /&gt;
ddcutil_2.2.0-2_source.changes&lt;br /&gt;
ddcutil-dbgsym_2.2.0-2_i386.deb&lt;br /&gt;
libddcutil5_2.2.0-2_i386.deb&lt;br /&gt;
libddcutil5-dbgsym_2.2.0-2_i386.deb&lt;br /&gt;
libddcutil-dev_2.2.0-2_i386.deb&lt;br /&gt;
&lt;br /&gt;
As simple as that.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Build after successful build&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
As you explore Debian and look at more bug reports you will see bugs that are failures to build after successful build. With &lt;strong&gt;pbuilder&lt;/strong&gt; we can use the &lt;strong&gt;--twice&lt;/strong&gt; switch and attempt to do two builds back to back. We do this with the command below.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;sudo pbuilder build --twice ddcutil_2.2.0-2.dsc&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Try it for yourself.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Building using local packages&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
On occasion you may need to build a package that depends on one or more packages that is not yet in Debian. To do this we need to some additional configuration.&lt;br /&gt;
&lt;br /&gt;
Add a file called &lt;strong&gt;.pbuilderrc&lt;/strong&gt; to your &lt;strong&gt;HOME&lt;/strong&gt; directory.&lt;br /&gt;
&lt;br /&gt;
In the new &lt;strong&gt;.pbuilderrc&lt;/strong&gt; add the text below and save the file.&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# The hook dir may already be set/populated!&lt;br /&gt;
#&lt;br /&gt;
HOOKDIR=&quot;$HOME/.config/pbuilder/hooks/&quot;&lt;br /&gt;
if [ -n &quot;$DEPS&quot; ] ; then&lt;br /&gt;
        export DEPSBASE=/var/cache/pbuilder/local_packages&lt;br /&gt;
        BINDMOUNTS=$DEPSBASE&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
The folder &lt;strong&gt;/var/cache/pbuilder/local_packages&lt;/strong&gt; is my personal base directory to use, but you may change it to whatever you wish. For now we will create this directory.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;sudo mkdir -p /var/cache/pbuilder/local_packages&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
We next create a directory for the packages as below, you may name it as you wish.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;sudo mkdir -p /var/cache/pbuilder/local_packages/kathenas&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Next we create the necessary hook.&lt;br /&gt;
&lt;br /&gt;
Create the following directory.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;mkdir -p ~/.config/pbuilder/hooks&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
In the above directory create the file named &lt;strong&gt;D05deps&lt;/strong&gt;.&lt;br /&gt;
&lt;br /&gt;
In the file &lt;strong&gt;D05deps&lt;/strong&gt; add the text below and save the file.&lt;br /&gt;
&lt;br /&gt;
DEPSPATH=&quot;$DEPSBASE/$DEPS&quot;&lt;br /&gt;
if [ -n &quot;$DEPS&quot; ] &amp;&amp;amp; [ -d &quot;$DEPSPATH&quot; ] ; then&lt;br /&gt;
        apt install --assume-yes apt-utils&lt;br /&gt;
        ( cd &quot;$DEPSPATH&quot;; apt-ftparchive packages . &gt; Packages )&lt;br /&gt;
        echo &quot;deb [trusted=yes] file://$DEPSPATH ./&quot; &gt;&gt; /etc/apt/sources.list&lt;br /&gt;
        apt update&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
We must make this hook file executable. This can be done with the command below.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;chmod +x ~/.config/pbuilder/hooks/D05deps&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Now we are able to build packages with local dependencies:&lt;br /&gt;
&lt;br /&gt;
1. Build the package you wish to use that is not in Debian.&lt;br /&gt;
2. Copy the &lt;strong&gt;.deb&lt;/strong&gt; files from &lt;strong&gt;/var/cache/pbuilder/result&lt;/strong&gt; to &lt;strong&gt;/var/cache/pbuilder/local_packages/kathenas&lt;/strong&gt;&lt;br /&gt;
3.Build your package now using the dependencies in &lt;strong&gt;/var/cache/pbuilder/local_packages/kathenas&lt;/strong&gt; using the reference command below.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;sudo -E DEPS=kathenas pbuilder build PACKAGE_NAME_AND_VERSION.dsc&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
I hope you find this tutorial useful and have a good rest of your day.&lt;br /&gt;
&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Tue, 15 Jul 2025 03:59:00 +0100</pubDate>
    <guid isPermaLink="false">https://blog.kathenas.org/index.php?/archives/11-guid.html</guid>
    
</item>

</channel>
</rss>
