Many packages in Debian require a lot of other Debian packages to be installed before they can built from sources. Some of those dependensies are also circular meaning that for package A to be built, package B has to be installed, but either directly or through other dependencies package B requires package A to be installed before it can be built.
Optimal solution would be that all developement tools that are required in build processes would be run on the developement host which is faster than the target platform, but including everything provided by Debian in scratchbox is not very practical and in any case we need libraries for the target platform when linking software or testing the compiled binaries.
Normally when one compiles Debian packages on a host natively Debian is already installed on that machine providing needed libraries, programs and a (hopefully) intact dpkg package database.
As it is hard to do a normall install to the target platform inside scratchbox (especially when some packages might require more resources at install time than the target platform has to offer) we did a "pre-installation" of the packages and packaged them into a tar archive which can be extracted directly to the "/targets/<TARGETNAME>/" directory inside scratchbox. It contains enough packages for 'apt-get source -b galculator' to work "out-of-the-box".
Start Scratchbox
$ /scratchbox/users/username/run.sh
Make sure you have created the ARM target (see Configuring Scratchbox for ARM)
You can download a preliminary version of rootstrap from the download section.
Eexample: wget http://scratchbox.org/download/files/crocodile-files/rootstrap_0.9.7.1-1.tar.gz
Extract rootstrap inside Scratchbox to your target directory
Example: $ xfz rootstrap_0.9.7.1-1.tar.gz -C /targets/ARM
Post-installation of rootstrap is not automated/scripted yet so you need to
Add your useraccount to /etc/passwd, /etc/group
Example: echo "$USER:x:$UID:$UID:,,,:/home/$USER:/bin/bash" >> /etc/passwd echo "$USER:x:$UID:" >>
/etc/group
Fix /etc/resolv.conf to match your network settings
Example: From OUTSIDE of scratchbox $ cp /etc/resolv.conf
/scratchbox/users/$USER/targets/ARM/etc/resolv.conf
Setup .bashrc with Scratchbox specific variables
Example: INSIDE scratchbox [sbox-ARM: ~ ] > cat > ~/.bashrc <<EOF
# Unset verbose cputransparency as it interferes with some configure scripts
unset SBOX_CPUTRANSPARENCY_VERBOSE
# Setup binary redirection for some executables
export SBOX_REDIRECT_BINARIES=/usr/bin/perl:/scratchbox/tools/bin/perl
export SBOX_REDIRECT_BINARIES=$SBOX_REDIRECT_BINARIES#/usr/bin/make:/scratchbox/tools/bin/make
export SBOX_REDIRECT_BINARIES=$SBOX_REDIRECT_BINARIES#/usr/bin/file:/scratchbox/tools/bin/file
export SBOX_REDIRECT_BINARIES=$SBOX_REDIRECT_BINARIES#/usr/bin/msgmerge:/scratchbox/tools/bin/msgmerge
export SBOX_REDIRECT_BINARIES=$SBOX_REDIRECT_BINARIES#/usr/bin/msgfmt:/scratchbox/tools/bin/msgfmt
export SBOX_REDIRECT_BINARIES=$SBOX_REDIRECT_BINARIES#/usr/bin/awk:/scratchbox/tools/bin/awk
# Setup perl to also search for modules from target directories export
PERL5LIB=/usr/lib/perl/5.8.0:/usr/lib/perl5:/usr/share/perl/5.8.0:/usr/share/perl5
# Set scratchboxes dpkg architecture
export SBOX_DPKG_INST_ARCH=arm
# Set scratchboxes architecture
export SBOX_UNAME_MACHINE=arm
# Setup TMPDIR to something that is also available on CPU transparency device
# /tmp is not mounted via NFS normally
export TMPDIR=/var/tmp
# Some buildscripts require these
export PERL=/usr/bin/perl
export PERL_PATH=/usr/bin/perl
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
export BUILDCC=host-gcc
EOF
Include the settings generated in the current bash session
[sbox-ARM: ~] > source .~/bashrc
Make sure Debian devkit is enabled in scratchbox
[sbox-ARM: ~ ] > sbox-config -sd debian
Check for updates to the rootstrap packages
[sbox-ARM: ] > apt-get update
[sbox-ARM: ] > fakeroot apt-get upgrade
Your Scratchbox is now be set up for GUI application cross-development for the ARM target platform. Test your installation by building the Hello World application from GTK+ 2.0 Tutorial:
gcc -Wall -g helloworld.c -o helloworld `pkg-config --cflags --libs gtk+-2.0`
Copy the "helloworld" binary executable over to the target device, ensure that you have a windowing system, gtk libraries, and all dependencies installed, and run the program. It should produce a simple window with a single button on the target device screen.
NOTE It is very important that build environment libraries and includes match those on the target device. Any discrepancies can lead to errors that are very hard to track down.
Rootstrap is meant for development purposes only.
PERL5LIB
environment variable needs to be explicitely set to make debhelper scripts work.
export PERL5LIB=$PERL5LIB:/scratchbox/tools/lib/perl5/site_perl/5.8.3/Debian/Debhelper
Similar approach may alleviate many other perl problems.
SBOX_REDIRECT_BINARIES
environment variable allows redirecting the execution of binaries to elsewhere.
The format is a comma separated list of pairs:
/usr/bin/make:/scratchbox/tools/bin/make,/usr/bin/perl:/scratchbox/tools/bin/perl
Don't hesitate to ask about these things on the scratchbox-users mailing list. This is still very much under construction.