22.-LFS automatico.pdf

62
#!/bin/bash #####PARTICIONADO DISCOS ##### read -p "Disco a particionar Ej:/dev/sdb:" disco dd if=$disco of=mbrcopia bs=512 count=1 echo "d 1 d 2 d 3 d 4 n p 1 953 n p 2 t 2 82 w"|fdisk $disco read -p "El disco elegido $disco es el correcto s/n:" resp

Transcript of 22.-LFS automatico.pdf

Page 1: 22.-LFS automatico.pdf

#!/bin/bash

#####PARTICIONADO DISCOS #####

read -p "Disco a particionar Ej:/dev/sdb:" disco

dd if=$disco of=mbrcopia bs=512 count=1

echo "d

1

d

2

d

3

d

4

n

p

1

953

n

p

2

t

2

82

w"|fdisk $disco

read -p "El disco elegido $disco es el correcto s/n:" resp

Page 2: 22.-LFS automatico.pdf

if [ "$resp" = "n" ]

then

dd if=mbrcopia of=$disco bs=512 count=1

exit

fi

#####FIN PARTICIONADO#####

#####PAQUETES ANFITRION (DEBIAN)#####

ifconfig eth0 192.168.0.58 255.255.255.0

route add default gw 192.168.0.1

echo "nameserver 8.8.8.8">/etc/resolv.conf

echo "nameserver 8.8.4.4">>/etc/resolv.conf

##### FIN PAQUETES ANFITRION #####

apt-get update

apt-get install autoconf

apt-get install automake

apt-get install bash

apt-get install binutils

apt-get install bison

apt-get install bzip2

apt-get install coreutils

apt-get install dejaGNU

apt-get install diffutils

apt-get install expect

apt-get install e2fsprogs

apt-get install file

Page 3: 22.-LFS automatico.pdf

apt-get install findutils

apt-get install flex

apt-get install gawk

apt-get install gcc

apt-get install libgdbm -dev

apt-get install Gettext

apt-get install glibc6

apt-get install libgmp3 -dev

apt-get install grep

apt-get install groff

apt-get install grub

apt-get install gzip

apt-get install libi18n-charset-perl

apt-get install inetutils-tools

apt-get install iproute -dev

apt-get install kbd

apt-get install kmod

apt-get install less

apt-get install libtool

apt-get install m4

apt-get install make

apt-get install man-DB

apt-get install libmpc -dev

apt-get install libmpfr -dev

apt-get install libncurses5

apt-get install patch

apt-get install perl

Page 4: 22.-LFS automatico.pdf

apt-get install procps

apt-get install psmisc

apt-get install readline-common

apt-get install sed

apt-get install sysklogd

apt-get install sysvinit

apt-get install tar

apt-get install tcl

apt-get install texinfo

apt-get install udev

apt-get install util-linux

apt-get install vim

apt-get install xz-utils

apt-get install libzzip -dev

apt-get install zlib1g -dev

apt-get install sysklogd

##### FORMATEO DISCOS ######

disco="/dev/sdb"

particion1="$disco"1

particion2="$disco"2

echo $particion1

mkswap $particion2

#####FIN FORMATEO#####

####Montaje sobre anfitrion####

mkdir /mnt/lfs

Page 5: 22.-LFS automatico.pdf

export LFS=/mnt/lfs

mount -t ext3 $disco $LFS

/usr/sbin/swapon $particion2

#### Montaje ####

####Paquetes Fuentes####

mkdir $LFS/sources

cd LFS/sources

wget http://www.linuxfromscratch.org/lfs/downloads/7.1/wget-list

wget -i wget-list -P $LFS/sources

wget http://source-forge.net/projects/libpng/files/zlib-1.2.6.tar.bz2/download

####Fin paquetes fuentes####

#### Montaje LFS ####

echo "/dev/$particion1 $LFS ext3 defaults 0 0">>/etc/fstab

#### Fin montaje LFS ####

####Agregr usuario alfs y permisos####

useradd alfs -s /bin/bash -g alfs -m -k /dev/null alfs

passwd alfs

groupadd alfs

mkdir $LFS/tools

ln -sv $LFS/tools

chown alfs $LFS/tools

chown -R alfs /$LFS/sources

su - alfs

####Fin usuario permisos####

Page 6: 22.-LFS automatico.pdf

####Ajuste Bashrc y bash_profile####

cat > ~/bash.profile << "EOF"

exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash

EOF

cat > ~/bashrc <<"EOF"

set +h

umask LFS=/mnt/lfs

LC_ALL=POSIX

LFS_TGT=$(uname -m)-lfs-linux-gnu

PATH=/tools/bin:/bin:/usr/bin

export LGS LC_ALL LGS_TGT PATH

EOF

####Fin bash####

#####Punto 5#####

#####Binutils PASO1#####

cd $LFS/sources

tar -jxvf binutils-.tar.bz2

mkdir binutils-build

cd binutils-build

../binutils-2.22/configure \

--target=$LFS_TGT --prefix=/tools \

--disable-nls --disable-werror

make

Page 7: 22.-LFS automatico.pdf

case $(uname -m) in

x86_64) mkdir -v /tools/lib && ln -sv lib /tools/lib64 ;;

esac

make install

cd ..

rm -rf binutils-build

cd $LFS/sources

####Fin binutils####

#####GCC####

tar -jxvf gcc-4.6.2.tar.bz2

tar -jxf ../mpfr-3.1.0.tar.bz2

mv -v mpfr-3.1.0 mpfr

tar -Jxf ../gmp-5.0.4.tar.xz

mv -v gmp-5.0.4 gmp

tar -zxf ../mpc-0.9.tar.gz

mv -v mpc-0.9 mpc

patch -Np1 -i ../gcc-4.6.2-cross_compile-1.patch

mkdir -v ../gcc-build

cd ../gcc-build

../gcc-4.6.2/configure \

Page 8: 22.-LFS automatico.pdf

--target=$LFS_TGT --prefix=/tools \

--disable-nls --disable-shared --disable-multilib \

--disable-decimal-float --disable-threads \

--disable-libmudflap --disable-libssp \

--disable-libgomp --disable-libquadmath \

--disable-target-libiberty --disable-target-zlib \

--enable-languages=c --without-ppl --without-cloog \

--with-mpfr-include=$(pwd)/../gcc-4.6.2/mpfr/src \

--with-mpfr-lib=$(pwd)/mpfr/src/.libs

make

make install

ln -vs libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | \

sed 's/libgcc/&_eh/'`

cd ..

cd -rf gcc-build

cd $LFS/sources

#####Fin GCC#####

#####API HEADERS#####

tar -Jxvf linux-3.2.6.tar.xz

cd linux-3.2.6

make mrproper

make headers_check

Page 9: 22.-LFS automatico.pdf

make INSTALL_HDR_PATH=dest headers_install

cp -rv dest/include/* /tools/include

cd $LFS/sources

#####Fin HEADERS#####

#####Glibc#####

tar -zxvf glibc-2.1.3.tar.gz

cd glibc-2.1.3

patch -Np1 -i ../glibc-2.14.1-gcc_fix-1.patch

patch -Np1 -i ../glibc-2.14.1-cpuid-1.patch

mkdir -v ../glibc-build

cd ../glibc-build

case `uname -m` in

i?86) echo "CFLAGS += -march=i486 -mtune=native" > configparms ;;

esac

../glibc-2.14.1/configure --prefix=/tools \

--host=$LFS_TGT --build=$(../glibc-2.14.1/scripts/config.guess) \

--disable-profile --enable-add-ons \

--enable-kernel=2.6.25 --with-headers=/tools/include \

libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes

make

make install

SPECS=`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/specs

$LFS_TGT-gcc -dumpspecs | sed \

-e 's@/lib\(64\)\?/ld@/tools&@g' \

Page 10: 22.-LFS automatico.pdf

-e "/^\*cpp:$/{n;s,$, -isystem /tools/include,}" > $SPECS

echo "New specs file is: $SPECS"

unset SPECS

echo 'main(){}' > dummy.c

$LFS_TGT-gcc -B/tools/lib dummy.c

readelf -l a.out | grep ': /tools'

rm -v dummy.c a.out

cd ..

rm -rf glibc-build

cd $LFS/sources

#####glibc#####

#####binutils#####

tar -jxvf binutils-2.22.tar.bz2

cd binutils-2.22

mkdir -v ../binutils-build

cd ../binutils-build

CC="$LFS_TGT-gcc -B/tools/lib/" \

AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \

../binutils-2.22/configure --prefix=/tools \

--disable-nls --with-lib-path=/tools/lib

make

make install

make -C ld clean

make -C ld LIB_PATH=/usr/lib:/lib

cp -v ld/ld-new /tools/bin

cd ..

rm -rf binutils-build

Page 11: 22.-LFS automatico.pdf

cd $LFS/sources

#####Fin BINUTILS#####

#####GCC#####

tar -jxvf gcc-4.6.2.tar.bz2

cd gcc-4.6.2

patch -Np1 -i ../gcc-4.6.2-startfiles_fix-1.patch

cp -v gcc/Makefile.in{,.orig}

sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in

cp -v gcc/Makefile.in{,.tmp}

sed 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in.tmp \

> gcc/Makefile.in

for file in \

$(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)

do

cp -uv $file{,.orig}

sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \

-e 's@/usr@/tools@g' $file.orig > $file

echo '

#undef STANDARD_INCLUDE_DIR

#define STANDARD_INCLUDE_DIR 0

#define STANDARD_STARTFILE_PREFIX_1 ""

#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file

touch $file.orig

done

case $(uname -m) in

x86_64)

Page 12: 22.-LFS automatico.pdf

for file in $(find gcc/config -name t-linux64) ; do \

cp -v $file{,.orig}

sed '/MULTILIB_OSDIRNAMES/d' $file.orig > $file

done

;;

esac

tar -jxf ../mpfr-3.1.0.tar.bz2

mv -v mpfr-3.1.0 mpfr

tar -Jxf ../gmp-5.0.4.tar.xz

mv -v gmp-5.0.4 gmp

tar -zxf ../mpc-0.9.tar.gz

mv -v mpc-0.9 mpc

mkdir -v ../gcc-build

cd ../gcc-build

CC="$LFS_TGT-gcc -B/tools/lib/" \

AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \

../gcc-4.6.2/configure --prefix=/tools \

--with-local-prefix=/tools --enable-clocale=gnu \

--enable-shared --enable-threads=posix \

--enable-__cxa_atexit --enable-languages=c,c++ \

--disable-libstdcxx-pch --disable-multilib \

--disable-bootstrap --disable-libgomp \

--without-ppl --without-cloog \

--with-mpfr-include=$(pwd)/../gcc-4.6.2/mpfr/src \

--with-mpfr-lib=$(pwd)/mpfr/src/.libs

make

Page 13: 22.-LFS automatico.pdf

make install

ln -vs gcc /tools/bin/cc

echo 'main(){}' > dummy.c

cc dummy.c

readelf -l a.out | grep ': /tools'

rm -v dummy.c a.out

cd ..

rm -rf gcc-build

cd $LFS/sources

#####FIN GCC#####

#####TCL#####

tar -jzvf tcl-8.5.11-1.tar.bz2

cd tcl-8.5.11-1

cd unix

./configure --prefix=/tools

make

TZ=UTC make test

make install

chmod -v u+w /tools/lib/libtcl8.5.so

make install-private-headers

ln -sv tclsh8.5 /tools/bin/tclsh

cd $LFS/sources

#####FIN TCL#####

##### Expect #####

tar -zxvf expect5.45.tar.gz

cd expect5.45

Page 14: 22.-LFS automatico.pdf

cp -v configure{,.orig}

sed 's:/usr/local/bin:/bin:' configure.orig > configure

./configure --prefix=/tools --with-tcl=/tools/lib \

--with-tclinclude=/tools/include

make

make test

make SCRIPTS="" install

cd $LFS/sources

#####FIN Expect#####

#####DejaGNU#####

tar -zxvf dejagnu-1.5.tar.gz

./configure --prefix=/tools

make install

make check

cd $LFS/sources

#####FIM DejaGNU#####

#####Check#####

tar -zxvf check-0.9.8.tar.gz

cd check-0.9.8

./configure --prefix=/tools

make

make check

make install

cd $LFS/sources

#####FIN Check#####

#####Ncurses#####

tar -zxvf Ncurses-5.9.tar.gz

Page 15: 22.-LFS automatico.pdf

cd Ncurses-5.9

./configure --prefix=/tools --with-shared \

--without-debug --without-ada --enable-overwrite

make

make install

cd $LFS/sources

#####FIN Ncurses#####

#####Bash#####

tar -zxvf bash-4.2.tar.gz

cd bash-4.2

patch -Np1 -i ../bash-4.2-fixes-4.patch

./configure --prefix=/tools --without-bash-malloc

make

make test

make install

ln -vs bash /tools/bin/sh

cd $LFS/sources

#####FIN Bash#####

#####Bzip#####

tar -zxvf bzip-1.0.6.tar.gz

cd bzip-1.0.6

make

make PREFIX=/tools install

cd $LFS/sources

#####FIN Bzip#####

Page 16: 22.-LFS automatico.pdf

#####Coreutils#####

tar -Jxvf coreutils-8.15.tar.xz

cd coreutils-8.15

./configure --prefix=/tools --enable-install-program=hostname

make

make RUN_EXPENSIVE_TESTS=yes check

make install

cp -v src/su /tools/bin/su-tools

cd $LFS/sources

#####Fin Coreutils#####

#####Diffutils#####

tar -zxvf diffutils-3.2.tar.gz

cd diffutils-3.2

./configure --prefix=/tools

make

make check

make install

cd $LFS/sources

#####Fin Coreutils#####

#####file#####

tar -zxvf tar-5.10.tar.gz

cd tar-5.10

./configure --prefix=/tools

make

make check

make install

cd $LFS/sources

Page 17: 22.-LFS automatico.pdf

#####fin file#####

#####findutils#####

tar -zxvf findutils-4.4.2.tar.gz

cd findutils-4.4.2

./configure --prefix=/tools

make

make check

make install

cd $LFS/sources

#####fin findutils#####

#####Gawk#####

tar -zxvf gawk-4.0.0.tar.gz

cd gawk-4.0.0

./configure --prefix=/tools

make

make check

make install

cd $LFS/sources

#####Fin Gawk#####

#####Gettext#####

tar -zxvf gettext-0.18.1.1.tar.gz

cd gettext-0.18.1.1

cd gettext-tools

./configure --prefix=/tools --disable-shared

make -C gnulib-lib

make -C src msgfmt

cp -v src/msgfmt /tools/bin

Page 18: 22.-LFS automatico.pdf

cd $LFS/sources

#####Fin Gettext#####

#####grep#####

tar -Jxvf grep-2.10.tar.xz

cd grep-2.10

./configure --prefix=/tools \

--disable-perl-regexp

make

make check

make install

cd $LFS/sources

#####fin grep#####

#####Gzip#####

tar -Jxvf gzip-1.4.tar.xz

cd gzip-1.4

./configure --prefix=/tools

make

make check

make install

cd $LFS/sources

#####Fin Gzip#####

#####M4#####

tar -jxvf m4-1.4.16.tar.bz2

cd m4-1.4.16

./configure --prefix=/tools

make

make check

Page 19: 22.-LFS automatico.pdf

make install

cd $LFS/sources

#####fin m4#####

#####make#####

tar -jxvf make-3.82.tar.bz2

cd make-3.82

./configure --prefix=/tools

make

make check

make install

cd $LFS/sources

#####Fin Make#####

#####Patch-2.6.1#####

tar -jxvf patch-2.6.1.tar.bz2

./configure --prefix=/tools

make

make check

make install

cd $LFS/sources

#####Fin Patch#####

#####Perl#####

tar -zxvf perl-5.14.2.tar.gz

cd perl-5.14.2

patch -Np1 -i ../perl-5.14.2-libc-1.patch

sh Configure -des -Dprefix=/tools

make

cp -v perl cpan/podlators/pod2man /tools/bin

Page 20: 22.-LFS automatico.pdf

mkdir -pv /tools/lib/perl5/5.14.2

cp -Rv lib/* /tools/lib/perl5/5.14.2

cd $LFS/sources

#####Fin Perl#####

#####Sed#####

tar -zxvf sed-4.2.1.tar.gz

cd sed-4.2.1

./configure --prefix=/tools

make

make check

make install

cd $LFS/sources

#####Fin Sed#####

#####tar#####

tar -zxvf tar-1.26.tar.gz

cd tar-1.26

./configure --prefix=/tools

make

make check

make install

cd $LFS/sources

#####Fin tar#####

#####Texinfo#####

tar -zxvf texinfo-4.13a.tar.gz

cd texinfo-4.13a

./configure --prefix=/tools

make

Page 21: 22.-LFS automatico.pdf

make check

make install

cd $LFS/sources

#####Fin Textinfo#####

#####Xz#####

tar -jxvf xz-5.0.3.tar.bz2

cd xz-5.0.3

./configure --prefix=/tools

make

make check

make install

cd $LFS/sources

#####Fin xz#####

#####Stripping#####

strip --strip-debug /tools/lib/*

strip --strip-unneeded /tools/{,s}bin/*

rm -rf /tools/{,share}/{info,man,doc}

chown -R root:root $LFS/tools

#####fin stripping#####

#####preparing Virtual kernel#####

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

Page 22: 22.-LFS automatico.pdf

mount -vt sysfs sysfs $LFS/sys

./configure --prefix=/usr/pkg/libfoo/1.1

make

make install

./configure --prefix=/usr

make

make DESTDIR=/usr/pkg/libfoo/1.1 install

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

mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib,mnt,opt,run}

mkdir -pv /{media/{floppy,cdrom},sbin,srv,var}

install -dv -m 0750 /root

install -dv -m 1777 /tmp /var/tmp

mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src}

mkdir -pv /usr/{,local/}share/{doc,info,locale,man}

mkdir -v /usr/{,local/}share/{misc,terminfo,zoneinfo}

mkdir -pv /usr/{,local/}share/man/man{1..8}

for dir in /usr /usr/local; do

ln -sv share/{man,doc,info} $dir

done

case $(uname -m) in

x86_64) ln -sv lib /lib64 && ln -sv lib /usr/lib64 ;;

esac

mkdir -v /var/{log,mail,spool}

ln -sv /run /var/run

Page 23: 22.-LFS automatico.pdf

ln -sv /run/lock /var/lock

mkdir -pv /var/{opt,cache,lib/{misc,locate},local}

ln -sv /tools/bin/{bash,cat,echo,pwd,stty} /bin

ln -sv /tools/bin/perl /usr/bin

ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib

ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib

sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la

ln -sv bash /bin/sh

touch /etc/mtab

cat > /etc/passwd << "EOF"

root:x:0:0:root:/root:/bin/bash

bin:x:1:1:bin:/dev/null:/bin/false

nobody:x:99:99:Unprivileged User:/dev/null:/bin/false

EOF

cat > /etc/group << "EOF"

root:x:0:

bin:x:1:

sys:x:2:

kmem:x:3:

tty:x:4:

tape:x:5:

daemon:x:6:

floppy:x:7:

disk:x:8:

lp:x:9:

dialout:x:10:

audio:x:11:

Page 24: 22.-LFS automatico.pdf

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

chmod -v 600 /var/log/btmp

#####Fin#####

######Headers######

cd linux-3.2.6

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 $LFS/sources

######Fin Headers######

######Glibc######

cd glibc-2.14.1

DL=$(readelf -l /bin/sh | sed -n 's@.*interpret.*/tools\(.*\)]$@\1@p')

sed -i "s|libs -o|libs -L/usr/lib -Wl,-dynamic-linker=$DL -o|" \

scripts/test-installation.pl

Page 25: 22.-LFS automatico.pdf

unset DL

sed -i -e 's/"db1"/& \&\& $name ne "nss_test1"/' scripts/test-installation.pl

sed -i 's|@BASH@|/bin/bash|' elf/ldd.bash.in

patch -Np1 -i ../glibc-2.14.1-fixes-1.patch

patch -Np1 -i ../glibc-2.14.1-sort-1.patch

patch -Np1 -i ../glibc-2.14.1-gcc_fix-1.patch

sed -i '195,213 s/PRIVATE_FUTEX/FUTEX_CLOCK_REALTIME/' \

nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timed{rd,wr}lock.S

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.14.1/configure --prefix=/usr \

--disable-profile --enable-add-ons \

--enable-kernel=2.6.25 --libexecdir=/usr/lib/glibc

make

cp -v ../glibc-2.14.1/iconvdata/gconv-modules iconvdata

make -k check 2>&1 | tee glibc-check-log

grep Error glibc-check-log

touch /etc/ld.so.conf

make install

cp -v ../glibc-2.14.1/sunrpc/rpc/*.h /usr/include/rpc

cp -v ../glibc-2.14.1/sunrpc/rpcsvc/*.h /usr/include/rpcsvc

cp -v ../glibc-2.14.1/nis/rpcsvc/*.h /usr/include/rpcsvc

mkdir -pv /usr/lib/locale

localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8

Page 26: 22.-LFS automatico.pdf

localedef -i de_DE -f ISO-8859-1 de_DE

localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro

localedef -i de_DE -f UTF-8 de_DE.UTF-8

localedef -i en_HK -f ISO-8859-1 en_HK

localedef -i en_PH -f ISO-8859-1 en_PH

localedef -i en_US -f ISO-8859-1 en_US

localedef -i en_US -f UTF-8 en_US.UTF-8

localedef -i es_MX -f ISO-8859-1 es_MX

localedef -i fa_IR -f UTF-8 fa_IR

localedef -i fr_FR -f ISO-8859-1 fr_FR

localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro

localedef -i fr_FR -f UTF-8 fr_FR.UTF-8

localedef -i it_IT -f ISO-8859-1 it_IT

localedef -i 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

make localedata/install-locales

cat > /etc/nsswitch.conf << "EOF"

# Begin /etc/nsswitch.conf

passwd: files

group: files

shadow: files

hosts: files dns

networks: files

protocols: files

Page 27: 22.-LFS automatico.pdf

services: files

ethers: files

rpc: files

# End /etc/nsswitch.conf

EOF

tzselect

cp -v --remove-destination /usr/share/zoneinfo/<xxx> \

/etc/localtime

cat > /etc/ld.so.conf << "EOF"

# Begin /etc/ld.so.conf

/usr/local/lib

/opt/lib

EOF

cat >> /etc/ld.so.conf << "EOF"

# Add an include directory

include /etc/ld.so.conf.d/*.conf

EOF

mkdir /etc/ld.so.conf.d

rm -rf glibc-build

cd $lfs/sources

######Fin Glibc######

######re-adjusting######

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

Page 28: 22.-LFS automatico.pdf

gcc -dumpspecs | sed -e 's@/tools@@g' \

-e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \

-e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > \

`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'

grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log

grep -B1 '^ /usr/include' dummy.log

grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'

grep "/lib.*/libc.so.6 " dummy.log

grep found dummy.log

rm -v dummy.c a.out dummy.log

######Fin re-adjusting######

######zlib######

cd zlib-1.2.6

./configure --prefix=/usr

make

make check

make install

mv -v /usr/lib/libz.so.* /lib

ln -sfv ../../lib/libz.so.1.2.6 /usr/lib/libz.so

cd $LFS/sources

######fin zlib######

######file######

cd file-5.10

Page 29: 22.-LFS automatico.pdf

./configure --prefix=/usr

make

make check

make install

cd $LFS/sources

######fin file######

######bintuils######

cd binutils-2.22

expect -c "spawn ls"

rm -fv etc/standards.info

sed -i.bak '/^INFO/s/standards.info //' etc/Makefile.in

sed -i "/exception_defines.h/d" ld/testsuite/ld-elf/new.cc

sed -i "s/-fvtable-gc //" ld/testsuite/ld-selective/selective.exp

mkdir -v ../binutils-build

cd ../binutils-build

../binutils-2.22/configure --prefix=/usr --enable-shared

make tooldir=/usr

make -k check

make tooldir=/usr install

cp -v ../binutils-2.22/include/libiberty.h /usr/include

cd $LFS/sources

######fin binutils######

######gmp######

cd gmp-5.0.4

./configure --prefix=/usr --enable-cxx --enable-mpbsd

make

make check 2>&1 | tee gmp-check-log

Page 30: 22.-LFS automatico.pdf

awk '/tests passed/{total+=$2} ; END{print total}' gmp-check-log

make install

mkdir -v /usr/share/doc/gmp-5.0.4

cp -v doc/{isa_abi_headache,configuration} doc/*.html \

/usr/share/doc/gmp-5.0.4

cd $LFS/sources

#####fin Gmp######

######mpfr######

cd mpfr-3.1.0

patch -Np1 -i ../mpfr-3.1.0-fixes-1.patch

./configure --prefix=/usr --enable-thread-safe \

--docdir=/usr/share/doc/mpfr-3.1.0

make

make check

make install

make html

make install-html

cd $LFS/soruces

######Fin mpfr######

######mpc######

cd mpc-0.9

./configure --prefix=/usr

make

make check

make install

cd $LFS/sources

######Fin mpc######

Page 31: 22.-LFS automatico.pdf

#######gcc#######

cd gcc-4.6.2

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 's@\./fixinc\.sh@-c true@' gcc/Makefile.in

mkdir -v ../gcc-build

cd ../gcc-build

../gcc-4.6.2/configure --prefix=/usr \

--libexecdir=/usr/lib --enable-shared \

--enable-threads=posix --enable-__cxa_atexit \

--enable-clocale=gnu --enable-languages=c,c++ \

--disable-multilib --disable-bootstrap --with-system-zlib

make

ulimit -s 16384

make -k check

../gcc-4.6.2/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'

grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log

grep -B4 '^ /usr/include' dummy.log

Page 32: 22.-LFS automatico.pdf

grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'

grep "/lib.*/libc.so.6 " dummy.log

grep found dummy.log

rm -v dummy.c a.out dummy.log

rm -rf gcc-build

cd $LFS/sources

######Fin gcc######

######sed######

cd sed-4.2.1

./configure --prefix=/usr --bindir=/bin --htmldir=/usr/share/doc/sed-4.2.1

make

make html

make check

make install

make -C doc install-html

cd $LFS/sources

######Fin sed######

######bzip2######

cd bzip2-1.0.6

patch -Np1 -i ../bzip2-1.0.6-install_docs-1.patch

sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile

make -f Makefile-libbz2_so

make clean

make

make PREFIX=/usr install

cp -v bzip2-shared /bin/bzip2

cp -av libbz2.so* /lib

Page 33: 22.-LFS automatico.pdf

ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so

rm -v /usr/bin/{bunzip2,bzcat,bzip2}

ln -sv bzip2 /bin/bunzip2

ln -sv bzip2 /bin/bzcat

cd $LFS/sources

######Fin bzip2######

######Ncurses#######

cd ncurses-5.9

./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.9

cp -v -R doc/* /usr/share/doc/ncurses-5.9

make distclean

Page 34: 22.-LFS automatico.pdf

./configure --prefix=/usr --with-shared --without-normal \

--without-debug --without-cxx-binding

make sources libs

cp -av lib/lib*.so.5* /usr/lib

cd $LFS/sources

#######Fin ncurses######

######Util-linux######

tar -jxvf util-linux-2.2.1.tar.bz2

cd util-linux-2.2.1

sed -e 's@etc/adjtime@var/lib/hwclock/adjtime@g' \

-i $(grep -rl '/etc/adjtime' .)

mkdir -pv /var/lib/hwclock

./configure --enable-arch --enable-partx --enable-write

make

make install

cd $LFS/sources

######fin util-liunx######

######psmisc######

tar -zxvf psmisc-22.15.tar.gz

cd psmisc-22.15

./configure --prefix=/usr

make

make install

mv -v /usr/bin/fuser /bin

mv -v /usr/bin/killall /bin

cd $LFs/sources

Page 35: 22.-LFS automatico.pdf

######Fin psmisc#######

######e2fsprogs######

tar -zxvf e2fsprogs-1.42.tar.gz

cd e2fsprogs

mkdir -v build

cd build

PKG_CONFIG=/tools/bin/true LDFLAGS="-lblkid -luuid" \

../configure --prefix=/usr --with-root-prefix="" \

--enable-elf-shlibs --disable-libblkid --disable-libuuid \

--disable-uuidd --disable-fsck

make

make check

make install

make install-libs

chmod -v u+w /usr/lib/{libcom_err,libe2p,libext2fs,libss}.a

gunzip -v /usr/share/info/libext2fs.info.gz

install-info --dir-file=/usr/share/info/dir \

/usr/share/info/libext2fs.info

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 $LFS/sources

###### Fin e2fsprogs######

######coreutils######

cd coreutils-8.15

Page 36: 22.-LFS automatico.pdf

case `uname -m` in

i?86 | x86_64) patch -Np1 -i ../coreutils-8.15-uname-1.patch ;;

esac

patch -Np1 -i ../coreutils-8.15-i18n-1.patch

./configure --prefix=/usr \

--libexecdir=/usr/lib \

--enable-no-install-program=kill,uptime

make

make NON_ROOT_USERNAME=nobody check-root

echo "dummy:x:1000:nobody" >> /etc/group

chown -Rv nobody .

su-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/share/man/man1/chroot.1 /usr/share/man/man8/chroot.8

sed -i s/\"1\"/\"8\"/1 /usr/share/man/man8/chroot.8

mv -v /usr/bin/{head,sleep,nice} /bin

cd $LFS/sources

######Fin coreutils######

######iana-etc######

tar -jxvf iana-etc-2.30.tar.bz2

cd iana-etc-2.30

make

Page 37: 22.-LFS automatico.pdf

make install

cd $LFS/sources

######Fin iana-etc######

######M4#######

cd m4-1.4.16

./configure --prefix=/usr

make

sed -i -e '41s/ENOENT/& || errno == EINVAL/' tests/test-readlink.h

make check

make install

cd $LFS/sources

######Fin M4######

######Bison######

tar -jxvf bison-2.5.tar.bz2

cd bison-2.5

./configure --prefix=/usr

echo '#define YYENABLE_NLS 1' >> lib/config.h

make

make check

make install

cd $LFS/sources

######Fin Bison######

######Procps#######

tar -zxvf procps-3.2.8.tar.gz

cd procps-3.2.8

patch -Np1 -i ../procps-3.2.8-fix_HZ_errors-1.patch

patch -Np1 -i ../procps-3.2.8-watch_unicode-1.patch

Page 38: 22.-LFS automatico.pdf

sed -i -e 's@\*/module.mk@proc/module.mk ps/module.mk@' Makefile

make

make install

cd $LFS/sources

######Fin procps######

######Grep######

cd grep-2.10

sed -i 's/cp/#&/' tests/unibyte-bracket-expr

./configure --prefix=/usr --bindir=/bin

make

make check

make install

cd $LFS/sources

######Fin Grep######

######readline######

cd readline-6.2

sed -i '/MV.*old/d' Makefile.in

sed -i '/{OLDSUFF}/c:' support/shlib-install

patch -Np1 -i ../readline-6.2-fixes-1.patch

./configure --prefix=/usr --libdir=/lib

make SHLIB_LIBS=-lncurses

make install

mv -v /lib/lib{readline,history}.a /usr/lib

rm -v /lib/lib{readline,history}.so

ln -sfv ../../lib/libreadline.so.6 /usr/lib/libreadline.so

ln -sfv ../../lib/libhistory.so.6 /usr/lib/libhistory.so

mkdir -v /usr/share/doc/readline-6.2

Page 39: 22.-LFS automatico.pdf

install -v -m644 doc/*.{ps,pdf,html,dvi} \

/usr/share/doc/readline-6.2

cd $LFS/sources

######Fin readline######

######bash######

cd bash-4.2

patch -Np1 -i ../bash-4.2-fixes-4.patch

./configure --prefix=/usr --bindir=/bin \

--htmldir=/usr/share/doc/bash-4.2 --without-bash-malloc \

--with-installed-readline

make

chown -Rv nobody .

su-tools nobody -s /bin/bash -c "make tests"

make install

exec /bin/bash --login +h

cd $LFS/sources

######Fin Bash######

######Libtool######

tar -zxvf libtool-2.4.2.tar.gz

cd libtool-2.4.2

./configure --prefix=/usr

make

make check

make install

cd $LFS/sources

######Fin libtool######

######gdbm######

Page 40: 22.-LFS automatico.pdf

tar -zxvf gdbm-1.10.tar.gz

cd gdbm-1.10

./configure --prefix=/usr --enable-libgdbm-compat

make

make check

make install

cd $LFS/sources

#####Fin gdbm######

######ineutils######

tar -zxvf inetutils-1.9.1.tar.gz

cd inetutils-1.9.1

./configure --prefix=/usr --libexecdir=/usr/sbin \

--localstatedir=/var --disable-ifconfig \

--disable-logger --disable-syslogd --disable-whois \

--disable-servers

make

make check

make install

make -C doc html

make -C doc install-html docdir=/usr/share/doc/inetutils-1.9.1

mv -v /usr/bin/{hostname,ping,ping6} /bin

mv -v /usr/bin/traceroute /sbin

cd $LFS/sources

######fin inetutils######

######perl######

cd perl-5.14.2

Page 41: 22.-LFS automatico.pdf

echo "127.0.0.1 localhost $(hostname)" > /etc/hosts

patch -Np1 -i ../perl-5.14.2-security_fix-1.patch

sed -i -e "s|BUILD_ZLIB\s*= True|BUILD_ZLIB = False|" \

-e "s|INCLUDE\s*= ./zlib-src|INCLUDE = /usr/include|" \

-e "s|LIB\s*= ./zlib-src|LIB = /usr/lib|" \

cpan/Compress-Raw-Zlib/config.in

sh Configure -des -Dprefix=/usr \

-Dvendorprefix=/usr \

-Dman1dir=/usr/share/man/man1 \

-Dman3dir=/usr/share/man/man3 \

-Dpager="/usr/bin/less -isR" \

-Duseshrplib

make

make test

make install

cd $LFS/soruces

######fin perl######

#######autoconf######

tar -jxvf autoconf-2.68.tar.bz2

cd autoconf-2.68

./configure --prefix=/usr

make

make check

make install

cd $LFS/sources

######fin autoconf######

Page 42: 22.-LFS automatico.pdf

######automake######

tar -Jxvf automake-1.11.3.tar.bz2

cd automake -1.11.3

./configure --prefix=/usr --docdir=/usr/share/doc/automake-1.11.3

make

make check

make install

cd $LFS/sources

######fin automake######

######diffutils######

cd diffutils-3.2

./configure --prefix=/usr

make

make check

make install

cd $LFS/sources

#######fin diffutils######

#######gawk#######

cd gawk-4.0.0

./configure --prefix=/usr --libexecdir=/usr/lib

make

make check

make install

mkdir -v /usr/share/doc/gawk-4.0.0

cp -v doc/{awkforai.txt,*.{eps,pdf,jpg}} \

/usr/share/doc/gawk-4.0.0

cd $LFS/sources

Page 43: 22.-LFS automatico.pdf

######fin gawk######

######findutils######

cd findutils-4.4.2

./configure --prefix=/usr --libexecdir=/usr/lib/findutils \

--localstatedir=/var/lib/locate

make

make check

make install

mv -v /usr/bin/find /bin

sed -i 's/find:=${BINDIR}/find:=\/bin/' /usr/bin/updatedb

cd $LFS/sources

######fin findutils######

######flex######

tar -jxvf flex-2.5.35.tar.bz2

cd flex-2.5.35

patch -Np1 -i ../flex-2.5.35-gcc44-1.patch

./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

Page 44: 22.-LFS automatico.pdf

EOF

chmod -v 755 /usr/bin/lex

mkdir -v /usr/share/doc/flex-2.5.35

cp -v doc/flex.pdf \

/usr/share/doc/flex-2.5.35

cd $LFS/sources

######fin flex######

######gettext######

cd gettext-0.18.1.1

./configure --prefix=/usr \

--docdir=/usr/share/doc/gettext-0.18.1.1

make

make check

make install

cd $LFS/sources

######fin gettext#######

######groff######

tar -zxvf groff-1.21.tar.gz

cd groff-1.21

PAGE=A4 ./configure --prefix=/usr

make

make install

ln -sv eqn /usr/bin/geqn

ln -sv tbl /usr/bin/gtbl

cd $LFS/sources

######fin groff######

Page 45: 22.-LFS automatico.pdf

######xz######

cd xz-5.0.3

./configure --prefix=/usr --libdir=/lib --docdir=/usr/share/doc/xz-5.0.3

make

make check

make pkgconfigdir=/usr/lib/pkgconfig install

cd $LFS/sources

######fin xz######

######grub######

tar -zxvf grub-1.99.tar.gz

cd grub-1.99

/configure --prefix=/usr \

--sysconfdir=/etc \

--disable-grub-emu-usb \

--disable-efiemu \

--disable-werror

make

make install

cd $LFS/sources

######fin grub######

######gzip#######

cd gzip-1.4

./configure --prefix=/usr --bindir=/bin

make

make check

Page 46: 22.-LFS automatico.pdf

make install

mv -v /bin/{gzexe,uncompress,zcmp,zdiff,zegrep} /usr/bin

mv -v /bin/{zfgrep,zforce,zgrep,zless,zmore,znew} /usr/bin

cd $LFS/sources

######fin gzip#######

######iproute2######

tar -Jxvf iproute2-3.2.0.tar.xz

cd iproute2-3.2.0

sed -i '/^TARGETS/s@arpd@@g' misc/Makefile

sed -i /ARPD/d Makefile

rm man/man8/arpd.8

sed -i -e '/netlink\//d' ip/ipl2tp.c

make DESTDIR=

make DESTDIR= MANDIR=/usr/share/man \

DOCDIR=/usr/share/doc/iproute2-3.2.0 install

cd $LFS/sources

######Fin iproute2######

######kdb#######

tar -zxvf kdb-1.15.2.tar.gz

cd kdb-1.15.2

patch -Np1 -i ../kbd-1.15.2-backspace-1.patch

./configure --prefix=/usr --datadir=/lib/kbd

make

make install

mv -v /usr/bin/{kbd_mode,loadkeys,openvt,setfont} /bin

mkdir -v /usr/share/doc/kbd-1.15.2

cp -R -v doc/* \

Page 47: 22.-LFS automatico.pdf

/usr/share/doc/kbd-1.15.2

cd $LFS/sources

######fin kdb######

######kmod######

tar -Jxvf kmod-5.tar.xz

cd kmod-5

liblzma_CFLAGS="-I/usr/include" \

liblzma_LIBS="-L/lib -llzma" \

zlib_CFLAGS="-I/usr/include" \

zlib_LIBS="-L/lib -lz" \

./configure --prefix=/usr --bindir=/bin --libdir=/lib --sysconfdir=/etc \

--with-xz --with-zlib

make

make check

make pkgconfigdir=/usr/lib/pkgconfig install

for target in depmod insmod modinfo modprobe rmmod; do

ln -sv ../bin/kmod /sbin/$target

done

ln -sv kmod /bin/lsmod

cd $LFS/sources

######fin kmod######

######less######

tar -zxvd less-444.tar.gz

cd less-444

./configure --prefix=/usr --sysconfdir=/etc

make

make install

Page 48: 22.-LFS automatico.pdf

cd $LFS/sources

######Fin less######

######libpipeline######

tar -zxvf libpipeline-1.2.0.tar.gz

cd libpipeline-1.2.0

/configure CHECK_CFLAGS=-I/tools/include \

CHECK_LIBS="-L/tools/lib -lcheck" --prefix=/usr

make

make check

make install

cd $LFS/sources

######Fin libpipeline######

######make######

cd make-3.82

./configure --prefix=/usr

make

make check

make install

cd $LFS/sources

######fin make######

######patch######

cd patch-2.6.1

patch -Np1 -i ../patch-2.6.1-test_fix-1.patch

./configure --prefix=/usr

make

make check

make install

Page 49: 22.-LFS automatico.pdf

cd $LFS/sources

######Fin patch######

######shadow######

tar -jxvf shadow-4.1.5.tar.bz2

cd shadow-4.1.5

patch -Np1 -i ../shadow-4.1.5-nscd-1.patch

sed -i 's/groups$(EXEEXT) //' src/Makefile.in

find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \;

sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' \

-e 's@/var/spool/mail@/var/mail@' etc/login.defs

sed -i 's@DICTPATH.*@DICTPATH\t/lib/cracklib/pw_dict@' \

etc/login.defs

./configure --sysconfdir=/etc

make

make install

mv -v /usr/bin/passwd /bin

pwconv

grpconv

sed -i 's/yes/no/' /etc/default/useradd

passwd root

cd $LFS/sources

######Fin shadow######

######sysklogd######

tar -jxvf shadow-4.1.5.tar.bz2

cd shadow-4.1.5

make

Page 50: 22.-LFS automatico.pdf

make BINDIR=/sbin 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 *

# End /etc/syslog.conf

EOF

cd $LFS/sources

######fin shadow######

######sysvinit######

tar -jxvf sysvinit-2.88dsf.tar.bz2

cd sysvinit-2.88dsf

sed -i 's@Sending processes@& configured via /etc/inittab@g' \

src/init.c

sed -i -e 's/utmpdump wall/utmpdump/' \

-e '/= mountpoint/d' \

-e 's/mountpoint.1 wall.1//' src/Makefile

make -C src

make -C src install

cd $LFS/sources

######Fin sysvinit######

######tar######

Page 51: 22.-LFS automatico.pdf

cd tar-1.26

FORCE_UNSAFE_CONFIGURE=1 ./configure --prefix=/usr \

--bindir=/bin --libexecdir=/usr/sbin

make

make check

make install

make -C doc install-html docdir=/usr/share/doc/tar-1.26

cd $LFS/sources

######Fin tar######

######Texinfo######

cd texinfo-4.13a

./configure --prefix=/usr

make

make check

make install

make TEXMF=/usr/share/texmf install-tex

cd /usr/share/info

rm -v dir

for f in *

do install-info $f dir 2>/dev/null

done

cd $LFS/sources

######fin texinfo######

###### udev######

tar -Jxvf udev-181.tar.xz

cd udev-181

tar -xvf ../udev-config-20100128.tar.bz2

Page 52: 22.-LFS automatico.pdf

install -dv /lib/{firmware,udev/devices/pts}

mknod -m0666 /lib/udev/devices/null c 1 3

BLKID_CFLAGS="-I/usr/include/blkid" \

BLKID_LIBS="-L/lib -lblkid" \

KMOD_CFLAGS="-I/usr/include" \

KMOD_LIBS="-L/lib -lkmod" \

./configure --prefix=/usr \

--with-rootprefix='' \

--bindir=/sbin \

--sysconfdir=/etc \

--libexecdir=/lib \

--enable-rule_generator \

--disable-introspection \

--disable-keymap \

--disable-gudev \

--with-usb-ids-path=no \

--with-pci-ids-path=no \

--with-systemdsystemunitdir=no

make

make check

make install

rmdir -v /usr/share/doc/udev

cd udev-config-20100128

make install

make install-doc

cd $LFS/sources

######fin udev######

Page 53: 22.-LFS automatico.pdf

######vim#######

tar -jxvf vim-7.3.tar.bz2

cd vim-7.3

echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h

./configure --prefix=/usr --enable-multibyte

make

make test

make install

ln -sv vim /usr/bin/vi

for L in /usr/share/man/{,*/}man1/vim.1; do

ln -sv vim.1 $(dirname $L)/vi.1

done

ln -sv ../vim/vim73/doc /usr/share/doc/vim-7.3

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

vim -c ':options'

logout

chroot $LFS /tools/bin/env -i \

HOME=/root TERM=$TERM PS1='\u:\w\$ ' \

Page 54: 22.-LFS automatico.pdf

PATH=/bin:/usr/bin:/sbin:/usr/sbin \

/tools/bin/bash --login

/tools/bin/find /{,usr/}{bin,lib,sbin} -type f \

-exec /tools/bin/strip --strip-debug '{}' ';'

chroot "$LFS" /usr/bin/env -i \

HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \

PATH=/bin:/usr/bin:/sbin:/usr/sbin \

/bin/bash --login

cd $LFS/sources

######FIN VIM######

#######punto 7#######

for NIC in /sys/class/net/* ; do

INTERFACE=${NIC##*/} udevadm test --action=add $NIC

done

cat /etc/udev/rules.d/70-persistent-net.rules

cd /etc/sysconfig/

cat > ifconfig.eth0 << "EOF"

ONBOOT=yes

IFACE=eth0

SERVICE=ipv4-static

IP=192.168.1.1

GATEWAY=192.168.1.2

PREFIX=24

BROADCAST=192.168.1.255

EOF

Page 55: 22.-LFS automatico.pdf

cat > /etc/resolv.conf << "EOF"

# Begin /etc/resolv.conf

domain <Your Domain Name>

nameserver <IP address of your primary nameserver>

nameserver <IP address of your secondary nameserver>

# End /etc/resolv.conf

EOF

cat > /etc/hosts << "EOF"

# Begin /etc/hosts (network card version)

127.0.0.1 localhost

<192.168.1.1> <HOSTNAME.example.org> [alias1] [alias2 ...]

# End /etc/hosts (network card version)

EOF

cat > /etc/hosts << "EOF"

# Begin /etc/hosts (no network card version)

127.0.0.1 <HOSTNAME.example.org> <HOSTNAME> localhost

# End /etc/hosts (no network card version)

EOF

udevadm test /sys/block/hdd

sed -i -e 's/"write_cd_rules"/"write_cd_rules mode"/' \

/lib/udev/rules.d/75-cd-aliases-generator.rules

udevadm info -a -p /sys/class/video4linux/video0

cat > /etc/udev/rules.d/83-duplicate_devs.rules << "EOF"

# Persistent symlinks for webcam and tuner

KERNEL=="video*", ATTRS{idProduct}=="1910", ATTRS{idVendor}=="0d81", \

SYMLINK+="webcam"

KERNEL=="video*", ATTRS{device}=="0x036f", ATTRS{vendor}=="0x109e", \

Page 56: 22.-LFS automatico.pdf

SYMLINK+="tvtuner"

EOF

#######LFS-Bootscripts#######

tar -jxvf lfs-bootscripts-20120229.tar.bz2

cd lfs-bootscripts-20120229

make install

cd $LFS/sources

######FIN LFS-Bootscripts#######

cat > /etc/inittab << "EOF"

# Begin /etc/inittab

id:3:initdefault:

si::sysinit:/etc/rc.d/init.d/rc S

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 --noclear tty1 9600

2:2345:respawn:/sbin/agetty tty2 9600

3:2345:respawn:/sbin/agetty tty3 9600

4:2345:respawn:/sbin/agetty tty4 9600

5:2345:respawn:/sbin/agetty tty5 9600

Page 57: 22.-LFS automatico.pdf

6:2345:respawn:/sbin/agetty tty6 9600

# End /etc/inittab

EOF

echo "HOSTNAME=<lfs>" > /etc/sysconfig/network

cat > /etc/sysconfig/clock << "EOF"

# Begin /etc/sysconfig/clock

UTC=1

# Set this to any options you might need to give to hwclock,

# such as machine hardware clock type for Alphas.

CLOCKPARAMS=

# End /etc/sysconfig/clock

EOF

cat > /etc/sysconfig/console << "EOF"

# Begin /etc/sysconfig/console

KEYMAP="pl2"

FONT="lat2a-16 -m 8859-2"

# End /etc/sysconfig/console

EOF

cat > /etc/sysconfig/console << "EOF"

# Begin /etc/sysconfig/console

KEYMAP="de-latin1"

KEYMAP_CORRECTIONS="euro2"

FONT="lat0-16 -m 8859-15"

# End /etc/sysconfig/console

EOF

cat > /etc/sysconfig/console << "EOF"

# Begin /etc/sysconfig/console

Page 58: 22.-LFS automatico.pdf

UNICODE="1"

KEYMAP="bg_bds-utf8"

FONT="LatArCyrHeb-16"

# End /etc/sysconfig/console

EOF

cat > /etc/sysconfig/console << "EOF"

# Begin /etc/sysconfig/console

UNICODE="1"

KEYMAP="bg_bds-utf8"

FONT="cyr-sun16"

# End /etc/sysconfig/console

EOF

cat > /etc/sysconfig/console << "EOF"

# Begin /etc/sysconfig/console

UNICODE="1"

KEYMAP="de-latin1"

KEYMAP_CORRECTIONS="euro2"

LEGACY_CHARSET="iso-8859-15"

FONT="LatArCyrHeb-16 -m 8859-15"

# End /etc/sysconfig/console

EOF

locale -a

LC_ALL=<locale name> locale charmap

LC_ALL=<locale name> locale language

LC_ALL=<locale name> locale charmap

LC_ALL=<locale name> locale int_curr_symbol

LC_ALL=<locale name> locale int_prefix

Page 59: 22.-LFS automatico.pdf

cat > /etc/profile << "EOF"

# Begin /etc/profile

export LANG=<ll>_<CC>.<charmap><@modifiers>

# End /etc/profile

EOF

cat > /etc/inputrc << "EOF"

# Begin /etc/inputrc

# Modified by Chris Lynn <[email protected]>

# Allow the command prompt to wrap to the next line

set horizontal-scroll-mode Off

# Enable 8bit input

set meta-flag On

set input-meta On

# Turns off 8th bit stripping

set convert-meta Off

# Keep the 8th bit for display

set output-meta On

# none, visible or audible

set bell-style none

# All of the following map the escape sequence of the value

# contained in the 1st argument to the readline specific functions

"\eOd": backward-word

"\eOc": forward-word

# for linux console

"\e[1~": beginning-of-line

"\e[4~": end-of-line

"\e[5~": beginning-of-history

Page 60: 22.-LFS automatico.pdf

"\e[6~": end-of-history

"\e[3~": delete-char

"\e[2~": quoted-insert

# for xterm

"\eOH": beginning-of-line

"\eOF": end-of-line

# for Konsole

"\e[H": beginning-of-line

"\e[F": end-of-line

# End /etc/inputrc

EOF

########PUNTO 8########

cat > /etc/fstab << "EOF"

# Begin /etc/fstab

# file system mount-point type options dump fsck

# order

/dev/<xxx> / <fff> defaults 1 1

/dev/<yyy> swap swap pri=1 0 0

proc /proc proc nosuid,noexec,nodev 0 0

sysfs /sys sysfs nosuid,noexec,nodev 0 0

devpts /dev/pts devpts gid=4,mode=620 0 0

tmpfs /run tmpfs defaults 0 0

devtmpfs /dev devtmpfs mode=0755,nosuid 0 0

# End /etc/fstab

EOF

hdparm -I /dev/sda | grep NCQ

Page 61: 22.-LFS automatico.pdf

cd linux-3.2.6

make mrproper

make LANG=<host_LANG_value> LC_ALL= menuconfig

make

cp -v arch/x86/boot/bzImage /boot/vmlinuz-3.2.6-lfs-7.1

cp -v System.map /boot/System.map-3.2.6

cp -v .config /boot/config-3.2.6

install -d /usr/share/doc/linux-3.2.6

cp -r Documentation/* /usr/share/doc/linux-3.2.6

install -v -m755 -d /etc/modprobe.d

cat > /etc/modprobe.d/usb.conf << "EOF"

# Begin /etc/modprobe.d/usb.conf

install ohci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i ohci_hcd ; true

install uhci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i uhci_hcd ; true

# End /etc/modprobe.d/usb.conf

EOF

cd $LFS/sources

cd /tmp &&

grub-mkrescue --output=grub-img.iso &&

xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso

grub-mkdevicemap --device-map=device.map

cat device.map

grub-install $particion1

cat > /boot/grub/grub.cfg << "EOF"

# Begin /boot/grub/grub.cfg

set default=0

set timeout=5

Page 62: 22.-LFS automatico.pdf

insmod ext2

set root=(hd0,2)

menuentry "GNU/Linux, Linux 3.2.6-lfs-7.1" {

linux /boot/vmlinuz-3.2.6-lfs-7.1 root=/dev/sda2 ro

}

EOF

########FIN PUNTO 8########

#########punto9#########

echo 7.1 > /etc/lfs-release

init 6

$LFS/sources

logout

umount -v $LFS/dev/pts

umount -v $LFS/dev/shm

umount -v $LFS/dev

umount -v $LFS/proc

umount -v $LFS/sys

umount -v $LFS

umount -v $LFS/usr

umount -v $LFS/home

umount -v $LFS

shutdown -r now

#########FIN PUNTO 9#########