Initial commit of LFS notes and scripts.

This commit is contained in:
Shaun Setlock
2025-01-20 15:44:57 -05:00
commit 386dc3cec7
78 changed files with 2628 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
# For doing Linux
dnf install -y vim tmux git wget tree
# For bpytop
dnf install python-pip3
python3 -m pip install psutil
mkdir -p /root/sources && cd /root/sources
git clone https://github.com/aristocratos/bpytop.git
cd bpytop
make install
# For fastfetch
dnf install cmake
mkdir -p /root/sources && cd /root/sources
git clone https://github.com/fastfetch-cli/fastfetch.git
cd fastfetch
mkdir build && cd build
cmake ..
cmake --build . --target fastfetch --target flashfetch
cmake --install . --prefix /usr/local

View File

@@ -0,0 +1,63 @@
# Chapter 2
## Section 2 Preparing Host
Two issues encountered after running `bash version_check.sh`.
1. Missing `texinfo`
`dnf install texinfo -y`
2. `yacc` is NOT `bison`
`ln -s /usr/bin/bison /usr/bin/yacc`
## Section 4 Partitioning
Label disk with GPT.
```
fdisk /dev/sdb
g
w
```
Create partitions.
1. Boot ("/boot") - 1M
- Ensure the partition type is switched to "Bios boot".
1. Swap - 2G
- Ensure the partition type is switched to "Linux swap".
1. Root ("/") - 10G
1. Home ("/home") - 10G
## Section 5 Filesystems
Make swap on the swap partition.
`mkswap /dev/sdb2`
`swaplabel -L lfs_swap /dev/sdb2`
Make ext4 on / and /home.
`mkfs -v -t ext4 /dev/sdb3`
`e2label /dev/sdb3 lfs_root`
`mkfs -v -t ext4 /dev/sdb4`
`e2label /dev/sdb4 lfs_home
## Section 6 Setting $LFS
I will follow the book.
`export LFS=/mnt/lfs`
`echo "export LFS=/mnt/lfs" >> /root/.bash_profile`
## Mounting LFS Filesystems (via /etc/fstab)
The book outlines temporarily mounting, and indicates consideration should be given to /etc/fstab entries.
First, we'll make the /mnt/lfs mountpoint(s). The below will create both /mnt/lfs and /mnt/lfs/home.
`mkdir -pv $LFS/home`
We will append the following to the host's /etc/fstab file.
```
# LFS mounts
UUID=49600a93-8e64-4ac1-b7d9-7a5ccdb2b179 /mnt/lfs ext4 defaults,nofail 0 0
UUID=0c0505fe-b133-4257-888e-9b16f4fca86c /mnt/lfs/home ext4 defaults,nofail 0 0
UUID=5bd12ccf-c72f-4cca-8a6a-7d40e847fc42 none swap defaults,nofail 0 0
```
Then load the new /etc/fstab file.
`systemctl daemon-reload`
And finally mount the new filesystems automatically.
`mount -a`
With the following output ...
```
# lsblk
sdb 8:16 0 30G 0 disk
├─sdb1 8:17 0 511M 0 part
├─sdb2 8:18 0 2G 0 part
├─sdb3 8:19 0 10G 0 part /mnt/lfs
└─sdb4 8:20 0 10G 0 part /mnt/lfs/home
```

View File

@@ -0,0 +1,90 @@
#!/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.
LC_ALL=C
PATH=/usr/bin:/bin
bail() { echo "FATAL: $1"; exit 1; }
grep --version > /dev/null 2> /dev/null || bail "grep does not work"
sed '' /dev/null || bail "sed does not work"
sort /dev/null || bail "sort does not work"
ver_check()
{
if ! type -p $2 &>/dev/null
then
echo "ERROR: Cannot find $2 ($1)"; return 1;
fi
v=$($2 --version 2>&1 | grep -E -o '[0-9]+\.[0-9\.]+[a-z]*' | head -n1)
if printf '%s\n' $3 $v | sort --version-sort --check &>/dev/null
then
printf "OK: %-9s %-6s >= $3\n" "$1" "$v"; return 0;
else
printf "ERROR: %-9s is TOO OLD ($3 or later required)\n" "$1";
return 1;
fi
}
ver_kernel()
{
kver=$(uname -r | grep -E -o '^[0-9\.]+')
if printf '%s\n' $1 $kver | sort --version-sort --check &>/dev/null
then
printf "OK: Linux Kernel $kver >= $1\n"; return 0;
else
printf "ERROR: Linux Kernel ($kver) is TOO OLD ($1 or later required)\n" "$kver";
return 1;
fi
}
# Coreutils first because --version-sort needs Coreutils >= 7.0
ver_check Coreutils sort 8.1 || bail "Coreutils too old, stop"
ver_check Bash bash 3.2
ver_check Binutils ld 2.13.1
ver_check Bison bison 2.7
ver_check Diffutils diff 2.8.1
ver_check Findutils find 4.2.31
ver_check Gawk gawk 4.0.1
ver_check GCC gcc 5.2
ver_check "GCC (C++)" g++ 5.2
ver_check Grep grep 2.5.1a
ver_check Gzip gzip 1.3.12
ver_check M4 m4 1.4.10
ver_check Make make 4.0
ver_check Patch patch 2.5.4
ver_check Perl perl 5.8.8
ver_check Python python3 3.4
ver_check Sed sed 4.1.5
ver_check Tar tar 1.22
ver_check Texinfo texi2any 5.0
ver_check Xz xz 5.0.0
ver_kernel 4.19
if mount | grep -q 'devpts on /dev/pts' && [ -e /dev/ptmx ]
then echo "OK: Linux Kernel supports UNIX 98 PTY";
else echo "ERROR: Linux Kernel does NOT support UNIX 98 PTY"; fi
alias_check() {
if $1 --version 2>&1 | grep -qi $2
then printf "OK: %-4s is $2\n" "$1";
else printf "ERROR: %-4s is NOT $2\n" "$1"; fi
}
echo "Aliases:"
alias_check awk GNU
alias_check yacc Bison
alias_check sh Bash
echo "Compiler check:"
if printf "int main(){}" | g++ -x c++ -
then echo "OK: g++ works";
else echo "ERROR: g++ does NOT work"; fi
rm -f a.out
if [ "$(nproc)" = "" ]; then
echo "ERROR: nproc is not available or it produces empty output"
else
echo "OK: nproc reports $(nproc) logical cores are available"
fi

View File

@@ -0,0 +1,20 @@
# Chapter 3
## Section 1 Intro
## Section 2 Packages
Make a directory for all the sources of packages/patches we're going to build.
`mkdir -v $LFS/sources`
Make it sticky and writable.
`chmod -v a+wt $LFS/sources`
Fetch the list of all packages needed.
`wget https://www.linuxfromscratch.org/lfs/downloads/stable-systemd/wget-list`
Pull them all down.
`wget --input-file=wget-list --continue --directory-prefix=$LFS/sources`
Fetch their MD5 checksums.
`wget https://www.linuxfromscratch.org/lfs/downloads/stable-systemd/md5sums`
Check every package for its integrity.
```
pushd $LFS/sources
md5sum -c md5sums
popd
```
## Section 3 Patches

View File

@@ -0,0 +1,68 @@
# Chapter 4
## Section 1 Intro
## Section 2 Simple File Structure
We start by building simple of the early pieces of the file structure.
The following is to be performed as root. These directories are not owned by an unprivileged user.
```
mkdir -pv $LFS/{etc,var} $LFS/usr/{bin,lib,sbin}
for i in bin lib sbin; do
ln -sv usr/$i $LFS/$i
done
case $(uname -m) in
x86_64) mkdir -pv $LFS/lib64 ;;
esac
```
We will also make a special, temporary directory for the cross compiler toolchain.
`mkdir -pv $LFS/tools`
## Section 3 The lfs User
As a measure of caution, let's proceed with the remaining steps as a normal user.
We will use the name lfs since it is unlikely to be found on the host system.
```
groupadd lfs
useradd -s /bin/bash -g lfs -m -k /dev/null lfs
```
Though not strictly required, we can set the password for the lfs user.
`passwd lfs`
Then, let's transfer ownership of this simple file structure to the lfs user.
```
chown -v lfs $LFS/{usr{,/*},lib,var,etc,bin,sbin,tools}
case $(uname -m) in
x86_64) chown -v lfs $LFS/lib64 ;;
esac
```
Finally, let's become lfs.
`su - lfs`
## Section 4 Setting Up The Environment
Create the bash profile for lfs.
```
cat > ~/.bash_profile << "EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
EOF
```
And the bashrc for lfs.
```
cat > ~/.bashrc << "EOF"
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=$(uname -m)-lfs-linux-gnu
PATH=/usr/bin
if [ ! -L /bin ]; then PATH=/bin:$PATH; fi
PATH=$LFS/tools/bin:$PATH
CONFIG_SITE=$LFS/usr/share/config.site
export LFS LC_ALL LFS_TGT PATH CONFIG_SITE
EOF
```
Since this system will only be used for this project, it is safe to force builds to use all cores.
```
cat >> ~/.bashrc << "EOF"
export MAKEFLAGS=-j$(nproc)
EOF
```
Finally, let's load this new environment setup contained within the bash profile and rc.
`source ~/.bash_profile`

View File

@@ -0,0 +1,124 @@
# Chapter 5
## Section 2 Install Binutils (1st Pass)
A couple things to check before proceeding:
1. `echo $LFS` to ensure that environment variable is pointing in the correct location.
1. `whoami` to ensure we are running as the lfs user.
>[!Recall We are about create the cross-compiler and associated tools.]
We start by extracting the tar.
`tar -xvf binutils-2.43.1.tar.xz`
Then, move into the unpacked tape archive.
`cd binutils-2.43.1`
Create a subdirectory where we will build the files, and move into it.
```
mkdir -v build
cd build
```
Prepare for compilation.
```
../configure --prefix=$LFS/tools \
--with-sysroot=$LFS \
--target=$LFS_TGT \
--disable-nls \
--enable-gprofng=no \
--disable-werror \
--enable-new-dtags \
--enable-default-hash-style=gnu
```
We now have a Makefile, so we can run `make` to compile `binutils`.
`make`
And finally, we can install the compiled package into an area of our lfs environment, again using make.
`make install`
## Section 3 Install of GCC (1st Pass)
Similar to binutils, the steps are,
1. Upack the tar of GCC.
1. EXTRA STEP, GCC requires additional packages, so unpack those within the extracted GCC folder.
1. EXTRA STEP, set a variable so that 64-bit OS's know to use lib64.
1. Create build directory.
1. configure, make, make install ...
1. EXTRA STEP, one file is incomplete the follow command is needed to complete it temporarily.
```
cd ..
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include/limits.h
```
## Section 4 Install Linux API Headers
This one is a little different,
1. Remove stale files with make,
`make mrproper`
1. Generate headers with make,
```
make headers
find usr/include -type f ! -name '*.h' -delete
cp -rv usr/include $LFS/usr
```
## Section 5 Install Glibc
Start by unpacking the tarball.
`tar -xvf glibc-2.40.tar.xz`
Create symbolic links for LSB compliance of 64-bit systems.
```
case $(uname -m) in
i?86) ln -sfv ld-linux.so.2 $LFS/lib/ld-lsb.so.3
;;
x86_64) ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3
;;
esac
```
glibc has a patch in this release, so we need to apply it.
`patch -Np1 -i ../glibc-2.40-fhs-1.patch`
Create a build directory, as usual.
`mkdir -v build && cd build`
Create a file called configparams that ensure `ldconfig` and `sln` are available.
`echo "rootsbindir=/usr/sbin" > configparms`
Then, configure to prepare for compilation.
```
../configure \
--prefix=/usr \
--host=$LFS_TGT \
--build=$(../scripts/config.guess) \
--enable-kernel=4.19 \
--with-headers=$LFS/usr/include \
--disable-nscd \
libc_cv_slibdir=/usr/lib
```
Then compile and install,
```
make
make DESTDIR=$LFS install
```
Fix a hardcoded path using sed,
`sed '/RTLDLIST=/s@/usr@@g' -i $LFS/usr/bin/ldd`
Finally, run some tests.
```
bash-5.1$ echo 'int main(){}' | $LFS_TGT-gcc -xc -
readelf -l a.out | grep ld-linux
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
bash-5.1$ rm -v a.out
removed 'a.out'
bash-5.1$
```
## Section 6 Install libstdc++
libstdc++ is part of GCC, but had to skip it during the first install of GCC because we didnt have glibc yet.
Unpack (or change back into) gcc and create a build directory.
`mkdir -v build && cd build`
Configure the make tool.
```
../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++/14.2.0
```
Compile and install.
```
make
make DESTDIR=$LFS install
```
Finally, remove libtool archive files because they're "harmful" for cross-compilation.
`rm -v $LFS/usr/lib/lib{stdc++{,exp,fs},supc++}.la`

View File

@@ -0,0 +1,26 @@
# Chapter 6
This chapter is all about creating tools to enable building even more tools.
In this case, these tools are cross compiled. (i.e. Built with host and targeted at lfs root.)
The tools that are created are runnable in the new, target environment. They'll be create tools natively, after chroot.
Here's the list:
1. M4
1. Ncurses
1. Bash
1. Coreutils
1. Diffutils
1. File
1. Findutils
1. Gawk
1. Grep
1. Gzip
1. Make
1. Patch
1. Sed
1. Tar
1. xz
1. Binutils (2nd Pass)
1. GCC (2nd Pass)

View File

@@ -0,0 +1,190 @@
# Chapter 7 - Chroot and Build More Tools
## Sections 7.1 - 7.3
First, the small starter filesystem we built at $LFS needs to be owned by root.
Otherwise, when we chroot, these files will be owned by a user ID for a user that doesn't exist.
```
chown --from lfs -R root:root $LFS/{usr,lib,var,etc,bin,sbin,tools}
case $(uname -m) in
x86_64) chown --from lfs -R root:root $LFS/lib64 ;;
esac
```
We can now build the "virtual filesystems" which are not on disk, hence the name.
These are used by the kernel so other systems can interact with it.
`mkdir -pv $LFS/{dev,proc,sys,run}`
Here's a snapshot of the environment we've built, so far ...
```
[root@lfs ~]# tree $LFS -L 1
/mnt/lfs
├── bin -> usr/bin
├── dev
├── etc
├── home
├── lib -> usr/lib
├── lib64
├── lost+found
├── proc
├── run
├── sbin -> usr/sbin
├── sources
├── sys
├── tools
├── usr
└── var
```
Typically, at boot, the kernel populates /dev with *devtmpfs* but since we will be chroot'ing into this
filesystem, we can bind mount our host's /dev directory.
`mount -v --bind /dev $LFS/dev`
We can now create the remaining virtual filesystems and mount them at their mountpoints.
```
mount -vt devpts devpts -o gid=5,mode=0620 $LFS/dev/pts
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
mount -vt tmpfs tmpfs $LFS/run
```
And finally, deal with `shm`, as needed.
```
if [ -h $LFS/dev/shm ]; then
install -v -d -m 1777 $LFS$(realpath /dev/shm)
else
mount -vt tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm
fi
```
## Section 7.4 (Chroot!!!)
Now that all the packages which are required to build the rest of the needed tools are on the system, it is time to enter
the chroot environment and finish installing the temporary tools.
This environment will also be used to install the final system. As user root, run the following command to enter the environment that is, at the moment, populated with nothing but temporary tools.
```
chroot "$LFS" /usr/bin/env -i \
HOME=/root \
TERM="$TERM" \
PS1='(lfs chroot) \u:\w\$ ' \
PATH=/usr/bin:/usr/sbin \
MAKEFLAGS="-j$(nproc)" \
TESTSUITEFLAGS="-j$(nproc)" \
/bin/bash --login
```
## Section 7.5 - Directories
From within this chroot, we can start building out the directory structure.
```
mkdir -pv /{boot,home,mnt,opt,srv}
mkdir -pv /etc/{opt,sysconfig}
mkdir -pv /lib/firmware
mkdir -pv /media/{floppy,cdrom}
mkdir -pv /usr/{,local/}{include,src}
mkdir -pv /usr/lib/locale
mkdir -pv /usr/local/{bin,lib,sbin}
mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man}
mkdir -pv /usr/{,local/}share/{misc,terminfo,zoneinfo}
mkdir -pv /usr/{,local/}share/man/man{1..8}
mkdir -pv /var/{cache,local,log,mail,opt,spool}
mkdir -pv /var/lib/{color,misc,locate}
ln -sfv /run /var/run
ln -sfv /run/lock /var/lock
install -dv -m 0750 /root
install -dv -m 1777 /tmp /var/tmp
```
*NOTE* This includes a sticky bit on certain directories will allow users to write, but not delete another user's files.
# Section 7.6 Essential Files and Symlinks
We link the modern /proc location of kernel mountpoint.
`ln -sv /proc/self/mounts /etc/mtab`
Create an `/etc/hosts/` file.
```
cat > /etc/hosts << EOF
127.0.0.1 localhost $(hostname)
::1 localhost
EOF
```
We need root to be able to login, so `/etc/passwd` and `/etc/groups` files are needed.
```
cat > /etc/passwd << "EOF"
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/dev/null:/usr/bin/false
daemon:x:6:6:Daemon User:/dev/null:/usr/bin/false
messagebus:x:18:18:D-Bus Message Daemon User:/run/dbus:/usr/bin/false
systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/usr/bin/false
systemd-journal-remote:x:74:74:systemd Journal Remote:/:/usr/bin/false
systemd-journal-upload:x:75:75:systemd Journal Upload:/:/usr/bin/false
systemd-network:x:76:76:systemd Network Management:/:/usr/bin/false
systemd-resolve:x:77:77:systemd Resolver:/:/usr/bin/false
systemd-timesync:x:78:78:systemd Time Synchronization:/:/usr/bin/false
systemd-coredump:x:79:79:systemd Core Dumper:/:/usr/bin/false
uuidd:x:80:80:UUID Generation Daemon User:/dev/null:/usr/bin/false
systemd-oom:x:81:81:systemd Out Of Memory Daemon:/:/usr/bin/false
nobody:x:65534:65534:Unprivileged User:/dev/null:/usr/bin/false
EOF
```
and
```
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:
cdrom:x:15:
adm:x:16:
messagebus:x:18:
systemd-journal:x:23:
input:x:24:
mail:x:34:
kvm:x:61:
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:
uuidd:x:80:
systemd-oom:x:81:
wheel:x:97:
users:x:999:
nogroup:x:65534:
EOF
```
We should also define the locale for packages which require it.
`localedef -i C -f UTF-8 C.UTF-8`
Add an ordinary user for some packages that need a regular user for testing.
```
echo "tester:x:101:101::/home/tester:/bin/bash" >> /etc/passwd
echo "tester:x:101:" >> /etc/group
install -o tester -d /home/tester
```
We are about to have our first user login, so let's make a couple log locations.
```
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
```
Finally, we can now be able to login as `root`. (Or `tester`, theoretically.)
`exec /usr/bin/bash --login`
*NOTE:*The "i have no name" should change.
# Section 7.7-7.12
Just follow the book for these package installations.
- Gettext
- Bison
- Perl
- Python
- Texinfo
- Util-linux
# Section 7.13 Clean Up
Some clean up steps can be done before performing the final package installs.
```
rm -rf /usr/share/{info,man,doc}/*
find /usr/{lib,libexec} -name \*.la -delete
rm -rf /tools
```
*NOTE:*The final step is to make a backup, but I'll just snapshot the VM.

View File

@@ -0,0 +1,5 @@
# Introduction to Part III
There are really three steps.
1. Build a limited cross compiler and its required libraries.
1. Use this cross toolchain to build utilities that are isolated from the host.
1. `chroot` into the new environment and complete the build of tools needed to construct the final system.

View File

@@ -0,0 +1,93 @@
# Chapter 8 - Install Basic System Software
## Sections 8.3 - 8.822
Just follow the book for these package installations.
- [x] Man-pages-6.9.1
- [x] Iana-Etc-20240806
- [x] Glibc-2.40
- [x] Zlib-1.3.1
- [x] Bzip2-1.0.8
- [x] Xz-5.6.2
- [x] Lz4-1.10.0
- [x] Zstd-1.5.6
- [x] File-5.45
- [x] Readline-8.2.13
- [x] M4-1.4.19
- [x] Bc-6.7.6
- [x] Flex-2.6.4
- [x] Tcl-8.6.14
- [x] Expect-5.45.4
- [x] DejaGNU-1.6.3
- [x] Pkgconf-2.3.0
- [x] Binutils-2.43.1
- [x] GMP-6.3.0
- [x] MPFR-4.2.1
- [x] MPC-1.3.1
- [x] Attr-2.5.2
- [x] Acl-2.3.2
- [x] Libcap-2.70
- [x] Libxcrypt-4.4.36
- [x] Shadow-4.16.0
- [x] GCC-14.2.0
- [x] Ncurses-6.5
- [x] Sed-4.9
- [x] Psmisc-23.7
- [x] Gettext-0.22.5
- [x] Bison-3.8.2
- [x] Grep-3.11
- [x] Bash-5.2.32
- [x] Libtool-2.4.7
- [x] GDBM-1.24
- [x] Gperf-3.1
- [x] Expat-2.6.2
- [x] Inetutils-2.5
- [x] Less-661
- [x] Perl-5.40.0
- [x] XML::Parser-2.47
- [x] Intltool-0.51.0
- [x] Autoconf-2.72
- [x] Automake-1.17
- [x] OpenSSL-3.3.1
- [x] Kmod-33
- [x] Libelf from Elfutils-0.191
- [x] Libffi-3.4.6
- [x] Python-3.12.5
- [x] Flit-Core-3.9.0
- [x] Wheel-0.44.0
- [x] Setuptools-72.2.0
- [x] Ninja-1.12.1
- [x] Meson-1.5.1
- [x] Coreutils-9.5
- [x] Check-0.15.2
- [x] Diffutils-3.10
- [x] Gawk-5.3.0
- [x] Findutils-4.10.0
- [x] Groff-1.23.0
- [x] GRUB-2.12
- [x] Gzip-1.13
- [x] IPRoute2-6.10.0
- [x] Kbd-2.6.4
- [x] Libpipeline-1.5.7
- [x] Make-4.4.1
- [x] Patch-2.7.6
- [x] Tar-1.35
- [x] Texinfo-7.1
- [x] Vim-9.1.0660
- [x] MarkupSafe-2.1.5
- [x] Jinja2-3.1.4
- [x] Systemd-256.4
- [ ] D-Bus-1.14.10
- [x] Man-DB-2.12.1
- [x] Procps-ng-4.0.4
- [x] Util-linux-2.40.2
- [x] E2fsprogs-1.47.1
- [x] Sysklogd-2.6.1
- [x] SysVinit-3.10
## Cleaning Up
A script was created to perform the cleanup steps.
```
rm -rf /tmp/{*,.*}
find /usr/lib /usr/libexec -name \*.la -delete
find /usr -depth -name $(uname -m)-lfs-linux-gnu\* | xargs rm -rf
userdel -r tester
```

View File

@@ -0,0 +1,3 @@
# Chapter 9 - System Configuration
## Sections 9.1

View File

@@ -0,0 +1,3 @@
# Introduction to Part IV
In this chapter, we start constructing the LFS system in earnest.
The installation of this software is straightforward. Although in many cases the installation instructions could be made shorter and more generic, we have opted to provide the full instructions for every package to minimize the possibilities for mistakes. The key to learning what makes a Linux system work is to know what each package is used for and why you (or the system) may need it.

25
lfs-scripts/acl.sh Normal file
View File

@@ -0,0 +1,25 @@
# Set the package we're building.
package="acl-2.3.2"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/acl-2.3.2
make && make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

28
lfs-scripts/attr.sh Normal file
View File

@@ -0,0 +1,28 @@
# Set the package we're building.
package="attr-2.5.2"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--disable-static \
--sysconfdir=/etc \
--docdir=/usr/share/doc/attr-2.5.2
make
make check
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

26
lfs-scripts/autoconf.sh Normal file
View File

@@ -0,0 +1,26 @@
# Set the package we're building.
package="autoconf-2.72"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr
make
make check
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

26
lfs-scripts/automake.sh Normal file
View File

@@ -0,0 +1,26 @@
# Set the package we're building.
package="automake-1.17"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr --docdir=/usr/share/doc/automake-1.17
make
make -j$(($(nproc)>4?$(nproc):4)) check
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

29
lfs-scripts/bash.sh Normal file
View File

@@ -0,0 +1,29 @@
# Set the package we're building.
package="bash-5.2.32"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--without-bash-malloc \
--with-installed-readline \
bash_cv_strtold_broken=no \
--docdir=/usr/share/doc/bash-5.2.32
make
chown -R tester .
su -s /usr/bin/expect tester << "EOF"
set timeout -1
spawn make tests
expect eof
lassign [wait] _ _ _ value
exit $value
EOF
make install
exec /usr/bin/bash --login

23
lfs-scripts/bison.sh Normal file
View File

@@ -0,0 +1,23 @@
# Set the package we're building.
package="bison-3.8.2"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr --docdir=/usr/share/doc/bison-3.8.2
make && make check && make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

22
lfs-scripts/blank.sh Normal file
View File

@@ -0,0 +1,22 @@
# Set the package we're building.
package=""
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

View File

@@ -0,0 +1,4 @@
rm -rf /tmp/{*,.*}
find /usr/lib /usr/libexec -name \*.la -delete
find /usr -depth -name $(uname -m)-lfs-linux-gnu\* | xargs rm -rf
userdel -r tester

26
lfs-scripts/check.sh Normal file
View File

@@ -0,0 +1,26 @@
# Set the package we're building.
package="check-0.15.2"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr --disable-static
make
make check
make docdir=/usr/share/doc/check-0.15.2 install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

37
lfs-scripts/coreutils.sh Normal file
View File

@@ -0,0 +1,37 @@
# Set the package we're building.
package="coreutils-9.5"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
patch -Np1 -i ../coreutils-9.5-i18n-2.patch
autoreconf -fiv
FORCE_UNSAFE_CONFIGURE=1 ./configure \
--prefix=/usr \
--enable-no-install-program=kill,uptime
make
make NON_ROOT_USERNAME=tester check-root
groupadd -g 102 dummy -U tester
chown -R tester .
su tester -c "PATH=$PATH make -k RUN_EXPENSIVE_TESTS=yes check" \
< /dev/null
groupdel dummy
make install
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"/' /usr/share/man/man8/chroot.8
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

25
lfs-scripts/diffutils.sh Normal file
View File

@@ -0,0 +1,25 @@
# Set the package we're building.
package="diffutils-3.10"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr
make
make check
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

41
lfs-scripts/e2fsprogs.sh Normal file
View File

@@ -0,0 +1,41 @@
# Set the package we're building.
package="e2fsprogs-1.47.1"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
mkdir -v build
cd build
../configure --prefix=/usr \
--sysconfdir=/etc \
--enable-elf-shlibs \
--disable-libblkid \
--disable-libuuid \
--disable-uuidd \
--disable-fsck
make
make check
make install
rm -fv /usr/lib/{libcom_err,libe2p,libext2fs,libss}.a
gunzip -v /usr/share/info/libext2fs.info.gz
install-info --dir-file=/usr/share/info/dir /usr/share/info/libext2fs.info
makeinfo -o doc/com_err.info ../lib/et/com_err.texinfo
install -v -m644 doc/com_err.info /usr/share/info
install-info --dir-file=/usr/share/info/dir /usr/share/info/com_err.info
sed 's/metadata_csum_seed,//' -i /etc/mke2fs.conf
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

26
lfs-scripts/expat.sh Normal file
View File

@@ -0,0 +1,26 @@
# Set the package we're building.
package="expat-2.6.2"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/expat-2.6.2
make && make check && make install
install -v -m644 doc/*.{html,css} /usr/share/doc/expat-2.6.2
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

26
lfs-scripts/findutils.sh Normal file
View File

@@ -0,0 +1,26 @@
# Set the package we're building.
package="findutils-4.10.0"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr --localstatedir=/var/lib/locate
make
chown -R tester .
su tester -c "PATH=$PATH make check"
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

24
lfs-scripts/flit_core.sh Normal file
View File

@@ -0,0 +1,24 @@
# Set the package we're building.
package="flit_core-3.9.0"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
pip3 wheel -w dist --no-cache-dir --no-build-isolation --no-deps $PWD
pip3 install --no-index --no-user --find-links dist flit_core
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

31
lfs-scripts/gawk.sh Normal file
View File

@@ -0,0 +1,31 @@
# Set the package we're building.
package="gawk-5.3.0"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
sed -i 's/extras//' Makefile.in
./configure --prefix=/usr
make
chown -R tester .
su tester -c "PATH=$PATH make check"
rm -f /usr/bin/gawk-5.3.0
make install
ln -sv gawk.1 /usr/share/man/man1/awk.1
mkdir -pv /usr/share/doc/gawk-5.3.0
cp -v doc/{awkforai.txt,*.{eps,pdf,jpg}} /usr/share/doc/gawk-5.3.0
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

68
lfs-scripts/gcc.sh Normal file
View File

@@ -0,0 +1,68 @@
# Set the package we're building.
package="gcc-14.2.0"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
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 --prefix=/usr \
LD=ld \
--enable-languages=c,c++ \
--enable-default-pie \
--enable-default-ssp \
--enable-host-pie \
--disable-multilib \
--disable-bootstrap \
--disable-fixincludes \
--with-system-zlib
make
ulimit -s -H unlimited
sed -e '/cpython/d' -i ../gcc/testsuite/gcc.dg/plugin/plugin.exp
sed -e 's/no-pic /&-no-pie /' -i ../gcc/testsuite/gcc.target/i386/pr113689-1.c
sed -e 's/300000/(1|300000)/' -i ../libgomp/testsuite/libgomp.c-c++-common/pr109062.c
sed -e 's/{ target nonpic } //' \
-e '/GOTPCREL/d' -i ../gcc/testsuite/gcc.target/i386/fentryname3.c
chown -R tester .
su tester -c "PATH=$PATH make -k check"
../contrib/test_summary
make install
chown -v -R root:root \
/usr/lib/gcc/$(gcc -dumpmachine)/14.2.0/include{,-fixed}
ln -svr /usr/bin/cpp /usr/lib
ln -sv gcc.1 /usr/share/man/man1/cc.1ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/14.2.0/liblto_plugin.so \
/usr/lib/bfd-plugins/
echo 'int main(){}' > dummy.c
cc dummy.c -v -Wl,--verbose &> dummy.log
readelf -l a.out | grep ': /lib'
sleep 10
grep -E -o '/usr/lib.*/S?crt[1in].*succeeded' dummy.log
sleep 10
grep -B4 '^ /usr/include' dummy.log
sleep 10
grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'
sleep 10
rm -v dummy.c a.out dummy.log
mkdir -pv /usr/share/gdb/auto-load/usr/lib
mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

25
lfs-scripts/gdbm.sh Normal file
View File

@@ -0,0 +1,25 @@
# Set the package we're building.
package="gdbm-1.24"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--disable-static \
--enable-libgdbm-compat
make && make check && make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

26
lfs-scripts/gettext.sh Normal file
View File

@@ -0,0 +1,26 @@
# Set the package we're building.
package="gettext-0.22.5"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/gettext-0.22.5
make && make check && make install
chmod -v 0755 /usr/lib/preloadable_libintl.so
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

10
lfs-scripts/gmp.sh Normal file
View File

@@ -0,0 +1,10 @@
./configure --prefix=/usr \
--enable-cxx \
--disable-static \
--docdir=/usr/share/doc/gmp-6.3.0
make
make html
make check 2>&1 | tee gmp-check-log
awk '/# PASS:/{total+=$3} ; END{print total}' gmp-check-log
make install
make install-html

23
lfs-scripts/gperf.sh Normal file
View File

@@ -0,0 +1,23 @@
# Set the package we're building.
package="gperf-3.1"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr --docdir=/usr/share/doc/gperf-3.1
make && make -j1 check && make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

24
lfs-scripts/grep.sh Normal file
View File

@@ -0,0 +1,24 @@
# Set the package we're building.
package="grep-3.11"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
sed -i "s/echo/#echo/" src/egrep.sh
./configure --prefix=/usr
make && make check && make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

25
lfs-scripts/groff.sh Normal file
View File

@@ -0,0 +1,25 @@
# Set the package we're building.
package="groff-1.23.0"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
PAGE=letter ./configure --prefix=/usr
make
make check
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

30
lfs-scripts/grub.sh Normal file
View File

@@ -0,0 +1,30 @@
# Set the package we're building.
package="grub-2.12"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
unset {C,CPP,CXX,LD}FLAGS
echo depends bli part_gpt > grub-core/extra_deps.lst
./configure --prefix=/usr \
--sysconfdir=/etc \
--disable-efiemu \
--disable-werror
make
make install
mv -v /etc/bash_completion.d/grub /usr/share/bash-completion/completions
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

25
lfs-scripts/gzip.sh Normal file
View File

@@ -0,0 +1,25 @@
# Set the package we're building.
package="gzip-1.13"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr
make
make check
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

35
lfs-scripts/inetutils.sh Normal file
View File

@@ -0,0 +1,35 @@
# Set the package we're building.
package="inetutils-2.5"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
sed -i 's/def HAVE_TERMCAP_TGETENT/ 1/' telnet/telnet.c
./configure --prefix=/usr \
--bindir=/usr/bin \
--localstatedir=/var \
--disable-logger \
--disable-whois \
--disable-rcp \
--disable-rexec \
--disable-rlogin \
--disable-rsh \
--disable-servers
make && make check && make install
mv -v /usr/{,s}bin/ifconfig
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

27
lfs-scripts/intltool.sh Normal file
View File

@@ -0,0 +1,27 @@
# Set the package we're building.
package="intltool-0.51.0"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
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
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

27
lfs-scripts/iproute2.sh Normal file
View File

@@ -0,0 +1,27 @@
# Set the package we're building.
package="iproute2-6.10.0"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
sed -i /ARPD/d Makefile
rm -fv man/man8/arpd.8
make NETNS_RUN_DIR=/run/netns
make SBINDIR=/usr/sbin install
mkdir -pv /usr/share/doc/iproute2-6.10.0
cp -v COPYING README* /usr/share/doc/iproute2-6.10.0
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

23
lfs-scripts/jinja2.sh Normal file
View File

@@ -0,0 +1,23 @@
# Set the package we're building.
package="jinja2-3.1.4"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
pip3 wheel -w dist --no-cache-dir --no-build-isolation --no-deps $PWD
pip3 install --no-index --no-user --find-links dist Jinja2
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

29
lfs-scripts/kbd.sh Normal file
View File

@@ -0,0 +1,29 @@
# Set the package we're building.
package="kbd-2.6.4"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
patch -Np1 -i ../kbd-2.6.4-backspace-1.patch
sed -i '/RESIZECONS_PROGS=/s/yes/no/' configure
sed -i 's/resizecons.8 //' docs/man/man8/Makefile.in
./configure --prefix=/usr --disable-vlock
make
make check
make install
cp -R -v docs/doc -T /usr/share/doc/kbd-2.6.4
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

35
lfs-scripts/kmod.sh Normal file
View File

@@ -0,0 +1,35 @@
# Set the package we're building.
package="kmod-33"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--sysconfdir=/etc \
--with-openssl \
--with-xz \
--with-zstd \
--with-zlib \
--disable-manpages
make
make install
for target in depmod insmod modinfo modprobe rmmod; do
ln -sfv ../bin/kmod /usr/sbin/$target
rm -fv /usr/bin/$target
done
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

24
lfs-scripts/less.sh Normal file
View File

@@ -0,0 +1,24 @@
# Set the package we're building.
package="less-661"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr --sysconfdir=/etc
make && make check && make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

25
lfs-scripts/libcap.sh Normal file
View File

@@ -0,0 +1,25 @@
# Set the package we're building.
package="libcap-2.70"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
sed -i '/install -m.*STA/d' libcap/Makefile
make prefix=/usr lib=lib
make test
make prefix=/usr lib=lib install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

29
lfs-scripts/libelf.sh Normal file
View File

@@ -0,0 +1,29 @@
# Set the package we're building.
package="elfutils-0.191"
extension=".tar.bz2"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--disable-debuginfod \
--enable-libdebuginfod=dummy
make
make check
make -C libelf install
install -vm644 config/libelf.pc /usr/lib/pkgconfig
rm /usr/lib/libelf.a
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

27
lfs-scripts/libffi.sh Normal file
View File

@@ -0,0 +1,27 @@
# Set the package we're building.
package="libffi-3.4.6"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--disable-static \
--with-gcc-arch=native
make
make check
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

View File

@@ -0,0 +1,26 @@
# Set the package we're building.
package="libpipeline-1.5.7"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr
make
make check
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

26
lfs-scripts/libtool.sh Normal file
View File

@@ -0,0 +1,26 @@
# Set the package we're building.
package="libtool-2.4.7"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr
make
make -k check
make install
rm -fv /usr/lib/libltdl.a
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

29
lfs-scripts/libxcrypt.sh Normal file
View File

@@ -0,0 +1,29 @@
# Set the package we're building.
package="libxcrypt-4.4.36"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--enable-hashes=strong,glibc \
--enable-obsolete-api=no \
--disable-static \
--disable-failure-tokens
make
make check
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

26
lfs-scripts/make.sh Normal file
View File

@@ -0,0 +1,26 @@
# Set the package we're building.
package="make-4.4.1"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr
make
chown -R tester .
su tester -c "PATH=$PATH make check"
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

35
lfs-scripts/mandb.sh Normal file
View File

@@ -0,0 +1,35 @@
# Set the package we're building.
package="man-db-2.12.1"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--docdir=/usr/share/doc/man-db-2.12.1 \
--sysconfdir=/etc \
--disable-setuid \
--enable-cache-owner=bin \
--with-browser=/usr/bin/lynx \
--with-vgrind=/usr/bin/vgrind \
--with-grap=/usr/bin/grap \
--with-systemdtmpfilesdir= \
--with-systemdsystemunitdir=
make
make check
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

23
lfs-scripts/markupsafe.sh Normal file
View File

@@ -0,0 +1,23 @@
# Set the package we're building.
package="MarkupSafe-2.1.5"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
pip3 wheel -w dist --no-cache-dir --no-build-isolation --no-deps $PWD
pip3 install --no-index --no-user --find-links dist Markupsafe
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

25
lfs-scripts/meson.sh Normal file
View File

@@ -0,0 +1,25 @@
# Set the package we're building.
package="meson-1.5.1"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
pip3 wheel -w dist --no-cache-dir --no-build-isolation --no-deps $PWD
pip3 install --no-index --find-links dist meson
install -vDm644 data/shell-completions/bash/meson /usr/share/bash-completion/completions/meson
install -vDm644 data/shell-completions/zsh/_meson /usr/share/zsh/site-functions/_meson
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

29
lfs-scripts/mpc.sh Normal file
View File

@@ -0,0 +1,29 @@
# Set the package we're building.
package="mpc-1.3.1"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/mpc-1.3.1
make
make html
make check
make install
make install-html
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

25
lfs-scripts/mpfr.sh Normal file
View File

@@ -0,0 +1,25 @@
# Set the package we're building.
package="mpfr-4.2.1"
# Decompress the source.
tar xvf ${package}.tar.xz
# Enter the unpacked sources.
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--disable-static \
--enable-thread-safe \
--docdir=/usr/share/doc/mpfr-4.2.1
make
make html
make check
make install
make install-html
# Exit sources directory.
cd ..
# Remove the directory of source files.
rm -rf ${package}

43
lfs-scripts/ncurses.sh Normal file
View File

@@ -0,0 +1,43 @@
# Set the package we're building.
package="ncurses-6.5"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--mandir=/usr/share/man \
--with-shared \
--without-debug \
--without-normal \
--with-cxx-shared \
--enable-pc-files \
--with-pkg-config-libdir=/usr/lib/pkgconfig
make
make DESTDIR=$PWD/dest install
install -vm755 dest/usr/lib/libncursesw.so.6.5 /usr/lib
rm -v dest/usr/lib/libncursesw.so.6.5
sed -e 's/^#if.*XOPEN.*$/#if 1/' \
-i dest/usr/include/curses.h
cp -av dest/* /
for lib in ncurses form panel menu ; do
ln -sfv lib${lib}w.so /usr/lib/lib${lib}.so
ln -sfv ${lib}w.pc /usr/lib/pkgconfig/${lib}.pc
done
ln -sfv libncursesw.so /usr/lib/libcurses.so
cp -v -R doc -T /usr/share/doc/ncurses-6.5
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

32
lfs-scripts/ninja.sh Normal file
View File

@@ -0,0 +1,32 @@
# Set the package we're building.
package="ninja-1.12.1"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
export NINJAJOBS=4
sed -i '/int Guess/a \
int j = 0;\
char* jobs = getenv( "NINJAJOBS" );\
if ( jobs != NULL ) j = atoi( jobs );\
if ( j > 0 ) return j;\
' src/ninja.cc
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
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

32
lfs-scripts/openssl.sh Normal file
View File

@@ -0,0 +1,32 @@
# Set the package we're building.
package="openssl-3.3.1"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./config --prefix=/usr \
--openssldir=/etc/ssl \
--libdir=lib \
shared \
zlib-dynamic
make
HARNESS_JOBS=$(nproc) make test
sed -i '/INSTALL_LIBS/s/libcrypto.a libssl.a//' Makefile
make MANSUFFIX=ssl install
mv -v /usr/share/doc/openssl /usr/share/doc/openssl-3.3.1
cp -vfr doc/* /usr/share/doc/openssl-3.3.1
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

26
lfs-scripts/patch.sh Normal file
View File

@@ -0,0 +1,26 @@
# Set the package we're building.
package="patch-2.7.6"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr
make
make check
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

41
lfs-scripts/perl.sh Normal file
View File

@@ -0,0 +1,41 @@
# Set the package we're building.
package="perl-5.40.0"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
export BUILD_ZLIB=False
export BUILD_BZIP2=0
sh Configure -des \
-D prefix=/usr \
-D vendorprefix=/usr \
-D privlib=/usr/lib/perl5/5.40/core_perl \
-D archlib=/usr/lib/perl5/5.40/core_perl \
-D sitelib=/usr/lib/perl5/5.40/site_perl \
-D sitearch=/usr/lib/perl5/5.40/site_perl \
-D vendorlib=/usr/lib/perl5/5.40/vendor_perl \
-D vendorarch=/usr/lib/perl5/5.40/vendor_perl \
-D man1dir=/usr/share/man/man1 \
-D man3dir=/usr/share/man/man3 \
-D pager="/usr/bin/less -isR" \
-D useshrplib \
-D usethreads
make
TEST_JOBS=$(nproc) make test_harness
make install
unset BUILD_ZLIB BUILD_BZIP2
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

30
lfs-scripts/procps-ng.sh Normal file
View File

@@ -0,0 +1,30 @@
# Set the package we're building.
package="procps-ng-4.0.4"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--docdir=/usr/share/doc/procps-ng-4.0.4 \
--disable-static \
--disable-kill
make
chown -R tester .
su tester -c "PATH=$PATH make check"
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

23
lfs-scripts/psmisc.sh Normal file
View File

@@ -0,0 +1,23 @@
# Set the package we're building.
package="psmisc-23.7"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr
make && make check && make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

40
lfs-scripts/python3.sh Normal file
View File

@@ -0,0 +1,40 @@
# Set the package we're building.
package="Python-3.12.5"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--enable-shared \
--with-system-expat \
--enable-optimizations
make
make test TESTOPTS="--timeout 120"
make install
cat > /etc/pip.conf << EOF
[global]
root-user-action = ignore
disable-pip-version-check = true
EOF
install -v -dm755 /usr/share/doc/python-3.12.5/html
tar --no-same-owner \
-xvf ../python-3.12.5-docs-html.tar.bz2
cp -R --no-preserve=mode python-3.12.5-docs-html/* \
/usr/share/doc/python-3.12.5/html
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

1
lfs-scripts/scp_to_lfs.sh Executable file
View File

@@ -0,0 +1 @@
scp -r ./* root@lfs.home.lan:/mnt/lfs/sources/scripts

28
lfs-scripts/sed.sh Normal file
View File

@@ -0,0 +1,28 @@
# Set the package we're building.
package="sed-4.9"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr
make && make html
chown -R tester .
su tester -c "PATH=$PATH make check"
make install
install -d -m755 /usr/share/doc/sed-4.9
install -m644 doc/sed.html /usr/share/doc/sed-4.9
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

23
lfs-scripts/setuptools.sh Normal file
View File

@@ -0,0 +1,23 @@
# Set the package we're building.
package="setuptools-72.2.0"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
pip3 wheel -w dist --no-cache-dir --no-build-isolation --no-deps $PWD
pip3 install --no-index --find-links dist setuptools
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

43
lfs-scripts/shadow.sh Normal file
View File

@@ -0,0 +1,43 @@
# Set the package we're building.
package="shadow-4.16.0"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
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 -e 's:#ENCRYPT_METHOD DES:ENCRYPT_METHOD YESCRYPT:' \
-e 's:/var/spool/mail:/var/mail:' \
-e '/PATH=/{s@/sbin:@@;s@/bin:@@}' \
-i etc/login.defs
touch /usr/bin/passwd
./configure --sysconfdir=/etc \
--disable-static \
--with-{b,yes}crypt \
--without-libbsd \
--with-group-name-max-length=32
make
make exec_prefix=/usr install
make -C man install-man
pwconv
grpconv
mkdir -p /etc/default
useradd -D --gid 999
passwd root
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

43
lfs-scripts/sysklogd.sh Normal file
View File

@@ -0,0 +1,43 @@
# Set the package we're building.
package="sysklogd-2.6.1"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr \
--sysconfdir=/etc \
--runstatedir=/run \
--without-logger
make
make install
cat > /etc/syslog.conf << "EOF"
# Begin /etc/syslog.conf
auth,authpriv.* -/var/log/auth.log
*.*;auth,authpriv.none -/var/log/sys.log
daemon.* -/var/log/daemon.log
kern.* -/var/log/kern.log
mail.* -/var/log/mail.log
user.* -/var/log/user.log
*.emerg *
# Do not open any internet ports.
secure_mode 2
# End /etc/syslog.conf
EOF
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

24
lfs-scripts/sysvinit.sh Normal file
View File

@@ -0,0 +1,24 @@
# Set the package we're building.
package="sysvinit-3.10"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
patch -Np1 -i ../sysvinit-3.10-consolidated-1.patch
make
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

27
lfs-scripts/tar.sh Normal file
View File

@@ -0,0 +1,27 @@
# Set the package we're building.
package="tar-1.35"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
FORCE_UNSAFE_CONFIGURE=1 \
./configure --prefix=/usr
make
make check
make install
make -C doc install-html docdir=/usr/share/doc/tar-1.35
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

32
lfs-scripts/texinfo.sh Normal file
View File

@@ -0,0 +1,32 @@
# Set the package we're building.
package="texinfo-7.1"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --prefix=/usr
make
make check
make install
make TEXMF=/usr/share/texmf install-tex
pushd /usr/share/info
rm -v dir
for f in *
do install-info $f dir 2>/dev/null
done
popd
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

80
lfs-scripts/udev.sh Normal file
View File

@@ -0,0 +1,80 @@
# Set the package we're building.
package="systemd-256.4"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
sed -i -e 's/GROUP="render"/GROUP="video"/' \
-e 's/GROUP="sgx", //' rules.d/50-udev-default.rules.in
sed '/systemd-sysctl/s/^/#/' -i rules.d/99-systemd.rules.in
sed '/NETWORK_DIRS/s/systemd/udev/' -i src/basic/path-lookup.h
mkdir -p build
cd build
meson setup .. \
--prefix=/usr \
--buildtype=release \
-D mode=release \
-D dev-kvm-mode=0660 \
-D link-udev-shared=false \
-D logind=false \
-D vconsole=false
export udev_helpers=$(grep "'name' :" ../src/udev/meson.build | \
awk '{print $3}' | tr -d ",'" | grep -v 'udevadm')
ninja udevadm systemd-hwdb \
$(ninja -n | grep -Eo '(src/(lib)?udev|rules.d|hwdb.d)/[^ ]*') \
$(realpath libudev.so --relative-to .) \
$udev_helpers
install -vm755 -d {/usr/lib,/etc}/udev/{hwdb.d,rules.d,network}
install -vm755 -d /usr/{lib,share}/pkgconfig
install -vm755 udevadm /usr/bin/
install -vm755 systemd-hwdb /usr/bin/udev-hwdb
ln -svfn ../bin/udevadm /usr/sbin/udevd
cp -av libudev.so{,*[0-9]} /usr/lib/
install -vm644 ../src/libudev/libudev.h /usr/include/
install -vm644 src/libudev/*.pc /usr/lib/pkgconfig/
install -vm644 src/udev/*.pc /usr/share/pkgconfig/
install -vm644 ../src/udev/udev.conf /etc/udev/
install -vm644 rules.d/* ../rules.d/README /usr/lib/udev/rules.d/
install -vm644 $(find ../rules.d/*.rules \
-not -name '*power-switch*') /usr/lib/udev/rules.d/
install -vm644 hwdb.d/* ../hwdb.d/{*.hwdb,README} /usr/lib/udev/hwdb.d/
install -vm755 $udev_helpers /usr/lib/udev
install -vm644 ../network/99-default.link /usr/lib/udev/network
tar -xvf ../../udev-lfs-20230818.tar.xz
make -f udev-lfs-20230818/Makefile.lfs install
tar -xf ../../systemd-man-pages-256.4.tar.xz \
--no-same-owner --strip-components=1 \
-C /usr/share/man --wildcards '*/udev*' '*/libudev*' \
'*/systemd.link.5' \
'*/systemd-'{hwdb,udevd.service}.8
sed 's|systemd/network|udev/network|' \
/usr/share/man/man5/systemd.link.5 \
> /usr/share/man/man5/udev.link.5
sed 's/systemd\(\\\?-\)/udev\1/' /usr/share/man/man8/systemd-hwdb.8 \
> /usr/share/man/man8/udev-hwdb.8
sed 's|lib.*udevd|sbin/udevd|' \
/usr/share/man/man8/systemd-udevd.service.8 \
> /usr/share/man/man8/udevd.8
rm /usr/share/man/man*/systemd*
unset udev_helpers
udev-hwdb update
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

42
lfs-scripts/util-linux.sh Normal file
View File

@@ -0,0 +1,42 @@
# Set the package we're building.
package="util-linux-2.40.2"
extension=".tar.xz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
./configure --bindir=/usr/bin \
--libdir=/usr/lib \
--runstatedir=/run \
--sbindir=/usr/sbin \
--disable-chfn-chsh \
--disable-login \
--disable-nologin \
--disable-su \
--disable-setpriv \
--disable-runuser \
--disable-pylibmount \
--disable-liblastlog2 \
--disable-static \
--without-python \
--without-systemd \
--without-systemdsystemunitdir \
ADJTIME_PATH=/var/lib/hwclock/adjtime \
--docdir=/usr/share/doc/util-linux-2.40.2
make
# skipping tests
make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

50
lfs-scripts/vim.sh Normal file
View File

@@ -0,0 +1,50 @@
# Set the package we're building.
package="vim-9.1.0660"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h
./configure --prefix=/usr
make
chown -R tester .
su tester -c "TERM=xterm-256color LANG=en_US.UTF-8 make -j1 test" \
&> vim-test.log
make install
ln -sv vim /usr/bin/vi
for L in /usr/share/man/{,*/}man1/vim.1; do
ln -sv vim.1 $(dirname $L)/vi.1
done
ln -sv ../vim/vim91/doc /usr/share/doc/vim-9.1.0660
cat > /etc/vimrc << "EOF"
" Begin /etc/vimrc
" Ensure defaults are set before customizing settings, not after
source $VIMRUNTIME/defaults.vim
let skip_defaults_vim=1
set nocompatible
set backspace=2
set mouse=
syntax on
if (&term == "xterm") || (&term == "putty")
set background=dark
endif
" End /etc/vimrc
EOF
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

View File

@@ -0,0 +1,19 @@
mkdir -pv $LFS/{dev,proc,sys,run}
mount -v --bind /dev $LFS/dev
mount -vt devpts devpts -o gid=5,mode=0620 $LFS/dev/pts
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
mount -vt tmpfs tmpfs $LFS/run
if [ -h $LFS/dev/shm ]; then
install -v -d -m 1777 $LFS$(realpath /dev/shm)
else
mount -vt tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm
fi
chroot "$LFS" /usr/bin/env -i \
HOME=/root \
TERM="$TERM" \
PS1='(lfs chroot) \u:\w\$ ' \
PATH=/usr/bin:/usr/sbin \
MAKEFLAGS="-j$(nproc)" \
TESTSUITEFLAGS="-j$(nproc)" \
/bin/bash --login

23
lfs-scripts/wheel.sh Normal file
View File

@@ -0,0 +1,23 @@
# Set the package we're building.
package="wheel-0.44.0"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
pip3 wheel -w dist --no-cache-dir --no-build-isolation --no-deps $PWD
pip3 install --no-index --find-links=dist wheel
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}

23
lfs-scripts/xml_parser.sh Normal file
View File

@@ -0,0 +1,23 @@
# Set the package we're building.
package="XML-Parser-2.47"
extension=".tar.gz"
# Decompress the source.
echo "Unpacking ${package}${extension} ..."
tar xvf ${package}${extension}
# Enter the unpacked sources.
echo "Entering ${package} directory ..."
cd ${package}
# LFS commands.
perl Makefile.PL
make && make test && make install
# Exit sources directory.
echo "Exiting ${package} directory ..."
cd ..
# Remove the directory of source files.
echo "Removing ${package} directory ..."
rm -rf ${package}