scratchbox Tips & Tricks
See alsoand the scratchbox section here
Running scratchbox builds from cron
crontab entry should be of the form:
<cron time settings> export USER= <user name to be used in scratchbox target> ; /scratchbox/login <build script location in scratchbox target>If USER is not set you will get errors of the form
"ERROR: Cannot determine user. $USER is NULL. Please check your environment" scratchbox login fails after host reboot
Try restarting scratchbox
/scratchbox/sbin/sbox_ctl restartIf it wasn't running you may need to add the startup & closedown script links
ln -s /etc/init.d/scratchbox-core in directories /etc/rc0.d to 6.d
0 & 1 should be named K20scratchbox-core to close down at exit, 3 to 6 S20scratchbox-core to start up at entry
Where /etc/init.d/scratchbox-core is
#!/bin/sh
SBCTL=/scratchbox/sbin/sbox_ctl
if [ -x $CTL ]; then
$CTL $@
fi
exit 0
Foreign toolchains: Helper scripts
Problems may occur if you get a new sb-toolchain-extras into an old scratchbox which does not provide the necessary support for new functionality.
sbrshd
- delete /etc/mtab before reboot to avoid remounting (possibly deleted) scratchbox directories
- sbrshd target must be rebooted if a scratchbox target is deleted & then remade
Inconsistency detected by ld.so: rtld.c: 1192: dl_main: Assertion '(void *) ph->p_vaddr == _rtld_local._dl_sysinfo_dso' failed!
Disable "vdso":
Outside scratchbox:
sudo -iecho 0 > /proc/sys/vm/vdso_enabledSee also the scratchbox section here
mmap: Permission denied
Outside scratchbox
sudo -iecho 4096 > /proc/sys/vm/mmap_min_addrCan be done in the boot script on most distributions...
See also the scratchbox section here
fakeroot hangs (probably not a scratchbox only problem)
fakeroot uses the loopback interface. If this is not running then fakeroot hangs and you see messages like
libfakeroot: connect: Connection timed outTry
ifconfig lo 127.0.0.1 up(outside scratchbox) to start the interface
ifconfig -a should show LOOPBACK RUNNING.
Ensure hosts are consistent
Example - toolchains built on a 64 bit host wont run on a 32 bit machine.
System Poisoning Warnings
Versions of the CodeSourcery toolchain from 2007Q1 onwards emit a warning under scratchbox regarding poisoning of the system directories & includes.
Some package configure scripts treat all warnings as a failure. Rather than switching this feature off and missing other warnings, stop this by supplying the flag -Wno-poison-system-directories
export SBOX_EXTRA_COMPILER_ARGS=-Wno-poison-system-directories
Foreign toolchains with multiple architectures
Some toolchains, e.g. CodeSourcery, include several versions of the system libraries
so that the same tools can be used to cross-compile several architectures e.g. armel, thumb, armv4t, marvell-f. This may confuse the scratchbox ~/sb-toolchain-extras/confhelper/create_toolchain_conf.py script
when it tries to configure the libraries to link with.
One solution is to remove the directories containing the extra libraries, once the (foreign) toolchain is installed on the host,
but before the scratchbox "foreign" toolchain installation is started e.g.
for d in thumb2, marvell-f, armv4t
do
find -name $d -exec rm -fr {} \;
done
CAUTION Some locale files are links to files in the lower architectures.
If this causes problems then
- Tar up the complete toolchain with -h
- Untar - the links are now converted to files
For thumb2, copy thumb2 libraries up over the arm ones, rather than deleting all thumb2 directories......
Another solution might be to hand edit the conf file
TODO Try the .conf edit
esp. ?? do the tools get built with the correct architecture ??
Foreign toolchains have different directory structures
To get the sb-toolchain-extras to build you may need this link in the top level include directory
ln -s /scratchbox/compilers//arm-none-linux-gnueabi/include/c++
Foreign toolchains - conf files
- COMPILER_PACKAGE value needs to be one debian word (lower case alphanum or '-+.') - it is used in the package name.
- Some toolchains rename items used by create_toochain_conf.py such that parsing doesn't work
- Code Sourcery
- ld version extended
Need to set different index to get the value for BINUTILS_FULLVER
- create_toochain_conf.py not updated to extract CRUNTIME_FILES
- Hand edit to give a space seperated list of files, links to copy to <target name>/lib
sb-menu
- CAUTION If you check both Install libc and Install c runtime you wont get the c libraries (unless you've added them into taret_setup.sh explicitly)
Using your own host binary
- Add the binary tag to the scratchbox define
- Ensure the to & from directories are in the scratchbox defines
export SBOX_REDIRECT_BINARIES="${SBOX_REDIRECT_BINARIES},/usr/invented/mytag:/home/my/binary"
export SBOX_REDIRECT_FROM_DIRS=${SBOX_REDIRECT_FROM_DIRS}:/usr/invented
export SBOX_REDIRECT_TO_DIRS=${SBOX_REDIRECT_FROM_DIRS}:/home/my
Note that the redirected binary and directory need not exist - the target binary
must.
Show the redirected binary isn't present in the scratchbox file system, whilst the target binary is .
[sbox] > /usr/invented/mytag
bash: /usr/invented/mytag: No such file or directory
[sbox] > ls /usr/invented
ls: /usr/invented: No such file or directory
[sbox] > ls /usr/invented/mytag
ls: /usr/invented/mytag: No such file or directory
[sbox] > ls /scratchbox/invented/binary
/scratchbox/invented/binary
[sbox] > /scratchbox/invented/binary
Hello from /scratchbox/invented/binary
Set up the redirection
[sbox] > export SBOX_REDIRECT_FROM_DIRS=${SBOX_REDIRECT_FROM_DIRS}:/usr/invented
[sbox] > export SBOX_REDIRECT_TO_DIRS=${SBOX_REDIRECT_TO_DIRS}:/scratchbox/invented
[sbox] > export SBOX_REDIRECT_BINARIES=${SBOX_REDIRECT_BINARIES},/usr/invented/mytag:/scratchbox/invented/binary
Show it works, although the redirected binary still isn't there
[sbox] > /usr/invented/mytag
Hello from /scratchbox/invented/binary
[sbox] > ls /usr/invented/mytag
ls: /usr/invented/mytag: No such file or directory
[sbox] > echo $SBOX_REDIRECT_FROM_DIRS
/bin:/usr/bin:/usr/local/bin:/usr/invented
[sbox] > echo $SBOX_REDIRECT_TO_DIRS
/scratchbox/devkits/debian-sarge/bin:/scratchbox/devkits/perl/bin:/scratchbox/devkits/cputransp/bin:/scratchbox/devkits/doctools/bin::/scratchbox/tools/bin:/targets/links/arch_tools/bin:
/scratchbox/compilers/bin:/scratchbox/invented
[sbox] > echo $SBOX_REDIRECT_BINARIES
,/scratchbox/devkits/doctools/bin/install-info:/scratchbox/devkits/debian-sarge/bin/install-info,/usr/lib/dpkg/enoent:/scratchbox/devkits/debian-sarge/lib/dpkg/enoent,/usr/invented/mytag:
/scratchbox/invented/binary
Exercises for the reader
- MUST the TO directory be under /scratchbox?
- MUST the target executable be a binary, or could it be a script and/or link
Avoiding building all those target packages that are only used for a build
scratchbox HowTo Bits I found unclear in the scratchbox instructions
Example is adding quilt
- Where's the sb-devkit-template go?
In scratchbox, host target , in ~. - How do we get the make to find the download site for the source.tgz? I couldn't see file_locations.mk being used so I included it in gar.conf.mk
I added QUILT_SITE=http://blah/ to it, trailing slash is required
and added $(QUILT_SITE) to the space seperated list MASTER_SITES in gar.conf.mk - Where do we make the tarball
Outside scratchbox in /scratchbox/users/<user name>/home/<user name>/sb-<devkit name>-devkit seemed to work
The tarball was in /scratchbox/users/<user name>/home/<user name> - Even after that you may have to fool dpkg-checkdeps by
- Fudging an entry in the scratchbox target /var/lib/dpkg/status file.
The easiest method (providing your host is a Debian distribution) is to copy the entry from the host /var/lib/dpkg/status
Check version - Fudging the /var/lib/dpkg/info/debhelper.list file
If you copy the host file check the contents against the scratchbox devkit....
- And the devkit wont be available for selection until you extract the tarball into / and restart scratchbox.
--
PeterPearse - 31 Aug 2007