Chapter 1. Development

Table of Contents

Recommended Reading
Building the kernel
Building uClibc
Building busybox
Building sources and libraries against uClibc
Building a LEAF package from the compiled sources

Recommended Reading

LEAF FAQ's - especially the sections "08. Package Questions Answered" and "13. Developer Questions Answered"

Oxygen Developer's Guide written by David Douthitt

Guide to compile a LEAF kernel written by Jacques Nilo

Building the kernel

The LEAF Bering-uClibc is build from a patched kernel source and compressed afterwards to reduce space.

The list of patches and the order in which you should apply them are described in kernel.txt. This file is provided as well as the kernel .config here. The needed patches can be found in the patches cvs repository .

Now it's time to download a clean 2.4.24 kernel source from ftp://ftp.kernel.org/pub/linux/kernel/v2.4/.

Add the kernel .config downloaded above, apply the patches as described in kernel.txt and follow the process explained there.

Build the kernel as usual:

make oldconfig; make dep; make bzImage; make modules

Finally, download upx-1.90 from: http://upx.sourceforge.net/#unstable and compress the kernel:

upx --best -f -o linux.upx arch/i386/boot/bzImage

Building uClibc

Download uClibc 0.9.20.

Download the uClibc .config, uClibc.txt and needed patches from: http://leaf.cvs.sourceforge.net/leaf/src/bering-uclibc/configs/uclibc/0.9.20/

Please read uClibc.txt for special notes.

Extract the uClibc source and copy the .config file to the source directory

Apply the patches (if any) by doing:

gunzip patchname.gz -c | patch -p1

Build uClibc with:

make

Install the development environment (as root):

make install

This will install the header files, libraries, and the gcc wrapper into the directories defined in the config.

Building busybox

Download the busybox source from: http://leaf.cvs.sourceforge.net/leaf/src/bering-uclibc/apps/busybox/

copy the .config file from http://leaf.cvs.sourceforge.net/leaf/src/bering-uclibc/configs/busybox/1.00/ to the busybox source directory

Build busybox by doing:

make

After compiling change the permission of the busybox binary with:

chmod 4755 busybox

copy busybox.list from the source directory to root.bb.links

Building sources and libraries against uClibc

Set the uClibc path:

export PATH=/usr/i386-linux-uclibc/usr/bin:$PATH

Download the Bering_uClibc sourcecode, patches, txt and mk files from http://leaf.cvs.sourceforge.net/leaf/src/bering-uclibc/apps/, unpack the sourcecode and copy the patch and mk files to the source directory. Apply the patches by doing (in the source directory):

gunzip source-1.2-3.patch.gz -c | patch -p1 (where source-1.2-3 is the actual name)

Read the comments in the source-name.txt file, most sources will compile out of the box, some need a little tweaking. After applying the necessary tweaks, make the "source-name.mk" file executable:

chmod 755 source-name.mk

And run:

./source-name.mk

After compilation the binaries must be stripped with:

strip -s --remove-section=.note --remove-section=.comment "binary-name"

Don't strip libraries unless explicitly noted.

For sources which need to be linked against libraries compiled against uClibc: first compile the libraries and copy the header files to the uClibc include directory and copy the libraries to the uClibc lib directory.

Building a LEAF package from the compiled sources

With the exception of initrd.lrp LEAF packages are tarballs compressed with gzip. The filename suffix must be "lrp" and the length is limited by the 8.3 convention.

Before creating a package make shure that file and owner permissions are set correctly.

LEAF packages

Create a directory tree and build a package by doing:

tar -c * | gzip -9 > package.lrp

initrd.lrp

initrd.lrp is a different package - it's a compressed, minix formatted filesystem. To add or change it's content you have to uncompress it and mount it on a minix formatted mount point:

dd if=/dev/zero of=initrd bs=1k count=1500
mkfs.minix initrd 4096
mount -t minix initrd /mnt -o loop

Copy the contents for the initrd package to the /mnt directory:

sync
umount /mnt
gzip -9 initrd
mv initrd.gz initrd.lrp