This blog post will cover some basics about debian package names and version strings, and how to build debian packaging boilerplate using
dh_make to streamline the creation of packages.
Install the packaging essentials
Understanding the package name and version
Let’s assume we have an upstream source with the archive name of
newprogram-0.12.7.tar.gz. We’ll use
newprogram as the package name and
0.12.7 as the upstream version.
It’s important to remember the following about package names:
- Consists of only lower case letters (a-z), digits (0-9), plus (+) and minus (-) signs, and periods (.)
- Must be at least two (2) characters long
- Must start with an alphanumeric character
- Recommended to be less than 30 characters, if possible.
and upstream versions:
- Must start with a digit (0-9)
- Must consist only of alphanumeric characters (0-9A-Za-z), plus signs (+), tildes (~) and periods (.)
- Recommended to be less than 8 characters, if possible.
If an upstream version does not use a versioning scheme recognized by the deb toolchain (i.e
0.12.7), remove the invalid values from the upstream version. These removed values can be recorded in the
debian/changelog file. If you need to create a version string, use the YYYYMMDD format (i.e 20150713).
Setting up dh_make
$DEBFULLNAME shell environment variables. These will be used to generate values in control and changelog entries.
Setting up the directory structure
1) Create the top-level directory and then change directory into the new folder:
2) Retreive and unpack upstream source:
3) Change into the unpacked directory:
Create the initial package using the original source archive
From inside the unpacked source directory (i.e.
./newprogram-0.12.7), run the following:
-f flag sets the
filepath as the original (
newprogram_0.12.7.orig.tar.gz) source archive, which skips the copying of the current program tree.
dh_make -f <filepath>, you will be prompted to select the type of package you are creating.
For this example, we can assume that
newprogram-0.12.7 is a single binary.
Next, if you set your shell environment variables
$DEBFULLNAME, you should see the output of a
control file with the relevant fields already completed. If not, you will have to edit the
control file manually. (See this post)
Piecing it all together
dh_make -f , a copy of the upstream tarball will be created in the parent directory.
There are a couple of things to note about the
- The package name and version are separated by the underscore (_) character
- The string
.origis placed before
Also, newly created debian template files will be placed in the source folder under the debian directory.
this example does not show all template files created by dh_make
After the debian boilerpate files have been created, the real fun can begin. This includes understanding and modifying the required files under the debian directory, modifying the upstream source, and building the actual package.
We’ve also put out a couple of blog posts that can likely help you along the way:
dh_make to automate some of the boilerplate around creating a debian package from an upstream source. Hopefully, it’ll get you a few steps ahead when building your next deb package. If you’re not experienced in making software packages, chances are there will be some pain and suffering in your immediate future - but fear not! We have released a series of blog posts to help you along the way. Check out the packagecloud.io blog.