In simple words, Debian packaging involves making computer software available for Debian distribution. This allows us to install, uninstall, upgrade or configure the software or package in Debian. This is also informally known as the act of debianizing
a package.
Requirement for Debian Packaging
Debian always has three distributions going for it at any point in time. There is a stable branch which is currently Bullseye, testing which currently is Bookworm and unstable which always will be Sid. Debian packaging must be done in a Debian sid/unstable environment. You can check here for instructions on how to set up sid.
Packaging for Debian
The first step in building a package will be downloading the upstream source package. A source package is a collection(usually an archive file) containing all the files necessary to build and modify a piece of software. A Debian source package usually contains the original source archive(orig.tar.gz), a Debian source control file (.dsc) etc. We can get the upstream source package manually or we can use a tool known as npm2deb. Npm2deb will automatically generate most of the required files and templates making your work so much easier. However, if we want to do it manually, we can take these steps;
Download the upstream source as tarball:
We can do this by going to the git repository of the package. Click on "Releases" usually on the right side of the repository page, and copy the source code(tar.gz) link of the latest release. Run the following command in your terminal("tar.gz link" being the link you just copied). First, install
wget
withsudo apt install wget
.sudo apt install wget wget tar.gz link
Rename the upstream source name to Debian standard using
mv
command:We can rename the source package downloaded by
wget
(runls
command to check) by runningmv source_package <source_package>_<upstream_version>.orig.tar.gz
For example, Let's call our source package "prickles" run;mv prickles-1.3.1.tar.gz prickles_1.3.1.orig.tar.gz
Check here under the heading "Package name" for more information on the Debian naming convention.
Extract the contents of the tarball;
We can do this by running the command;
tar -zxvf prickles_1.3.1.orig.tar.gz
Rename the directory
Again using the
mv
command, rename the directory to<source_package>-<upstream_version>
. Example,prickles-1.3.1
Change into the directory you just created by running
cd prickles-1.3.1
.Run
debmake
to generate the Debian directory. This directory should contain; control, changelog, copyright, and rules files. Using npm2deb generates this automatically and is preferred.Create a Debian source package;
The Debian source package will contain a tarball of the Debian folder
<source_package>_<version>.debian.tar.xz
and<source_package>_<version>.dsc
file in the parent directory. We can create it by running;dpkg-source -b .
Build the binary package by running the following command;
dpkg-buildpackage
Import the package to git in other to track all changes made in the package. This can be done by running;
cd .. gbp import-dsc --pristine-tar prickles_1.3.1.dsc
This command generates a new directory (repository) called
<source_package>
which is git tracked, for exampleprickles
without the version number added to it.Change to the newly created directory by running
cd prickles
Remove the git tag by running the command;
git tag -d debian/<version>
Make your package lintian clean;
Run the command
lintian
and fix all the errors you find. Errors that start withE:
(error) orW:
(warning) must be fixed. Here's an example of fixes to somelintian
complaints you might find. After making a fix, rundebuild
ordpkg-buildpackage
to be sure the errors are fixed.Commit changes to git;
Run
git status
to check for changes staged for commit. Rundebclean
to delete unwanted files generated bydpkg-buildpackage
to avoid committing them. Commit your changes by runninggit commit file_path
, write a simple commit message and save.File ITP;
File an ITP to update the bug number in
debian/changelog
. Npm2deb normally generates a template in../prickles_itp.mail
directory.Build your package in a clean environment;
You can do this by using
sbuild
to build the package in a clean environment. Check here for instructions on how to set upsbuild
.Run tests if available;
Run
autopkgtest
. You can set this up by following the instructions in the README.md file of the scripts created by the Debian ruby team. Clone the repo, change into the directory and run the setup by running the command./setup
. Then you can run the test by running~/meta/test
Push the repo to salsa;
Once sbuild builds successfully and autopkgtest passes, you can push the package to a salsa repo in
salsa.debian.org
. Push by running the commandgit push --all --follow-tags
File a Request for Sponsorship(RFS)
Send a mail to request sponsorship for your package. Check here for more details and here for a sample mail.
Reference;
Further reading;