Packaging a Qt application

(move some content to Packaging)
(Useful Links: add link)
 
(27 intermediate revisions not shown)
Line 1: Line 1:
-
= Packaging a Qt application for Maemo=
 
-
 
{{main|Packaging}}
{{main|Packaging}}
-
== Porting a Debian package to a Maemo package ==
+
Packaging a Qt application for Maemo is very similar to packaging any other application, so this document only contains information on Qt-specific packaging issues.
-
If your application has been already packaged for Debian, you can begin your Maemo packaging with this section. Once you have the source of the debian package, you will need to make some modifications to that package for it to build under Maemo. For the complete Maemo Package Policy, use [http://maemo.org/forrest-images/pdf/maemo-policy.pdf this link] to a pdf.
+
 
 +
== Creating a Maemo package from a qmake project ==
 +
 
 +
In order to create a new package for Maemo, from a qmake project, you will need to:
 +
* Rename the source directory to <code>Package-Version</code> (for example myapp-0.1 for an application ‘myapp’ with a version of ‘0.1’)
 +
* Create a ‘src’ directory in <code>Package-Version/</code>
 +
* Copy all the files to the <code>src/</code> directory
 +
* Rename <code>src/appname.pro</code> to <code>src/src.pro</code>
 +
Please make sure that the directory name is <package-version> format and in small case letters.
-
In order to create a new package for maemo, you'll need to:
 
-
* Rename the upstream source directory in Package-Version (eg: myapp-0.1)
 
-
* Create “src” directory in Package-Version/
 
-
* Copy all the files in the src/
 
-
* Rename src/appname.pro in src/src.pro
 
<pre>
<pre>
$mv myapp myapp-0.1
$mv myapp myapp-0.1
Line 19: Line 20:
</pre>
</pre>
-
Append the following chunk to end of your src/src.pro . The chunk adds install section to your qmakefile   
+
Append the following chunk to end of your <code>src/src.pro</code>. The chunk adds an install section to your qmakefile   
<pre>
<pre>
-
  unix {
+
unix {
-
    #VARIABLES
+
  #VARIABLES
-
    isEmpty(PREFIX) {
+
  isEmpty(PREFIX) {
-
        PREFIX = /usr/local
+
    PREFIX = /usr
   }
   }
-
BINDIR = $$PREFIX/bin
+
  BINDIR = $$PREFIX/bin
-
DATADIR =$$PREFIX/share
+
  DATADIR =$$PREFIX/share
-
DEFINES += DATADIR=\"$$DATADIR\" PKGDATADIR=\"$$PKGDATADIR\"
+
  DEFINES += DATADIR=\\\"$$DATADIR\\\" PKGDATADIR=\\\"$$PKGDATADIR\\\"
-
#MAKE INSTALL
+
  #MAKE INSTALL
-
INSTALLS += target desktop iconxpm icon26 icon48 icon64
+
  INSTALLS += target desktop service iconxpm icon26 icon48 icon64
   target.path =$$BINDIR
   target.path =$$BINDIR
Line 41: Line 42:
   desktop.files += $${TARGET}.desktop
   desktop.files += $${TARGET}.desktop
-
   iconxpm.path = $$DATADIR/pixmap
+
   service.path = $$DATADIR/dbus-1/services
-
  iconxpm.files += ../data/maemo/$${TARGET}.xpm
+
   service.files += $${TARGET}.service
-
 
+
-
   icon26.path = $$DATADIR/icons/hicolor/26x26/apps
+
-
  icon26.files += ../data/26x26/$${TARGET}.png
+
-
 
+
-
  icon48.path = $$DATADIR/icons/hicolor/48x48/apps
+
-
  icon48.files += ../data/48x48/$${TARGET}.png
+
   icon64.path = $$DATADIR/icons/hicolor/64x64/apps
   icon64.path = $$DATADIR/icons/hicolor/64x64/apps
Line 56: Line 51:
-
*Create a myapp-0.1/myapp.pro file like this:
+
*Create a <code>myapp-0.1/myapp.pro</code> file like this:
<pre>
<pre>
QMAKEVERSION = $$[QMAKE_VERSION]
QMAKEVERSION = $$[QMAKE_VERSION]
Line 75: Line 70:
dh_make --createorig --single -e maintainer@email.org -c gpl
dh_make --createorig --single -e maintainer@email.org -c gpl
</pre>
</pre>
-
 
-
== Having a look inside the debian/ dir ==
 
-
At this point the directory my-app contains
 
-
* the source directory ( src/ )
 
-
* the debian directory (debian/)
 
-
 
-
Inside the debian dir we have the files needed for the creation of the debian package
 
-
* Changelog  - Application's change log
 
-
* Compat  - Debian helper compatibly version
 
-
* Control - Describes the packages to be made
 
-
* Copyright - Copyright text
 
-
* Rules - A binary makefile containing the rules to build the package
 
-
 
-
== Maemo Packaging Policy ==
 
-
Maemo packages follow the Debian Policy, but there are some items where Maemo:
 
-
* Is more strict (it is an embedded distribution)
 
-
* Is more relaxed
 
-
**Only a target device (Nokia Internet Tablet)
 
-
**Only a specified UI (Hildon)
 
-
**Only one user.
 
-
*Differs from Debian because Maemo has different:
 
-
**Objectives
 
-
**Maintainers
 
-
**Infrastructure
 
-
 
-
==Editing the Control file ==
 
-
Basically it specifies for each package (source or binary) a name, some dependencies, a description etc...
 
-
For a Maemo package these fields are very important:
 
-
* [http://wiki.maemo.org/Task:Package_categories#Translations Section]: Only the packages in the user segment are showed by App Installer.
 
-
* Maintainer: This field MUST be changed if the upstream package is modified
 
-
* XB-Maemo-Icon26: It contains the PNG icon encoded in base64 visible in the Application Installer
 
-
 
-
If you need to encode your icon as base64, there are [http://wiki.maemo.org/Maemo_packaging#Displaying_an_icon_in_the_Application_Manager_next_to_your_package instructions here.]
 
-
 
-
<pre>
 
-
Source: my-application
 
-
Section: user/valid_subsection
 
-
Priority: optional
 
-
Maintainer: name surname <xxxxxxx.xxxxxx@maemo.org>
 
-
XSBC-Original-Maintainer: name surname <yyyyy.yyyyy@debian.org>
 
-
Build-Depends: debhelper (>= 5), libqt4-dev, OTHERS_BUILD DEPENDECIES
 
-
Standards-Version: 3.7.3
 
-
 
-
Package: my-application
 
-
Architecture: any
 
-
Depends: ${shlibs:Depends}, ${misc:Depends}
 
-
Description: A simple test application
 
-
A very simple application with a short description.
 
-
Which spans multiple lines actually.
 
-
XB-Maemo-Icon-26:
 
-
iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAABmJLR0QA/wD/AP+g
 
-
vaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1gURDQoYya0JlwAAAU9J
 
-
REFUSMftlL1KA0EUhb/NZl/ggnHQxsJUxt5CUucVJCCkDfgyKdIGG5/A0s5HEBtJ
 
-
EdDAQGBgmw0YJmMzgXXYza5CtNkDW9zZw5z7c+ZCgwb/Ai3i9sVl/Bq8RIs4LRK1
 
-
gJDsKvJyNXmJMuYTsMoY1zpgozaABdYArQNPZQ1kfyGU7SpqVwxzAMwABWhgpIwp
 
-
4vWBB+AUWAI3ypjnfEXtPU4bLKx9vErTeCeiRSYF+fTn1j5dp2myE9EiU+DSi3wX
 
-
ymeqRQAmZ3EcA5E/fgO6BULT8zhOcrwXoJdrXRa2Lgps2y2odAUcBUIXQdz78YyC
 
-
SldAp8b7+bXrIv91qjZBietqCc2DjbAt4b2WxJkyZljVujlwp0U0cPxuLcAIuC+4
 
-
dKxFlsDJarvdAGP/b6hFnDImYs+uG3hbO2AB3Jbsur63tQM+fFx3bzZocEB8AdV2
 
-
gJBZgKTwAAAAAElFTkSuQmCC
 
-
 
-
Package: my-application-dbg
 
-
Section: devel
 
-
Architecture: any
 
-
Depends: my-application (= ${binary:Version})
 
-
Description: Debug symbols for a simple test application
 
-
Debug symbols for a very simple application, which allow
 
-
tracing and debugging.
 
-
</pre>
 
-
 
-
Valid subsections are:
 
-
* accessories
 
-
* communication
 
-
* games
 
-
* multimedia
 
-
* office
 
-
* other
 
-
* programming
 
-
* support
 
-
* themes
 
-
* tools
 
== Editing the rules file ==
== Editing the rules file ==
-
The rules file generated by dh_make will be modified in order to look like this one.
+
The rules file generated by <code>dh_make</code>, found in <code>debian/rules</code> will be modified in order to look like this one. We are using qmake, so there is no <code>configure</code> script to run. If you copy and paste the following file, notice the empty space at the beginning of the lines these are TAB characters, they are not multiple space characters. If you copy and paste the following chunk, you most propably get space's instead of tabs if this is true then the file will not work.
-
We are using qmake, so we haven't a configure file to run.  
+
-
If you cut-and-paste following file, notify that empty space beginning of lines it TAB characters, it is not multiple space characters. If you cut-and-paste  
+
-
the following chunk, you most propably get spaces instead tabs and the file does not wok
+
<pre>
<pre>
Line 220: Line 131:
</pre>
</pre>
-
== Application menu icon & position ==
+
== Editing the control file ==
-
The Maemo application menu detects automatically an app that provides a .desktop file in /usr/share/application/hildon . If you don't have desktop file, create one in the src directory.
+
The control file generated by <code>dh_make</code>, found in <code>debian/control</code> will be modified substantially. Please refer to the general packaging guide for Maemo for details.
-
<pre>
+
For Qt applications you need to make sure to add <code>libqt4-dev</code> as an additional entry in the field <code>Build-Depends</code>.
-
[Desktop Entry]
+
-
Encoding=UTF-8
+
-
Version=0.1
+
-
Type=Application
+
-
Name=myapp
+
-
Exec=/usr/bin/myapp
+
-
Icon=myapp
+
-
X-HildonDesk-ShowInToolbar=true
+
-
X-Osso-Type=application/x-executable
+
-
</pre>
+
 +
== Example ==
 +
You can download the [http://maemo.org/packages/view/qt-maemo-example/ source package of qt-maemo-example] from the [[extras-devel]] repository as follows, if you have source packages enabled in your <code>/etc/apt/sources.list</code> file:
-
Maemo menu structure is completely different from Debian:
+
  apt-get source qt-maemo-example
-
* An unmodified Debian package installs the proper .desktop in /usr/share/applications
+
-
* Applications that use the debian menu are displayed in the extra menu
+
-
 
+
-
In order to show our application in the correct Maemo menu:
+
-
* debian/myapp.install moves the .desktop file and icons in the right directory
+
-
<pre>
+
-
src/*.desktop usr/share/applications/hildon
+
-
src/*.png usr/share/icons/hicolor/26x26/apps
+
-
</pre>
+
-
 
+
-
* debian/postinst should call maemo-select-menu-location utility to permit the user to choose the menu location.  '''This works only in Diablo, it doesn't work in Fremantle.'''
+
-
<pre>
+
-
#!/bin/sh
+
-
maemo-select-menu-location myapp.desktop
+
-
</pre>
+
-
 
+
-
== Checking Maemo Packages ==
+
-
Lintian dissects Debian packages and reports bugs and policy violations.
+
-
It contains automated checks for many aspects of Debian policy as well as some checks for common errors.
+
-
Unfortunately it doesn't check conformance to the additional Maemo policy.
+
-
 
+
-
Currently Maemo is creating [http://maemian.garage.maemo.org/ Maemian] to check its policy.
+
-
 
+
-
== Building the binary and the source package ==
+
-
To build only binary packages:
+
-
<pre>$dpkg-buildpackage -rfakeroot -b</pre>
+
-
we can install these binary package with dpkg:
+
-
<pre>$dpkg -i myapp.deb</pre>
+
-
 
+
-
To build the source package and to sign it with your gpg key (ABCDEF12)
+
-
<pre>dpkg-buildpackage -rfakeroot -sa -S -kABCDEF12</pre>
+
-
 
+
-
At this point, if you have tested your package and it works fine, you can [[Uploading_to_Extras-devel|upload it to extras-devel]].
+
-
 
+
-
= Example =
+
-
You can download the source package of qt-maemo-example from the extras-devel repository just running if you have source packages enabled in your sources file;
+
-
 
+
-
''apt-get source qt-maemo-example''
+
This command will download the:
This command will download the:
-
- unmodified source (.orig.tar.gz)
+
* unmodified source (.orig.tar.gz)
 +
* debian dsc file (.dsc)
 +
* diff file (.diff)
-
- debian dsc file (.dsc)
+
and will then automatically launch <code>dpkg -x file.dsc</code> in order to decompress the orig.tar.gz and apply the changes.
-
- diff file (.diff)
+
== Useful Links ==
-
 
+
-
and after it will launch automatically dpkg -x file.dsc in order to uncompress the orig.tar.gz and apply the changes.
+
-
 
+
-
= Useful Links =
+
 +
* [[Packaging Qt Creator Apps for Maemo Extras]]
* [[Qt-Maemo|Qt for Maemo]]
* [[Qt-Maemo|Qt for Maemo]]
* [[Packaging|Packaging guide for Maemo]]
* [[Packaging|Packaging guide for Maemo]]
-
* [http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html Desktop entry specification]
+
* [http://doc.qt.nokia.com/qt-maemo-4.6/maemo5-with-qt-introduction.html#deploying-your-applications Deploying your Maemo 5 Qt application] Qt documentation
-
 
+
-
= Debhelper 7 =
+
-
 
+
-
A backport of Debhelper 7 for fremantle is available in extras-devel.
+
-
It works transparently and can coexist with debhelper 5 in the SDK.
+
-
It even works on autobuilder, if you specify the correct build-dependency debhelper7.
+
-
Read the mails about [http://www.mail-archive.com/maemo-developers@maemo.org/msg23779.html debhelper7]
+
-
and [http://www.mail-archive.com/maemo-developers@maemo.org/msg23749.html cdbs-dh7].
+
-
 
+
-
Alternatively, you can try to use debhelper 5 in some cases:
+
-
 
+
-
Debian packages that requires level 7 needs some changes:
+
-
eg:
+
-
* debian/compat:  7 -> 5
+
-
* debian/control: Build-Depends: debhelper (>= 7) -> debhelper (>= 5)
+
-
* And maybe comment out a few dh_* calls from debian/rules, which might not exist on level 5
+
-
 
+
-
Now things might get complex if the packaging already uses some new
+
-
features of level 7, like those CDBS-like helper rules. In such cases,
+
-
looking at versions prior to the compatibility level upgrade might
+
-
help doing the downgrade (and most Debian packages are kept in public
+
-
SCMs like svn.debian.org).
+
-
[[Category:Development]]
+
[[Category:Packaging]]
[[Category:Qt]]
[[Category:Qt]]

Latest revision as of 09:11, 4 November 2010

Main article: Packaging


Packaging a Qt application for Maemo is very similar to packaging any other application, so this document only contains information on Qt-specific packaging issues.

Contents

[edit] Creating a Maemo package from a qmake project

In order to create a new package for Maemo, from a qmake project, you will need to:

  • Rename the source directory to Package-Version (for example myapp-0.1 for an application ‘myapp’ with a version of ‘0.1’)
  • Create a ‘src’ directory in Package-Version/
  • Copy all the files to the src/ directory
  • Rename src/appname.pro to src/src.pro

Please make sure that the directory name is <package-version> format and in small case letters.

$mv myapp myapp-0.1
$cd myapp-0.1
$mkdir src
$cp * src
$mv src/appname.pro src/src.pro

Append the following chunk to end of your src/src.pro. The chunk adds an install section to your qmakefile

unix {
  #VARIABLES
  isEmpty(PREFIX) {
    PREFIX = /usr
  }
  BINDIR = $$PREFIX/bin
  DATADIR =$$PREFIX/share

  DEFINES += DATADIR=\\\"$$DATADIR\\\" PKGDATADIR=\\\"$$PKGDATADIR\\\"

  #MAKE INSTALL

  INSTALLS += target desktop service iconxpm icon26 icon48 icon64

  target.path =$$BINDIR

  desktop.path = $$DATADIR/applications/hildon
  desktop.files += $${TARGET}.desktop

  service.path = $$DATADIR/dbus-1/services
  service.files += $${TARGET}.service

  icon64.path = $$DATADIR/icons/hicolor/64x64/apps
  icon64.files += ../data/64x64/$${TARGET}.png
}


  • Create a myapp-0.1/myapp.pro file like this:
QMAKEVERSION = $$[QMAKE_VERSION]
ISQT4 = $$find(QMAKEVERSION, ^[2-9])
isEmpty( ISQT4 ) {
error("Use the qmake include with Qt4.4 or greater, on Debian that is qmake-qt4");
}

TEMPLATE = subdirs
SUBDIRS  = src
  • Run dh_make to debianize the source archive, it creates:
    • An archive with the unchanged upstream source (orig.tar.gz)
    • Some basic files in the debian directory
    • Some example files (*.EX *.ex)
export DEBFULLNAME="maintainer first name and last name"
dh_make --createorig --single -e maintainer@email.org -c gpl

[edit] Editing the rules file

The rules file generated by dh_make, found in debian/rules will be modified in order to look like this one. We are using qmake, so there is no configure script to run. If you copy and paste the following file, notice the empty space at the beginning of the lines these are TAB characters, they are not multiple space characters. If you copy and paste the following chunk, you most propably get space's instead of tabs if this is true then the file will not work.

#!/usr/bin/make -f
APPNAME := my_app_name
builddir:
        mkdir -p builddir

builddir/Makefile: builddir
        cd builddir && qmake-qt4 PREFIX=/usr ../$(APPNAME).pro

build: build-stamp

build-stamp: builddir/Makefile
        dh_testdir
        # Add here commands to compile the package.
        cd builddir && $(MAKE)
        touch $@

clean:
        dh_testdir
        dh_testroot
        rm -f build-stamp
        # Add here commands to clean up after the build process.
        rm -rf builddir
        dh_clean
install: build
        dh_testdir
        dh_testroot
        dh_clean -k
        dh_installdirs

        # 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_testdir
        dh_testroot
        dh_installdocs
        dh_installexamples
        dh_installman
        dh_link
        dh_strip --dbg-package=my-application-dbg
        dh_compress
        dh_fixperms
        dh_installdeb
        dh_shlibdeps
        dh_gencontrol
        dh_md5sums
        dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

[edit] Editing the control file

The control file generated by dh_make, found in debian/control will be modified substantially. Please refer to the general packaging guide for Maemo for details.

For Qt applications you need to make sure to add libqt4-dev as an additional entry in the field Build-Depends.

[edit] Example

You can download the source package of qt-maemo-example from the extras-devel repository as follows, if you have source packages enabled in your /etc/apt/sources.list file:

apt-get source qt-maemo-example

This command will download the:

  • unmodified source (.orig.tar.gz)
  • debian dsc file (.dsc)
  • diff file (.diff)

and will then automatically launch dpkg -x file.dsc in order to decompress the orig.tar.gz and apply the changes.

[edit] Useful Links