Skip to content

Commit b5c078a

Browse files
committed
Updating all scripts, instructions and screenshots for LFS 11.0
1 parent bbf422a commit b5c078a

11 files changed

Lines changed: 141383 additions & 134374 deletions

README.md

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# lfs-scripts :penguin:
2-
Instructions and scripts to build LFS (Linux From Scratch), version 10.0, as simply as possible (I know, not that simple, but anyway).
2+
Instructions and scripts to build Linux From Scratch (LFS), version 11.0, as simply as possible (I know, not that simple, but anyway).
33

44
![Output of uname -a](https://github.com/luisgbm/lfs-scripts/blob/master/img/uname.png?raw=true)
55

66
![vim :smile](https://github.com/luisgbm/lfs-scripts/blob/master/img/vim-smile.png?raw=true)
77

88
# Foreword
99

10-
First, this guide does not replace reading the whole LFS book. I highly recommend that you read it at least once. Only then you should use the automation scripts provided here.
10+
First, this guide does not replace reading the whole LFS book. I highly recommend that you read it at least once. Only then you should use the automated scripts provided here.
1111

12-
This build will be accomplished inside a virtual machine. I'll be using Oracle VirtualBox, but you can use the tool of your personal preference. I'm running an Arch Linux VM, feel free to use your GNU/Linux distribution of choice. Just be sure to install the development tools available (base-devel package on Arch).
12+
This build will be accomplished inside a virtual machine. I'll be using Oracle VirtualBox, but you can use any tool of your personal preference. I'm running an Arch Linux VM, feel free to use your GNU/Linux distribution of choice. Just be sure to install the development tools available (base-devel package on Arch).
1313

1414
My VM has two virtual hard disks: one for the host (Arch Linux itself) and another for building LFS. You could also use a single hard disk with two partitions, that's also up to personal taste. I've decided to use two separate hard disks so I can completely isolate LFS from the host after the build. At the end, you'll be able to create a separate VM and boot from it directly.
1515

16-
The packages needed to build LFS were downloaded from [here](http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/lfs-packages-10.0.tar) (423 MB), other mirrors are available [here](http://linuxfromscratch.org/lfs/download.html) (look for the "LFS HTTP/FTP Sites" section at the bottom, the file you need is lfs-packages-10.0.tar).
16+
The packages needed to build LFS were downloaded from [here](http://ftp.osuosl.org/pub/lfs/lfs-packages/lfs-packages-11.0.tar) (443 MB), other mirrors are available [here](http://linuxfromscratch.org/lfs/download.html) (look for the "LFS HTTP/FTP Sites" section at the bottom, the file you need is lfs-packages-11.0.tar).
1717

1818
# Build instructions
1919

@@ -47,15 +47,14 @@ Source the file:
4747
source .bashrc
4848
```
4949

50-
Download all the packages and extract them to $LFS/sources. The tcl package must be renamed in order to work with the scripts that will follow.
50+
Download all the packages and extract them to $LFS/sources.
5151

5252
```
5353
cd $LFS
54-
cp /<location_of_the_package>/lfs-packages-10.0.tar .
55-
tar xf lfs-packages-10.0.tar
56-
mv 10.0 sources
54+
cp /<location_of_the_package>/lfs-packages-11.0.tar .
55+
tar xf lfs-packages-11.0.tar
56+
mv 11.0 sources
5757
chmod -v a+wt $LFS/sources
58-
mv $LFS/sources/tcl8.6.10-src.tar.gz $LFS/sources/tcl8.6.10.tar.gz
5958
```
6059

6160
Copy all the shell scripts from this repository to your $LFS directory:
@@ -67,7 +66,17 @@ cp /<location_of_the_scripts>/*.sh $LFS
6766
Create the basic filesystem for LFS:
6867

6968
```
70-
mkdir -pv $LFS/{bin,etc,lib,sbin,usr,var,lib64,tools}
69+
mkdir -pv $LFS/{etc,var} $LFS/usr/{bin,lib,sbin}
70+
71+
for i in bin lib sbin; do
72+
ln -sv usr/$i $LFS/$i
73+
done
74+
75+
case $(uname -m) in
76+
x86_64) mkdir -pv $LFS/lib64 ;;
77+
esac
78+
79+
mkdir -pv $LFS/tools
7180
```
7281

7382
Create the lfs user, used during the initial build process (you will have to type a password):
@@ -113,19 +122,20 @@ LFS_TGT=$(uname -m)-lfs-linux-gnu
113122
PATH=/usr/bin
114123
if [ ! -L /bin ]; then PATH=/bin:$PATH; fi
115124
PATH=$LFS/tools/bin:$PATH
116-
export LFS LC_ALL LFS_TGT PATH
125+
CONFIG_SITE=$LFS/usr/share/config.site
126+
export LFS LC_ALL LFS_TGT PATH CONFIG_SITE
117127
EOF
118128
119129
source ~/.bashrc
120130
```
121131

122-
Run the lfs-cross.sh script, which will build the cross-toolchain and cross compiling temporary tools from chapters 5 and 6:
132+
Run the lfs-cross.sh script, which will build the cross toolchain and cross compiling temporary tools from chapters 5 and 6:
123133

124134
```
125135
sh $LFS/lfs-cross.sh | tee $LFS/lfs-cross.log
126136
```
127137

128-
Return to being root:
138+
Exit from the lfs user to become root again:
129139

130140
```
131141
exit
@@ -163,7 +173,7 @@ chroot "$LFS" /usr/bin/env -i \
163173
HOME=/root \
164174
TERM="$TERM" \
165175
PS1='(lfs chroot) \u:\w\$ ' \
166-
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
176+
PATH=/usr/bin:/usr/sbin \
167177
/bin/bash --login +h
168178
```
169179

@@ -174,25 +184,36 @@ mkdir -pv /{boot,home,mnt,opt,srv}
174184
mkdir -pv /etc/{opt,sysconfig}
175185
mkdir -pv /lib/firmware
176186
mkdir -pv /media/{floppy,cdrom}
177-
mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src}
187+
mkdir -pv /usr/{,local/}{include,src}
188+
mkdir -pv /usr/local/{bin,lib,sbin}
178189
mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man}
179190
mkdir -pv /usr/{,local/}share/{misc,terminfo,zoneinfo}
180191
mkdir -pv /usr/{,local/}share/man/man{1..8}
181192
mkdir -pv /var/{cache,local,log,mail,opt,spool}
182193
mkdir -pv /var/lib/{color,misc,locate}
194+
183195
ln -sfv /run /var/run
184196
ln -sfv /run/lock /var/lock
197+
185198
install -dv -m 0750 /root
186199
install -dv -m 1777 /tmp /var/tmp
200+
187201
ln -sv /proc/self/mounts /etc/mtab
188-
echo "127.0.0.1 localhost $(hostname)" > /etc/hosts
202+
203+
cat > /etc/hosts << EOF
204+
127.0.0.1 localhost $(hostname)
205+
::1 localhost
206+
EOF
207+
189208
cat > /etc/passwd << "EOF"
190209
root:x:0:0:root:/root:/bin/bash
191210
bin:x:1:1:bin:/dev/null:/bin/false
192211
daemon:x:6:6:Daemon User:/dev/null:/bin/false
193-
messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
212+
messagebus:x:18:18:D-Bus Message Daemon User:/run/dbus:/bin/false
213+
uuidd:x:80:80:UUID Generation Daemon User:/dev/null:/bin/false
194214
nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
195215
EOF
216+
196217
cat > /etc/group << "EOF"
197218
root:x:0:
198219
bin:x:1:daemon
@@ -215,14 +236,17 @@ messagebus:x:18:
215236
input:x:24:
216237
mail:x:34:
217238
kvm:x:61:
239+
uuidd:x:80:
218240
wheel:x:97:
219241
nogroup:x:99:
220242
users:x:999:
221243
EOF
244+
222245
touch /var/log/{btmp,lastlog,faillog,wtmp}
223246
chgrp -v utmp /var/log/lastlog
224247
chmod -v 664 /var/log/lastlog
225248
chmod -v 600 /var/log/btmp
249+
226250
exec /bin/bash --login +h
227251
```
228252

@@ -235,8 +259,9 @@ sh /lfs-chroot.sh | tee /lfs-chroot.log
235259
Cleanup before the final build phase:
236260

237261
```
238-
find /usr/{lib,libexec} -name \*.la -delete
239262
rm -rf /usr/share/{info,man,doc}/*
263+
find /usr/{lib,libexec} -name \*.la -delete
264+
rm -rf /tools
240265
```
241266

242267
For the final build phase, run the lfs-system.sh script:
@@ -255,10 +280,11 @@ Logout from the chroot environment and re-enter it with updated configuration:
255280

256281
```
257282
logout
283+
258284
chroot "$LFS" /usr/bin/env -i \
259285
HOME=/root TERM="$TERM" \
260286
PS1='(lfs chroot) \u:\w\$ ' \
261-
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
287+
PATH=/usr/bin:/usr/sbin \
262288
/bin/bash --login
263289
```
264290

@@ -270,4 +296,4 @@ sh /lfs-final.sh | tee /lfs-final.log
270296

271297
# The end
272298

273-
You can now create a new VM using the virtual hard disk with the LFS build. It will be bootable and fully functional. Enjoy!
299+
You can now create a new VM using the virtual hard disk with the LFS build. It will be bootable and fully functional. Enjoy!

img/uname.png

-1.12 KB
Loading

img/vim-smile.png

-145 Bytes
Loading

lfs-chroot.sh

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
#!/bin/bash
2-
# LFS 10.0 Build Script
2+
# LFS 11.0 Build Script
33
# Builds the additional temporary tools from chapter 7
44
# by Luís Mendes :)
5-
# 14/09/2020
5+
# 10/Sep/2021
66

77
package_name=""
88
package_ext=""
99

1010
begin() {
1111
package_name=$1
1212
package_ext=$2
13-
13+
14+
echo "[lfs-scripts] Starting build of $package_name at $(date)"
15+
1416
tar xf $package_name.$package_ext
1517
cd $package_name
1618
}
1719

1820
finish() {
21+
echo "[lfs-scripts] Finishing build of $package_name at $(date)"
22+
1923
cd /sources
2024
rm -rf $package_name
2125
}
2226

2327
cd /sources
2428

25-
# 7.7. Libstdc++ from GCC-10.2.0, Pass 2
26-
begin gcc-10.2.0 tar.xz
29+
# 7.7. Libstdc++ from GCC-11.2.0, Pass 2
30+
begin gcc-11.2.0 tar.xz
2731
ln -s gthr-posix.h libgcc/gthr-default.h
2832
mkdir -v build
2933
cd build
@@ -45,50 +49,53 @@ make
4549
cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /usr/bin
4650
finish
4751

48-
# 7.9. Bison-3.7.1
49-
begin bison-3.7.1 tar.xz
52+
# 7.9. Bison-3.7.6
53+
begin bison-3.7.6 tar.xz
5054
./configure --prefix=/usr \
51-
--docdir=/usr/share/doc/bison-3.7.1
55+
--docdir=/usr/share/doc/bison-3.7.6
5256
make
5357
make install
5458
finish
5559

56-
# 7.10. Perl-5.32.0
57-
begin perl-5.32.0 tar.xz
60+
# 7.10. Perl-5.34.0
61+
begin perl-5.34.0 tar.xz
5862
sh Configure -des \
5963
-Dprefix=/usr \
6064
-Dvendorprefix=/usr \
61-
-Dprivlib=/usr/lib/perl5/5.32/core_perl \
62-
-Darchlib=/usr/lib/perl5/5.32/core_perl \
63-
-Dsitelib=/usr/lib/perl5/5.32/site_perl \
64-
-Dsitearch=/usr/lib/perl5/5.32/site_perl \
65-
-Dvendorlib=/usr/lib/perl5/5.32/vendor_perl \
66-
-Dvendorarch=/usr/lib/perl5/5.32/vendor_perl
65+
-Dprivlib=/usr/lib/perl5/5.34/core_perl \
66+
-Darchlib=/usr/lib/perl5/5.34/core_perl \
67+
-Dsitelib=/usr/lib/perl5/5.34/site_perl \
68+
-Dsitearch=/usr/lib/perl5/5.34/site_perl \
69+
-Dvendorlib=/usr/lib/perl5/5.34/vendor_perl \
70+
-Dvendorarch=/usr/lib/perl5/5.34/vendor_perl
6771
make
6872
make install
6973
finish
7074

71-
# 7.11. Python-3.8.5
72-
begin Python-3.8.5 tar.xz
75+
# 7.11. Python-3.9.6
76+
begin Python-3.9.6 tar.xz
7377
./configure --prefix=/usr \
7478
--enable-shared \
7579
--without-ensurepip
7680
make
7781
make install
7882
finish
7983

80-
# 7.12. Texinfo-6.7
81-
begin texinfo-6.7 tar.xz
84+
# 7.12. Texinfo-6.8
85+
begin texinfo-6.8 tar.xz
86+
sed -e 's/__attribute_nonnull__/__nonnull/' \
87+
-i gnulib/lib/malloc/dynarray-skeleton.c
8288
./configure --prefix=/usr
8389
make
8490
make install
8591
finish
8692

87-
# 7.13. Util-linux-2.36
88-
begin util-linux-2.36 tar.xz
93+
# 7.13. Util-linux-2.37.2
94+
begin util-linux-2.37.2 tar.xz
8995
mkdir -pv /var/lib/hwclock
9096
./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \
91-
--docdir=/usr/share/doc/util-linux-2.36 \
97+
--libdir=/usr/lib \
98+
--docdir=/usr/share/doc/util-linux-2.37.2 \
9299
--disable-chfn-chsh \
93100
--disable-login \
94101
--disable-nologin \
@@ -97,7 +104,8 @@ mkdir -pv /var/lib/hwclock
97104
--disable-runuser \
98105
--disable-pylibmount \
99106
--disable-static \
100-
--without-python
107+
--without-python \
108+
runstatedir=/run
101109
make
102110
make install
103111
finish

0 commit comments

Comments
 (0)