Maemo 5.0 SDK without scratchbox

After years of fighting with scratchbox I decided to ditch it in favour of a simple chroot. These are the steps to set yourself free.
Ping me if you want to add something to this tutorial

TODO:

  • Automate this
  • Try to use schroot instead of chroot directly
  • ??? Another idea?

P.S.: For the armel arch replace i386 by armel in the following steps :-P

Download the rootstrap

$ wget http://repository.maemo.org/stable/5.0/i386/maemo-sdk-rootstrap_5.0_i386.tgz

Unpack the rootstrap

$ sudo mkdir -p /opt/devel/chroots/maemo/fremantle/i386
$ cd /opt/devel/chroots/maemo/fremantle/i386
$ sudo tar -xvzf /path/to/maemo-sdk-rootstrap_5.0_i386.tgz

ATTENTION: ARMEL ONLY STEP

$ sudo apt-get install qemu-arm-static
$ sudo cp /usr/bin/qemu-arm-static /opt/devel/chroots/maemo/fremantle/armel/usr/bin

Identify your chroot target

$ sudo -s
$ echo fremantle-i386 > /opt/devel/chroots/maemo/fremantle/i386/etc/debian_chroot

Copy the essential files

$ sudo cp /etc/resolv.conf /opt/devel/chroots/maemo/fremantle/i386/etc
$ sudo cp -a /etc/ld.so.conf* /opt/devel/chroots/maemo/fremantle/i386/etc

Get rid of the dpkg-preconfigure warnings

Edit the /opt/devel/chroots/maemo/fremantle/i386/etc/apt/apt.conf.d/70debconf file and
comment the line as follows.
// DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt || true";};

Get nokia binaries repository access.
Go to http://tablets-dev.nokia.com/eula/index.php
Do what you have to do there.
And get the resulting repository. It is something like this

deb http://repository.maemo.org/ fremantle/00000000000000000000000000000000 nokia-binaries

The sources.list should look something like

deb http://repository.maemo.org/ fremantle/sdk free non-free
deb-src http://repository.maemo.org/ fremantle/sdk free
deb http://repository.maemo.org/ fremantle/tools free non-free
deb-src http://repository.maemo.org/ fremantle/tools free
deb http://repository.maemo.org/ fremantle/00000000000000000000000000000000 nokia-binaries

deb http://repository.maemo.org/extras/ fremantle free non-free
deb-src http://repository.maemo.org/extras/ fremantle free

deb http://repository.maemo.org/extras-devel/ fremantle free non-free
deb-src http://repository.maemo.org/extras-devel/ fremantle free

Mount the filesystems

$ sudo mount -t proc proc /opt/devel/chroots/maemo/fremantle/i386/proc
$ sudo mount -t sysfs sysfs /opt/devel/chroots/maemo/fremantle/i386/sys
$ sudo mkdir /opt/devel/chroots/maemo/fremantle/i386/dev
$ sudo mount -o bind /dev /opt/devel/chroots/maemo/fremantle/i386/dev
$ sudo mount -t devpts devpts /opt/devel/chroots/maemo/fremantle/i386/dev/pts
$ sudo mkdir -p /opt/devel/chroots/maemo/fremantle/i386/var/lib/dbus
$ sudo mount -o bind /var/lib/dbus /opt/devel/chroots/maemo/fremantle/i386/var/lib/dbus

Enter the chroot

$ sudo LC_ALL=C chroot /opt/devel/chroots/maemo/fremantle/i386
# apt-get update
# apt-get -y --force-yes dist-upgrade

Create the dir where scratchbox devel tool will be located (later on we will add a symbolic link)

# mkdir /scratchbox/tools/bin

Install the development tools

# apt-get install libc6-dev g++ make dpkg-dev autoconf automake

# ln -s /usr/bin/perl /scratchbox/tools/bin
l# n -s /usr/bin/m4 /scratchbox/tools/bin

If you use https repositories

# apt-get source apt
# apt-get build-dep apt
# cd apt-<version>
# dpkg-buildpackage
# dpkg -i apt-transport-https....deb

Install nokia desktop packages

# apt-get install nokia-binaries nokia-apps

During the installation alarmd and mce will fail.
Solution:
Edit /etc/init.d/alarmd from alarmd package and comment the lines with start_alarmd and stop_alarmd. After that repeat the previous step. Do the same for the mce package.

Create some scratchbox compatibilities.

# mkdir -p /scratchbox/tools/bin
# ln -s /bin/kill /scratchbox/tools/bin/

Run the following command to start dbus and others daemons.

# af-sb-init.sh start

Continue with the installation

# apt-get install nokia-binaries nokia-apps

Stop dbus and other daemons

# af-sb-init.sh stop