Buildtool

From Bubble

Contents

Introduction

The Buildtool is the Bering-uClibc development environment.

The steps to get everything up and running are described in the Bering uClibc Developers Guide.

This article summarize the issues I had when building the environment.

All this is based on Bering-uClibc 2.3 rc1

Fetching the sources

./buildtool.pl source

No particular problem here... As usual some sources did not download at first try, but eventually all went trough.

Note that wget leaves an empty file when the download fails, and that the Buildtool thinks it is already downloaded. So when it fails, the package source needs to be cleaned up.

Compiling the sources

./buildtool.pl build

All the packages but 3 are compiling...

LrpStat

To be able to build this package, we need to have:

  • A recent Java SDK (1.4) -- I have used the J2SE from Sun
  • The classes.zip from a 1.1 SDK -- After some investigations, I found one at Blackdown (jdk118_v3)

The detection mechanism of the setup script is not bullet proof, but the following incantation will work:

 JAVA_HOME=/usr/local/j2sdk1.4.2_09 CLASSES=/usr/local/jdk118_v3/lib/classes.zip ./buildtool.pl build lrpstat

MadWifi

After install, the makefile runs a depmod that returns a non-zero return code and the make fails.

In source/madwifi/madwifi/Makefile, just make the following changes:

   @if [ -z $(DESTDIR) ]; then \
       /sbin/depmod -ae ; \
   elif [ -f $(SYSTEMMAP) ]; then \
       /sbin/depmod -ae -b $(DESTDIR) -F $(SYSTEMMAP) $(KERNELRELEASE) ; \
   else \
       echo "Don't forget to run \"depmod -ae\" on the target system."; \
   fi

into

   -if [ -z $(DESTDIR) ]; then \
       /sbin/depmod -ae ; \
   elif [ -f $(SYSTEMMAP) ]; then \
       /sbin/depmod -ae -b $(DESTDIR) -F $(SYSTEMMAP) $(KERNELRELEASE) ; \
   else \
       echo "Don't forget to run \"depmod -ae\" on the target system."; \
   fi

(We just change the @ in -)

Pptpd

For whatever reason the source/pptpd/pptpd-1.2.3/Makefile contains references to aclocal-1.9 and automake-1.9 while we have 1.8 installed in the Buildtool stage...

I have changed the version in the Makefile and now it compiles!

Packages

The buidpacket.pl is used to generate .lrp from the builds.

buildall.sh script

Unfortunately, you cannot generate all the packages at once... This is when I discovered the tools/buildall.sh script!
This little shell script can actually setup the whole environment:

  • Fetch the sources
  • Run the build
  • Generate all the packages

It produce a neat HTML report, with a link to the log files, one log file per source.

Unfortunately, the script overwrites the buidpacket.pl log files, so you cannot what is going wrong at that stage.

This little fix will help in tracing the issues

diff -u -r1.6 buildall.sh
--- buildall.sh    21 Mar 2005 00:56:02 -0000  1.6
+++ buildall.sh    3 Oct 2005 20:59:13 -0000
@@ -51,13 +51,13 @@
 }

 call_buildpacket() {
-  echo "-------------------------" >> $MYDIR/$name.build.txt 2>&1
+  echo "-------------------------" >> $BTLOGFILE 2>&1
   # check if it has a package definition in it:
   grep -q '<Package>' $BTSOURCEDIR/$1/buildtool.cfg 2>/dev/null
   if [ $? -eq 0 ] ; then
-      echo "calling buildpacket for $1 " >> $MYDIR/$name.build.txt 2>&1
+      echo "calling buildpacket for $1 " >> $BTLOGFILE 2>&1

-      fakeroot $BPBIN --package=$1 --all >> $MYDIR/$name.build.txt 2>&1
+      fakeroot $BPBIN --package=$1 --all >> $BTLOGFILE 2>&1
       ret=$?
       if [ $ret -eq 0 ] ; then
           echo -n "OK"

Gpio

The source/gpio/buildtool.cfg is not taking the driver from the right location.
The correct entry should be

               <File>
                   Filename    = lib/modules/gpio.o
                   Source      = lib/modules/2.4.31/gpio/gpio.o
                   Type        = binary
                   Permissions = 644
               </File>

Initrd

Doesn't build with fakeroot, we really have to sudo to package this one...

sudo ./buildpacket.pl --package=initrd --all

Another issue is that the initrd buildroot.cfg includes common.cfg multiple times. This does not work! The perl package Config::General will not read (and include) the same file twice:

   350     if (exists $this->{files}->{$configfile} ) {
   351       # do not read the same file twice, just return
   352       # FIXME: should we croak here, when some "debugging" is enabled?
   353       return;
   354     }

I have used a dirty workaround: create some symbolic links for common.cfg and use the different names in the initrd buildroot.cfg.

Shorewall

buildpacket.pl fails because the cp command returns a non-zero status code on /etc/shorewall/*.

The problem is that the weblet package creates directories in /etc/shorewall/, which makes that cp issues warnings.

Workaround is to build weblet after shorewall is packaged, but this is a bit annoying: it just works the first time, after that you have to buildclean both packages.

I prefer to tweak the pattern matching in source/shorewall/buildtool.cfg -- this is not bullet proof, but good enough

           <File>
               Filename    = etc/shorewall/
               Source      = etc/shorewall/*[^.]?
               Permissions = 600
               Type        = binary
           </File>

What else do we need?

We have now all the packages in the package directory, but we need a couple of other things to build an image...
The tools directory has a couple of scripts to build images, but they fetch binaries from the Internet, which is obviously not what I wanted to do...

So what else do we need?

Linux kernel

The kernel is available as build/kernel/bzimage-2.4.31-upx and just need to be renamed in linux

SysLinux and Leaf config files

Templates for syslinux.cfg and leaf.cfg are available in tools/image/fd and tools/image/iso diectories

Readme and banner

The readme file and the syslinux.dpy banner templates are available in the tools/image directory.

Build date and version need to be substituted.

Note that the banner does not look too good on an old VT200 screen, and should be cleaned up if your console is on the serial port!

WebConf plugins

The webconf plugins (.lwp files) are not part of the buildroot and need to be fetched from http://cvs.sourceforge.net/viewcvs.py/leaf/devel/nangel/webconf/lrp/ .

Linux kernel modules

The Linux kernel modules are available in build/kernel/lib/modules.

Summary

In order to build the whole environment:

  1. Get all the sources
  2. Apply the couple of fixes described above
  3. Build the whole stuff with:
    JAVA_HOME=/usr/local/j2sdk1.4.2_09 CLASSES=/usr/local/jdk118_v3/lib/classes.zip ./tools/buildall.sh
  4. Package the initrd manually:
    sudo ./buildpacket.pl --package=initrd --all
  5. To make your own images, grab your selection of packages and the required additional files!