log entry 2013-08-04

git-buildpackage creates iptables-converter.deb v0.8

As I want to have a wide platform to reach as many users as possible, I intended to build .deb for iptables-converter. Then I learned some useful details about git-buildpackage recently. Having started my project with a git, it should be possible to adapt it to Guidos tool. It was an arousing way of trials and errors. But finally it is easy going.

Of course you need the usual debian directory and some files there:

hans@jha:~/gh/conv$ ls -l debian/
total 32
-rw-r--r-- 1 hans hans  822 Aug  2 01:31 changelog
-rw-r--r-- 1 hans hans    2 Jul 23 09:06 compat
-rw-r--r-- 1 hans hans  531 Aug  2 01:40 control
-rw-r--r-- 1 hans hans 1074 Jul 23 09:06 copyright
-rw-r--r-- 1 hans hans   25 Jul 23 09:06 iptables-converter.manpages
-rw-r--r-- 1 hans hans  199 Jul 23 09:06 README.Debian
-rwxr-xr-x 1 hans hans 1024 Jul 23 09:03 rules
drwxr-xr-x 2 hans hans 4096 Jul 23 09:06 source
hans@jha:~/gh/conv$

Most of these files are necessary for building a debian packet. Especially the control file describes some essentials about the .deb:

Source: iptables-converter
Maintainer: Johannes Hubertz <johannes@hubertz.de>
Section: utils
Priority: optional
Build-Depends: python-all-dev (>= 2.6.6-3-), debhelper (>= 9), python-support
Standards-Version: 3.9.3

Package: iptables-converter
Architecture: all
Depends: ${misc:Depends}, ${python:Depends}, ${sphinxdoc:Depends}
Description: convert set of iptables-commands to iptables-save format
 iptables_converter.py: convert iptables in a script to iptables-save
 readable format to stdout with [0:0] for iptables-restore -c

Within the rules file, which is a makefile, the necessary steps to produce the .deb are mentioned. The debhelper scripts may be called here. For tests, debuild may be run in the main directory, it should be able to produce a .deb file quickly. But everything must be done by hand, that's unwanted.

git-buildpackage works with the master branch or with the debian branch, if master is upstream. Being upstream, the master branch will do. Tags are required as configured in gbp.conf:

upstream-tag = v%(version)s

Here are my tags from the actual git repository:

hans@jha:~/gh/conv$ git tag -l
v0.6
v0.7
v0.8

Annotations are useful, see one as an example:

hans@jha:~/gh/conv$ git tag -v v0.7
object f10c3ab221458d762579b392f609a2534d21df6e
type commit
tag v0.7
tagger Johannes Hubertz <johannes@hubertz.de> 1374354728 +0200

version 0.7
Thanks: Guido Guenther and Toni Mueller gave very useful hints to do it.
gpg: Unterschrift vom Sa 20 Jul 2013 23:12:10 CEST mittels RSA-Schl├╝ssel ID 8857914A
gpg: Korrekte Unterschrift von "Johannes Hubertz <johannes@hubertz.de>"
gpg:                     alias "Johannes <johannes@guug.de>"

When the source is ready to be released, a changelog entry can be done very easily:

gbp dch --release --auto

This will sample all the commit logs headlines since the last release and format them correctly within the debian/changelog on top:

iptables-converter (0.8) unstable; urgency=low

  * [20c2ed1] manpages also renamed
  * [569fdb5] renaming included the deletion of the old file
  * [240c595] copy .py to pyshared as well
  * [f10c3ab] dh_python necessary for dependencies
  * [86be17f] dh_python replaced by python-support reasoned by squeeze install
  * [d4be880] Version changed to 0.8

 -- Johannes Hubertz <johannes@hubertz.de>  Fri, 02 Aug 2013 00:50:59 +0200

iptables-converter (0.7) unstable; urgency=low
...

Now the packaging process may be started using gbp:

gbp buildpackage --git-pbuilder

A lot of output is presented, finally the usual suspects are produced in the next upper directory:

hans@jha:~/gh/conv$ ls -l ../iptables-converter_0.8*
-rw-r--r-- 1 hans hans  6430 Aug  4 10:53 ../iptables-converter_0.8_all.deb
-rw-r--r-- 1 hans hans 20771 Aug  4 10:53 ../iptables-converter_0.8_amd64.build
-rw-r--r-- 1 hans hans  1572 Aug  4 10:53 ../iptables-converter_0.8_amd64.changes
-rw-r--r-- 1 hans hans   608 Aug  4 10:53 ../iptables-converter_0.8.dsc
-rw-r--r-- 1 hans hans 27491 Aug  4 10:53 ../iptables-converter_0.8.tar.gz

The .build is the logged output of the build process, as well the desired debian package is on file. As root a test can give a proof:

root@jha:/home/hans/gh/conv# dpkg -i ../iptables-converter_0.8_all.deb
Selecting previously unselected package iptables-converter.
(Reading database ... 223084 files and directories currently installed.)
Unpacking iptables-converter (from .../iptables-converter_0.8_all.deb) ...
Setting up iptables-converter (0.8) ...
Processing triggers for man-db ...
root@jha:/home/hans/gh/conv#

Of course it is interesting, which files belong to the package:

root@jha:/home/hans/gh/conv# dpkg -L iptables-converter
/.
/usr
/usr/share
/usr/share/python-support
/usr/share/python-support/iptables-converter.public
/usr/share/man
/usr/share/man/man8
/usr/share/man/man8/iptables-converter.8.gz
/usr/share/pyshared
/usr/share/pyshared/iptables_converter.py
/usr/share/doc
/usr/share/doc/iptables-converter
/usr/share/doc/iptables-converter/copyright
/usr/share/doc/iptables-converter/README.Debian
/usr/share/doc/iptables-converter/changelog.gz
/usr/sbin
/usr/sbin/iptables-converter

It is so easy to have fun with Debian, git-buildpackage is a great tool. A prebuild package of the iptables-converter is available for your convenience.

Ah, you ask for other package management systems like rpm? The python setup.py already gives a chance to have a .rpm, if the rpm package is installed on your Debian system. These are available for download here.

Have fun!

social