LFS的安装脚本
LFS的安装一般有三种常见的方式:1、以现有Linux系统为宿主,下载目标LFS系统软件的源代码包,搭建临时编译编译环境,然后生成目标LFS系统,最后加入GRUB引导项;2、以livecd为宿主,以光盘上自带的源程序包为基础开始编译;3、采用ALFS(jhlfs),可自定义源码包的位置。 基于在Pentium 4 2.4GHz的机器上安装成功的经历,完全按照手册手工输入命令有两个弊
·
LFS的安装一般有三种常见的方式:
1、以现有Linux系统为宿主,下载目标LFS系统软件的源代码包,搭建临时编译编译环境,然后生成目标LFS系统,最后加入GRUB引导项;
2、以livecd为宿主,以光盘上自带的源程序包为基础开始编译;
3、采用ALFS(jhlfs),可自定义源码包的位置。
基于在Pentium 4 2.4GHz的机器上安装成功的经历,完全按照手册手工输入命令有两个弊端:
一是太多,容易疲惫出错;
二是多数时候执行livecd环境中的命令需要读取光盘,而命令之间有大段编译时间光驱又会停转,光驱容易“疲惫”。 尽量把命令集中到若干个脚本文件中,把读取光盘的时机尽量集中,于是整理出下面的脚本。对比jhlfs,这是相当简陋的了,所以下一步就是修改jhlfs,达到上述连个要求。
( 因为最终是要给Celeron级别的笔记本电脑安装,所以不得不以光驱为重-_-| )
------->事先从网上把livecd 抓到/dev/hda6/lfs,以便使用其中的源码包;然后刻盘启动,目标:/dev/hda7,预留3G,swapon /dev/hda8。
-------> 由于命令中使用到exec ....bash.....和chroot这样切换shell环境的命令,因此据此分割为多个脚本文件。
--------> 由于脚本随时可能由于非预期 的失败而暂停等待采取措施纠正后继续,所以最好准备两个console,其中一个用来在脚本暂停时采取措施纠正失败状态,这一点还很不够通用性,尤其是构建临时编译环境时,还需要对GNU toolchain进一步了解。
1、以现有Linux系统为宿主,下载目标LFS系统软件的源代码包,搭建临时编译编译环境,然后生成目标LFS系统,最后加入GRUB引导项;
2、以livecd为宿主,以光盘上自带的源程序包为基础开始编译;
3、采用ALFS(jhlfs),可自定义源码包的位置。
基于在Pentium 4 2.4GHz的机器上安装成功的经历,完全按照手册手工输入命令有两个弊端:
一是太多,容易疲惫出错;
二是多数时候执行livecd环境中的命令需要读取光盘,而命令之间有大段编译时间光驱又会停转,光驱容易“疲惫”。 尽量把命令集中到若干个脚本文件中,把读取光盘的时机尽量集中,于是整理出下面的脚本。对比jhlfs,这是相当简陋的了,所以下一步就是修改jhlfs,达到上述连个要求。
( 因为最终是要给Celeron级别的笔记本电脑安装,所以不得不以光驱为重-_-| )
------->事先从网上把livecd 抓到/dev/hda6/lfs,以便使用其中的源码包;然后刻盘启动,目标:/dev/hda7,预留3G,swapon /dev/hda8。
-------> 由于命令中使用到exec ....bash.....和chroot这样切换shell环境的命令,因此据此分割为多个脚本文件。
--------> 由于脚本随时可能由于非预期 的失败而暂停等待采取措施纠正后继续,所以最好准备两个console,其中一个用来在脚本暂停时采取措施纠正失败状态,这一点还很不够通用性,尤其是构建临时编译环境时,还需要对GNU toolchain进一步了解。
1)pre-env.sh
#
! /bin/bash
###################
## login shell,when " --login" or "sh"
cat > ~/. bash_profile << " EOF "
exec env - i HOME = $HOME TERM = $TERM PS1 = ' u:w$ ' / bin / bash
EOF
# ##################
## non-login shell, when logining X11
cat > ~/. bashrc << " EOF "
set + h
umask 022
LFS =/ mnt / lfs
LC_ALL = POSIX
PATH =/ tools / bin :/ bin :/ usr / bin
export LFS LC_ALL PATH
# ###########
#source $LFS/pre-build
EOF
source ~/. bash_profile
###################
## login shell,when " --login" or "sh"
cat > ~/. bash_profile << " EOF "
exec env - i HOME = $HOME TERM = $TERM PS1 = ' u:w$ ' / bin / bash
EOF
# ##################
## non-login shell, when logining X11
cat > ~/. bashrc << " EOF "
set + h
umask 022
LFS =/ mnt / lfs
LC_ALL = POSIX
PATH =/ tools / bin :/ bin :/ usr / bin
export LFS LC_ALL PATH
# ###########
#source $LFS/pre-build
EOF
source ~/. bash_profile
2)pre-env.sh
#
! /bin/bash
########################## chapter 1-4
export LFS =/ mnt / lfs
mkdir - pv $LFS
mount / dev / hda8 $LFS
swapon / dev / hda2
mkdir - pv $LFS / tools $LFS / sources
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
chmod - v a + wt $LFS / sources
su - lfs
########################## chapter 1-4
export LFS =/ mnt / lfs
mkdir - pv $LFS
mount / dev / hda8 $LFS
swapon / dev / hda2
mkdir - pv $LFS / tools $LFS / sources
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
chmod - v a + wt $LFS / sources
su - lfs
3)pre-build.sh
#
! /bin/bash
cd $LFS / sources
mkdir / mnt / win
mount / dev / hda6 / mnt / win
mkdir / mnt / iso
mount - o loop / mnt / win / lfs / lfslivecd - x86 - 6.1 . 1 - 3 . iso / mnt / iso
export SRC =/ mnt / iso / lfs - sources
uname - a > start . txt
tar xf $SRC / gcc - 3.4 . 3 . tar . bz2
tar xf $SRC / binutils - 2.15 . 94.0 . 2.2 . tar . bz2
tar xf $SRC / linux - libc - headers - 2.6 . 11.2 . tar . bz2
tar xf $SRC / glibc - 2.3 . 4 . tar . bz2
# ######################################## raise a toolchain upon host (livecd)
mkdir - v binutils - build
cd binutils - build
time { ../ binutils - 2.15 . 94.0 . 2.2 / configure -- prefix =/ tools -- disable - nls
&& make && make install ; } && read &&
make - C ld clean &&
make - C ld LIB_PATH =/ tools / lib &&
cd .. || read
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 || read
cd linux - libc - headers - 2.6 . 11.2 &&
cp - Rv include / asm - i386 / tools / include / asm &&
cp - Rv include / linux / tools / include || read
cd ..
cd glibc - 2.3 . 4
patch - Np1 - i $SRC / glibc - 2.3 . 4 - fix_test - 1 . patch
mkdir - v / tools / etc
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 &&
touch / tools / etc / ld . so . conf &&
make install || read
mkdir / tools / lib / locale
localedef - i zh_CN - f GBK zh_CN
localedef - i zh_CN - f GB2312 zh_CN
localedef - i zh_CN - f GB18030 zh_CN
localedef - i zh_CN - f UTF - 8 zh_CN
cd ..
rm - rf glibc - build
rm - rf glibc - 2.3 . 4
# ######################################## adjust toolchain, link to newly libc
cd binutils - build &&
make - C ld install &&
cd .. &&
rm - rf binutils - build &&
rm - rf binutils - 2.15 . 94.0 . 2.2 &&
sed ' s@ /lib/ld-linux.so.2@ /tools/lib/ld-linux.so.2@g '
`gcc -- print - file specs` > tmpspecs &&
mv tmpspecs `gcc -- print - file specs` &&
rm - vf / tools / lib / gcc /*/*/ include / {pthread . h , bits / sigthread . h} &&
echo ' main(){} ' > dummy . c &&
cc dummy . c &&
readelf - l a . out | grep ' : /tools ' || read
# ##################### build the temporary tools ########################
cd $LFS / sources
tar xf $SRC / gcc - 3.4 . 3 . tar . bz2
cd gcc - 3.4 . 3
patch - Np1 < $SRC / gcc - 3.4 . 3 - no_fixincludes - 1 . patch
patch - Np1 < $SRC / 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 || read
cd ..
rm - rf gcc - build
rm - rf gcc - 3.4 . 3
tar xf $SRC / 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 || read
tar xf $SRC / gawk - 3.1 . 4 . tar . bz2
tar xf $SRC / coreutils - 5.2 . 1 . tar . bz2
tar xf $SRC / bzip2 - 1.0 . 3 . tar . bz2
tar xf $SRC / gzip - 1.3 . 5 . tar . bz2
tar xf $SRC / diffutils - 2.8 . 1 . tar . bz2
tar xf $SRC / findutils - 4.2 . 23 . tar . bz2
tar xf $SRC / make - 3.80 . tar . bz2
tar xf $SRC / grep - 2.5 . 1a . tar . bz2
tar xf $SRC / sed - 4.1 . 4 . tar . bz2
tar xf $SRC / gettext - 0.14 . 3 . tar . bz2
tar xf $SRC / ncurses - 5.4 . tar . bz2
tar xf $SRC / patch - 2.5 . 4 . tar . bz2
tar xf $SRC / tar - 1.15 . 1 . tar . bz2
tar xf $SRC / texinfo - 4.8 . tar . bz2
tar xf $SRC / bash - 3.0 . tar . bz2
cd bash - 3.0 /
patch - Np1 < $SRC / bash - 3.0 - avoid_WCONTINUED - 1 . patch
cd ..
tar xf $SRC / m4 - 1.4 . 3 . tar . bz2
tar xf $SRC / bison - 2.0 . tar . bz2
tar xf $SRC / flex - 2.5 . 31 . tar . bz2
cd flex - 2.5 . 31 /
patch - Np1 < $SRC / flex - 2.5 . 31 - debian_fixes - 3 . patch
cd ..
tar xf $SRC / util - linux - 2 . 12q . tar . bz2
tar xf $SRC / perl - 5.8 . 7 . tar . bz2
cd perl - 5.8 . 7 /
patch - Np1 < $SRC / perl - 5.8 . 7 - libc - 1 . patch
cd ..
cd gawk - 3.1 . 4 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf gawk - 3.1 . 4 /
cd coreutils - 5.2 . 1 /
DEFAULT_POSIX2_VERSION = 199209 ./ configure -- prefix =/ tools &&
make && make install || read
cd ..
rm - rf coreutils - 5.2 . 1 /
cd bzip2 - 1.0 . 3 /
make && make PREFIX =/ tools install || read
cd ..
rm - rf bzip2 - 1.0 . 3 /
cd gzip - 1.3 . 5 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf gzip - 1.3 . 5 /
cd diffutils - 2.8 . 1 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf diffutils - 2.8 . 1 /
cd findutils - 4.2 . 23 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf findutils - 4.2 . 23 /
cd make - 3.80 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf make - 3.80 /
cd grep - 2.5 . 1a
./ configure -- prefix =/ tools -- disable - perl - regexp &&
make && make install || read
cd ..
rm - rf grep - 2.5 . 1a
cd sed - 4.1 . 4
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf sed - 4.1 . 4
cd gettext - 0.14 . 3 /
./ configure -- prefix =/ tools -- disable - libasprintf
-- without - csharp && make && make install || read
cd ..
rm - rf gettext - 0.14 . 3 /
cd ncurses - 5.4 /
./ configure -- prefix =/ tools -- with - shared -- without - debug
-- without - ada -- enable - overwrite && make && make install || read
cd ..
rm - rf ncurses - 5.4 /
cd patch - 2.5 . 4 /
CPPFLAGS =- D_GNU_SOURCE ./ configure -- prefix =/ tools &&
make && make install || read
cd ..
rm - rf patch - 2.5 . 4 /
cd tar - 1.15 . 1 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf tar - 1.15 . 1 /
cd texinfo - 4.8 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf texinfo - 4.8 /
cd bash - 3.0 /
./ configure -- prefix =/ tools -- without - bash - malloc &&
make && make install || read
ln - sv bash / tools / bin / sh
cd ..
rm - rf bash - 3.0 /
cd m4 - 1.4 . 3 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf m4 - 1.4 . 3 /
cd bison - 2.0 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf bison - 2.0 /
cd flex - 2.5 . 31 /
touch doc / flex . 1
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf flex - 2.5 . 31 /
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 || read
cp mount / { , u}mount text - utils / more / tools / bin /
cd ..
rm - rf util - linux - 2 . 12q /
cd perl - 5.8 . 7 /
./ 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 || read
cd ..
rm - rf perl - 5.8 . 7
strip -- strip - debug / tools / lib /*
strip -- strip - unneeded / tools / { , s}bin /*
rm - rf / tools / {info , man}
# cp .bash_history /mnt/win/lfs-temp-built.txt
exit
cd $LFS / sources
mkdir / mnt / win
mount / dev / hda6 / mnt / win
mkdir / mnt / iso
mount - o loop / mnt / win / lfs / lfslivecd - x86 - 6.1 . 1 - 3 . iso / mnt / iso
export SRC =/ mnt / iso / lfs - sources
uname - a > start . txt
tar xf $SRC / gcc - 3.4 . 3 . tar . bz2
tar xf $SRC / binutils - 2.15 . 94.0 . 2.2 . tar . bz2
tar xf $SRC / linux - libc - headers - 2.6 . 11.2 . tar . bz2
tar xf $SRC / glibc - 2.3 . 4 . tar . bz2
# ######################################## raise a toolchain upon host (livecd)
mkdir - v binutils - build
cd binutils - build
time { ../ binutils - 2.15 . 94.0 . 2.2 / configure -- prefix =/ tools -- disable - nls
&& make && make install ; } && read &&
make - C ld clean &&
make - C ld LIB_PATH =/ tools / lib &&
cd .. || read
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 || read
cd linux - libc - headers - 2.6 . 11.2 &&
cp - Rv include / asm - i386 / tools / include / asm &&
cp - Rv include / linux / tools / include || read
cd ..
cd glibc - 2.3 . 4
patch - Np1 - i $SRC / glibc - 2.3 . 4 - fix_test - 1 . patch
mkdir - v / tools / etc
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 &&
touch / tools / etc / ld . so . conf &&
make install || read
mkdir / tools / lib / locale
localedef - i zh_CN - f GBK zh_CN
localedef - i zh_CN - f GB2312 zh_CN
localedef - i zh_CN - f GB18030 zh_CN
localedef - i zh_CN - f UTF - 8 zh_CN
cd ..
rm - rf glibc - build
rm - rf glibc - 2.3 . 4
# ######################################## adjust toolchain, link to newly libc
cd binutils - build &&
make - C ld install &&
cd .. &&
rm - rf binutils - build &&
rm - rf binutils - 2.15 . 94.0 . 2.2 &&
sed ' s@ /lib/ld-linux.so.2@ /tools/lib/ld-linux.so.2@g '
`gcc -- print - file specs` > tmpspecs &&
mv tmpspecs `gcc -- print - file specs` &&
rm - vf / tools / lib / gcc /*/*/ include / {pthread . h , bits / sigthread . h} &&
echo ' main(){} ' > dummy . c &&
cc dummy . c &&
readelf - l a . out | grep ' : /tools ' || read
# ##################### build the temporary tools ########################
cd $LFS / sources
tar xf $SRC / gcc - 3.4 . 3 . tar . bz2
cd gcc - 3.4 . 3
patch - Np1 < $SRC / gcc - 3.4 . 3 - no_fixincludes - 1 . patch
patch - Np1 < $SRC / 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 || read
cd ..
rm - rf gcc - build
rm - rf gcc - 3.4 . 3
tar xf $SRC / 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 || read
tar xf $SRC / gawk - 3.1 . 4 . tar . bz2
tar xf $SRC / coreutils - 5.2 . 1 . tar . bz2
tar xf $SRC / bzip2 - 1.0 . 3 . tar . bz2
tar xf $SRC / gzip - 1.3 . 5 . tar . bz2
tar xf $SRC / diffutils - 2.8 . 1 . tar . bz2
tar xf $SRC / findutils - 4.2 . 23 . tar . bz2
tar xf $SRC / make - 3.80 . tar . bz2
tar xf $SRC / grep - 2.5 . 1a . tar . bz2
tar xf $SRC / sed - 4.1 . 4 . tar . bz2
tar xf $SRC / gettext - 0.14 . 3 . tar . bz2
tar xf $SRC / ncurses - 5.4 . tar . bz2
tar xf $SRC / patch - 2.5 . 4 . tar . bz2
tar xf $SRC / tar - 1.15 . 1 . tar . bz2
tar xf $SRC / texinfo - 4.8 . tar . bz2
tar xf $SRC / bash - 3.0 . tar . bz2
cd bash - 3.0 /
patch - Np1 < $SRC / bash - 3.0 - avoid_WCONTINUED - 1 . patch
cd ..
tar xf $SRC / m4 - 1.4 . 3 . tar . bz2
tar xf $SRC / bison - 2.0 . tar . bz2
tar xf $SRC / flex - 2.5 . 31 . tar . bz2
cd flex - 2.5 . 31 /
patch - Np1 < $SRC / flex - 2.5 . 31 - debian_fixes - 3 . patch
cd ..
tar xf $SRC / util - linux - 2 . 12q . tar . bz2
tar xf $SRC / perl - 5.8 . 7 . tar . bz2
cd perl - 5.8 . 7 /
patch - Np1 < $SRC / perl - 5.8 . 7 - libc - 1 . patch
cd ..
cd gawk - 3.1 . 4 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf gawk - 3.1 . 4 /
cd coreutils - 5.2 . 1 /
DEFAULT_POSIX2_VERSION = 199209 ./ configure -- prefix =/ tools &&
make && make install || read
cd ..
rm - rf coreutils - 5.2 . 1 /
cd bzip2 - 1.0 . 3 /
make && make PREFIX =/ tools install || read
cd ..
rm - rf bzip2 - 1.0 . 3 /
cd gzip - 1.3 . 5 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf gzip - 1.3 . 5 /
cd diffutils - 2.8 . 1 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf diffutils - 2.8 . 1 /
cd findutils - 4.2 . 23 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf findutils - 4.2 . 23 /
cd make - 3.80 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf make - 3.80 /
cd grep - 2.5 . 1a
./ configure -- prefix =/ tools -- disable - perl - regexp &&
make && make install || read
cd ..
rm - rf grep - 2.5 . 1a
cd sed - 4.1 . 4
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf sed - 4.1 . 4
cd gettext - 0.14 . 3 /
./ configure -- prefix =/ tools -- disable - libasprintf
-- without - csharp && make && make install || read
cd ..
rm - rf gettext - 0.14 . 3 /
cd ncurses - 5.4 /
./ configure -- prefix =/ tools -- with - shared -- without - debug
-- without - ada -- enable - overwrite && make && make install || read
cd ..
rm - rf ncurses - 5.4 /
cd patch - 2.5 . 4 /
CPPFLAGS =- D_GNU_SOURCE ./ configure -- prefix =/ tools &&
make && make install || read
cd ..
rm - rf patch - 2.5 . 4 /
cd tar - 1.15 . 1 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf tar - 1.15 . 1 /
cd texinfo - 4.8 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf texinfo - 4.8 /
cd bash - 3.0 /
./ configure -- prefix =/ tools -- without - bash - malloc &&
make && make install || read
ln - sv bash / tools / bin / sh
cd ..
rm - rf bash - 3.0 /
cd m4 - 1.4 . 3 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf m4 - 1.4 . 3 /
cd bison - 2.0 /
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf bison - 2.0 /
cd flex - 2.5 . 31 /
touch doc / flex . 1
./ configure -- prefix =/ tools && make && make install || read
cd ..
rm - rf flex - 2.5 . 31 /
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 || read
cp mount / { , u}mount text - utils / more / tools / bin /
cd ..
rm - rf util - linux - 2 . 12q /
cd perl - 5.8 . 7 /
./ 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 || read
cd ..
rm - rf perl - 5.8 . 7
strip -- strip - debug / tools / lib /*
strip -- strip - unneeded / tools / { , s}bin /*
rm - rf / tools / {info , man}
# cp .bash_history /mnt/win/lfs-temp-built.txt
exit
4)chroot-to-temp.sh
#
! /bin/bash
export LFS =/ mnt / lfs
mkdir - pv $LFS
mount / dev / hda8 $LFS
swapon / dev / hda2
ln - sv $LFS / tools /
mount - vt proc proc $LFS / proc
mount - vt sysfs sysfs $LFS / sys
cp / 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
/ bin / bash -- login + h
export LFS =/ mnt / lfs
mkdir - pv $LFS
mount / dev / hda8 $LFS
swapon / dev / hda2
ln - sv $LFS / tools /
mount - vt proc proc $LFS / proc
mount - vt sysfs sysfs $LFS / sys
cp / 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
/ bin / bash -- login + h
5)temp-env.sh
#
! /bin/bash
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
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
6)target-build.sh
#
! /bin/bash
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
# ############### target environment build #################
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
# ################ build target toolchain ########################
cp - Rv include / asm - i386 / usr / include / asm &&
cp - Rv include / linux / usr / include &&
chown - Rv root : root / usr / include / {asm , linux} &&
find / usr / include / {asm , linux} - type d - exec chmod - v 755 {} ; &&
find / usr / include / {asm , linux} - type f - exec chmod - v 644 {} ; &&
cd .. &&
rm - rf linux - libc - headers - 2.6 . 11.2 || read
tar xf $LFS / man - pages - 2.01 . tar . bz2 &&
cd man - pages - 2.01 &&
make install &&
cd .. &&
rm - rf man - pages - 2.01 || read
tar xf $LFS / glibc - 2.3 . 4 . tar . bz2 &&
cd glibc - 2.3 . 4 &&
tar - xjf $LFS / glibc - linuxthreads - 2.3 . 4 . tar . bz2
patch - Np1 < $LFS / glibc - 2.3 . 4 - rtld_search_dirs - 1 . patch
patch - Np1 < $LFS / glibc - 2.3 . 4 - fix_test - 1 . patch
patch - Np1 < $LFS / glibc - 2.3 . 4 - tls_assert - 1 . patch
mkdir - v ../ glibc - build
cd ../ glibc - build &&
../ glibc - 2.3 . 4 / configure -- prefix =/ usr
-- disable - profile -- enable - add - ons
-- enable - kernel = 2.6 . 0 -- libexecdir =/ usr / lib / glibc &&
make &&
touch / etc / ld . so . conf &&
make install || read
mkdir - pv / usr / lib / locale
localedef - i de_DE - f ISO - 8859 - 1 de_DE
localedef - i de_DE @euro - f ISO - 8859 - 15 de_DE @euro
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 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 it_IT - f ISO - 8859 - 1 it_IT
localedef - i ja_JP - f EUC - JP ja_JP
make - C ../ glibc - 2.3 . 4 / linuxthreads / man &&
make - C ../ glibc - 2.3 . 4 / linuxthreads / man install || read
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
cp - v -- remove - destination / usr / share / zoneinfo / Asia / Shanghai / etc / localtime
cat > / etc / ld . so . conf << " EOF "
/ usr / local / lib
/ opt / lib
EOF
cd ..
rm - rf glibc - build
rm - rf glibc - 2.3 . 4
# ############################ re-adjust toolchain, link to target lib
cd binutils - build
make - C ld clean &&
make - C ld LIB_PATH =/ usr / lib :/ lib &&
make - C ld INSTALL =/ tools / bin / install install || read
cd ..
rm - rf binutils - build
rm - rf binutils - 2.15 . 94.0 . 2.2
perl - pi - e ' s@ /tools/lib/ld-linux.so.2@ /lib/ld-linux.so.2@g; '
- e ' s@*startfile_prefix_spec: @$_/usr/lib/ @g; '
$(gcc -- print - file specs) &&
echo ' main(){} ' > dummy . c &&
cc dummy . c &&
readelf - l a . out | grep ' : /lib ' || (echo " >>>at:target-binutils test " ; read )
rm - v dummy . c a . out
# ################## build target environment include toolchain ###############
tar xf $LFS / binutils - 2.15 . 94.0 . 2.2 . tar . bz2
mkdir binutils - build
cd binutils - build
../ binutils - 2.15 . 94.0 . 2.2 / configure -- prefix =/ usr -- enable - shared &&
make tooldir =/ usr &&
make check &&
make tooldir =/ usr install &&
cp - v ../ binutils - 2.15 . 94.0 . 2.2 / include / libiberty . h / usr / include || read
cd ..
rm - rf binutils - build
rm - rf binutils - 2.15 . 94.0 . 2.2
tar xf $LFS / gcc - 3.4 . 3 . tar . bz2
cd gcc - 3.4 . 3
patch - Np1 < $LFS / gcc - 3.4 . 3 - no_fixincludes - 1 . patch
patch - Np1 < $LFS / gcc - 3.4 . 3 - linkonce - 1 . patch
sed - i ' s/install_to_$(INSTALL_DEST) // ' libiberty / Makefile . in &&
mkdir - v ../ gcc - build &&
cd ../ gcc - build &&
../ gcc - 3.4 . 3 / configure -- prefix =/ usr
-- libexecdir =/ usr / lib -- enable - shared
-- enable - threads = posix -- enable - __cxa_atexit
-- enable - clocale = gnu -- enable - languages = c , c ++ &&
make &&
# make -k check
#read
make install &&
ln - sv ../ usr / bin / cpp / lib &&
ln - sv gcc / usr / bin / cc || read
cd ..
rm - rf gcc - build
rm - rf gcc - 3.4 . 3
tar xf $LFS / coreutils - 5.2 . 1 . tar . bz2
cd coreutils - 5.2 . 1
patch - Np1 - i $LFS / coreutils - 5.2 . 1 - uname - 2 . patch
patch - Np1 - i $LFS / coreutils - 5.2 . 1 - suppress_uptime_kill_su - 1 . patch
DEFAULT_POSIX2_VERSION = 199209 ./ configure -- prefix =/ usr &&
make &&
(echo " dummy1:x:1000: " >> / etc / group
echo " dummy2:x:1001:dummy " >> / etc / group
echo " dummy:x:1000:1000:::/bin/bash " >> / etc / passwd) &&
make NON_ROOT_USERNAME = dummy check - root &&
(echo " ***after check-root coreutils*** " ; read ) &&
src / su dummy - c " make RUN_EXPENSIVE_TESTS=yes check " &&
(echo " ***after su check coreutils*** " ; read ) &&
sed - i ' /dummy/d ' / etc / passwd / etc / group &&
make install &&
mv - v / usr / bin / {cat , chgrp , chmod , chown , cp , date , dd , df , echo} / bin &&
mv - v / usr / bin / {false , hostname , 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 } / bin || (echo " ***coreutils*** " ; read )
cd ..
rm - rf coreutils - 5.2 . 1
tar xf $LFS / zlib - 1.2 . 3 . tar . bz2
cd zlib - 1.2 . 3
./ configure -- prefix =/ usr -- shared -- libdir =/ lib &&
make &&
make check &&
make install &&
rm - v / lib / libz . so &&
ln - sfv ../../ lib / libz . so . 1.2 . 3 / usr / lib / libz . so &&
make clean &&
./ configure -- prefix =/ usr &&
make &&
make check &&
# read
make install &&
chmod - v 644 / usr / lib / libz . a || (echo " ***zlib*** " ; read )
cd ..
rm - rf zlib - 1.2 . 3
tar xf $LFS / mktemp - 1.5 . tar . bz2
cd mktemp - 1.5
patch - Np1 - i $LFS / mktemp - 1.5 - add_tempfile - 2 . patch &&
./ configure -- prefix =/ usr -- with - libc &&
make &&
make install &&
make install - tempfile || (echo " ***mktemp*** " ; read )
cd ..
rm - rf mktemp - 1.5
tar xf $LFS / iana - etc - 1.04 . tar . bz2
cd iana - etc - 1.04
make &&
make install || read
cd ..
rm - rf iana - etc - 1.04
tar xf $LFS / findutils - 4.2 . 23 . tar . bz2
cd findutils - 4.2 . 23 &&
./ configure -- prefix =/ usr -- libexecdir =/ usr / lib / locate
-- localstatedir =/ var / lib / locate &&
make &&
make check &&
make install || read
cd ..
rm - rf findutils - 4.2 . 23
(tar xf $LFS / gawk - 3.1 . 4 . tar . bz2 &&
cd gawk - 3.1 . 4 &&
./ configure -- prefix =/ usr -- libexecdir =/ usr / lib &&
make &&
make check &&
make install ) || read
cd ..
rm - rf gawk - 3.1 . 4
tar xf $LFS / ncurses - 5.4 . tar . bz2
cd ncurses - 5.4 &&
./ configure -- prefix =/ usr -- with - shared -- without - debug &&
make &&
make install &&
chmod - v 755 / usr / lib /*. 5.4 &&
chmod - v 644 / usr / lib / libncurses ++. a &&
mv - v / usr / lib / libncurses . so . 5 * / lib &&
ln - sfv ../../ lib / libncurses . so . 5 / usr / lib / libncurses . so &&
ln - sfv libncurses . so / usr / lib / libcurses . so || read
cd ..
rm - rf ncurses - 5.4
tar xf $LFS / readline - 5.0 . tar . bz2
cd readline - 5.0 &&
patch - Np1 - i $LFS / readline - 5.0 - fixes - 1 . patch &&
./ configure -- prefix =/ usr -- libdir =/ lib &&
make SHLIB_XLDFLAGS =- lncurses &&
make install &&
chmod - v 755 / lib / lib{ readline , history} . so * &&
mv - v / lib / lib{ readline , history} . a / usr / lib &&
rm - v / lib / lib{ readline , history} . so &&
ln - sfv ../../ lib / libreadline . so . 5 / usr / lib / libreadline . so &&
ln - sfv ../../ lib / libhistory . so . 5 / usr / lib / libhistory . so || read
cd ..
rm - rf readline - 5.0
tar xf $LFS / vim - 6.3 . tar . bz2
tar xf $LFS / vim - 6.3 - lang . tar . bz2 &&
cd vim63 &&
echo ' #define SYS_VIMRC_FILE "/etc/vimrc" ' >> src / feature . h &&
patch - Np1 - i $LFS / vim - 6.3 - security_fix - 2 . patch &&
./ configure -- prefix =/ usr -- enable - multibyte &&
make &&
make test &&
# echo "***after test vim***";read
make install &&
ln - sv vim / usr / bin / vi || read
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
cd ..
rm - rf vim63
(tar xf $LFS / m4 - 1.4 . 3 . tar . bz2 &&
cd m4 - 1.4 . 3 &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install ) || read
cd ..
rm - rf m4 - 1.4 . 3
tar xf $LFS / bison - 2.0 . tar . bz2
cd bison - 2.0 &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install || read
cd ..
rm - rf bison - 2.0
tar xf $LFS / less - 382 . tar . bz2
cd less - 382 &&
./ configure -- prefix =/ usr -- bindir =/ bin -- sysconfdir =/ etc &&
make &&
make install || read
cd ..
rm - rf less - 382
tar xf $LFS / groff - 1.19 . 1 . tar . bz2
cd groff - 1.19 . 1 &&
PAGE = A4 ./ configure -- prefix =/ usr &&
make &&
make install &&
ln - sv soelim / usr / bin / zsoelim &&
ln - sv eqn / usr / bin / geqn &&
ln - sv tbl / usr / bin / gtbl) || read
cd ..
rm - rf groff - 1.19 . 1
(tar xf $LFS / sed - 4.1 . 4 . tar . bz2 &&
cd sed - 4.1 . 4 &&
sed - i ' s@/doc@&/sed-4.1.4@ ' doc / Makefile . in &&
./ configure -- prefix =/ usr -- bindir =/ bin &&
make &&
make check &&
make install || read
cd ..
rm - rf sed - 4.1 . 4
tar xf $LFS / flex - 2.5 . 31 . tar . bz2
cd flex - 2.5 . 31
patch - Np1 - i $LFS / flex - 2.5 . 31 - debian_fixes - 3 . patch &&
touch doc / flex . 1 &&
./ configure -- prefix =/ usr &&
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 || read
cd ..
rm - rf flex - 2.5 . 31
tar xf $LFS / gettext - 0.14 . 3 . tar . bz2
cd gettext - 0.14 . 3 &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install || read
cd ..
rm - rf gettext - 0.14 . 3
tar xf $LFS / inetutils - 1.4 . 2 . tar . bz2
cd inetutils - 1.4 . 2 &&
patch - Np1 - i $LFS / inetutils - 1.4 . 2 - kernel_headers - 1 . patch &&
patch - Np1 - i $LFS / inetutils - 1.4 . 2 - no_server_man_pages - 1 . patch &&
./ configure -- prefix =/ usr -- libexecdir =/ usr / sbin
-- sysconfdir =/ etc -- localstatedir =/ var
-- disable - logger -- disable - syslogd
-- disable - whois -- disable - servers &&
make &&
make install &&
mv - v / usr / bin / ping / bin || read
cd ..
rm - rf inetutils - 1.4 . 2
tar xf $LFS / iproute2 - 2.6 . 11 - 050330 . tar . bz2
cd iproute2 - 2.6 . 11 &&
sed - i ' /^TARGETS/s@arpd@@g ' misc / Makefile &&
./ configure &&
make SBINDIR =/ sbin &&
make SBINDIR =/ sbin install || read
cd ..
rm - rf iproute2 - 2.6 . 11
tar xf $LFS / perl - 5.8 . 7 . tar . bz2
cd perl - 5.8 . 7 &&
./ configure . gnu -- prefix =/ usr - Dpager = " /bin/less -isR " &&
make &&
echo " 127.0.0.1 localhost $(hostname) " > / etc / hosts &&
make test
echo " ***after test perl*** " ; read
make install || read
cd ..
rm - rf perl - 5.8 . 7
tar xf $LFS / texinfo - 4.8 . tar . bz2
cd texinfo - 4.8 &&
patch - Np1 - i $LFS / texinfo - 4.8 - tempfile_fix - 1 . patch &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install &&
make TEXMF =/ usr / share / texmf install - tex &&
cd / usr / share / info &&
rm dir &&
for f in *
do install - info $f dir 2 >/ dev / null
done &&
cd / sources &&
rm - rf texinfo - 4.8 || read
tar xf $LFS / autoconf - 2.59 . tar . bz2
cd autoconf - 2.59 &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install ) || read
cd ..
rm - rf autoconf - 2.59
tar xf $LFS / automake - 1.9 . 5 . tar . bz2
cd automake - 1.9 . 5 &&
./ configure -- prefix =/ usr &&
make &&
make check
echo " ***after check automake*** " ; read
make install || read
cd ..
rm - rf automake - 1.9 . 5
tar xf $LFS / bash - 3.0 . tar . bz2
cd bash - 3.0
tar xf $LFS / bash - doc - 3.0 . tar . bz2
sed - i " s|htmldir = @htmldir@|htmldir = /usr/share/doc/bash-3.0| " Makefile . in &&
patch - Np1 - i $LFS / bash - 3.0 - fixes - 3 . patch &&
patch - Np1 - i $LFS / bash - 3.0 - avoid_WCONTINUED - 1 . patch &&
./ configure -- prefix =/ usr -- bindir =/ bin -- without - bash - malloc -- with - installed - readline &&
make &&
make check &&
make install || read
cd ..
rm - rf bash - 3.0
exec / 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
# ############### target environment build #################
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
# ################ build target toolchain ########################
cp - Rv include / asm - i386 / usr / include / asm &&
cp - Rv include / linux / usr / include &&
chown - Rv root : root / usr / include / {asm , linux} &&
find / usr / include / {asm , linux} - type d - exec chmod - v 755 {} ; &&
find / usr / include / {asm , linux} - type f - exec chmod - v 644 {} ; &&
cd .. &&
rm - rf linux - libc - headers - 2.6 . 11.2 || read
tar xf $LFS / man - pages - 2.01 . tar . bz2 &&
cd man - pages - 2.01 &&
make install &&
cd .. &&
rm - rf man - pages - 2.01 || read
tar xf $LFS / glibc - 2.3 . 4 . tar . bz2 &&
cd glibc - 2.3 . 4 &&
tar - xjf $LFS / glibc - linuxthreads - 2.3 . 4 . tar . bz2
patch - Np1 < $LFS / glibc - 2.3 . 4 - rtld_search_dirs - 1 . patch
patch - Np1 < $LFS / glibc - 2.3 . 4 - fix_test - 1 . patch
patch - Np1 < $LFS / glibc - 2.3 . 4 - tls_assert - 1 . patch
mkdir - v ../ glibc - build
cd ../ glibc - build &&
../ glibc - 2.3 . 4 / configure -- prefix =/ usr
-- disable - profile -- enable - add - ons
-- enable - kernel = 2.6 . 0 -- libexecdir =/ usr / lib / glibc &&
make &&
touch / etc / ld . so . conf &&
make install || read
mkdir - pv / usr / lib / locale
localedef - i de_DE - f ISO - 8859 - 1 de_DE
localedef - i de_DE @euro - f ISO - 8859 - 15 de_DE @euro
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 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 it_IT - f ISO - 8859 - 1 it_IT
localedef - i ja_JP - f EUC - JP ja_JP
make - C ../ glibc - 2.3 . 4 / linuxthreads / man &&
make - C ../ glibc - 2.3 . 4 / linuxthreads / man install || read
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
cp - v -- remove - destination / usr / share / zoneinfo / Asia / Shanghai / etc / localtime
cat > / etc / ld . so . conf << " EOF "
/ usr / local / lib
/ opt / lib
EOF
cd ..
rm - rf glibc - build
rm - rf glibc - 2.3 . 4
# ############################ re-adjust toolchain, link to target lib
cd binutils - build
make - C ld clean &&
make - C ld LIB_PATH =/ usr / lib :/ lib &&
make - C ld INSTALL =/ tools / bin / install install || read
cd ..
rm - rf binutils - build
rm - rf binutils - 2.15 . 94.0 . 2.2
perl - pi - e ' s@ /tools/lib/ld-linux.so.2@ /lib/ld-linux.so.2@g; '
- e ' s@*startfile_prefix_spec: @$_/usr/lib/ @g; '
$(gcc -- print - file specs) &&
echo ' main(){} ' > dummy . c &&
cc dummy . c &&
readelf - l a . out | grep ' : /lib ' || (echo " >>>at:target-binutils test " ; read )
rm - v dummy . c a . out
# ################## build target environment include toolchain ###############
tar xf $LFS / binutils - 2.15 . 94.0 . 2.2 . tar . bz2
mkdir binutils - build
cd binutils - build
../ binutils - 2.15 . 94.0 . 2.2 / configure -- prefix =/ usr -- enable - shared &&
make tooldir =/ usr &&
make check &&
make tooldir =/ usr install &&
cp - v ../ binutils - 2.15 . 94.0 . 2.2 / include / libiberty . h / usr / include || read
cd ..
rm - rf binutils - build
rm - rf binutils - 2.15 . 94.0 . 2.2
tar xf $LFS / gcc - 3.4 . 3 . tar . bz2
cd gcc - 3.4 . 3
patch - Np1 < $LFS / gcc - 3.4 . 3 - no_fixincludes - 1 . patch
patch - Np1 < $LFS / gcc - 3.4 . 3 - linkonce - 1 . patch
sed - i ' s/install_to_$(INSTALL_DEST) // ' libiberty / Makefile . in &&
mkdir - v ../ gcc - build &&
cd ../ gcc - build &&
../ gcc - 3.4 . 3 / configure -- prefix =/ usr
-- libexecdir =/ usr / lib -- enable - shared
-- enable - threads = posix -- enable - __cxa_atexit
-- enable - clocale = gnu -- enable - languages = c , c ++ &&
make &&
# make -k check
#read
make install &&
ln - sv ../ usr / bin / cpp / lib &&
ln - sv gcc / usr / bin / cc || read
cd ..
rm - rf gcc - build
rm - rf gcc - 3.4 . 3
tar xf $LFS / coreutils - 5.2 . 1 . tar . bz2
cd coreutils - 5.2 . 1
patch - Np1 - i $LFS / coreutils - 5.2 . 1 - uname - 2 . patch
patch - Np1 - i $LFS / coreutils - 5.2 . 1 - suppress_uptime_kill_su - 1 . patch
DEFAULT_POSIX2_VERSION = 199209 ./ configure -- prefix =/ usr &&
make &&
(echo " dummy1:x:1000: " >> / etc / group
echo " dummy2:x:1001:dummy " >> / etc / group
echo " dummy:x:1000:1000:::/bin/bash " >> / etc / passwd) &&
make NON_ROOT_USERNAME = dummy check - root &&
(echo " ***after check-root coreutils*** " ; read ) &&
src / su dummy - c " make RUN_EXPENSIVE_TESTS=yes check " &&
(echo " ***after su check coreutils*** " ; read ) &&
sed - i ' /dummy/d ' / etc / passwd / etc / group &&
make install &&
mv - v / usr / bin / {cat , chgrp , chmod , chown , cp , date , dd , df , echo} / bin &&
mv - v / usr / bin / {false , hostname , 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 } / bin || (echo " ***coreutils*** " ; read )
cd ..
rm - rf coreutils - 5.2 . 1
tar xf $LFS / zlib - 1.2 . 3 . tar . bz2
cd zlib - 1.2 . 3
./ configure -- prefix =/ usr -- shared -- libdir =/ lib &&
make &&
make check &&
make install &&
rm - v / lib / libz . so &&
ln - sfv ../../ lib / libz . so . 1.2 . 3 / usr / lib / libz . so &&
make clean &&
./ configure -- prefix =/ usr &&
make &&
make check &&
# read
make install &&
chmod - v 644 / usr / lib / libz . a || (echo " ***zlib*** " ; read )
cd ..
rm - rf zlib - 1.2 . 3
tar xf $LFS / mktemp - 1.5 . tar . bz2
cd mktemp - 1.5
patch - Np1 - i $LFS / mktemp - 1.5 - add_tempfile - 2 . patch &&
./ configure -- prefix =/ usr -- with - libc &&
make &&
make install &&
make install - tempfile || (echo " ***mktemp*** " ; read )
cd ..
rm - rf mktemp - 1.5
tar xf $LFS / iana - etc - 1.04 . tar . bz2
cd iana - etc - 1.04
make &&
make install || read
cd ..
rm - rf iana - etc - 1.04
tar xf $LFS / findutils - 4.2 . 23 . tar . bz2
cd findutils - 4.2 . 23 &&
./ configure -- prefix =/ usr -- libexecdir =/ usr / lib / locate
-- localstatedir =/ var / lib / locate &&
make &&
make check &&
make install || read
cd ..
rm - rf findutils - 4.2 . 23
(tar xf $LFS / gawk - 3.1 . 4 . tar . bz2 &&
cd gawk - 3.1 . 4 &&
./ configure -- prefix =/ usr -- libexecdir =/ usr / lib &&
make &&
make check &&
make install ) || read
cd ..
rm - rf gawk - 3.1 . 4
tar xf $LFS / ncurses - 5.4 . tar . bz2
cd ncurses - 5.4 &&
./ configure -- prefix =/ usr -- with - shared -- without - debug &&
make &&
make install &&
chmod - v 755 / usr / lib /*. 5.4 &&
chmod - v 644 / usr / lib / libncurses ++. a &&
mv - v / usr / lib / libncurses . so . 5 * / lib &&
ln - sfv ../../ lib / libncurses . so . 5 / usr / lib / libncurses . so &&
ln - sfv libncurses . so / usr / lib / libcurses . so || read
cd ..
rm - rf ncurses - 5.4
tar xf $LFS / readline - 5.0 . tar . bz2
cd readline - 5.0 &&
patch - Np1 - i $LFS / readline - 5.0 - fixes - 1 . patch &&
./ configure -- prefix =/ usr -- libdir =/ lib &&
make SHLIB_XLDFLAGS =- lncurses &&
make install &&
chmod - v 755 / lib / lib{ readline , history} . so * &&
mv - v / lib / lib{ readline , history} . a / usr / lib &&
rm - v / lib / lib{ readline , history} . so &&
ln - sfv ../../ lib / libreadline . so . 5 / usr / lib / libreadline . so &&
ln - sfv ../../ lib / libhistory . so . 5 / usr / lib / libhistory . so || read
cd ..
rm - rf readline - 5.0
tar xf $LFS / vim - 6.3 . tar . bz2
tar xf $LFS / vim - 6.3 - lang . tar . bz2 &&
cd vim63 &&
echo ' #define SYS_VIMRC_FILE "/etc/vimrc" ' >> src / feature . h &&
patch - Np1 - i $LFS / vim - 6.3 - security_fix - 2 . patch &&
./ configure -- prefix =/ usr -- enable - multibyte &&
make &&
make test &&
# echo "***after test vim***";read
make install &&
ln - sv vim / usr / bin / vi || read
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
cd ..
rm - rf vim63
(tar xf $LFS / m4 - 1.4 . 3 . tar . bz2 &&
cd m4 - 1.4 . 3 &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install ) || read
cd ..
rm - rf m4 - 1.4 . 3
tar xf $LFS / bison - 2.0 . tar . bz2
cd bison - 2.0 &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install || read
cd ..
rm - rf bison - 2.0
tar xf $LFS / less - 382 . tar . bz2
cd less - 382 &&
./ configure -- prefix =/ usr -- bindir =/ bin -- sysconfdir =/ etc &&
make &&
make install || read
cd ..
rm - rf less - 382
tar xf $LFS / groff - 1.19 . 1 . tar . bz2
cd groff - 1.19 . 1 &&
PAGE = A4 ./ configure -- prefix =/ usr &&
make &&
make install &&
ln - sv soelim / usr / bin / zsoelim &&
ln - sv eqn / usr / bin / geqn &&
ln - sv tbl / usr / bin / gtbl) || read
cd ..
rm - rf groff - 1.19 . 1
(tar xf $LFS / sed - 4.1 . 4 . tar . bz2 &&
cd sed - 4.1 . 4 &&
sed - i ' s@/doc@&/sed-4.1.4@ ' doc / Makefile . in &&
./ configure -- prefix =/ usr -- bindir =/ bin &&
make &&
make check &&
make install || read
cd ..
rm - rf sed - 4.1 . 4
tar xf $LFS / flex - 2.5 . 31 . tar . bz2
cd flex - 2.5 . 31
patch - Np1 - i $LFS / flex - 2.5 . 31 - debian_fixes - 3 . patch &&
touch doc / flex . 1 &&
./ configure -- prefix =/ usr &&
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 || read
cd ..
rm - rf flex - 2.5 . 31
tar xf $LFS / gettext - 0.14 . 3 . tar . bz2
cd gettext - 0.14 . 3 &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install || read
cd ..
rm - rf gettext - 0.14 . 3
tar xf $LFS / inetutils - 1.4 . 2 . tar . bz2
cd inetutils - 1.4 . 2 &&
patch - Np1 - i $LFS / inetutils - 1.4 . 2 - kernel_headers - 1 . patch &&
patch - Np1 - i $LFS / inetutils - 1.4 . 2 - no_server_man_pages - 1 . patch &&
./ configure -- prefix =/ usr -- libexecdir =/ usr / sbin
-- sysconfdir =/ etc -- localstatedir =/ var
-- disable - logger -- disable - syslogd
-- disable - whois -- disable - servers &&
make &&
make install &&
mv - v / usr / bin / ping / bin || read
cd ..
rm - rf inetutils - 1.4 . 2
tar xf $LFS / iproute2 - 2.6 . 11 - 050330 . tar . bz2
cd iproute2 - 2.6 . 11 &&
sed - i ' /^TARGETS/s@arpd@@g ' misc / Makefile &&
./ configure &&
make SBINDIR =/ sbin &&
make SBINDIR =/ sbin install || read
cd ..
rm - rf iproute2 - 2.6 . 11
tar xf $LFS / perl - 5.8 . 7 . tar . bz2
cd perl - 5.8 . 7 &&
./ configure . gnu -- prefix =/ usr - Dpager = " /bin/less -isR " &&
make &&
echo " 127.0.0.1 localhost $(hostname) " > / etc / hosts &&
make test
echo " ***after test perl*** " ; read
make install || read
cd ..
rm - rf perl - 5.8 . 7
tar xf $LFS / texinfo - 4.8 . tar . bz2
cd texinfo - 4.8 &&
patch - Np1 - i $LFS / texinfo - 4.8 - tempfile_fix - 1 . patch &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install &&
make TEXMF =/ usr / share / texmf install - tex &&
cd / usr / share / info &&
rm dir &&
for f in *
do install - info $f dir 2 >/ dev / null
done &&
cd / sources &&
rm - rf texinfo - 4.8 || read
tar xf $LFS / autoconf - 2.59 . tar . bz2
cd autoconf - 2.59 &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install ) || read
cd ..
rm - rf autoconf - 2.59
tar xf $LFS / automake - 1.9 . 5 . tar . bz2
cd automake - 1.9 . 5 &&
./ configure -- prefix =/ usr &&
make &&
make check
echo " ***after check automake*** " ; read
make install || read
cd ..
rm - rf automake - 1.9 . 5
tar xf $LFS / bash - 3.0 . tar . bz2
cd bash - 3.0
tar xf $LFS / bash - doc - 3.0 . tar . bz2
sed - i " s|htmldir = @htmldir@|htmldir = /usr/share/doc/bash-3.0| " Makefile . in &&
patch - Np1 - i $LFS / bash - 3.0 - fixes - 3 . patch &&
patch - Np1 - i $LFS / bash - 3.0 - avoid_WCONTINUED - 1 . patch &&
./ configure -- prefix =/ usr -- bindir =/ bin -- without - bash - malloc -- with - installed - readline &&
make &&
make check &&
make install || read
cd ..
rm - rf bash - 3.0
exec / bin / bash -- login + h
7)target-build2.sh
#
! /bin/bash
cd / sources
tar xf $LFS / file - 4.13 . tar . bz2
tar xf $LFS / libtool - 1.5 . 14 . tar . bz2
tar xf $LFS / bzip2 - 1.0 . 3 . tar . bz2
cd bzip2 - 1.0 . 3
patch - Np1 < $LFS / bzip2 - 1.0 . 3 - install_docs - 1 . patch
patch - Np1 < $LFS / bzip2 - 1.0 . 3 - bzgrep_security - 1 . patch
cd ..
tar xf $LFS / diffutils - 2.8 . 1 . tar . bz2
tar xfj $LFS / kbd - 1.12 . tar . bz2
tar xfj $LFS / e2fsprogs - 1.37 . tar . bz2
tar xf $LFS / grep - 2.5 . 1a . tar . bz2
tar xf $LFS / grub - 0.96 . tar . bz2
tar xf $LFS / gzip - 1.3 . 5 . tar . bz2
cd gzip - 1.3 . 5
patch - Np1 - i $LFS / gzip - 1.3 . 5 - security_fixes - 1 . patch
cd ..
tar xf $LFS / hotplug - 2004_09_23 . tar . bz2
tar xf $LFS / man - 1 . 5p . tar . bz2
tar xf $LFS / make - 3.80 . tar . bz2
tar xf $LFS / module - init - tools - 3.1 . tar . bz2
tar xf $LFS / module - init - tools - testsuite - 3.1 . tar . bz2
tar xf $LFS / patch - 2.5 . 4 . tar . bz2
tar xf $LFS / procps - 3.2 . 5 . tar . bz2
tar xf $LFS / psmisc - 21.6 . tar . bz2
tar xf $LFS / shadow - 4.0 . 9 . tar . bz2
tar xf $LFS / sysklogd - 1.4 . 1 . tar . bz2
cd sysklogd - 1.4 . 1
patch - Np1 - i $LFS / sysklogd - 1.4 . 1 - fixes - 1 . patch
cd ..
tar xf $LFS / sysvinit - 2.86 . tar . bz2
tar xf $LFS / tar - 1.15 . 1 . tar . bz2
cd tar - 1.15 . 1
patch - Np1 - i $LFS / tar - 1.15 . 1 - sparse_fix - 1 . patch
cd ..
tar xf $LFS / udev - 056 . tar . bz2
tar xf $LFS / util - linux - 2 . 12q . tar . bz2
cd util - linux - 2 . 12q
sed - i ' s@etc/adjtime@var/lib/hwclock/adjtime@g '
hwclock / hwclock . c
mkdir - p / var / lib / hwclock
patch - Np1 - i $LFS / util - linux - 2 . 12q - cramfs - 1 . patch
patch - Np1 - i $LFS / util - linux - 2 . 12q - umount_fix - 1 . patch
cd ..
cd file - 4.13 &&
./ configure -- prefix =/ usr &&
make &&
make install || (echo " ***file*** " ; read )
cd ..
rm - rf file - 4.13
cd libtool - 1.5 . 14 &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install || (echo " ***libtool*** " ; read )
cd ..
rm - rf libtool - 1.5 . 14
cd bzip2 - 1.0 . 3 &&
make - f Makefile - libbz2_so &&
make clean &&
make &&
make 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 || (echo " ***bzip2*** " ; read )
cd ..
rm - rf bzip2 - 1.0 . 3
cd diffutils - 2.8 . 1 &&
./ configure -- prefix =/ usr &&
make &&
make install ) || (echo " ***diffutils*** " ; read )
cd ..
rm - rf diffutils - 2.8 . 1
(cd kbd - 1.12 &&
./ configure &&
make &&
make install || (echo " ***kbd*** " ; read )
cd ..
rm - rf kbd - 1.12
pwd
read
cd e2fsprogs - 1.37 &&
sed - i - e ' s/-DTEST/$(ALL_CFLAGS) &/ ' lib / e2p / Makefile . in &&
mkdir - v build &&
cd build &&
../ configure -- prefix =/ usr -- with - root - prefix = ""
-- enable - elf - shlibs -- disable - evms &&
make &&
make check &&
make install &&
make install - libs || (echo " ***e2fsprogs*** " ; read )
cd ../..
rm - rf e2fsprogs - 1.37
cd grep - 2.5 . 1a &&
./ configure -- prefix =/ usr -- bindir =/ bin &&
make &&
make check &&
make install || (echo " ***grep*** " ; read )
cd ..
rm - rf grep - 2.5 . 1a
cd grub - 0.96 &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install &&
mkdir - v / boot / grub &&
cp - v / usr / lib / grub / i386 - pc / stage{ 1 , 2 } / boot / grub || (echo " ***grub*** " ; read )
cd ..
rm - rf grub - 0.96
cd gzip - 1.3 . 5 &&
./ configure -- prefix =/ usr &&
sed - i ' s@"BINDIR"@/bin@g ' gzexe . in &&
make &&
make install &&
mv - v / usr / bin / gzip / bin &&
rm - v / usr / bin / {gunzip , zcat} &&
ln - sv gzip / bin / gunzip &&
ln - sv gzip / bin / zcat &&
ln - sv gzip / bin / compress &&
ln - sv gunzip / bin / uncompress || (echo " ***gzip*** " ; read )
cd ..
rm - rf gzip - 1.3 . 5
cd hotplug - 2004_09_23 &&
make install &&
cp - v etc / hotplug / pnp . distmap / etc / hotplug &&
rm - rfv / etc / init . d &&
rm - fv / etc / hotplug / net . agent &&
mkdir - v / lib / firmware || (echo " ***hotplug*** " ; read )
cd ..
rm - rf hotplug - 2004_09_23
cd man - 1 . 5p &&
sed - i ' s@-is@&R@g ' configure &&
sed - i ' s@MANPATH./usr/man@#&@g ' src / man . conf . in &&
./ configure - confdir =/ etc &&
make &&
make install || (echo " ***man*** " ; read )
cd ..
rm - rf man - 1 . 5p
cd make - 3.80 &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install || (echo " ***make*** " ; read )
cd ..
rm - rf make - 3.80
cd module - init - tools - 3.1 &&
touch modprobe . conf . 5 &&
./ configure &&
make check &&
make distclean &&
./ configure -- prefix = "" -- enable - zlib &&
make &&
make install || (echo " ***file*** " ; read )
cd ..
rm - rf module - init - tools - 3.1
cd patch - 2.5 . 4 &&
CPPFLAGS =- D_GNU_SOURCE ./ configure -- prefix =/ usr &&
make &&
make install || (echo " ***patch*** " ; read )
cd ..
rm - rf patch - 2.5 . 4
cd procps - 3.2 . 5 &&
make &&
make install || (echo " ***procps*** " ; read )
cd ..
rm - rf procps - 3.2 . 5
cd psmisc - 21.6 &&
./ configure -- prefix =/ usr -- exec - prefix = "" &&
make &&
make install &&
mv - v / bin / pstree * / usr / bin &&
ln - sv killall / bin / pidof || (echo " ***psmisc*** " ; read )
cd ..
rm - rf psmisc - 21.6
cd shadow - 4.0 . 9 &&
./ configure -- libdir =/ lib -- enable - shared &&
sed - i ' s/groups$(EXEEXT) // ' src / Makefile &&
sed - i ' /groups/d ' man / Makefile &&
make &&
make install &&
cp - v etc / {limits , login . access} / etc &&
sed - e ' s@#MD5_CRYPT_ENAB.no@MD5_CRYPT_ENAB yes@ '
- e ' s@/var/spool/mail@/var/mail@ '
etc / login . defs . linux > / etc / login . defs &&
mv - v / usr / bin / passwd / bin &&
mv - v / lib / libshadow .* a / usr / lib &&
rm - v / lib / libshadow . so &&
ln - sfv ../../ lib / libshadow . so . 0 / usr / lib / libshadow . so &&
mkdir - v / etc / default &&
pwconv &&
grpconv || (echo " ***shadow*** " ; read )
passwd root
cd ..
rm - rf shadow - 4.0 . 9
cd sysklogd - 1.4 . 1 &&
make &&
make install &&
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 *
# log the bootscript output:
local2 .* -/ var / log / boot . log
# End /etc/syslog.conf
EOF
|| (echo " ***sysklogd*** " ; read )
cd ..
rm - rf sysklogd - 1.4 . 1
cd sysvinit - 2.86 &&
sed - i ' s@Sending processes@& started by init@g ' src / init . c &&
make - C src &&
make - C src install &&
cat > / etc / inittab << " EOF " &&
# Begin /etc/inittab
id : 3 : initdefault :
si :: sysinit :/ etc / rc . d / init . d / rc sysinit
l0 : 0 : wait :/ etc / rc . d / init . d / rc 0
l1 : S1 : wait :/ etc / rc . d / init . d / rc 1
l2 : 2 : wait :/ etc / rc . d / init . d / rc 2
l3 : 3 : wait :/ etc / rc . d / init . d / rc 3
l4 : 4 : wait :/ etc / rc . d / init . d / rc 4
l5 : 5 : wait :/ etc / rc . d / init . d / rc 5
l6 : 6 : wait :/ etc / rc . d / init . d / rc 6
ca : 12345 : ctrlaltdel :/ sbin / shutdown - t1 - a - r now
su : S016 : once :/ sbin / sulogin
1 : 2345 : respawn :/ sbin / agetty - I ' (K ' tty1 9600
2 : 2345 : respawn :/ sbin / agetty - I ' (K ' tty2 9600
3 : 2345 : respawn :/ sbin / agetty - I ' (K ' tty3 9600
4 : 2345 : respawn :/ sbin / agetty - I ' (K ' tty4 9600
5 : 2345 : respawn :/ sbin / agetty - I ' (K ' tty5 9600
6 : 2345 : respawn :/ sbin / agetty - I ' (K ' tty6 9600
# End /etc/inittab
EOF
|| (echo " ***sysvinit*** " ; read )
cd ..
rm - rf sysvinit - 2.86
cd tar - 1.15 . 1 &&
./ configure -- prefix =/ usr -- bindir =/ bin -- libexecdir =/ usr / sbin &&
make &&
make check &&
make install || (echo " ***tar*** " ; read )
cd ..
rm - rf tar - 1.15 . 1
cd udev - 056 &&
make udevdir =/ dev &&
make test &&
make DESTDIR =/ udevdir =/ dev install &&
cp - v ../ udev - config - 4 . rules / etc / udev / rules . d / 25 - lfs . rules &&
/ sbin / udevstart || (echo " ***udev*** " ; read )
cd ..
rm - rf udev - 056
cd util - linux - 2 . 12q &&
./ configure &&
make HAVE_KILL = yes HAVE_SLN = yes &&
make HAVE_KILL = yes HAVE_SLN = yes install &&
mv / usr / bin / logger / bin || (echo " ***utils-linux*** " ; read )
cd ..
rm - rf util - linux - 2 . 12q
logout
cd / sources
tar xf $LFS / file - 4.13 . tar . bz2
tar xf $LFS / libtool - 1.5 . 14 . tar . bz2
tar xf $LFS / bzip2 - 1.0 . 3 . tar . bz2
cd bzip2 - 1.0 . 3
patch - Np1 < $LFS / bzip2 - 1.0 . 3 - install_docs - 1 . patch
patch - Np1 < $LFS / bzip2 - 1.0 . 3 - bzgrep_security - 1 . patch
cd ..
tar xf $LFS / diffutils - 2.8 . 1 . tar . bz2
tar xfj $LFS / kbd - 1.12 . tar . bz2
tar xfj $LFS / e2fsprogs - 1.37 . tar . bz2
tar xf $LFS / grep - 2.5 . 1a . tar . bz2
tar xf $LFS / grub - 0.96 . tar . bz2
tar xf $LFS / gzip - 1.3 . 5 . tar . bz2
cd gzip - 1.3 . 5
patch - Np1 - i $LFS / gzip - 1.3 . 5 - security_fixes - 1 . patch
cd ..
tar xf $LFS / hotplug - 2004_09_23 . tar . bz2
tar xf $LFS / man - 1 . 5p . tar . bz2
tar xf $LFS / make - 3.80 . tar . bz2
tar xf $LFS / module - init - tools - 3.1 . tar . bz2
tar xf $LFS / module - init - tools - testsuite - 3.1 . tar . bz2
tar xf $LFS / patch - 2.5 . 4 . tar . bz2
tar xf $LFS / procps - 3.2 . 5 . tar . bz2
tar xf $LFS / psmisc - 21.6 . tar . bz2
tar xf $LFS / shadow - 4.0 . 9 . tar . bz2
tar xf $LFS / sysklogd - 1.4 . 1 . tar . bz2
cd sysklogd - 1.4 . 1
patch - Np1 - i $LFS / sysklogd - 1.4 . 1 - fixes - 1 . patch
cd ..
tar xf $LFS / sysvinit - 2.86 . tar . bz2
tar xf $LFS / tar - 1.15 . 1 . tar . bz2
cd tar - 1.15 . 1
patch - Np1 - i $LFS / tar - 1.15 . 1 - sparse_fix - 1 . patch
cd ..
tar xf $LFS / udev - 056 . tar . bz2
tar xf $LFS / util - linux - 2 . 12q . tar . bz2
cd util - linux - 2 . 12q
sed - i ' s@etc/adjtime@var/lib/hwclock/adjtime@g '
hwclock / hwclock . c
mkdir - p / var / lib / hwclock
patch - Np1 - i $LFS / util - linux - 2 . 12q - cramfs - 1 . patch
patch - Np1 - i $LFS / util - linux - 2 . 12q - umount_fix - 1 . patch
cd ..
cd file - 4.13 &&
./ configure -- prefix =/ usr &&
make &&
make install || (echo " ***file*** " ; read )
cd ..
rm - rf file - 4.13
cd libtool - 1.5 . 14 &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install || (echo " ***libtool*** " ; read )
cd ..
rm - rf libtool - 1.5 . 14
cd bzip2 - 1.0 . 3 &&
make - f Makefile - libbz2_so &&
make clean &&
make &&
make 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 || (echo " ***bzip2*** " ; read )
cd ..
rm - rf bzip2 - 1.0 . 3
cd diffutils - 2.8 . 1 &&
./ configure -- prefix =/ usr &&
make &&
make install ) || (echo " ***diffutils*** " ; read )
cd ..
rm - rf diffutils - 2.8 . 1
(cd kbd - 1.12 &&
./ configure &&
make &&
make install || (echo " ***kbd*** " ; read )
cd ..
rm - rf kbd - 1.12
pwd
read
cd e2fsprogs - 1.37 &&
sed - i - e ' s/-DTEST/$(ALL_CFLAGS) &/ ' lib / e2p / Makefile . in &&
mkdir - v build &&
cd build &&
../ configure -- prefix =/ usr -- with - root - prefix = ""
-- enable - elf - shlibs -- disable - evms &&
make &&
make check &&
make install &&
make install - libs || (echo " ***e2fsprogs*** " ; read )
cd ../..
rm - rf e2fsprogs - 1.37
cd grep - 2.5 . 1a &&
./ configure -- prefix =/ usr -- bindir =/ bin &&
make &&
make check &&
make install || (echo " ***grep*** " ; read )
cd ..
rm - rf grep - 2.5 . 1a
cd grub - 0.96 &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install &&
mkdir - v / boot / grub &&
cp - v / usr / lib / grub / i386 - pc / stage{ 1 , 2 } / boot / grub || (echo " ***grub*** " ; read )
cd ..
rm - rf grub - 0.96
cd gzip - 1.3 . 5 &&
./ configure -- prefix =/ usr &&
sed - i ' s@"BINDIR"@/bin@g ' gzexe . in &&
make &&
make install &&
mv - v / usr / bin / gzip / bin &&
rm - v / usr / bin / {gunzip , zcat} &&
ln - sv gzip / bin / gunzip &&
ln - sv gzip / bin / zcat &&
ln - sv gzip / bin / compress &&
ln - sv gunzip / bin / uncompress || (echo " ***gzip*** " ; read )
cd ..
rm - rf gzip - 1.3 . 5
cd hotplug - 2004_09_23 &&
make install &&
cp - v etc / hotplug / pnp . distmap / etc / hotplug &&
rm - rfv / etc / init . d &&
rm - fv / etc / hotplug / net . agent &&
mkdir - v / lib / firmware || (echo " ***hotplug*** " ; read )
cd ..
rm - rf hotplug - 2004_09_23
cd man - 1 . 5p &&
sed - i ' s@-is@&R@g ' configure &&
sed - i ' s@MANPATH./usr/man@#&@g ' src / man . conf . in &&
./ configure - confdir =/ etc &&
make &&
make install || (echo " ***man*** " ; read )
cd ..
rm - rf man - 1 . 5p
cd make - 3.80 &&
./ configure -- prefix =/ usr &&
make &&
make check &&
make install || (echo " ***make*** " ; read )
cd ..
rm - rf make - 3.80
cd module - init - tools - 3.1 &&
touch modprobe . conf . 5 &&
./ configure &&
make check &&
make distclean &&
./ configure -- prefix = "" -- enable - zlib &&
make &&
make install || (echo " ***file*** " ; read )
cd ..
rm - rf module - init - tools - 3.1
cd patch - 2.5 . 4 &&
CPPFLAGS =- D_GNU_SOURCE ./ configure -- prefix =/ usr &&
make &&
make install || (echo " ***patch*** " ; read )
cd ..
rm - rf patch - 2.5 . 4
cd procps - 3.2 . 5 &&
make &&
make install || (echo " ***procps*** " ; read )
cd ..
rm - rf procps - 3.2 . 5
cd psmisc - 21.6 &&
./ configure -- prefix =/ usr -- exec - prefix = "" &&
make &&
make install &&
mv - v / bin / pstree * / usr / bin &&
ln - sv killall / bin / pidof || (echo " ***psmisc*** " ; read )
cd ..
rm - rf psmisc - 21.6
cd shadow - 4.0 . 9 &&
./ configure -- libdir =/ lib -- enable - shared &&
sed - i ' s/groups$(EXEEXT) // ' src / Makefile &&
sed - i ' /groups/d ' man / Makefile &&
make &&
make install &&
cp - v etc / {limits , login . access} / etc &&
sed - e ' s@#MD5_CRYPT_ENAB.no@MD5_CRYPT_ENAB yes@ '
- e ' s@/var/spool/mail@/var/mail@ '
etc / login . defs . linux > / etc / login . defs &&
mv - v / usr / bin / passwd / bin &&
mv - v / lib / libshadow .* a / usr / lib &&
rm - v / lib / libshadow . so &&
ln - sfv ../../ lib / libshadow . so . 0 / usr / lib / libshadow . so &&
mkdir - v / etc / default &&
pwconv &&
grpconv || (echo " ***shadow*** " ; read )
passwd root
cd ..
rm - rf shadow - 4.0 . 9
cd sysklogd - 1.4 . 1 &&
make &&
make install &&
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 *
# log the bootscript output:
local2 .* -/ var / log / boot . log
# End /etc/syslog.conf
EOF
|| (echo " ***sysklogd*** " ; read )
cd ..
rm - rf sysklogd - 1.4 . 1
cd sysvinit - 2.86 &&
sed - i ' s@Sending processes@& started by init@g ' src / init . c &&
make - C src &&
make - C src install &&
cat > / etc / inittab << " EOF " &&
# Begin /etc/inittab
id : 3 : initdefault :
si :: sysinit :/ etc / rc . d / init . d / rc sysinit
l0 : 0 : wait :/ etc / rc . d / init . d / rc 0
l1 : S1 : wait :/ etc / rc . d / init . d / rc 1
l2 : 2 : wait :/ etc / rc . d / init . d / rc 2
l3 : 3 : wait :/ etc / rc . d / init . d / rc 3
l4 : 4 : wait :/ etc / rc . d / init . d / rc 4
l5 : 5 : wait :/ etc / rc . d / init . d / rc 5
l6 : 6 : wait :/ etc / rc . d / init . d / rc 6
ca : 12345 : ctrlaltdel :/ sbin / shutdown - t1 - a - r now
su : S016 : once :/ sbin / sulogin
1 : 2345 : respawn :/ sbin / agetty - I ' (K ' tty1 9600
2 : 2345 : respawn :/ sbin / agetty - I ' (K ' tty2 9600
3 : 2345 : respawn :/ sbin / agetty - I ' (K ' tty3 9600
4 : 2345 : respawn :/ sbin / agetty - I ' (K ' tty4 9600
5 : 2345 : respawn :/ sbin / agetty - I ' (K ' tty5 9600
6 : 2345 : respawn :/ sbin / agetty - I ' (K ' tty6 9600
# End /etc/inittab
EOF
|| (echo " ***sysvinit*** " ; read )
cd ..
rm - rf sysvinit - 2.86
cd tar - 1.15 . 1 &&
./ configure -- prefix =/ usr -- bindir =/ bin -- libexecdir =/ usr / sbin &&
make &&
make check &&
make install || (echo " ***tar*** " ; read )
cd ..
rm - rf tar - 1.15 . 1
cd udev - 056 &&
make udevdir =/ dev &&
make test &&
make DESTDIR =/ udevdir =/ dev install &&
cp - v ../ udev - config - 4 . rules / etc / udev / rules . d / 25 - lfs . rules &&
/ sbin / udevstart || (echo " ***udev*** " ; read )
cd ..
rm - rf udev - 056
cd util - linux - 2 . 12q &&
./ configure &&
make HAVE_KILL = yes HAVE_SLN = yes &&
make HAVE_KILL = yes HAVE_SLN = yes install &&
mv / usr / bin / logger / bin || (echo " ***utils-linux*** " ; read )
cd ..
rm - rf util - linux - 2 . 12q
logout
8)chroot-to-strip.sh
#
! /bin/bash
export LFS =/ mnt / lfs
ln - sv $LFS / tools /
chroot $LFS / tools / bin / env - i
HOME =/ root TERM = $TERM PS1 = ' u:w$ '
PATH =/ bin :/ usr / bin :/ sbin :/ usr / sbin
/ tools / bin / bash -- login
export LFS =/ mnt / lfs
ln - sv $LFS / tools /
chroot $LFS / tools / bin / env - i
HOME =/ root TERM = $TERM PS1 = ' u:w$ '
PATH =/ bin :/ usr / bin :/ sbin :/ usr / sbin
/ tools / bin / bash -- login
9)strip.sh
#
! /bin/bash
/ tools / bin / find / { , usr / }{bin , lib , sbin} - type f
- exec / tools / bin / strip -- strip - debug ' {} ' ' ; '
logout
/ tools / bin / find / { , usr / }{bin , lib , sbin} - type f
- exec / tools / bin / strip -- strip - debug ' {} ' ' ; '
logout
10)chroot-to-boot.sh
#
! /bin/bash
export LFS =/ mnt / lfs
chroot " $LFS " / usr / bin / env - i
HOME =/ root TERM = " $TERM " PS1 = ' u:w$ '
PATH =/ bin :/ usr / bin :/ sbin :/ usr / sbin
/ bin / bash -- login
export LFS =/ mnt / lfs
chroot " $LFS " / usr / bin / env - i
HOME =/ root TERM = " $TERM " PS1 = ' u:w$ '
PATH =/ bin :/ usr / bin :/ sbin :/ usr / sbin
/ bin / bash -- login
11)to-boot.sh
#
! /bin/bash
export LFS =/ sources
cd / sources
tar xf $LFS / lfs - bootscripts - 3.2 . 1 . tar . bz2
cd lfs - bootscripts - 3.2 . 1
make install
cd ..
rm - rf lfs - bootscripts - 3.2 . 1
cat > / etc / sysconfig / clock << " EOF "
# Begin /etc/sysconfig/clock
UTC = 1
# End /etc/sysconfig/clock
EOF
cat > / etc / inputrc << " EOF "
set horizontal - scroll - mode Off
set meta - flag On
set input - meta On
set convert - meta Off
set output - meta On
set bell - style none
" eOd " : backward - word
" eOc " : forward - word
" e[1~ " : beginning - of - line
" e[4~ " : end - of - line
" e[5~ " : beginning - of - history
" e[6~ " : end - of - history
" e[3~ " : delete - char
" e[2~ " : quoted - insert
" eOH " : beginning - of - line
" eOF " : end - of - line
" e[H " : beginning - of - line
" e[F " : end - of - line
EOF
cat > / etc / profile << " EOF "
# Begin /etc/profile
export LANG = zh_CN . GB18030
export INPUTRC =/ etc / inputrc
# End /etc/profile
EOF
echo " HOSTNAME=mylinux " > / etc / sysconfig / network
cat > / etc / hosts << " EOF "
# Begin /etc/hosts (no network card version)
127.0 . 0.1 mylinux localhost
# End /etc/hosts (no network card version)
EOF
cd / etc / sysconfig / network - devices
mkdir - v ifconfig . eth0
cat > ifconfig . eth0 / ipv4 << " EOF "
ONBOOT = yes
SERVICE = ipv4 - static
IP = 192.9 . 200.111
GATEWAY = 192.9 . 200.254
PREFIX = 24
BROADCAST = 192.9 . 200.255
EOF
cat > / etc / resolv . conf << " EOF "
# Begin /etc/resolv.conf
nameserver 192.9 . 200.254
nameserver 202.117 . 80.2
# End /etc/resolv.conf
EOF
cat > / etc / fstab << " EOF "
# Begin /etc/fstab
# file system mount-point type options dump fsck
# order
/ dev / hda7 / ext3 defaults 1 1
/ dev / hda8 swap swap pri = 1 0 0
proc / proc proc defaults 0 0
sysfs / sys sysfs defaults 0 0
devpts / dev / pts devpts gid = 4 , mode = 620 0 0
shm / dev / shm tmpfs defaults 0 0
# End /etc/fstab
EOF
cd / sources
tar xf $LFS / linux - 2.6 . 11.12 . tar . bz2
cd linux - 2.6 . 11.12
make mrproper
make menuconfig
make
make modules_install
cp - v arch / i386 / boot / bzImage / boot / lfskernel - 2.6 . 11.12
cp - v System . map / boot / System . map - 2.6 . 11.12
cp - v . config / boot / config - 2.6 . 11.12
cp my . config ../../
cd ..
grub
cat > / boot / grub / menu . lst << " EOF "
# Begin /boot/grub/menu.lst
# Allow 30 seconds before booting the default.
timeout 5
# Use prettier colors.
color green / black light - green / black
# By default boot the first menu entry.
default 0
# The first entry is for Windows XP
title Microsoft Windows XP
root (hd0 , 0 )
chainloader + 1
# The second entry is for LFS.
title LFS 6.1 . 1
root (hd0 , 6 )
kernel / boot / lfskernel - 2.6 . 11.12 root =/ dev / hda7
EOF
mkdir - v / etc / grub
ln - sv / boot / grub / menu . lst / etc / grub
logout
export LFS =/ sources
cd / sources
tar xf $LFS / lfs - bootscripts - 3.2 . 1 . tar . bz2
cd lfs - bootscripts - 3.2 . 1
make install
cd ..
rm - rf lfs - bootscripts - 3.2 . 1
cat > / etc / sysconfig / clock << " EOF "
# Begin /etc/sysconfig/clock
UTC = 1
# End /etc/sysconfig/clock
EOF
cat > / etc / inputrc << " EOF "
set horizontal - scroll - mode Off
set meta - flag On
set input - meta On
set convert - meta Off
set output - meta On
set bell - style none
" eOd " : backward - word
" eOc " : forward - word
" e[1~ " : beginning - of - line
" e[4~ " : end - of - line
" e[5~ " : beginning - of - history
" e[6~ " : end - of - history
" e[3~ " : delete - char
" e[2~ " : quoted - insert
" eOH " : beginning - of - line
" eOF " : end - of - line
" e[H " : beginning - of - line
" e[F " : end - of - line
EOF
cat > / etc / profile << " EOF "
# Begin /etc/profile
export LANG = zh_CN . GB18030
export INPUTRC =/ etc / inputrc
# End /etc/profile
EOF
echo " HOSTNAME=mylinux " > / etc / sysconfig / network
cat > / etc / hosts << " EOF "
# Begin /etc/hosts (no network card version)
127.0 . 0.1 mylinux localhost
# End /etc/hosts (no network card version)
EOF
cd / etc / sysconfig / network - devices
mkdir - v ifconfig . eth0
cat > ifconfig . eth0 / ipv4 << " EOF "
ONBOOT = yes
SERVICE = ipv4 - static
IP = 192.9 . 200.111
GATEWAY = 192.9 . 200.254
PREFIX = 24
BROADCAST = 192.9 . 200.255
EOF
cat > / etc / resolv . conf << " EOF "
# Begin /etc/resolv.conf
nameserver 192.9 . 200.254
nameserver 202.117 . 80.2
# End /etc/resolv.conf
EOF
cat > / etc / fstab << " EOF "
# Begin /etc/fstab
# file system mount-point type options dump fsck
# order
/ dev / hda7 / ext3 defaults 1 1
/ dev / hda8 swap swap pri = 1 0 0
proc / proc proc defaults 0 0
sysfs / sys sysfs defaults 0 0
devpts / dev / pts devpts gid = 4 , mode = 620 0 0
shm / dev / shm tmpfs defaults 0 0
# End /etc/fstab
EOF
cd / sources
tar xf $LFS / linux - 2.6 . 11.12 . tar . bz2
cd linux - 2.6 . 11.12
make mrproper
make menuconfig
make
make modules_install
cp - v arch / i386 / boot / bzImage / boot / lfskernel - 2.6 . 11.12
cp - v System . map / boot / System . map - 2.6 . 11.12
cp - v . config / boot / config - 2.6 . 11.12
cp my . config ../../
cd ..
grub
cat > / boot / grub / menu . lst << " EOF "
# Begin /boot/grub/menu.lst
# Allow 30 seconds before booting the default.
timeout 5
# Use prettier colors.
color green / black light - green / black
# By default boot the first menu entry.
default 0
# The first entry is for Windows XP
title Microsoft Windows XP
root (hd0 , 0 )
chainloader + 1
# The second entry is for LFS.
title LFS 6.1 . 1
root (hd0 , 6 )
kernel / boot / lfskernel - 2.6 . 11.12 root =/ dev / hda7
EOF
mkdir - v / etc / grub
ln - sv / boot / grub / menu . lst / etc / grub
logout
更多推荐
已为社区贡献3条内容
所有评论(0)