GNU/Linux Desktop Survival Guide
by Graham Williams |
|||||
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 |
Install dependencies:
$ 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) |
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 |
$ fakeroot dpkg-buildpackage -b -uc -us |
$ cd .. $ wajig install most_4.9.5-1_i386.deb |