Debian Package Development
Debian is an operating-system and a distributor of Free Software. Many Popular Linux Distributions(Ubuntu, Kali Linux, Tails, etc) are based on Debian Operating System, they are known as derivatives of Debian. If you want to create a package for debian based linux distribution like Ubuntu, you will have to create a debian package.
This article will briefly take you through the steps of packaging a software for the same, For detailed information on the debian package format and the tools to maintain a debian based Linux system you can take a look at Debian Package Management Book.
The package that we will create today, will be called hangman, and it will simply contain a Python script of a famous game known as hangman,
If you want the code for the script you can see it in this gist, Python-Hangman-Script
Next we will compress this directory to create a tar file,
tar -zcvf hangman.tar.gz /path/to/hangman-python-script
Requirements
- Packaging Tool Chain
Their are some minimum package requirements on the operating system, for building a debian package:
- devscripts
- debhelper
- libfile-fcntllock-perl
Install these using the following command:
$ apt-get install devscripts debhelper libfile-fcntllock-perl
- Prepare the software to be packaged
Create a directory, this will be the environment in which we will build our package, copy the tar file into the build directory
$ mkdir -p ~./build/hangman
$ cp -v hangman.tar.gz ~./debian/hangman
Change into the directory, and extract the package:
$ cd ~./build/hangman
$ tar -xzf hangman.tar.gz
Debanization
Let’s add the files that are specific to debian packaging system, Create a new directory in the build directory debian, and change into that directory
$ mkdir ~./build/helloworld/debian
$ cd ~./build/helloworld/debian
Now, once we are inside the debian directory we can start making the files for debian packaging.
- debian/control
This files contains the meta-data about the package (dependencies, etc.) and each binary package built from the source, the constituents of the file are:
- package-name
- section
- priority
- maintainer
- uploaders
- description
- homepage …etc;
Example for the hangman file is:
Source: hangman
Section: web
Priority: optional
Maintainer: <your-name> <your-email>
Build-Depends: debhelper (>= 9.0.0), python(>=2.6)
Standards-Version: 4.2.1
Homepage: <your-site>Package: hangman
Architecture: all
Depends: ${misc:Depends}
Description: hangman guessing game written in python
- debian/rules
This file contains the interface used to build debian packages. The care of indentation in this file, dh command have a tab space in the starting.
#!/usr/bin/make -f
# -*- makefile -*-# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1%:
dh $@
override_dh_auto_build:
# Skip, just use dh_install.override_dh_install:
dh_install --fail-missing#override_dh_install:
#$(MAKE) DESTDIR=$(CURDIR)/debian/plymouth-meilix-logo
- debian/changelog
This files lists the Debian packaging chsnges, and gives the current version of the package.
This file can be edited manually or using dch.
Creating a new changelog entry for a new release using: dch -i, initial version of changelog can be:
hangman (1.0) UNRELEASED; urgency=medium* Initial release. (Closes: #XXXXXX)-- <your-name> <your-email> Wed, 22 May 2019 14:13:16 +0530
- debian/source/format
You can specify the format of the debian package using this file.
Create a directory source inside debian, and make a file format in that directory, a sample format files will be:
3.0 (native)
- debian/copyright
This file contains the copyright information of the package.
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: hangman
Source:Files: *
Copyright: 2019 <your-name><your-mail>
License: GPL-3+Files: debian/*
Copyright: 2019 <your-name><your-email>
License: GPL-2+
License: GPL-2+
On Debian systems, the full text of the GNU General Public License version 2 can
be found in the `/usr/share/common-licenses/GPL-2' file.License: GPL-3+
This package 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 3 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
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 3 can
be found in the `/usr/share/common-licenses/GPL-3' file.
This completes the basic file-structure required for the making a debian package, using these simple steps you can create different debian packages according to your choice and purpose, to create the debian package we just to execute the command,
$ debuild -us -uc
If you want the code for making of this debian packages, you can check it here: Hangman-Debian