sbuild: create powertop deb package from source

Last time we where installing our sbuild-based build environment (here). Now let’s build powertop from source (github).

It is mandatory to create the sbuild based buildenvironment first before proceeding!

Let’s go

Create a directory where the build will happen and the deb will be put into:

$ mkdir ~/powertop
$ cd ~/powertop

Sbuild needs debian-folders which contains patches, controlfiles and other information on how to build the sources. I got one for powertop here.

Extract that file:

$ tar xzf powertop-debian.tar.gz

That will lead to a debian folder.

Now let’s get the sources as a *.orig.tar.gz file:

$ wget -O "powertop_2.8.orig.tar.gz" ""
$ tar xzf powertop_2.8.orig.tar.gz

Change into that directory and copy the debian folder from the previous step into the current folder:

$ cd powertop-2.8
$ cp -r ../debian .

Lets update the changelog file to issue a non-maintainer build:

$ debchange \
    --newversion="2.8-1" \
    --distribution=stable \
    --maintmaint \
    "Non-Maintainer Build. The full changelog can be found at"

And invoke sbuild with a few parameters to build powertop from source using the debian folder which contains further information (like package dependencies) on how exactly to compile powertop:

$ sbuild \
    --jobs=2 --build-path=/build/powertop-2.8 \
    --no-apt-clean --no-apt-update --no-apt-upgrade --no-apt-distupgrade --nolog \
    --verbose --arch-all \
    --chroot=jessie-amd64-sbuild --dist=jessie --source

That’s it. Leave that src-folder:

$ cd ../

We now have a deb package of powertop:

$ ls *.deb
powertop_2.8-1_amd64.deb  powertop-dbg_2.8-1_amd64.deb

We can now put those files into our own repository and use the usual apt-get update/install or directly install/test that package using dpkg:

$ dpkg -i powertop_2.8-1_amd64.deb

Look’s complicated! Why not ./configure && make && make install ?

See my post here.

Benefits from using sbuild and not the configure/make way:

  • no need to install several gigs of lib…-dev packages on my workstation that is not primarily a developer buildmachine but more like a desktop-thingy.
  • my apt-cache is not getting spammed with installed lib…-dev packages.
  • improved performance because of apt-cache, eatmydata and ccache.
  • sbuild will install all missing dependencies (see debian/control file) so i don’t have to.
  • after each build all modifications in the build-environment get flushed away which is good
  • further builds are more predictable because we start with a debian minimal and no leftovers of previous builds exist.
  • using make will not create a deb package.
  • using make install will directly install that software on your system, you cannot simply remove those installed files, apt-get remove is not possible. One must use fakeroot or issue some environment variable like INSTALL_DIR before calling make install which is a weird way of doing such things.
  • using sbuild you can target other machines, architectures, releases, etc. Example: i have a stock debian-8-jessie-amd64 and can build my packages against an older wheezy or a newer debian-testing or even a i386 crossbuild without that much trouble.

I could go on and on…

Great, where can i get those debian folders from?

In this powertop related example see Grab the debian-file on the right side. Patch it to reflect the proper dependencies (like the minimal libc version or the minimal required gtk3 version).

Or create your own debian-folder with a specific control file. It’s not that complicated. Also read the debian package mainter guide for more information.

Tip #1

I maintain a subversion based code repository with some sbuild-based build-scripts for most of the desktop-software i need on a daily basis:

  • complete cinnamon desktop environment with nemo filemanager
  • darktable
  • linux-kernel
  • gimp 2.9
  • libreoffice
  • several libraries needed for the programs above

This really simplyfies building new deb-packages as i just need to execute my ./ in the programs folder and it then downloads the latest source package (from git or other sites), retrieves the corresponding original debian-folder (or uses my patched one) and issues the sbuild-command.

Tip #2

One can inject further sbuild build dependencies by using


which otherwise are optional and not installed by sbuild by default.

And then there is the –extra-package statement which installs specified packages in the sbuild-chroot-environment before building the sources:

--extra-package=/full/path/to/libflickcurl-dev_*.deb \

That in particular is useful when a package X (x.deb) we want to build depends on the existance (must be installed in the sbuild chroot) of another package (Y.deb) (in a specific version) which we previously built but did not put on our repository server yet as we are still building the software as a whole (Software X plus the required new version of library Y).