Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I write a pygtk app and want to make a deb pkg for it.

$ tree WebPad/
|-- jspad
|   |--
|   |--
|   |--
|-- pixmaps
|   |-- c.png
|   |-- run.png
|   `-- webpad.png
`-- templates
    `-- webpad.tpl

3 directories, 19 files

Do I need to change the directory layout?

share|improve this question
up vote 5 down vote accepted

First of all, you need to create a file using distutils in the root directory of your project. It should contain text similar to the following:

#!/usr/bin/env python

from distutils.core import setup
from glob import glob

setup(name = "WebPad",
    data_files=[('share/webpad/pixmaps', glob("pixmaps/*"), ('share/webpad/templates', ['templates/webpad.tpl'])],

And you should also create a file:

recursive-include pixmaps *
recursive-include templates *

One you've done that, you can run various commands on the terminal to distribute your project:

chmod +x
sudo ./ install # installs your project to /usr/local
./ sdist # creates a source distribution in dist/

The last command is the one we're interested in. Once you've got a source distribution with a distutils script, you can then follow the Python packaging guide for Ubuntu. Basically, it involves creating a debian/ directory in the root of your project with various bits of information and running debuild.

I wrote a tutorial on how to do this a while ago, some of it is not best practise, but it will help you understand a few concepts.

share|improve this answer

I always liked "learn by example" methods, so here it goes:

  1. Download the package from one of the mirrors.
  2. Open it with the archive manager.
  3. You will see some directories. They are structured like you are in the absolute root of the file system.


The runner will have to go in the /usr/bin/ directory. Rename it into "web-pad" or "webpad" and make sure it starts with "#!/usr/bin/python". That way you can easily launch it from command line, without having to write "python web-pad". Instead, "web-pad" will be enough.

The other files will have to go into /usr/share/web-pad/ or /usr/share/webpad/ For the launcher to work, you will need to make a /usr/share/pyshared-data/web-pad or /usr/share/pyshared-data/webpad file. I think it adds your source files to the include path, so the launcher can launch them. Again, as an example of one, use the /usr/share/pyshared-data/software-center file inside the package.

You should also have a look at other files in the software center package. They can provide some very useful information.

And yeah, look at the files in the DEBIAN directory. Especially the control file, as it is where you set the dependencies, description, version, conflicts, etc...

The triggers file allows you to set triggers to your application. (probably launches the application when something is done, but I am not sure. You could always try...) The prerm script runs before the files are removed. (package removing) The preinst script runs before the files are copied into their place. (package installing) The postrm script runs after the files are removed. (package removing) The postinst script runs after the files are copied into their place. (package installing) The md5sums file contains md5 checksums of files inside. The conflies file probably contains the configuration files, although I am not sure about that.

As said by @Flimm, File roller has built-in functionality of opening deb archives in a more friendly manner - this includes unpacking control.tar.gz into DEBIAN directory, data.tar.gz into the root (it contains your files) and hides the debian-binary file. Opening deb files in Ark doesn't do that.


You could try this application, I looked at it and it seems quite good:

share|improve this answer
so, that means that Ubuntu Software Centre only extract all folders and files(except DEBIAN folder and its files) from the .deb package and put it in / directory? :) – kv1dr Jun 1 '11 at 8:14
@kv1dr Yes, the packages are structured like that. – nickguletskii Jun 1 '11 at 8:29
Most developers don't make a .deb file manually though, and this method won't work if you want to eventually upload your package to a PPA. – Flimm Jun 1 '11 at 8:38
@Flimm I don't see what is wrong with manually creating packages. I disliked the utilities that I've found. Also, why won't it work? How is your guide better in that sense? – nickguletskii Jun 1 '11 at 8:51
@nickguletskii: You can manually create packages, you can learn a lot that way. PPAs expect a clear division between the source tarball and the additions created by the packager in a .diff.gz file, among other things. It makes a lot more sense when you're packaging C programs, because the source code is completely different from the binaries you distribute, and debian/rules contains instructions on how to build the binaries. – Flimm Jun 1 '11 at 9:12

You might also want to port your application to quickly, and then use the quickly package command to do the packaging automatically for you. There's also more information on quickly commands on the Ubuntu App Developer site.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.