Browse Source

add branch development

development
Cyril CONSTANTIN 2 weeks ago
parent
commit
e20979f9f2
  1. 315
      build.sh

315
build.sh

@ -1,46 +1,43 @@ @@ -1,46 +1,43 @@
#!/usr/bin/env bash
cat > /tmp/lfs_sudo << EOF
# 3.1. Introduction
# 4.3. Adding the LFS User
lfs ALL = NOPASSWD: /usr/bin/chown * /mnt/lfs*
# 7.3. Preparing Virtual Kernel File Systems
lfs ALL = NOPASSWD: /usr/bin/mount * /mnt/lfs*
lfs ALL = NOPASSWD: /usr/bin/install * /mnt/lfs*
lfs ALL = NOPASSWD: /usr/sbin/chroot /mnt/lfs*
cat > /tmp/lfsdev_sudo << EOF
lfsdev ALL = NOPASSWD: /usr/bin/chown * /mnt/lfsdev*
lfsdev ALL = NOPASSWD: /usr/bin/mount * /mnt/lfsdev*
lfsdev ALL = NOPASSWD: /usr/bin/install * /mnt/lfsdev*
lfsdev ALL = NOPASSWD: /usr/sbin/chroot /mnt/lfsdev*
EOF
add_lfs_user()
add_lfsdev_user()
{
echo "4.3. Adding the LFS User"
echo "# groupadd lfs"
echo "# useradd -s /bin/bash -g lfs -m -k /dev/null lfs"
echo "# passwd lfs"
echo "4.3. Adding the lfsdev User"
echo "# groupadd lfsdev"
echo "# useradd -s /bin/bash -g lfsdev -m -k /dev/null lfsdev"
echo "# passwd lfsdev"
echo "And add sudo rights"
echo "# cp /tmp/lfs_sudo /etc/sudoers.d/lfs"
echo "Now connect as lfs and execute the script"
echo "$ su - lfs"
echo "$ cd <lfs build git repo>"
echo "# cp /tmp/lfsdev_sudo /etc/sudoers.d/lfsdev"
echo "Now connect as lfsdev and execute the script"
echo "$ su - lfsdev"
echo "$ cd <lfsdev build git repo>"
echo "$ bash build.sh"
}
if [ "$(whoami)" != "lfs" ]
if [ "$(whoami)" != "lfsdev" ]
then
echo "Please execute this script as user lfs"
grep -q lfs /etc/passwd || add_lfs_user
echo "Please execute this script as user lfsdev"
grep -q lfsdev /etc/passwd || add_lfsdev_user
exit 1
fi
set -ueEo pipefail
export LFS=/mnt/lfs
export LFS=/mnt/lfsdev
# shellcheck source=/dev/null
if [ ! -e /home/lfs/.lfsbuild_config ]
if [ ! -e /home/lfsdev/.lfsdevbuild_config ]
then
cat > /home/lfs/.lfsbuild_config << EOSF
cat > /home/lfsdev/.lfsdevbuild_config << EOSF
# location of local package sources
LFS_PACKAGE_DIR=/home/lfs/packages
LFS_PACKAGE_DIR=/home/lfsdev/packages
# Number of processors to use
LFS_NPROC=$(nproc)
# Bypass step by step validation until a breakpoint
@ -57,10 +54,10 @@ EOSF @@ -57,10 +54,10 @@ EOSF
fi
# shellcheck source=/dev/null
source /home/lfs/.lfsbuild_config
source /home/lfsdev/.lfsdevbuild_config
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
LFS_PACKAGE_DIR=${LFS_PACKAGE_DIR:-/home/lfs/packages}
LFS_PACKAGE_DIR=${LFS_PACKAGE_DIR:-/home/lfsdev/packages}
LFS_NPROC=${LFS_NPROC:-$(nproc)}
LFS_BREAKPOINT=${LFS_BREAKPOINT:-1}
LFS_STRIP_BINARIES=${LFS_STRIP_BINARIES:-false}
@ -123,12 +120,12 @@ ask_for_execution() { @@ -123,12 +120,12 @@ ask_for_execution() {
}
# 2.2
cat > /tmp/lfs_version-check.sh << "EOF"
cat > /tmp/lfsdev_version-check.sh << "EOF"
#!/bin/bash
# A script to list version numbers of critical development tools
# If you have tools installed in other directories, adjust PATH here AND
# in ~lfs/.bashrc (section 4.4) as well.
# in ~lfsdev/.bashrc (section 4.4) as well.
LC_ALL=C
PATH=/usr/bin:/bin
@ -206,10 +203,10 @@ version_check() @@ -206,10 +203,10 @@ version_check()
alias_check sh Bash
echo "Compiler check:"
if printf "int main(){}" | g++ -x c++ -o /tmp/lfs_a.out -
if printf "int main(){}" | g++ -x c++ -o /tmp/lfsdev_a.out -
then echo "OK: g++ works";
else echo "ERROR: g++ does NOT work"; fi
rm -f /tmp/lfs_a.out
rm -f /tmp/lfsdev_a.out
if [ "$(nproc)" = "" ]; then
echo "ERROR: nproc is not available or it produces empty output"
@ -220,32 +217,32 @@ version_check() @@ -220,32 +217,32 @@ version_check()
EOF
# shellcheck source=/dev/null
source /tmp/lfs_version-check.sh
source /tmp/lfsdev_version-check.sh
# 2.6. Setting the $LFS Variable and the Umask
# 4.4. Setting Up the Environment
cat > ~/.bashrc << EOF
set +h
umask 022
export LFS=/mnt/lfs
export LFS=/mnt/lfsdev
export PATH=/usr/bin
if [ ! -L /bin ]; then PATH=/bin:$PATH; fi
export PATH=/mnt/lfs/tools/bin:$PATH:/usr/sbin
export PATH=/mnt/lfsdev/tools/bin:$PATH:/usr/sbin
export CONFIG_SITE=$LFS/usr/share/config.site
export MAKEFLAGS=-j${LFS_NPROC}
export ARCH=$(uname -m)
export LC_ALL=POSIX
export LFS_VERSION=13.0
export LFS_CODENAME=lfs # change this to whatever you want
export LFS_CODENAME=lfsdev # change this to whatever you want
export LFS_KERNEL_VERSION=6.18.10
export LFS_TGT=$(uname -m)-lfs-linux-gnu
export LFS_TGT=$(uname -m)-lfsdev-linux-gnu
export LFS_ZONEINFO=$(realpath --relative-to=/usr/share/zoneinfo /etc/localtime)
export LFS_HOSTNAME=${LFS_HOSTNAME:-lfs} # change this to whatever you want
export LFS_HOSTNAME=${LFS_HOSTNAME:-lfsdev} # change this to whatever you want
export SOURCES=$LFS/sources
export HLFSB=/home/lfs/lfs_build
export SLFSB=/mnt/lfs/sources/lfs_build
export RLFSB=/sources/lfs_build
export STEMP=/mnt/lfs/tmp
export HLFSB=/home/lfsdev/lfsdev_build
export SLFSB=/mnt/lfsdev/sources/lfsdev_build
export RLFSB=/sources/lfsdev_build
export STEMP=/mnt/lfsdev/tmp
EOF
# shellcheck source=/dev/null
@ -257,8 +254,8 @@ source ~/.bashrc @@ -257,8 +254,8 @@ source ~/.bashrc
## shellcheck source=/dev/null
# source ~/.bash_profile
cat > "${HOME}"/lfs_chroot.sh <<EOSF
if ! mount |grep -q "proc on /mnt/lfs/proc type proc"
cat > "${HOME}"/lfsdev_chroot.sh <<EOSF
if ! mount |grep -q "proc on /mnt/lfsdev/proc type proc"
then
echo "chroot is not available at this step"
exit 1
@ -266,7 +263,7 @@ fi @@ -266,7 +263,7 @@ fi
sudo /usr/sbin/chroot $LFS /usr/bin/env -i \
HOME=/root \
TERM="${TERM}" \
PS1='(lfs chroot) \u:\w\$ ' \
PS1='(lfsdev chroot) \u:\w\$ ' \
PATH=/usr/bin:/usr/sbin \
LFS_NPROC=${LFS_NPROC} \
MAKEFLAGS="-j${LFS_NPROC}" \
@ -507,7 +504,7 @@ describe() @@ -507,7 +504,7 @@ describe()
;;
zlib)
echo "Zlib : This package contains compression and decompression routines used by some programs."
;;
0 ;;
zstd)
echo "Zstd : This package supplies compression and decompression routines used by some programs. It provides high compression ratios and a very wide range of compression / speed trade-offs."
;;
@ -921,8 +918,8 @@ copy_scripts() @@ -921,8 +918,8 @@ copy_scripts()
create_directories()
{
echo "call create_directories"
echo "sudo operation : /usr/bin/chown lfs:root $LFS"
sudo /usr/bin/chown lfs:root $LFS || return 1
echo "sudo operation : /usr/bin/chown lfsdev:root $LFS"
sudo /usr/bin/chown lfsdev:root $LFS || return 1
mkdir --parents --verbose $LFS/{etc,var,tools,dev,proc,sys,run} $LFS/usr/{bin,lib,sbin}
@ -987,17 +984,17 @@ cross_toolchain() @@ -987,17 +984,17 @@ cross_toolchain()
fi
pushd "${buildpath}"
set -ueExo pipefail
if ! eval "$(cat ../"${scriptname}")" | tee "/tmp/lfs_${step}.log"
if ! eval "$(cat ../"${scriptname}")" | tee "/tmp/lfsdev_${step}.log"
then
echo "compilation error"
exit 1
else
echo "compilation ok"
cp -v "/tmp/lfs_${step}.log" "${HOME}"
cp -v "/tmp/lfsdev_${step}.log" "${HOME}"
fi
popd
set -ueEo pipefail
check_errors "/tmp/lfs_${step}.log"
check_errors "/tmp/lfsdev_${step}.log"
rm --recursive --verbose --force "${buildpath}"
echo "${step}" > "${SLFSB}"
ask_for_exit "${step}"
@ -1031,7 +1028,7 @@ building_temporary_tools() @@ -1031,7 +1028,7 @@ building_temporary_tools()
then
archivepath=$(find "${SOURCES}" -name "${packagename}*.tar.*" -print)
echo "archpath: ${archivepath}"
archivesubpath=${archivepath##/mnt/lfs}
archivesubpath=${archivepath##/mnt/lfsdev}
echo "archivesubpath: ${archivesubpath}"
archivename=$(basename "${archivepath}")
echo "archname: ${archivename}"
@ -1040,7 +1037,7 @@ building_temporary_tools() @@ -1040,7 +1037,7 @@ building_temporary_tools()
echo "There is no archive with this name !!!"
exit 1
fi
sudofile=/tmp/lfs_${step}.sh
sudofile=/tmp/lfsdev_${step}.sh
cat > "${sudofile}" << EOSF
if [ -d "${buildpath}" ]
then
@ -1055,21 +1052,21 @@ then @@ -1055,21 +1052,21 @@ then
fi
pushd "${buildpath}"
set -ueExo pipefail
eval "\$(cat ../"${scriptname}")" | tee "/tmp/lfs_${step}.log"
eval "\$(cat ../"${scriptname}")" | tee "/tmp/lfsdev_${step}.log"
popd
rm -rf "${buildpath}"
set -ueEo pipefail
EOSF
if ! lfs_chroot "${sudofile}"
if ! lfsdev_chroot "${sudofile}"
then
echo "compilation error"
exit 1
else
echo "compilation ok"
fi
check_errors "${STEMP}/lfs_${step}.log"
check_errors "${STEMP}/lfsdev_${step}.log"
echo "${step}" > "${SLFSB}"
cp -v "${STEMP}/lfs_${step}.log" "${HOME}"
cp -v "${STEMP}/lfsdev_${step}.log" "${HOME}"
ask_for_exit "${step}"
done
}
@ -1077,12 +1074,12 @@ EOSF @@ -1077,12 +1074,12 @@ EOSF
check_virtual_kernel_filesystems()
{
echo "call check_virtual_kernel_filesystems"
if mount |grep -q "udev on /mnt/lfs/dev type devtmpfs" && \
mount |grep -q "devpts on /mnt/lfs/dev/pts type devpts" && \
mount |grep -q "proc on /mnt/lfs/proc type proc" && \
mount |grep -q "sysfs on /mnt/lfs/sys type sysfs" && \
mount |grep -q "tmpfs on /mnt/lfs/run type tmpfs" && \
mount |grep -q "tmpfs on /mnt/lfs/dev/shm type tmpfs"
if mount |grep -q "udev on /mnt/lfsdev/dev type devtmpfs" && \
mount |grep -q "devpts on /mnt/lfsdev/dev/pts type devpts" && \
mount |grep -q "proc on /mnt/lfsdev/proc type proc" && \
mount |grep -q "sysfs on /mnt/lfsdev/sys type sysfs" && \
mount |grep -q "tmpfs on /mnt/lfsdev/run type tmpfs" && \
mount |grep -q "tmpfs on /mnt/lfsdev/dev/shm type tmpfs"
then
echo "Ok, Filesystems are ready for chroot"
return 0
@ -1122,11 +1119,11 @@ mount_virtual_kernel_filesystem() @@ -1122,11 +1119,11 @@ mount_virtual_kernel_filesystem()
return 0
}
lfs_chroot()
lfsdev_chroot()
{
echo "call lfs_chroot $1"
echo "call lfsdev_chroot $1"
CHROOTFILE=$1
sed "1iif [[ ! \"\${UID\}\" -eq 0 ]] && [ ! -e ${CHROOTFILE} ] && [ -e /sources/lfs_build ]" -i "${CHROOTFILE}"
sed "1iif [[ ! \"\${UID\}\" -eq 0 ]] && [ ! -e ${CHROOTFILE} ] && [ -e /sources/lfsdev_build ]" -i "${CHROOTFILE}"
sed "2ithen" -i "${CHROOTFILE}"
sed "3iecho \"bad chroot\"" -i "${CHROOTFILE}"
sed "4iexit 1" -i "${CHROOTFILE}"
@ -1135,7 +1132,7 @@ lfs_chroot() @@ -1135,7 +1132,7 @@ lfs_chroot()
if cat "${CHROOTFILE}" | sudo /usr/sbin/chroot "$LFS" /usr/bin/env -i \
HOME=/root \
TERM="$TERM" \
PS1='(lfs chroot) \u:\w\$ ' \
PS1='(lfsdev chroot) \u:\w\$ ' \
PATH=/usr/bin:/usr/sbin \
LFS_NPROC="${LFS_NPROC}" \
MAKEFLAGS="-j${LFS_NPROC}" \
@ -1164,9 +1161,9 @@ main() { @@ -1164,9 +1161,9 @@ main() {
if [[ $(cat "${HLFSB}") -lt 22000 ]]
then
set +e
version_check | tee /tmp/lfs_version_check.log
version_check | tee /tmp/lfsdev_version_check.log
echo "=== Check for errors ==="
grep ERROR /tmp/lfs_version_check.log && exit 1
grep ERROR /tmp/lfsdev_version_check.log && exit 1
if [ -e /etc/bash.bashrc ]
then
echo "Please disable /etc/bash.bashrc for compilation"
@ -1177,20 +1174,20 @@ main() { @@ -1177,20 +1174,20 @@ main() {
fi
echo "2.7. Mounting the New Partition"
if ! mount |grep -q "/mnt/lfs type ext4"
if ! mount |grep -q "/mnt/lfsdev type ext4"
then
echo "2.4. Creating a New Partition"
echo "2.5. Creating a File System on the Partition"
echo "2.7. Mounting the New Partition"
echo "You have to mount a ext4 partition under /mnt/lfs"
echo "You have to mount a ext4 partition under /mnt/lfsdev"
echo "Think to create a swap partition on the target device"
exit 1
fi
if [ "${LFS}" != "/mnt/lfs" ]
if [ "${LFS}" != "/mnt/lfsdev" ]
then
echo "2.6. Setting the \$LFS Variable and the Umask"
echo "LFS is not /mnt/lfs"
echo "LFS is not /mnt/lfsdev"
exit 1
fi
@ -1247,11 +1244,11 @@ main() { @@ -1247,11 +1244,11 @@ main() {
echo "4.2. Creating a Limited Directory Layout in the LFS Filesystem"
echo "III. Building the LFS Cross Toolchain and Temporary Tools"
echo "Failed to create directories on $LFS"
echo "The user lfs has not sufficient rights"
echo "The user lfsdev has not sufficient rights"
echo "If not, you can fix it manually"
echo "Or the file /tmp/lfs_sudo may be copied under /etc/sudoers.d/lfs"
echo "Or the file /tmp/lfsdev_sudo may be copied under /etc/sudoers.d/lfsdev"
echo "And execute the following command as root to valide syntax"
echo "# visudo /etc/sudoers.d/lfs"
echo "# visudo /etc/sudoers.d/lfsdev"
exit 1
fi
else
@ -1283,9 +1280,9 @@ main() { @@ -1283,9 +1280,9 @@ main() {
echo "Copy scripts to sources failed"
exit 1
else
if [[ ! $(du /mnt/lfs/sources/ |cut -f 1) -gt 500000 ]]
if [[ ! $(du /mnt/lfsdev/sources/ |cut -f 1) -gt 500000 ]]
then
echo "check /mnt/lfs/sources content failed"
echo "check /mnt/lfsdev/sources content failed"
exit 1
fi
echo "48000" > "${HLFSB}"
@ -1298,7 +1295,7 @@ main() { @@ -1298,7 +1295,7 @@ main() {
if [ ! -e "${SLFSB}" ]
then
echo "Initialize lfs_build on /mnt/lfs"
echo "Initialize lfsdev_build on /mnt/lfsdev"
echo "48000" > "${SLFSB}"
rm --force --verbose "${HLFSB}"
ln --symbolic --force --verbose "${SLFSB}" "${HLFSB}"
@ -1324,22 +1321,22 @@ main() { @@ -1324,22 +1321,22 @@ main() {
then
case $(uname -m) in
x86_64)
if [ ! -e /mnt/lfs/tools/x86_64-lfs-linux-gnu/bin/ld ] || \
[ ! -e /mnt/lfs/tools/bin/x86_64-lfs-linux-gnu-gcc ] || \
[ ! -e /mnt/lfs/usr/include/asm/fcntl.h ] || \
[ ! -e /mnt/lfs/usr/sbin/ldconfig ] || \
[ ! -e /mnt/lfs/usr/lib/libstdc++.so.6.0.34 ]
if [ ! -e /mnt/lfsdev/tools/x86_64-lfsdev-linux-gnu/bin/ld ] || \
[ ! -e /mnt/lfsdev/tools/bin/x86_64-lfsdev-linux-gnu-gcc ] || \
[ ! -e /mnt/lfsdev/usr/include/asm/fcntl.h ] || \
[ ! -e /mnt/lfsdev/usr/sbin/ldconfig ] || \
[ ! -e /mnt/lfsdev/usr/lib/libstdc++.so.6.0.34 ]
then
echo "Some binaries are missing from cross_toolchain 5xxxx"
exit 1
fi
;;
i686)
if [ ! -e /mnt/lfs/tools/bin/i686-lfs-linux-gnu-ld ] || \
[ ! -e /mnt/lfs/tools/bin/i686-lfs-linux-gnu-gcc ] || \
[ ! -e /mnt/lfs/usr/include/asm/fcntl.h ] || \
[ ! -e /mnt/lfs/usr/sbin/ldconfig ] || \
[ ! -e /mnt/lfs/usr/lib/libstdc++.so.6.0.34 ]
if [ ! -e /mnt/lfsdev/tools/bin/i686-lfsdev-linux-gnu-ld ] || \
[ ! -e /mnt/lfsdev/tools/bin/i686-lfsdev-linux-gnu-gcc ] || \
[ ! -e /mnt/lfsdev/usr/include/asm/fcntl.h ] || \
[ ! -e /mnt/lfsdev/usr/sbin/ldconfig ] || \
[ ! -e /mnt/lfsdev/usr/lib/libstdc++.so.6.0.34 ]
then
echo "Some binaries are missing from cross_toolchain 5xxxx"
exit 1
@ -1392,7 +1389,7 @@ main() { @@ -1392,7 +1389,7 @@ main() {
if [[ $(cat "${SLFSB}") -lt 70200 ]]
then
echo "Preparing for chroot step."
echo "/mnt/lfs will be closed for chroot"
echo "/mnt/lfsdev will be closed for chroot"
echo "Do you validate preceding steps ?"
if ask_for_exit 61810
then
@ -1407,7 +1404,7 @@ main() { @@ -1407,7 +1404,7 @@ main() {
esac
if sudo /usr/bin/chown -R root:root $LFS/{usr,var,etc,tools}
then
sudo /usr/bin/chown lfs "${SLFSB}" || exit 1
sudo /usr/bin/chown lfsdev "${SLFSB}" || exit 1
echo "70200" > "${SLFSB}"
else
echo "Rights error"
@ -1444,7 +1441,7 @@ main() { @@ -1444,7 +1441,7 @@ main() {
echo "7.5. Creating Directories"
if [[ $(cat "${SLFSB}") -lt 70500 ]]
then
sudofile=/tmp/lfs_70500.sh
sudofile=/tmp/lfsdev_70500.sh
cat > ${sudofile} << "EOSF"
mkdir -pv /{boot,home,mnt,opt,srv}
mkdir -pv /etc/{opt,sysconfig}
@ -1463,7 +1460,7 @@ ln -sfv /run/lock /var/lock @@ -1463,7 +1460,7 @@ ln -sfv /run/lock /var/lock
install -dv -m 0750 /root
install -dv -m 1777 /tmp /var/tmp
EOSF
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "70500" > "${SLFSB}"
fi
@ -1474,7 +1471,7 @@ EOSF @@ -1474,7 +1471,7 @@ EOSF
echo "7.6. Creating Essential Files and Symlinks"
if [[ $(cat "${SLFSB}") -lt 70600 ]]
then
sudofile=/tmp/lfs_70600.sh
sudofile=/tmp/lfsdev_70600.sh
cat > ${sudofile} << "EOSF"
ln -sv /proc/self/mounts /etc/mtab
cat > /etc/hosts << EOF
@ -1541,7 +1538,7 @@ chgrp -v utmp /var/log/lastlog @@ -1541,7 +1538,7 @@ chgrp -v utmp /var/log/lastlog
chmod -v 664 /var/log/lastlog
chmod -v 600 /var/log/btmp
EOSF
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "70600" > "${SLFSB}"
fi
@ -1574,13 +1571,13 @@ EOSF @@ -1574,13 +1571,13 @@ EOSF
echo "7.13. Cleaning up and Saving the Temporary System"
if [[ $(cat "${SLFSB}") -lt 71310 ]]
then
sudofile=/tmp/lfs_71310.sh
sudofile=/tmp/lfsdev_71310.sh
cat > ${sudofile} << "EOSF"
rm -rf /usr/share/{info,man,doc}/*
find /usr/{lib,libexec} -name \*.la -delete
# rm -rf /tools
EOSF
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "71310" > "${SLFSB}"
fi
@ -1689,7 +1686,7 @@ EOSF @@ -1689,7 +1686,7 @@ EOSF
echo "8.85. Stripping"
if [[ $(cat "${SLFSB}") -lt 88510 ]]
then
sudofile=/tmp/lfs_88510.sh
sudofile=/tmp/lfsdev_88510.sh
cat > ${sudofile} << "EOSF"
save_usrlib="$(cd /usr/lib; ls ld-linux*[^g])
libc.so.6
@ -1745,7 +1742,7 @@ EOSF @@ -1745,7 +1742,7 @@ EOSF
echo "Do you want to strip binaries ?"
if ${LFS_STRIP_BINARIES}
then
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "88510" > "${SLFSB}"
fi
@ -1760,14 +1757,14 @@ EOSF @@ -1760,14 +1757,14 @@ EOSF
echo "8.86. Cleaning Up"
if [[ $(cat "${SLFSB}") -lt 88610 ]]
then
sudofile=/tmp/lfs_88610.sh
sudofile=/tmp/lfsdev_88610.sh
cat > ${sudofile} << "EOSF"
#rm -rf /tmp/{*,.*}
find /usr/lib /usr/libexec -name \*.la -delete
find /usr -depth -name $(uname -m)-lfs-linux-gnu\* | xargs rm -rf
find /usr -depth -name $(uname -m)-lfsdev-linux-gnu\* | xargs rm -rf
userdel -r tester
EOSF
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "88610" > "${SLFSB}"
fi
@ -1784,7 +1781,7 @@ EOSF @@ -1784,7 +1781,7 @@ EOSF
echo "90210" > "${SLFSB}"
elif ${LFS_NETWORK}
then
sudofile=/tmp/lfs_90210.sh
sudofile=/tmp/lfsdev_90210.sh
INTERFACE=$(ip route |grep default |cut --delimiter=' ' --fields=5)
GATEWAY=$(ip route |grep default |cut --delimiter=' ' --fields=3)
IPADDRESS=$(ip address show dev "${INTERFACE}" |grep "${INTERFACE}$" |cut --delimiter=' ' --fields=6)
@ -1836,7 +1833,7 @@ EOSF @@ -1836,7 +1833,7 @@ EOSF
;;
esac
echo "Configure network (same as host)"
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "90210" > "${SLFSB}"
else
@ -1855,7 +1852,7 @@ EOSF @@ -1855,7 +1852,7 @@ EOSF
echo "9.6. Configuring the Linux Console"
if [[ $(cat "${SLFSB}") -lt 90610 ]]
then
VCONSOLE=/mnt/lfs/tmp/vconsole.conf
VCONSOLE=/mnt/lfsdev/tmp/vconsole.conf
cat > ${VCONSOLE} << EOSF
KEYMAP=XX
FONT=XX
@ -1931,11 +1928,11 @@ EOSF @@ -1931,11 +1928,11 @@ EOSF
sed "/FONT/s/FONT=XX/FONT=Lat2-Terminus16/" --in-place ${VCONSOLE}
sed "/XKBLAYOUT/s/XKBLAYOUT=XX/XKBLAYOUT=fr/" --in-place ${VCONSOLE}
# building chroot
sudofile=/tmp/lfs_90610.sh
sudofile=/tmp/lfsdev_90610.sh
cat > ${sudofile} << "EOSF"
cp -v /tmp/vconsole.conf /etc/vconsole.conf
EOSF
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "90610" > "${SLFSB}"
else
@ -1949,7 +1946,7 @@ EOSF @@ -1949,7 +1946,7 @@ EOSF
echo "9.7. Configuring the System Locale"
if [[ $(cat "${SLFSB}") -lt 90710 ]]
then
LOCALECONF=/mnt/lfs/tmp/locale.conf
LOCALECONF=/mnt/lfsdev/tmp/locale.conf
cat > ${LOCALECONF} << EOSF
LANG=XX
EOSF
@ -1964,7 +1961,7 @@ EOSF @@ -1964,7 +1961,7 @@ EOSF
fi
# default if nothing is set (if LANG=XX)
sed /LANG/s/LANG=XX/LANG="fr_FR.UTF-8"/ --in-place "${LOCALECONF}"
sudofile=/tmp/lfs_90710.sh
sudofile=/tmp/lfsdev_90710.sh
cat > ${sudofile} << "EOSF"
cp -v /tmp/locale.conf /etc/locale.conf
cat > /etc/profile << "EOF"
@ -1986,7 +1983,7 @@ fi @@ -1986,7 +1983,7 @@ fi
# End /etc/profile
EOF
EOSF
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "90710" > "${SLFSB}"
else
@ -2000,7 +1997,7 @@ EOSF @@ -2000,7 +1997,7 @@ EOSF
echo "9.8. Creating the /etc/inputrc File "
if [[ $(cat "${SLFSB}") -lt 90810 ]]
then
sudofile=/tmp/lfs_90810.sh
sudofile=/tmp/lfsdev_90810.sh
cat > ${sudofile} << "EOSF"
cat > /etc/inputrc << "EOF"
# Begin /etc/inputrc
@ -2036,7 +2033,7 @@ set bell-style none @@ -2036,7 +2033,7 @@ set bell-style none
# End /etc/inputrc
EOF
EOSF
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "90810" > "${SLFSB}"
else
@ -2050,7 +2047,7 @@ EOSF @@ -2050,7 +2047,7 @@ EOSF
echo "9.9. Creating the /etc/shells File"
if [[ $(cat "${SLFSB}") -lt 90910 ]]
then
sudofile=/tmp/lfs_90910.sh
sudofile=/tmp/lfsdev_90910.sh
cat > ${sudofile} << "EOSF"
cat > /etc/shells << "EOF"
# Begin /etc/shells
@ -2059,7 +2056,7 @@ cat > /etc/shells << "EOF" @@ -2059,7 +2056,7 @@ cat > /etc/shells << "EOF"
# End /etc/shells
EOF
EOSF
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "90910" > "${SLFSB}"
else
@ -2073,7 +2070,7 @@ EOSF @@ -2073,7 +2070,7 @@ EOSF
echo "9.10. Systemd Usage and Configuration"
if [[ $(cat "${SLFSB}") -lt 91010 ]]
then
sudofile=/tmp/lfs_91010.sh
sudofile=/tmp/lfsdev_91010.sh
cat > ${sudofile} << "EOSF"
mkdir -pv /etc/systemd/system/getty@tty1.service.d
cat > /etc/systemd/system/getty@tty1.service.d/noclear.conf << EOF
@ -2082,7 +2079,7 @@ TTYVTDisallocate=no @@ -2082,7 +2079,7 @@ TTYVTDisallocate=no
# ln -sfv /dev/null /etc/systemd/system/tmp.mount
EOF
EOSF
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "91010" > "${SLFSB}"
cat <<EOF
@ -2110,7 +2107,7 @@ EOF @@ -2110,7 +2107,7 @@ EOF
then
rm ${FSTAB}
fi
blockdevice="$(mount |grep '/mnt/lfs type ext4' |cut --delimiter=' ' --fields=1 |cut --delimiter='/' --fields=3)"
blockdevice="$(mount |grep '/mnt/lfsdev type ext4' |cut --delimiter=' ' --fields=1 |cut --delimiter='/' --fields=3)"
for link in /dev/disk/by-uuid/*
do
# readlink "${link}"
@ -2153,14 +2150,14 @@ EOSF @@ -2153,14 +2150,14 @@ EOSF
echo "Can't init swap /etc/fstab"
echo "Fix it by ourself"
fi
sudofile=/tmp/lfs_100200.sh
sudofile=/tmp/lfsdev_100200.sh
cat > ${sudofile} << "EOSF"
cp -v /tmp/fstab /etc/fstab
EOSF
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "100200" > "${SLFSB}"
echo "Please check /etc/fstab in /mnt/lfs"
echo "Please check /etc/fstab in /mnt/lfsdev"
echo "Check root and swap"
echo "Add /boot and other mount point if necessary"
else
@ -2180,12 +2177,12 @@ EOSF @@ -2180,12 +2177,12 @@ EOSF
unnumbered=${scriptname##*_}
packagename=${unnumbered%.*}
archivepath=$(find "${SOURCES}" -name "${packagename}*.tar.*" -print)
archivesubpath=${archivepath##/mnt/lfs}
archivesubpath=${archivepath##/mnt/lfsdev}
archivename=$(basename "${archivepath}")
package=${archivename%%.tar.xz}
buildpath=/sources/"${package}"
linuxversion=${package##*-}
sudofile=/tmp/lfs_103100.sh
sudofile=/tmp/lfsdev_103100.sh
cat > "${sudofile}" << EOSF
if [ ! -d "${buildpath}" ]
then
@ -2201,17 +2198,17 @@ then @@ -2201,17 +2198,17 @@ then
fi
pushd "${buildpath}"
set -ueExo pipefail
eval "\$(cat ../"${scriptname}")" | tee "/tmp/lfs_103100.log"
eval "\$(cat ../"${scriptname}")" | tee "/tmp/lfsdev_103100.log"
popd
EOSF
if ! lfs_chroot "${sudofile}"
if ! lfsdev_chroot "${sudofile}"
then
echo "compilation error"
exit 1
else
echo "compilation ok"
fi
check_errors "${STEMP}/lfs_103100.log"
check_errors "${STEMP}/lfsdev_103100.log"
echo 103100 > "${SLFSB}"
fi
@ -2231,13 +2228,13 @@ EOSF @@ -2231,13 +2228,13 @@ EOSF
linuxversion=${package##*-}
if ${LFS_LINUXCONFIG}
then
if cp --verbose "${SCRIPT_DIR}/linux-config-${ARCH}.txt" /mnt/lfs/tmp/linux-config-host
if cp --verbose "${SCRIPT_DIR}/linux-config-${ARCH}.txt" /mnt/lfsdev/tmp/linux-config-host
then
sudofile=/tmp/lfs_103110.sh
sudofile=/tmp/lfsdev_103110.sh
cat > ${sudofile} << EOSF
cp --verbose /tmp/linux-config-host ${buildpath}/.config
EOSF
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "copy ok"
echo "103110" > "${SLFSB}"
@ -2251,7 +2248,7 @@ EOSF @@ -2251,7 +2248,7 @@ EOSF
exit 1
fi
fi
if [ -e /mnt/lfs/sources/"${package}"/.config ]
if [ -e /mnt/lfsdev/sources/"${package}"/.config ]
then
echo "103110" > "${SLFSB}"
echo "A config file for kernel compilation exist"
@ -2260,12 +2257,12 @@ EOSF @@ -2260,12 +2257,12 @@ EOSF
echo "Script is stopped for linux configuration"
echo "It's time to configure kernel compilation"
echo "LFS recommand to compile the kernel by youself"
echo "Please execute as lfs :"
echo "$ bash $HOME/lfs_chroot.sh"
echo "(lfs chroot) root:/$ cd /sources/linux-6.8.10"
echo "(lfs chroot) root:/$ make menuconfig"
echo "Please execute as lfsdev :"
echo "$ bash $HOME/lfsdev_chroot.sh"
echo "(lfsdev chroot) root:/$ cd /sources/linux-6.8.10"
echo "(lfsdev chroot) root:/$ make menuconfig"
echo "you can try this at minimal :"
echo "(lfs chroot) root:/$ make defconfig"
echo "(lfsdev chroot) root:/$ make defconfig"
exit 0
fi
fi
@ -2287,15 +2284,15 @@ EOSF @@ -2287,15 +2284,15 @@ EOSF
if [ ! -e "${LFS}"/"${buildpath}"/.config ]
then
echo "Seems kernel was not configured"
echo "Please execute as lfs :"
echo "$ bash /tmp/lfs_chroot.sh"
echo "(lfs chroot) root:/$ cd ${buildpath}"
echo "(lfs chroot) root:/$ make menuconfig"
echo "Please execute as lfsdev :"
echo "$ bash /tmp/lfsdev_chroot.sh"
echo "(lfsdev chroot) root:/$ cd ${buildpath}"
echo "(lfsdev chroot) root:/$ make menuconfig"
echo "you can try too :"
echo "(lfs chroot) root:/$ make defconfig"
echo "(lfsdev chroot) root:/$ make defconfig"
exit 1
fi
sudofile=/tmp/lfs_103120.sh
sudofile=/tmp/lfsdev_103120.sh
cat > ${sudofile} << EOSF
cd "${buildpath}"
make
@ -2303,7 +2300,7 @@ if grep "CONFIG_MODULES=y" "${buildpath}"/.config @@ -2303,7 +2300,7 @@ if grep "CONFIG_MODULES=y" "${buildpath}"/.config
then
make modules
fi
cp -v arch/x86/boot/bzImage /boot/vmlinuz-${linuxversion}-lfs-13.0-systemd
cp -v arch/x86/boot/bzImage /boot/vmlinuz-${linuxversion}-lfsdev-13.0-systemd
cp -v System.map /boot/System.map-${linuxversion}
cp -v .config /boot/config-${linuxversion}
cp -r Documentation -T /usr/share/doc/${package}
@ -2315,7 +2312,7 @@ install uhci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i uhci_hcd ; true @@ -2315,7 +2312,7 @@ install uhci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i uhci_hcd ; true
# End /etc/modprobe.d/usb.conf
EOF
EOSF
if ! lfs_chroot "${sudofile}"
if ! lfsdev_chroot "${sudofile}"
then
echo "compilation error"
exit 1
@ -2337,7 +2334,7 @@ EOSF @@ -2337,7 +2334,7 @@ EOSF
buildpath=/sources/"${package}"
linuxversion=${package##*-}
# get root device uuid
blockdevice=$(mount |grep '/mnt/lfs type ext4' | cut --delimiter=' ' --fields=1)
blockdevice=$(mount |grep '/mnt/lfsdev type ext4' | cut --delimiter=' ' --fields=1)
#for link in /dev/disk/by-uuid/*
#do
# case $(readlink "${link}") in
@ -2357,24 +2354,24 @@ EOSF @@ -2357,24 +2354,24 @@ EOSF
# esac
#done
#
if [ ! -e "$LFS/boot/vmlinuz-${linuxversion}-lfs-13.0-systemd" ]
if [ ! -e "$LFS/boot/vmlinuz-${linuxversion}-lfsdev-13.0-systemd" ]
then
echo "Kernel file absent from /boot"
exit 1
fi
uuidfilesystem=$(lsblk -o UUID,PARTUUID,PATH,MOUNTPOINT |grep /mnt/lfs$ |cut --delimiter=' ' --fields=1)
uuidfilesystem=$(lsblk -o UUID,PARTUUID,PATH,MOUNTPOINT |grep /mnt/lfsdev$ |cut --delimiter=' ' --fields=1)
if [[ ! "${uuidfilesystem}" =~ ^[a-z0-9-]+$ ]]
then
echo "UUID seems bad"
exit 1
fi
uuidpartition=$(lsblk -o UUID,PARTUUID,PATH,MOUNTPOINT |grep /mnt/lfs$ |sed -e "s/ */ /g" |cut --delimiter=' ' --fields=2)
uuidpartition=$(lsblk -o UUID,PARTUUID,PATH,MOUNTPOINT |grep /mnt/lfsdev$ |sed -e "s/ */ /g" |cut --delimiter=' ' --fields=2)
if [[ ! "${uuidpartition}" =~ ^[a-z0-9-]+$ ]]
then
echo "PARTUUID seems bad"
exit 1
fi
sudofile=/tmp/lfs_104000.sh
sudofile=/tmp/lfsdev_104000.sh
cat > ${sudofile} << EOSF
mkdir --verbose /boot/grub
cat > /boot/grub/grub.cfg << "EOF"
@ -2385,15 +2382,15 @@ insmod part_gpt @@ -2385,15 +2382,15 @@ insmod part_gpt
insmod ext2
search --set=root --fs-uuid=${uuidfilesystem}
set gfxpayload=1024x768x32
menuentry "GNU/Linux, Linux ${linuxversion}-lfs-13.0-systemd with blockdevice" {
linux /boot/vmlinuz-${linuxversion}-lfs-13.0-systemd root=${blockdevice} ro
menuentry "GNU/Linux, Linux ${linuxversion}-lfsdev-13.0-systemd with blockdevice" {
linux /boot/vmlinuz-${linuxversion}-lfsdev-13.0-systemd root=${blockdevice} ro
}
menuentry "GNU/Linux, Linux ${linuxversion}-lfs-13.0-systemd with partuuid" {
linux /boot/vmlinuz-${linuxversion}-lfs-13.0-systemd root=PARTUUID=${uuidpartition} ro
menuentry "GNU/Linux, Linux ${linuxversion}-lfsdev-13.0-systemd with partuuid" {
linux /boot/vmlinuz-${linuxversion}-lfsdev-13.0-systemd root=PARTUUID=${uuidpartition} ro
}
EOF
EOSF
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "104000" > "${SLFSB}"
else
@ -2407,9 +2404,9 @@ EOSF @@ -2407,9 +2404,9 @@ EOSF
echo "11.1. The End"
if [[ $(cat "${SLFSB}") -lt 110100 ]]
then
sudofile=/tmp/lfs_110100.sh
sudofile=/tmp/lfsdev_110100.sh
cat > ${sudofile} << EOSF
echo 13.0-systemd > /etc/lfs-release
echo 13.0-systemd > /etc/lfsdev-release
cat > /etc/lsb-release << "EOF"
DISTRIB_ID="Linux From Scratch"
DISTRIB_RELEASE="13.0-systemd"
@ -2419,12 +2416,12 @@ EOF @@ -2419,12 +2416,12 @@ EOF
cat > /etc/os-release << "EOF"
NAME="Linux From Scratch"
VERSION="13.0-systemd"
ID=lfs
ID=lfsdev
PRETTY_NAME="Linux From Scratch 13.0-systemd"
VERSION_CODENAME="<your name here>"
EOF
EOSF
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "104000" > "${SLFSB}"
else
@ -2438,9 +2435,9 @@ EOSF @@ -2438,9 +2435,9 @@ EOSF
echo "11.1. The End"
if [[ $(cat "${SLFSB}") -lt 110100 ]]
then
sudofile=/tmp/lfs_110100.sh
sudofile=/tmp/lfsdev_110100.sh
cat > ${sudofile} << EOSF
echo 13.0-systemd > /etc/lfs-release
echo 13.0-systemd > /etc/lfsdev-release
cat > /etc/lsb-release << "EOF"
DISTRIB_ID="Linux From Scratch"
DISTRIB_RELEASE="13.0-systemd"
@ -2450,14 +2447,14 @@ EOF @@ -2450,14 +2447,14 @@ EOF
cat > /etc/os-release << "EOF"
NAME="Linux From Scratch"
VERSION="13.0-systemd"
ID=lfs
ID=lfsdev
PRETTY_NAME="Linux From Scratch 13.0-systemd"
VERSION_CODENAME="<your name here>"
HOME_URL="https://www.linuxfromscratch.org/lfs/"
RELEASE_TYPE="stable"
EOF
EOSF
if lfs_chroot "${sudofile}"
if lfsdev_chroot "${sudofile}"
then
echo "You can edit /etc/lsb-release and /etc/os-release and edit your name"
echo "110100" > "${SLFSB}"
@ -2470,7 +2467,7 @@ EOSF @@ -2470,7 +2467,7 @@ EOSF
echo "Finish successfully"
echo "Adapt /boot/grub/grub.cfg to your configuration"
echo "And install the bootloader if needed with the appropriate boot device"
echo "(lfs chroot) root:/$ grub-install /dev/xda"
echo "(lfsdev chroot) root:/$ grub-install /dev/xda"
}

Loading…
Cancel
Save