BTux hacking

BTux is a GNU/Linux distribution, and needs some effort to bootstrap its building and maintenance environment. Although BTux is a light weight one, you will still need to consider long initial build times (1 hour is common). Building the development environment is is explained in parts 1 to 3.

Then, compiling and updating individual packages is a more easy process. You will still have to consider a long initial build, but regular maintenance will be reduced to minimal efforts and re-compilations. Building packages and maintaining them is covered in parts 4 to FIXME.

Requirements

  • A working and installed GNU/Linux distribution (Debian recommended)
  • A basic development toolchain to start with (GCC/G++ compiler and linker, glibc headers)
  • A subversion client
  • A CF card reader to host your build image
  • Some disk space, at least FIXME MB

BTux currently requires the GCC 3.4 branch. GCC 4 is known to fail, and other versions are not supported.

If you run Debian Etch, you would simply execute (as root):

# apt-get install subversion gcc-3.4

1. Fetching BTux scripts

Retrieve a working copy of BTux subversion repository with:

$ svn checkout svn://btux.org/btux

You end up with a btux folder (weighting about 5 MB). Later on, you will be able to update your working copy easily (note that it won't overwrite your local modifications if you have any):

$ cd btux
$ svn up

2. Fetching tools sources

You need to download all tools sources and patches at once. A script will automatically fetch them for you. Conveniently, it will first try a package native location, and fallback on a backup mirror if not found here.

$ cd btux/scripts
$ ./download-tools

This operation might take a long time depending on your location and available bandwidth. You should end up with about 160 MB of files (they are stored in btux/packages and btux/patches).

3. Building tools

Using your host system toolchain, you will now build the target system toolchain. In other words, you are about to build GCC and friends, targeted for a BTux system.

You need to create a file called btux/build/params reading like this (see params.sample):

#!/bin/sh

LFS=/path/to/btux
LFSCC=gcc-3.4
CHOST="i686-pc-linux-gnu"
KERNEL_VER=2.6.14.4
TZ="Europe/Paris"
KBD=i386/azerty/fr-latin1.map.gz
TERM=xterm

export LFS LFSCC CHOST KERNEL_VER TZ KBD TERM 

You might need to adjust those variables :

LFSabsolute path to your BTux working copy
LFSCCname of the host GCC 3.4 binary (gcc-3.4 in Debian Etch)
CHOSTtarget system description. Don't change unless you understand autoconf and cross-compilation.
KERNEL_VERtarget Linux kernel version
TZtarget system timezone (formated as Continent/City)
KBDtarget system default keyboard map
TERMyour default terminal type, some interactive console-based will complain otherwise

To ensure that you will not kill your host system (erasing system files) :

  • you need to create a lfs user on your system with custom .bashrc/.bash_profile files.
  • a /tools directory at the root of your system will be create as a link to $LFS/tools.

A script will do that for you, it must be run as root :

cd ../build
./first

Warning : if there is an existing /tools directory on your system, it will be deleted '''

Now change user from root to lfs : su - lfs

Launch tools compilation :

cd $LFS/build
./tools

./tools script will call scripts t01binutils, t02.., through t31tools-tarball senquentially.

It will produce a log in $LFS/build/tools.log

You can use to see tools being builded. Just open another shell, and use :

tail -f your_path/butx/build/tools.log

At the end, examine it to see if something got wrong.

A tarball of /tools has also been generated, tools-jjmmaa-hh.tar.bz2

It will be used as a restart point in case something fail at the next step.

4. Building BTux

Now we've builded our tools, we can start building the target system.

lfs user is now useless, so exit from it. Now all operations will be done in a chrooted environnement.

Go into your btux/build directory as root user, then run ./chroot (Note: dont forget the ./ as chroot is there a script).

The first time you launch it, it will create target system directories and devices nodes. System will show

###### create dir'n'devs after STEP 1
Creating dirs'n'devs...
...Done
##### STEP 2 (build system)
[ch-root:/]$

If you exited and relaunched ./chroot system will show :

##### STEP 2 (build system)
[ch-root:/]$

To launch the target system building :

cd /build
./system

Tips

Here are some tips you can use. They are NOT mandatory.