Maemo Packages
On Maemo (the Linux distribution for Nokia internet tablets), software
is distributed as Debian packages. This document describes a simple way
to build such packages for Maemo applications.
While methods to build packages for Maemo are described in Maemo
official
documentation, they seem to be overly complicated: they rely on Debian
tools which generate many superfluous files and require the tuning of a
"rules" file difficult to reverse-engineer and to master.
Our goal is to show a simple method based on:
- the basic format of Debian packages (.deb files);
- the requirements for well-behaved Maemo applications.
Remark: this is a work in progress. Information is gathered from
experiments done to create packages for Hike
and Sysquake.
Format of a package file
Package files (.deb files) are described in manual pages
deb (5) and deb-control (5). They
are archive files which can be created and manipulated by the
ar unix tool. They contain the following members, in that
order:
debian-binary, a text file which contains 2.0;
control.tar.gz, a compressed tar file with metadata (see below);
data.tar.gz, a compressed tar file whose contents will be expanded
at the root level of the internet tablet.
control.tar.gz contains files without any directory. One
file is mandatory: control, which describes the package. Other
files important for Maemo packages are postinst, a shell script
which is executed after files in data.tar.gz have been unarchived,
and postrm, a shell script which is executed at uninstall time after
the files in data.tar.gz have been removed.
control is a text file with the following contents for a Maemo
application:
Package: package name
Version: version number
Architecture: armel
Section: user/other
Installed-Size: size in KB once installed
Depends: dependencies (can be empty)
Maintainer: package maintainer name and contact
Description: one-line description
Longer description indented by one space. Empty lines
must contain a single indented dot.
XB-Maemo-Icon-26:
26x26 icon as a PNG file with transparent background,
encoded in base64, indented by one space (optional).
Dependencies should reflect the libraries used by the applications.
For the moment, we'll leave it empty.
The icon, if defined, is used by the Application Manager.
To encode it, including the indenting, the following command
can be used:
openssl base64 <icon26.png | sed -e 's/^/ /'
Here is the current control file of Hike:
Package: Hike
Version: 0.1-1
Architecture: armel
Section: user/other
Installed-Size: 123
Depends: maemo-installer-utils
Maintainer: Yves Piguet, http://nyctergatis.com
Description: GPS location on maps grabbed with a digital camera
Hike is a simple application for displaying GPS location on a
map provided as an image file, typically obtained with a digital
camera. Conversion from longitude/latitude to pixel coordinates
is based on some reference points (at least 2) entered directly
in Hike.
.
Typical usage is for places where good electronic maps aren't
easily available, such as hiking paths.
XB-Maemo-Icon-26:
iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAACXBIWXMAAAsTAAAL
...
hlEkjYRRdVrzUyOjmw60d3bsGh4e+tfAwID7v3w+c/0HDBpWaaV6V1AAAAAASUVO
RK5CYII=
Script
Here is the shell script used to create Debian packages
(download). It relies on ar and
the GNU version of tar (with support for gzip compression).
#!/bin/sh
# Make .deb package
# Usage: make-deb-package data control [-o p.deb] [-postinst postinst] [-postrm postrm]
# Yves Piguet, 3 Sept 2008, http://nyctergatis.com
# help
if [ "$1" == --help -o -z "$1" -o -z "$2" ]
then
echo "Usage: $0 data control [-o p.deb] [-postinst postinst] [-postrm postrm]"
echo "data: directory to be unarchived at the root of the target file system"
echo "control: debian control file"
echo "p.deb: output package file"
echo "postinst: shell script to execute after installation"
echo "postrm: shell script to execute after removal"
exit 0
fi
# default values
DIR="$1"
CONTROL="$2"
DEB="$DIR".deb
POSTINST=""
POSTRM=""
if [ -n "$TMPDIR" ]
then
TMP=$TMPDIR"debian-tmp"
else
TMP=/tmp/debian-tmp
fi
# decode optional arguments
while [ -n "$3" ]
do
case "$3" in
-o)
DEB="$4"
;;
-postinst)
POSTINST="$4"
;;
-postrm)
POSTRM="$4"
;;
*)
echo "Unknown option $3" >&2
echo "Type $0 --help for help" >&2
exit 1
;;
esac
shift
shift
done
# create temporary directory
rm -Rf "$TMP"
mkdir "$TMP"
# debian-binary
echo 2.0 >"$TMP"/debian-binary
# control.tar.gz
mkdir "$TMP"/control
cp "$CONTROL" "$TMP"/control/control
if [ -n "$POSTINST" ]
then
cp "$POSTINST" "$TMP"/control/postinst
chmod +x "$TMP"/control/postinst
fi
if [ -n "$POSTRM" ]
then
cp "$POSTRM" "$TMP"/control/postrm
chmod +x "$TMP"/control/postrm
fi
(cd "$TMP"/control; COPY_EXTENDED_ATTRIBUTES_DISABLE=true tar cfz ../control.tar.gz *)
# data.tar.gz
(cd "$DIR"; COPY_EXTENDED_ATTRIBUTES_DISABLE=true tar cfz "$TMP"/data.tar.gz *)
# deb
ar -q "$DEB" \
"$TMP"/debian-binary "$TMP"/control.tar.gz "$TMP"/data.tar.gz
# clean up
rm -Rf $TMP
exit 0
Here is a fragment of the makefile of Hike.
It assumes that the application binary file hike,
metadata files control, postinstall and postrm,
desktop file hike.desktop, service file hike.service,
and help file hike.xml are in the current directory.
NAME = hike
SERVICENAME = com.nyctergatis.Hike
DATE = $(shell date "+%y%m%d")
$(NAME)-$(DATE).deb: $(NAME) $(NAME).desktop $(SERVICENAME).service control
mkdir data
mkdir -p data/usr/bin
mkdir -p data/usr/share/applications/hildon
mkdir -p data/usr/share/dbus-1/services
mkdir -p data/usr/share/osso-help/en_GB
mkdir -p data/usr/share/icons/hicolor/26x26/hildon
mkdir -p data/usr/share/icons/hicolor/40x40/hildon
mkdir -p data/usr/share/icons/hicolor/scalable/hildon
cp $(NAME) data/usr/bin
cp $(NAME).desktop data/usr/share/applications/hildon
cp $(SERVICENAME).service data/usr/share/dbus-1/services
cp $(NAME).xml data/usr/share/osso-help/en_GB
cp $(NAME)-26.png data/usr/share/icons/hicolor/26x26/hildon/hike.png
cp $(NAME)-40.png data/usr/share/icons/hicolor/40x40/hildon/hike.png
cp $(NAME)-64.png data/usr/share/icons/hicolor/scalable/hildon/hike.png
./make-deb-package data control -o $@ -postinst postinst
rm -Rf data
|