lesslinux.org Development Blog

Just another WordPress weblog

Building LessLinux – stage01

Many changes were added since my first description of how to build LessLinux. There are two major changes that are worth noting most:

  • We switched from MySQL to SQLite3 as database during build

  • LessLinux is self containing now, this means you can use LessLinux to build LessLinux to build LessLinux…

The stage01 build of LessLinux very closely resembles the chapter Chapter 5 – Constructing a Temporary System from Linux from Scratch. You’ll even notice similar environment variables. There will always be slight differences in package versions – this is intended. So you might be able to build LessLinux on any machine equipped with the right programs to build Linux from Scratch. But in my opinion do one of the two following things:

  • Setup a clean Ubuntu 10.04 LTS and install all necessary packages by running
    apt-get install ` wget -O - http://download.lesslinux.org/builder/packagelists/20110202_ubuntu_1004_packages.txt `

  • Download the latest FULL ISO, a build of LessLinux containing compilers, headers and stuff. FULL ISO images are currently around 1.5GB and they allow you to build LessLinux without having to permanently setup a build environment. As of this post being written the current FULL ISO is lesslinux-search-and-rescue-uluru-20110202-155012-FULL-en.iso

I strongly recommend to take a dedicated build box – with the FULL ISO and an USB hard drive the conversion will be temporary. This can be some fairly recent PC (2GHz, 1GB RAM) and a USB hard drive (30GB upwards – a 32GB thumb drive might also do the job). In the mid term we will concentrate on the self containing builds, so it’s best to get used to building with FULL ISO. The FULL ISO might also be a good starting point for anyone diving into Linux from Scratch since the versions of GCC and Glibc are usually close to those in LFS.

Directories and users

You have great freedom on directory layout and the unprivileged user that is used for building some packages, but for start you should stick with the defaults in LessLinux.

  • I use /mnt/archiv/LessLinux as base for building. This path is used in the default config, so I suggest to keep it by mounting a dedicated build partition to /mnt/archiv/LessLinux:

    mkdir -p /mnt/archiv/LessLinux
    mkfs.ext3 /dev/sdx1
    mount /dev/sdx1 /mnt/archiv/LessLinux
    mkdir /mnt/archiv/LessLinux/llbuild
    mkdir /mnt/archiv/LessLinux/llbuilder
    mkdir /mnt/archiv/LessLinux/src

  • Add an unprivileged user for building. He must have /bin/bash as a shell, otherwise the build will fail. The default scripts use mattias as unprivileged user:

    adduser -s /bin/bash mattias

Downloading and Building

You’ll need some buildscripts from http://download.lesslinux.org/src/. Take either the most recent ones or some that match a certain version you want to build. As I write this, lesslinux-search-and-rescue-uluru-20110202-155012-buildscripts.tbz is recommended.

  • Go to the directory /mnt/archiv/LessLinux/llbuilder where you unpack the tarball:

    tar xvjf *-buildscripts.tbz

  • Edit the file lesslinux-builder/config/general.xml and change the node unpriv to contain the username of the unprivileged user created above

  • Change to the newly created directory lesslinux-builder, from there run:

    ruby -I. builder.rb -s 2,3 -n -u

This tells the builder to do an unstable (-u) build (glibc 2.12 and kernel 2.6.37 instead of glibc 2.11 and kernel 2.6.36). In a view days, I’ll move it to stable and take 2.6.38-rc and glibc 2.13 as unstable. The -n tells to omit tests. When making changes to stage01, you would probably omit this to run tests to discover problems. Finally -s makes the builder skipping stages 2 and 3.

Cleaning up

The build will now take somewhere between two and eight hours, strongly depending on how fast your machine is. After the build, the freshly created chroot environment and the database file containing will be backed up so that you can start any stage02 build without having to re-build stage01. Thus you should delete the build directory for stage01:

rm -rf /mnt/archiv/LessLinux/llbuild/stage01/build

And the next step…

Tomorrow I’ll describe how to build stage02 – which means building all packages in a chroot environment – and finally assembling an ISO image from it.

Comments are closed.