Port an existing Debian package

Finding your package in Debian
If you want to port a Debian package to Maemo, you should check and see if it is already packaged for Debian and use that package if you can - this will save you time and effort. You can search in Debian's Package Tracking System (PTS) to see if it is there. There is a search system on the PTS page, under the "distribution" drop-down, select 'any', this will search throughout Debian's repositories to find the package. Debian has more than 20,000 packages just in its stable distribution so your application is likely already packaged.

If you find the package already exists in Debian, you can get the source, including the packaging source, with apt-get. To do this, you'll have to edit your, you can follow this recipe;

$ echo "deb http://ftp.it.debian.org/debian/ unstable main contrib non-free" >> /etc/apt/sources.list $ echo "deb-src http://ftp.it.debian.org/debian/ unstable main contrib non-free" >> /etc/apt/sources.list $ apt-get update $ apt-cache search "application name" $ apt-get source "application name"

To learn more about the  you can do a 'man sources.list' if you are running Debian or a Debian-based GNU/Linux distro.

Modifying a Debian package for Maemo
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. See the Maemo packaging policy for more information.

The maintainer field (in the  file) must be changed if the upstream package is modified, for example: Maintainer: Tcl/Tk Debian Packagers  should be replaced by Maintainer: My Name  XSBC-Original-Maintainer: Tcl/Tk Debian Packagers 

You must add a new entry to  and append   to the version, for example: tk8.5 (8.5.8-1) unstable; urgency=low becomes: tk8.5 (8.5.8-1maemo1) fremantle; urgency=low This indicates that there have been Maemo-specific changes to the packaging. If you upload new changes, you must add a new changelog entry and increment the version number, for example ).

The "Debian way" is to keep all modifications to the package in the  file and to leave the   file untouched. There are several ways to apply patches with Debian packaging, and some are described in the patching section of the New Maintainer's Guide

However, the  cannot store binary files like icons. A possible workaround is to uuencode the binary file, for example (in ): uuencode -m icon.png icon.png > icon.png.b64 and in the rules file decode the file to debian/icon.png before installation uudecode debian/icon.png.b64 For this solution you have to add  to the.

If the package should be visible in the Application Manager, the Section field should begin with, with the valid sections. You should also add and install a  file for starting the application, if one does not already exist.

Differences between Debian/Ubuntu and Maemo
The are a couple of important differences between a Debian system and Maemo:


 * Busybox: Maemo uses busybox to replace most of bsdutils, coreutils, findutils and bash, therefore most of the extended options for the commands and shell are not available. Check the postinstall and other package scripts for such options and try to replace or emulate them.


 * Outdated build and configuration tools: the SDK and autobuilder provide only outdated versions of gcc, dpkg, debhelper, cdbs, debconf, ucf and other build tools. Try to replace the  in the   file with older versions or use backports like debhelper7


 * Directories for temporary files: is only 900 kB and should only be used for very small temporary files.   on the NAND is larger. A new temporary directory in   could be even larger. Replace constructs like   in shell scripts with   (the same applies to  ).


 * Optification may confuse programs: some programs try to find their data files relative to the binary location. Such a program stored in  would search, for instance, in   while the actual data may be in.


 * Installation in : if you want to perform manual optification (e.g. using  ) you should store "none" in   and add some to the postinst script which symlinks the binaries and libraries of the package to   and , respectively.


 * Documentation: do not install documentation in  or   - docpurge will remove it. You may install it in the   hierarchy, however.