4. The Build System

4.1. Directory structure

Table 3.1. Build system directory structure

Directory Description
build/ Main directory, you find the following files are located here: Makefile, .config and CHANGES.
build/config Holds the /etc directory, which is always included and acts as a common base.
build/scripts The acutal scripts which compile, install and create DL.
build/scripts/config Configuration files which are needed for build process. You find here for example the initial Kernel configuration file (config_kernel).
build/scripts/configuration Scripts which are used the generate the menu structure for the command: make menuconfig.
build/scripts/configuration/help Files which hold the help information for entries in make menuconfig.
build/scripts/lxdialog Sources of the lxdialog program, will be automatically compiled when you use make menuconfig
build/scripts/scripts Scripts which are needed for final DL. You find here for example several start/stop scripts for deamons which are optional.
build/dist The finished DL.
build/doc All included documentation.
build/src The source files.
build/tmp Working directory. Here you find the unpacked sources and all other temporary stuff. In this location are also.
build/tmp/ETC These are the contents of the later etc.tar.bz2
build/tmp/ISO/bootimagetree Contents of the bootimage.
build/tmp/ISO/cdtree Contents of the CD.
build/tmp/ISO/initrdtree Contents of the inital ramdisk.
build/tmp/ISO/ramdisktree Contents of the ramdisk.

4.2. The build process

By invoking the command make build, the Makefile will execute the script build/scripts/build.sh with the parameter build.

The script will now look in the folder build/scripts/.buildorder/rc1.d for the first build script to call, ,this will be S01prepare. Now the build/tmp directory is checked, if the script was already successfully executed. The flag-file is called in this case .done_build_001_prepare. When this file doesn't exist, the script build/scripts/prepare is called with the parameter build, otherwise the build script will continue with the next file. After a sub-script was successfully executed ( return code 0 ), the flag file is created and the build script starts at the beginning.

This description counts for the make commands build, install and iso, you just have to replace the "build" parts with e.g. "install".

[Tip] Tip

When you test your own scripts, you can easily force a recompilation by executing e.g. rm build/tmp/.done_build_123_foo

[Tip] Tip

While playing around with your own scripts, just place a exit 1 after the command your currently testing or at the end of the script (within the case statement). With that trick you can make sure, that no other scripts are executed and your scripts stops at the right place.

4.3. Adding Programs

Adding Programs to Devil-Linux is much easier then you would expect. The only thing which takes a long time, is to compile the system.

[Note] Note

In order to be able to add functionality to Devil-Linux, you need to know how to write Bash scripts and need to understand how to compile and install programs from their source code.

Here is a sample script:

# $Source: /cvsroot/devil-linux/build/docs/documentation/sample/ez-ipupdate,v $
# $Revision: 1.16 $
# $Date: 2004/04/15 23:58:35 $
# http://www.devil-linux.org

# you need the next line, otherwise script won't be executed !!!
# DL-build-system v3

# Provides:       ez-ipupdate
# Required-Start: $basebuildtools $libs
# Required-Stop:
# Default-Start:  1 2
# Default-Stop:
# Description:    description

# get the directoryname of the script

# source functions and config
source $MYDIR/settings


case $1 in
        build )
                if [ "$CONFIG_EZ_IPUPDATE" = "y" ]; then
                        ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc/ez-ipupdate || exit 1
                        make $PMAKE all || exit 1

        install )
                if [ "$CONFIG_EZ_IPUPDATE" = "y" ]; then
                        rm -rf $WORKDIR/tmp || exit 1
                        mkdir -p $WORKDIR/tmp/usr/bin || exit 1
                        make install DESTDIR=$WORKDIR/tmp || exit 1

                        copy_files $WORKDIR/tmp/usr $CDDIR/ || exit 1
                        mkdir -p $ETCDIR/etc/ez-ipupdate || exit 1
                        cp -dpR example*.conf $ETCDIR/etc/ez-ipupdate || exit 1
                        chmod 600 $ETCDIR/etc/ez-ipupdate/* || exit 1
                        rm -rf $WORKDIR/tmp || exit 1

                        cp $MYDIR/scripts/ez-ipupdate $ETCDIR/etc/init.d || exit 1

                        echo "# start the ez-ipupdate?" >> $CONFIGFILE
                        echo "START_$MYNAME=no" >> $CONFIGFILE
                        echo >> $CONFIGFILE
                        echo "HELP_$MYNAME=\"$MYNAME is a client for DDNS services.\"" >> $SOFTWAREHELP

        * )
                echo "ERROR ($0)"
                echo "please add parameter so I know what to do"
                exit 1

Now you have to activate that script by running make prepare again.

[Note] Note

Don't forgett to execute make menuconfig and enable the program you just added.

4.4. Adding Libraries

Libraries are the same as any other script, except that you usually don't have the "install)" part. Libraries must be installed within the "build)", otherwise they're not available for the other scripts.

4.5. Runlevel configuration

FIXME -> man insserv

4.6. Variables

The following variables are defined within the build environment.

This list is probably outdated, take a look at the file build/scripts/settings to get a closer look what's defined.

Table 3.2. Variables in build environment

variable description example
SCRIPTDIR location of the build scripts /data/build/scripts
DL_VERSION version number of Devil-Linux 0.6
WORKDIR location of temporary files and the unpacked sources /data/build/tmp
SRCDIR location of the packed sources /data/build/src
ISODIR location of the directories for the ISO creation /data/build/tmp/ISO
INITRD location of the Initial Ramdisk /data/build/tmp/ISO/initrdtree
RAMDISKDIR location of the ramdisk (main Devil-Linux system without packages) /data/build/tmp/ISO/ramdisktree
CDDIR location of the root CD folder, everything here you will find later on the CD /data/build/tmp/ISO/cdtree
ETCDIR directory which will be later the etc.tar.bz2 /data/build/tmp/ETC
CONFIGFILE general configuration file (for final system) /data/build/tmp/ETC/etc/sysconfig/config
DL_DIR root of the build system /data/build

4.7. Functions