The Debian package distributes the software effectively and efficiently in the Linux or Debian-based distributions. It automatically manages the applications with their source code, configuration files, Deb files, etc. to install the applications on the system. The Deb file in the Debian like Operating systems is like execution or .exe file for Windows to install the software or application on your system.
This guide will explain the process of building a Debian package in the Debian 12 system.
How to Build a Debian Package
To build the Debian package, simply login to the Debian system and open its terminal to update its apt package. After that, install the “devscripts” from the “dpkg” tool to add the source links to the system and the “proftpd-basic” package. Now, edit the packages before building them on the system using the “build-dep” command. To learn the process in detail, simply go through the following steps:
Step 1: Setting Prerequisites
First, update the APT package manager to store the latest software or packages on the repository using the following command:
sudo apt update
Running the above command displays that all the packages are up to date as mentioned below:
After that, install the “dpkg-dev devscripts” from the APT package manager with the command mentioned below. The “devscripts” contain all the basic scripts to build the packages and are useful for Debian developers:
sudo apt install dpkg-dev devscripts
Running the above command installs the devscripts from the updated APT package manager as displayed in the following snippet:
Step 2: Edit Package From Source
We need to edit the “sources.lists” file to add the Debian sources in the APT package and use them to get and build the packages. For that, open the “sources.list” file from the apt directory in the nano text editor using the following command:
nano /etc/apt/sources.list
Executing the above command opens the “sources.list” files in the text editor as mentioned below. Now, simply edit the file by removing the “#” from the “deb-src” line to uncomment them as highlighted in the following screenshot:
After editing the sources.list file, simply save the file using the “Ctrl + s” and exit the editor using the “Ctrl + x” from the keyboard:
After that, simply update the APT package to get the uncommented lists from the sources file included in the APT packages:
sudo apt update
Step 3: Get Debian Source Package
Once we get the Debian sources added to the APT package, simply get the “proftpd-basic” package using the following command. The ProFTPD is an opensource and free software containing different packages and directories for building the Debian packages:
apt source proftpd-basic
After getting the packages, simply get the list of all the packages using the “ls” command:
ls
Running the above command displays the list of packages available in the root directory as shown in the following screenshot:
Step 4: Edit Source Package
After that, head inside the “proftpd-dfsg-1.3.8+dfsg” directory using the “cd” command:
cd proftpd-dfsg-1.3.8+dfsg
Inside the directory, use the following command with the build-dep to search the “proftpd-basic” package from the local repository. After getting the package it simply installs the build dependency for building the Debian package:
sudo apt build-dep proftpd-basic
From the directory, open the “data.c” file from the “src” directory using the following command:
nano src/data.c
Edit the files to set the configuration highlighted in the following screenshot and if it is already configured simply ignore this step:
Step 5: Build Debian Package
After configuring the src file, simply build the Debian package using the “buildpackage” command from the dpkg tool. Use the “-rfakeroot” flag so the Debian package can be used to install applications on the system. Some more flags are required to build the package like “-b” to build the binary package only and use the “-uc” and “-us” flags to remove the cryptographic or source signs:
dpkg-buildpackage -rfakeroot -b -uc -us
Running the above command takes a few moments to build the Debian package as displayed in the following screenshot:
The Debian package has been build successfully with binary packages only with the source code or source files:
Step 6: Build Successful
Once the package is built, simply get out of the directory to get back to the root directory using the following command:
cd ..
From the root directory, simply use the ls command to get the list of all the Debian packages built on the Debian system:
ls
The following screenshot displays the list of all the Debian packages built using the “proftpd-basic” package source:
That’s all about the process of building the Debian package in the Debian-based operating system.
Conclusion
To build the Debian package in Debian, update the APT packages to get the updated ProFTPD packages and configure its source file before building. After that, get inside the ProFTPD directory to configure the source files and then build the Debian package from there. After building the package, simply head back to the root directory to get the list of all the Debian packages. Now, building the packages is useful as you can install and use them on your system whenever you need them.