Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Copyright © 2021 Miamondo <https://miamondo.org/contact/>
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # any later version.
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>
- # ------------------------------------------------------------------------------
- :<<'### BLOCK COMMENT'
- PRÉREQUIS:
- 1) Avant de lancer le script, créer un utilisateur lfs. Ajoutez-le immédiatement
- au groupe sudo et REDEMARREZ votre ordinateur pour prendre en compte les
- changements:
- sudo groupadd lfs
- sudo useradd -s /bin/bash -g lfs -m -k /dev/null lfs
- sudo usermod -aG sudo lfs
- reboot
- 2) RECONNECTEZ-VOUS en tant qu'utilisateur lfs.
- 3) Puis, copiez les scripts suivants dans le répertoire /home/lfs:
- start.sh (fichier lanceur)
- wget-list (liste des paquets à télecharger sous forme d'archives)
- md5sums (sommes de contrôle)
- 4) Rendez l'utilisateur lfs récursivement propriétaire de son répertoire
- avec la commande suivante:
- sudo chown -R lfs:lfs /home/lfs
- 5) Donnez le droit d'exécution au script start.sh
- chmod +x /home/lfs/start.sh
- 6) Lancez ce script en tant qu'utilisateur lfs. Le code va s'exécuter de
- la balise n° 1 à la balise n° 2. Il va s'interrompre automatiquement à la
- commande "source /home/lfs/.bash_profile". Relancez le script après avoir
- DECOMMENTÉ la balise ouvrante : <<'END_COMMENT' et la balise fermante
- END_COMMENT qui se trouve juste sous la balise n°2.
- Cela a pour effet de créer un commentaire multilignes qui neutralise l'exécution
- de cette partie du code. Le code va s'exécuter seulement à partir
- de la balise n° 2.
- 7) Ne JAMAIS neutraliser les instructions suivantes:
- export MAKEFLAGS=-j`nproc --all`
- cd /mnt/lfs/sources
- 8) À partir de la balise n° 2 (décompression des archives et installation des paquets),
- vous pouvez très bien exécuter le script en renvoyant les erreurs de compilation
- dans un fichier errors.txt:
- /home/lfs/start.sh 2> /home/lfs/errors.txt
- Cela facilite grandement le débogage.
- 9) Vous pouvez également déplacer les balises END_COMMENT comme bon vous semble et
- exécuter le script en plusieurs fois ou bien exécuter seulement une partie du
- script.
- ### BLOCK COMMENT
- #-------------------------------------------------------------------------------
- # Balise n° 1
- : <<'END_COMMENT'
- echo "#####################################################################"
- echo "# #"
- echo "# Programme d'installation de Linux From Scratch. #"
- echo "# Vous devez formater une partition d'au moins 35 GB avec un #"
- echo "# système de fichiers ext4. #"
- echo "# #"
- echo "#####################################################################"
- echo ""
- echo "Quelle partition avez-vous formatée? (/dev/sda1, /dev/sdb2, etc...)"
- read partition
- # Création du répertoire /mnt/lfs
- sudo mkdir -p /mnt/lfs
- # La partition est montée sur le répertoire nouvellement créé
- mount $partition /mnt/lfs
- # Ce répertoire va stocker les archives des paquets à télécharger
- mkdir -p /mnt/lfs/sources
- # Droits d'écriture et sticky sur le répertoire /mnt/lfs/sources
- chmod -v a+wt /mnt/lfs/sources
- # Téléchargement des sources
- wget --input-file=`readlink -f wget-list` \
- --continue \
- --directory-prefix=/mnt/lfs/sources
- cp `readlink -f md5sums` /mnt/lfs/sources
- pushd /mnt/lfs/sources
- md5sum -c md5sums
- popd
- # Création de différents répertoires nécessaires à la construction.
- # Pour la version 32-bit, supprimer lib64
- mkdir -pv /mnt/lfs/{etc,var,lib64,tools} /mnt/lfs/usr/{bin,lib,sbin}
- for i in bin lib sbin
- do
- ln -sv usr/$i /mnt/lfs/$i
- done
- # L'utilisateur lfs devient propriétaire de /mnt/lfs
- sudo chown -R lfs:lfs /mnt/lfs
- # Mise en place d'un environnement propre
- cat > /home/lfs/.bash_profile << "EOF"
- exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
- EOF
- cat > /home/lfs/.bashrc << "EOF"
- set +h
- umask 022
- LC_ALL=POSIX
- LFS_TGT=$(uname -m)-lfs-linux-gnu
- PATH=/usr/bin
- if [ ! -L /bin ]; then PATH=/bin:$PATH; fi
- PATH=/mnt/lfs/tools/bin:$PATH
- CONFIG_SITE=/mnt/lfs/usr/share/config.site
- export LC_ALL LFS_TGT PATH CONFIG_SITE
- EOF
- # Chargement du nouveau profil de l'utilisateur lfs
- source /home/lfs/.bash_profile
- # Balise n° 2
- END_COMMENT
- # Optimisation du temps de compilation
- export MAKEFLAGS=-j`nproc --all`
- # Déplacement dans le répertoire des archives
- cd /mnt/lfs/sources
- # CONSTRUCTION D'UNE CHAINE DE COMPILATION CROISÉE
- : <<'END_COMMENT'
- #--binutils-2.37---------------------------------
- tar -xf binutils-2.37.tar.*
- cd binutils-2.37
- mkdir -v build
- cd build
- ../configure --prefix=/mnt/lfs/tools \
- --with-sysroot=/mnt/lfs \
- --target=$LFS_TGT \
- --disable-nls \
- --disable-werror
- make $MAKEFLAGS
- make install -j1
- cd ../..
- sudo rm -r binutils-2.37
- echo "binutils-2.37 installé (1ère passe)"
- echo 'Pressez la touche "Entrée"'
- read
- #--gcc-11.2.0------------------------------------
- tar -xf gcc-11.2.0.tar.*
- cd gcc-11.2.0
- tar -xf ../mpfr-4.1.0.tar.*
- mv -v mpfr-4.1.0 mpfr
- tar -xf ../gmp-6.2.1.tar.*
- mv -v gmp-6.2.1 gmp
- tar -xf ../mpc-1.2.1.tar.gz
- mv -v mpc-1.2.1 mpc
- case $(uname -m) in
- x86_64)
- sed -e '/m64=/s/lib64/lib/' \
- -i.orig gcc/config/i386/t-linux64
- ;;
- esac
- mkdir -v build
- cd build
- ../configure --target=$LFS_TGT \
- --prefix=/mnt/lfs/tools \
- --with-glibc-version=2.11 \
- --with-sysroot=/mnt/lfs \
- --with-newlib \
- --without-headers \
- --enable-initfini-array \
- --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 $MAKEFLAGS
- make install $MAKEFLAGS
- cd ..
- cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
- `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h
- cd ..
- sudo rm -r gcc-11.2.0
- echo "gcc-11.2.0 installé (1ère passe)"
- echo 'Pressez la touche "Entrée"'
- read
- #--linux-5.13.12---------------------------------
- tar -xf linux-5.13.12.tar.*
- cd linux-5.13.12
- make mrproper
- make headers
- find usr/include -name '.*' -delete
- rm usr/include/Makefile
- cp -rv usr/include /mnt/lfs/usr
- cd ..
- sudo rm -r linux-5.13.12
- echo "linux-5.13.12 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--glibc-2.34------------------------------------
- tar -xf glibc-2.34.tar.*
- cd glibc-2.34
- case $(uname -m) in
- i?86) ln -sfv ld-linux.so.2 /mnt/lfs/lib/ld-lsb.so.3
- ;;
- x86_64) ln -sfv ../lib/ld-linux-x86-64.so.2 /mnt/lfs/lib64
- ln -sfv ../lib/ld-linux-x86-64.so.2 /mnt/lfs/lib64/ld-lsb-x86-64.so.3
- ;;
- esac
- patch -Np1 -i ../glibc-2.34-fhs-1.patch
- mkdir -v build
- cd build
- echo "rootsbindir=/usr/sbin" > configparms
- ../configure --prefix=/usr \
- --host=$LFS_TGT \
- --build=$(../scripts/config.guess) \
- --enable-kernel=3.2 \
- --with-headers=/mnt/lfs/usr/include \
- libc_cv_slibdir=/usr/lib
- make
- make DESTDIR=/mnt/lfs install
- sed '/RTLDLIST=/s@/usr@@g' -i /mnt/lfs/usr/bin/ldd
- echo 'int main(){}' > dummy.c
- $LFS_TGT-gcc dummy.c
- readelf -l a.out | grep '/ld-linux'
- rm -v dummy.c a.out
- /mnt/lfs/tools/libexec/gcc/$LFS_TGT/11.2.0/install-tools/mkheaders
- cd ../..
- sudo rm -r glibc-2.34
- echo "glibc-2.34 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--libstdc++ de gcc-11.2.0------------------------------------
- tar -xf gcc-11.2.0.tar.*
- cd gcc-11.2.0
- mkdir -v build
- cd build
- ../libstdc++-v3/configure \
- --host=$LFS_TGT \
- --build=$(../config.guess) \
- --prefix=/usr \
- --disable-multilib \
- --disable-nls \
- --disable-libstdcxx-pch \
- --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/11.2.0
- make
- make DESTDIR=/mnt/lfs install
- cd ../..
- sudo rm -r gcc-11.2.0
- echo "libstdc++ installé"
- echo "FIN DE LA CONSTRUCTION D'UNE CHAINE DE COMPILATION CROISÉE"
- echo "DÉBUT DE LA COMPILATION CROISÉE DES OUTILS TEMPORAIRES"
- read
- #--COMPILATION CROISÉE DES OUTILS TEMPORAIRES
- #--m4-1.4.19-------------------------------------
- tar -xf m4-1.4.19.tar.*
- cd m4-1.4.19
- ./configure --prefix=/usr \
- --host=$LFS_TGT \
- --build=$(build-aux/config.guess)
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install $MAKEFLAGS
- cd ..
- sudo rm -r m4-1.4.19
- echo "m4-1.4.19 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--ncurses-6.2-----------------------------------
- tar -xf ncurses-6.2.tar.gz
- cd ncurses-6.2
- sed -i s/mawk// configure
- mkdir build
- pushd build
- ../configure
- make -C include
- make -C progs tic
- popd
- ./configure --prefix=/usr \
- --host=$LFS_TGT \
- --build=$(./config.guess) \
- --mandir=/usr/share/man \
- --with-manpage-format=normal \
- --with-shared \
- --without-debug \
- --without-ada \
- --without-normal \
- --enable-widec
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs TIC_PATH=$(pwd)/build/progs/tic install
- echo "INPUT(-lncursesw)" > /mnt/lfs/usr/lib/libncurses.so
- cd ..
- sudo rm -r ncurses-6.2
- echo "ncurses-6.2 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--bash-5.1.8------------------------------------
- tar -xf bash-5.1.8.tar.gz
- cd bash-5.1.8
- ./configure --prefix=/usr \
- --build=$(support/config.guess) \
- --host=$LFS_TGT \
- --without-bash-malloc
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install
- ln -sv bash /mnt/lfs/bin/sh
- cd ..
- sudo rm -r bash-5.1.8
- echo "bash-5.1.8 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--coreutils-8.32--------------------------------
- tar -xf coreutils-8.32.tar.*
- cd coreutils-8.32
- ./configure --prefix=/usr \
- --host=$LFS_TGT \
- --build=$(build-aux/config.guess) \
- --enable-install-program=hostname \
- --enable-no-install-program=kill,uptime
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install
- mv -v /mnt/lfs/usr/bin/chroot /mnt/lfs/usr/sbin
- mkdir -pv /mnt/lfs/usr/share/man/man8
- mv -v /mnt/lfs/usr/share/man/man1/chroot.1 /mnt/lfs/usr/share/man/man8/chroot.8
- sed -i 's/"1"/"8"/' /mnt/lfs/usr/share/man/man8/chroot.8
- cd ..
- sudo rm -r coreutils-8.32
- echo "coreutils-8.32 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--diffutils-3.8---------------------------------
- tar -xf diffutils-3.8.tar.*
- cd diffutils-3.8
- ./configure --prefix=/usr --host=$LFS_TGT
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install
- cd ..
- sudo rm -r diffutils-3.8
- echo "diffutils-3.8 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--file-5.40-------------------------------------
- tar -xf file-5.40.tar.gz
- cd file-5.40
- mkdir build
- pushd build
- ../configure --disable-bzlib \
- --disable-libseccomp \
- --disable-xzlib \
- --disable-zlib
- make $MAKEFLAGS
- popd
- ./configure --prefix=/usr \
- --host=$LFS_TGT \
- --build=$(./config.guess)
- make FILE_COMPILE=$(pwd)/build/src/file
- make DESTDIR=/mnt/lfs install
- cd ..
- sudo rm -r file-5.40
- echo "file-5.40 installé"
- echo 'Pressez la touche "Entrée"'
- read
- END_COMMENT
- #--findutils-4.8.0-------------------------------
- tar -xf findutils-4.8.0.tar.*
- cd findutils-4.8.0
- ./configure --prefix=/usr \
- --localstatedir=/var/lib/locate \
- --host=$LFS_TGT \
- --build=$(./build-aux/config.guess)
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install
- cd ..
- sudo rm -r findutils-4.8.0
- echo "findutils-4.8.0 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--gawk-5.1.0------------------------------------
- tar -xf gawk-5.1.0.tar.*
- cd gawk-5.1.0
- sed -i 's/extras//' Makefile.in
- ./configure --prefix=/usr \
- --host=$LFS_TGT \
- --build=$(./config.guess)
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install
- cd ..
- sudo rm -r gawk-5.1.0
- echo "gawk-5.1.0 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--grep-3.7--------------------------------------
- tar -xf grep-3.7.tar.*
- cd grep-3.7
- ./configure --prefix=/usr \
- --host=$LFS_TGT
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install
- cd ..
- sudo rm -r grep-3.7
- echo "grep-3.7 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--gzip-1.10-------------------------------------
- tar -xf gzip-1.10.tar.*
- cd gzip-1.10
- ./configure --prefix=/usr
- --host=$LFS_TGT
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install
- cd ..
- sudo rm -r gzip-1.10
- echo "gzip-1.10 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--make-4.3--------------------------------------
- tar -xf make-4.3.tar.*
- cd make-4.3
- ./configure --prefix=/usr \
- --without-guile \
- --host=$LFS_TGT \
- --build=$(build-aux/config.guess)
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install
- cd ..
- sudo rm -r make-4.3
- echo "make-4.3 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--patch-2.7.6-----------------------------------
- tar -xf patch-2.7.6.tar.*
- cd patch-2.7.6
- ./configure --prefix=/usr \
- --host=$LFS_TGT \
- --build=$(build-aux/config.guess)
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install
- cd ..
- sudo rm -r patch-2.7.6
- echo "patch-2.7.6 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--sed-4.8---------------------------------------
- tar -xf sed-4.8.tar.*
- cd sed-4.8
- ./configure --prefix=/usr \
- --host=$LFS_TGT
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install
- cd ..
- sudo rm -r sed-4.8
- echo "sed-4.8 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--tar-1.34--------------------------------------
- tar -xf tar-1.34.tar.*
- cd tar-1.34
- ./configure --prefix=/usr \
- --host=$LFS_TGT \
- --build=$(build-aux/config.guess)
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install
- cd ..
- sudo rm -r tar-1.34
- echo "tar-1.34 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--xz-5.2.5--------------------------------------
- tar -xf xz-5.2.5.tar.*
- cd xz-5.2.5
- ./configure --prefix=/usr \
- --host=$LFS_TGT \
- --build=$(build-aux/config.guess) \
- --disable-static \
- --docdir=/usr/share/doc/xz-5.2.5
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install
- cd ..
- sudo rm -r xz-5.2.5
- echo "xz-5.2.5 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--binutils-2.37 — Passe 2-----------------------
- tar -xf binutils-2.37.tar.*
- cd binutils-2.37
- mkdir -v build
- cd build
- ../configure \
- --prefix=/usr \
- --build=$(../config.guess) \
- --host=$LFS_TGT \
- --disable-nls \
- --enable-shared \
- --disable-werror \
- --enable-64-bit-bfd
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install -j1
- install -vm755 libctf/.libs/libctf.so.0.0.0 /mnt/lfs/usr/lib
- cd ../..
- sudo rm -r binutils-2.37
- echo "binutils-2.37 installé"
- echo 'Pressez la touche "Entrée"'
- read
- #--gcc-11.2.0 — Passe 2--------------------------
- tar -xf gcc-11.2.0.tar.*
- cd gcc-11.2.0
- tar -xf ../mpfr-4.1.0.tar.xz
- mv -v mpfr-4.1.0 mpfr
- tar -xf ../gmp-6.2.1.tar.xz
- mv -v gmp-6.2.1 gmp
- tar -xf ../mpc-1.2.1.tar.gz
- mv -v mpc-1.2.1 mpc
- case $(uname -m) in
- x86_64)
- sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
- ;;
- esac
- mkdir -v build
- cd build
- mkdir -pv $LFS_TGT/libgcc
- ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h
- ../configure \
- --build=$(../config.guess) \
- --host=$LFS_TGT \
- --prefix=/usr \
- CC_FOR_TARGET=$LFS_TGT-gcc \
- --with-build-sysroot=/mnt/lfs \
- --enable-initfini-array \
- --disable-nls \
- --disable-multilib \
- --disable-decimal-float \
- --disable-libatomic \
- --disable-libgomp \
- --disable-libquadmath \
- --disable-libssp \
- --disable-libvtv \
- --disable-libstdcxx \
- --enable-languages=c,c++
- make $MAKEFLAGS
- make DESTDIR=/mnt/lfs install
- ln -sv gcc /mnt/lfs/usr/bin/cc
- cd ../..
- sudo rm -r gcc-11.2.0
- echo "gcc-11.2.0 installé"
- echo 'Pressez la touche "Entrée"'
- read
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement