Creating Debian ARM Packages For Nokia 770

Here is a collection of instructions gathered from different sources in order to build a Debian package from the source code. For the general discussion, refer to Debian New Maintainers' Guide

All binary Debian packages consist of three basic things:

Naming Convention

Every Debian binary package should have a filename that follows this format: packagename_version_arch.deb, where

Creating a Debian Package

To debianize the package libfoo whose version is 0.1.0, set the environment variables:

$ export DEBFULLNAME="Vladislav Grinchenko"
$ export EMAIL="vlg@users.sourceforge.net"
		  

Go into the libfoo source directory and make a distribution tarball:

$ cd libfoo
$ autogen.sh
$ configure --prefix=/usr
$ make
$ make dist
$ make isntall
		  

NOTE: Make sure you ran make install command. Otherwise, you won't be able to build applications based on libfoo in SDK_ARM target. This is another obstacle to overcome (any comments would be highly welcome).

Move distribution tarball out and rename directory to the bearing the proper version information, libfoo-0.1.0

$ mv libfoo-0.1.0.tar.gz ..
$ cd ..
$ mv libfoo/ libfoo-0.1.0/
$ cd libfoo-0.1.0
		  

Debianize the package (make sure there is no debian directory)

$ dh_make -l -c lgpl -f ../libfoo-0.1.0
$ cd debian
$ rm -f *.ex *.EX README.Debian
		  

Now, you are ready to muck with debian/ control files. You would have to change them slightly to adjust to the hildon framework.

changelog File

libfoo (0.1.0-1) unstable; urgency=low
                                                                                              
  * Initial Release.
                                                                                              
 -- Vladislav Grinchenko   Sat, 14 Jan 2006 19:06:00 -0500
		  

control File

Source: foobar
Priority: optional
Maintainer: Vladislav Grinchenko <vlg@users.sourceforge.net>
Build-Depends: debhelper (>= 4.0.0)
Standards-Version: 3.6.0

Package: foobar-dev
Section: devel
Architecture: any
Description: C++ wrapper for foobar
 Wraps foobar into C++ classes.

Package: foobar
Section: libs
Architecture: any
Depends: maemo
Description: C++ wrapper for foobar
 Wraps foobar into C++ classes.

		  

rules File

# Build architecture-dependent files here.
binary-arch: build install
    dh_testdir
    dh_testroot
    dh_installchangelogs ChangeLog
    dh_installdocs
    dh_installexamples
    dh_install --sourcedir=debian/tmp 
...
    dh_link
    dh_strip
    dh_compress
    dh_fixperms
#   dh_perl
#   dh_python
    dh_makeshlibs --noscripts 
    dh_installdeb
    dh_shlibdeps
    dh_gencontrol
    dh_md5sums
    dh_builddeb

...
		  

Rename all debian/*.files to debian/*.install - otherwise, the libraries are not packaged (someone should explain why?):

$ cd libfoo/debian

$ mv libfoo.files libfoo.install
$ mv libfoo-dev.files libfoo-dev.install
		  

NOTE: Now, the weird part, move foobar-0.1.0 back to foobar.

$ mv foobar-0.1.0/ foobar/
		  

Building The Packages

Go to libfoo/ and build debian packages:

$ cd libfoo
$ dpkg-buildpackage -rfakeroot  -uc -us -sa -D -b
		  

The last option, -b, tells dpkg-buildpackage to ignore dependencies. This is due to the wicked maemo build/install incongruity.

Validate The Package

It is worth to look into the package to validate that everything was properly placed together. First, copy the package to some tmp/ directory, and the unpack it and examine the structure layout:

$ cd ..
$ mkdir tmp
$ cp libfoo_0.1.0-1_arm.deb tmp
$ cd tmp
$ ar -x libfoo_0.1.0-1_arm.deb
$ ls 

control.tar.gz
data.tar.gz
debian-binary
libfoo_0.1.0-1_arm.deb

$ tar xvfz control.tar.gz

./
./md5sums
./control

		  

Pause here and validate that there was neither postinst nor postrm scripts packed in. If they were, then either you had them in your libfoo/debian/ directory or you forgot to modify the rules file as shown above.

You can find more information on Debian package here. It also shows you how to create a Debian package by hand. This might come useful if you want to put together a bunch of libraries as one maemo package.

Various Useful Commands

To get source code and build package from it:

% apt-get source -b package
		  

To show all packages installed on your system:

% apt-show-versions 
		  

To install a package and its dependencies from Debian repository:

# apt-get intall package
		  

To remove a package (and I guess all others that depend on in):

% apt-get --purge remove package
		  

To list everything installed on the system (you might want to install it first):

% apt-show-versions
		  

To search for a specific pattern name:

% dpkg-query --list 'libgtkmm*'
% dpkg-query --listfiles 'libgtkmm*'
		  

To list the contents of the package:

% dpkg --status package
% dpkg --contents package
		  

To install a .deb package file downloaded manually:

% dpkg-install package.deb
		  

To get around dependency on pseudo-package maemo in SDK_ARM target, use special installation utility, app-installer-tool instead:

% fakeroot 
% app-installer-tool install package.deb
		  

Calling app-installer-tool is equivalent to the following command:

% dpkg --force-not-root --root=/var/lib/install --install package.deb
		  

To remove a package:

% dpkg --remove package
		  

To build a package foobar-1.0.0 from the source. This implies presense of foobar-1.0.0/debian/ package configuration files in the source (at least that is how I understand it).

% cd foobar-1.0.0 

% dpkg-buildpackage -rfakeroot  -uc -us -sa -D

or to ignore dependencies

% dpkg-buildpackage -rfakeroot  -uc -us -sa -D -d
		  

To find the package that contains a file filename:

% dpkg -S filename
		  

Vladislav Grinchenko