Saturday, June 23, 2012

From code to Universe - How to publish your app on Ubuntu

If you are reading this article, I am going to assume that you are an Ubuntu user and a programmer that wants to publish some work to the Ubuntu Universe and have it appear on the software center. If you do, you are in luck. I will show you the steps involved in taking a "Hello World" to a published application in the Ubuntu Software Center in a few easy steps.

1 - Write the program
This is a simple step. Write the program and compile it into an executable. You can also send the source off to be made into a package, but this article does not explain that step. Once you have the executable, make the .deb file.

2 - Make the .deb
To do this, make a folder called "hworld". Then, inside of this file, make "DEBIAN" and "usr". DEBIAN is a control directory. Anything else will go in the root filesystem. For instance, a file at /etc/xdg/file would be placed in /etc/xdg/file on the installee's filesystem. You should have a grasp on how /usr works. Place the executable in /usr/bin. In /usr/doc/hworld you should put your license and a README. You can make the man page in /usr/man. When you're ready, move to the main directory of this .deb where the DEBIAN folder is. Move to DEBIAN. 
Inside of DEBIAN you need to make three files called "control", "postinst", and "prerm". "control" has its own syntax that gives some information about the .deb. "postinst" and "prerm" are two BASH scripts that execute after the program is installed and before it is removed. Both of the files should contain the command "ldconfig". Here is how the syntax of "control" should be:

Package: hworld
Version: 1.0-0ubuntu1
Architecture: amd64
Maintainer: Norton "dymatic" Jenkins <>
Installed-Size: 15
Section: accessories
Priority: optional
Description: Do nothing

There are extra fields that you can add, but this is the basic functionality. You are now ready to create the .deb file. Issue this command "fakeroot dpkg -b [path/without/brackets] [output/path/name.deb]
Fakeroot is important. The package will have the wrong permissions without it. Sudo is NOT a replacement for fakeroot. Now, you need to make the package name standards-compliant. Easy. Do this: "dpkg-name [/path/to/deb].

You can crack open any old .deb with an archive manager to examine how they go about their business. A good program to try it with is guru, my most recent project. 

Try to install it with the software center and see if it gives you any trouble. If it does, try again. If not, move onto step 3.

3 - Submit it
Go to and submit an application. This whole process is explained very well on the site, so I do not need to describe it in-depth here. You DO need to make a 64X64 icon for the program, though. You can download and edit mine here:  or you can get it right from this blog.
If you do not want to edit the Guru icon, you can make your own in GIMP or Kolourpaint if you wish. On the main uploading screen, upload the .deb, NOT the executable. Also, do not worry if it says "Buy $0.00" if you want it to be free. This is a minor bug.

The package has to be reviewed before it is published. It can be rejected for a number of reasons, and if it is it is up to you to fix it according to their suggestions and then re-submit it. The reviewing process can take up to 5 days. It can take even longer for your package to appear in the repositories.
4 - Done
You're done. You can now sit back and relax and add this published application to your resume. Remember that you can still update it and that it is a good idea to do so. 

No comments:

Post a Comment