分类: LINUX
2007-04-23 14:18:20
cfdisk
mkswap /dev/sda1 mkfs.xfs /dev/sda2
export LFS=/mnt/lfs mkdir -pv $LFS
mount /dev/sda2 $LFS
mkdir -v $LFS/sources chmod -v a+wt $LFS/sources
mkdir -v $LFS/tools ln -sv $LFS/tools /
groupadd lfs useradd -s /bin/bash -g lfs -m -k /dev/null lfs
passwd lfs
chown -v lfs $LFS/tools chown -v lfs $LFS/sources
su - lfs
cat > ~/.bash_profile << "EOF" exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash EOF cat > ~/.bashrc << "EOF" set +h umask 022 LFS=/mnt/lfs LC_ALL=POSIX PATH=/tools/bin:/bin:/usr/bin export LFS LC_ALL PATH EOF source ~/.bash_profile
cd $LFS/sources
tar xvf /lfs-sources/binutils-2.15.94.0.2.2.tar.bz2 cd binutils-2.15.94.0.2.2
patch -Np1 -i /lfs-sources/binutils-2.15.94.0.2.2-gcc4-1.patch
mkdir -v ../binutils-build cd ../binutils-build ../binutils-2.15.94.0.2.2/configure --prefix=/tools --disable-nls make make install make -C ld clean make -C ld LIB_PATH=/tools/lib cd ..
tar xvf /lfs-sources/gcc-3.4.3.tar.bz2 mkdir -v gcc-build cd gcc-build ../gcc-3.4.3/configure --prefix=/tools --libexecdir=/tools/lib \ --with-local-prefix=/tools --disable-nls \ --enable-shared --enable-languages=c make bootstrap make install ln -vs gcc /tools/bin/cc cd .. rm -rf gcc-build rm -rf gcc-3.4.3
tar xvf /lfs-sources/linux-libc-headers-2.6.11.2.tar.bz2 cd linux-libc-headers-2.6.11.2 cp -Rv include/asm-i386 /tools/include/asm cp -Rv include/linux /tools/include cd .. rm -rf linux-libc-headers-2.6.11.2
tar xvf /lfs-sources/glibc-2.3.4.tar.bz2 cd glibc-2.3.4 patch -Np1 -i /lfs-sources/glibc-2.3.4-fix_test-1.patch mkdir -v ../glibc-build cd ../glibc-build ../glibc-2.3.4/configure --prefix=/tools \ --disable-profile --enable-add-ons \ --enable-kernel=2.6.0 --with-binutils=/tools/bin \ --without-gd --with-headers=/tools/include \ --without-selinux make mkdir -v /tools/etc touch /tools/etc/ld.so.conf make install make localedata/install-locales cd .. rm -rf glibc-build rm -rf glibc-2.3.4
cd binutils-build make -C ld install cd .. rm -rf binutils-build rm -rf binutils-2.15.94.0.2.2 SPECFILE=$(gcc --print-file specs) && sed 's@ /lib/ld-linux.so.2@ /tools/lib/ld-linux.so.2@g' $SPECFILE > tempspecfile && mv -f tempspecfile $SPECFILE && unset SPECFILE rm -vf /tools/lib/gcc/*/*/include/{pthread.h,bits/sigthread.h}
tar xvf /lfs-sources/tcl8.4.9-src.tar.bz2 cd tcl8.4.9/unix ./configure --prefix=/tools make make install cd .. export TCLPATH=$(pwd) ln -sv tclsh8.4 /tools/bin/tclsh cd .. tar xvf /lfs-sources/expect-5.43.0.tar.bz2 cd expect-5.43 patch -Np1 -i /lfs-sources/expect-5.43.0-spawn-1.patch ./configure --prefix=/tools --with-tcl=/tools/lib --with-tclinclude=$TCLPATH --with-x=no make make SCRIPTS="" install unset TCLPATH cd .. tar xvf /lfs-sources/dejagnu-1.4.4.tar.bz2 cd dejagnu-1.4.4 ./configure --prefix=/tools make install cd .. rm -rf tcl8.4.9 rm -rf expect-5.43 rm -rf dejagnu-1.4.4
tar xvf /lfs-sources/gcc-3.4.3.tar.bz2 cd gcc-3.4.3 patch -Np1 -i /lfs-sources/gcc-3.4.3-no_fixincludes-1.patch patch -Np1 -i /lfs-sources/gcc-3.4.3-specs-2.patch mkdir -v ../gcc-build cd ../gcc-build ../gcc-3.4.3/configure --prefix=/tools \ --libexecdir=/tools/lib --with-local-prefix=/tools \ --enable-clocale=gnu --enable-shared \ --enable-threads=posix --enable-__cxa_atexit \ --enable-languages=c,c++ --disable-libstdcxx-pch make make install cd .. rm -rf gcc-build rm -rf gcc-3.4.3
tar xvf /lfs-sources/binutils-2.15.94.0.2.2.tar.bz2 mkdir -v binutils-build cd binutils-build ../binutils-2.15.94.0.2.2/configure --prefix=/tools --disable-nls \ --enable-shared --with-lib-path=/tools/lib make make install make -C ld clean make -C ld LIB_PATH=/usr/lib:/lib cd ..
tar xvf /lfs-sources/gawk-3.1.4.tar.bz2 cd gawk-3.1.4 ./configure --prefix=/tools make make install cd .. rm -rf gawk-3.1.4
tar xvf /lfs-sources/coreutils-5.2.1.tar.bz2 cd coreutils-5.2.1 DEFAULT_POSIX2_VERSION=199209 ./configure --prefix=/tools make make install cd .. rm -rf coreutils-5.2.1
tar xvf /lfs-sources/bzip2-1.0.3.tar.bz2 cd bzip2-1.0.3 make make PREFIX=/tools install cd .. rm -rf bzip2-1.0.3
tar xvf /lfs-sources/gzip-1.3.5.tar.bz2 cd gzip-1.3.5 ./configure --prefix=/tools make make install cd .. rm -rf gzip-1.3.5
tar xvf /lfs-sources/diffutils-2.8.1.tar.bz2 cd diffutils-2.8.1 ./configure --prefix=/tools make make install cd .. rm -rf diffutils-2.8.1
tar xvf /lfs-sources/findutils-4.2.23.tar.bz2 cd findutils-4.2.23 ./configure --prefix=/tools make make install cd .. rm -rf findutils-4.2.23
tar xvf /lfs-sources/make-3.80.tar.bz2 cd make-3.80 ./configure --prefix=/tools make make install cd .. rm -rf make-3.80
tar xvf /lfs-sources/grep-2.5.1a.tar.bz2 cd grep-2.5.1a ./configure --prefix=/tools --disable-perl-regexp make make install cd .. rm -rf grep-2.5.1a
tar xvf /lfs-sources/sed-4.1.4.tar.bz2 cd sed-4.1.4 ./configure --prefix=/tools make make install cd .. rm -rf sed-4.1.4
tar xvf /lfs-sources/gettext-0.14.3.tar.bz2 cd gettext-0.14.3 ./configure --prefix=/tools --disable-libasprintf --without-csharp make make install cd .. rm -rf gettext-0.14.3
tar xvf /lfs-sources/ncurses-5.4.tar.bz2 cd ncurses-5.4 ./configure --prefix=/tools --with-shared --without-debug --without-ada --enable-overwrite make make install cd .. rm -rf ncurses-5.4
tar xvf /lfs-sources/patch-2.5.4.tar.bz2 cd patch-2.5.4 CPPFLAGS=-D_GNU_SOURCE ./configure --prefix=/tools make make install cd .. rm -rf patch-2.5.4
tar xvf /lfs-sources/tar-1.15.1.tar.bz2 cd tar-1.15.1 ./configure --prefix=/tools make make install cd .. rm -rf tar-1.15.1
tar xvf /lfs-sources/texinfo-4.8.tar.bz2 cd texinfo-4.8 ./configure --prefix=/tools make make install cd .. rm -rf texinfo-4.8
tar xvf /lfs-sources/bash-3.0.tar.bz2 cd bash-3.0 patch -Np1 -i /lfs-sources/bash-3.0-avoid_WCONTINUED-1.patch ./configure --prefix=/tools --without-bash-malloc make make install ln -vs bash /tools/bin/sh cd .. rm -rf bash-3.0
tar xvf /lfs-sources/m4-1.4.3.tar.bz2 cd m4-1.4.3 ./configure --prefix=/tools make make install cd .. rm -rf m4-1.4.3
tar xvf /lfs-sources/bison-2.0.tar.bz2 cd bison-2.0 ./configure --prefix=/tools make make install cd .. rm -rf bison-2.0
tar xvf /lfs-sources/flex-2.5.31.tar.bz2 cd flex-2.5.31 patch -Np1 -i /lfs-sources/flex-2.5.31-debian_fixes-3.patch touch doc/flex.1 ./configure --prefix=/tools make make install cd .. rm -rf flex-2.5.31
tar xvf /lfs-sources/util-linux-2.12q.tar.bz2 cd util-linux-2.12q sed -i 's@/usr/include@/tools/include@g' configure ./configure make -C lib make -C mount mount umount make -C text-utils more cp mount/{,u}mount text-utils/more /tools/bin cd .. rm -rf util-linux-2.12q
tar xvf /lfs-sources/perl-5.8.7.tar.bz2 cd perl-5.8.7 patch -Np1 -i /lfs-sources/perl-5.8.7-libc-1.patch ./configure.gnu --prefix=/tools -Dstatic_ext='IO Fcntl POSIX' make perl utilities cp -v perl pod/pod2man /tools/bin mkdir -pv /tools/lib/perl5/5.8.7 cp -Rv lib/* /tools/lib/perl5/5.8.7 cd .. rm -rf perl-5.8.7
strip --strip-debug /tools/lib/* strip --strip-unneeded /tools/{,s}bin/*
exit
mkdir -pv $LFS/{proc,sys}
mount -vt proc proc $LFS/proc mount -vt sysfs sysfs $LFS/sys
mount -vft tmpfs tmpfs $LFS/dev mount -vft tmpfs tmpfs $LFS/dev/shm mount -vft devpts -o gid=4,mode=620 devpts $LFS/dev/pts
cp -a /lfs-sources/* $LFS/sources
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
chown -R 0:0 /tools
install -dv /{bin,boot,dev,etc/opt,home,lib,mnt} install -dv /{sbin,srv,usr/local,var,opt} install -dv /root -m 0750 install -dv /tmp /var/tmp -m 1777 install -dv /media/{floppy,cdrom} install -dv /usr/{bin,include,lib,sbin,share,src} ln -sv share/{man,doc,info} /usr install -dv /usr/share/{doc,info,locale,man} install -dv /usr/share/{misc,terminfo,zoneinfo} install -dv /usr/share/man/man{1,2,3,4,5,6,7,8} install -dv /usr/local/{bin,etc,include,lib,sbin,share,src} ln -sv share/{man,doc,info} /usr/local install -dv /usr/local/share/{doc,info,locale,man} install -dv /usr/local/share/{misc,terminfo,zoneinfo} install -dv /usr/local/share/man/man{1,2,3,4,5,6,7,8} install -dv /var/{lock,log,mail,run,spool} install -dv /var/{opt,cache,lib/{misc,locate},local} install -dv /opt/{bin,doc,include,info} install -dv /opt/{lib,man/man{1,2,3,4,5,6,7,8}}
ln -sv /tools/bin/{bash,cat,pwd,stty} /bin ln -sv /tools/bin/perl /usr/bin ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib ln -sv bash /bin/sh
cat > /etc/passwd << "EOF" root:x:0:0:root:/root:/bin/bash 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: 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
mknod -m 600 /dev/console c 5 1 mknod -m 666 /dev/null c 1 3
mount -nvt tmpfs none /dev mknod -m 622 /dev/console c 5 1 mknod -m 666 /dev/null c 1 3 mknod -m 666 /dev/zero c 1 5 mknod -m 666 /dev/ptmx c 5 2 mknod -m 666 /dev/tty c 5 0 mknod -m 444 /dev/random c 1 8 mknod -m 444 /dev/urandom c 1 9 chown -v root:tty /dev/{console,ptmx,tty} ln -sv /proc/self/fd /dev/fd ln -sv /proc/self/fd/0 /dev/stdin ln -sv /proc/self/fd/1 /dev/stdout ln -sv /proc/self/fd/2 /dev/stderr ln -sv /proc/kcore /dev/core mkdir -v /dev/pts mkdir -v /dev/shm mount -vt devpts -o gid=4,mode=620 none /dev/pts mount -vt tmpfs none /dev/shm
cd /sources
export LFS=/sources