Ceci est une ancienne révision du document !
Linux From Scratch
http://fr.linuxfromscratch.org/view/lfs-systemd-stable/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
Prérequis du système hôte
Exécuter le script fournit ici.
Correction à apporter:
- installer les paquets
build-essential bison gawk m4 texinfo
Définir la variable $LFS
export LFS=/mnt/lfs
Monter la nouvelle partition
sudo mkdir -pv $LFS sudo mount -v -t ext4 /dev/<xxx> $LFS
Téléchargement des sources
sudo mkdir -v $LFS/sources sudo chmod -v a+wt $LFS/sources wget http://fr.linuxfromscratch.org/view/lfs-systemd-stable/wget-list sudo wget --input-file=wget-list --continue --directory-prefix=$LFS/sources
Créer le répertoire $LFS/tools
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'
Ajouter l'utilisateur LFS
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.
Configurer l'environnement
- ~/.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.
Binutils-2.34 — Passe 1
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
GCC-9.2.0 — Passe 1
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
Linux-5.5.3 API Headers
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
Glibc-2.31
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
Libstdc++ de GCC-9.2.0
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
Binutils-2.34 — Passe 2
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
GCC-9.2.0 — Passe 2
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
Tcl-8.6.10
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
Expect-5.45.4
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
DejaGNU-1.6.2
cd $LFS/sources/ tar xfv dejagnu-1.6.2.tar.gz cd dejagnu-1.6.2 ./configure --prefix=/tools make install make check
M4-1.4.18
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
Ncurses-6.2
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 ==== Bash-5.0 ==== <code bash> 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
Bison-3.5.2
cd $LFS/sources/ tar xfv bison-3.5.2.tar.xz cd bison-3.5.2 ./configure --prefix=/tools make make check make install
Bzip2-1.0.8
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
Coreutils-8.31
cd $LFS/sources/ tar xfv coreutils-8.31.tar.xz cd coreutils-8.31 ./configure --prefix=/tools --enable-install-program=hostname make make install
Diffutils-3.7
cd $LFS/sources/ tar xfv diffutils-3.7.tar.xz cd diffutils-3.7 ./configure --prefix=/tools make make install
File-5.38
cd $LFS/sources/ tar xfv file-5.38.tar.gz cd file-5.38 make make install
Findutils-4.7.0
cd $LFS/sources/ tar xfv findutils-4.7.0.tar.xz cd findutils-4.7.0 ./configure --prefix=/tools make make install
Gawk-5.0.1
cd $LFS/sources/ tar xfv gawk-5.0.1.tar.xz cd gawk-5.0.1 ./configure --prefix=/tools make make install
Gettext-0.20.1
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
Grep-3.4
cd $LFS/sources/ tar xfv grep-3.4.tar.xz cd grep-3.4 ./configure --prefix=/tools make make install
Gzip-1.10
cd $LFS/sources/ tar xfv gzip-1.10.tar.xz cd gzip-1.10 ./configure --prefix=/tools make make install
Make-4.3
cd $LFS/sources/ tar xfv make-4.3.tar.gz cd make-4.3 ./configure --prefix=/tools --without-guile make make install
Patch-2.7.6
cd $LFS/sources/ tar xfv patch-2.7.6.tar.xz cd patch-2.7.6 ./configure --prefix=/tools make make install
Perl-5.30.1
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
Python-3.8.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
Sed-4.8
cd $LFS/sources/ tar xfv sed-4.8.tar.xz cd sed-4.8 ./configure --prefix=/tools make make install
Tar-1.32
cd $LFS/sources/ tar xfv tar-1.32.tar.xz cd tar-1.32 ./configure --prefix=/tools make make install
Texinfo-6.7
cd $LFS/sources/ tar xfv texinfo-6.7.tar.xz cd texinfo-6.7 ./configure --prefix=/tools make make install
Util-linux-2.35.1
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
Xz-5.2.4
cd $LFS/sources/ tar xfv xz-5.2.4.tar.xz cd xz-5.2.4 ./configure --prefix=/tools make make install
Supprimer les symboles des fichiers objets
strip --strip-debug /tools/lib/* /usr/bin/strip --strip-unneeded /tools/{,s}bin/*
Changer de propriétaire
En tant que root (ne pas oublie $LFS !)
chown -R root:root $LFS/tools