Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1071399
  • 博文数量: 277
  • 博客积分: 8313
  • 博客等级: 中将
  • 技术积分: 2976
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-22 11:25
文章分类

全部博文(277)

文章存档

2013年(17)

2012年(66)

2011年(104)

2010年(90)

我的朋友

分类: LINUX

2010-09-21 19:00:13

6.1. Introduction
mkdir -v $LFS/{dev,proc,sys}
mknod -m 600 $LFS/dev/console c 5 1
mknod -m 666 $LFS/dev/null c 1 3
mount -v --bind /dev $LFS/dev
mount -vt devpts devpts $LFS/dev/pts
mount -vt tmpfs shm $LFS/dev/shm
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
 
6.4. Entering the Chroot Environment
chroot "$LFS" /tools/bin/env -i \
    HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
    /tools/bin/bash --login +h
 
6.5. Creating Directories
mkdir -pv /{bin,boot,etc/opt,home,lib,mnt,opt}
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/{lock,log,mail,run,spool}
mkdir -pv /var/{opt,cache,lib/{misc,locate},local}
 

6.6. Creating Essential Files and Symlinks
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
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:
tty:x:4:
tape: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
exec /tools/bin/bash --login +h
touch /var/run/utmp /var/log/{btmp,lastlog,wtmp}
chgrp -v utmp /var/run/utmp /var/log/lastlog
chmod -v 664 /var/run/utmp /var/log/lastlog
 

6.7. Linux-2.6.35.4 API Headers
cd linux-2.6.35.4
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
cd ..   
 
 
6.8. Man-pages-3.25
tar -xf man-pages-3.25.tar.bz2
cd man-pages-3.25
make install
cd ..
rm -rf man-pages-3.25
 
6.9. Glibc-2.12.1
tar -jxf glibc-2.12.1.tar.bz2
cd glibc-2.12.1
DL=$(readelf -l /bin/sh | sed -n )
sed -i "s|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=$DL -o|" \
        scripts/test-installation.pl
unset DL
sed -i elf/ldd.bash.in
patch -Np1 -i ../glibc-2.12.1-gcc_fix-1.patch
patch -Np1 -i ../glibc-2.12.1-makefile_fix-1.patch
mkdir -v ../glibc-build
cd ../glibc-build
case `uname -m` in
  i?86) echo "CFLAGS += -march=i486 -mtune=native -O3 -pipe" > configparms ;;
esac
../glibc-2.12.1/configure --prefix=/usr \
    --disable-profile --enable-add-ons \
    --enable-kernel=2.6.22.5 --libexecdir=/usr/lib/glibc
make
cp -v ../glibc-2.12.1/iconvdata/gconv-modules iconvdata
make -k check 2>&1 | tee glibc-check-log
grep Error glibc-check-log
touch /etc/ld.so.conf
touch /etc/ld.so.conf
make install
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 -f ISO-8859-15
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 -f ISO-8859-15
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
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
tzselect
cp -v --remove-destination /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
   
   
cat > /etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf
/usr/local/lib
/opt/lib
# End /etc/ld.so.conf
EOF

cd ..
rm -rf glibc-2.12.1 glibc-build        
  
 
6.10. Re-adjusting the Toolchain
mv -v /tools/bin/{ld,ld-old}
mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}
mv -v /tools/bin/{ld-new,ld}
ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld
gcc -dumpspecs | sed -e \
    -e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \
    -e '/\*cpp:/{n;s@$@ -isystem > \
    `dirname $(gcc --print-libgcc-file-name)`/specs
echo 'main(){}' > dummy.c
cc dummy.c -v -Wl,--verbose &> dummy.log
readelf -l a.out | grep ': /lib'

6.11. Zlib-1.2.5  
tar -xf zlib-1.2.5.tar.bz2
cd zlib-1.2.5
sed -i 's/ifdef _LARGEFILE64_SOURCE/ifndef _LARGEFILE64_SOURCE/' zlib.h
CFLAGS='-mstackrealign -fPIC -O3' ./configure --prefix=/usr
make
make check
make install
mv -v /usr/lib/libz.so.* /lib
ln -sfv ../../lib/libz.so.1.2.5 /usr/lib/libz.so
cd ..
rm -rf zlib-1.2.5
 
6.12. Binutils-2.20.1
tar -jxf binutils-2.20.1.tar.bz2
cd binutils-2.20.1
rm -fv etc/standards.info
sed -i.bak '/^INFO/s/standards.info //' etc/Makefile.in
mkdir -v ../binutils-build
cd ../binutils-build
../binutils-2.20.1/configure --prefix=/usr \
    --enable-shared
make tooldir=/usr
make check
make tooldir=/usr install
cp -v ../binutils-2.20.1/include/libiberty.h /usr/include
cd ..
rm -rf binutils-2.20.1 binutils-build

6.13. GMP-5.0.1
tar -jxf gmp-5.0.1.tar.bz2
cd gmp-5.0.1
./configure --prefix=/usr --enable-cxx --enable-mpbsd
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.0.1
cp    -v doc/{isa_abi_headache,configuration} doc/*.html \
         /usr/share/doc/gmp-5.0.1
cd ..
rm -rf gmp-5.0.1
        

6.14. MPFR-3.0.0
tar -jxf mpfr-3.0.0.tar.bz2
cd mpfr-3.0.0
./configure --prefix=/usr --enable-thread-safe \
  --docdir=/usr/share/doc/mpfr-3.0.0
make
make check
make install
make html
make install-html
cd ..
rm -rf mpfr-3.0.0
 
6.15. MPC-0.8.2
tar -zxf mpc-0.8.2.tar.gz
cd mpc-0.8.2
./configure --prefix=/usr
make
make check
make install
cd ..
rm -rf mpc-0.8.2
 
6.16. GCC-4.5.1
tar -jxf gcc-4.5.1.tar.bz2
cd gcc-4.5.1
sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
case `uname -m` in
  i?86) sed -i 's/^T_CFLAGS =$/& -fomit-frame-pointer/' \
        gcc/Makefile.in ;;
esac
sed -i gcc/Makefile.in
mkdir -v ../gcc-build
cd ../gcc-build
../gcc-4.5.1/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
make -k check
../gcc-4.5.1/contrib/test_summary
make install
ln -sv ../usr/bin/cpp /lib
ln -sv gcc /usr/bin/cc
echo 'main(){}' > dummy.c
cc dummy.c -v -Wl,--verbose &> dummy.log
readelf -l a.out | grep ': /lib'   
 

6.17. Sed-4.2.1
tar -xf sed-4.2.1.tar.bz2
cd sed-4.2.1
./configure --prefix=/usr --bindir=/bin --htmldir=/usr/share/doc/sed-4.2.1
make
make html
make install
make -C doc install-html
cd ..
rm -rf sed-4.2.1
 
6.18. Pkg-config-0.25
tar -xf pkg-config-0.25.tar.gz
cd pkg-config-0.25
./configure --prefix=/usr
make
make install
cd ..
rm -rf pkg-config-0.25
 
6.19. Ncurses-5.7
tar -xf ncurses-5.7.tar.gz
cd ncurses-5.7        
./configure --prefix=/usr --with-shared --without-debug --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 ; \
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
mkdir -v       /usr/share/doc/ncurses-5.7
cp -v -R doc/* /usr/share/doc/ncurses-5.7
cd ..
rm -rf ncurses-5.7
 
6.20. Util-linux-ng-2.18
tar -xf util-linux-ng-2.18.tar.bz2
cd util-linux-ng-2.18
sed -e \
    -i $(grep -rl '/etc/adjtime' .)
mkdir -pv /var/lib/hwclock
./configure --enable-arch --enable-partx --enable-write
make
make install
cd ..
rm -rf util-linux-ng-2.18
 
6.21. E2fsprogs-1.41.12
tar -xf e2fsprogs-1.41.12.tar.gz
cd e2fsprogs-1.41.12
mkdir -v build
cd build
../configure --prefix=/usr --with-root-prefix="" \
    --enable-elf-shlibs --disable-libblkid --disable-libuuid \
    --disable-uuidd --disable-fsck
make
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
makeinfo -o      doc/com_err.info ../lib/et/com_err.texinfo
install -v -m644 doc/com_err.info /usr/share/info
install-info --dir-file=/usr/share/info/dir \
             /usr/share/info/com_err.info
cd ../..
rm -rf e2fsprogs-1.41.12
 

6.22. Coreutils-8.5
tar -xf coreutils-8.5.tar.gz
cd coreutils-8.5
case `uname -m` in
 i?86 | x86_64) patch -Np1 -i ../coreutils-8.5-uname-2.patch ;;
esac
patch -Np1 -i ../coreutils-8.5-i18n-1.patch
./configure --prefix=/usr \
    --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-tools nobody -s /bin/bash -c "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} /bin
mv -v /usr/bin/chroot /usr/sbin
mv -v /usr/bin/{head,sleep,nice} /bin
cd ..
rm -rf coreutils-8.5
 
6.23. Iana-Etc-2.30
tar -xf iana-etc-2.30.tar.bz2
cd iana-etc-2.30
make
make install
cd ..
rm -rf iana-etc-2.30
 
6.24. M4-1.4.14
tar -xf m4-1.4.14.tar.bz2
cd m4-1.4.14
sed -i -e '/"m4.h"/a\
#include ' src/path.c
./configure --prefix=/usr
make
make install
cd ..
rm -rf m4-1.4.14
 
6.25. Bison-2.4.3
tar -xf bison-2.4.3.tar.bz2
cd bison-2.4.3
./configure --prefix=/usr
echo '#define YYENABLE_NLS 1' >> lib/config.h
make
make install
cd ..
rm -rf bison-2.4.3
 
6.26. Procps-3.2.8
tar -xf procps-3.2.8.tar.gz
cd procps-3.2.8
patch -Np1 -i ../procps-3.2.8-watch_unicode-1.patch
sed -i -e Makefile
make
make install
cd ..
rm -rf procps-3.2.8
 
6.27. Grep-2.6.3
tar -xf grep-2.6.3.tar.gz
cd grep-2.6.3
./configure --prefix=/usr \
    --bindir=/bin
make
make install
cd ..
rm -rf grep-2.6.3
 
6.28. Readline-6.1
tar -xf readline-6.1.tar.gz
cd readline-6.1
sed -i '/MV.*old/d' Makefile.in
sed -i '/{OLDSUFF}/c:' support/shlib-install
sed -i -e 's/0x0600/0x0601/' \
       -e 's/6\.0/6.1/' \
       -e 's/RL_VERSION_MINOR\t0/RL_VERSION_MINOR\t1/' readline.h
./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
mkdir   -v       /usr/share/doc/readline-6.1
install -v -m644 doc/*.{ps,pdf,html,dvi} \
                 /usr/share/doc/readline-6.1
cd ..
rm -rf readline-6.1
阅读(641) | 评论(0) | 转发(0) |
0

上一篇:lfs_1

下一篇:lfs_3

给主人留下些什么吧!~~