======= LFS 기본 시스템 제작 ======
이전에 모든 파일의 소유권을 root로 넘겼으므로 여기서부터는 root가 명령을 수행해야 한다. 그런데 root은 $LFS 변수를 명시적으로 가지고 있지 않으므로, 작업 전에 반드시 선언해야 한다.
# export LFS=/mnt/lfs
===== 가상 커널 파일 시스템 =====
mkdir -v $LFS/{dev,proc,sys}
# console, null
#
mknod -m 600 $LFS/dev/console c 5 1
mknod -m 666 $LFS/dev/null c 1 3
# mounting dev
#
mount -v --bind /dev $LFS/dev
# virtual file systems
#
mount -vt devpts devpts $LFS/dev/pts
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
# /dev/shm
if [ -h $LFS/dev/shm ]; then
link=$(readlink $LFS/dev/shm)
mkdir -p $LFS/$link
mount -vt tmpfs shm $LFS/$link
unset link
else
mount -vt tmpfs shm $LFS/dev/shm
fi
mknod 상에 major number, minor number는 http://www.lanana.org/docs/device-list/devices-2.6+.txt 를 참고한다. 5 1은 /dev/console을 위한 번호이고, 1 3 또한 /dev/null을 위해 정해진 번호이다.
===== chrooting =====
chroot "$LFS" /tools/bin/env -i \
HOME=/root \
TERM="$TERM" \
PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
CFLAGS="-O2 -pipe -march=native -fomit-frame-pointer" \
CXXFLAGS="${CFLAGS}" \
MAKEOPTS="-j5" \
/tools/bin/bash --login +h
-i 옵션을 사용하면 환경 변수들이 모두 초기화된다. 그러므로 CFLAGS, CXXFLAGS가 있다면 여기에 넣어주면 된다.
/etc/passwd 파일이 없으므로 ''I have no name!''이란 문자열이 나온다. 이제 지금까지 만든 시스템으로 진입했다.
===== 디렉토리 생성 =====
호스트에서 생성한 파일을 제외하면 현재 시스템에는 기본적인 디렉토리 구성이 되어 있지 않으므로 표준에 맞도록 디렉토리를 만들어 준다.
mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib,mnt,opt,run}
mkdir -pv /{media/{floppy,cdrom},sbin,srv,var}
install -dv -m 0750 /root
install -dv -m 1777 /tmp /var/tmp
mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src}
mkdir -pv /usr/{,local/}share/{doc,info,locale,man}
mkdir -v /usr/{,local/}share/{misc,terminfo,zoneinfo}
mkdir -pv /usr/{,local/}share/man/man{1..8}
for dir in /usr /usr/local; do
ln -sv share/{man,doc,info} $dir
done
case $(uname -m) in
x86_64) ln -sv lib /lib64 && ln -sv lib /usr/lib64 ;;
esac
mkdir -v /var/{log,mail,spool}
ln -sv /run /var/run
ln -sv /run/lock /var/lock
mkdir -pv /var/{opt,cache,lib/{misc,locate},local}
모든 리눅스에서 거의 공통적으로 사용되는 표준 디렉토리 구성을 직접 만들어내는 것을 볼 수 있다. 이러한 파일 구성을 하도록 만든 표준이 있다. [[http://www.pathname.com/fhs/ |FHS (Filesystem Hierarchy Standard)]]라고 한다.
여기서 /tmp, /var/tmp, /root에 대해 특별한 처리를 해 주는 것에 주목하자. /tmp, /var/tmp에는 누구나 파일을 쓸 수 있지만, 디렉토리를 지울 수는 없고, /root 디렉토리에는 root만이 접근 가능하도록(root 그룹은 접근, 읽기만 가능) 만든다.
===== 필수적인 파일들 =====
몇몇 프로그램들은 아직 설치되지 않았지만 필수적으로 필요하다. 이런 것들은 미리 symlink를 걸어 둔다.
ln -sv /tools/bin/{bash,cat,echo,pwd,stty} /bin
ln -sv /tools/bin/perl /usr/bin
ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib
sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la
ln -sv bash /bin/sh
touch /etc/mtab
cat > /etc/passwd << "EOF"
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/dev/null:/bin/false
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
EOF
cat > /etc/group << "EOF"
root:x:0:
bin:x:1:
sys:x:2:
kmem:x:3:
tape:x:4:
tty:x:5:
daemon:x:6:
floppy:x:7:
disk:x:8:
lp:x:9:
dialout:x:10:
audio:x:11:
video:x:12:
utmp:x:13:
usb:x:14:
cdrom:x:15:
mail:x:34:
nogroup:x:99:
EOF
이제 ''I have no name!''을 없애보자.
exec /tools/bin/bash --login +h
로그와 관련된 파일을 생성한다.
touch /var/log/{btmp,lastlog,wtmp}
chgrp -v utmp /var/log/lastlog
chmod -v 664 /var/log/lastlog
chmod -v 600 /var/log/btmp
wtmp는 모든 로그인/아웃을, lastlog는 마지막 로그인을, btmp는 잘못된 로그인 시도를 기록한다. utmp는 현재 접속한 사용자들을 기록한다. 이 파일은 부트 스크립트에 의해 자동으로 생성된다.
===== Linux-3.8.1 API Headers =====
cd /sources
tar -xJf linux-3.8.1.tar.xz
cd linux-3.8.1
make mrproper
make headers_check
make INSTALL_HDR_PATH=dest headers_install
find dest/include \( -name .install -o -name ..install.cmd \) -delete
cp -rv dest/include/* /usr/include
===== Man-pages-3.47 =====
tar -xJf man-pages-3.47.tar.xz
cd man-pages-3.47
make install
cd ..
rm -fr man-pages-3.47
===== Glibc-2.17 =====
tar -xJf glibc-2.17.tar.xz
cd glibc-2.17
mkdir -v ../glibc-build
cd ../glibc-build
../glibc-2.17/configure \
--prefix=/usr \
--disable-profile \
--enable-kernel=2.6.25 \
--libexecdir=/usr/lib/glibc
make
make -k check 2>&1 | tee glibc-check-log
grep Error glibc-check-log
touch /etc/ld.so.conf
make install
cp -v ../glibc-2.17/sunrpc/rpc/*.h /usr/include/rpc
cp -v ../glibc-2.17/sunrpc/rpcsvc/*.h /usr/include/rpcsvc
cp -v ../glibc-2.17/nis/rpcsvc/*.h /usr/include/rpcsvc
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_GB -f UTF-8 en_GB.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 it_IT -f UTF-8 it_IT.UTF-8
localedef -i ja_JP -f EUC-JP ja_JP
localedef -i ru_RU -f KOI8-R ru_RU.KOI8-R
localedef -i ru_RU -f UTF-8 ru_RU.UTF-8
localedef -i tr_TR -f UTF-8 tr_TR.UTF-8
localedef -i zh_CN -f GB18030 zh_CN.GB18030
localedef -i ko_KR -f UTF-8 ko_KR.UTF-8
make localedata/install-locales
cd ..
rm -fr glibc-2.17 glibc-build
GClibc 설정
# nsswitch.conf
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
# Timezone
tar -xf ../tzdata2012j.tar.gz
ZONEINFO=/usr/share/zoneinfo
mkdir -pv $ZONEINFO/{posix,right}
for tz in etcetera southamerica northamerica europe africa antarctica \
asia australasia backward pacificnew solar87 solar88 solar89 \
systemv; do
zic -L /dev/null -d $ZONEINFO -y "sh yearistype.sh" ${tz}
zic -L /dev/null -d $ZONEINFO/posix -y "sh yearistype.sh" ${tz}
zic -L leapseconds -d $ZONEINFO/right -y "sh yearistype.sh" ${tz}
done
cp -v zone.tab iso3166.tab $ZONEINFO
zic -d $ZONEINFO -p America/New_York
unset ZONEINFO
tzselect
cp -v --remove-destination /usr/share/zoneinfo/Asia/Seoul /etc/localtime
cat > /etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf
/usr/local/lib
/opt/lib
EOF
cat >> /etc/ld.so.conf << "EOF"
# Add an include directory
include /etc/ld.so.conf.d/*.conf
EOF
mkdir /etc/ld.so.conf.d
===== 툴체인 조정 =====
C라이브러리가 새로 생성되었으므로 툴체인을 새롭게 조정한다.
6.10 Adjusting the Toolchain 챕터를 참고할 것.
===== Zlib-1.2.7 =====
tar -xjf zlib-1.2.7.tar.bz2
cd zlib-1.2.7
./configure --prefix=/usr
make && make check && make install
mv -v /usr/lib/libz.so.* /lib
ln -sfv ../../lib/libz.so.1.2.7 /usr/lib/libz.so
cd ..
rm -fr zlib-1.2.7
===== File-5.13 =====
tar -xzf file-5.13.tar.gz
cd file-5.13
./configure --prefix=/usr
make && make check && make install
cd ..
rm -fr file-5.13
===== Binutils-2.23.1 =====
다음 테스트를 통해 PTY가 제대로 동작하는지 확인
expect -c "spawn ls" # spawn ls 라는 문자열을 내보냄
tar -xjf binutils-2.23.1.tar.bz2
cd binutils-2.23.1
rm -fv etc/standards.info
sed -i.bak '/^INFO/s/standards.info //' etc/Makefile.in
patch -Np1 -i ../binutils-2.23.1-testsuite_fix-1.patch
mkdir -v ../binutils-build
cd ../binutils-build
../binutils-2.23.1/configure --prefix=/usr --enable-shared
make tooldir=/usr
make check
make tooldir=/usr install
cp -v ../binutils-2.23.1/include/libiberty.h /usr/include
cd ..
rm -fr binutils-2.23.1
===== Gmp-5.1.1 =====
tar -xJf gmp-5.1.1.tar.xz
cd gmp-5.1.1
./configure --prefix=/usr --enable-cxx
make
make check 2>&1 | tee gmp-check-log
awk '/tests passed/{total+=$2} ; END{print total}' gmp-check-log
make install
mkdir -v /usr/share/doc/gmp-5.1.1
cp -v doc/{isa_abi_headache,configuration} doc/*.html \
/usr/share/doc/gmp-5.1.1
cd ..
rm -fr gmp-5.1.1
===== Mpfr-3.1.1 =====
tar -xJf mpfr-3.1.1.tar.xz
cd mpfr-3.1.1
./configure --prefix=/usr \
--enable-thread-safe \
--docdir=/usr/share/doc/mpfr-3.1.1
make
make check
make install
make html
make install-html
cd ..
rm -fr mpfr-3.1.1
===== Mpc-1.0.1 =====
tar -xzf mpc-1.0.1.tar.gz
cd mpc-1.0.1
./configure --prefix=/usr
make
make check
make install
cd ..
rm -fr mpc-1.0.1
===== Gcc-4.7.2 =====
tar -xjf gcc-4.7.2.tar.bz2
cd gcc-4.7.2
sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
sed -i 's/BUILD_INFO=info/BUILD_INFO=/' gcc/configure
case `uname -m` in
i?86) sed -i 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in ;;
esac
sed -i -e /autogen/d -e /check.sh/d fixincludes/Makefile.in
mkdir -v ../gcc-build
cd ../gcc-build
../gcc-4.7.2/configure --prefix=/usr \
--libexecdir=/usr/lib \
--enable-shared \
--enable-threads=posix \
--enable-__cxa_atexit \
--enable-clocale=gnu \
--enable-languages=c,c++ \
--disable-multilib \
--disable-bootstrap \
--with-system-zlib
make
ulimit -s 32768
make -k check
../gcc-4.7.2/contrib/test_summary
make install
ln -sv ../usr/bin/cpp /lib
ln -sv gcc /usr/bin/cc
# Test Phase
#
echo 'main(){}' > dummy.c
cc dummy.c -v -Wl,--verbose &> dummy.log
readelf -l a.out | grep ': /lib' # [Requesting program interpreter: /lib/ld-linux.so.2]
grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log
grep -B4 '^ /usr/include' dummy.log
grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'
grep "/lib.*/libc.so.6 " dummy.log
grep found dummy.log
rm -v dummy.c a.out dummy.log
mkdir -pv /usr/share/gdb/auto-load/usr/lib
mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib
cd ..
rm -fr gcc-4.7.2
===== Sed-4.2.2 =====
tar -xjf sed-4.2.2.tar.bz2
cd sed-4.2.2
./configure --prefix=/usr --bindir=/bin --htmldir=/usr/share/doc/sed-4.2.2
make && make html && make check
make install
make -C doc install-html
cd ..
rm -fr sed-4.2.2
===== Bzip2-1.0.6 =====
tar -xzf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
patch -Np1 -i ../bzip2-1.0.6-install_docs-1.patch
sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile
sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile
make -f Makefile-libbz2_so
make clean
make
make PREFIX=/usr install
cp -v bzip2-shared /bin/bzip2
cp -av libbz2.so* /lib
ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so
rm -v /usr/bin/{bunzip2,bzcat,bzip2}
ln -sv bzip2 /bin/bunzip2
ln -sv bzip2 /bin/bzcat
cd ..
rm -fr bzip2-1.0.6
===== Pkg-config-0.28 =====
tar -xzf pkg-config-0.28.tar.gz
cd pkg-config-0.28
./configure --prefix=/usr \
--with-internal-glib \
--disable-host-tool \
--docdir=/usr/share/doc/pkg-config-0.28
make
make check
make install
cd ..
rm -fr pkg-config-0.28
===== Ncurses-5.9 =====
tar -xzf ncurses-5.9.tar.gz
cd ncurses-5.9
./configure --prefix=/usr \
--mandir=/usr/share/man \
--with-shared \
--without-debug \
--enable-pc-files \
--enable-widec
make
make install
mv -v /usr/lib/libncursesw.so.5* /lib
ln -sfv ../../lib/libncursesw.so.5 /usr/lib/libncursesw.so
for lib in ncurses form panel menu ; do
rm -vf /usr/lib/lib${lib}.so
echo "INPUT(-l${lib}w)" > /usr/lib/lib${lib}.so
ln -sfv lib${lib}w.a /usr/lib/lib${lib}.a
ln -sfv ${lib}w.pc /usr/lib/pkgconfig/${lib}.pc
done
ln -sfv libncurses++w.a /usr/lib/libncurses++.a
rm -vf /usr/lib/libcursesw.so
echo "INPUT(-lncursesw)" > /usr/lib/libcursesw.so
ln -sfv libncurses.so /usr/lib/libcurses.so
ln -sfv libncursesw.a /usr/lib/libcursesw.a
ln -sfv libncurses.a /usr/lib/libcurses.a
cd ..
rm -fr ncurses-5.9
===== Util-linux-2.22.2 =====
tar -xJf util-linux-2.22.2.tar.xz
cd util-linux-2.22.2
sed -i -e 's@etc/adjtime@var/lib/hwclock/adjtime@g' \
$(grep -rl '/etc/adjtime' .)
mkdir -pv /var/lib/hwclock
./configure --disable-su --disable-sulogin --disable-login
make
make install
cd ..
rm -fr util-linux-2.22.2
===== Psmisc-22.20 =====
tar -xzf psmisc-22.20.tar.gz
cd psmisc-22.20
./configure --prefix=/usr
make
make install
mv -v /usr/bin/fuser /bin
mv -v /usr/bin/killall /bin
cd ..
rm -fr psmisc-22.20
===== Procps-ng-3.3.6 =====
tar -xJf procps-ng-3.3.6.tar.xz
cd procps-ng-3.3.6
./configure --prefix=/usr \
--exec-prefix= \
--libdir=/usr/lib \
--docdir=/usr/share/doc/procps-ng-3.3.6 \
--disable-static \
--disable-skill \
--disable-kill
make
# modification for test in LFS
pushd testsuite
sed -i -e 's|exec which sleep|exec echo /tools/bin/sleep|' \
-e 's|999999|&9|' config/unix.exp
sed -i -e 's|pmap_initname\\\$|pmap_initname|' pmap.test/pmap.exp
make site.exp
DEJAGNU=global-conf.exp runtest
popd
make install
mv -v /usr/lib/libprocps.so.* /lib
ln -sfv ../../lib/libprocps.so.1.1.0 /usr/lib/libprocps.so
cd ..
rm -fr procps-ng-3.3.6
===== E2fsprogs-1.42.7 =====
tar -xzf e2fsprogs-1.42.7.tar.gz
cd e2fsprogs-1.42.7
mkdir -v build
cd build
../configure --prefix=/usr \
--with-root-prefix="" \
--enable-elf-shlibs \
--disable-libblkid \
--disable-libuuid \
--disable-uuidd \
--disable-fsck
make
make check
make install
make install-libs
chmod -v u+w /usr/lib/{libcom_err,libe2p,libext2fs,libss}.a
gunzip -v /usr/share/info/libext2fs.info.gz
install-info --dir-file=/usr/share/info/dir /usr/share/info/libext2fs.info
cd ../../
rm -fr e2fsprogs-1.42.7
===== Shadow-4.1.5.1 =====
tar -xjf shadow-4.1.5.1.tar.bz2
cd shadow-4.1.5.1
sed -i 's/groups$(EXEEXT) //' src/Makefile.in
find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \;
sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' \
-e 's@/var/spool/mail@/var/mail@' etc/login.defs
sed -i 's@DICTPATH.*@DICTPATH\t/lib/cracklib/pw_dict@' \
etc/login.defs
./configure --sysconfdir=/etc --with-libcrack
make
make install
mv -v /usr/bin/passwd /bin
cd ..
rm -fr shadow-4.1.5.1
pwconv
grpconv
===== Coreutils-8.21 =====
tar -xJf coreutils-8.21.tar.xz
cd coreutils-8.21
patch -Np1 -i ../coreutils-8.21-i18n-1.patch
FORCE_UNSAFE_CONFIGURE=1 ./configure \
--prefix=/usr \
--libexecdir=/usr/lib \
--enable-no-install-program=kill,uptime
make
make NON_ROOT_USERNAME=nobody check-root
echo "dummy:x:1000:nobody" >> /etc/group
chown -Rv nobody .
su nobody -s /bin/bash \
-c "PATH=$PATH make RUN_EXPENSIVE_TESTS=yes check"
sed -i '/dummy/d' /etc/group
make install
mv -v /usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} /bin
mv -v /usr/bin/{false,ln,ls,mkdir,mknod,mv,pwd,rm} /bin
mv -v /usr/bin/{rmdir,stty,sync,true,uname,test,[} /bin
mv -v /usr/bin/chroot /usr/sbin
mv -v /usr/share/man/man1/chroot.1 /usr/share/man/man8/chroot.8
sed -i s/\"1\"/\"8\"/1 /usr/share/man/man8/chroot.8
mv -v /usr/bin/{head,sleep,nice} /bin
cd ..
rm -fr coreutils-8.21
===== Iana-etc-2.30 =====
tar -xjf iana-etc-2.30.tar.bz2
cd iana-etc-2.30
make
make install
cd ..
rm -fr iana-etc-2.30
===== M4-1.4.16 =====
tar -xjf m4-1.4.16.tar.bz2
cd m4-1.4.16
sed -i -e '/gets is a/d' lib/stdio.in.h
./configure --prefix=/usr
make
sed -i -e '41s/ENOENT/& || errno == EINVAL/' tests/test-readlink.h
make check
make install
cd ..
rm -fr m4-1.4.16
===== Bison-2.7 =====
tar -xJf bison-2.7.tar.xz
cd bison-2.7
./configure --prefix=/usr
echo '#define YYENABLE_NLS 1' >> lib/config.h
make
make check
make install
cd ..
rm -fr bison-2.7
===== Grep-2.14 =====
tar -xJf grep-2.14.tar.xz
cd grep-2.14
./configure --prefix=/usr --bindir=/bin
make
make check
make install
cd ..
rm -fr grep-2.14
===== Readline-6.2 =====
tar -xzf readline-6.2.tar.gz
cd readline-6.2
sed -i '/MV.*old/d' Makefile.in
sed -i '/{OLDSUFF}/c:' support/shlib-install
patch -Np1 -i ../readline-6.2-fixes-1.patch
./configure --prefix=/usr --libdir=/lib
make SHLIB_LIBS=-lncurses
make install
mv -v /lib/lib{readline,history}.a /usr/lib
rm -v /lib/lib{readline,history}.so
ln -sfv ../../lib/libreadline.so.6 /usr/lib/libreadline.so
ln -sfv ../../lib/libhistory.so.6 /usr/lib/libhistory.so
cd ..
rm -fr readline-6.2
===== Bash-4.2 =====
tar -xzf bash-4.2.tar.gz
cd bash-4.2
patch -Np1 -i ../bash-4.2-fixes-11.patch
./configure --prefix=/usr \
--bindir=/bin \
--htmldir=/usr/share/doc/bash-4.2 \
--without-bash-malloc \
--with-installed-readline
make
chown -Rv nobody .
su nobody -s /bin/bash -c "PATH=$PATH make tests"
make install
exec /bin/bash --login +h
cd ..
rm -fr bash-4.2
===== Libtool-2.4.2 =====
tar -xzf libtool-2.4.2.tar.gz
cd libtool-2.4.2
./configure --prefix=/usr
make
make check
make install
cd ..
rm -fr libtool-2.4.2
===== Gdbm-1.10 =====
tar -xzf gdbm-1.10.tar.gz
cd gdbm-1.10
./configure --prefix=/usr --enable-libgdbm-compat
make
make check
make install
cd ..
rm -fr gdbm-1.10
===== Inetutils-1.9.1 =====
tar -xzf inetutils-1.9.1.tar.gz
cd inetutils-1.9.1
sed -i -e '/gets is a/d' lib/stdio.in.h
./configure --prefix=/usr \
--libexecdir=/usr/sbin \
--localstatedir=/var \
--disable-ifconfig \
--disable-logger \
--disable-syslogd \
--disable-whois \
--disable-servers
make
make check
make install
mv -v /usr/bin/{hostname,ping,ping6,traceroute} /bin
cd ..
rm -fr inetutils-1.9.1
===== Perl-5.16.2 =====
tar -xjf perl-5.16.2.tar.bz2
cd perl-5.16.2
echo "127.0.0.1 localhost $(hostname)" > /etc/hosts
sed -i -e "s|BUILD_ZLIB\s*= True|BUILD_ZLIB = False|" \
-e "s|INCLUDE\s*= ./zlib-src|INCLUDE = /usr/include|" \
-e "s|LIB\s*= ./zlib-src|LIB = /usr/lib|" \
cpan/Compress-Raw-Zlib/config.in
sh Configure -des -Dprefix=/usr \
-Dvendorprefix=/usr \
-Dman1dir=/usr/share/man/man1 \
-Dman3dir=/usr/share/man/man3 \
-Dpager="/usr/bin/less -isR" \
-Duseshrplib
make
make -k test
make install
cd ..
rm -fr perl-5.16.2
===== Autoconf-2.69 =====
tar -xJf autoconf-2.69.tar.xz
cd autoconf-2.69
./configure --prefix=/usr
make
make check
make install
cd ..
rm -fr autoconf-2.69
===== Automake-1.13.1 =====
tar -xJf automake-1.13.1.tar.xz
cd automake-1.13.1
./configure --prefix=/usr --docdir=/usr/share/doc/automake-1.13.1
make
make install
cd ..
rm -fr automake-1.13.1
===== Diffutils-3.2 =====
tar -xzf diffutils-3.2.tar.gz
cd diffutils-3.2
sed -i -e '/gets is a/d' lib/stdio.in.h
./configure --prefix=/usr
make
make check
make install
cd ..
rm -fr diffutils-3.2
===== Gawk-4.0.2 =====
tar -xJf gawk-4.0.2.tar.xz
cd gawk-4.0.2
./configure --prefix=/usr --libexecdir=/usr/lib
make
make check
make install
cd ..
rm -fr gawk-4.0.2
===== Findutils-4.4.2 =====
tar -xzf findutils-4.4.2.tar.gz
cd findutils-4.4.2
./configure --prefix=/usr \
--libexecdir=/usr/lib/findutils \
--localstatedir=/var/lib/locate
make
make check
make install
mv -v /usr/bin/find /bin
sed -i 's/find:=${BINDIR}/find:=\/bin/' /usr/bin/updatedb
cd ..
rm -fr findutils-4.4.2
===== Flex-2.5.37 =====
tar -xjf flex-2.5.37.tar.bz2
cd flex-2.5.37
patch -Np1 -i ../flex-2.5.37-bison-2.6.1-1.patch
./configure --prefix=/usr \
--docdir=/usr/share/doc/flex-2.5.37
make
make check
make install
ln -sv libfl.a /usr/lib/libl.a
cat > /usr/bin/lex << "EOF"
#!/bin/sh
# Begin /usr/bin/lex
exec /usr/bin/flex -l "$@"
# End /usr/bin/lex
EOF
chmod -v 755 /usr/bin/lex
cd ..
rm -fr flex-2.5.37
===== Gettext-0.18.2 =====
tar -xzf gettext-0.18.2.tar.gz
cd gettext-0.18.2
./configure --prefix=/usr \
--docdir=/usr/share/doc/gettext-0.18.2
make
make check
make install
cd ..
rm -fr gettext-0.18.2
===== Groff-1.22.2 =====
tar -xzf groff-1.22.2.tar.gz
cd groff-1.22.2
PAGE=A4 ./configure --prefix=/usr
make
mkdir -p /usr/share/doc/groff-1.22/pdf
make install
ln -sv eqn /usr/bin/geqn
ln -sv tbl /usr/bin/gtbl
cd ..
rm -fr groff-1.22.2
===== Xz-5.0.4 =====
tar -xJf xz-5.0.4.tar.xz
cd xz-5.0.4
./configure --prefix=/usr --libdir=/lib --docdir=/usr/share/doc/xz-5.0.4
make
make check
make pkgconfigdir=/usr/lib/pkgconfig install
cd ..
rm -fr xz-5.0.4
===== Grub-2.00 =====
tar -xJf grub-2.00.tar.xz
cd grub-2.00
sed -i -e '/gets is a/d' grub-core/gnulib/stdio.in.h
./configure --prefix=/usr \
--sysconfdir=/etc \
--disable-grub-emu-usb \
--disable-efiemu \
--disable-werror
make
make install
cd ..
rm -fr grub-2.00
===== Less-451 =====
tar -xzf less-451.tar.gz
cd less-451
./configure --prefix=/usr --sysconfdir=/etc
make
make install
cd ..
rm -fr less-451
===== Gzip-1.5 =====
tar -xJf gzip-1.5.tar.xz
cd gzip-1.5
./configure --prefix=/usr --bindir=/bin
make
make check
make install
mv -v /bin/{gzexe,uncompress,zcmp,zdiff,zegrep} /usr/bin
mv -v /bin/{zfgrep,zforce,zgrep,zless,zmore,znew} /usr/bin
cd ..
rm -fr gzip-1.5
===== Iproute2-3.8.0 =====
tar -xJf iproute2-3.8.0.tar.xz
cd iproute2-3.8.0
sed -i '/^TARGETS/s@arpd@@g' misc/Makefile
sed -i /ARPD/d Makefile
sed -i 's/arpd.8//' man/man8/Makefile
sed -i 's/-Werror//' Makefile
make DESTDIR=
make DESTDIR= \
MANDIR=/usr/share/man \
DOCDIR=/usr/share/doc/iproute2-3.8.0 install
cd ..
rm -fr iproute2-3.8.0
===== Kbd-1.15.5 =====
tar -xzf kbd-1.15.5.tar.gz
cd kbd-1.15.5
patch -Np1 -i ../kbd-1.15.5-backspace-1.patch
sed -i -e '326 s/if/while/' src/loadkeys.analyze.l
sed -i 's/\(RESIZECONS_PROGS=\)yes/\1no/g' configure
sed -i 's/resizecons.8 //' man/man8/Makefile.in
./configure --prefix=/usr --datadir=/lib/kbd \
--disable-vlock
make
make install
mv -v /usr/bin/{kbd_mode,loadkeys,openvt,setfont} /bin
cd ..
rm -fr kbd-1.15.5
===== Kmod-12 =====
tar -xJf kmod-12.tar.xz
cd kmod-12
./configure --prefix=/usr \
--bindir=/bin \
--libdir=/lib \
--sysconfdir=/etc \
--disable-manpages \
--with-xz \
--with-zlib
make
make check
make pkgconfigdir=/usr/lib/pkgconfig install
for target in depmod insmod modinfo modprobe rmmod; do
ln -sv ../bin/kmod /sbin/$target
done
ln -sv kmod /bin/lsmod
cd ..
rm -fr kmod-12
===== Libpipeline-1.2.2 =====
tar -xzf libpipeline-1.2.2.tar.gz
cd libpipeline-1.2.2
PKG_CONFIG_PATH=/tools/lib/pkgconfig ./configure --prefix=/usr
make
make check
make install
cd ..
rm -fr libpipeline-1.2.2
===== Make-3.82 =====
tar -xjf make-3.82.tar.bz2
cd make-3.82
patch -Np1 -i ../make-3.82-upstream_fixes-3.patch
./configure --prefix=/usr
make
make check
make install
cd ..
rm -fr make-3.82
===== Man-db-2.6.3 =====
tar -xJf man-db-2.6.3.tar.xz
cd man-db-2.6.3
./configure --prefix=/usr \
--libexecdir=/usr/lib \
--docdir=/usr/share/doc/man-db-2.6.3 \
--sysconfdir=/etc \
--disable-setuid \
--with-browser=/usr/bin/lynx \
--with-vgrind=/usr/bin/vgrind \
--with-grap=/usr/bin/grap
make
make check
make install
cd ..
rm -fr man-db-2.6.3
===== Patch-2.7.1 =====
tar -xJf patch-2.7.1.tar.xz
cd patch-2.7.1
./configure --prefix=/usr
make
make check
make install
cd ..
rm -fr patch-2.7.1
===== Sysklogd-1.5 =====
tar -xzf sysklogd-1.5.tar.gz
cd sysklogd-1.5
make
make BINDIR=/sbin install
cd ..
rm -fr sysklogd-1.5
Configuration
cat > /etc/syslog.conf << "EOF"
# Begin /etc/syslog.conf
auth,authpriv.* -/var/log/auth.log
*.*;auth,authpriv.none -/var/log/sys.log
daemon.* -/var/log/daemon.log
kern.* -/var/log/kern.log
mail.* -/var/log/mail.log
user.* -/var/log/user.log
*.emerg *
# End /etc/syslog.conf
EOF
===== Sysvinit-2.88dsf =====
tar -xjf sysvinit-2.88dsf.tar.bz2
cd sysvinit-2.88dsf
sed -i 's@Sending processes@& configured via /etc/inittab@g' src/init.c
sed -i -e '/utmpdump/d' \
-e '/mountpoint/d' src/Makefile
make -C src
make -C src install
cd ..
rm -fr sysvinit-2.88dsf
===== Tar-1.26 =====
tar -xjf tar-1.26.tar.bz2
cd tar-1.26
sed -i -e '/gets is a/d' gnu/stdio.in.h
FORCE_UNSAFE_CONFIGURE=1 \
./configure --prefix=/usr \
--bindir=/bin \
--libexecdir=/usr/sbin
make
make check
make install
make -C doc install-html docdir=/usr/share/doc/tar-1.26
cd ..
rm -fr tar-1.26
===== Texinfo-5.0 =====
tar -xJf texinfo-5.0.tar.xz
cd texinfo-5.0
./configure --prefix=/usr
make
make check
make install
make TEXMF=/usr/share/texmf install-tex
cd ..
rm -fr texinfo-5.0
===== Systemd-197 =====
tar -xJf systemd-197.tar.xz
cd systemd-197
tar -xvf ../udev-lfs-197-2.tar.bz2
make -f udev-lfs-197-2/Makefile.lfs
make -f udev-lfs-197-2/Makefile.lfs install
build/udevadm hwdb --update
bash udev-lfs-197-2/init-net-rules.sh
cd ..
rm -fr systemd-197
===== Vim-7.3 =====
tar -xjf vim-7.3.tar.bz2
cd vim73
echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h
./configure --prefix=/usr --enable-multibyte
make
make test
make install
ln -sv vim /usr/bin/vi
for L in /usr/share/man/{,*/}man1/vim.1; do
ln -sv vim.1 $(dirname $L)/vi.1
done
ln -sv ../vim/vim73/doc /usr/share/doc/vim-7.3
cd ..
rm -fr vim-7.3
cat > /etc/vimrc << "EOF"
" Begin /etc/vimrc
set nocompatible
set backspace=2
syntax on
if (&term == "iterm") || (&term == "putty")
set background=dark
endif
" End /etc/vimrc
EOF
===== Stripping =====
/tools/bin/find /{,usr/}{bin,lib,sbin} -type f \
-exec /tools/bin/strip --strip-debug '{}' ';'
===== Cleaning =====
이제부터 chroot을 하려면,
chroot "$LFS" /usr/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
CFLAGS="-O2 -pipe -march=native -fomit-frame-pointer" \
CXXFLAGS="${CFLAGS}" \
MAKEOPTS="-j5" \
/bin/bash --login
이제는 /tools 디렉토리가 의미가 없어졌기 때문이다.
===== CrackLib-2.9.0 =====
racklib-words-20080507.gz 파일을 /source 에 보관.
tar xf cracklib-2.9.0.tar.gz
cd cracklib-2.9.0
./configure --prefix=/usr \
--with-default-dict=/lib/cracklib/pw_dict \
--disable-static &&
make
make install
mv -v /usr/lib/libcrack.so.2* /lib
ln -v -sf ../../lib/libcrack.so.2.9.0 /usr/lib/libcrack.so
install -v -m644 -D ../cracklib-words-20080507.gz \
/usr/share/dict/cracklib-words.gz
gunzip -v /usr/share/dict/cracklib-words.gz
ln -v -s cracklib-words /usr/share/dict/words
echo $(hostname) >>/usr/share/dict/cracklib-extra-words
install -v -m755 -d /lib/cracklib
create-cracklib-dict /usr/share/dict/cracklib-words \
/usr/share/dict/cracklib-extra-words
cd ..
rm -fr cracklib-2.9.0.tar.gz