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 source vim
Next, navigate to the vim source package directory
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.
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:
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:
Installing Build Dependencies
Once you have the list of required dependencies, simply use apt to install them as:
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.
Installing New Package
Once the build completes successfully, you should have a .deb package that you can install using dpkg.
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.