User Tools

Site Tools




Notes on Debian Packaging

An Alternative - stdeb

Hi everyone

Some time ago, I gave a talk about the "fpm" package manager a while back.
Today, I came across a different tool, which is also available from
the Ubuntu repositories called "stdeb":

I successfully generated a Debian package for one of my little Python utilities:

Just by using this command-line (using the "" of the project):
python3 --command-packages=stdeb.command bdist_deb

Requires "python3-all" to be installed.

Thought you might find this useful.

Cheers, Peter
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174
Thanks to the following stackoverflow post I figured out how to
include a .desktop file and icon, making an application appear in the
main menu:

Example code mentioned in that post is available from here:

Step by Step


  • Any new folders or files? Update KEEPME rules
  • run 0 KEEP (in SOFA/storage) - details in “Steps Covered by Script” below.
  • NB copies final deb into grantshare ready for testing immediately.


  • copy deb package from /home/g/projects/SOFA/debmaker into grantshare and make all permissions Read and Write
  • remove /home/grant/sofa from notebook before reinstalling
  • copy onto notebook desktop and reinstall - then test
  • copy to transfer and set permissions to RW
  • select lucid snapshot, revert to snapshot, then open
    • (already done in snapshot) sudo mkdir /transfer
    • sudo mount -t vboxsf transfer /transfer (this will only work if vb settings have Shared Folder set to transfer_nb as transfer etc)
  • Test on Lucid (if OK, ready to release :-))
  • Shift copy to /home/g/projects/SOFA/installers

tar.gz Notes

Steps Covered by Script

  • Go to /home/g/projects/SOFA/debmaker
  • Apart from the KEEPME subfolder, delete everything in debmaker. KEEPME has demo control, rules, dirs etc files etc + desktop file
  • Delete everything in sofaclean
  • Copy into sofaclean the sofa.main folder from the /home/g/projects/SOFA/sofastatistics/sofa.repo folder
    • delete tests folder
    • delete .bzr folder
    • delete storage folder under dbe_plugins
    • examples folder under boomslang and
    • remove all pyc files, including in dbe_plugins
    • delete 2 spss files,, and the non-Python files e.g. app.fil, messages.pot, any po files in main folder.
    • delete ./locale/ru_RU
    • in ./locale/gl_ES/LC_MESSAGES delete and and then rename to
  • Also copy the sofa folder from home.
  • you should now have two folders:
  • - sofa.main
  • - and sofa
  • Working in the sofa folder …
  • Delete comtypes_handled.txt and proj_file_customised.txt if present.
  • Delete misc folder and misc.tar.gz
  • Empty _internal except for SOFA_Default_db (which should be about 169KB not many MBs)
  • Remove all projs except the SOFA_Default one.
  • Ensure MS Access and MS SQL Server items are not in the db and tbl dics inside default proj file.
  • Empty reports and scripts completely.
  • Remove all vdts except the SOFA_Default one. Check the default one for additions ;-).
  • Select both sofa and sofa.main folders and make .tar.gz archive - call it sofa-n.n.n.tar.gz (e.g. sofa-1.2.27.tar.gz)
  • Copy tar.gz file into debmaker and go there.
  • Extract Here but don't delete tar.gz file
  • Move tar.gz file to freshly extracted sofa-n.n.n subfolder
  • cd /home/g/projects/SOFA/debmaker/sofastats-n.n.n
  • dh_make -e -f sofastats-n.n.n.tar.gz
    • (include -c gpl if using gpl. Modify licence file by hand if agpl)
    • select s for single and confirm
    • ignore comment about absence of top level Makefile. Keep terminal open as is.
  • delete sofastats-n.n.n.tar.gz from /home/g/projects/SOFA/debmaker/sofastats-n.n.n
  • delete sofastats-n.n.n.orig.tar.gz from /home/g/projects/SOFA/debmaker
  • put SOFA Statistics desktop file from KEEPME in /home/g/projects/SOFA/debmaker/sofastats-n.n.n
  • Prepare all files under /home/g/projects/SOFA/debmaker/sofastats-n.n.n/debian
    • add to the KEEPME version of rules any new files, including images, added to project since last time. NB change both left and right hand side of lines
    • control, dirs and rules can be copied across in toto
    • changelog - add jaunty upwards unstable, and change second line so * put my comment here …
      • NB no commas or will fail!
    • copyright - copy across from “It was downloaded” downwards (NB if including anything not AGPL3 need to update KEEPME version first)
    • delete all files and folders apart from changelog, compat, control, copyright, dirs, and rules (6 files)
  • dpkg-buildpackage -rfakeroot (check for errors) - ignore Failed to sign .dsc and .changes file
  • rename deb from sofastats_ to sofastats-



  • make sure dh-make is installed e.g. sudo apt-get install dh-make

Specific Settings in debian folder

NB copy and paste from KEEPME

  • NB any changes for dates or version numbers
  • NB put desktop file into ~/Desktop/debmaker/sofastats-n.n.n before running build command
  • It is helpful to

# Uncomment this to turn on verbose mode.

export DH_VERBOSE=1


format as package name then version

"When working with a package which originated in Debian, use a version number 
derived from the Debian version number with ubuntu<revision> appended. i.e. Debian 1.0-2 
becomes 1.0-2ubuntu1, followed by 1.0-2ubuntu2, etc.  Packages not in debian yet 
should end with revision -0ubuntu1"

sofastatistics (0.6-0ubuntu1) jaunty stable; urgency=low # could be experimental, unstable etc

*ubuntu linux package for jaunty jackalope.

*a stable release. Any other comments about what has changed.

– Grant Paton-Simpson Fri, 8 May 2009 18:52:02 +0000

Formatting rules:

The change details may in fact be any series of lines starting with at least two spaces, but conventionally each change starts with an asterisk and a separating space and continuation lines are indented so as to bring them in line with the start of the text above. Blank lines may be used here to separate groups of changes, if desired.

Doesn't like comma in first line - so jaunty karmic and lucid is fine but jaunty, karmic, and lucid = eof fault.



e.g. Depends: python (>=2.6.2-0ubuntu1), …

The relations allowed are: <<, <=, =, >= and >> for strictly earlier, earlier or equal, 
exactly equal, later or equal and strictly later, respectively.


main (as opposed to non-free or unknown or contrib) and a subsection e.g. main/python

The Debian archive maintainers provide the authoritative list of subsections. 
At present, they are: admin, base, comm, contrib, devel, doc, editors, electronics, 
embedded, games, gnome, graphics, hamradio, interpreters, kde, libs, libdevel, 
mail, math, misc, net, news, non-free, oldlibs, otherosfs, perl, python, science, 
shells, sound, tex, text, utils, web, x11.


Line 4 is the name and email address of the maintainer. Make sure that this field 
includes a valid "To: " header for an email, because after you upload it, the bug 
tracking system will use it to deliver bug emails to you. Avoid using commas, 
ampersands and parenthesis.


If your package is architecture independent (for example, a shell or Perl script, 
or a document), change this to "all", and read later in `rules' file, Section 4.4 
about using the `binary-indep' rule instead of `binary-arch' for building the package.

This would apply to python as well.


Stats/analysis - favours ease-of-use over comprehensiveness # has to no more than 60 characters

A statistics, reporting and analysis package with an emphasis on ease-of-use. The goal is flexible input and beautiful output - i.e. lots of databases supported and attractive, ready-to-present output.


If using the GPL, make a selection - either GPL2 or GPL2+

If using the AGPL will need to fill this in manually.

From man dh_make

     -c, --copyright <license>
            Use <license> type in copyright file.   <license>  can  be  gpl,
            lgpl, artistic or bsd.  If this field is not specified the copy‐
            right file has a space to fill in which sort of license is used.
            The field is case-insensitive so -c GPL works as well as -c gpl.


NB there must be a space before the description. And complete a full description. If you want a space between 2 lines use a . (dot).


List the directories actually used

e.g. usr/share/pyshared/sofastats

NB no preceding slash


Not relevant to me.

"Any extra details or discrepancies between the original package and your debianized version should be documented here."


In rules, it wants tabs, not eight spaces. If using gedit, may need to paste tabs in so it doesn't autoconvert them (or untick “Insert spaces instead of tabs” option under Edit>Preferences>Editor).

E.g. (NB only showing examples of some sections, not a replacement for entire rules document)

build-stamp: configure-stamp # NB tab in front of each of the following


touch build-stamp

clean: # NB tab in front of each of the following



rm -f build-stamp configure-stamp


install: build # NB tab in front of each of the following





# Add here commands to install the package into debian/mydeb.

#$(MAKE) DESTDIR=$(CURDIR)/debian/mydeb install

mkdir -p $(CURDIR)/debian/mydeb

cp $(CURDIR)/debian/mydeb/usr/share/pyshared/mydeb/

mime.conf needs this line:

rules text/plain



Desktop File

Icon is in /usr/share/pyshared/sofa/images/sofa_48x48.xpm

NB make executable to see as icon

Available Categories are:

  • Accessories –> Utility;
  • Edutainment –> Education;
  • Games –> Game;
  • Graphics –> Graphics;
  • Internet –> Network;
  • Office –> Office;
  • Programming –> Development;
  • Sound & Video –>AudioVideo;
  • System Tools –> System;
  • Others –> Other;

For SOFA I want it to appear under Science. Putting Science on its own is not enough. Need Education as well.

What I haven't been able to figure out is where the "Categories" come from, and how they are parsed. 
If I leave for example "Education;" out of it, it will not show up in the "Science" menu, but in the 
"Others" menu. [[ | Creating .debs - not exactly easy]]
proj/deb.txt · Last modified: 2020/09/08 20:08 by