-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
2901 lines (2668 loc) · 93.7 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# syntax=docker/dockerfile:1.4
# BuildKit is required to build this Dockerfile
# Based on LFS 11.1-systemd: https://www.linuxfromscratch.org/lfs/view/11.1-systemd/
# For the aarch64 version, the following adaptation is also referenced:
# https://linuxfromscratch.org/~kb0iic/lfs-systemd/index.html
###############################
# II. Preparing for the Build #
###############################
# All multi-line scripts are run using this command
ARG SH="sh -eu"
# Architecture codes
# For x86_64
ARG LFS_ARCH=x86_64
ARG DOCKER_ARCH=amd64
ARG BUSYBOX_ARCH=x86_64
# For aarch64
# ARG LFS_ARCH=aarch64
# ARG DOCKER_ARCH=arm64v8
# ARG BUSYBOX_ARCH=armv8l
ARG LFS=/lfs
ARG LFS_TGT=${LFS_ARCH}-lfs-linux-gnu
ARG LFS_USER=lfs
ARG LFS_GROUOP=lfs
ARG LFS_HOSTNAME=lfs
# Build options
ARG ENABLE_TESTS=false
ARG MAKEFLAGS=-j8
# Download source files from ${SOURCES_MIRROR}<file_name>
# If the original download URLs in the LFS manual are desired, comment the following line
ARG SOURCES_MIRROR=https://github.com/rod-lin/lfs-docker/raw/files/sources/
# Final bootable ISO image options
ARG ISO_IMAGE_NAME=lfs-${LFS_ARCH}.iso
ARG ISO_VOLUME_ID=LFS
ARG ISO_GRUB_PRELOAD_MODULES="part_gpt part_msdos linux normal iso9660 udf all_video video_fb search configfile echo cat"
# Source files
FROM scratch AS sources
ARG BUSYBOX_ARCH
# NOTE: If you have already downloaded all required source files, you can
# put all of them into a local directory, say, sources/, then uncomment the
# following lines to replace other ADD commands in this stage:
# COPY --chmod=744 sources/acl-2.3.1.tar.xz .
# COPY --chmod=744 sources/attr-2.5.1.tar.gz .
# COPY --chmod=744 sources/autoconf-2.71.tar.xz .
# COPY --chmod=744 sources/automake-1.16.5.tar.xz .
# COPY --chmod=744 sources/bash-5.1.16.tar.gz .
# COPY --chmod=744 sources/bc-5.2.2.tar.xz .
# COPY --chmod=744 sources/binutils-2.38.tar.xz .
# COPY --chmod=744 sources/bison-3.8.2.tar.xz .
# COPY --chmod=744 sources/bzip2-1.0.8.tar.gz .
# COPY --chmod=744 sources/check-0.15.2.tar.gz .
# COPY --chmod=744 sources/coreutils-9.0.tar.xz .
# COPY --chmod=744 sources/dbus-1.12.20.tar.gz .
# COPY --chmod=744 sources/dejagnu-1.6.3.tar.gz .
# COPY --chmod=744 sources/diffutils-3.8.tar.xz .
# COPY --chmod=744 sources/e2fsprogs-1.46.5.tar.gz .
# COPY --chmod=744 sources/elfutils-0.186.tar.bz2 .
# COPY --chmod=744 sources/eudev-3.2.11.tar.gz .
# COPY --chmod=744 sources/expat-2.4.6.tar.xz .
# COPY --chmod=744 sources/expect5.45.4.tar.gz .
# COPY --chmod=744 sources/file-5.41.tar.gz .
# COPY --chmod=744 sources/findutils-4.9.0.tar.xz .
# COPY --chmod=744 sources/flex-2.6.4.tar.gz .
# COPY --chmod=744 sources/gawk-5.1.1.tar.xz .
# COPY --chmod=744 sources/gcc-11.2.0.tar.xz .
# COPY --chmod=744 sources/gdbm-1.23.tar.gz .
# COPY --chmod=744 sources/gettext-0.21.tar.xz .
# COPY --chmod=744 sources/glibc-2.35.tar.xz .
# COPY --chmod=744 sources/gmp-6.2.1.tar.xz .
# COPY --chmod=744 sources/gperf-3.1.tar.gz .
# COPY --chmod=744 sources/grep-3.7.tar.xz .
# COPY --chmod=744 sources/groff-1.22.4.tar.gz .
# COPY --chmod=744 sources/grub-2.06.tar.xz .
# COPY --chmod=744 sources/gzip-1.11.tar.xz .
# COPY --chmod=744 sources/iana-etc-20220207.tar.gz .
# COPY --chmod=744 sources/inetutils-2.2.tar.xz .
# COPY --chmod=744 sources/intltool-0.51.0.tar.gz .
# COPY --chmod=744 sources/iproute2-5.16.0.tar.xz .
# COPY --chmod=744 sources/Jinja2-3.0.3.tar.gz .
# COPY --chmod=744 sources/kbd-2.4.0.tar.xz .
# COPY --chmod=744 sources/kmod-29.tar.xz .
# COPY --chmod=744 sources/less-590.tar.gz .
# COPY --chmod=744 sources/lfs-bootscripts-20210608.tar.xz .
# COPY --chmod=744 sources/libcap-2.63.tar.xz .
# COPY --chmod=744 sources/libffi-3.4.2.tar.gz .
# COPY --chmod=744 sources/libpipeline-1.5.5.tar.gz .
# COPY --chmod=744 sources/libtool-2.4.6.tar.xz .
# COPY --chmod=744 sources/linux-5.16.9.tar.xz .
# COPY --chmod=744 sources/m4-1.4.19.tar.xz .
# COPY --chmod=744 sources/make-4.3.tar.gz .
# COPY --chmod=744 sources/man-db-2.10.1.tar.xz .
# COPY --chmod=744 sources/man-pages-5.13.tar.xz .
# COPY --chmod=744 sources/MarkupSafe-2.0.1.tar.gz .
# COPY --chmod=744 sources/meson-0.61.1.tar.gz .
# COPY --chmod=744 sources/mpc-1.2.1.tar.gz .
# COPY --chmod=744 sources/mpfr-4.1.0.tar.xz .
# COPY --chmod=744 sources/ncurses-6.3.tar.gz .
# COPY --chmod=744 sources/ninja-1.10.2.tar.gz .
# COPY --chmod=744 sources/openssl-3.0.1.tar.gz .
# COPY --chmod=744 sources/patch-2.7.6.tar.xz .
# COPY --chmod=744 sources/perl-5.34.0.tar.xz .
# COPY --chmod=744 sources/pkg-config-0.29.2.tar.gz .
# COPY --chmod=744 sources/procps-ng-3.3.17.tar.xz .
# COPY --chmod=744 sources/psmisc-23.4.tar.xz .
# COPY --chmod=744 sources/Python-3.10.2.tar.xz .
# COPY --chmod=744 sources/python-3.10.2-docs-html.tar.bz2 .
# COPY --chmod=744 sources/readline-8.1.2.tar.gz .
# COPY --chmod=744 sources/sed-4.8.tar.xz .
# COPY --chmod=744 sources/shadow-4.11.1.tar.xz .
# COPY --chmod=744 sources/sysklogd-1.5.1.tar.gz .
# COPY --chmod=744 sources/systemd-250.tar.gz .
# COPY --chmod=744 sources/systemd-man-pages-250.tar.xz .
# COPY --chmod=744 sources/sysvinit-3.01.tar.xz .
# COPY --chmod=744 sources/tar-1.34.tar.xz .
# COPY --chmod=744 sources/tcl8.6.12-src.tar.gz .
# COPY --chmod=744 sources/tcl8.6.12-html.tar.gz .
# COPY --chmod=744 sources/texinfo-6.8.tar.xz .
# COPY --chmod=744 sources/tzdata2021e.tar.gz .
# COPY --chmod=744 sources/udev-lfs-20171102.tar.xz .
# COPY --chmod=744 sources/util-linux-2.37.4.tar.xz .
# COPY --chmod=744 sources/vim-8.2.4383.tar.gz .
# COPY --chmod=744 sources/XML-Parser-2.46.tar.gz .
# COPY --chmod=744 sources/xz-5.2.5.tar.xz .
# COPY --chmod=744 sources/zlib-1.2.12.tar.xz .
# COPY --chmod=744 sources/zstd-1.5.2.tar.gz .
# COPY --chmod=744 sources/binutils-2.38-lto_fix-1.patch .
# COPY --chmod=744 sources/bzip2-1.0.8-install_docs-1.patch .
# COPY --chmod=744 sources/coreutils-9.0-i18n-1.patch .
# COPY --chmod=744 sources/coreutils-9.0-chmod_fix-1.patch .
# COPY --chmod=744 sources/glibc-2.35-fhs-1.patch .
# COPY --chmod=744 sources/kbd-2.4.0-backspace-1.patch .
# COPY --chmod=744 sources/perl-5.34.0-upstream_fixes-1.patch .
# COPY --chmod=744 sources/sysvinit-3.01-consolidated-1.patch .
# COPY --chmod=744 sources/systemd-250-upstream_fixes-1.patch .
# COPY --chmod=744 sources/busybox-${BUSYBOX_ARCH} .
# NOTE: Even if this list is updated, BuildKit will only rebuild layers that use the updated files
ARG SOURCES_MIRROR
ADD --chmod=744 ${SOURCES_MIRROR:-https://download.savannah.gnu.org/releases/acl/}acl-2.3.1.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://download.savannah.gnu.org/releases/attr/}attr-2.5.1.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/autoconf/}autoconf-2.71.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/automake/}automake-1.16.5.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/bash/}bash-5.1.16.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://github.com/gavinhoward/bc/releases/download/5.2.2/}bc-5.2.2.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/binutils/}binutils-2.38.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/bison/}bison-3.8.2.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.sourceware.org/pub/bzip2/}bzip2-1.0.8.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://github.com/libcheck/check/releases/download/0.15.2/}check-0.15.2.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/coreutils/}coreutils-9.0.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://dbus.freedesktop.org/releases/dbus/}dbus-1.12.20.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/dejagnu/}dejagnu-1.6.3.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/diffutils/}diffutils-3.8.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://downloads.sourceforge.net/project/e2fsprogs/e2fsprogs/v1.46.5/}e2fsprogs-1.46.5.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://sourceware.org/ftp/elfutils/0.186/}elfutils-0.186.tar.bz2 .
ADD --chmod=744 ${SOURCES_MIRROR:-https://github.com/eudev-project/eudev/releases/download/v3.2.11/}eudev-3.2.11.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://prdownloads.sourceforge.net/expat/}expat-2.4.6.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://prdownloads.sourceforge.net/expect/}expect5.45.4.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://astron.com/pub/file/}file-5.41.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/findutils/}findutils-4.9.0.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://github.com/westes/flex/releases/download/v2.6.4/}flex-2.6.4.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/gawk/}gawk-5.1.1.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/gcc/gcc-11.2.0/}gcc-11.2.0.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/gdbm/}gdbm-1.23.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/gettext/}gettext-0.21.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/glibc/}glibc-2.35.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/gmp/}gmp-6.2.1.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/gperf/}gperf-3.1.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/grep/}grep-3.7.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/groff/}groff-1.22.4.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/grub/}grub-2.06.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/gzip/}gzip-1.11.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://github.com/Mic92/iana-etc/releases/download/20220207/}iana-etc-20220207.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/inetutils/}inetutils-2.2.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://launchpad.net/intltool/trunk/0.51.0/+download/}intltool-0.51.0.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.kernel.org/pub/linux/utils/net/iproute2/}iproute2-5.16.0.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://files.pythonhosted.org/packages/source/J/Jinja2/}Jinja2-3.0.3.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.kernel.org/pub/linux/utils/kbd/}kbd-2.4.0.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.kernel.org/pub/linux/utils/kernel/kmod/}kmod-29.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.greenwoodsoftware.com/less/}less-590.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.linuxfromscratch.org/lfs/downloads/11.1/}lfs-bootscripts-20210608.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/}libcap-2.63.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://github.com/libffi/libffi/releases/download/v3.4.2/}libffi-3.4.2.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://download.savannah.gnu.org/releases/libpipeline/}libpipeline-1.5.5.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/libtool/}libtool-2.4.6.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.kernel.org/pub/linux/kernel/v5.x/}linux-5.16.9.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/m4/}m4-1.4.19.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/make/}make-4.3.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://download.savannah.gnu.org/releases/man-db/}man-db-2.10.1.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.kernel.org/pub/linux/docs/man-pages/}man-pages-5.13.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://files.pythonhosted.org/packages/source/M/MarkupSafe/}MarkupSafe-2.0.1.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://github.com/mesonbuild/meson/releases/download/0.61.1/}meson-0.61.1.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/mpc/}mpc-1.2.1.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.mpfr.org/mpfr-4.1.0/}mpfr-4.1.0.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://invisible-mirror.net/archives/ncurses/}ncurses-6.3.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://github.com/ninja-build/ninja/archive/v1.10.2/}ninja-1.10.2.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.openssl.org/source/}openssl-3.0.1.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/patch/}patch-2.7.6.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.cpan.org/src/5.0/}perl-5.34.0.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://pkg-config.freedesktop.org/releases/}pkg-config-0.29.2.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://sourceforge.net/projects/procps-ng/files/Production/}procps-ng-3.3.17.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://sourceforge.net/projects/psmisc/files/psmisc/}psmisc-23.4.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.python.org/ftp/python/3.10.2/}Python-3.10.2.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.python.org/ftp/python/doc/3.10.2/}python-3.10.2-docs-html.tar.bz2 .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/readline/}readline-8.1.2.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/sed/}sed-4.8.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://github.com/shadow-maint/shadow/releases/download/v4.11.1/}shadow-4.11.1.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.infodrom.org/projects/sysklogd/download/}sysklogd-1.5.1.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://github.com/systemd/systemd/archive/v250/}systemd-250.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://anduin.linuxfromscratch.org/LFS/}systemd-man-pages-250.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://download.savannah.gnu.org/releases/sysvinit/}sysvinit-3.01.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/tar/}tar-1.34.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://downloads.sourceforge.net/tcl/}tcl8.6.12-src.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://downloads.sourceforge.net/tcl/}tcl8.6.12-html.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://ftp.gnu.org/gnu/texinfo/}texinfo-6.8.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.iana.org/time-zones/repository/releases/}tzdata2021e.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://anduin.linuxfromscratch.org/LFS/}udev-lfs-20171102.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.kernel.org/pub/linux/utils/util-linux/v2.37/}util-linux-2.37.4.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://anduin.linuxfromscratch.org/LFS/}vim-8.2.4383.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://cpan.metacpan.org/authors/id/T/TO/TODDR/}XML-Parser-2.46.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://tukaani.org/xz/}xz-5.2.5.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://zlib.net/}zlib-1.2.12.tar.xz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://github.com/facebook/zstd/releases/download/v1.5.2/}zstd-1.5.2.tar.gz .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.linuxfromscratch.org/patches/lfs/11.1/}binutils-2.38-lto_fix-1.patch .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.linuxfromscratch.org/patches/lfs/11.1/}bzip2-1.0.8-install_docs-1.patch .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.linuxfromscratch.org/patches/lfs/11.1/}coreutils-9.0-i18n-1.patch .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.linuxfromscratch.org/patches/lfs/11.1/}coreutils-9.0-chmod_fix-1.patch .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.linuxfromscratch.org/patches/lfs/11.1/}glibc-2.35-fhs-1.patch .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.linuxfromscratch.org/patches/lfs/11.1/}kbd-2.4.0-backspace-1.patch .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.linuxfromscratch.org/patches/lfs/11.1/}perl-5.34.0-upstream_fixes-1.patch .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.linuxfromscratch.org/patches/lfs/11.1/}sysvinit-3.01-consolidated-1.patch .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.linuxfromscratch.org/patches/lfs/11.1/}systemd-250-upstream_fixes-1.patch .
ADD --chmod=744 ${SOURCES_MIRROR:-https://www.busybox.net/downloads/binaries/1.28.1-defconfig-multiarch/}busybox-${BUSYBOX_ARCH} .
#################
# Stage 1. Host #
#################
FROM ${DOCKER_ARCH}/alpine:3.16 AS host
ARG SH
# 2.2. Host System Requirements
RUN apk add --no-cache \
bash binutils bison \
coreutils diffutils findutils \
gawk gcc g++ grep gzip m4 make \
patch perl python3 sed tar \
texinfo wget xz shadow
# Change the default shell to bash
RUN <<'EOT' $SH
ln -svf /bin/bash /bin/sh
ln -svf /bin/bash /bin/ash
echo "/bin/bash" >> /etc/shells
usermod -s /bin/bash root
EOT
ARG LFS
ENV PATH=${LFS}/tools/bin:/bin:/sbin:/usr/bin:/usr/sbin
ENV LC_ALL=POSIX
ENV CONFIG_SITE=${LFS}/usr/share/config.site
# 4.2. Creating a limited directory layout in LFS filesystem
RUN <<'EOT' $SH
mkdir -pv $LFS $LFS/{etc,var,lib64,sources} $LFS/usr/{bin,lib,sbin}
ln -sv usr/bin $LFS/bin
ln -sv usr/lib $LFS/lib
ln -sv usr/sbin $LFS/sbin
EOT
# 4.3. Adding the LFS User
ARG LFS_USER
ARG LFS_GROUOP
RUN <<'EOT' $SH
adduser -D -s /bin/bash $LFS_USER
adduser $LFS_USER $LFS_GROUOP
chown -Rv $LFS_USER $LFS
EOT
USER ${LFS_USER}
#############################################################
# III. Building the LFS Cross Toolchain and Temporary Tools #
#############################################################
ARG LFS_ARCH
ARG LFS_TGT
ARG MAKEFLAGS
WORKDIR /tmp
# 5.2. Binutils-2.38 - Pass 1
RUN --mount=type=tmpfs \
--mount=from=sources,source=binutils-2.38.tar.xz,target=binutils-2.38.tar.xz \
<<'EOT' $SH
tar -xf binutils-2.38.tar.xz
cd binutils-2.38
mkdir -v build
cd build
../configure --prefix=$LFS/tools \
--with-sysroot=$LFS \
--target=$LFS_TGT \
--disable-nls \
--disable-werror
make
make install
EOT
# 5.3. GCC-11.2.0 - Pass 1
RUN --mount=type=tmpfs \
--mount=from=sources,source=gcc-11.2.0.tar.xz,target=gcc-11.2.0.tar.xz \
--mount=from=sources,source=mpfr-4.1.0.tar.xz,target=mpfr-4.1.0.tar.xz \
--mount=from=sources,source=gmp-6.2.1.tar.xz,target=gmp-6.2.1.tar.xz \
--mount=from=sources,source=mpc-1.2.1.tar.gz,target=mpc-1.2.1.tar.gz \
<<'EOT' $SH
tar -xf gcc-11.2.0.tar.xz
cd gcc-11.2.0
tar -xf ../mpfr-4.1.0.tar.xz
mv -v mpfr-4.1.0 mpfr
tar -xf ../gmp-6.2.1.tar.xz
mv -v gmp-6.2.1 gmp
tar -xf ../mpc-1.2.1.tar.gz
mv -v mpc-1.2.1 mpc
case $LFS_ARCH in
x86_64)
sed -e '/m64=/s/lib64/lib/' \
-i.orig gcc/config/i386/t-linux64
;;
aarch64)
sed -e '/mabi.lp64=/s/lib64/lib/' \
-i.orig gcc/config/aarch64/t-aarch64-linux
;;
esac
mkdir -v build
cd build
../configure \
--target=$LFS_TGT \
--prefix=$LFS/tools \
--with-glibc-version=2.35 \
--with-sysroot=$LFS \
--with-newlib \
--without-headers \
--enable-initfini-array \
--disable-nls \
--disable-shared \
--disable-multilib \
--disable-decimal-float \
--disable-threads \
--disable-libatomic \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libstdcxx \
--enable-languages=c,c++
make
make install
cd ..
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h
EOT
# 5.4. Linux-5.16.9 API Headers
RUN --mount=type=tmpfs \
--mount=from=sources,source=linux-5.16.9.tar.xz,target=linux-5.16.9.tar.xz \
<<'EOT' $SH
tar -xf linux-5.16.9.tar.xz
cd linux-5.16.9
make mrproper
make headers
find usr/include -name '.*' -delete
rm usr/include/Makefile
cp -rv usr/include $LFS/usr
EOT
# 5.5. Glibc-2.35
RUN --mount=type=tmpfs \
--mount=from=sources,source=glibc-2.35.tar.xz,target=glibc-2.35.tar.xz \
--mount=from=sources,source=glibc-2.35-fhs-1.patch,target=glibc-2.35-fhs-1.patch \
<<'EOT' $SH
tar -xf glibc-2.35.tar.xz
cd glibc-2.35
case $LFS_ARCH in
x86_64)
ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3
;;
aarch64)
ln -sfv ../lib/ld-linux-aarch64.so.1 $LFS/lib64
ln -sfv ../lib/ld-linux-aarch64.so.1 $LFS/lib64/ld-lsb-aarch64.so.3
;;
esac
patch -Np1 -i ../glibc-2.35-fhs-1.patch
mkdir -v build
cd build
echo "rootsbindir=/usr/sbin" > configparms
../configure \
--prefix=/usr \
--host=$LFS_TGT \
--build=$(../scripts/config.guess) \
--enable-kernel=3.2 \
--with-headers=$LFS/usr/include \
libc_cv_slibdir=/usr/lib
make
make DESTDIR=$LFS install
sed '/RTLDLIST=/s@/usr@@g' -i $LFS/usr/bin/ldd
$LFS/tools/libexec/gcc/$LFS_TGT/11.2.0/install-tools/mkheaders
EOT
# 5.6. Libstdc++ from GCC-11.2.0, Pass 1
RUN --mount=type=tmpfs \
--mount=from=sources,source=gcc-11.2.0.tar.xz,target=gcc-11.2.0.tar.xz \
<<'EOT' $SH
tar -xf gcc-11.2.0.tar.xz
pushd gcc-11.2.0
mkdir -v build
cd build
../libstdc++-v3/configure \
--host=$LFS_TGT \
--build=$(../config.guess) \
--prefix=/usr \
--disable-multilib \
--disable-nls \
--disable-libstdcxx-pch \
--with-gxx-include-dir=/tools/$LFS_TGT/include/c++/11.2.0
make
make DESTDIR=$LFS install
EOT
# 6.2. M4-1.4.19
RUN --mount=type=tmpfs \
--mount=from=sources,source=m4-1.4.19.tar.xz,target=m4-1.4.19.tar.xz \
<<'EOT' $SH
tar -xf m4-1.4.19.tar.xz
cd m4-1.4.19
./configure --prefix=/usr \
--host=$LFS_TGT \
--build=$(build-aux/config.guess)
make
make DESTDIR=$LFS install
EOT
# 6.3. Ncurses-6.3
RUN --mount=type=tmpfs \
--mount=from=sources,source=ncurses-6.3.tar.gz,target=ncurses-6.3.tar.gz \
<<'EOT' $SH
tar -xf ncurses-6.3.tar.gz
cd ncurses-6.3
sed -i s/mawk// configure
mkdir build
pushd build
../configure
make -C include
make -C progs tic
popd
./configure --prefix=/usr \
--host=$LFS_TGT \
--build=$(./config.guess) \
--mandir=/usr/share/man \
--with-manpage-format=normal \
--with-shared \
--without-debug \
--without-ada \
--without-normal \
--disable-stripping \
--enable-widec
make
make DESTDIR=$LFS TIC_PATH=$(pwd)/build/progs/tic install
echo "INPUT(-lncursesw)" > $LFS/usr/lib/libncurses.so
EOT
# 6.4. Bash-5.1.16
RUN --mount=type=tmpfs \
--mount=from=sources,source=bash-5.1.16.tar.gz,target=bash-5.1.16.tar.gz \
<<'EOT' $SH
tar -xf bash-5.1.16.tar.gz
cd bash-5.1.16
./configure --prefix=/usr \
--build=$(support/config.guess) \
--host=$LFS_TGT \
--without-bash-malloc
make
make DESTDIR=$LFS install
ln -sv bash $LFS/bin/sh
EOT
# 6.5. Coreutils-9.0
RUN --mount=type=tmpfs \
--mount=from=sources,source=coreutils-9.0.tar.xz,target=coreutils-9.0.tar.xz \
<<'EOT' $SH
tar -xf coreutils-9.0.tar.xz
cd coreutils-9.0
./configure --prefix=/usr \
--host=$LFS_TGT \
--build=$(build-aux/config.guess) \
--enable-install-program=hostname \
--enable-no-install-program=kill,uptime
make
make DESTDIR=$LFS install
mv -v $LFS/usr/bin/chroot $LFS/usr/sbin
mkdir -pv $LFS/usr/share/man/man8
mv -v $LFS/usr/share/man/man1/chroot.1 $LFS/usr/share/man/man8/chroot.8
sed -i 's/"1"/"8"/' $LFS/usr/share/man/man8/chroot.8
EOT
# 6.6. Diffutils-3.8
RUN --mount=type=tmpfs \
--mount=from=sources,source=diffutils-3.8.tar.xz,target=diffutils-3.8.tar.xz \
<<'EOT' $SH
tar -xf diffutils-3.8.tar.xz
cd diffutils-3.8
./configure --prefix=/usr --host=$LFS_TGT
make
make DESTDIR=$LFS install
EOT
# 6.7. File-5.41
RUN --mount=type=tmpfs \
--mount=from=sources,source=file-5.41.tar.gz,target=file-5.41.tar.gz \
<<'EOT' $SH
tar -xf file-5.41.tar.gz
cd file-5.41
mkdir build
pushd build
../configure --disable-bzlib \
--disable-libseccomp \
--disable-xzlib \
--disable-zlib
make
popd
./configure --prefix=/usr --host=$LFS_TGT --build=$(./config.guess)
make FILE_COMPILE=$(pwd)/build/src/file
make DESTDIR=$LFS install
EOT
# 6.8. Findutils-4.9.0
RUN --mount=type=tmpfs \
--mount=from=sources,source=findutils-4.9.0.tar.xz,target=findutils-4.9.0.tar.xz \
<<'EOT' $SH
tar -xf findutils-4.9.0.tar.xz
cd findutils-4.9.0
./configure --prefix=/usr \
--localstatedir=/var/lib/locate \
--host=$LFS_TGT \
--build=$(build-aux/config.guess)
make
make DESTDIR=$LFS install
EOT
# 6.9. Gawk-5.1.1
RUN --mount=type=tmpfs \
--mount=from=sources,source=gawk-5.1.1.tar.xz,target=gawk-5.1.1.tar.xz \
<<'EOT' $SH
tar -xf gawk-5.1.1.tar.xz
cd gawk-5.1.1
sed -i 's/extras//' Makefile.in
./configure --prefix=/usr \
--host=$LFS_TGT \
--build=$(build-aux/config.guess)
make
make DESTDIR=$LFS install
EOT
# 6.10. Grep-3.7
RUN --mount=type=tmpfs \
--mount=from=sources,source=grep-3.7.tar.xz,target=grep-3.7.tar.xz \
<<'EOT' $SH
tar -xf grep-3.7.tar.xz
cd grep-3.7
./configure --prefix=/usr --host=$LFS_TGT
make
make DESTDIR=$LFS install
EOT
# 6.11. Gzip-1.11
RUN --mount=type=tmpfs \
--mount=from=sources,source=gzip-1.11.tar.xz,target=gzip-1.11.tar.xz \
<<'EOT' $SH
tar -xf gzip-1.11.tar.xz
cd gzip-1.11
./configure --prefix=/usr --host=$LFS_TGT
make
make DESTDIR=$LFS install
EOT
# 6.12. Make-4.3
RUN --mount=type=tmpfs \
--mount=from=sources,source=make-4.3.tar.gz,target=make-4.3.tar.gz \
<<'EOT' $SH
tar -xf make-4.3.tar.gz
cd make-4.3
./configure --prefix=/usr \
--without-guile \
--host=$LFS_TGT \
--build=$(build-aux/config.guess)
make
make DESTDIR=$LFS install
EOT
# 6.13. Patch-2.7.6
RUN --mount=type=tmpfs \
--mount=from=sources,source=patch-2.7.6.tar.xz,target=patch-2.7.6.tar.xz \
<<'EOT' $SH
tar -xf patch-2.7.6.tar.xz
pushd patch-2.7.6
./configure --prefix=/usr \
--host=$LFS_TGT \
--build=$(build-aux/config.guess)
make
make DESTDIR=$LFS install
EOT
# 6.14. Sed-4.8
RUN --mount=type=tmpfs \
--mount=from=sources,source=sed-4.8.tar.xz,target=sed-4.8.tar.xz \
<<'EOT' $SH
tar -xf sed-4.8.tar.xz
cd sed-4.8
./configure --prefix=/usr --host=$LFS_TGT
make
make DESTDIR=$LFS install
EOT
# 6.15. Tar-1.34
RUN --mount=type=tmpfs \
--mount=from=sources,source=tar-1.34.tar.xz,target=tar-1.34.tar.xz \
<<'EOT' $SH
tar -xf tar-1.34.tar.xz
cd tar-1.34
./configure --prefix=/usr \
--host=$LFS_TGT \
--build=$(build-aux/config.guess)
make
make DESTDIR=$LFS install
EOT
# 6.16. Xz-5.2.5
RUN --mount=type=tmpfs \
--mount=from=sources,source=xz-5.2.5.tar.xz,target=xz-5.2.5.tar.xz \
<<'EOT' $SH
tar -xf xz-5.2.5.tar.xz
cd xz-5.2.5
./configure --prefix=/usr \
--host=$LFS_TGT \
--build=$(build-aux/config.guess) \
--disable-static \
--docdir=/usr/share/doc/xz-5.2.5
make
make DESTDIR=$LFS install
EOT
# 6.17. Binutils-2.38 - Pass 2
RUN --mount=type=tmpfs \
--mount=from=sources,source=binutils-2.38.tar.xz,target=binutils-2.38.tar.xz \
<<'EOT' $SH
tar -xf binutils-2.38.tar.xz
cd binutils-2.38
sed '6009s/$add_dir//' -i ltmain.sh
mkdir -v build
cd build
../configure --prefix=/usr \
--build=$(../config.guess) \
--host=$LFS_TGT \
--disable-nls \
--enable-shared \
--disable-werror \
--enable-64-bit-bfd
make
make DESTDIR=$LFS install
EOT
# 6.18. GCC-11.2.0 - Pass 2
RUN --mount=type=tmpfs \
--mount=from=sources,source=gcc-11.2.0.tar.xz,target=gcc-11.2.0.tar.xz \
--mount=from=sources,source=mpfr-4.1.0.tar.xz,target=mpfr-4.1.0.tar.xz \
--mount=from=sources,source=gmp-6.2.1.tar.xz,target=gmp-6.2.1.tar.xz \
--mount=from=sources,source=mpc-1.2.1.tar.gz,target=mpc-1.2.1.tar.gz \
<<'EOT' $SH
tar -xf gcc-11.2.0.tar.xz
cd gcc-11.2.0
tar -xf ../mpfr-4.1.0.tar.xz
mv -v mpfr-4.1.0 mpfr
tar -xf ../gmp-6.2.1.tar.xz
mv -v gmp-6.2.1 gmp
tar -xf ../mpc-1.2.1.tar.gz
mv -v mpc-1.2.1 mpc
case $LFS_ARCH in
x86_64)
sed -e '/m64=/s/lib64/lib/' \
-i.orig gcc/config/i386/t-linux64
;;
aarch64)
sed -e '/mabi.lp64=/s/lib64/lib/' \
-i.orig gcc/config/aarch64/t-aarch64-linux
;;
esac
mkdir -v build
cd build
mkdir -pv $LFS_TGT/libgcc
ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h
../configure --build=$(../config.guess) \
--host=$LFS_TGT \
--prefix=/usr \
CC_FOR_TARGET=$LFS_TGT-gcc \
--with-build-sysroot=$LFS \
--enable-initfini-array \
--disable-nls \
--disable-multilib \
--disable-decimal-float \
--disable-libatomic \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libstdcxx \
--enable-languages=c,c++
make
make DESTDIR=$LFS install
ln -sv gcc $LFS/usr/bin/cc
EOT
# 7.2. Changing Ownership
USER root
RUN chown -R root:root $LFS
######################
# State 2. Toolchain #
######################
FROM scratch AS toolchain
ARG SH
ARG LFS
# Copy the LFS root directory from previous build
COPY --from=host ${LFS} /
# NOTE: section "7.3. Preparing Virtual Kernel File Systems" is managed by Docker during the build
# We need to add them manually later (see iso-builder)
# 7.4. Entering the Chroot Environment
ENV HOME=/root
ENV PS1='[toolchain] \u:\w\$ '
ENV PATH=/bin:/usr/bin:/usr/sbin
ENTRYPOINT [ "/bin/bash" ]
# 7.5. Creating Directories
RUN <<'EOT' $SH
mkdir -pv /{boot,home,mnt,opt,srv,run}
mkdir -pv /etc/{opt,sysconfig}
mkdir -pv /lib/firmware
mkdir -pv /media/{floppy,cdrom}
mkdir -pv /usr/{,local/}{include,src}
mkdir -pv /usr/local/{bin,lib,sbin}
mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man}
mkdir -pv /usr/{,local/}share/{misc,terminfo,zoneinfo}
mkdir -pv /usr/{,local/}share/man/man{1..8}
mkdir -pv /var/{cache,local,log,mail,opt,spool}
mkdir -pv /var/lib/{color,misc,locate}
ln -sfv /run /var/run
ln -sfv /run/lock /var/lock
install -dv -m 0750 /root
install -dv -m 1777 /tmp /var/tmp
EOT
# 7.6. Creating Essential Files and Symlinks
# Skipping `ln -sv /proc/self/mounts /etc/mtab` since it's created by Docker
# Skipping setting /etc/hosts since it's managed by Docker
ADD <<-'EOT' /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/dev/null:/usr/bin/false
daemon:x:6:6:Daemon User:/dev/null:/usr/bin/false
messagebus:x:18:18:D-Bus Message Daemon User:/run/dbus:/usr/bin/false
systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/usr/bin/false
systemd-journal-remote:x:74:74:systemd Journal Remote:/:/usr/bin/false
systemd-journal-upload:x:75:75:systemd Journal Upload:/:/usr/bin/false
systemd-network:x:76:76:systemd Network Management:/:/usr/bin/false
systemd-resolve:x:77:77:systemd Resolver:/:/usr/bin/false
systemd-timesync:x:78:78:systemd Time Synchronization:/:/usr/bin/false
systemd-coredump:x:79:79:systemd Core Dumper:/:/usr/bin/false
uuidd:x:80:80:UUID Generation Daemon User:/dev/null:/usr/bin/false
systemd-oom:x:81:81:systemd Out Of Memory Daemon:/:/usr/bin/false
nobody:x:99:99:Unprivileged User:/dev/null:/usr/bin/false
EOT
ADD <<-'EOT' /etc/group
root:x:0:
bin:x:1:daemon
sys:x:2:
kmem:x:3:
tape:x:4:
tty:x:5:
daemon:x:6:
floppy:x:7:
disk:x:8:
lp:x:9:
dialout:x:10:
audio:x:11:
video:x:12:
utmp:x:13:
usb:x:14:
cdrom:x:15:
adm:x:16:
messagebus:x:18:
systemd-journal:x:23:
input:x:24:
mail:x:34:
kvm:x:61:
systemd-journal-gateway:x:73:
systemd-journal-remote:x:74:
systemd-journal-upload:x:75:
systemd-network:x:76:
systemd-resolve:x:77:
systemd-timesync:x:78:
systemd-coredump:x:79:
uuidd:x:80:
systemd-oom:x:81:
wheel:x:97:
nogroup:x:99:
users:x:999:
EOT
RUN <<'EOT' $SH
echo "tester:x:101:101::/home/tester:/bin/bash" >> /etc/passwd
echo "tester:x:101:" >> /etc/group
install -o tester -d /home/tester
touch /var/log/{btmp,lastlog,faillog,wtmp}
chgrp -v utmp /var/log/lastlog
chmod -v 664 /var/log/lastlog
chmod -v 600 /var/log/btmp
EOT
ARG LFS_ARCH
ARG LFS_TGT
ARG MAKEFLAGS
WORKDIR /tmp
# 7.7. Libstdc++ from GCC-11.2.0, Pass 2
RUN --mount=type=tmpfs \
--mount=from=sources,source=gcc-11.2.0.tar.xz,target=gcc-11.2.0.tar.xz \
<<'EOT' $SH
tar -xf gcc-11.2.0.tar.xz
cd gcc-11.2.0
ln -s gthr-posix.h libgcc/gthr-default.h
mkdir -v build
cd build
../libstdc++-v3/configure \
CXXFLAGS="-g -O2 -D_GNU_SOURCE" \
--prefix=/usr \
--disable-multilib \
--disable-nls \
--host=$LFS_TGT \
--disable-libstdcxx-pch
make
make install
EOT
# 7.8. Gettext-0.21
RUN --mount=type=tmpfs \
--mount=from=sources,source=gettext-0.21.tar.xz,target=gettext-0.21.tar.xz \
<<'EOT' $SH
tar -xf gettext-0.21.tar.xz
cd gettext-0.21
./configure --disable-shared
make
cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /usr/bin
EOT
# 7.9. Bison-3.8.2
RUN --mount=type=tmpfs \
--mount=from=sources,source=bison-3.8.2.tar.xz,target=bison-3.8.2.tar.xz \
<<'EOT' $SH
tar -xf bison-3.8.2.tar.xz
cd bison-3.8.2
./configure --prefix=/usr \
--docdir=/usr/share/doc/bison-3.8.2
make
make install
EOT
# 7.10. Perl-5.34.0
RUN --mount=type=tmpfs \
--mount=from=sources,source=perl-5.34.0.tar.xz,target=perl-5.34.0.tar.xz \
<<'EOT' $SH
tar -xf perl-5.34.0.tar.xz
cd perl-5.34.0
sh Configure -des \
-Dprefix=/usr \
-Dvendorprefix=/usr \
-Dprivlib=/usr/lib/perl5/5.34/core_perl \
-Darchlib=/usr/lib/perl5/5.34/core_perl \
-Dsitelib=/usr/lib/perl5/5.34/site_perl \
-Dsitearch=/usr/lib/perl5/5.34/site_perl \
-Dvendorlib=/usr/lib/perl5/5.34/vendor_perl \
-Dvendorarch=/usr/lib/perl5/5.34/vendor_perl
make
make install
EOT
# 7.11. Python-3.10.2
RUN --mount=type=tmpfs \
--mount=from=sources,source=Python-3.10.2.tar.xz,target=Python-3.10.2.tar.xz \
<<'EOT' $SH
tar -xf Python-3.10.2.tar.xz
cd Python-3.10.2
./configure --prefix=/usr \
--enable-shared \
--without-ensurepip
make
make install
EOT
# 7.12. Texinfo-6.8
RUN --mount=type=tmpfs \
--mount=from=sources,source=texinfo-6.8.tar.xz,target=texinfo-6.8.tar.xz \
<<'EOT' $SH
tar -xf texinfo-6.8.tar.xz
cd texinfo-6.8
sed -e 's/__attribute_nonnull__/__nonnull/' \
-i gnulib/lib/malloc/dynarray-skeleton.c
./configure --prefix=/usr
make
make install
EOT
# 7.13. Util-linux-2.37.4
RUN --mount=type=tmpfs \
--mount=from=sources,source=util-linux-2.37.4.tar.xz,target=util-linux-2.37.4.tar.xz \
<<'EOT' $SH
tar -xf util-linux-2.37.4.tar.xz
cd util-linux-2.37.4
mkdir -pv /var/lib/hwclock
./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \
--libdir=/usr/lib \
--docdir=/usr/share/doc/util-linux-2.37.4 \
--disable-chfn-chsh \
--disable-login \
--disable-nologin \
--disable-su \
--disable-setpriv \
--disable-runuser \
--disable-pylibmount \
--disable-static \
--without-python \
runstatedir=/run
make
make install
EOT
# 7.14. Cleaning up and Saving the Temporary System
RUN <<'EOT' $SH
rm -rf /usr/share/{info,man,doc}/*
find /usr/{lib,libexec} -name \*.la -delete
rm -rf /tools
EOT
###############################
# IV. Building the LFS System #
###############################
###################
# Stage 3. System #
###################
FROM toolchain AS system
ARG SH
ARG ENABLE_TESTS
ARG MAKEFLAGS
WORKDIR /tmp
# 8.3. Man-pages-5.13
RUN --mount=type=tmpfs \
--mount=from=sources,source=man-pages-5.13.tar.xz,target=man-pages-5.13.tar.xz \
<<'EOT' $SH
tar -xf man-pages-5.13.tar.xz
cd man-pages-5.13
make prefix=/usr install
EOT
# 8.4. Iana-Etc-20220207
RUN --mount=type=tmpfs \
--mount=from=sources,source=iana-etc-20220207.tar.gz,target=iana-etc-20220207.tar.gz \
<<'EOT' $SH
tar -xf iana-etc-20220207.tar.gz
cd iana-etc-20220207
cp services protocols /etc
EOT
# 8.5. Glibc-2.35
# TODO: make the result of `make check` more visible
RUN --mount=type=tmpfs \
--mount=from=sources,source=glibc-2.35.tar.xz,target=glibc-2.35.tar.xz \
--mount=from=sources,source=glibc-2.35-fhs-1.patch,target=glibc-2.35-fhs-1.patch \