The Coreutils package contains utilities for showing and setting the basic system characteristics.
A known issue with the uname program from this package is that the -p switch always returns unknown. The following patch fixes this behavior for i386 architectures:
patch -Np1 -i ../coreutils-6.7-uname_PIC-1.patch
Now prepare Coreutils for compilation:
./configure --prefix=/usr
Compile the package:
make
First, run the tests that are meant to be run as user root:
make NON_ROOT_USERNAME=nobody check-root
The “append-only” test uses the chattr program and only works on ext2 and ext3 filesystems. If your HLFS partition is formated with another filesystem, such as reiserfs, then this test will fail.
Then run the remainder of the tests as the nobody user:
src/su nobody -s /bin/sh -c "make RUN_EXPENSIVE_TESTS=yes check"
This package installs some programs we may not want, and programs we do want in the wrong places. Install Coreutils to a temporary directory so the files can be manipulated before they are installed:
make DESTDIR=$(pwd)/DESTDIR install
If you choose to install the Coreutils versions of uptime, su, or kill, you will have opportunities later to not install conflicting versions from other packages.
The uptime program provided by the Section 6.52, “Procps-3.2.7” package has about 10 times less code than the uptime program provided Coreutils, according to the size utility, and they both provide identical functionality. Most users and distributions favor the least bloated version of programs which have identical features. Remove this uptime with the following commands:
rm -v DESTDIR/usr/bin/uptime \
DESTDIR/usr/share/man/man1/uptime.1
The su program provided by the Section 6.54, “Shadow-4.0.18.1” package has more features than the version provided by Coreutils, such as Linux-PAM support. Most users and distributions favor the su program from the Section 6.54, “Shadow-4.0.18.1” package because of the added features, and it is more widely used. There is a discussion of the differences between the two versions here: http://www.diy-linux.org/pipermail/diy-linux-dev/2005-August/000610.html. Remove this su with the following commands:
rm -v DESTDIR/usr/bin/su \
DESTDIR/usr/share/man/man1/su.1
The kill program provided by the Section 6.52, “Procps-3.2.7” package has more options than the one provided by Coreutils, and is favored by many users and distributions. However, some other distributions believe this Coreutils version of kill is written more cleanly. Whether you use it or not is up to you. FIXME: -insert differences of the two versions here-. Remove it with the following commands:
rm -v DESTDIR/usr/bin/kill \
DESTDIR/usr/share/man/man1/kill.1
The true program provided by Coreutils provides --help and --version options, and has the overhead of the C library. The true program's sole purpose is to return 0, and nothing else. Because this program is often used for authentication and security sensitive tasks it is more secure to use a version written in assembly language. A true program written in assembly language will not only be smaller, but will use far fewer syscalls than a C language version. The following program is written in i386 assembly, and will only work on i386 (386, 486, and Pentium) hardware. Replace the Coreutils true with an assembly version with the following commands (we can keep the manual page):
cat > src/true.S << "EOF" /* Public Domain - i386 true.S */ .global _start _start: movl $0,%ebx movl $1,%eax int $0x80 EOF rm -v DESTDIR/usr/bin/true gcc -nostdlib src/true.S -o DESTDIR/usr/bin/true
The false program provided by Coreutils has the same issues as the true program, but is moreso depended on for authentication and security tasks. Replace the Coreutils false program with an i386 assembly language version with the following commands:
cat > src/false.S << "EOF" /* Public Domain - i386 false.S */ .global _start _start: movl $1,%ebx movl $1,%eax int $0x80 EOF rm -v DESTDIR/usr/bin/false gcc -nostdlib src/false.S -o DESTDIR/usr/bin/false
Move programs to the locations specified by the FHS:
install -vd DESTDIR/bin
mv -v DESTDIR/usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} DESTDIR/bin
mv -v DESTDIR/usr/bin/{false,hostname,ln,ls,mkdir,mknod,mv,pwd,rm} DESTDIR/bin
mv -v DESTDIR/usr/bin/{rmdir,stty,sync,true,uname} DESTDIR/bin
install -vd DESTDIR/usr/sbin
mv -v DESTDIR/usr/bin/chroot DESTDIR/usr/sbin
Some of the scripts in the LFS-Bootscripts package depend on head, sleep, and nice. As /usr may not be available during the early stages of booting, those binaries need to be on the root partition:
mv -v DESTDIR/usr/bin/{head,sleep,nice} DESTDIR/bin
Note that the Coreutils info page has not been edited to respect any of the programs you may have removed or replaced. You may want to modify it yourself.
Now copy the files to the system:
cp -va DESTDIR/* /
kill, true, false, and many others, are bash shell builtins. To use the ones we just installed the full path must be given.