linux:lfs

Ceci est une ancienne révision du document !


Linux From Scratch

http://fr.linuxfromscratch.org/view/lfs-9.1-systemd-fr/index.html

Fonctionnement général: à partir d'un système existant, on construit LFS sur une partition à côté du système existant. On pourra ensuite booter sur LFS situé sur la nouvelle partition.

Dans une machine virtuelle avec 80 Go de stockage et 2 Go de RAM, installer une Debian Stable, en partitionnant comme suit:

  • 20 Go pour le système hôte, type ext4, monté sur / avec l'indicateur d'amorçage
  • 55 Go pour LFS, type ext4, non monté
  • le reste pour le swap

Exécuter le script fournit ici.

Correction à apporter:

  • faire pointer /bin/sh vers bash au lieu de dash (Source):
    sudo dpkg-reconfigure dash
  • installer les paquets build-essential bison gawk m4 texinfo
export LFS=/mnt/lfs
sudo mkdir -pv $LFS
sudo mount -v -t ext4 /dev/<xxx> $LFS
sudo mkdir -v $LFS/sources
sudo chmod -v a+wt $LFS/sources
wget http://fr.linuxfromscratch.org/view/lfs-9.1-systemd-fr/wget-list
sudo wget --input-file=wget-list --continue --directory-prefix=$LFS/sources

Passer root, c'est bien plus simple (ne pas oublier de définir $LFS !).

mkdir -v $LFS/tools
ln -sv $LFS/tools / # '/tools' -> '/mnt/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

Se connecter avec l'utilisateur lfs.

~/.bash_profile
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
~/.bashrc
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=$(uname -m)-lfs-linux-gnu
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL LFS_TGT PATH
source ~/.bash_profile

Si on redémarre la machine maintenant, il faut monter la partition dans $LFS et se connecter avec l'utilisateur lfs, tout est déjà défini.

cd $LFS/sources/
tar fxv binutils-2.34.tar.xz
cd binutils-2.34
mkdir build
cd build
../configure --prefix=/tools --with-sysroot=$LFS --with-lib-path=/tools/lib --target=$LFS_TGT --disable-nls --disable-werror
make 
mkdir -v /tools/lib && ln -sv lib /tools/lib64
make install
cd $LFS/sources/
tar xfv gcc-9.2.0.tar.xz
cd gcc-9.2.0
 
tar -xf ../mpfr-4.0.2.tar.xz
mv -v mpfr-4.0.2 mpfr
tar -xf ../gmp-6.2.0.tar.xz
mv -v gmp-6.2.0 gmp
tar -xf ../mpc-1.1.0.tar.gz
mv -v mpc-1.1.0 mpc
 
for file in gcc/config/{linux,i386/linux{,64}}.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_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
  touch $file.orig
done
 
sed -e '/m64=/s/lib64/lib/' \
        -i.orig gcc/config/i386/t-linux64
 
mkdir build
cd build
 
../configure                                       \
    --target=$LFS_TGT                              \
    --prefix=/tools                                \
    --with-glibc-version=2.11                      \
    --with-sysroot=$LFS                            \
    --with-newlib                                  \
    --without-headers                              \
    --with-local-prefix=/tools                     \
    --with-native-system-header-dir=/tools/include \
    --disable-nls                                  \
    --disable-shared                               \
    --disable-multilib                             \
    --disable-decimal-float                        \
    --disable-threads                              \
    --disable-libatomic                            \
    --disable-libgomp                              \
    --disable-libquadmath                          \
    --disable-libssp                               \
    --disable-libvtv                               \
    --disable-libstdcxx                            \
    --enable-languages=c,c++
make
make install 
cd $LFS/sources/
tar xfv linux-5.5.3.tar.xz
cd linux-5.5.3
make mrproper
make headers
cp -rv usr/include/* /tools/include
cd $LFS/sources/
tar xfv glibc-2.31.tar.xz
cd glib-2.31
 
mkdir build
cd build
 
../configure                             \
      --prefix=/tools                    \
      --host=$LFS_TGT                    \
      --build=$(../scripts/config.guess) \
      --enable-kernel=3.2                \
      --with-headers=/tools/include
make
make install
 
 
 
echo 'int main(){}' > dummy.c
$LFS_TGT-gcc dummy.c
readelf -l a.out | grep ': /tools' # doit retourner [Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]
rm dummy.c a.out
cd $LFS/sources/gcc-9.2.0/build
 
../libstdc++-v3/configure           \
    --host=$LFS_TGT                 \
    --prefix=/tools                 \
    --disable-multilib              \
    --disable-nls                   \
    --disable-libstdcxx-threads     \
    --disable-libstdcxx-pch         \
    --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/9.2.0
make
make install
cd $LFS/srouces/binutils-2.34/build
rm -rf *
CC=$LFS_TGT-gcc                \
AR=$LFS_TGT-ar                 \
RANLIB=$LFS_TGT-ranlib         \
../configure                   \
    --prefix=/tools            \
    --disable-nls              \
    --disable-werror           \
    --with-lib-path=/tools/lib \
    --with-sysroot
make
make install
 
make -C ld clean
make -C ld LIB_PATH=/usr/lib:/lib
cp -v ld/ld-new /tools/bin
cd $LFS/sources/gcc-9.2.0
 
cat gcc/limitx.h gcc/glimits.h gcc/limity.h >  `dirname \
  $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h
 
for file in gcc/config/{linux,i386/linux{,64}}.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_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
  touch $file.orig
done
 
sed -e '/m64=/s/lib64/lib/' \
        -i.orig gcc/config/i386/t-linux64
 
sed -e '1161 s|^|//|' \
    -i libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
 
cd build
rm -rf *
CC=$LFS_TGT-gcc                                    \
CXX=$LFS_TGT-g++                                   \
AR=$LFS_TGT-ar                                     \
RANLIB=$LFS_TGT-ranlib                             \
../configure                                       \
    --prefix=/tools                                \
    --with-local-prefix=/tools                     \
    --with-native-system-header-dir=/tools/include \
    --enable-languages=c,c++                       \
    --disable-libstdcxx-pch                        \
    --disable-multilib                             \
    --disable-bootstrap                            \
    --disable-libgomp
make
make install
ln -sv gcc /tools/bin/cc
 
echo 'int main(){}' > dummy.c
cc dummy.c
readelf -l a.out | grep ': /tools' # doit retourner [Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]
rm -v dummy.c a.out
cd $LFS/sources/
tar xfv tcl8.6.10-src.tar.gz
cd tcl8.6.10/unix
./configure --prefix=/tools
make
TZ=UTC make test
make install
chmod -v u+w /tools/lib/libtcl8.6.so
make install-private-headers
ln -sv tclsh8.6 /tools/bin/tclsh
cd $LFS/sources/
tar xfv expect5.45.4.tar.gz
cd expect5.45.4
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/
tar xfv dejagnu-1.6.2.tar.gz
cd dejagnu-1.6.2
./configure --prefix=/tools
make install
make check
cd $LFS/sources/
tar xfv m4-1.4.18.tar.xz
cd m4-1.4.18
sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c
echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h
./configure --prefix=/tools
make
make check
make install
cd $LFS/sources/
tar xfv ncurses-6.2.tar.gz
cd ncurses-6.2
sed -i s/mawk// configure
./configure --prefix=/tools \
            --with-shared   \
            --without-debug \
            --without-ada   \
            --enable-widec  \
            --enable-overwrite
make
make install
ln -s libncursesw.so /tools/lib/libncurses.so
cd $LFS/sources/
tar xfv bash-5.0.tar.gz
cd bash-5.0
./configure --prefix=/tools --without-bash-malloc
make
make tests
make install
ln -sv bash /tools/bin/sh
cd $LFS/sources/
tar xfv bison-3.5.2.tar.xz
cd bison-3.5.2
./configure --prefix=/tools
make
make check
make install
cd $LFS/sources/
tar xfv bzip2-1.0.8.tar.gz
cd bzip2-1.0.8
make -f Makefile-libbz2_so
make clean
make
make PREFIX=/tools install
cp -v bzip2-shared /tools/bin/bzip2
cp -av libbz2.so* /tools/lib
ln -sv libbz2.so.1.0 /tools/lib/libbz2.so
cd $LFS/sources/
tar xfv coreutils-8.31.tar.xz
cd coreutils-8.31
./configure --prefix=/tools --enable-install-program=hostname
make
make install
cd $LFS/sources/
tar xfv diffutils-3.7.tar.xz
cd diffutils-3.7
./configure --prefix=/tools
make
make install
cd $LFS/sources/
tar xfv file-5.38.tar.gz
cd file-5.38
make
make install
cd $LFS/sources/
tar xfv findutils-4.7.0.tar.xz
cd findutils-4.7.0
./configure --prefix=/tools
make
make install
cd $LFS/sources/
tar xfv gawk-5.0.1.tar.xz
cd gawk-5.0.1
./configure --prefix=/tools
make
make install
cd $LFS/sources/
tar xfv gettext-0.20.1.tar.xz
cd gettext-0.20.1
make
cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /tools/bin
cd $LFS/sources/
tar xfv grep-3.4.tar.xz
cd grep-3.4
./configure --prefix=/tools
make
make install
cd $LFS/sources/
tar xfv gzip-1.10.tar.xz
cd gzip-1.10
./configure --prefix=/tools
make
make install
cd $LFS/sources/
tar xfv make-4.3.tar.gz
cd make-4.3
./configure --prefix=/tools --without-guile
make
make install
cd $LFS/sources/
tar xfv patch-2.7.6.tar.xz
cd patch-2.7.6
./configure --prefix=/tools
make
make install
cd $LFS/sources/
tar xfv perl-5.30.1.tar.xz
cd perl-5.30.1
sh Configure -des -Dprefix=/tools -Dlibs=-lm -Uloclibpth -Ulocincpth
make
cp -v perl cpan/podlators/scripts/pod2man /tools/bin
mkdir -pv /tools/lib/perl5/5.30.1
cp -Rv lib/* /tools/lib/perl5/5.30.1
cd $LFS/sources/
tar xfv Python-3.8.1.tar.xz
cd  Python-3.8.1
sed -i '/def add_multiarch_paths/a \        return' setup.py
./configure --prefix=/tools --without-ensurepip
make
make install
cd $LFS/sources/
tar xfv sed-4.8.tar.xz
cd sed-4.8
./configure --prefix=/tools
make
make install
cd $LFS/sources/
tar xfv tar-1.32.tar.xz
cd tar-1.32
./configure --prefix=/tools
make
make install
cd $LFS/sources/
tar xfv texinfo-6.7.tar.xz
cd texinfo-6.7
./configure --prefix=/tools
make
make install
cd $LFS/sources/
tar xfv util-linux-2.35.1.tar.xz
cd util-linux-2.35.1
./configure --prefix=/tools                \
            --without-python               \
            --disable-makeinstall-chown    \
            --without-systemdsystemunitdir \
            --without-ncurses              \
            PKG_CONFIG=""
make
make install
cd $LFS/sources/
tar xfv xz-5.2.4.tar.xz
cd xz-5.2.4
./configure --prefix=/tools
make
make install
strip --strip-debug /tools/lib/*
/usr/bin/strip --strip-unneeded /tools/{,s}bin/*

En tant que root (ne pas oublie $LFS !)

chown -R root:root $LFS/tools

En tant que root:

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
chroot "$LFS" /tools/bin/env -i \
    HOME=/root                  \
    TERM="$TERM"                \
    PS1='(lfs chroot) \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/firmware,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}
mkdir -v  /usr/lib/pkgconfig
 
case $(uname -m) in
 x86_64) mkdir -v /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,chmod,dd,echo,ln,mkdir,pwd,rm,stty,touch} /bin
ln -sv /tools/bin/{env,install,perl,printf}         /usr/bin
ln -sv /tools/lib/libgcc_s.so{,.1}                  /usr/lib
ln -sv /tools/lib/libstdc++.{a,so{,.6}}             /usr/lib
ln -sv bash /bin/sh
 
ln -sv /proc/self/mounts /etc/mtab
 
cat > /etc/passwd << "EOF"
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/dev/null:/bin/false
daemon:x:6:6:Daemon User:/dev/null:/bin/false
messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
systemd-network:x:76:76:systemd Network Management:/:/bin/false
systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
systemd-coredump:x:79:79:systemd Core Dumper:/:/bin/false
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
EOF
 
cat > /etc/group << "EOF"
root:x:0:
bin:x:1:daemon
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:
adm:x:16:
messagebus:x:18:
systemd-journal:x:23:
input:x:24:
mail:x:34:
kvm:x:61:
systemd-bus-proxy:x:72:
systemd-journal-gateway:x:73:
systemd-journal-remote:x:74:
systemd-journal-upload:x:75:
systemd-network:x:76:
systemd-resolve:x:77:
systemd-timesync:x:78:
systemd-coredump:x:79:
wheel:x:97:
nogroup:x:99:
users:x:999:
EOF
 
exec /tools/bin/bash --login +h
 
touch /var/log/{btmp,lastlog,faillog,wtmp}
chgrp -v utmp /var/log/lastlog
chmod -v 664  /var/log/lastlog
chmod -v 600  /var/log/btmp
cd /sources/linux-5.5.3
make mrproper
make headers
find usr/include -name '.*' -delete
rm usr/include/Makefile
cp -rv usr/include/* /usr/include
cd /sources/
tar xfv man-pages-5.05.tar.xz
cd man-pages-5.05
make install
cd /sources/glibc-2.31/
patch -Np1 -i ../glibc-2.31-fhs-1.patch
 
ln -sfv ../lib/ld-linux-x86-64.so.2 /lib64
ln -sfv ../lib/ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so.3
 
cd build
rm -rf *
 
CC="gcc -ffile-prefix-map=/tools=/usr" \
../configure --prefix=/usr                          \
             --disable-werror                       \
             --enable-kernel=3.2                    \
             --enable-stack-protector=strong        \
             --with-headers=/usr/include            \
             libc_cv_slibdir=/lib
 
make
 
ln -sfnv $PWD/elf/ld-linux-x86-64.so.2 /lib
 
make check
 
touch /etc/ld.so.conf
 
sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile
 
make install
 
cp -v ../nscd/nscd.conf /etc/nscd.conf
mkdir -pv /var/cache/nscd
 
install -v -Dm644 ../nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf
install -v -Dm644 ../nscd/nscd.service /lib/systemd/system/nscd.service
 
mkdir -pv /usr/lib/locale
localedef -i POSIX -f UTF-8 C.UTF-8 2> /dev/null || true
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 el_GR -f ISO-8859-7 el_GR
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 ja_JP -f SHIFT_JIS ja_JP.SIJS 2> /dev/null || true
localedef -i ja_JP -f UTF-8 ja_JP.UTF-8
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
localedef -i zh_HK -f BIG5-HKSCS zh_HK.BIG5-HKSCS
 
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 ../../tzdata2019c.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       ${tz}
    zic -L /dev/null   -d $ZONEINFO/posix ${tz}
    zic -L leapseconds -d $ZONEINFO/right ${tz}
done
cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO
zic -d $ZONEINFO -p America/New_York
unset ZONEINFO
tzselect
ln -sfv /usr/share/zoneinfo/Europe/Paris /etc/localtime
 
cat > /etc/ld.so.conf << "EOF"
# Début de /etc/ld.so.conf
/usr/local/lib
/opt/lib
 
EOF
cat >> /etc/ld.so.conf << "EOF"
# Ajout d'un répertoire include
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/$(uname -m)-pc-linux-gnu/bin/{ld,ld-old}
mv -v /tools/bin/{ld-new,ld}
ln -sv /tools/bin/ld /tools/$(uname -m)-pc-linux-gnu/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

Faire certaines vérifications, cf le manuel.

cd /sources/
tar xfv zlib-1.2.11.tar.xz
cd zlib-1.2.11
./configure --prefix=/usr
make
make install
mv -v /usr/lib/libz.so.* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libz.so) /usr/lib/libz.so
cd /sources/bzip2-1.0.8/
 
patch -Np1 -i ../bzip2-1.0.8-install_docs-1.patch
sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile
sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile
 
make clean
make -f Makefile-libbz2_so
make clean
make
make PREFIX=/usr 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
cd /sources/xz-5.2.4
./configure --prefix=/usr    \
            --disable-static \
            --docdir=/usr/share/doc/xz-5.2.4
make
make check
make install
mv -v   /usr/bin/{lzma,unlzma,lzcat,xz,unxz,xzcat} /bin
mv -v /usr/lib/liblzma.so.* /lib
ln -svf ../../lib/$(readlink /usr/lib/liblzma.so) /usr/lib/liblzma.so
cd /sources/file-5.38
./configure --prefix=/usr
make
make check
make install
cd /sources/
tar xfv readline-8.0.tar.gz
cd readline-8.0
 
sed -i '/MV.*old/d' Makefile.in
sed -i '/{OLDSUFF}/c:' support/shlib-install
 
./configure --prefix=/usr    \
            --disable-static \
            --docdir=/usr/share/doc/readline-8.0
make SHLIB_LIBS="-L/tools/lib -lncursesw"
make SHLIB_LIBS="-L/tools/lib -lncursesw" install
 
mv -v /usr/lib/lib{readline,history}.so.* /lib
chmod -v u+w /lib/lib{readline,history}.so.*
ln -sfv ../../lib/$(readlink /usr/lib/libreadline.so) /usr/lib/libreadline.so
ln -sfv ../../lib/$(readlink /usr/lib/libhistory.so ) /usr/lib/libhistory.so
cd /sources/m4-1.4.18/
 
sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c
echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h
 
./configure --prefix=/usr
make
make check
make install
cd /sources
tar xfv bc-2.5.3.tar.gz
cd bc-2.5.3
 
PREFIX=/usr CC=gcc CFLAGS="-std=c99" ./configure.sh -G -O3
make
make test
make install
cd /sources/binutils-2.34
 
sed -i '/@\tincremental_copy/d' gold/testsuite/Makefile.in
 
cd build/
rm -rf *
 
../configure --prefix=/usr       \
             --enable-gold       \
             --enable-ld=default \
             --enable-plugins    \
             --enable-shared     \
             --disable-werror    \
             --enable-64-bit-bfd \
             --with-system-zlib
make tooldir=/usr
make -k check
make tooldir=/usr install
cd /sources/
tar xfv gmp-6.2.0.tar.gz
cd gmp-6.2.0
 
./configure --prefix=/usr    \
            --enable-cxx     \
            --disable-static \
            --docdir=/usr/share/doc/gmp-6.2.0
make
make check 2>&1 | tee gmp-check-log
awk '/# PASS:/{total+=$3} ; END{print total}' gmp-check-log # >= 197
make install
cd /sources/
tar xfv mpfr-4.0.2.tar.gz
cd mpfr-4.0.2
 
./configure --prefix=/usr        \
            --disable-static     \
            --enable-thread-safe \
            --docdir=/usr/share/doc/mpfr-4.0.2
make
make check
make install
cd /sources/
tar xfv mpc-1.1.0.tar.gz
cd mpc-1.1.0
 
./configure --prefix=/usr    \
            --disable-static \
            --docdir=/usr/share/doc/mpc-1.1.0
make
make check
make install
cd /sources/
tar xfv attr-2.4.48.tar.gz
cd attre-2.4.48
 
./configure --prefix=/usr     \
            --disable-static  \
            --sysconfdir=/etc \
            --docdir=/usr/share/doc/attr-2.4.48
make
make check
make install
 
mv -v /usr/lib/libattr.so.* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libattr.so) /usr/lib/libattr.so
cd /sources/
tar xfv acl-2.2.53.tar.gz
cd acl-2.2.53
./configure --prefix=/usr         \
            --disable-static      \
            --libexecdir=/usr/lib \
            --docdir=/usr/share/doc/acl-2.2.53
make
make install
cd /sources/
tar xfv shadow-4.8.1.tar.gz
cd shadow-4.8.1
 
sed -i 's/groups$(EXEEXT) //' src/Makefile.in
find man -name Makefile.in -exec sed -i 's/groups\.1 / /'   {} \;
find man -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \;
find man -name Makefile.in -exec sed -i 's/passwd\.5 / /'   {} \;
 
sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' \
       -e 's@/var/spool/mail@/var/mail@' etc/login.defs
 
sed -i 's/1000/999/' etc/useradd
 
./configure --sysconfdir=/etc --with-group-name-max-length=32
make
make install
 
pwconv
grpconv
 
passwd root
cd /sources/gcc-9.2.0
 
sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
sed -e '1161 s|^|//|' -i libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
 
cd build
rm -rf *
 
SED=sed                               \
../configure --prefix=/usr            \
             --enable-languages=c,c++ \
             --disable-multilib       \
             --disable-bootstrap      \
             --with-system-zlib
make
 
ulimit -s 32768
chown -Rv nobody . 
su nobody -s /bin/bash -c "PATH=$PATH make -k check" # très très très long (plus de 4h), voir la doc pour interpréter le résultat
make install
rm -rf /usr/lib/gcc/$(gcc -dumpmachine)/9.2.0/include-fixed/bits/
chown -v -R root:root /usr/lib/gcc/*linux-gnu/9.2.0/include{,-fixed}
ln -sv ../usr/bin/cpp /lib
ln -sv gcc /usr/bin/cc
install -v -dm755 /usr/lib/bfd-plugins
ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/9.2.0/liblto_plugin.so /usr/lib/bfd-plugins/
 
# vérifications, cf le manuel, j'ai eu besoin de faire:
gcc -dumpspecs > `dirname $(gcc --print-libgcc-file-name)`/specs
# et supprimer tous les '/tools' pour que l'interpréteur soit le bon
 
mkdir -pv /usr/share/gdb/auto-load/usr/lib
mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib
cd /sources
tar xfv pkg-config-0.29.2.tar.gz
cd pkg-config-0.29.2
 
./configure --prefix=/usr              \
            --with-internal-glib       \
            --disable-host-tool        \
            --docdir=/usr/share/doc/pkg-config-0.29.2
make
make check
make install
cd /sources/ncurses-6.2/
sed -i '/LIBTOOL_INSTALL/d' c++/Makefile.in
./configure --prefix=/usr           \
            --mandir=/usr/share/man \
            --with-shared           \
            --without-debug         \
            --without-normal        \
            --enable-pc-files       \
            --enable-widec
make
make install
 
mv -v /usr/lib/libncursesw.so.6* /lib
ln -sfv ../../lib/$(readlink /usr/lib/libncursesw.so) /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}w.pc        /usr/lib/pkgconfig/${lib}.pc
done
 
rm -vf                     /usr/lib/libcursesw.so
echo "INPUT(-lncursesw)" > /usr/lib/libcursesw.so
ln -sfv libncurses.so      /usr/lib/libcurses.so
cd /sources/
tar xfv libcap-2.31.tar.gz
cd libcap-2.31
 
sed -i '/install.*STA...LIBNAME/d' libcap/Makefile
 
make lib=lib
make test
make lib=lib install
 
chmod -v 755 /lib/libcap.so.2.31
cd /sources/sed-4.8
 
sed -i 's/usr/tools/'                 build-aux/help2man
sed -i 's/testsuite.panic-tests.sh//' Makefile.in
 
./configure --prefix=/usr --bindir=/bin
make
make check
make install
install -d -m755           /usr/share/doc/sed-4.8
cd /sources
tar xfv psmisc-23.2.tar.xz
cd psmisc-23.2
 
./configure --prefix=/usr
make
make install
 
mv -v /usr/bin/fuser   /bin
mv -v /usr/bin/killall /bin
cd /sources/
tar xfv iana-etc-2.30.tar.bz2
cd iana-etc-2.30/
 
make
make install
cd /sources/bison-3.5.2
./configure --prefix=/usr --docdir=/usr/share/doc/bison-3.5.2
make
make install
cd /sources/
tar xfv flex-2.6.4.tar.gz
cd flex-2.6.4/
 
sed -i "/math.h/a #include <malloc.h>" src/flexdef.h
 
HELP2MAN=/tools/bin/true \
./configure --prefix=/usr --docdir=/usr/share/doc/flex-2.6.4
make
make check
make install
 
ln -s flex /usr/bin/lex
cd /sources/grep-3.4
./configure --prefix=/usr --bindir=/bin
make
make check
make install
cd /sources/bash-5.0
 
patch -Np1 -i ../bash-5.0-upstream_fixes-1.patch
 
./configure --prefix=/usr                    \
            --docdir=/usr/share/doc/bash-5.0 \
            --without-bash-malloc            \
            --with-installed-readline
make
make install
mv -vf /usr/bin/bash /bin
 
exec /bin/bash --login +h
cd /sources/
tar xfv libtool-2.4.6.tar.xz
cd libtool-2.4.6/
 
./configure --prefix=/usr
make
make install
cd /sources/
tar xfv gdbm-1.18.1.tar.xz
cd gdbm-1.18.1/
 
./configure --prefix=/usr    \
            --disable-static \
            --enable-libgdbm-compat
make
make check
make install
cd /sources
tar xfv gperf-3.1.tar.gz
cd gperf-3.1
 
./configure --prefix=/usr --docdir=/usr/share/doc/gperf-3.1
make
make -j1 check
make install
cd /sources/
tar xfv expat-2.2.9.tar.xz
cd expat-2.2.9/
 
sed -i 's|usr/bin/env |bin/|' run.sh.in
 
./configure --prefix=/usr    \
            --disable-static \
            --docdir=/usr/share/doc/expat-2.2.9
make
make check
make install
cd /sources
tar xfv inetutils-1.9.4.tar.xz
cd inetutils-1.9.4/
 
./configure --prefix=/usr        \
            --localstatedir=/var \
            --disable-logger     \
            --disable-whois      \
            --disable-rcp        \
            --disable-rexec      \
            --disable-rlogin     \
            --disable-rsh        \
            --disable-servers
make
make install
 
mv -v /usr/bin/{hostname,ping,ping6,traceroute} /bin
mv -v /usr/bin/ifconfig /sbin
cd /sources/
rm -rf perl-5.30.1
tar xfv perl-5.30.1.tar.xz
cd perl-5.30.1
 
echo "127.0.0.1 localhost $(hostname)" > /etc/hosts
export BUILD_ZLIB=False
export BUILD_BZIP2=0
 
sh Configure -des -Dprefix=/usr                 \
                  -Dvendorprefix=/usr           \
                  -Dman1dir=/usr/share/man/man1 \
                  -Dman3dir=/usr/share/man/man3 \
                  -Dpager="/usr/bin/less -isR"  \
                  -Duseshrplib                  \
                  -Dusethreads
make
make install
unset BUILD_ZLIB BUILD_BZIP2
cd /sources/
tar xfv XML-Parser-2.46.tar.gz
cd XML-Parser-2.46
 
perl Makefile.PL
make
make test
make install
cd /sources
tar xfv intltool-0.51.0.tar.gz
cd intltool-0.51.0
 
sed -i 's:\\\${:\\\$\\{:' intltool-update.in
 
./configure --prefix=/usr
make
make check
make install
install -v -Dm644 doc/I18N-HOWTO /usr/share/doc/intltool-0.51.0/I18N-HOWTO
cd /sources
tar xfv autoconf-2.69.tar.xz
cd autoconf-2.69
 
sed '361 s/{/\\{/' -i bin/autoscan.in
 
./configure --prefix=/usr
make
make install
cd /sources
tar xfv automake-1.16.1.tar.xz
cd automake-1.16.1
 
./configure --prefix=/usr --docdir=/usr/share/doc/automake-1.16.1
make
make install
cd /sources
tar xfv kmod-26.tar.xz
cd kmod-26
 
./configure --prefix=/usr          \
            --bindir=/bin          \
            --sysconfdir=/etc      \
            --with-rootlibdir=/lib \
            --with-xz              \
            --with-zlib
make
make install
 
for target in depmod insmod lsmod modinfo modprobe rmmod; do
  ln -sfv ../bin/kmod /sbin/$target
done
ln -sfv kmod /bin/lsmod
cd /sources/gettext-0.20.1
./configure --prefix=/usr    \
            --disable-static \
            --docdir=/usr/share/doc/gettext-0.20.1
make
make install
chmod -v 0755 /usr/lib/preloadable_libintl.so
cd /sources
tar xfv elfutils-0.178.tar.bz2
cd elfutils-0.178
 
./configure --prefix=/usr --disable-debuginfod
make
make -C libelf install
install -vm644 config/libelf.pc /usr/lib/pkgconfig
rm /usr/lib/libelf.a
cd /sources
tar xfv libffi-3.3.tar.gz
cd libffi-3.3
 
./configure --prefix=/usr --disable-static --with-gcc-arch=native
make
make install
cd /sources
tar xfv openssl-1.1.1.tar.gz
cd openssl-1.1.1d
 
./config --prefix=/usr         \
         --openssldir=/etc/ssl \
         --libdir=lib          \
         shared                \
         zlib-dynamic
make
sed -i '/INSTALL_LIBS/s/libcrypto.a libssl.a//' Makefile
make MANSUFFIX=ssl install
cd /sources/Python-3.8.1
./configure --prefix=/usr       \
            --enable-shared     \
            --with-system-expat \
            --with-system-ffi   \
            --with-ensurepip=yes
make
make install
chmod -v 755 /usr/lib/libpython3.8.so
chmod -v 755 /usr/lib/libpython3.so
ln -sfv pip3.8 /usr/bin/pip3
cd /sources
tar xfv ninja-1.10.0.tar.gz
cd ninja-1.10.0
 
python3 configure.py --bootstrap
 
install -vm755 ninja /usr/bin/
install -vDm644 misc/bash-completion /usr/share/bash-completion/completions/ninja
install -vDm644 misc/zsh-completion  /usr/share/zsh/site-functions/_ninja
cd /sources/
tar xfv meson-0.53.1.tar.gz
cd meson-0.53.1
 
python3 setup.py build
python3 setup.py install --root=dest
cp -rv dest/* /
cd /sources/coreutils-8.31/
patch -Np1 -i ../coreutils-8.31-i18n-1.patch
sed -i '/test.lock/s/^/#/' gnulib-tests/gnulib.mk
autoreconf -fiv
 
FORCE_UNSAFE_CONFIGURE=1 ./configure \
            --prefix=/usr            \
            --enable-no-install-program=kill,uptime
make
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,nice,sleep,touch} /bin
cd /sources/
tar xfv check-0.14.0.tar.gz
cd check-0.14.0
 
./configure --prefix=/usr
make
make docdir=/usr/share/doc/check-0.14.0 install &&
sed -i '1 s/tools/usr/' /usr/bin/checkmk
cd /sources/diffutils-3.7
./configure --prefix=/usr
make
make check
make install
cd /sources/gawk-5.0.1
sed -i 's/extras//' Makefile.in
./configure --prefix=/usr
make
make check
make install
  • linux/lfs.1601220459.txt.gz
  • Dernière modification : 2021/04/04 17:01
  • (modification externe)