Packaging Qt Creator Apps for Maemo Extras

While there are a few pages relating to packaging Maemo and Qt apps, this document is designed to provide step-by-step instructions for taking a working app in Qt Creator and publishing it to the Maemo extras development repository for all to enjoy. The methods here have been tested with basic Qt apps in an Ubuntu Linux environment. Hopefully additional feedback and edits will provide information about working on the lesser platforms available, for example Windows and Mac.


[edit] Is there a simple(r) way ?

Note that the instructions on this page apply to QtSDK 1.0.x and QtCreator 2.0.x. The use of the QtSDK 1.1 is strongly encouraged, as it has incorporated/automated most of the steps outlined below.

[edit] Using the Wizard

With QtSDK 1.1, all you need to do is go to Build-> Publish Project... --> Start Wizard. As shown here.

You can then choose to upload your app directly to the repository using your maemo garage account, or you can do the more straightforward approach of choosing not to upload through QtSDK (make sure that the "do not upload" box is ticked) and instead uploading the generated files using Maemo Extras Assistant (check your /tmp/qtc_packing_appname/ folder for the .changes, .tar.gz and .dsc files).

[edit] Issues

Some developers have encountered problems with the debian/rules file using this method, in which case it should be noted that one working solution is to uncomment the "qmake PREFIX=/usr" and "dh_shlibdeps" lines in the rules file (as suggested by notation in the actual file itself). Another common solution is to check that each line of the rules file is indented with TABS and not spaces.

[edit] Using Custom Build Steps

Another way to generate the .changes, .tar.gz and .dsc files is to add a custom step to the build configuration . This is also a fairly straightforward process and is outlined here and here

[edit] Qt Creator Notes

A few notes on Qt Creator, especially if you haven't started yet:

  • create a work directory and create the Qt Creator project directory within that. For example, if your app is called supercalc, create a directory called supercalc-work (or whatever you want to call it) and create the supercalc project directory within that. When you do all of the building and testing within Qt Creator, it creates lots of directories. You can control where they are created, but this lets you use the default locations.
  • If you create a Desktop target, you can run your app outside the simulator and test the functionality directly in a native app. Sometimes this is easier than working within the simulator.
  • The QSettings class works as expected on Maemo 5, so make use of it for configuration files and storing system information.
  • Before attempting the packaging, you should make sure that a build with the Maemo target is successful.

[edit] Packaging

Now that you have a working application, you can package it as follows. For the purposes of this discussion, we will refer to the work directory and the source directory. The source directory is the directory created for the Qt project—the one with the .pro file in it. The work directory is probably the parent directory of the source directory, but it can easily be somewhere else.

  1. Add a directory for the maemo-specific files in the source directory. Call it "maemofiles". It will contain the following two files:
    • an icon file — make it a 48×48 PNG, which you can build in GIMP, or whatever else you use to make images. appname_icon.png is probably a good name, but use whatever you like. In the final package this file will end up in /usr/share/icons/hicolor/48x48/apps
    • the appname.desktop file. This tells the system how to present the app in the menus and where to find the executable. It will end up in /usr/share/applications/hildon in the final package. For more information on what goes in this file, see the article on the desktop file format. Also, note that the .pro changes below will write the app into /usr/bin/appname/appname, so make sure you have the desktop file match this.
  2. Next we need to tell the project how to find those files and where to put them. Edit the .pro file for your app and add a unix{} section as follows (make sure the directories and filenames match the ones you just created above):
    unix {
       INSTALLS += target desktop icon48
       target.path = /usr/bin/appname
       desktop.path = /usr/share/applications/hildon
       desktop.files += maemofiles/appname.desktop
       icon48.path = /usr/share/icons/hicolor/48x48/apps
       icon48.files += maemofiles/appname_icon.png
  3. Add a folder to the source directory named "debian" folder and copy the Debian files needed from appname-build-maemo directory that was created when you did a Maemo target build in Qt Creator. The files you need for a basic app are: changelog, compat, control, copyright, rules
  4. The Debian files need to be updated for your application as follows:
    • add a file called "optify" and put the word "auto" in the file as the only contents. This will cause the application to be automatically "optified" for install on an N900.
    • make sure the "changelog" file is up to date and in the proper format. There should be an entry for the current release version. The version number here is the one used to determine the version number when the application is built later on, so make sure this file is correct. The "dch" command in Linux will add an entry in the proper format and open an editor for you to do changes on it. From the source directory, type "dch -v 1.0.1" (substitute your version number for 1.0.1, of course), and an editor will open with a new entry for you to use. There are also some git tools which automatically update this file, if you care to figure those out.
    • change the contents of the "compat" file to be just a single digit: the number 5. (It is probably 7 now, which is not compatible with the autobuilder.) Numbers higher than 5 will cause mysterious errors in the autobuilder.
    • update the "control" file with the proper information:
      • Make sure it has these on the "Build-Depends" line: debhelper (>= 5), libqt4-dev
      • The "section" entry on the "control" file can have values as found on the packaging guidelines article
      • add the icon to the control file. See the package icon section in the packaging article for more information
    • set the copyright file as needed, including any copyright info on external items you use such as images or libraries.
    • set the rules file to be slightly different than the one found in the article on packaging a Qt application, so that it is as follows:
      #!/usr/bin/make -f
      APPNAME := appname
      	mkdir -p builddir
      builddir/Makefile: builddir
      	cd builddir && qmake-qt4 PREFIX=/usr ../$(APPNAME).pro
      build: build-stamp
      build-stamp: builddir/Makefile
      	# Add here commands to compile the package.
      	cd builddir && $(MAKE)
      	touch $@
      	rm -f build-stamp
      	# Add here commands to clean up after the build process.
      	rm -rf builddir
      install: build
      	dh_clean -k
      	# Add here commands to install the package into debian/your_appname
      	cd builddir && $(MAKE) INSTALL_ROOT=$(CURDIR)/debian/$(APPNAME) install
      # Build architecture-independent files here.
      binary-indep: build install
      # We have nothing to do by default.
      # Build architecture-dependent files here.
      binary-arch: build install
      #	dh_strip --dbg-package=appname-dbg
      binary: binary-indep binary-arch
      .PHONY: build clean binary-indep binary-arch binary install configure

      ""IMPORTANT: These are tabs and not spaces!"" Change the application name in the beginning of the file to your app name. Also note that the debug line is commented out. This change appears to be necessary in order to work properly.

  5. Copy the source directory (including the debian and maemofiles directories, but not the file) into another directory (outside the source directory) called app-version, for example appname-1.0.0, in your work directory. We'll call this the app-version directory. The version number should match the one in the changelog.
  6. In the app-version directory, issue the following commands:
    This should build a binary Debian package. This isn't really required to create the files we need, but is a good check that all is in working order.
    dpkg-buildpackage -sa -S

    This will build the source package files we need for submission. They wil be found in the work directory (the parent of the app-version directory) Note: You can also issue the dpkg-buildpackage commands with ~/NokiaQtSDK/Maemo/4.6.2/bin/mad in front of them (or wherever you find the mad binary files), for example:

    ~/NokiaQtSDK/Maemo/4.6.2/bin/mad dpkg-buildpackage -sa -S

    This will use MADDE to generate the files instead of doing it directly in the OS. This may be preferable, but I have seen it work fine either way for creating the source. The native buildpackage command will build an x86 or x86_64 package, and the MADDE buildpackage will build an armel package.

[edit] Submitting

At this point you should have all the files needed to upload to the Maemo extras assistant. The files you need should be located in your work directory.