tonybtw.com

tonybtw.com

https://git.tonybtw.com/tonybtw.com.git git://git.tonybtw.com/tonybtw.com.git
86,445 bytes raw
1
#+TITLE: Linux From Scratch
2
#+AUTHOR: Tony, btw
3
#+date: 2025-10-22
4
#+HUGO_TITLE: How to Install Linux from Scratch
5
#+HUGO_FRONT_MATTER_FORMAT: yaml
6
#+HUGO_CUSTOM_FRONT_MATTER: :image "/img/lfs.png" :showTableOfContents true
7
#+HUGO_BASE_DIR: ~/repos/tonybtw.com
8
#+HUGO_SECTION: tutorial/linux-from-scratch
9
#+EXPORT_FILE_NAME: index
10
#+OPTIONS: toc:nil broken-links:mark
11
#+HUGO_AUTO_SET_HEADLINE_SECTION: nil
12
#+DESCRIPTION: This is a slow, and painful tutorial on how to install linux from scratch in 2026. We go over the entire lfs book, from 0 to booting into our LFS system. A challenging, but educational and rewarding process.
13
14
* Intro
15
What's up guys, my name is Tony, and today, I'm gonna give you a slow and painful guide on installing Linux from Scratch.
16
* Chapter 1 - Introduction:
17
** Install Gentoo ISO
18
19
For the iso image, we're going to use the gentoo gui live cd, and drop into a tty immediatly, and ssh to it from another machine. This is because it will already have all of the required tools needed to compile all the software, and other than that it is relatively minimal.
20
21
** Setup ISO, and enable SSH
22
23
Let's boot into our Gentoo Live CD. I see this kde nonsense, lets just drop into a tty right on with Control Alt F2, and lets do a few things.
24
25
Let's begin by creating a root password on this machine, and switching to root, and enabling ssh. Now we check the ip here with ip a, and then we can ssh to it from our other machine.
26
27
#+begin_src sh
28
sudo passwd root
29
su
30
rc-service sshd start
31
ip a
32
#+end_src
33
34
ssh root@192.168.x.x
35
36
** Testing Versions:
37
38
We need to prepare for this by testing the versions of our toolchain. Let's run this script here on the lfs manual like so:
39
40
And here's the output:
41
42
#+begin_src sh
43
bash check-version.sh
44
OK:    Coreutils 9.7    >= 8.1
45
OK:    Bash      5.3.3  >= 3.2
46
OK:    Binutils  2.45   >= 2.13.1
47
OK:    Bison     3.8.2  >= 2.7
48
OK:    Diffutils 3.12   >= 2.8.1
49
OK:    Findutils 4.10.0 >= 4.2.31
50
OK:    Gawk      5.3.2  >= 4.0.1
51
OK:    GCC       14.3.1 >= 5.4
52
OK:    GCC (C++) 14.3.1 >= 5.4
53
OK:    Grep      3.12   >= 2.5.1a
54
OK:    Gzip      1.14   >= 1.3.12
55
OK:    M4        1.4.20 >= 1.4.10
56
OK:    Make      4.4.1  >= 4.0
57
OK:    Patch     2.8    >= 2.5.4
58
OK:    Perl      5.40.2 >= 5.8.8
59
OK:    Python    3.13.5 >= 3.4
60
OK:    Sed       4.9    >= 4.1.5
61
OK:    Tar       1.35   >= 1.22
62
OK:    Texinfo   7.2    >= 5.0
63
OK:    Xz        5.8.1  >= 5.0.0
64
OK:    Linux Kernel 6.12.47 >= 5.4
65
OK:    Linux Kernel supports UNIX 98 PTY
66
Aliases:
67
OK:    awk  is GNU
68
OK:    yacc is Bison
69
OK:    sh   is Bash
70
Compiler check:
71
OK:    g++ works
72
OK: nproc reports 12 logical cores are available
73
#+end_src
74
75
And we are ready to move on to the next step.
76
* Chapter 2 - Preparing the Host System:
77
** Create Partitions
78
This part might be familiar to those of you who have installed gentoo, arch, or even nix using the minimal iso. Let's hop into cfdisk and create our partitions.
79
80
lsblk will tell us what our disk is named. Mine is /dev/vda
81
Let's run cfdisk on /dev/vda, your disk might be named something else, such as /dev/sda
82
Let's select gpt for the label type because we are on a UEFI system.
83
84
For the partitions, let's create a 1G boot partition, a 4G swap partition, and the rest can be the root partition.
85
86
Lets write and quit here, and move on to creating the filesystems
87
#+begin_src
88
vda    252:0    0   50G  0 disk
89
├─vda1 252:1    0    1G  0 part
90
├─vda2 252:2    0    4G  0 part
91
└─vda3 252:3    0   45G  0 part
92
#+end_src
93
94
** Make Filesystems
95
96
Lets make those filesystems.
97
98
For the root partition:
99
For the boot partition:
100
And for that swap:
101
#+begin_src
102
mkfs.ext4 /dev/vda3
103
mkfs.fat -F 32 /dev/vda1
104
mkswap /dev/vda2
105
#+end_src
106
107
#+begin_src
108
vda    252:0    0   50G  0 disk
109
├─vda1 252:1    0    1G  0 part
110
├─vda2 252:2    0    4G  0 part
111
└─vda3 252:3    0   45G  0 part
112
livecd ~ # mkfs.ext4 /dev/vda3
113
mke2fs 1.47.3 (8-Jul-2025)
114
Discarding device blocks: done
115
Creating filesystem with 11795968 4k blocks and 2949120 inodes
116
Filesystem UUID: cf482c8d-d5e7-4cd5-82b9-1fe1e21156e4
117
Superblock backups stored on blocks:
118
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
119
        4096000, 7962624, 11239424
120
121
Allocating group tables: done
122
Writing inode tables: done
123
Creating journal (65536 blocks): done
124
Writing superblocks and filesystem accounting information: done
125
126
livecd ~ # mkfs.fat -F 32 /dev/vda1
127
mkfs.fat 4.2 (2021-01-31)
128
livecd ~ # mkswap /dev/vda2
129
Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
130
no label, UUID=9ad48deb-4292-4267-95a3-0b189a8d2acd
131
livecd ~ #
132
#+end_src
133
134
Let's move on to mounting the filesystems.
135
** Exporting $LFS and confirming Umask:
136
So this is where we deviate from the arch installs, and what have you. We need to export the $LFS variable here mainly for convenience, because we will be referencing the path of $LFS throughout this installation.
137
138
So lets run
139
140
#+begin_src
141
export LFS=/mnt/lfs
142
#+end_src
143
144
And we need to ensure `umask` is set to `022` so that newly created files and directories are only writable by their owner, but are readable and searchable by anyone.
145
146
so lets run
147
#+begin_src sh
148
umask 022
149
#+end_src
150
151
And we look good here, we can echo $LFS and we see umask is correct. Let's create the filesystems.
152
** Mounting Partitions
153
154
Let's create the directory here for lfs and mount it. We can run
155
#+begin_src
156
mount --mkdir /dev/vda3 $LFS
157
#+end_src
158
159
And for our root partition:
160
#+begin_src sh
161
mount --mkdir /dev/vda1 $LFS/boot/efi
162
#+end_src
163
164
And lastly, for our swap:
165
#+begin_src
166
swapon /dev/vda2
167
#+end_src
168
169
We can confirm this worked with the following commands:
170
#+begin_src
171
livecd ~ # mount | grep vda
172
/dev/vda3 on /mnt/lfs type ext4 (rw,relatime)
173
/dev/vda1 on /mnt/lfs/boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
174
livecd ~ # lsblk
175
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
176
vda    252:0    0   50G  0 disk
177
├─vda1 252:1    0    1G  0 part /mnt/lfs/boot/efi
178
├─vda2 252:2    0    4G  0 part [SWAP]
179
└─vda3 252:3    0   45G  0 part /mnt/lfs
180
#+end_src
181
182
Following the book it suggests to chown the $LFS directory here:
183
184
#+begin_src
185
chown root:root $LFS
186
chmod 755 $LFS
187
#+end_src
188
189
And confirm with ls -la $LFS
190
191
#+begin_src
192
livecd ~ # ls -la $LFS
193
total 24
194
drwxr-xr-x 4 root root  4096 Oct 17 05:05 .
195
drwxr-xr-x 1 root root    60 Oct 17 05:03 ..
196
drwxr-xr-x 3 root root  4096 Oct 17 05:05 boot
197
drwx------ 2 root root 16384 Oct 17 04:48 lost+found
198
#+end_src
199
200
And it looks good to go! We are ready to move to Chapter 3. Sources.
201
202
* Chapter 3 - Packages and Patches:
203
** Sources:
204
We need to make a directory for the sources here, like so:
205
#+begin_src
206
mkdir -v $LFS/sources
207
#+end_src
208
209
And we need to make it 'sticky', so that even if any user can have write permissions on a directory, only the owner can delete a file within the directory. We can achieve this with:
210
211
#+begin_src
212
chmod -v a+wt $LFS/sources
213
#+end_src
214
215
Which will look like this:
216
#+begin_src
217
livecd ~ # mkdir -v $LFS/sources
218
mkdir: created directory '/mnt/lfs/sources'
219
livecd ~ # chmod -v a+wt $LFS/sources
220
mode of '/mnt/lfs/sources' changed from 0755 (rwxr-xr-x) to 1777 (rwxrwxrwt)
221
livecd ~ #
222
#+end_src
223
224
** Retrieve wget-list and md5sums
225
226
Let's cd into the sources directory here and download the sources.
227
228
#+begin_src
229
cd $LFS/sources
230
#+end_src
231
232
So we can grab all of the sources here from a wget list. let's wget the wget list (inception) like so: right click this link and copy link as, and do:
233
234
Let's also grab the md5sums so we can verify the download succeeded with no corrupted data like so:
235
#+begin_src
236
wget https://www.linuxfromscratch.org/lfs/view/12.4/wget-list-sysv
237
wget https://www.linuxfromscratch.org/lfs/downloads/stable/md5sums
238
#+end_src
239
240
And our ouput should look like this:
241
#+begin_src
242
livecd /mnt/lfs/sources # wget https://www.linuxfromscratch.org/lfs/view/12.4/wget-list-sysv
243
--2025-10-17 09:14:50--  https://www.linuxfromscratch.org/lfs/view/12.4/wget-list-sysv
244
Resolving www.linuxfromscratch.org... 208.118.68.85
245
Connecting to www.linuxfromscratch.org|208.118.68.85|:443... connected.
246
HTTP request sent, awaiting response... 200 OK
247
Length: 6107 (6.0K)
248
Saving to: ‘wget-list-sysv’
249
250
wget-list-sysv                    100%[===========================================================>]   5.96K  --.-KB/s    in 0s
251
252
2025-10-17 09:14:50 (9.62 GB/s) - ‘wget-list-sysv’ saved [6107/6107]
253
#+end_src
254
255
** Grab All Packages from wget-list
256
257
So we can see what this wget list is by running less on it, and we see its just a list of urls with each package we need. So let's just download them here with this wget command:
258
259
And now for the fun part...
260
#+begin_src
261
wget --input-file=wget-list-sysv --continue --directory-prefix=$LFS/sources
262
#+end_src
263
264
This will iterate through the wget list and grab all the files in it. I will see you in a minute.
265
266
** Check md5sums:
267
268
Alright, looks like our wget command finished, so lets test the md5sums here, this will let us know if all of the packages are downloaded to, as well as confirm if any of them are corrupted or not.
269
270
#+begin_src
271
md5sum -c md5sums | less
272
#+end_src
273
274
#+begin_src
275
acl-2.3.2.tar.xz: OK
276
attr-2.5.2.tar.gz: OK
277
autoconf-2.72.tar.xz: OK
278
automake-1.18.1.tar.xz: OK
279
bash-5.3.tar.gz: OK
280
bc-7.0.3.tar.xz: OK
281
binutils-2.45.tar.xz: OK
282
bison-3.8.2.tar.xz: OK
283
bzip2-1.0.8.tar.gz: OK
284
coreutils-9.7.tar.xz: OK
285
dejagnu-1.6.3.tar.gz: OK
286
diffutils-3.12.tar.xz: OK
287
e2fsprogs-1.47.3.tar.gz: OK
288
elfutils-0.193.tar.bz2: OK
289
expat-2.7.1.tar.xz: OK
290
expect5.45.4.tar.gz: OK
291
file-5.46.tar.gz: OK
292
findutils-4.10.0.tar.xz: OK
293
flex-2.6.4.tar.gz: OK
294
flit_core-3.12.0.tar.gz: OK
295
gawk-5.3.2.tar.xz: OK
296
gcc-15.2.0.tar.xz: OK
297
gdbm-1.26.tar.gz: OK
298
gettext-0.26.tar.xz: OK
299
glibc-2.42.tar.xz: OK
300
gmp-6.3.0.tar.xz: OK
301
gperf-3.3.tar.gz: OK
302
grep-3.12.tar.xz: OK
303
groff-1.23.0.tar.gz: OK
304
grub-2.12.tar.xz: OK
305
gzip-1.14.tar.xz: OK
306
iana-etc-20250807.tar.gz: OK
307
#+end_src
308
309
As we see here, our md5sums are all verified, meaning we have all the necessary packages. The book recommends to change ownership of these files to root, but we are root so they are already owned by us. If you downloaded them as a non root user, just run this to be safe
310
311
#+begin_src
312
chown root:root $LFS/sources/*
313
#+end_src
314
315
We're ready to move onto Chapter 4.
316
* Chapter 4 - Final Preparations:
317
** Creating the LFS Filesystem
318
So we want to actually create the LFS filesystem here, so lets create some directories like so:
319
#+begin_src
320
mkdir -pv $LFS/{etc,var} $LFS/usr/{bin,lib,sbin}
321
#+end_src
322
323
Expected output:
324
#+begin_src
325
mkdir: created directory '/mnt/lfs/etc'
326
mkdir: created directory '/mnt/lfs/var'
327
mkdir: created directory '/mnt/lfs/usr'
328
mkdir: created directory '/mnt/lfs/usr/bin'
329
mkdir: created directory '/mnt/lfs/usr/lib'
330
mkdir: created directory '/mnt/lfs/usr/sbin'
331
#+end_src
332
333
And to create symlinks here:
334
335
#+begin_src
336
for i in bin lib sbin; do
337
  ln -sv usr/$i $LFS/$i
338
done
339
#+end_src
340
341
Expected output:
342
#+begin_src
343
'/mnt/lfs/bin' -> 'usr/bin'
344
'/mnt/lfs/lib' -> 'usr/lib'
345
'/mnt/lfs/sbin' -> 'usr/sbin'
346
#+end_src
347
348
And for the lib64 directory in my case (because I am on x86_64 technology)
349
350
#+begin_src
351
case $(uname -m) in
352
  x86_64) mkdir -pv $LFS/lib64 ;;
353
esac
354
#+end_src
355
356
Expected output:
357
#+begin_src
358
mkdir: created directory '/mnt/lfs/lib64'
359
#+end_src
360
361
And for the tools directory, we will use this to keep some of the temporary programs we will be compiling.
362
#+begin_src
363
mkdir -pv $LFS/tools
364
#+end_src
365
366
Expected output:
367
#+begin_src
368
mkdir: created directory '/mnt/lfs/tools'
369
#+end_src
370
371
And we're ready to add the LFS user.
372
373
** Adding LFS user:
374
We want an LFS user because running things as root could break our system, and if we do it as LFS, we dont risk nefariously affecting the host iso in any way.
375
376
So lets add the group and create the user like so:
377
#+begin_src
378
groupadd lfs
379
useradd -s /bin/bash -g lfs -m -k /dev/null lfs
380
#+end_src
381
382
And add a passwd so we can log in to it:
383
384
#+begin_src
385
passwd lfs
386
#+end_src
387
388
And we want lfs to have full access to all lfs directories so lets run:
389
#+begin_src
390
chown -v lfs $LFS/{usr{,/*},var,etc,tools}
391
case $(uname -m) in
392
  x86_64) chown -v lfs $LFS/lib64 ;;
393
esac
394
#+end_src
395
396
Expected output:
397
#+begin_src
398
livecd /mnt/lfs/sources # chown -v lfs $LFS/{usr{,/*},var,etc,tools}
399
changed ownership of '/mnt/lfs/usr' from root to lfs
400
changed ownership of '/mnt/lfs/usr/bin' from root to lfs
401
changed ownership of '/mnt/lfs/usr/lib' from root to lfs
402
changed ownership of '/mnt/lfs/usr/sbin' from root to lfs
403
changed ownership of '/mnt/lfs/var' from root to lfs
404
changed ownership of '/mnt/lfs/etc' from root to lfs
405
changed ownership of '/mnt/lfs/tools' from root to lfs
406
livecd /mnt/lfs/sources # case $(uname -m) in
407
>   x86_64) chown -v lfs $LFS/lib64 ;;
408
> esac
409
changed ownership of '/mnt/lfs/lib64' from root to lfs
410
#+end_src
411
412
And we're ready to switch into our new user. We can ignore this warning here, since gentoo wont give us issues, but take a look at this warning if you are on a different host.
413
#+begin_src
414
su - lfs
415
#+end_src
416
417
And now we're LFS, so we are ready to setup the environment
418
419
** Setup Environment for lfs user
420
Let's create a bash profile like so:
421
#+begin_src
422
cat > ~/.bash_profile << "EOF"
423
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
424
EOF
425
#+end_src
426
427
And as we see here, this will ensure that no unwanted and potentially hazardous environment variables from the host system leak into the build environment
428
429
And lets create the bashrc here like so:
430
#+begin_src
431
cat > ~/.bashrc << "EOF"
432
set +h
433
umask 022
434
LFS=/mnt/lfs
435
LC_ALL=POSIX
436
LFS_TGT=$(uname -m)-lfs-linux-gnu
437
PATH=/usr/bin
438
if [ ! -L /bin ]; then PATH=/bin:$PATH; fi
439
PATH=$LFS/tools/bin:$PATH
440
CONFIG_SITE=$LFS/usr/share/config.site
441
export LFS LC_ALL LFS_TGT PATH CONFIG_SITE
442
EOF
443
#+end_src
444
445
Main things here are setting +h which turns off the hashing feature, which we need to disable in order to force our shell to search for the proper path whenever a program is to be run. The rest of these options are things we already did previously such as umask, or exporting the LFS path, or can be explained here.
446
447
For this important block here, we dont need to do this on gentoo because the usrs environment is already clean of the /etc/bash.bashrc, but we can run it anyway to be safe. we have to run it as root, though, so lets do this:
448
449
#+begin_src
450
logout
451
[ ! -e /etc/bash.bashrc ] || mv -v /etc/bash.bashrc /etc/bash.bashrc.NOUSE
452
su - lfs
453
#+end_src
454
455
No output means we are in the clear.
456
457
Now to update our makeflags to reflect our cpus. Our cpu has 12 logical cores, so we can use 12 instead of 32... or better yet we can just automatically use nproc to get the true value of logical cores and append it to our bashrc like so, and then source our bash_profile like so:
458
459
#+begin_src
460
cat >> ~/.bashrc << "EOF"
461
export MAKEFLAGS=-j$(nproc)
462
EOF
463
464
source ~/.bash_profile
465
#+end_src
466
467
** SBUs
468
This will be a unit that measures how long it takes to compile/install a package. We can use the time command to test that when we install Binutils Pass 1.
469
** Test Suites
470
And here it just says that test suites can't run in Chapters 5-6 because we're cross-compiling. We'll run them later when building inside the LFS chroot environment where we are agnostic to the host machine.
471
* Chapter 5 - Compiling a Cross Toolchain:
472
** Overview
473
First we compile a cross toolchain, then use it to build temporary tools, and finally install the permanent system. We separate these stages because cross-compilation prevents any dependencies on the host system, ensuring a clean, self-contained build.
474
475
To build these tools, its going to be a 3 step method:
476
477
1. untar the source tarball
478
2. follow instructions on lfs book to install tool
479
3. cd back into sources and clean it up
480
481
We will repeat this process over 100 times in lfs, so I'll go slow for the first few and as soon as I finish 3-4 of them, you will sort of understand the pattern here.
482
483
I'll also do my best to explain what each tool is, and thats the real benefit of LFS in my opinion, you learn what ever tool on your system is and what it does.
484
485
So let's jump straight into Binutils.
486
487
** Binutils-2.45 - Pass 1
488
489
The Binutils package contains a linker, an assembler, and other tools for handling object files.
490
491
Some of the binutils you may be familiar with are:
492
strings, size, strip.
493
494
This will be a pattern we see.. extract the tool, cd into it, and run the commands from the handbook to create/compile the tool.
495
496
#+begin_src
497
cd $LFS/sources
498
tar -xvf binutils
499
cd binutils
500
#+end_src
501
502
#+begin_src
503
mkdir -v build
504
cd       build
505
#+end_src
506
507
So lets actually time this compilation to see what we're working with:
508
Prepare for compilation:
509
#+begin_src
510
time { ../configure --prefix=$LFS/tools \
511
             --with-sysroot=$LFS \
512
             --target=$LFS_TGT   \
513
             --disable-nls       \
514
             --enable-gprofng=no \
515
             --disable-werror    \
516
             --enable-new-dtags  \
517
             --enable-default-hash-style=gnu && make && make install; }
518
#+end_src
519
520
As we see at the top here, binutils is 1 sbu, so that means we can use it as a reference. so if glibc is 2 sbus, we can expect it to take 2 times the amount of time that binutils took.
521
522
Once thats complete, lets get back to the sources directory, and remove the binutils directory like so:
523
#+begin_src
524
cd ../..
525
rm -Rf binutils
526
#+end_src
527
528
** GCC-15.2.0 - Pass 1
529
The GCC package contains the GNU compiler collection, which includes the C and C++ compilers.
530
You are probabily familiar with this.. if you have ever compiled any C code, you probably used gcc.
531
532
This is our first pass of GCC, and this will be simply so that we can cross compile all the necessary tools in chapter 5.
533
534
#+begin_src
535
tar -xvf gcc-tab
536
cd gcc-tab
537
#+end_src
538
539
Now in here we have to extract subpackages, and rename them like so:
540
541
#+begin_src
542
tar -xf ../mpfr-4.2.2.tar.xz
543
mv -v mpfr-4.2.2 mpfr
544
tar -xf ../gmp-6.3.0.tar.xz
545
mv -v gmp-6.3.0 gmp
546
tar -xf ../mpc-1.3.1.tar.gz
547
mv -v mpc-1.3.1 mpc
548
#+end_src
549
550
Run these individually in case one errors out
551
And since were on 64 bit architecture lets run this:
552
553
#+begin_src
554
case $(uname -m) in
555
  x86_64)
556
    sed -e '/m64=/s/lib64/lib/' \
557
        -i.orig gcc/config/i386/t-linux64
558
 ;;
559
esac
560
#+end_src
561
562
And now time to build gcc...
563
564
#+begin_src
565
mkdir -v build
566
cd       build
567
#+end_src
568
569
#+begin_src
570
time { ../configure                  \
571
    --target=$LFS_TGT         \
572
    --prefix=$LFS/tools       \
573
    --with-glibc-version=2.42 \
574
    --with-sysroot=$LFS       \
575
    --with-newlib             \
576
    --without-headers         \
577
    --enable-default-pie      \
578
    --enable-default-ssp      \
579
    --disable-nls             \
580
    --disable-shared          \
581
    --disable-multilib        \
582
    --disable-threads         \
583
    --disable-libatomic       \
584
    --disable-libgomp         \
585
    --disable-libquadmath     \
586
    --disable-libssp          \
587
    --disable-libvtv          \
588
    --disable-libstdcxx       \
589
    --enable-languages=c,c++ && make && make install; }
590
#+end_src
591
592
And we need to recreate this header file:
593
594
#+begin_src
595
cd ..
596
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
597
  `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include/limits.h
598
#+end_src
599
600
and cleanup:
601
#+begin_src
602
cd ..
603
rm -rf gcc-tab
604
#+end_src
605
606
** Linux-6.16.1 API Headers:
607
The Linux API Headers provide the kernel interface that Glibc uses to interact with the Linux kernel.
608
609
Ensure no stale files embedded in this package:
610
#+begin_src
611
make mrproper
612
#+end_src
613
614
Expect no output above, and then run:
615
#+begin_src
616
make headers
617
find usr/include -type f ! -name '*.h' -delete
618
cp -rv usr/include $LFS/usr
619
#+end_src
620
621
So all we're doing here is creating the linux header files, and copying them to the lfs/usr directory.
622
623
#+begin_src
624
cd ..
625
rm -rf linux-tab
626
#+end_src
627
628
** Glibc-2.42
629
630
This is the main C library.
631
632
First we need to create symlinks for 'LSB Compliance' which is the linux standard base, which depends on your architecture so we can run this case statement here to create symlinks for where the dynamic linkers need to point to respectively:
633
634
#+begin_src
635
case $(uname -m) in
636
    i?86)   ln -sfv ld-linux.so.2 $LFS/lib/ld-lsb.so.3
637
    ;;
638
    x86_64) ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
639
            ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3
640
    ;;
641
esac
642
#+end_src
643
644
And to apply this patch here:
645
646
#+begin_src sh
647
patch -Np1 -i ../glibc-2.42-fhs-1.patch
648
#+end_src
649
650
Expected output:
651
#+begin_src
652
patching file Makeconfig
653
Hunk #1 succeeded at 262 (offset 12 lines).
654
patching file nscd/nscd.h
655
Hunk #1 succeeded at 160 (offset 48 lines).
656
patching file nss/db-Makefile
657
Hunk #1 succeeded at 21 (offset -1 lines).
658
patching file sysdeps/generic/paths.h
659
patching file sysdeps/unix/sysv/linux/paths.h
660
#+end_src
661
662
And to build glibc:
663
#+begin_src
664
mkdir -v build
665
cd       build
666
echo "rootsbindir=/usr/sbin" > configparms
667
668
../configure                             \
669
      --prefix=/usr                      \
670
      --host=$LFS_TGT                    \
671
      --build=$(../scripts/config.guess) \
672
      --disable-nscd                     \
673
      libc_cv_slibdir=/usr/lib           \
674
      --enable-kernel=5.4
675
#+end_src
676
677
#+begin_src
678
make
679
make DESTDIR=$LFS install
680
sed '/RTLDLIST=/s@/usr@@g' -i $LFS/usr/bin/ldd
681
#+end_src
682
683
Sanity checks for the symlinks:
684
685
#+begin_src
686
echo 'int main(){}' | $LFS_TGT-gcc -x c - -v -Wl,--verbose &> dummy.log
687
readelf -l a.out | grep ': /lib'
688
#+end_src
689
690
Expected output:
691
#+begin_src
692
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
693
#+end_src
694
695
Ensure we are setup to choose the correct start files:
696
#+begin_src
697
grep -E -o "$LFS/lib.*/S?crt[1in].*succeeded" dummy.log
698
#+end_src
699
700
Expected output:
701
#+begin_src
702
/mnt/lfs/lib/../lib/Scrt1.o succeeded
703
/mnt/lfs/lib/../lib/crti.o succeeded
704
/mnt/lfs/lib/../lib/crtn.o succeeded
705
#+end_src
706
707
Verify that the compiler is searching for the correct header files:
708
#+begin_src
709
grep -B3 "^ $LFS/usr/include" dummy.log
710
#+end_src
711
712
Expected output:
713
#+begin_src
714
#include <...> search starts here:
715
 /mnt/lfs/tools/lib/gcc/x86_64-lfs-linux-gnu/15.2.0/include
716
 /mnt/lfs/tools/lib/gcc/x86_64-lfs-linux-gnu/15.2.0/include-fixed
717
 /mnt/lfs/usr/include
718
#+end_src
719
720
Next, verify that the new linker is being used with the correct search paths:
721
#+begin_src
722
grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'
723
#+end_src
724
725
Expected output:
726
#+begin_src
727
SEARCH_DIR("=/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib64")
728
SEARCH_DIR("=/usr/local/lib64")
729
SEARCH_DIR("=/lib64")
730
SEARCH_DIR("=/usr/lib64")
731
SEARCH_DIR("=/mnt/lfs/tools/x86_64-lfs-linux-gnu/lib")
732
SEARCH_DIR("=/usr/local/lib")
733
SEARCH_DIR("=/lib")
734
SEARCH_DIR("=/usr/lib");
735
#+end_src
736
737
Ensure correct version of glibc:
738
#+begin_src
739
grep "/lib.*/libc.so.6 " dummy.log
740
>> attempt to open /mnt/lfs/usr/lib/libc.so.6 succeeded
741
#+end_src
742
743
Make sure gcc is using correct dynamic linker:
744
#+begin_src
745
grep found dummy.log
746
>> found ld-linux-x86-64.so.2 at /mnt/lfs/usr/lib/ld-linux-x86-64.so.2
747
#+end_src
748
749
Clean up dummy.log
750
#+begin_src
751
rm -v a.out dummy.log
752
cd ../..
753
rm -Rf glibc
754
#+end_src
755
756
** Libstdc++ from GCC-15.2.0
757
Lib standard C++ is needed to compile c++ code.
758
759
#+begin_src
760
tar -xvf gcc-15.2.0...
761
cd gcc...
762
#+end_src
763
764
#+begin_src
765
mkdir -v build; cd build
766
#+end_src
767
768
#+begin_src
769
../libstdc++-v3/configure      \
770
    --host=$LFS_TGT            \
771
    --build=$(../config.guess) \
772
    --prefix=/usr              \
773
    --disable-multilib         \
774
    --disable-nls              \
775
    --disable-libstdcxx-pch    \
776
    --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/15.2.0
777
make
778
make DESTDIR=$LFS install
779
rm -v $LFS/usr/lib/lib{stdc++{,exp,fs},supc++}.la
780
#+end_src
781
782
Clean this up:
783
#+begin_src
784
cd ../..
785
rm -rf gcc-tab
786
#+end_src
787
788
And that is the end of chaper 5. We are ready to move on to cross compiling temporary tools!
789
* Chapter 6 - Cross Compiling Temporary Tools:
790
#+begin_quote
791
"This chapter shows how to cross-compile basic utilities using the just built cross-toolchain. Those utilities are installed into their final location, but cannot be used yet. Basic tasks still rely on the host's tools. Nevertheless, the installed libraries are used when linking."  - LFS manual
792
#+end_quote
793
794
** M4-1.4.20
795
#+begin_src sh
796
cd $LFS/sources
797
tar -xf m4-1.4.20.tar.xz
798
cd m4-1.4.20
799
800
./configure --prefix=/usr   \
801
            --host=$LFS_TGT \
802
            --build=$(build-aux/config.guess)
803
804
make
805
make DESTDIR=$LFS install
806
807
cd $LFS/sources
808
rm -rf m4-1.4.20
809
#+end_src
810
811
** Ncurses-6.5-20250809
812
#+begin_src sh
813
tar -xf ncurses-6.5-20250809.tar.gz
814
cd ncurses-6.5-20250809
815
816
sed -i s/mawk// configure
817
818
mkdir build
819
pushd build
820
  ../configure
821
  make -C include
822
  make -C progs tic
823
popd
824
825
./configure --prefix=/usr                \
826
            --host=$LFS_TGT              \
827
            --build=$(./config.guess)    \
828
            --mandir=/usr/share/man      \
829
            --with-manpage-format=normal \
830
            --with-shared                \
831
            --without-normal             \
832
            --with-cxx-shared            \
833
            --without-debug              \
834
            --without-ada                \
835
            --disable-stripping          \
836
            --enable-widec
837
838
make
839
make DESTDIR=$LFS TIC_PATH=$(pwd)/build/progs/tic install
840
ln -sv libncursesw.so $LFS/usr/lib/libncurses.so
841
sed -e 's/^#if.*XOPEN.*$/#if 1/' \
842
    -i $LFS/usr/include/curses.h
843
844
cd $LFS/sources
845
rm -rf ncurses-6.5-20250809
846
#+end_src
847
848
** Bash-5.3
849
#+begin_src sh
850
tar -xf bash-5.3.tar.gz
851
cd bash-5.3
852
853
./configure --prefix=/usr                      \
854
            --build=$(sh support/config.guess) \
855
            --host=$LFS_TGT                    \
856
            --without-bash-malloc              \
857
            bash_cv_strtold_broken=no
858
859
make
860
make DESTDIR=$LFS install
861
862
ln -sv bash $LFS/bin/sh
863
864
cd $LFS/sources
865
rm -rf bash-5.3
866
#+end_src
867
868
** Coreutils-9.7
869
#+begin_src sh
870
tar -xf coreutils-9.7.tar.xz
871
cd coreutils-9.7
872
873
./configure --prefix=/usr                     \
874
            --host=$LFS_TGT                   \
875
            --build=$(build-aux/config.guess) \
876
            --enable-install-program=hostname \
877
            --enable-no-install-program=kill,uptime
878
879
make
880
make DESTDIR=$LFS install
881
882
mv -v $LFS/usr/bin/chroot $LFS/usr/sbin
883
mkdir -pv $LFS/usr/share/man/man8
884
mv -v $LFS/usr/share/man/man1/chroot.1 $LFS/usr/share/man/man8/chroot.8
885
sed -i 's/"1"/"8"/' $LFS/usr/share/man/man8/chroot.8
886
887
cd $LFS/sources
888
rm -rf coreutils-9.7
889
#+end_src
890
891
** Diffutils-3.12
892
#+begin_src sh
893
tar -xf diffutils-3.12.tar.xz
894
cd diffutils-3.12
895
896
./configure --prefix=/usr   \
897
            --host=$LFS_TGT \
898
            --build=$(./build-aux/config.guess)
899
900
make
901
make DESTDIR=$LFS install
902
903
cd $LFS/sources
904
rm -rf diffutils-3.12
905
#+end_src
906
907
** File-5.46
908
#+begin_src sh
909
tar -xf file-5.46.tar.gz
910
cd file-5.46
911
912
mkdir build
913
pushd build
914
  ../configure --disable-bzlib      \
915
               --disable-libseccomp \
916
               --disable-xzlib      \
917
               --disable-zlib
918
  make
919
popd
920
921
./configure --prefix=/usr --host=$LFS_TGT --build=$(./config.guess)
922
923
make FILE_COMPILE=$(pwd)/build/src/file
924
make DESTDIR=$LFS install
925
926
rm -v $LFS/usr/lib/libmagic.la
927
928
cd $LFS/sources
929
rm -rf file-5.46
930
#+end_src
931
932
** Findutils-4.10.0
933
#+begin_src sh
934
tar -xf findutils-4.10.0.tar.xz
935
cd findutils-4.10.0
936
937
./configure --prefix=/usr                   \
938
            --localstatedir=/var/lib/locate \
939
            --host=$LFS_TGT                 \
940
            --build=$(build-aux/config.guess)
941
942
make
943
make DESTDIR=$LFS install
944
945
cd $LFS/sources
946
rm -rf findutils-4.10.0
947
#+end_src
948
949
** Gawk-5.3.2
950
#+begin_src sh
951
tar -xf gawk-5.3.2.tar.xz
952
cd gawk-5.3.2
953
954
sed -i 's/extras//' Makefile.in
955
956
./configure --prefix=/usr   \
957
            --host=$LFS_TGT \
958
            --build=$(build-aux/config.guess)
959
960
make
961
make DESTDIR=$LFS install
962
963
cd $LFS/sources
964
rm -rf gawk-5.3.2
965
#+end_src
966
967
** Grep-3.12
968
#+begin_src sh
969
tar -xf grep-3.12.tar.xz
970
cd grep-3.12
971
972
./configure --prefix=/usr   \
973
            --host=$LFS_TGT \
974
            --build=$(./build-aux/config.guess)
975
976
make
977
make DESTDIR=$LFS install
978
979
cd $LFS/sources
980
rm -rf grep-3.12
981
#+end_src
982
983
** Gzip-1.14
984
#+begin_src sh
985
tar -xf gzip-1.14.tar.xz
986
cd gzip-1.14
987
988
./configure --prefix=/usr --host=$LFS_TGT
989
990
make
991
make DESTDIR=$LFS install
992
993
cd $LFS/sources
994
rm -rf gzip-1.14
995
#+end_src
996
997
** Make-4.4.1
998
#+begin_src sh
999
tar -xf make-4.4.1.tar.gz
1000
cd make-4.4.1
1001
1002
./configure --prefix=/usr   \
1003
            --without-guile \
1004
            --host=$LFS_TGT \
1005
            --build=$(build-aux/config.guess)
1006
1007
make
1008
make DESTDIR=$LFS install
1009
1010
cd $LFS/sources
1011
rm -rf make-4.4.1
1012
#+end_src
1013
1014
** Patch-2.8
1015
#+begin_src sh
1016
tar -xf patch-2.8.tar.xz
1017
cd patch-2.8
1018
1019
./configure --prefix=/usr   \
1020
            --host=$LFS_TGT \
1021
            --build=$(build-aux/config.guess)
1022
1023
make
1024
make DESTDIR=$LFS install
1025
1026
cd $LFS/sources
1027
rm -rf patch-2.8
1028
#+end_src
1029
1030
** Sed-4.9
1031
#+begin_src sh
1032
tar -xf sed-4.9.tar.xz
1033
cd sed-4.9
1034
1035
./configure --prefix=/usr   \
1036
            --host=$LFS_TGT \
1037
            --build=$(./build-aux/config.guess)
1038
1039
make
1040
make DESTDIR=$LFS install
1041
1042
cd $LFS/sources
1043
rm -rf sed-4.9
1044
#+end_src
1045
1046
** Tar-1.35
1047
#+begin_src sh
1048
tar -xf tar-1.35.tar.xz
1049
cd tar-1.35
1050
1051
./configure --prefix=/usr                     \
1052
            --host=$LFS_TGT                   \
1053
            --build=$(build-aux/config.guess)
1054
1055
make
1056
make DESTDIR=$LFS install
1057
1058
cd $LFS/sources
1059
rm -rf tar-1.35
1060
#+end_src
1061
1062
** Xz-5.8.1
1063
#+begin_src sh
1064
tar -xf xz-5.8.1.tar.xz
1065
cd xz-5.8.1
1066
1067
./configure --prefix=/usr                     \
1068
            --host=$LFS_TGT                   \
1069
            --build=$(build-aux/config.guess) \
1070
            --disable-static                  \
1071
            --docdir=/usr/share/doc/xz-5.8.1
1072
1073
make
1074
make DESTDIR=$LFS install
1075
1076
rm -v $LFS/usr/lib/liblzma.la
1077
1078
cd $LFS/sources
1079
rm -rf xz-5.8.1
1080
#+end_src
1081
1082
** Binutils-2.45 - Pass 2
1083
#+begin_src sh
1084
tar -xf binutils-2.45.tar.xz
1085
cd binutils-2.45
1086
1087
sed '6009s/$add_dir//' -i ltmain.sh
1088
1089
mkdir -v build
1090
cd build
1091
1092
../configure                   \
1093
    --prefix=/usr              \
1094
    --build=$(../config.guess) \
1095
    --host=$LFS_TGT            \
1096
    --disable-nls              \
1097
    --enable-shared            \
1098
    --enable-gprofng=no        \
1099
    --disable-werror           \
1100
    --enable-64-bit-bfd        \
1101
    --enable-new-dtags         \
1102
    --enable-default-hash-style=gnu
1103
1104
make
1105
make DESTDIR=$LFS install
1106
1107
rm -v $LFS/usr/lib/lib{bfd,ctf,ctf-nobfd,opcodes,sframe}.{a,la}
1108
1109
cd $LFS/sources
1110
rm -rf binutils-2.45
1111
#+end_src
1112
1113
** GCC-15.2.0 - Pass 2
1114
#+begin_src sh
1115
tar -xf gcc-15.2.0.tar.xz
1116
cd gcc-15.2.0
1117
1118
tar -xf ../mpfr-4.2.2.tar.xz
1119
mv -v mpfr-4.2.2 mpfr
1120
tar -xf ../gmp-6.3.0.tar.xz
1121
mv -v gmp-6.3.0 gmp
1122
tar -xf ../mpc-1.3.1.tar.gz
1123
mv -v mpc-1.3.1 mpc
1124
1125
case $(uname -m) in
1126
  x86_64)
1127
    sed -e '/m64=/s/lib64/lib/' \
1128
        -i.orig gcc/config/i386/t-linux64
1129
  ;;
1130
esac
1131
1132
sed '/thread_header =/s/@.*@/gthr-posix.h/' \
1133
    -i libgcc/Makefile.in libstdc++-v3/include/Makefile.in
1134
1135
mkdir -v build
1136
cd build
1137
1138
../configure                                       \
1139
    --build=$(../config.guess)                     \
1140
    --host=$LFS_TGT                                \
1141
    --target=$LFS_TGT                              \
1142
    LDFLAGS_FOR_TARGET=-L$PWD/$LFS_TGT/libgcc      \
1143
    --prefix=/usr                                  \
1144
    --with-build-sysroot=$LFS                      \
1145
    --enable-default-pie                           \
1146
    --enable-default-ssp                           \
1147
    --disable-nls                                  \
1148
    --disable-multilib                             \
1149
    --disable-libatomic                            \
1150
    --disable-libgomp                              \
1151
    --disable-libquadmath                          \
1152
    --disable-libsanitizer                         \
1153
    --disable-libssp                               \
1154
    --disable-libvtv                               \
1155
    --enable-languages=c,c++
1156
1157
make
1158
make DESTDIR=$LFS install
1159
1160
ln -sv gcc $LFS/usr/bin/cc
1161
1162
cd $LFS/sources
1163
rm -rf gcc-15.2.0
1164
#+end_src
1165
1166
* Chapter 7 - Entering Chroot and Building Additional Temporary Tools:
1167
1168
** Changing Ownership
1169
Before we enter chroot, we need to change ownership of everything to root:
1170
1171
#+begin_src sh
1172
chown -R root:root $LFS/{usr,lib,var,etc,bin,sbin,tools}
1173
case $(uname -m) in
1174
  x86_64) chown -R root:root $LFS/lib64 ;;
1175
esac
1176
#+end_src
1177
1178
** Preparing Virtual Kernel File Systems
1179
1180
To enter chroot, we need to create and mount all the binded directories like so:
1181
1182
#+begin_src sh
1183
mkdir -pv $LFS/{dev,proc,sys,run}
1184
mount -v --bind /dev $LFS/dev
1185
mount -vt devpts devpts -o gid=5,mode=0620 $LFS/dev/pts
1186
mount -vt proc proc $LFS/proc
1187
mount -vt sysfs sysfs $LFS/sys
1188
mount -vt tmpfs tmpfs $LFS/run
1189
1190
if [ -h $LFS/dev/shm ]; then
1191
  install -v -d -m 1777 $LFS$(realpath /dev/shm)
1192
else
1193
  mount -vt tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm
1194
fi
1195
#+end_src
1196
1197
** Entering Chroot
1198
1199
Then we can chroot into our new system like so:
1200
1201
#+begin_src sh
1202
chroot "$LFS" /usr/bin/env -i   \
1203
    HOME=/root                  \
1204
    TERM="$TERM"                \
1205
    PS1='(lfs chroot) \u:\w\$ ' \
1206
    PATH=/usr/bin:/usr/sbin     \
1207
    MAKEFLAGS="-j$(nproc)"      \
1208
    TESTSUITEFLAGS="-j$(nproc)" \
1209
    /bin/bash --login
1210
#+end_src
1211
1212
You should now see your prompt change to `(lfs chroot) root:/#` - you're inside your new LFS system!
1213
1214
** Creating Directories
1215
1216
Now we need to create the remaining directory structure:
1217
1218
#+begin_src sh
1219
mkdir -pv /{boot,home,mnt,opt,srv}
1220
mkdir -pv /etc/{opt,sysconfig}
1221
mkdir -pv /lib/firmware
1222
mkdir -pv /media/{floppy,cdrom}
1223
mkdir -pv /usr/{,local/}{include,src}
1224
mkdir -pv /usr/local/{bin,lib,sbin}
1225
mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man}
1226
mkdir -pv /usr/{,local/}share/{misc,terminfo,zoneinfo}
1227
mkdir -pv /usr/{,local/}share/man/man{1..8}
1228
mkdir -pv /var/{cache,local,log,mail,opt,spool}
1229
mkdir -pv /var/lib/{color,misc,locate}
1230
1231
ln -sfv /run /var/run
1232
ln -sfv /run/lock /var/lock
1233
1234
install -dv -m 0750 /root
1235
install -dv -m 1777 /tmp /var/tmp
1236
#+end_src
1237
1238
** Creating Essential Files and Symlinks
1239
1240
Create essential system files:
1241
1242
#+begin_src sh
1243
ln -sv /proc/self/mounts /etc/mtab
1244
1245
cat > /etc/hosts << EOF
1246
127.0.0.1  localhost $(hostname)
1247
::1        localhost
1248
EOF
1249
1250
cat > /etc/passwd << "EOF"
1251
root:x:0:0:root:/root:/bin/bash
1252
bin:x:1:1:bin:/dev/null:/usr/bin/false
1253
daemon:x:6:6:Daemon User:/dev/null:/usr/bin/false
1254
messagebus:x:18:18:D-Bus Message Daemon User:/run/dbus:/usr/bin/false
1255
systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/usr/bin/false
1256
systemd-journal-remote:x:74:74:systemd Journal Remote:/:/usr/bin/false
1257
systemd-journal-upload:x:75:75:systemd Journal Upload:/:/usr/bin/false
1258
systemd-network:x:76:76:systemd Network Management:/:/usr/bin/false
1259
systemd-resolve:x:77:77:systemd Resolver:/:/usr/bin/false
1260
systemd-timesync:x:78:78:systemd Time Synchronization:/:/usr/bin/false
1261
systemd-coredump:x:79:79:systemd Core Dumper:/:/usr/bin/false
1262
uuidd:x:80:80:UUID Generator Daemon User:/dev/null:/usr/bin/false
1263
systemd-oom:x:81:81:systemd Out Of Memory Daemon:/:/usr/bin/false
1264
nobody:x:65534:65534:Unprivileged User:/dev/null:/usr/bin/false
1265
EOF
1266
1267
cat > /etc/group << "EOF"
1268
root:x:0:
1269
bin:x:1:daemon
1270
sys:x:2:
1271
kmem:x:3:
1272
tape:x:4:
1273
tty:x:5:
1274
daemon:x:6:
1275
floppy:x:7:
1276
disk:x:8:
1277
lp:x:9:
1278
dialout:x:10:
1279
audio:x:11:
1280
video:x:12:
1281
utmp:x:13:
1282
cdrom:x:15:
1283
adm:x:16:
1284
messagebus:x:18:
1285
systemd-journal:x:23:
1286
input:x:24:
1287
mail:x:34:
1288
kvm:x:61:
1289
systemd-journal-gateway:x:73:
1290
systemd-journal-remote:x:74:
1291
systemd-journal-upload:x:75:
1292
systemd-network:x:76:
1293
systemd-resolve:x:77:
1294
systemd-timesync:x:78:
1295
systemd-coredump:x:79:
1296
uuidd:x:80:
1297
systemd-oom:x:81:
1298
wheel:x:97:
1299
users:x:999:
1300
nogroup:x:65534:
1301
EOF
1302
1303
echo "tester:x:101:101::/home/tester:/bin/bash" >> /etc/passwd
1304
echo "tester:x:101:" >> /etc/group
1305
install -o tester -d /home/tester
1306
1307
exec /usr/bin/bash --login
1308
1309
touch /var/log/{btmp,lastlog,faillog,wtmp}
1310
chgrp -v utmp /var/log/lastlog
1311
chmod -v 664  /var/log/lastlog
1312
chmod -v 600  /var/log/btmp
1313
#+end_src
1314
1315
Now we build the remaining temporary tools in chroot:
1316
1317
** Gettext-0.26
1318
#+begin_src sh
1319
cd /sources
1320
tar -xf gettext-0.26.tar.xz
1321
cd gettext-0.26
1322
1323
./configure --disable-shared
1324
1325
make
1326
cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /usr/bin
1327
1328
cd /sources
1329
rm -rf gettext-0.26
1330
#+end_src
1331
1332
** Bison-3.8.2
1333
#+begin_src sh
1334
tar -xf bison-3.8.2.tar.xz
1335
cd bison-3.8.2
1336
1337
./configure --prefix=/usr \
1338
            --docdir=/usr/share/doc/bison-3.8.2
1339
1340
make
1341
make install
1342
1343
cd /sources
1344
rm -rf bison-3.8.2
1345
#+end_src
1346
1347
** Perl-5.42.0
1348
#+begin_src sh
1349
tar -xf perl-5.42.0.tar.xz
1350
cd perl-5.42.0
1351
1352
sh Configure -des                                          \
1353
             -D prefix=/usr                                \
1354
             -D vendorprefix=/usr                          \
1355
             -D useshrplib                                 \
1356
             -D privlib=/usr/lib/perl5/5.42/core_perl      \
1357
             -D archlib=/usr/lib/perl5/5.42/core_perl      \
1358
             -D sitelib=/usr/lib/perl5/5.42/site_perl      \
1359
             -D sitearch=/usr/lib/perl5/5.42/site_perl     \
1360
             -D vendorlib=/usr/lib/perl5/5.42/vendor_perl  \
1361
             -D vendorarch=/usr/lib/perl5/5.42/vendor_perl
1362
1363
make
1364
make install
1365
1366
cd /sources
1367
rm -rf perl-5.42.0
1368
#+end_src
1369
1370
** Python-3.13.7
1371
Use capital P here, and ignore ssl warnings.
1372
#+begin_src sh
1373
tar -xf Python-3.13.7.tar.xz
1374
cd Python-3.13.7
1375
1376
./configure --prefix=/usr   \
1377
            --enable-shared \
1378
            --without-ensurepip
1379
1380
make
1381
make install
1382
1383
cd /sources
1384
rm -rf Python-3.13.7
1385
#+end_src
1386
1387
** Texinfo-7.2
1388
#+begin_src sh
1389
tar -xf texinfo-7.2.tar.xz
1390
cd texinfo-7.2
1391
1392
./configure --prefix=/usr
1393
1394
make
1395
make install
1396
1397
cd /sources
1398
rm -rf texinfo-7.2
1399
#+end_src
1400
1401
** Util-linux-2.41.1
1402
#+begin_src sh
1403
tar -xf util-linux-2.41.1.tar.xz
1404
cd util-linux-2.41.1
1405
1406
mkdir -pv /var/lib/hwclock
1407
1408
./configure --libdir=/usr/lib     \
1409
            --runstatedir=/run    \
1410
            --disable-chfn-chsh   \
1411
            --disable-login       \
1412
            --disable-nologin     \
1413
            --disable-su          \
1414
            --disable-setpriv     \
1415
            --disable-runuser     \
1416
            --disable-pylibmount  \
1417
            --disable-static      \
1418
            --disable-liblastlog2 \
1419
            --without-python      \
1420
            ADJTIME_PATH=/var/lib/hwclock/adjtime \
1421
            --docdir=/usr/share/doc/util-linux-2.41.1
1422
1423
make
1424
make install
1425
1426
cd /sources
1427
rm -rf util-linux-2.41.1
1428
#+end_src
1429
1430
** Cleaning up and Saving the Temporary System
1431
1432
Now let's clean up the temporary system:
1433
1434
#+begin_src sh
1435
rm -rf /usr/share/{info,man,doc}/*
1436
1437
find /usr/{lib,libexec} -name \*.la -delete
1438
1439
rm -rf /tools
1440
#+end_src
1441
1442
At this point, you can optionally backup your system. If something goes wrong in Chapter 8, you can restore from here:
1443
1444
#+begin_src sh
1445
# Exit chroot
1446
logout
1447
1448
# From the host system:
1449
cd $LFS
1450
tar -cJpf $HOME/lfs-temp-tools-12.4.tar.xz .
1451
#+end_src
1452
1453
To restore the backup later if needed:
1454
1455
#+begin_src sh
1456
cd $LFS
1457
rm -rf ./*
1458
tar -xpf $HOME/lfs-temp-tools-12.4.tar.xz
1459
#+end_src
1460
1461
And you're done with Chapter 7! The temporary tools are now built and you're ready to move on to Chapter 8 where you'll build the final LFS system.
1462
1463
* Chapter 8 - Installing Basic System Software:
1464
** Man-pages-6.15
1465
#+begin_src sh
1466
cd /sources
1467
tar -xf man-pages-6.15.tar.xz
1468
cd man-pages-6.15
1469
1470
rm -v man3/crypt*
1471
make prefix=/usr install
1472
1473
cd /sources
1474
rm -rf man-pages-6.15
1475
#+end_src
1476
1477
** Iana-Etc-20250807
1478
#+begin_src sh
1479
tar -xf iana-etc-20250807.tar.gz
1480
cd iana-etc-20250807
1481
1482
cp services protocols /etc
1483
1484
cd /sources
1485
rm -rf iana-etc-20250807
1486
#+end_src
1487
1488
** Glibc-2.42
1489
#+begin_src sh
1490
tar -xf glibc-2.42.tar.xz
1491
cd glibc-2.42
1492
1493
patch -Np1 -i ../glibc-2.42-fhs-1.patch
1494
1495
mkdir -v build
1496
cd build
1497
1498
echo "rootsbindir=/usr/sbin" > configparms
1499
1500
../configure --prefix=/usr                            \
1501
             --disable-werror                         \
1502
             --enable-kernel=5.4                      \
1503
             --enable-stack-protector=strong          \
1504
             --disable-nscd                           \
1505
             libc_cv_slibdir=/usr/lib
1506
1507
make
1508
1509
# Optional but recommended - run tests
1510
make check
1511
1512
# Install
1513
touch /etc/ld.so.conf
1514
sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile
1515
make install
1516
sed '/RTLDLIST=/s@/usr@@g' -i /usr/bin/ldd
1517
1518
# Configure Glibc
1519
cat > /etc/nsswitch.conf << "EOF"
1520
passwd: files
1521
group: files
1522
shadow: files
1523
1524
hosts: files dns
1525
networks: files
1526
1527
protocols: files
1528
services: files
1529
ethers: files
1530
rpc: files
1531
EOF
1532
1533
# Add timezone data
1534
tar -xf ../../tzdata2025b.tar.gz
1535
1536
ZONEINFO=/usr/share/zoneinfo
1537
mkdir -pv $ZONEINFO/{posix,right}
1538
1539
for tz in etcetera southamerica northamerica europe africa antarctica  \
1540
          asia australasia backward; do
1541
    zic -L /dev/null   -d $ZONEINFO       ${tz}
1542
    zic -L /dev/null   -d $ZONEINFO/posix ${tz}
1543
    zic -L leapseconds -d $ZONEINFO/right ${tz}
1544
done
1545
1546
cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO
1547
zic -d $ZONEINFO -p America/New_York
1548
unset ZONEINFO
1549
1550
# Set your timezone (adjust as needed)
1551
ln -sfv /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
1552
1553
# Configure dynamic loader
1554
cat > /etc/ld.so.conf << "EOF"
1555
/usr/local/lib
1556
/opt/lib
1557
EOF
1558
1559
# Configure limits
1560
cat > /etc/ld.so.conf << "EOF"
1561
/usr/local/lib
1562
/opt/lib
1563
EOF
1564
1565
mkdir -pv /usr/lib/locale
1566
localedef -i C -f UTF-8 C.UTF-8
1567
localedef -i en_US -f UTF-8 en_US.UTF-8
1568
1569
cd /sources
1570
rm -rf glibc-2.42
1571
#+end_src
1572
1573
** Zlib-1.3.1
1574
I had a bug with this package so I copied it from the host iso image.
1575
#+begin_src
1576
sudo cp -av /usr/lib64/libz.so* /mnt/lfs/usr/lib/
1577
#+end_src
1578
1579
Or do it the proper way:
1580
#+begin_src sh
1581
tar -xf zlib-1.3.1.tar.xz
1582
cd zlib-1.3.1
1583
1584
./configure --prefix=/usr
1585
1586
make
1587
make check
1588
make install
1589
1590
rm -fv /usr/lib/libz.a
1591
1592
cd /sources
1593
rm -rf zlib-1.3.1
1594
#+end_src
1595
1596
** Bzip2-1.0.8
1597
#+begin_src sh
1598
tar -xf bzip2-1.0.8.tar.gz
1599
cd bzip2-1.0.8
1600
1601
patch -Np1 -i ../bzip2-1.0.8-install_docs-1.patch
1602
1603
sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile
1604
sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile
1605
1606
make -f Makefile-libbz2_so
1607
make clean
1608
make
1609
make PREFIX=/usr install
1610
1611
cp -av libbz2.so.* /usr/lib
1612
ln -sv libbz2.so.1.0.8 /usr/lib/libbz2.so
1613
1614
cp -v bzip2-shared /usr/bin/bzip2
1615
for i in /usr/bin/{bzcat,bunzip2}; do
1616
  ln -sfv bzip2 $i
1617
done
1618
1619
rm -fv /usr/lib/libbz2.a
1620
1621
cd /sources
1622
rm -rf bzip2-1.0.8
1623
#+end_src
1624
1625
** Xz-5.8.1
1626
#+begin_src sh
1627
tar -xf xz-5.8.1.tar.xz
1628
cd xz-5.8.1
1629
1630
./configure --prefix=/usr    \
1631
            --disable-static \
1632
            --docdir=/usr/share/doc/xz-5.8.1
1633
1634
make
1635
make check
1636
make install
1637
1638
cd /sources
1639
rm -rf xz-5.8.1
1640
#+end_src
1641
1642
** Lz4-1.10.0
1643
#+begin_src sh
1644
tar -xf lz4-1.10.0.tar.gz
1645
cd lz4-1.10.0
1646
1647
make BUILD_STATIC=no PREFIX=/usr
1648
make -j1 check
1649
make BUILD_STATIC=no PREFIX=/usr install
1650
1651
cd /sources
1652
rm -rf lz4-1.10.0
1653
#+end_src
1654
1655
** Zstd-1.5.7
1656
#+begin_src sh
1657
tar -xf zstd-1.5.7.tar.gz
1658
cd zstd-1.5.7
1659
1660
make prefix=/usr
1661
make check
1662
make prefix=/usr install
1663
1664
rm -v /usr/lib/libzstd.a
1665
1666
cd /sources
1667
rm -rf zstd-1.5.7
1668
#+end_src
1669
1670
** File-5.46
1671
#+begin_src sh
1672
tar -xf file-5.46.tar.gz
1673
cd file-5.46
1674
1675
./configure --prefix=/usr
1676
1677
make
1678
make check
1679
make install
1680
1681
cd /sources
1682
rm -rf file-5.46
1683
#+end_src
1684
1685
** Readline-8.3
1686
#+begin_src sh
1687
tar -xf readline-8.3.tar.gz
1688
cd readline-8.3
1689
1690
sed -i '/MV.*old/d' Makefile.in
1691
sed -i '/{OLDSUFF}/c:' support/shlib-install
1692
1693
./configure --prefix=/usr    \
1694
            --disable-static \
1695
            --with-curses    \
1696
            --docdir=/usr/share/doc/readline-8.3
1697
1698
make SHLIB_LIBS="-lncursesw"
1699
make SHLIB_LIBS="-lncursesw" install
1700
1701
install -v -m644 doc/*.{ps,pdf,html,dvi} /usr/share/doc/readline-8.3
1702
1703
cd /sources
1704
rm -rf readline-8.3
1705
#+end_src
1706
1707
** M4-1.4.20
1708
#+begin_src sh
1709
tar -xf m4-1.4.20.tar.xz
1710
cd m4-1.4.20
1711
1712
./configure --prefix=/usr
1713
1714
make
1715
make check
1716
make install
1717
1718
cd /sources
1719
rm -rf m4-1.4.20
1720
#+end_src
1721
1722
** Bc-7.0.3
1723
#+begin_src sh
1724
tar -xf bc-7.0.3.tar.xz
1725
cd bc-7.0.3
1726
1727
CC=gcc ./configure --prefix=/usr -G -O3 -r
1728
1729
make
1730
make test
1731
make install
1732
1733
cd /sources
1734
rm -rf bc-7.0.3
1735
#+end_src
1736
1737
** Flex-2.6.4
1738
#+begin_src sh
1739
tar -xf flex-2.6.4.tar.gz
1740
cd flex-2.6.4
1741
1742
./configure --prefix=/usr \
1743
            --docdir=/usr/share/doc/flex-2.6.4 \
1744
            --disable-static
1745
1746
make
1747
make check
1748
make install
1749
1750
ln -sv flex /usr/bin/lex
1751
ln -sv flex.1 /usr/share/man/man1/lex.1
1752
1753
cd /sources
1754
rm -rf flex-2.6.4
1755
#+end_src
1756
1757
** Tcl-8.6.16
1758
#+begin_src sh
1759
tar -xf tcl8.6.16-src.tar.gz
1760
cd tcl8.6.16
1761
1762
SRCDIR=$(pwd)
1763
cd unix
1764
./configure --prefix=/usr           \
1765
            --mandir=/usr/share/man
1766
1767
make
1768
1769
sed -e "s|$SRCDIR/unix|/usr/lib|" \
1770
    -e "s|$SRCDIR|/usr/include|"  \
1771
    -i tclConfig.sh
1772
1773
sed -e "s|$SRCDIR/unix/pkgs/tdbc1.1.10|/usr/lib/tdbc1.1.10|" \
1774
    -e "s|$SRCDIR/pkgs/tdbc1.1.10/generic|/usr/include|"    \
1775
    -e "s|$SRCDIR/pkgs/tdbc1.1.10/library|/usr/lib/tcl8.6|" \
1776
    -e "s|$SRCDIR/pkgs/tdbc1.1.10|/usr/include|"            \
1777
    -i pkgs/tdbc1.1.10/tdbcConfig.sh
1778
1779
sed -e "s|$SRCDIR/unix/pkgs/itcl4.2.5|/usr/lib/itcl4.2.5|" \
1780
    -e "s|$SRCDIR/pkgs/itcl4.2.5/generic|/usr/include|"    \
1781
    -e "s|$SRCDIR/pkgs/itcl4.2.5|/usr/include|"            \
1782
    -i pkgs/itcl4.2.5/itclConfig.sh
1783
1784
unset SRCDIR
1785
1786
make test
1787
make install
1788
1789
chmod -v u+w /usr/lib/libtcl8.6.so
1790
1791
make install-private-headers
1792
1793
ln -sfv tclsh8.6 /usr/bin/tclsh
1794
mv /usr/share/man/man3/{Thread,Tcl_Thread}.3
1795
1796
cd /sources
1797
rm -rf tcl8.6.16
1798
#+end_src
1799
1800
** Expect-5.45.4
1801
#+begin_src sh
1802
tar -xf expect5.45.4.tar.gz
1803
cd expect5.45.4
1804
1805
python3 -c 'from pty import spawn; spawn(["echo", "ok"])'
1806
1807
patch -Np1 -i ../expect-5.45.4-gcc15-1.patch
1808
1809
./configure --prefix=/usr           \
1810
            --with-tcl=/usr/lib     \
1811
            --enable-shared         \
1812
            --disable-rpath         \
1813
            --mandir=/usr/share/man \
1814
            --with-tclinclude=/usr/include
1815
1816
make
1817
make test
1818
make install
1819
ln -svf expect5.45.4/libexpect5.45.4.so /usr/lib
1820
1821
cd /sources
1822
rm -rf expect5.45.4
1823
#+end_src
1824
1825
** DejaGNU-1.6.3
1826
#+begin_src sh
1827
tar -xf dejagnu-1.6.3.tar.gz
1828
cd dejagnu-1.6.3
1829
1830
mkdir -v build
1831
cd build
1832
1833
../configure --prefix=/usr
1834
makeinfo --html --no-split -o doc/dejagnu.html ../doc/dejagnu.texi
1835
makeinfo --plaintext       -o doc/dejagnu.txt  ../doc/dejagnu.texi
1836
1837
make install
1838
install -v -dm755  /usr/share/doc/dejagnu-1.6.3
1839
install -v -m644   doc/dejagnu.{html,txt} /usr/share/doc/dejagnu-1.6.3
1840
1841
make check
1842
1843
cd /sources
1844
rm -rf dejagnu-1.6.3
1845
#+end_src
1846
1847
** Pkgconf-2.5.1
1848
#+begin_src sh
1849
tar -xf pkgconf-2.5.1.tar.xz
1850
cd pkgconf-2.5.1
1851
1852
./configure --prefix=/usr              \
1853
            --disable-static           \
1854
            --docdir=/usr/share/doc/pkgconf-2.5.1
1855
1856
make
1857
make install
1858
1859
ln -sv pkgconf   /usr/bin/pkg-config
1860
ln -sv pkgconf.1 /usr/share/man/man1/pkg-config.1
1861
1862
cd /sources
1863
rm -rf pkgconf-2.5.1
1864
#+end_src
1865
1866
** Binutils-2.45
1867
#+begin_src sh
1868
tar -xf binutils-2.45.tar.xz
1869
cd binutils-2.45
1870
1871
mkdir -v build
1872
cd build
1873
1874
../configure --prefix=/usr       \
1875
             --sysconfdir=/etc   \
1876
             --enable-gold       \
1877
             --enable-ld=default \
1878
             --enable-plugins    \
1879
             --enable-shared     \
1880
             --disable-werror    \
1881
             --enable-64-bit-bfd \
1882
             --enable-new-dtags  \
1883
             --with-system-zlib  \
1884
             --enable-default-hash-style=gnu
1885
1886
make tooldir=/usr
1887
1888
make -k check
1889
1890
make tooldir=/usr install
1891
1892
rm -fv /usr/lib/lib{bfd,ctf,ctf-nobfd,gprofng,opcodes,sframe}.a
1893
1894
cd /sources
1895
rm -rf binutils-2.45
1896
#+end_src
1897
1898
** GMP-6.3.0
1899
#+begin_src sh
1900
tar -xf gmp-6.3.0.tar.xz
1901
cd gmp-6.3.0
1902
1903
./configure --prefix=/usr    \
1904
            --enable-cxx     \
1905
            --disable-static \
1906
            --docdir=/usr/share/doc/gmp-6.3.0
1907
1908
make
1909
make html
1910
1911
make check 2>&1 | tee gmp-check-log
1912
awk '/# PASS:/{total+=$3} ; END{print total}' gmp-check-log
1913
1914
make install
1915
make install-html
1916
1917
cd /sources
1918
rm -rf gmp-6.3.0
1919
#+end_src
1920
1921
** MPFR-4.2.2
1922
#+begin_src sh
1923
tar -xf mpfr-4.2.2.tar.xz
1924
cd mpfr-4.2.2
1925
1926
./configure --prefix=/usr        \
1927
            --disable-static     \
1928
            --enable-thread-safe \
1929
            --docdir=/usr/share/doc/mpfr-4.2.2
1930
1931
make
1932
make html
1933
1934
make check
1935
1936
make install
1937
make install-html
1938
1939
cd /sources
1940
rm -rf mpfr-4.2.2
1941
#+end_src
1942
1943
** MPC-1.3.1
1944
#+begin_src sh
1945
tar -xf mpc-1.3.1.tar.gz
1946
cd mpc-1.3.1
1947
1948
./configure --prefix=/usr    \
1949
            --disable-static \
1950
            --docdir=/usr/share/doc/mpc-1.3.1
1951
1952
make
1953
make html
1954
1955
make check
1956
1957
make install
1958
make install-html
1959
1960
cd /sources
1961
rm -rf mpc-1.3.1
1962
#+end_src
1963
1964
** Attr-2.5.2
1965
#+begin_src sh
1966
tar -xf attr-2.5.2.tar.gz
1967
cd attr-2.5.2
1968
1969
./configure --prefix=/usr     \
1970
            --disable-static  \
1971
            --sysconfdir=/etc \
1972
            --docdir=/usr/share/doc/attr-2.5.2
1973
1974
make
1975
make check
1976
make install
1977
1978
cd /sources
1979
rm -rf attr-2.5.2
1980
#+end_src
1981
1982
** Acl-2.3.2
1983
#+begin_src sh
1984
tar -xf acl-2.3.2.tar.xz
1985
cd acl-2.3.2
1986
1987
./configure --prefix=/usr         \
1988
            --disable-static      \
1989
            --docdir=/usr/share/doc/acl-2.3.2
1990
1991
make
1992
make install
1993
1994
cd /sources
1995
rm -rf acl-2.3.2
1996
#+end_src
1997
1998
** Libcap-2.76
1999
#+begin_src sh
2000
tar -xf libcap-2.76.tar.xz
2001
cd libcap-2.76
2002
2003
sed -i '/install -m.*STA/d' libcap/Makefile
2004
2005
make prefix=/usr lib=lib
2006
make test
2007
make prefix=/usr lib=lib install
2008
2009
cd /sources
2010
rm -rf libcap-2.76
2011
#+end_src
2012
2013
** Libxcrypt-4.4.38
2014
We can ignore note about api headers
2015
#+begin_src sh
2016
tar -xf libxcrypt-4.4.38.tar.xz
2017
cd libxcrypt-4.4.38
2018
2019
./configure --prefix=/usr                \
2020
            --enable-hashes=strong,glibc \
2021
            --enable-obsolete-api=no     \
2022
            --disable-static             \
2023
            --disable-failure-tokens
2024
2025
make
2026
make check
2027
make install
2028
2029
cd /sources
2030
rm -rf libxcrypt-4.4.38
2031
#+end_src
2032
2033
** Shadow-4.18.0
2034
#+begin_src sh
2035
tar -xf shadow-4.18.0.tar.xz
2036
cd shadow-4.18.0
2037
2038
sed -i 's/groups$(EXEEXT) //' src/Makefile.in
2039
find man -name Makefile.in -exec sed -i 's/groups\.1 / /'   {} \;
2040
find man -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \;
2041
find man -name Makefile.in -exec sed -i 's/passwd\.5 / /'   {} \;
2042
2043
sed -e 's:#ENCRYPT_METHOD DES:ENCRYPT_METHOD YESCRYPT:' \
2044
    -e 's:/var/spool/mail:/var/mail:'                   \
2045
    -e '/PATH=/{s@/sbin:@@;s@/bin:@@}'                  \
2046
    -i etc/login.defs
2047
2048
touch /usr/bin/passwd
2049
./configure --sysconfdir=/etc   \
2050
            --disable-static    \
2051
            --with-{b,yes}crypt \
2052
            --without-libbsd    \
2053
            --with-group-name-max-length=32
2054
2055
make
2056
make exec_prefix=/usr install
2057
make -C man install-man
2058
2059
pwconv
2060
grpconv
2061
2062
mkdir -p /etc/default
2063
useradd -D --gid 999
2064
2065
sed -i '/MAIL/s/yes/no/' /etc/default/useradd
2066
2067
cd /sources
2068
rm -rf shadow-4.18.0
2069
#+end_src
2070
2071
** GCC-15.2.0
2072
Check gcc failures with the link in the build logs in the book
2073
pr0576 or whatever is a known fail
2074
#+begin_src sh
2075
tar -xf gcc-15.2.0.tar.xz
2076
cd gcc-15.2.0
2077
2078
case $(uname -m) in
2079
  x86_64)
2080
    sed -e '/m64=/s/lib64/lib/' \
2081
        -i.orig gcc/config/i386/t-linux64
2082
  ;;
2083
esac
2084
2085
mkdir -v build
2086
cd build
2087
2088
../configure --prefix=/usr            \
2089
             LD=ld                    \
2090
             --enable-languages=c,c++ \
2091
             --enable-default-pie     \
2092
             --enable-default-ssp     \
2093
             --enable-host-pie        \
2094
             --disable-multilib       \
2095
             --disable-bootstrap      \
2096
             --disable-fixincludes    \
2097
             --with-system-zlib
2098
2099
make
2100
2101
# Test suite (takes a long time)
2102
ulimit -s -H unlimited
2103
sed -e '/cpython/d'               -i ../gcc/testsuite/gcc.dg/plugin/plugin.exp
2104
sed -e 's/no-pic /&-no-pie /'     -i ../gcc/testsuite/gcc.target/i386/pr113689-1.c
2105
sed -e 's/300000/(1|300000)/'     -i ../libgomp/testsuite/libgomp.c-c++-common/pr94366.c
2106
sed -e 's/{ target nonpic }//' -e '/GOTPCREL/d' -i ../gcc/testsuite/gcc.target/i386/fentryname3.c
2107
2108
chown -R tester .
2109
su tester -c "PATH=$PATH make -k check"
2110
2111
# See test results
2112
../contrib/test_summary
2113
2114
make install
2115
2116
chown -v -R root:root \
2117
    /usr/lib/gcc/$(gcc -dumpmachine)/15.2.0/include{,-fixed}
2118
2119
ln -svr /usr/bin/cpp /usr/lib
2120
2121
ln -sv gcc.1 /usr/share/man/man1/cc.1
2122
2123
ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/15.2.0/liblto_plugin.so \
2124
        /usr/lib/bfd-plugins/
2125
2126
echo 'int main(){}' > dummy.c
2127
cc dummy.c -v -Wl,--verbose &> dummy.log
2128
readelf -l a.out | grep ': /lib'
2129
2130
# Should output: [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
2131
2132
grep -E -o '/usr/lib.*/S?crt[1in].*succeeded' dummy.log
2133
grep -B4 '^ /usr/include' dummy.log
2134
grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'
2135
grep "/lib.*/libc.so.6 " dummy.log
2136
grep found dummy.log
2137
2138
rm -v dummy.c a.out dummy.log
2139
2140
mkdir -pv /usr/share/gdb/auto-load/usr/lib
2141
mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib
2142
2143
cd /sources
2144
rm -rf gcc-15.2.0
2145
#+end_src
2146
2147
** Ncurses-6.5-20250809
2148
Ignore warning, and do cd test and play with some of these. could be good content. ./hanoi, ./knight
2149
#+begin_src sh
2150
tar -xf ncurses-6.5-20250809.tar.gz
2151
cd ncurses-6.5-20250809
2152
2153
./configure --prefix=/usr           \
2154
            --mandir=/usr/share/man \
2155
            --with-shared           \
2156
            --without-debug         \
2157
            --without-normal        \
2158
            --with-cxx-shared       \
2159
            --enable-pc-files       \
2160
            --with-pkg-config-libdir=/usr/lib/pkgconfig
2161
2162
make
2163
make DESTDIR=$PWD/dest install
2164
install -vm755 dest/usr/lib/libncursesw.so.6.5 /usr/lib
2165
rm -v  dest/usr/lib/libncursesw.so.6.5
2166
sed -e 's/^#if.*XOPEN.*$/#if 1/' \
2167
    -i dest/usr/include/curses.h
2168
cp -av dest/* /
2169
2170
for lib in ncurses form panel menu ; do
2171
    ln -sfv lib${lib}w.so /usr/lib/lib${lib}.so
2172
    ln -sfv ${lib}w.pc    /usr/lib/pkgconfig/${lib}.pc
2173
done
2174
2175
ln -sfv libncursesw.so /usr/lib/libcurses.so
2176
2177
cp -v -R doc -T /usr/share/doc/ncurses-6.5-20250809
2178
2179
# Optional - play with demos
2180
make distclean
2181
./configure --prefix=/usr    \
2182
            --with-shared    \
2183
            --without-normal \
2184
            --without-debug  \
2185
            --without-cxx-binding \
2186
            --with-abi-version=5
2187
2188
make sources libs
2189
cp -av lib/lib*.so.5* /usr/lib
2190
2191
cd /sources
2192
rm -rf ncurses-6.5-20250809
2193
#+end_src
2194
2195
** Sed-4.9
2196
#+begin_src sh
2197
tar -xf sed-4.9.tar.xz
2198
cd sed-4.9
2199
2200
./configure --prefix=/usr
2201
2202
make
2203
make html
2204
2205
chown -R tester .
2206
su tester -c "PATH=$PATH make check"
2207
2208
make install
2209
install -d -m755           /usr/share/doc/sed-4.9
2210
install -m644 doc/sed.html /usr/share/doc/sed-4.9
2211
2212
cd /sources
2213
rm -rf sed-4.9
2214
#+end_src
2215
2216
** Psmisc-23.7
2217
#+begin_src sh
2218
tar -xf psmisc-23.7.tar.xz
2219
cd psmisc-23.7
2220
2221
./configure --prefix=/usr
2222
2223
make
2224
make check
2225
make install
2226
2227
cd /sources
2228
rm -rf psmisc-23.7
2229
#+end_src
2230
2231
** Gettext-0.26
2232
#+begin_src sh
2233
tar -xf gettext-0.26.tar.xz
2234
cd gettext-0.26
2235
2236
./configure --prefix=/usr    \
2237
            --disable-static \
2238
            --docdir=/usr/share/doc/gettext-0.26
2239
2240
make
2241
make check
2242
make install
2243
chmod -v 0755 /usr/lib/preloadable_libintl.so
2244
2245
cd /sources
2246
rm -rf gettext-0.26
2247
#+end_src
2248
2249
** Bison-3.8.2
2250
#+begin_src sh
2251
tar -xf bison-3.8.2.tar.xz
2252
cd bison-3.8.2
2253
2254
./configure --prefix=/usr --docdir=/usr/share/doc/bison-3.8.2
2255
2256
make
2257
make check
2258
make install
2259
2260
cd /sources
2261
rm -rf bison-3.8.2
2262
#+end_src
2263
2264
** Grep-3.12
2265
#+begin_src sh
2266
tar -xf grep-3.12.tar.xz
2267
cd grep-3.12
2268
2269
sed -i "s/echo/#echo/" src/egrep.sh
2270
2271
./configure --prefix=/usr
2272
2273
make
2274
make check
2275
make install
2276
2277
cd /sources
2278
rm -rf grep-3.12
2279
#+end_src
2280
2281
** Bash-5.3
2282
#+begin_src sh
2283
tar -xf bash-5.3.tar.gz
2284
cd bash-5.3
2285
2286
./configure --prefix=/usr             \
2287
            --without-bash-malloc     \
2288
            --with-installed-readline \
2289
            bash_cv_strtold_broken=no \
2290
            --docdir=/usr/share/doc/bash-5.3
2291
2292
make
2293
2294
chown -R tester .
2295
2296
su -s /usr/bin/expect tester << "EOF"
2297
set timeout -1
2298
spawn make tests
2299
expect eof
2300
lassign [wait] _ _ _ value
2301
exit $value
2302
EOF
2303
2304
make install
2305
2306
# Start a new shell
2307
exec /usr/bin/bash --login
2308
2309
cd /sources
2310
rm -rf bash-5.3
2311
#+end_src
2312
2313
** Libtool-2.5.4
2314
#+begin_src sh
2315
tar -xf libtool-2.5.4.tar.xz
2316
cd libtool-2.5.4
2317
2318
./configure --prefix=/usr
2319
2320
make
2321
make -k check
2322
make install
2323
2324
rm -fv /usr/lib/libltdl.a
2325
2326
cd /sources
2327
rm -rf libtool-2.5.4
2328
#+end_src
2329
2330
** GDBM-1.26
2331
#+begin_src sh
2332
tar -xf gdbm-1.26.tar.gz
2333
cd gdbm-1.26
2334
2335
./configure --prefix=/usr    \
2336
            --disable-static \
2337
            --enable-libgdbm-compat
2338
2339
make
2340
make check
2341
make install
2342
2343
cd /sources
2344
rm -rf gdbm-1.26
2345
#+end_src
2346
2347
** Gperf-3.3
2348
#+begin_src sh
2349
tar -xf gperf-3.3.tar.gz
2350
cd gperf-3.3
2351
2352
./configure --prefix=/usr --docdir=/usr/share/doc/gperf-3.3
2353
2354
make
2355
make -j1 check
2356
make install
2357
2358
cd /sources
2359
rm -rf gperf-3.3
2360
#+end_src
2361
2362
** Expat-2.7.1
2363
#+begin_src sh
2364
tar -xf expat-2.7.1.tar.xz
2365
cd expat-2.7.1
2366
2367
./configure --prefix=/usr    \
2368
            --disable-static \
2369
            --docdir=/usr/share/doc/expat-2.7.1
2370
2371
make
2372
make check
2373
make install
2374
2375
install -v -m644 doc/*.{html,css} /usr/share/doc/expat-2.7.1
2376
2377
cd /sources
2378
rm -rf expat-2.7.1
2379
#+end_src
2380
2381
** Inetutils-2.6
2382
#+begin_src sh
2383
tar -xf inetutils-2.6.tar.xz
2384
cd inetutils-2.6
2385
2386
sed -i 's/def HAVE_TERMCAP_TGETENT/ 1/' telnet/telnet.c
2387
2388
./configure --prefix=/usr        \
2389
            --bindir=/usr/bin    \
2390
            --localstatedir=/var \
2391
            --disable-logger     \
2392
            --disable-whois      \
2393
            --disable-rcp        \
2394
            --disable-rexec      \
2395
            --disable-rlogin     \
2396
            --disable-rsh        \
2397
            --disable-servers
2398
2399
make
2400
make check
2401
make install
2402
2403
mv -v /usr/{,s}bin/ifconfig
2404
2405
cd /sources
2406
rm -rf inetutils-2.6
2407
#+end_src
2408
2409
** Less-679
2410
#+begin_src sh
2411
tar -xf less-679.tar.gz
2412
cd less-679
2413
2414
./configure --prefix=/usr --sysconfdir=/etc
2415
2416
make
2417
make check
2418
make install
2419
2420
cd /sources
2421
rm -rf less-679
2422
#+end_src
2423
2424
** Perl-5.42.0
2425
#+begin_src sh
2426
tar -xf perl-5.42.0.tar.xz
2427
cd perl-5.42.0
2428
2429
export BUILD_ZLIB=False
2430
export BUILD_BZIP2=0
2431
2432
sh Configure -des                                          \
2433
             -D prefix=/usr                                \
2434
             -D vendorprefix=/usr                          \
2435
             -D privlib=/usr/lib/perl5/5.42/core_perl      \
2436
             -D archlib=/usr/lib/perl5/5.42/core_perl      \
2437
             -D sitelib=/usr/lib/perl5/5.42/site_perl      \
2438
             -D sitearch=/usr/lib/perl5/5.42/site_perl     \
2439
             -D vendorlib=/usr/lib/perl5/5.42/vendor_perl  \
2440
             -D vendorarch=/usr/lib/perl5/5.42/vendor_perl \
2441
             -D man1dir=/usr/share/man/man1                \
2442
             -D man3dir=/usr/share/man/man3                \
2443
             -D pager="/usr/bin/less -isR"                 \
2444
             -D useshrplib                                 \
2445
             -D usethreads
2446
2447
make
2448
TEST_JOBS=$(nproc) make test_harness
2449
make install
2450
unset BUILD_ZLIB BUILD_BZIP2
2451
2452
cd /sources
2453
rm -rf perl-5.42.0
2454
#+end_src
2455
2456
** XML::Parser-2.47
2457
#+begin_src sh
2458
tar -xf XML-Parser-2.47.tar.gz
2459
cd XML-Parser-2.47
2460
2461
perl Makefile.PL
2462
2463
make
2464
make test
2465
make install
2466
2467
cd /sources
2468
rm -rf XML-Parser-2.47
2469
#+end_src
2470
2471
** Intltool-0.51.0
2472
#+begin_src sh
2473
tar -xf intltool-0.51.0.tar.gz
2474
cd intltool-0.51.0
2475
2476
sed -i 's:\\\${:\\\$\\{:' intltool-update.in
2477
2478
./configure --prefix=/usr
2479
2480
make
2481
make check
2482
make install
2483
install -v -Dm644 doc/I18N-HOWTO /usr/share/doc/intltool-0.51.0/I18N-HOWTO
2484
2485
cd /sources
2486
rm -rf intltool-0.51.0
2487
#+end_src
2488
2489
** Autoconf-2.72
2490
#+begin_src sh
2491
tar -xf autoconf-2.72.tar.xz
2492
cd autoconf-2.72
2493
2494
./configure --prefix=/usr
2495
2496
make
2497
make check
2498
make install
2499
2500
cd /sources
2501
rm -rf autoconf-2.72
2502
#+end_src
2503
2504
** Automake-1.18.1
2505
#+begin_src sh
2506
tar -xf automake-1.18.1.tar.xz
2507
cd automake-1.18.1
2508
2509
./configure --prefix=/usr --docdir=/usr/share/doc/automake-1.18.1
2510
2511
make
2512
make -j$(($(nproc)>4?$(nproc):4)) check
2513
make install
2514
2515
cd /sources
2516
rm -rf automake-1.18.1
2517
#+end_src
2518
2519
** OpenSSL-3.5.2
2520
#+begin_src sh
2521
tar -xf openssl-3.5.2.tar.gz
2522
cd openssl-3.5.2
2523
2524
./config --prefix=/usr         \
2525
         --openssldir=/etc/ssl \
2526
         --libdir=lib          \
2527
         shared                \
2528
         zlib-dynamic
2529
2530
make
2531
HARNESS_JOBS=$(nproc) make test
2532
sed -i '/INSTALL_LIBS/s/libcrypto.a libssl.a//' Makefile
2533
make MANSUFFIX=ssl install
2534
2535
mv -v /usr/share/doc/openssl /usr/share/doc/openssl-3.5.2
2536
2537
cp -vfr doc/* /usr/share/doc/openssl-3.5.2
2538
2539
cd /sources
2540
rm -rf openssl-3.5.2
2541
#+end_src
2542
2543
** Libelf from Elfutils-0.193
2544
Known failure in dwarf_scrlang_check
2545
#+begin_src sh
2546
tar -xf elfutils-0.193.tar.bz2
2547
cd elfutils-0.193
2548
2549
./configure --prefix=/usr                \
2550
            --disable-debuginfod         \
2551
            --enable-libdebuginfod=dummy
2552
2553
make
2554
make check
2555
make -C libelf install
2556
install -vm644 config/libelf.pc /usr/lib/pkgconfig
2557
rm /usr/lib/libelf.a
2558
2559
cd /sources
2560
rm -rf elfutils-0.193
2561
#+end_src
2562
2563
** Libffi-3.5.2
2564
#+begin_src sh
2565
tar -xf libffi-3.5.2.tar.gz
2566
cd libffi-3.5.2
2567
2568
./configure --prefix=/usr          \
2569
            --disable-static       \
2570
            --with-gcc-arch=native
2571
2572
make
2573
make check
2574
make install
2575
2576
cd /sources
2577
rm -rf libffi-3.5.2
2578
#+end_src
2579
2580
** Python-3.13.7
2581
Known expected warning can be surpressed by adding root user action to the global pip.conf like so
2582
#+begin_src sh
2583
tar -xf Python-3.13.7.tar.xz
2584
cd Python-3.13.7
2585
2586
./configure --prefix=/usr        \
2587
            --enable-shared      \
2588
            --with-system-expat  \
2589
            --enable-optimizations
2590
2591
make
2592
make test
2593
make install
2594
2595
cat > /etc/pip.conf << EOF
2596
[global]
2597
root-user-action = ignore
2598
disable-pip-version-check = true
2599
EOF
2600
2601
install -v -dm755 /usr/share/doc/python-3.13.7/html
2602
2603
tar --no-same-owner \
2604
    -xvf ../python-3.13.7-docs-html.tar.bz2
2605
cp -R --no-preserve=mode python-3.13.7-docs-html/* \
2606
    /usr/share/doc/python-3.13.7/html
2607
2608
cd /sources
2609
rm -rf Python-3.13.7
2610
#+end_src
2611
2612
** Flit-Core-3.12.0
2613
#+begin_src sh
2614
tar -xf flit_core-3.12.0.tar.gz
2615
cd flit_core-3.12.0
2616
2617
pip3 wheel -w dist --no-cache-dir --no-build-isolation --no-deps $PWD
2618
2619
pip3 install --no-index --no-user --find-links dist flit_core
2620
2621
cd /sources
2622
rm -rf flit_core-3.12.0
2623
#+end_src
2624
2625
** Packaging-25.0
2626
#+begin_src sh
2627
tar -xf packaging-25.0.tar.gz
2628
cd packaging-25.0
2629
2630
pip3 wheel -w dist --no-cache-dir --no-build-isolation --no-deps $PWD
2631
2632
pip3 install --no-index --no-user --find-links dist packaging
2633
2634
cd /sources
2635
rm -rf packaging-25.0
2636
#+end_src
2637
2638
** Wheel-0.46.1
2639
#+begin_src sh
2640
tar -xf wheel-0.46.1.tar.gz
2641
cd wheel-0.46.1
2642
2643
pip3 wheel -w dist --no-cache-dir --no-build-isolation --no-deps $PWD
2644
2645
pip3 install --no-index --find-links=dist wheel
2646
2647
cd /sources
2648
rm -rf wheel-0.46.1
2649
#+end_src
2650
2651
** Setuptools-80.9.0
2652
#+begin_src sh
2653
tar -xf setuptools-80.9.0.tar.gz
2654
cd setuptools-80.9.0
2655
2656
pip3 wheel -w dist --no-cache-dir --no-build-isolation --no-deps $PWD
2657
2658
pip3 install --no-index --find-links dist setuptools
2659
2660
cd /sources
2661
rm -rf setuptools-80.9.0
2662
#+end_src
2663
2664
** Ninja-1.13.1
2665
#+begin_src sh
2666
tar -xf ninja-1.13.1.tar.gz
2667
cd ninja-1.13.1
2668
2669
export NINJAJOBS=$(nproc)
2670
2671
sed -i '/int Guess/a \
2672
  int   j = 0;\
2673
  char* jobs = getenv( "NINJAJOBS" );\
2674
  if ( jobs != NULL ) j = atoi( jobs );\
2675
  if ( j > 0 ) return j;\
2676
' src/ninja.cc
2677
2678
python3 configure.py --bootstrap
2679
2680
./ninja ninja_test
2681
./ninja_test --gtest_filter=-SubprocessTest.SetWithLots
2682
2683
install -vm755 ninja /usr/bin/
2684
install -vDm644 misc/bash-completion /usr/share/bash-completion/completions/ninja
2685
install -vDm644 misc/zsh-completion  /usr/share/zsh/site-functions/_ninja
2686
2687
cd /sources
2688
rm -rf ninja-1.13.1
2689
#+end_src
2690
2691
** Meson-1.8.3
2692
#+begin_src sh
2693
tar -xf meson-1.8.3.tar.gz
2694
cd meson-1.8.3
2695
2696
pip3 wheel -w dist --no-cache-dir --no-build-isolation --no-deps $PWD
2697
2698
pip3 install --no-index --find-links dist meson
2699
install -vDm644 data/shell-completions/bash/meson /usr/share/bash-completion/completions/meson
2700
install -vDm644 data/shell-completions/zsh/_meson /usr/share/zsh/site-functions/_meson
2701
2702
cd /sources
2703
rm -rf meson-1.8.3
2704
#+end_src
2705
2706
** Kmod-34.2
2707
#+begin_src sh
2708
tar -xf kmod-34.2.tar.xz
2709
cd kmod-34.2
2710
2711
./configure --prefix=/usr     \
2712
            --sysconfdir=/etc \
2713
            --with-openssl    \
2714
            --with-xz         \
2715
            --with-zstd       \
2716
            --with-zlib       \
2717
            --disable-manpages
2718
2719
make
2720
make install
2721
2722
for target in depmod insmod modinfo modprobe rmmod; do
2723
  ln -sfv ../bin/kmod /usr/sbin/$target
2724
  rm -fv /usr/bin/$target
2725
done
2726
2727
cd /sources
2728
rm -rf kmod-34.2
2729
#+end_src
2730
2731
** Coreutils-9.7
2732
#+begin_src sh
2733
tar -xf coreutils-9.7.tar.xz
2734
cd coreutils-9.7
2735
2736
patch -Np1 -i ../coreutils-9.7-i18n-2.patch
2737
2738
autoreconf -fiv
2739
FORCE_UNSAFE_CONFIGURE=1 ./configure \
2740
            --prefix=/usr            \
2741
            --enable-no-install-program=kill,uptime
2742
2743
make
2744
make NON_ROOT_USERNAME=tester check-root
2745
2746
groupadd -g 102 dummy -U tester
2747
2748
chown -R tester .
2749
2750
su tester -c "PATH=$PATH make -k RUN_EXPENSIVE_TESTS=yes check"
2751
2752
groupdel dummy
2753
2754
make install
2755
2756
mv -v /usr/bin/chroot /usr/sbin
2757
mv -v /usr/share/man/man1/chroot.1 /usr/share/man/man8/chroot.8
2758
sed -i 's/"1"/"8"/' /usr/share/man/man8/chroot.8
2759
2760
cd /sources
2761
rm -rf coreutils-9.7
2762
#+end_src
2763
2764
** Diffutils-3.12
2765
#+begin_src sh
2766
tar -xf diffutils-3.12.tar.xz
2767
cd diffutils-3.12
2768
2769
./configure --prefix=/usr
2770
2771
make
2772
make check
2773
make install
2774
2775
cd /sources
2776
rm -rf diffutils-3.12
2777
#+end_src
2778
2779
** Gawk-5.3.2
2780
#+begin_src sh
2781
tar -xf gawk-5.3.2.tar.xz
2782
cd gawk-5.3.2
2783
2784
sed -i 's/extras//' Makefile.in
2785
2786
./configure --prefix=/usr
2787
2788
make
2789
chown -R tester .
2790
su tester -c "PATH=$PATH make check"
2791
rm -f /usr/bin/gawk-5.3.2
2792
make install
2793
2794
ln -sv gawk.1 /usr/share/man/man1/awk.1
2795
2796
mkdir -pv                                   /usr/share/doc/gawk-5.3.2
2797
cp    -v doc/{awkforai.txt,*.{eps,pdf,jpg}} /usr/share/doc/gawk-5.3.2
2798
2799
cd /sources
2800
rm -rf gawk-5.3.2
2801
#+end_src
2802
2803
** Findutils-4.10.0
2804
#+begin_src sh
2805
tar -xf findutils-4.10.0.tar.xz
2806
cd findutils-4.10.0
2807
2808
./configure --prefix=/usr --localstatedir=/var/lib/locate
2809
2810
make
2811
chown -R tester .
2812
su tester -c "PATH=$PATH make check"
2813
2814
make install
2815
2816
cd /sources
2817
rm -rf findutils-4.10.0
2818
#+end_src
2819
2820
** Groff-1.23.0
2821
#+begin_src sh
2822
tar -xf groff-1.23.0.tar.gz
2823
cd groff-1.23.0
2824
2825
PAGE=letter ./configure --prefix=/usr
2826
2827
make
2828
make check
2829
make install
2830
2831
cd /sources
2832
rm -rf groff-1.23.0
2833
#+end_src
2834
2835
** GRUB-2.12
2836
#+begin_src sh
2837
tar -xf grub-2.12.tar.xz
2838
cd grub-2.12
2839
2840
unset {C,CPP,CXX,LD}FLAGS
2841
2842
echo depends bli part_gpt > grub-core/extra_deps.lst
2843
2844
./configure --prefix=/usr          \
2845
            --sysconfdir=/etc      \
2846
            --disable-efiemu       \
2847
            --disable-werror
2848
2849
make
2850
make install
2851
mv -v /etc/bash_completion.d/grub /usr/share/bash-completion/completions
2852
2853
cd /sources
2854
rm -rf grub-2.12
2855
#+end_src
2856
2857
** Gzip-1.14
2858
#+begin_src sh
2859
tar -xf gzip-1.14.tar.xz
2860
cd gzip-1.14
2861
2862
./configure --prefix=/usr
2863
2864
make
2865
make check
2866
make install
2867
2868
cd /sources
2869
rm -rf gzip-1.14
2870
#+end_src
2871
2872
** IPRoute2-6.16.0
2873
#+begin_src sh
2874
tar -xf iproute2-6.16.0.tar.xz
2875
cd iproute2-6.16.0
2876
2877
sed -i /ARPD/d Makefile
2878
rm -fv man/man8/arpd.8
2879
2880
make NETNS_RUN_DIR=/run/netns
2881
make SBINDIR=/usr/sbin install
2882
2883
mkdir -pv             /usr/share/doc/iproute2-6.16.0
2884
cp -v COPYING README* /usr/share/doc/iproute2-6.16.0
2885
2886
cd /sources
2887
rm -rf iproute2-6.16.0
2888
#+end_src
2889
2890
** Kbd-2.8.0
2891
#+begin_src sh
2892
tar -xf kbd-2.8.0.tar.xz
2893
cd kbd-2.8.0
2894
2895
patch -Np1 -i ../kbd-2.8.0-backspace-1.patch
2896
2897
sed -i '/RESIZECONS_PROGS=/s/yes/no/' configure
2898
sed -i 's/resizecons.8 //' docs/man/man8/Makefile.in
2899
2900
./configure --prefix=/usr --disable-vlock
2901
2902
make
2903
make check
2904
make install
2905
2906
cp -R -v docs/doc -T /usr/share/doc/kbd-2.8.0
2907
2908
cd /sources
2909
rm -rf kbd-2.8.0
2910
#+end_src
2911
2912
** Libpipeline-1.5.8
2913
#+begin_src sh
2914
tar -xf libpipeline-1.5.8.tar.gz
2915
cd libpipeline-1.5.8
2916
2917
./configure --prefix=/usr
2918
2919
make
2920
make check
2921
make install
2922
2923
cd /sources
2924
rm -rf libpipeline-1.5.8
2925
#+end_src
2926
2927
** Make-4.4.1
2928
#+begin_src sh
2929
tar -xf make-4.4.1.tar.gz
2930
cd make-4.4.1
2931
2932
./configure --prefix=/usr
2933
2934
make
2935
chown -R tester .
2936
su tester -c "PATH=$PATH make check"
2937
2938
make install
2939
2940
cd /sources
2941
rm -rf make-4.4.1
2942
#+end_src
2943
2944
** Patch-2.8
2945
#+begin_src sh
2946
tar -xf patch-2.8.tar.xz
2947
cd patch-2.8
2948
2949
./configure --prefix=/usr
2950
2951
make
2952
make check
2953
make install
2954
2955
cd /sources
2956
rm -rf patch-2.8
2957
#+end_src
2958
2959
** Tar-1.35
2960
Known failure test suite 233 (read comment)
2961
#+begin_src sh
2962
tar -xf tar-1.35.tar.xz
2963
cd tar-1.35
2964
2965
FORCE_UNSAFE_CONFIGURE=1  \
2966
./configure --prefix=/usr
2967
2968
make
2969
make check
2970
make install
2971
make -C doc install-html docdir=/usr/share/doc/tar-1.35
2972
2973
cd /sources
2974
rm -rf tar-1.35
2975
#+end_src
2976
2977
** Texinfo-7.2
2978
#+begin_src sh
2979
tar -xf texinfo-7.2.tar.xz
2980
cd texinfo-7.2
2981
2982
./configure --prefix=/usr
2983
2984
make
2985
make check
2986
make install
2987
2988
make TEXMF=/usr/share/texmf install-tex
2989
2990
cd /sources
2991
rm -rf texinfo-7.2
2992
#+end_src
2993
2994
** Vim-9.1.1629
2995
Use my own vimrc, ignore vi symlink
2996
#+begin_src sh
2997
tar -xf vim-9.1.1629.tar.gz
2998
cd vim-9.1.1629
2999
3000
echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h
3001
3002
./configure --prefix=/usr
3003
3004
make
3005
chown -R tester .
3006
su tester -c "TERM=xterm-256color LANG=en_US.UTF-8 make -j1 test" \
3007
   &> vim-test.log
3008
3009
make install
3010
3011
ln -sv vim /usr/bin/vi
3012
for L in  /usr/share/man/{,*/}man1/vim.1; do
3013
    ln -sv vim.1 $(dirname $L)/vi.1
3014
done
3015
3016
ln -sv ../vim/vim91/doc /usr/share/doc/vim-9.1.1629
3017
3018
cat > /etc/vimrc << "EOF"
3019
" Begin /etc/vimrc
3020
3021
filetype plugin indent on
3022
set expandtab
3023
set shiftwidth=4
3024
set softtabstop=4
3025
set tabstop=4
3026
set number
3027
set relativenumber
3028
set smartindent
3029
set showmatch
3030
set backspace=indent,eol,start
3031
syntax on
3032
3033
if (&term == "xterm") || (&term == "putty")
3034
  set background=dark
3035
endif
3036
3037
" End /etc/vimrc
3038
EOF
3039
3040
cd /sources
3041
rm -rf vim-9.1.1629
3042
#+end_src
3043
3044
** MarkupSafe-3.0.2
3045
#+begin_src sh
3046
tar -xf MarkupSafe-3.0.2.tar.gz
3047
cd MarkupSafe-3.0.2
3048
3049
pip3 wheel -w dist --no-cache-dir --no-build-isolation --no-deps $PWD
3050
3051
pip3 install --no-index --no-user --find-links dist Markupsafe
3052
3053
cd /sources
3054
rm -rf MarkupSafe-3.0.2
3055
#+end_src
3056
3057
** Jinja2-3.1.6
3058
#+begin_src sh
3059
tar -xf jinja2-3.1.6.tar.gz
3060
cd jinja2-3.1.6
3061
3062
pip3 wheel -w dist --no-cache-dir --no-build-isolation --no-deps $PWD
3063
3064
pip3 install --no-index --no-user --find-links dist Jinja2
3065
3066
cd /sources
3067
rm -rf jinja2-3.1.6
3068
#+end_src
3069
3070
** Udev from Systemd-257.8
3071
#+begin_src sh
3072
tar -xf systemd-257.8.tar.gz
3073
cd systemd-257.8
3074
3075
sed -i -e 's/GROUP="render"/GROUP="video"/' \
3076
       -e 's/GROUP="sgx", //' rules.d/50-udev-default.rules.in
3077
3078
sed '/systemd-sysctl/s/^/#/' -i rules.d/99-systemd.rules.in
3079
3080
sed '/NETWORK_DIRS/s/systemd/udev/' -i src/basic/path-lookup.h
3081
3082
mkdir -p build
3083
cd       build
3084
3085
meson setup ..                \
3086
      --prefix=/usr           \
3087
      --buildtype=release     \
3088
      -D mode=release         \
3089
      -D dev-kvm-mode=0660    \
3090
      -D link-udev-shared=false \
3091
      -D logind=false         \
3092
      -D vconsole=false
3093
3094
export udev_helpers=$(grep "'name' :" ../src/udev/meson.build | \
3095
                      awk '{print $2}' | tr -d ",'" | grep -v 'udevadm')
3096
3097
ninja udevadm systemd-hwdb \
3098
      $(ninja -n | grep -Eo '(src/(lib)?udev|rules.d|hwdb.d)/[^ ]*') \
3099
      $(realpath libudev.so --relative-to .) \
3100
      $udev_helpers
3101
3102
install -vm755 -d {/usr/lib,/etc}/udev/{hwdb.d,rules.d,network}
3103
install -vm755 -d /usr/{lib,share}/pkgconfig
3104
install -vm755 udevadm                            /usr/bin/
3105
install -vm755 systemd-hwdb                       /usr/bin/udev-hwdb
3106
ln      -svfn  ../bin/udevadm                     /usr/sbin/udevd
3107
cp      -av    libudev.so{,*[0-9]}                /usr/lib/
3108
install -vm644 ../src/libudev/libudev.h           /usr/include/
3109
install -vm644 src/libudev/*.pc                   /usr/lib/pkgconfig/
3110
install -vm644 src/udev/*.pc                      /usr/share/pkgconfig/
3111
install -vm644 ../src/udev/udev.conf              /etc/udev/
3112
install -vm644 rules.d/* ../rules.d/README        /usr/lib/udev/rules.d/
3113
install -vm644 $(find ../rules.d/*.rules \
3114
                      -not -name '*power-switch*') /usr/lib/udev/rules.d/
3115
install -vm644 hwdb.d/*  ../hwdb.d/{*.hwdb,README} /usr/lib/udev/hwdb.d/
3116
install -vm755 $udev_helpers                      /usr/lib/udev
3117
install -vm644 ../network/99-default.link         /usr/lib/udev/network
3118
3119
tar -xvf ../../udev-lfs-20230818.tar.xz
3120
make -f udev-lfs-20230818/Makefile.lfs install
3121
3122
tar -xf ../../systemd-man-pages-257.8.tar.xz                            \
3123
    --no-same-owner --strip-components=1                              \
3124
    -C /usr/share/man --wildcards '*/udev*' '*/libudev*'             \
3125
                                  '*/systemd.link.5'                 \
3126
                                  '*/systemd-'{hwdb,udevd.service}.8
3127
3128
sed 's|systemd/network|udev/network|'                                 \
3129
    /usr/share/man/man5/systemd.link.5                                \
3130
  > /usr/share/man/man5/udev.link.5
3131
3132
sed 's/systemd\(\\\?-\)/udev\1/' /usr/share/man/man8/systemd-hwdb.8   \
3133
                                 > /usr/share/man/man8/udev-hwdb.8
3134
3135
sed 's|lib.*udevd|sbin/udevd|'                                        \
3136
    /usr/share/man/man8/systemd-udevd.service.8                       \
3137
  > /usr/share/man/man8/udevd.8
3138
3139
rm /usr/share/man/man*/systemd*
3140
3141
unset udev_helpers
3142
3143
udev-hwdb update
3144
3145
cd /sources
3146
rm -rf systemd-257.8
3147
#+end_src
3148
3149
** Man-DB-2.13.1
3150
#+begin_src sh
3151
tar -xf man-db-2.13.1.tar.xz
3152
cd man-db-2.13.1
3153
3154
./configure --prefix=/usr                         \
3155
            --docdir=/usr/share/doc/man-db-2.13.1 \
3156
            --sysconfdir=/etc                     \
3157
            --disable-setuid                      \
3158
            --enable-cache-owner=bin              \
3159
            --with-browser=/usr/bin/lynx          \
3160
            --with-vgrind=/usr/bin/vgrind         \
3161
            --with-grap=/usr/bin/grap             \
3162
            --with-systemdtmpfilesdir=            \
3163
            --with-systemdsystemunitdir=
3164
3165
make
3166
make check
3167
make install
3168
3169
cd /sources
3170
rm -rf man-db-2.13.1
3171
#+end_src
3172
3173
** Procps-ng-4.0.5
3174
#+begin_src sh
3175
tar -xf procps-ng-4.0.5.tar.xz
3176
cd procps-ng-4.0.5
3177
3178
./configure --prefix=/usr                           \
3179
            --docdir=/usr/share/doc/procps-ng-4.0.5 \
3180
            --disable-static                        \
3181
            --disable-kill                          \
3182
            --with-systemd
3183
3184
make src_w_LDADD='$(LDADD) -lsystemd'
3185
make check
3186
make install
3187
3188
cd /sources
3189
rm -rf procps-ng-4.0.5
3190
#+end_src
3191
3192
** Util-linux-2.41.1
3193
Kill error is known
3194
#+begin_src sh
3195
tar -xf util-linux-2.41.1.tar.xz
3196
cd util-linux-2.41.1
3197
3198
./configure --bindir=/usr/bin              \
3199
            --libdir=/usr/lib              \
3200
            --runstatedir=/run             \
3201
            --sbindir=/usr/sbin            \
3202
            --disable-chfn-chsh            \
3203
            --disable-login                \
3204
            --disable-nologin              \
3205
            --disable-su                   \
3206
            --disable-setpriv              \
3207
            --disable-runuser              \
3208
            --disable-pylibmount           \
3209
            --disable-static               \
3210
            --disable-liblastlog2          \
3211
            --without-python               \
3212
            ADJTIME_PATH=/var/lib/hwclock/adjtime \
3213
            --docdir=/usr/share/doc/util-linux-2.41.1
3214
3215
make
3216
# Skip tests in chroot
3217
# chown -R tester .
3218
# su tester -c "make -k check"
3219
3220
make install
3221
3222
cd /sources
3223
rm -rf util-linux-2.41.1
3224
#+end_src
3225
3226
** E2fsprogs-1.47.3
3227
Known m_asdfasfd test fail
3228
#+begin_src sh
3229
tar -xf e2fsprogs-1.47.3.tar.gz
3230
cd e2fsprogs-1.47.3
3231
3232
mkdir -v build
3233
cd       build
3234
3235
../configure --prefix=/usr           \
3236
             --sysconfdir=/etc       \
3237
             --enable-elf-shlibs     \
3238
             --disable-libblkid      \
3239
             --disable-libuuid       \
3240
             --disable-uuidd         \
3241
             --disable-fsck
3242
3243
make
3244
make check
3245
make install
3246
3247
rm -fv /usr/lib/{libcom_err,libe2p,libext2fs,libss}.a
3248
3249
gunzip -v /usr/share/info/libext2fs.info.gz
3250
install-info --dir-file=/usr/share/info/dir /usr/share/info/libext2fs.info
3251
3252
makeinfo -o      doc/com_err.info ../lib/et/com_err.texinfo
3253
install -v -m644 doc/com_err.info /usr/share/info
3254
install-info --dir-file=/usr/share/info/dir /usr/share/info/com_err.info
3255
3256
sed 's/metadata_csum_seed,//' -i /etc/mke2fs.conf
3257
3258
cd /sources
3259
rm -rf e2fsprogs-1.47.3
3260
#+end_src
3261
3262
** Sysklogd-2.7.2
3263
#+begin_src sh
3264
tar -xf sysklogd-2.7.2.tar.gz
3265
cd sysklogd-2.7.2
3266
3267
./configure --prefix=/usr      \
3268
            --sysconfdir=/etc  \
3269
            --runstatedir=/run \
3270
            --without-logger
3271
3272
make
3273
make install
3274
3275
cat > /etc/syslog.conf << "EOF"
3276
# Begin /etc/syslog.conf
3277
3278
auth,authpriv.* -/var/log/auth.log
3279
*.*;auth,authpriv.none -/var/log/sys.log
3280
daemon.* -/var/log/daemon.log
3281
kern.* -/var/log/kern.log
3282
mail.* -/var/log/mail.log
3283
user.* -/var/log/user.log
3284
*.emerg *
3285
3286
# End /etc/syslog.conf
3287
EOF
3288
3289
cd /sources
3290
rm -rf sysklogd-2.7.2
3291
#+end_src
3292
3293
** SysVinit-3.14
3294
#+begin_src sh
3295
tar -xf sysvinit-3.14.tar.xz
3296
cd sysvinit-3.14
3297
3298
patch -Np1 -i ../sysvinit-3.14-consolidated-1.patch
3299
3300
make
3301
make install
3302
3303
cd /sources
3304
rm -rf sysvinit-3.14
3305
#+end_src
3306
3307
** Stripping Debug Symbols
3308
3309
Now we clean up debug symbols to save space:
3310
3311
#+begin_src sh
3312
save_usrlib="$(cd /usr/lib; ls ld-linux*[^g])
3313
             libc.so.6
3314
             libthread_db.so.1
3315
             libquadmath.so.0.0.0
3316
             libstdc++.so.6.0.33
3317
             libitm.so.1.0.0
3318
             libatomic.so.1.2.0"
3319
3320
cd /usr/lib
3321
3322
for LIB in $save_usrlib; do
3323
    objcopy --only-keep-debug --compress-debug-sections=zlib $LIB $LIB.dbg
3324
    cp $LIB /tmp/$LIB
3325
    strip --strip-unneeded /tmp/$LIB
3326
    objcopy --add-gnu-debuglink=$LIB.dbg /tmp/$LIB
3327
    install -vm755 /tmp/$LIB /usr/lib
3328
    rm /tmp/$LIB
3329
done
3330
3331
online_usrbin="bash find strip"
3332
online_usrlib="libbfd-2.45.so
3333
               libsframe.so.1.0.0
3334
               libhistory.so.8.3
3335
               libncursesw.so.6.5
3336
               libm.so.6
3337
               libreadline.so.8.3
3338
               libz.so.1.3.1
3339
               libzstd.so.1.5.7
3340
               $(cd /usr/lib; find libnss*.so* -type f)"
3341
3342
for BIN in $online_usrbin; do
3343
    cp /usr/bin/$BIN /tmp/$BIN
3344
    strip --strip-unneeded /tmp/$BIN
3345
    install -vm755 /tmp/$BIN /usr/bin
3346
    rm /tmp/$BIN
3347
done
3348
3349
for LIB in $online_usrlib; do
3350
    cp /usr/lib/$LIB /tmp/$LIB
3351
    strip --strip-unneeded /tmp/$LIB
3352
    install -vm755 /tmp/$LIB /usr/lib
3353
    rm /tmp/$LIB
3354
done
3355
3356
for i in $(find /usr/lib -type f -name \*.so* ! -name \*dbg) \
3357
         $(find /usr/lib -type f -name \*.a)                 \
3358
         $(find /usr/{bin,sbin,libexec} -type f); do
3359
    case "$online_usrbin $online_usrlib $save_usrlib" in
3360
        *$(basename $i)* )
3361
            ;;
3362
        * ) strip --strip-unneeded $i 2>/dev/null
3363
            ;;
3364
    esac
3365
done
3366
3367
unset BIN LIB save_usrlib online_usrbin online_usrlib
3368
#+end_src
3369
3370
** Cleaning Up
3371
3372
#+begin_src sh
3373
rm -rf /tmp/{*,.*}
3374
find /usr/lib /usr/libexec -name \*.la -delete
3375
find /usr -depth -name $(uname -m)-lfs-linux-gnu\* | xargs rm -rf
3376
userdel -r tester
3377
#+end_src
3378
3379
** GRUB BLFS LINK
3380
mkdir BLFS
3381
cd BLFS
3382
screen -> control A D
3383
cd /mnt/lfs/sources/BLFS
3384
(middle click freetype, middle click efitbootmgr, copy links..)
3385
wget https://downloads.sourceforge.net/freetype/freetype-2.13.3.tar.xz
3386
wget https://downloads.sourceforge.net/freetype/freetype-doc-2.13.3.tar.xz
3387
md5sum * (eyeball check on this to match the md5sums)
3388
screen -r lfs
3389
extract freetype-2
3390
cd freetype-2
3391
follow instructions from here..
3392
https://www.linuxfromscratch.org/blfs/view/12.4/general/freetype2.html
3393
tar -xf ../freetype-doc-2.13.3.tar.xz --strip-components=2 -C docs
3394
...
3395
3396
we need to get dependencies for efibootmgr...
3397
3398
efivar-39 and popt-1.19
3399
skip api documentaiton for popt as it is optional
3400
get grub the same way, just the additional dependency
3401
then in BLFS, do
3402
#+begin_src
3403
tar -xvf ../grub-2.
3404
#+end_src
3405
https://youtu.be/ReIeiTqYTGc?list=PLyc5xVO2uDsDzdT8lkx430hZ-gY69wgS3&t=15288
3406
3407
* Chapter 9 - System Configuration:
3408
** Managing Devies:
3409
Udev script wont work on qemu..
3410
We dont need to run it though because all it does is rename enp1s0 to eth0
3411
We can skip the rest of all this actually since we are not worried about changing our network interface.
3412
** Network Interface:
3413
#+begin_src
3414
cd /etc/sysconfig/
3415
vim ifconfig.enp1s0
3416
ONBOOT=yes
3417
IFACE=enp1s0
3418
SERVICE=ipv4-static
3419
IP=192.168.122.101
3420
GATEWAY=192.168.122.1
3421
PREFIX=24
3422
BROADCAST=192.168.122.255
3423
#+end_src
3424
3425
You can get all this information from running ip a on another machine, or your host machine
3426
3427
#+begin_src
3428
vim /etc/resolv.conf
3429
# Begin /etc/resolv.conf
3430
3431
nameserver 8.8.8.8
3432
nameserver 1.1.1.1
3433
3434
# End /etc/resolv.conf
3435
#+end_src
3436
3437
I use lfs, btw..
3438
#+begin_src
3439
echo 'lfs-btw' >> /etc/hostname
3440
#+end_src
3441
3442
3443
/etc/hosts..
3444
#+begin_src
3445
cat > /etc/hosts << "EOF"
3446
# Begin /etc/hosts
3447
3448
127.0.0.1 localhost
3449
127.0.1.1 lfs-btw
3450
::1       localhost
3451
3452
# End /etc/hosts
3453
EOF
3454
#+end_src
3455
3456
** sysvinit
3457
3458
Create inittab file for sysvinit
3459
3460
#+begin_src
3461
cat > /etc/inittab << "EOF"
3462
# Begin /etc/inittab
3463
3464
id:3:initdefault:
3465
3466
si::sysinit:/etc/rc.d/init.d/rc S
3467
3468
l0:0:wait:/etc/rc.d/init.d/rc 0
3469
l1:S1:wait:/etc/rc.d/init.d/rc 1
3470
l2:2:wait:/etc/rc.d/init.d/rc 2
3471
l3:3:wait:/etc/rc.d/init.d/rc 3
3472
l4:4:wait:/etc/rc.d/init.d/rc 4
3473
l5:5:wait:/etc/rc.d/init.d/rc 5
3474
l6:6:wait:/etc/rc.d/init.d/rc 6
3475
3476
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
3477
3478
su:S06:once:/sbin/sulogin
3479
s1:1:respawn:/sbin/sulogin
3480
3481
1:2345:respawn:/sbin/agetty --noclear tty1 9600
3482
2:2345:respawn:/sbin/agetty tty2 9600
3483
3:2345:respawn:/sbin/agetty tty3 9600
3484
4:2345:respawn:/sbin/agetty tty4 9600
3485
5:2345:respawn:/sbin/agetty tty5 9600
3486
6:2345:respawn:/sbin/agetty tty6 9600
3487
3488
# End /etc/inittab
3489
EOF
3490
#+end_src
3491
3492
Hardware clock: Linux only, leave it as 1
3493
#+begin_src
3494
cat > /etc/sysconfig/clock << "EOF"
3495
# Begin /etc/sysconfig/clock
3496
3497
UTC=1
3498
3499
# Set this to any options you might need to give to hwclock,
3500
# such as machine hardware clock type for Alphas.
3501
CLOCKPARAMS=
3502
3503
# End /etc/sysconfig/clock
3504
EOF
3505
#+end_src
3506
3507
We can run this since we're on en-us_UTF-8
3508
#+begin_src
3509
cat > /etc/sysconfig/console << "EOF"
3510
# Begin /etc/sysconfig/console
3511
3512
UNICODE="1"
3513
FONT="Lat2-Terminus16"
3514
3515
# End /etc/sysconfig/console
3516
EOF
3517
#+end_src
3518
3519
If you are on a different keymap, such as gb, or romania or something, check out these instructions here on how to change that.
3520
3521
The rest is optional, let's move on to generating the locales
3522
** Locale Configuration
3523
For my situation, im on en_US.UTF-8, and you can check yours with `locale -a`
3524
3525
so i'll do:
3526
#+begin_src
3527
cat > /etc/profile << "EOF"
3528
# Begin /etc/profile
3529
3530
for i in $(locale); do
3531
  unset ${i%=*}
3532
done
3533
3534
if [[ "$TERM" = linux ]]; then
3535
  export LANG=C.UTF-8
3536
else
3537
  export LANG=en_US.UTF-8
3538
fi
3539
3540
# End /etc/profile
3541
EOF
3542
#+end_src
3543
3544
If you are on a different locale, you will need to run this command to figure out what to add to the suffix of en_<>
3545
3546
LC_ALL=en_GB locale charmap
3547
* Chapter 10 - Make System Bootable:
3548
** Fstab
3549
3550
I can make my fstab just like this, you just need to ensure your /dev/vda matches your actual partition names.
3551
3552
#+begin_src
3553
cat > /etc/fstab << "EOF"
3554
# Begin /etc/fstab
3555
3556
# file system  mount-point    type     options             dump  fsck
3557
#                                                                order
3558
3559
/dev/vda3      /              ext4     defaults            1     1
3560
/dev/vda1      /boot/efi      vfat     defaults            0     2
3561
/dev/vda2      swap           swap     pri=1               0     0
3562
proc           /proc          proc     nosuid,noexec,nodev 0     0
3563
sysfs          /sys           sysfs    nosuid,noexec,nodev 0     0
3564
devpts         /dev/pts       devpts   gid=5,mode=620      0     0
3565
tmpfs          /run           tmpfs    defaults            0     0
3566
devtmpfs       /dev           devtmpfs mode=0755,nosuid    0     0
3567
tmpfs          /dev/shm       tmpfs    nosuid,nodev        0     0
3568
cgroup2        /sys/fs/cgroup cgroup2  nosuid,noexec,nodev 0     0
3569
3570
# End /etc/fstab
3571
EOF
3572
#+end_src
3573
3574
** Kernel
3575
3576
Hard part... but final boss if you will
3577
3578
cd /sources
3579
tar -xvf linux-16
3580
cd linux-
3581
3582
3583
make mrproper
3584
make defconfig
3585
3586
This creates a config based on my current system architecture. It doesnt make sense for me to customize the kernel here since your hardware will not be the same as mine, so I'll just show you the defaults and how to get it up and running.
3587
3588
Lets add some defaults to get it working
3589
3590
make menuconfig
3591
3592
Actually everything here is good, but just verify some stuff
3593
For my situation, I'm going to just take a look at every default setting the guide offers, and provide those, as well as enable a few virtio drivers for my qemu setup. Also its important here to follow the blfs guide on EFI since we installed grub using efi.
3594
3595
#+begin_src
3596
Bare Minimum to Enable for QEMU/KVM VM:
3597
1. Virtio Drivers (CRITICAL - without these you won't see your disk!)
3598
Navigate to: Device Drivers → Block devices
3599
3600
Enable: [*] Virtio block driver
3601
3602
Navigate to: Device Drivers → Network device support
3603
3604
Enable: [*] Virtio network driver
3605
3606
Navigate to: Device Drivers → SCSI device support
3607
3608
Enable: [*] virtio-scsi support
3609
3610
Or search in menuconfig (press / then type VIRTIO):
3611
3612
CONFIG_VIRTIO_BLK=y
3613
CONFIG_VIRTIO_NET=y
3614
CONFIG_VIRTIO_PCI=y
3615
CONFIG_SCSI_VIRTIO=y
3616
3617
2. EXT4 Filesystem
3618
Navigate to: File systems
3619
3620
Enable: [*] The Extended 4 (ext4) filesystem
3621
Already enabled in defconfig, but verify
3622
3623
3. EFI Boot Support
3624
Navigate to: Processor type and features
3625
3626
Enable: [*] EFI runtime service support
3627
Enable: [*] EFI stub support
3628
3629
That's it
3630
Save and exit (Save → Exit), then:
3631
#+end_src
3632
3633
time to build the kernel:
3634
3635
#+begin_src
3636
make
3637
make modules_install
3638
#+end_src
3639
3640
Copy these boot files...
3641
Change ownership of this for BLFS
3642
#+begin_src
3643
chown -R 0:0 ../linux-6.16.1
3644
#+end_src
3645
3646
Skip the modprobe, we didnt do anything with usb ports so we are good.
3647
We're ready to install grub.
3648
3649
** GRUB
3650
Skip all of this, just go straight to BLFS page because we are on UEFI, not bios.
3651
I've installed grub over 100 times on efi, we can just do the following:
3652
3653
mount the efi vars:
3654
3655
#+begin_src
3656
# mount efivarfs
3657
mountpoint /sys/firmware/efi/efivars || mount -v -t efivarfs efivarfs /sys/firmware/efi/efivars
3658
3659
# Add efivarfs to fstab
3660
cat >> /etc/fstab << "EOF"
3661
efivarfs /sys/firmware/efi/efivars efivarfs defaults 0 0
3662
EOF
3663
3664
# Install GRUB
3665
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=LFS --recheck
3666
3667
# Generate config
3668
We need to generate a minimal grub config here, we can do so by just pasting this in here:
3669
cat > /boot/grub/grub.cfg << EOF
3670
# Begin /boot/grub/grub.cfg
3671
set default=0
3672
set timeout=5
3673
3674
insmod part_gpt
3675
insmod ext2
3676
set root=(hd0,3)
3677
3678
insmod efi_gop
3679
insmod efi_uga
3680
if loadfont /boot/grub/fonts/unicode.pf2; then
3681
  terminal_output gfxterm
3682
fi
3683
3684
menuentry "GNU/Linux, Linux 6.16.1-lfs-12.4" {
3685
  linux   /boot/vmlinuz-6.16.1-lfs-12.4 root=/dev/vda3 ro
3686
}
3687
3688
menuentry "Firmware Setup" {
3689
  fwsetup
3690
}
3691
EOF
3692
#+end_src
3693
3694
Note i've changed sda to vda here, and 2 to 3, because that is where my root file system is.
3695
I cant believe I'm about to say this but its finally time to reboot into our LFS system..
3696
3697
* Reboot and Pray:
3698
3699
#+begin_src
3700
# Exit chroot
3701
logout
3702
3703
# Unmount everything (from live CD)
3704
umount -v /mnt/lfs/dev/pts
3705
umount -v /mnt/lfs/dev
3706
umount -v /mnt/lfs/run
3707
umount -v /mnt/lfs/proc
3708
umount -v /mnt/lfs/sys
3709
umount -v /mnt/lfs/boot/efi
3710
umount -v /mnt/lfs
3711
3712
# Reboot
3713
reboot
3714
#+end_src
3715
3716
* Final Thoughts:
3717
3718
Alright, that's it. We just built an entire Linux system from scratch. This is probably
3719
the most educational project you can do in Linux.
3720
3721
We compiled over 80 packages, built a custom kernel, configured a bootloader, and created
3722
a fully functional system. You now understand how Linux works at a fundamental level - how
3723
packages depend on each other, how the toolchain works, how the boot process functions.
3724
3725
This is just the base LFS system. From here, you can continue with BLFS (Beyond Linux From
3726
Scratch) to add X11, desktop environments, browsers, and all the software you actually use
3727
day to day.
3728
3729
If you provide proof that you installed LFS using this guide, I will give you a special role in my discord server.
3730
3731
Thanks so much for checking out this tutorial. If you got value from it, and you want to find more tutorials like this, check out
3732
my youtube channel here: [[https://youtube.com/@tony-btw][YouTube]], or my website here: [[https://www.tonybtw.com][tony,btw]]
3733
3734
You can support me here: [[https://ko-fi.com/tonybtw][kofi]]