Kali Linux

How To Rebuild a Source Package In Kali Linux

Even though it’s customized explicitly for penetration testing, Kali Linux is a flexible and highly customizable Linux distro. It allows you to customize things like the Desktop environment, packages, and even the kernel as long as you know what you are doing,

Let’s discuss how we can modify installed packages and rebuild them from the source.

NOTE: Before we begin, you will need to include the source deb-src package URIs in the sources.list file.

Adding deb-src Packages

To add the deb-src package in Kali Linux sources.list file, edit the file in /etc/apt/sources.list and uncomment the deb-src line.

Next, update your source packages before proceeding.

NOTE: Ensure you have the dpkg-dev package installed.

Downloading Source Packages

The next step is to download the source package. For this example, we will use vim. Run the commands:

sudo apt-get update
sudo apt source vim

Next, navigate to the vim source package directory

cd vim-8.2.2434/

 Modify Package Source Code

The next step is to make changes to the source code as you see fit. I will not get into details because this will depend on the package you are modifying and your targeted needs.

sudo nano src/vimrun.c

Once you have made your appropriate modifications, save and close the file.

Check for Build Dependencies

Before rebuilding the source packages, you need to install the package dependencies. You can check the required dependencies using the command:

dpkg-checkbuilddeps

Running this command will display all the required dependencies before rebuilding the package. The result will be empty if no dependencies are required. For vim, you’ll see an output similar to the one shown below:

dpkg-checkbuilddeps: error: Unmet build dependencies: autoconf cscope debhelper-compat (= 12) libacl1-dev libcanberra-dev libgpmg1-dev libgtk-3-dev liblua5.2-dev libperl-dev libselinux1-dev libncurses-dev libtool-bin libxaw7-dev libxpm-dev libxt-dev lua5.2 python3-dev ruby-dev tcl-dev docbook-utils docbook-xml ghostscript pdf2svg

Installing Build Dependencies

Once you have the list of required dependencies, simply use apt to install them as:

sudo apt-get install autoconf cscope debhelper-compat libacl1-dev libcanberra-dev libgpmg1-dev libgtk-3-dev liblua5.2-dev libperl-dev libselinux1-dev libncurses-dev libtool-bin libxaw7-dev libxpm-dev libxt-dev lua5.2 python3-dev ruby-dev tcl-dev docbook-utils docbook-xml ghostscript pdf2svg -y

 Building the Source Package

After fulfilling the required dependencies and saving the new source package changes, you can build the new package.

Use the command below to build the new package.

dpkg-buildpackage

Installing New Package

Once the build completes successfully, you should have a .deb package that you can install using dpkg.

sudo dpkg –i ../vim-???.deb

 Conclusion

This quick guide has shown you how to source, modify, and rebuild packages in Kali Linux. Rebuilding packages can be very useful when you want a customized version of a tool.

Thank you for reading.

About the author

John Otieno

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list