Sıfırdan Linux 7 - Sistem İnşası


Sistemi inşa etmeye başlayalım.








Bu yazının başından sonuna kadar uçbirimi hiç kapatmayın. Kapatırsanız "Başlıyoruz" dediğim yere kadarki geçiş ve mountları tekrar yapmanız gerekir.

su -

En son root idik. Gerekli klasörler ve bağlantılar


export LFS=/mnt/lfs
mkdir -pv $LFS/{dev,proc,sys,run}

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 -o gid=5,mode=620
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
mount -vt tmpfs tmpfs $LFS/run

if [ -h $LFS/dev/shm ]; then
mkdir -pv $LFS/$(readlink $LFS/dev/shm)
fi

Ve bu da I have no name! demeli:

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
_____________________________________________________________________________

Başlıyoruz:

mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib,mnt,opt}
mkdir -pv /{media/{floppy,cdrom},sbin,srv,var}
install -dv -m 0750 /root
install -dv -m 1777 /tmp /var/tmp
mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src}
mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man}
mkdir -v /usr/{,local/}share/{misc,terminfo,zoneinfo}
mkdir -v /usr/libexec
mkdir -pv /usr/{,local/}share/man/man{1..8}
case $(uname -m) in
x86_64) ln -sv lib /lib64
&&
ln -sv lib /usr/lib64 &&
ln -sv lib /usr/local/lib64 ;;
esac
mkdir -v /var/{log,mail,spool}
ln -sv /run /var/run
ln -sv /run/lock /var/lock
mkdir -pv /var/{opt,cache,lib/{color,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

ln -sv /proc/self/mounts /etc/mtab

Bir komut olarak

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

Bir komut:

cat > /etc/group << "EOF"
root:x:0:
bin:x:1:
sys:x:2:
kmem:x:3:
tape:x:4:
tty:x:5:
daemon:x:6:
floppy:x:7:
disk:x:8:
lp:x:9:
dialout:x:10:
audio:x:11:
video:x:12:
utmp:x:13:
usb:x:14:
cdrom:x:15:
mail:x:34:
nogroup:x:99:
EOF

root olalım:

exec /tools/bin/bash --login +h

touch /var/log/{btmp,lastlog,wtmp}
chgrp -v utmp /var/log/lastlog
chmod -v 664 /var/log/lastlog
chmod -v 600 /var/log/btmp

cd /sources/linux-3.13.3

make mrproper

make headers_check
make INSTALL_HDR_PATH=dest headers_install
find dest/include \( -name .install -o -name ..install.cmd \) -delete
cp -rv dest/include/* /usr/include
___________________________________________________________________________

man-pages'i yükleyelim:

cd /sources
tar -Jxf man-pages-3.59.tar.xz
cd man-pages-3.59

make install
___________________________________________________________________________

glibc'de ikinci tur biraz uzun sürecek

cd /sources/glibc-2.19
sed -i 's/\\$$(pwd)/`pwd`/' timezone/Makefile
patch -Np1 -i ../glibc-2.19-fhs-1.patch

mkdir -v ../glibc-build2
cd ../glibc-build2

../glibc-2.19/configure --prefix=/usr --disable-profile --enable-kernel=2.6.32 --enable-obsolete-rpc

make

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

touch /etc/ld.so.conf

make install

cp -v ../glibc-2.19/nscd/nscd.conf /etc/nscd.conf
mkdir -pv /var/cache/nscd

Yerelleştirmeler:

mkdir -pv /usr/lib/locale
localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8
localedef -i de_DE -f ISO-8859-1 de_DE
localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
localedef -i de_DE -f UTF-8 de_DE.UTF-8
localedef -i en_GB -f UTF-8 en_GB.UTF-8
localedef -i en_HK -f ISO-8859-1 en_HK
localedef -i en_PH -f ISO-8859-1 en_PH
localedef -i en_US -f ISO-8859-1 en_US
localedef -i en_US -f UTF-8 en_US.UTF-8
localedef -i es_MX -f ISO-8859-1 es_MX
localedef -i fa_IR -f UTF-8 fa_IR
localedef -i fr_FR -f ISO-8859-1 fr_FR
localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro
localedef -i fr_FR -f UTF-8 fr_FR.UTF-8
localedef -i it_IT -f ISO-8859-1 it_IT
localedef -i it_IT -f UTF-8 it_IT.UTF-8
localedef -i ja_JP -f EUC-JP ja_JP
localedef -i ru_RU -f KOI8-R ru_RU.KOI8-R
localedef -i ru_RU -f UTF-8 ru_RU.UTF-8
localedef -i tr_TR -f UTF-8 tr_TR.UTF-8
localedef -i zh_CN -f GB18030 zh_CN.GB18030

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
services: files
ethers: files
rpc: files
# End /etc/nsswitch.conf
EOF

tar -xf ../tzdata2013i.tar.gz
ZONEINFO=/usr/share/zoneinfo
mkdir -pv $ZONEINFO/{posix,right}

for tz in etcetera southamerica northamerica europe africa antarctica asia australasia backward pacificnew systemv; do
zic -L /dev/null -d $ZONEINFO -y "sh yearistype.sh" ${tz}
zic -L /dev/null -d $ZONEINFO/posix -y "sh yearistype.sh" ${tz}
zic -L leapseconds -d $ZONEINFO/right -y "sh yearistype.sh" ${tz}
done

cp -v zone.tab iso3166.tab $ZONEINFO
zic -d $ZONEINFO -p Europe/Istanbul
unset ZONEINFO

TZ='Europe/Istanbul'; export TZ

cp -v /usr/share/zoneinfo/Europe/Istanbul /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 -pv /etc/ld.so.conf.d

mv -v /tools/bin/{ld,ld-old}
mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}
mv -v /tools/bin/{ld-new,ld}
ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld

gcc -dumpspecs | sed -e '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'

Bize [Requesting program interpreter: /lib/ld-linux.so.2] cevabını dönmeli.

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

Eğer found ld-linux.so.2 at /lib/ld-linux.so.2 dediyse her şey iyi gidiyor demektir.

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

___________________________________________________________________________

zlib için

cd /sources
tar -Jxf zlib-1.2.8.tar.xz
cd zlib-1.2.8

./configure --prefix=/usr

make
make check
make install

mv -v /usr/lib/libz.so.* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libz.so) /usr/lib/libz.so
___________________________________________________________________________

file için

cd /sources/file-5.17
./configure --prefix=/usr

make
make check
make install
___________________________________________________________________________


rm -fv etc/standards.info

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

Bende Makefile.in yok hatası verdi.

patch -Np1 -i ../binutils-2.24-load_gcc_lto_plugin_by_default-1.patch

patch -Np1 -i ../binutils-2.24-lto_testsuite-1.patch

mkdir -v ../binutils-build3
cd ../binutils-build3

../binutils-2.24/configure --prefix=/usr --enable-shared --disable-werror

make tooldir=/usr
make check
make tooldir=/usr install
___________________________________________________________________________

gmp için

cd /sources
tar -Jxf gmp-5.1.3.tar.xz
cd gmp-5.1.3
./configure --prefix=/usr --enable-cxx
make
make check 2>&1 | tee gmp-check-log
awk '/tests passed/{total+=$2} ; END{print total}' gmp-check-log
make install

Dediğimde iki hata verdi. /usr/lib klasörüne yüklenmediğini gördüm.

mkdir -v /usr/share/doc/gmp-5.1.3
cp -v doc/{isa_abi_headache,configuration} doc/*.html /usr/share/doc/gmp-5.1.3
___________________________________________________________________________

mpfr için

cd /sources
tar -Jxf mpfr-3.1.2.tar.xz

Yapılandırma komutunda gmp.h dosyasını bulamadığı hatasını veriyor.

./configure --prefix=/usr --enable-thread-safe --docdir=/usr/share/doc/mpfr-3.1.2

Ve gmp'nin verdiği iki hatadan beklediğim üzere mpfr de yüklenmedi.

İlk fırsatta bu hataların üzerine gidip yazıyı düzenleyeceğim.





Hiç yorum yok :


Yorum Gönder