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