1 TITLE: LFS 4.1 using static-pwd hack
3 AUTHOR: Ronald Hummelink <ronald AT hummelink DOT xs4all DOT nl>
6 How to install Linux From Scratch 4.1 from a pre glibc-2.3.x system
7 using the static password lib hack
10 Grant Leslie for inventing the hack.
13 1.2 07-03-2002 Mention the glibc-2.3.1-libnss patch is not needed
14 1.1 05-03-2002 Initial release
18 Use the hint at your own risk. Neither the author, nor the Linux From Scratch
19 project accepts any reponsibility for anything that happens when using these
20 documents or associated files.
22 You may freely copy this document or create derivate works or distribute the
23 document in any format. At your discretion, you may give credit to the original
26 Comments and improvements are welcome at the email address mentioned above in
29 When installing Linux From Scratch with glibc 2.3.1 from a system with an
30 older glibc version installed several binaries will crash with a segmentation
31 fault when attempting to access the libnss libraries. This is due to an
32 incompatibility between the static binaries (linked with old glibc) and the
35 This hint describes how to work around this problem by compiling a small
36 library that will replace the passwd and group resolving functions avoiding
37 the binaries to crash.
40 The work-around only involves a number of changes to chapter 5 of the LFS book.
41 The hint will only list instructions for the packages that have changed
44 Before building bash you need to compile the static-pwd libary
46 Download the static-pwd package from:
47 http://www.linuxfromscratch.org/~scot/static-pwd.tar.bz2
48 Extract the tarball normally and cd into the created directory
53 export LFS_LIBS=$(pwd)
55 export LFS_LIBS=$(pwd): This command sets an environment variable to aid in
56 linking this library with some of the later installed programs.
61 Install Bash by running the following commands:
63 CFLAGS="-I$LFS_LIBS" ./configure --enable-static-link \
64 --prefix=$LFS/static --with-curses &&
65 make LOCAL_LIBS="$LFS_LIBS/libpwd.a" &&
68 CFLAGS="-I$LFS_LIBS": This adds the static-pwd directory to the library search
70 LOCAL_LIBS="$LFS_LIBS/libpwd.a": This adds the static-pwd stub library to the
76 If you need the fileutils patch, apply it:
78 patch -Np1 -i ../fileutils-4.1.patch
80 Install Fileutils by running the following commands:
82 LDFLAGS=-static CFLAGS="-I$LFS_LIBS" \
83 ./configure --disable-nls --prefix=$LFS/static &&
84 make LIBS="$LFS_LIBS/libpwd.a" &&
87 LIBS="$LFS_LIBS/libpwd.a": This adds the static_pwd stub library to the
93 Install Findutils by running the following commands:
95 patch -Np1 -i ../findutils-4.1.patch &&
96 CPPFLAGS=-Dre_max_failures=re_max_failures2 \
97 CFLAGS="-I$LFS_LIBS" ./configure --prefix=$LFS/static &&
98 make LDFLAGS=-static LIBS="$LFS_LIBS/libpwd.a" &&
104 Install Make by running the following commands:
106 CFLAGS="-I$LFS_LIBS" ./configure \
107 --prefix=$LFS/static --disable-nls &&
108 make LDFLAGS=-static LIBS="$LFS_LIBS/libpwd.a" &&
114 If you need the sh-utils patch, apply it:
116 patch -Np1 -i ../sh-utils-2.0.patch
118 Install Sh-utils by running the following commands:
120 CFLAGS="-I$LFS_LIBS" ./configure --prefix=$LFS/static \
122 make LDFLAGS=-static LIBS="$LFS_LIBS/libpwd.a" &&
128 If you want the tar patch, apply it:
130 patch -Np1 -i ../tar-1.13.patch
132 Install Tar by running the following commands:
134 CFLAGS="-I$LFS_LIBS" ./configure \
135 --prefix=$LFS/static --disable-nls &&
136 make LDFLAGS=-static LIBS="$LFS_LIBS/libpwd.a" &&
140 All the other packages build in chapter 5 are build with the normal
141 instructions as given in the book.
143 Optionally you can create the passwd and group files before chrooting into the
144 chapter 5 system. This is purely cosmetic however, you won't get the
145 "I have no name" prompt from bash.
148 echo "root:x:0:0:root:/root:/bin/bash" > $LFS/etc/passwd
150 cat > $LFS/etc/group << "EOF"
165 If you do this you can also change the command to change the ownership from
168 chown -R root:root /static /etc/passwd /etc/group
170 You should from now on be able to complete chapter 6 without encountering
171 segmentation faults. When installing glibc, the glibc-2.3.1-libnss patch
172 is not needed anymore. It is cleaner to omit the patch but it won't hurt
173 to apply it if you do decide to rebuild glibc at the end of chapter 6.