6.28 Building Source Packages
You can download the source code for any Debian package from the Debian archive. You can then modify it, if you wish, and then generate your own deb file for installation. Or perhaps, like Gentoo, you are interested in building the package with your local compilation optimisations to suit your system specifically. This is all quite easy with Debian.
The steps involved include: Install dependencies; Obtain the source; Unpack the source; Apply the patches; Compile the source code; Build the Debian package.
A use case here was that gnome-shell had been updated to 3.36.3 but not yet available for the specific release:
$ wajig builddeps gnome-shell $ wget http://archive.ubuntu.com/ubuntu/pool/main/g/gnome-shell/gnome-shell_3.36.3.orig.tar.xz $ wget http://archive.ubuntu.com/ubuntu/pool/main/g/gnome-shell/gnome-shell_3.36.3-1ubuntu2.debian.tar.xz $ tar xvf gnome-shell_3.36.3.orig.tar.xz $ cd gnome-shell_3.36.3 $ tar xvf ../gnome-shell_3.36.3-1ubuntu2.debian.tar.xz $ dpkg-buildpackage -us -uc -nc $ cd .. $ wajig install gnome-shell_3.36.3-1ubuntu2_amd64.deb gnome-shell-common_3.36.3-1ubuntu2_all.deb gnome-shell-extension-prefs_3.36.3-1ubuntu2_amd64.deb
$ wajig builddeps <package-name> (apt-get source
Sources should be specified in
/etc/apt/sources.list with the
appropriate deb-src lines:
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted
Obtain and unpack the source Debian package:
$ wajig source <package names> (apt-get source)
This will download tar.gz (source code), dsc (test packaging), and possibly diff (patches). It then extracts the source code into a subdirectory of the package name and version, and applies the patches.
The patching can be reversed:
$ zcat <pkg>_<version>.diff.gz | patch -R -p0
To go one step further and also configure and compile the package, and then generate a default Debian deb package from the source code then use:
$ wajig build <package names> (apt-get source -b)
This will allow you to apply any optimisations during the compilation
process to suit your own environment. This is similar to
Gentoo, allowing for automatic
optimisation and customisation to suit the user. To tune the build
edit the file
If you need to modify the source to the package (e.g., the package most) in some way and thus need to rebuild the deb package, the steps would be:
$ wajig update $ wajig source most $ cd most_4.9.5
Now modify the source code to your own liking, then generate the Debian package with:
$ fakeroot dpkg-buildpackage -b -uc -us
This leaves a new
most_4.9.5-1_i386.deb in the parent
directory, and you can install it directly:
$ cd .. $ wajig install most_4.9.5-1_i386.deb
Your donation will support ongoing development and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.