Thorough packingMaking application submissions and publishing easier for developers is knowing how to package your software for the Ubuntu Software Center. One of greatest things about Ubuntu is the simplicity and reliability of installing software with Debian packages and apt. Ubuntu uses the same system to deliver software through the Ubuntu Software Center. The packaging tools described below were written for Debian developers working and integrating upstream Linux projects. Some parts can be tricky and many developers are working hard to automate most of your packaging experience with a new service aptly named pkgme. However, that service is not quite ready today so please read on!

Debian and Ubuntu organize software into packages. These packages have a specific format which end in .deb. The .deb package is an archive that holds the binary or source of the application along with metadata describing the location to copy the application and it’s supporting files. Many different methods exist for creating Debian packages, however in the example below debhelper is our tool of choice.

The example provided is a how to step by step guide to create a Debian source package from a compiled application which will install into /opt/<appname>, add a desktop file and icon into the global menu for launching the application, and submit it for publishing under the Ubuntu App Developer Program.

Ubuntu Software Center expects all application files to be installed into /opt/<appname>. Configuration and user data files should reside in ~/.config/<appname>. With those requirements in mind, the example below has been tested and will run in /opt/<appname> without any problems.

Prerequisites for these instructions

sudo apt-get install devscripts build-essential lintian dh-make

Getting ready to package

Setting up the directory structure

  1. Create the top dir. Create a directory to work in first. We want to package the Dungeon Adventure Game app, so we’ll choose a fitting name for it: dungeon – Make a directory called dungeon using mkdir dungeon
  2. Create the packaging dir. In the new dungeon directory create another directory to place the package files you’ll be creating. The name of this directory should coincide with the version of the package using a dash between the package name and the package version. The resulting directory is dungeon/dungeon-1980.0
  3. Create the original files dir. In the new dungeon-1980.0 directory extract the downloaded archive into a new dungeon_1980 subdirectory.

Setting up the desktop file

Now that the file structure is complete, you’ll need to create what is called a Desktop file. A desktop file contains information on how to execute an application and on its associated icon. It will enable users to see your app’s icon in the Unity Launcher and in the Unity Dash, and to launch it from there.

  1. Desktop file. Create a file named dungeon.desktop with your text editor of choice and save it in the <code>dungeon-1980.0</code> directory. Copy the content below and save it.
  2. Icon. Create an icon named <code>desktop.png</code> and save it in the same <code>dungeon-1980.0</code> directory. You can use the example 48 x48 pixel image below.

[Desktop Entry]
Name=Dungeon Adventure
Comment=Dungeon Adventure Game (a.k.a. Zork)
Icon=dungeon Exec=gnome-terminal --window -e '/opt/adventure/dungeon’


You’ve just finished creating the directory layout and file needed for the packaging tools to work. After having followed the steps above, your file structure should look like this:

Now onto the fun stuff: actually packaging your app.

Packaging fun: debianizing the package

  1. Create the package control files. In the dungeon/dungeon-1980.0/ directory run dh_make -n (for our example we will build as a native package hence the -n option). The dh_make command will create the debian directory and populate the example templates. At the prompt for the Type of package, select s for Single binary. Now change into the debian directory.
  2. Remove unnecessary files. For this application, in the debian directory remove all files with the .ex and .EX extensions and all README.* files as they are not needed for the native application being built.
  3. Create the installation script. During installation of the application the files need to be copied into the /opt/dungeon directory. Edit (create a new file) dungeon/dungeon-1980.0/debian/install adding the lines below to place the files in their proper location during installation.
dungeon_1980/* opt/dungeon
dungeon.desktop usr/share/applications
dungeon.png usr/share/icons/dungeon.png

Now you are ready to build the package

Packaging fun: building the package

  1. Update the changelog. Ensure you are in the dungeon/dungeon-1980.0/ directory and run dch to update the changelog. For an intial release you can simply have one entry that shows * Initial Release along with your name and email address. The package name at the top of the changelog should be “dungeon (1980.0)”
  2. Build the binary package. From the dungeon/dungeon-1980.0 directory run debuild -b to build the binary package. This will create a number of lintian (lintian is a sanity check tool for the package) errors. Disregard them for this example, but do fix these errors in your real submission.
  3. Check out the output. The output is a file named dungeon_1980.0_i386.deb (if a amd64 app was being created the extension will have _amd64.deb)
  4. Install and verify the binary package. In order to verify the build worked run sudo dpkg -i dungeon_1980.0_i386.deb to install the .deb built in the previous step, check the files are all where we expected them (/opt/dungeon, /usr/share/applications) and run the Dungeon Adventure by clicking on the Dash icon and typing Dungeon to show the icon for the app. Don’t get distracted here – this game is addictive.
  5. Remove the binary package. Once the install is verified remove the installed package (if you wish) using dpkg --purge dungeon
  6. Create the source package. The final step is to create the Debian source package for submission via MyApps. cd to the dungeon/dungeon-1980.0 directory and run debuild -S the -S is for source package and creates a .dsc file (among others).
  7. Archive the source package. Provided no errors appeared in the build process tar up the files found in the dungeon/ directory as the Debian source tar cxf dungeon-1980.0-debsrc.tar.gz *.dsc *.changes *.tar.gz from the working directory (dungeon/)
  8. Submit to MyApps. That’s it! Submit the debian source package tar created in step 7 to our Developer Program or MyApps!

Follow us on Twitter @ubuntuappdev and give us feedback!

Additional resources

Follow Ubuntu App Development on:


Social Media Icons by Paul Robert Lloyd

  • naba

    Hi, Nice tutorial. Can also describe step 3 for a typical autotools based project which would involve configure/make/make install/? Thanks.

  • Pingback: Ubuntu 12.04 is for App Developers | Michael Hall's Blog

  • lolo

    The main problem with the Ubuntu’s app store is that you cannot include in the same package the x86 and x64 version, which is really bad.

  • Antonio

    @lolo: that’s a restriction in Debian packaging. The x86 and the x86_64 packages need to be stored at different repositories. If your app is not architecture-specific (i.e. it’s in Java or Python), you can use the “all” pseudo-architecture.

  • Pingback: Blog Lateriaguna - [CHALLENGE] Resources dan Opportunities di bulan Oktober 2012

  • ChrisM

    I’m wondering if anyone can help me. I’ve managed to build a .deb and then install it so all files appear in the expected locations (e.g. /opt/myname/runmygame), however I am not actually able to run the installed package and there is no sign of it in the gnome apps menu.

    I am sure I am missing something, but I’ve no idea what!