Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: APT: Rebuilding Package in Debian  (Read 1337 times)

0 Members and 1 Guest are viewing this topic.

akhilt

  • Guest
APT: Rebuilding Package in Debian
« on: March 24, 2018, 04:53:41 am »
Package rebuilding is something easily done in Debian. As SysAdmin, you might find yourself in a spot needed to rebuild a Package, maybe to enable a feature or something.

This exactly I will show you how to do in this post. In this post, I will be using squid3 package.

Adding deb-src to my repository

At first, I need to make sure my repository in /etc/apt/sources.list has deb-src repository part. With this, you can be able to download the source files of packages in a repository. Now in my repository, I have this:

Code: [Select]
deb http://security.debian.org/ stable/updates main contrib non-free
This alone won’t get me the source files of squid3, I need to add the deb-src part, making it look like this:

Code: [Select]
deb http://security.debian.org/ stable/updates main contrib non-free
deb-src http://security.debian.org/ stable/updates main contrib non-free

Save this and run:

Code: [Select]
$ apt update
Now I have added deb-src repository and updated my package list.

Downloading Source Files and Rebuilding

To download source files of squid3:

Code: [Select]
$ sudo apt source squid
After a successful download of source files, I’m going to downloading building dependencies – packages needed to build this package, by running:

Code: [Select]
$ sudo apt build-dep squid3
This should install some packages if they are not installed in your system.

Modifying Package and Rebuilding

Here, for example, I will be enabling a http-violations in squid3 by cd into the package source folder which I just downloaded and edit the file debian/rules. Adding this option --enable-http-violations and save it.

Building

Before building, I will make sure I have devscripts installed.

Code: [Select]
$ sudo apt install devscripts
With installation done, before building I have to cd back into the directory of the source package and then run:

Code: [Select]
$ debuild -uc -us -b
Rebuilding of the package starts, enough debug will be returned to your console which you don’t need to worry about. But when building is done, you see something similar to this at the end:

Code: [Select]
[...]
dh_gencontrol -psquid 
dpkg-gencontrol: warning: package squid: unused substitution variable ${perl:Depends}
dh_md5sums -psquid
dh_builddeb -psquid
dpkg-deb: building package 'squid' in '../squid_3.5.19-1_amd64.deb'.
dh_gencontrol -psquid-dbg 
dh_md5sums -psquid-dbg
dh_builddeb -psquid-dbg
dpkg-deb: building package 'squid-dbg' in '../squid-dbg_3.5.19-1_amd64.deb'.
dh_gencontrol -psquidclient 
dh_md5sums -psquidclient
dh_builddeb -psquidclient
dpkg-deb: building package 'squidclient' in '../squidclient_3.5.19-1_amd64.deb'.
dh_gencontrol -psquid-cgi 
dh_md5sums -psquid-cgi
dh_builddeb -psquid-cgi
dpkg-deb: building package 'squid-cgi' in '../squid-cgi_3.5.19-1_amd64.deb'.
dh_gencontrol -psquid-purge 
dh_md5sums -psquid-purge
dh_builddeb -psquid-purge
dpkg-deb: building package 'squid-purge' in '../squid-purge_3.5.19-1_amd64.deb'.
 dpkg-genchanges --build=any,all >../squid3_3.5.19-1_amd64.changes
dpkg-genchanges: info: binary-only upload (no source code included)
 dpkg-source --after-build squid3-3.5.19
dpkg-buildpackage: info: binary-only upload (no source included)
Now running lintian...
N: 1 tag overridden (1 warning)
Finished running lintian.

Package has been successfully rebuilt and keep in the parent directory. You can now reinstall them using:

Code: [Select]
$ sudo dpkg -i squid3*.deb