A beginners guide on how to create debian packages

In my last post I posted how to add a menu globally I thought that would make a good example of how to make a debian package.

First install the requried packages.

sudo apt-get install build-essential fakeroot lintian

Then create a folder for building the package. I am using ~/sshmenu.

mkdir ~/sshmenu

Create the folders and copy the filesfor the menu when they get install

mkdir -p ~/sshmenu/etc/xdg/menus/applications-merged
mkdir -p ~/sshmenu/usr/share/desktop-directories
cp ~/.config/menus/applications-merged/ssh.menu ~/sshmenu/etc/xdg/menus/applications-merged/.
cp ~/.local/share/desktop-directories/ssh.directory ~/sshmenu/usr/share/desktop-directories/.

In this folder create a folder called DEBIAN

mkdir ~/sshmenu/DEBIAN

In this folder create a control file, this file should look something like this

Package: sshmenu
Version: 1.0
Section: admin
Priority: optional
Architecture: all
Depends: openssh-client, ssh-askpass
Maintainer: Me <my-email@address.com>
Description: This package adds a menu for users to add custom ssh menuentries.
Add a menu for ssh entries

As you can see for this i have added openssh-client and ssh-askpass as dependencies, not much point without openssh-client and ssh-askpass as there needs to be a way to enter the password. If all you were to do is create a metapackage you would just add the dependencies you needed here.

With that done build the package with,

fakeroot dpkg-deb –build sshmenu

So the package is created , but is it complete and error free ? to check this use the lintian command

lintian sshmenu.deb

From the output,

E: sshmenu: changelog-file-missing-in-native-package
E: sshmenu: file-in-etc-not-marked-as-conffile etc/xdg/menus/applications-merged/ssh.menu
E: sshmenu: no-copyright-file

These are items that require fixing, fortunately these aren’t too troubling. The first error requires a changelog this changelog goes to /usr/share/doc/sshmenu/.

mkdir -p ~/sshmenu/usr/share/doc/sshmenu/

This file should look something like this

sshmenu (1.0) UNRELEASED; urgency=low

* Initial release

— Me <my-email@address.com> Mon, 09 Feb 2015 03:00:24 +1300

Since this is the first release it should be indicated here and the date format is date -R

This file needs to be compressed using gzip -9

gzip -9 ~/sshmenu/usr/share/doc/sshmenu/changelog

The next error E: sshmenu: file-in-etc-not-marked-as-conffile etc/xdg/menus/applications-merged/ssh.menu means a new file needs to be created in ~/sshmenu/DEBIAN this file is called conffiles and needs to have this line added to it /etc/xdg/menus/applications-merged/ssh.menu

echo /etc/xdg/menus/applications-merged/ssh.menu > ~/sshmenu/DEBIAN/confiles

Make sure there is an empty line at the bottom of this file.

The last error is we need to create a copyright file. This needs to be in ~/sshmenu/usr/share/doc/sshmenu/ and should look like,

Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: SSHmenu
Source: ftp://ftp.example.com

Files: *
Copyright: Copyright 2015 Me <my-email@address.com>
License: GPL-2+

Files: debian/*
Copyright: Copyright 2015 Me <my-email@address.com>
License: GPL-2+

License: GPL-2+
This program is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later
This program is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
PURPOSE. See the GNU General Public License for more
You should have received a copy of the GNU General Public
License along with this package; if not, write to the Free
Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301 USA
On Debian systems, the full text of the GNU General Public
License version 2 can be found in the file

Now recreate the package

fakeroot dpkg-deb –build sshmenu

Check the new package for any errors.

lintian sshmenu.deb

There are no errors for me this time, so the package has been created successfully, however I would add md5sums of the files that need to be installed, all the files not in ~/sshmenu/DEBIAN, create the ~/sshmenu/DEBIAN/md5sums file.

find . -type f ! -regex ‘.*.hg.*’ ! -regex ‘.*?debian-binary.*’ ! -regex ‘.*?DEBIAN.*’ -printf ‘%P ‘ | xargs md5sum > DEBIAN/md5sums

Make sure to rebuild and check the package as before.

I have not discussed maintainer scripts as they were needed for this package, but there are DEBIAN/postinst and DEBIAN/prerm and take care of updating document files.

Posted in 01Ben, Computers, Debian, Linux

Please feel free to leave a reply.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Enter your email address to follow this blog and receive notifications of new posts by email.

Join 67 other followers

%d bloggers like this: