Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

$ tree WebPad/
WebPad/
|-- jspad
|   |-- __init__.py
|   |-- main.py
|   |-- t.py
|-- pixmaps
|   |-- c.png
|   |-- run.png
|   `-- webpad.png
|-- README
|-- run.py
`-- templates
    `-- webpad.tpl

3 directories, 19 files

Do I need to change the directory layout?

share|improve this question

3 Answers 3

up vote 4 down vote accepted

First of all, you need to create a setup.py 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",
    version="0.1",
    author="znetor",
    packages=["jspad"],
    data_files=[('share/webpad/pixmaps', glob("pixmaps/*"), ('share/webpad/templates', ['templates/webpad.tpl'])],
    scripts=['run.py'])

And you should also create a MANIFEST.in 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 setup.py
sudo ./setup.py install # installs your project to /usr/local
./setup.py 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 setup.py 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: http://packages.ubuntu.com/natty/all/software-center/download

  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.

Conclusion:

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.

USING FILE ROLLER TO MAKE DEB PACKAGES WILL NOT WORK! FILE ROLLER ONLY SUPPORTS READING DEBS!

You could try this application, I looked at it and it seems quite good: http://debcreator.cmsoft.net/#download

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

 
discard

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.