Tuesday 20 July 2010

LAP - Actual Build - Part 2, Headers, Manuals and Glibc for real

The first set of software to install is the Linux Headers again. Still no idea what these actually are, but they are still in the main Kernel /sources:

cd /tmp
tar -xjvf /sources/linux-2.6.32.8.tar.bz2
cd linux-2.6.32.8
make mrproper
make headers_check
make INSTALL_HDR_PATH=dest headers_install

So far, so toolchain.

find dest/include \( -name .install -o -name ..install.cmd \) -delete

That's different. This command, according to the book, is to delete some non-essential hidden files in the ./dest/include directory. You can see the [.install] and [..install.cmd] files which would be treated as hidden because they start with a [.]. The option at the end of the line [-delete] tells the whole thing what to do with the files found by the command.

cp -rv dest/include/* /usr/include
cd ..
rm -rvf linux-2.6.32.8

All the rest is the same, other than the final destination that we copy the files to - this time it is /usr/include and not the /tools directory. The next package is, I think it may be safe to say, the easiest one we have dealt with, and most probably will deal with. It is a collection of manual pages. These are the pages that are brought up with the [man] command.

tar -xjvf /sources/man-pages-3.23.tar.bz2
cd man-pages-3.23
make install
cd ..
rm -rvf man-pages-3.23

Well, things are going well aren't they? Let's move on to another simple … oh shit, it's Glibc again.

tar -xjvf /sources/glibc-2.11.1.tar.bz2
cd glibc-2.11.1
DL=$(readelf -l /bin/sh | sed -n 's@.*interpret.*/tools\(.*\)]$@\1@p')

Ok, first of all I refuse to take a command seriously if it starts going on about elves. Secondly SHIT it's SED! The bastard was sneakily hiding halfway through that command! Careful now - he just seems to be setting a variable [DL]. Lets see what that is going to be used for.

sed -i "s|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=$DL -o|" scripts/test-installation.pl

Aaaargh! More sed in-fucking-sanity.

unset DL

At last, something clear. Apparently the point of all this is to change a script that runs in the test suite for Glibc to make sure it doesn't try to test the /tools version of Glibc by accident. Right, next.

sed -i 's|@BASH@|/bin/bash|' elf/ldd.bash.in

Bugger. We have elf and sed again. Lets try to not get over excited. Apparently, this forces the 'ldd shell script' (whatever that is) to use the /bin/bash program.

mkdir -v ../glibc-build
cd ../glibc-build
case `uname -m` in
  i?86) echo "CFLAGS += -march=i486 -mtune=native -O3 -pipe" > configparms ;;
esac

That is mostly the same as we saw before, but there is a tweak with the [-O3] and [-pipe] options. The first sets the optimisation level for the compiler. It is safe to think of this as the compression level of a file compressor. More optimisation will take longer to compile, but should result in a smaller final program file, that also runs faster. The second just tells the compiler it can pipe [|] information from one command to another during the compilation instead of using temporary files. As you might imagine, this is considerably quicker, and does not actually affect the end result.

../glibc-2.11.1/configure --prefix=/usr --disable-profile --enable-add-ons --enable-kernel=2.6.18 --libexecdir=/usr/lib/glibc

This time we are installing to [/usr] so the prefix has changed. Expect to see this in virtually every package. The other change is the [libexecdir=/usr/lib/glibc]. According to the book, this changes the location for one program file that is installed. Does not seem to be earth shattering.

make $CORES_TO_USE
cp -v ../glibc-2.11.1/iconvdata/gconv-modules iconvdata

We are now going to check the compiled files, and this command copies across a file from the unpacked source code folder to the build folder for testing purposes.

make $CORES_TO_USE -k check 2>&1 | tee glibc-check-log

This command actually runs the tests and sends the output to a file.

grep Error glibc-check-log

This command searches the log file from the last command for any lines with the word Error in them and prints them out. When I ran this, the output looked like this:

make[2]: [/sources/glibc-build/posix/annexc.out] Error 1 (ignored) 
make[2]: *** [/sources/glibc-build/rt/tst-cpuclock2.out] Error 1 
make[1]: *** [rt/tests] Error 2 
make: *** [check] Error 2

All of these errors are referred to in the book and anticipated. It is safe to proceed with these. During another build I got these errors instead:

make[2]: [/tmp/glibc-build/posix/annexc.out] Error 1 (ignored)
make[2]: *** [/tmp/glibc-build/posix/tst-waitid.out] Error 1
make[1]: *** [posix/tests] Error 2
make[2]: *** [/tmp/glibc-build/rt/tst-mqueue5.out] Error 1
make[2]: *** [/tmp/glibc-build/rt/tst-cpuclock2.out] Error 1
make[1]: *** [rt/tests] Error 2
make: *** [check] Error 2

At this point we should create another empty file, by touching it. Incidentally is it just me or is there something vaguely unsettling about the command 'touch'?

touch /etc/ld.so.conf

As it sounds, this is a config file and we will fill it up shortly.

make install

This next section creates a number of locale files. These are language specific translation files, and we have alluded to them before. The book recommends the following locales be installed in order to be sure of passing the tests in other software we are going to install. To these I have added the en_GB versions. How you get your own country codes if they are not listed is an adventure for you and google to embark on together.

mkdir -pv /usr/lib/locale
localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8
localedef -i de_DE -f ISO-8859-1 de_DE
localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
localedef -i de_DE -f UTF-8 de_DE.UTF-8
localedef -i en_HK -f ISO-8859-1 en_HK
localedef -i en_PH -f ISO-8859-1 en_PH
localedef -i en_US -f ISO-8859-1 en_US
localedef -i en_US -f UTF-8 en_US.UTF-8
localedef -i es_MX -f ISO-8859-1 es_MX
localedef -i fa_IR -f UTF-8 fa_IR
localedef -i fr_FR -f ISO-8859-1 fr_FR
localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro
localedef -i fr_FR -f UTF-8 fr_FR.UTF-8
localedef -i it_IT -f ISO-8859-1 it_IT
localedef -i ja_JP -f EUC-JP ja_JP
localedef -i tr_TR -f UTF-8 tr_TR.UTF-8
localedef -i zh_CN -f GB18030 zh_CN.GB18030
localedef -i en_GB -f UTF-8 en_GB.utf8
localedef -i en_GB -f ISO-8859-1 en_GB

The next file to be created is effectively a list of types of information and where to find them. Essentially it seems designed to tell the system whether to look locally for a user list, for instance, or whether to look to a domain server. I think.

cat > /etc/nsswitch.conf << "EOF"
# Begin /etc/nsswitch.conf

passwd: files
group: files
shadow: files

hosts: files dns
networks: files

protocols: files
services: files
ethers: files
rpc: files

# End /etc/nsswitch.conf
EOF

The following command tells the system that we are on London Time. If you are not on London time you can find out what time zone code you need instead by running the program [tzselect].

cp -v --remove-destination /usr/share/zoneinfo/Europe/London /etc/localtime

Lastly, we are back to this config file. This is a list of alternative locations that the system can look to find shared libraries. Or in other words, parts of programs that other programs might want to use. You will find, if you dip your toes into a lot of the BLFS packages, that this list becomes quite lengthy.

cat > /etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf

/usr/local/lib
/opt/lib

# End /etc/ld.so.conf
EOF

cd ..
rm -rvf glibc-2.11.1  glibc-build

And thus endeth the lesson on how to properly install the full C library Glibc.

No comments:

Post a Comment