Introduces the concept of Debian packages and describes tools to create them. For more tutorials, see Packaging.

Describes a specific packaging workflow

This page describes one possible workflow to solve a specific problem. Parts of it may inspire you to find a workflow that suits your situation.

For more pages like this, see Packaging.

What is Debian packaging

A Debian package is a collection of files that allow for applications or libraries to be distributed via the Debian package management system. The aim of packaging is to allow the automation of installing, upgrading, configuring, and removing computer programs for Debian in a consistent manner. A Debian specific binary package is a .deb file used to install some software while a source package is .dsc file that can provide us with all of the necessary files to compile or otherwise, build the desired piece of software. The act of producing source packages (.dsc) and binary packages (.deb) usually from an upstream release tarball (.tar.gz) either manually or by using tools such as debmake and dpkg-buildpackage is called Debian packaging.

The main aim of this tutorial is to provide a basic overview of the whole packaging process without missing any important points rather than a detailed tutorial. For a detailed guide see Debian New Maintainer's Guide instead.

Structure of a source package

A source package not only contains the upstream source distribution and options for the Debian package build system but also lists of run-time dependencies and conflicting packages, a machine-readable description of copyright and license information, initial configurations, etc.

A source package in Debian consists of the following:

  1. The upstream (original software source) tarball .tar.gz ending.

  2. A tarball (usually with .debian.tar.gz or .debian.tar.xz ending), with any changes made to upstream source, plus all the files created for the Debian package.

  3. A description file with .dsc ending which has checksums (md5, sha etc) for the above 2 files.

Structure of a binary package: A binary package (.deb) in Debian consists of the following:

  1. debian-binary: version of the deb file format.

  2. control.tar.gz: metadata about the package.

  3. data.tar.gz: data files of the package.

Creating a basic source package

We will take pretty-ms node module as an example.

run this following commands and this should run fine

apt install debmake
cd <replace with unpacked directory>
debmake

Another option is dh_make command from dh-make package

Install the package with apt install dh-make then

cd <replace with unpacked directory> and run dh_make

This is an optional step if you just want to generate the dsc file (for example to build with sbuild command), the next command will also generate the dsc file.

  • Create Debian source package using the following command:

dpkg-source -b .

  • The above command will generate a tarball of the debian folder (<source_package>_<version>.debian.tar.xz and <source_package>_<version>.dsc file in the parent directory).

    debuild -us -uc

   sudo apt install  ../node-pretty-ms_9.2.0-1_all.deb

   dpkg -L node-pretty-ms | grep index.js
   /usr/share/nodejs/pretty-ms/index.js

and

   nodejs -e "require('pretty-ms')"

Make sure index.js is installed in /usr/share/nodejs/pretty-ms and nodejs require command should not give an error.

If you get an error like,

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'parse-ms' imported from <packaging  path>/node-pretty-ms-9.2.0/index.js

Then you may need to make sure the dependency is available in node_modules directory (requirement of ES module imports).

   ln -s /usr/share/nodejs/parse-ms node_modules

Note: This testing / verification step can be different for different packages.

   cd ..
   sudo apt install git-buildpackage
   gbp import-dsc --pristine-tar <source_package>_<version>.dsc

git tag -d debian/<version>

dch -e

cme update dpkg-copyright

Next Steps

See also

This tutorial is based on the following guides:


CategoryPackaging