This repository has been archived by the owner on Jan 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
build-system.sh
executable file
·6975 lines (6949 loc) · 231 KB
/
build-system.sh
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
#!/bin/bash
#
# Builds the core MassOS system (Stage 2) in a chroot environment.
# Copyright (C) 2021-2022 MassOS Developers.
#
# This script is part of the MassOS build system. It is licensed under GPLv3+.
# See the 'LICENSE' file for the full license text. On a MassOS system, this
# document can also be found at '/usr/share/massos/LICENSE'.
#
# === IF RESUMING A FAILED BUILD, DO NOT REMOVE ANY LINES BEFORE LINE 38 ===
#
# Exit if something goes wrong.
set -e
# Disabling hashing is useful so the newly built tools are detected.
set +h
# Ensure we're running in the MassOS chroot.
if [ $EUID -ne 0 ] || [ ! -d /sources ]; then
echo "This script should not be run manually." >&2
echo "stage2.sh will automatically run it in a chroot environment." >&2
exit 1
fi
# Set the source directory correctly.
export SRC=/sources
cd $SRC
# Set the PATH correctly.
export PATH=/usr/bin:/usr/sbin:/sources/sphinx/bin:/sources/cargoc
# Set the locale correctly.
export LC_ALL="en_US.UTF-8" 2>/dev/null
# Build in parallel using all available CPU cores.
export MAKEFLAGS="-j$(nproc)"
# Allow building some packages as root.
export FORCE_UNSAFE_CONFIGURE=1
# SHELL may not be set in chroot by default.
export SHELL=/bin/bash
# Compiler flags for MassOS. We prefer to optimise for size.
CFLAGS="-Os -pipe"
CXXFLAGS="-Os -pipe"
export CFLAGS CXXFLAGS
# === REMOVE LINES BELOW THIS FOR RESUMING A FAILED BUILD ===
# Mark the build as started, for Stage 2 resume.
touch .BUILD_HAS_STARTED
# Setup the full filesystem structure.
mkdir -p /{boot,home,mnt,opt,srv}
mkdir -p /boot/efi
mkdir -p /etc/{opt,sysconfig}
mkdir -p /usr/lib/firmware
mkdir -p /usr/{,local/}{include,src}
mkdir -p /usr/local/{bin,lib,libexec,sbin}
mkdir -p /usr/{,local/}share/{color,dict,doc,info,locale,man}
mkdir -p /usr/{,local/}share/{misc,terminfo,zoneinfo}
mkdir -p /var/{cache,local,log,mail,opt,spool}
mkdir -p /var/lib/{color,misc,locate}
ln -sf lib /usr/local/lib64
ln -sf /run /var/run
ln -sf /run/lock /var/lock
ln -sf /run/media /media
install -dm0750 /root
cp -r /etc/skel/. /root
install -dm1777 /tmp /var/tmp
touch /var/log/{btmp,lastlog,faillog,wtmp}
chgrp utmp /var/log/lastlog
chmod 664 /var/log/lastlog
chmod 600 /var/log/btmp
# Install man pages for MassOS system utilities.
cp -r man/* /usr/share/man
# Install MassOS Backgrounds.
install -t /usr/share/backgrounds/xfce -Dm644 backgrounds/*
# Set the locale correctly.
mkdir -p /usr/lib/locale
mklocales 2>/dev/null
# Gettext utilities (for circular dependencies; full Gettext is built later).
tar -xf gettext-0.21.tar.xz
cd gettext-0.21
./configure --disable-shared
make
install -t /usr/bin -Dm755 gettext-tools/src/{msgfmt,msgmerge,xgettext}
cd ..
rm -rf gettext-0.21
# Bison (circular deps; rebuilt later).
tar -xf bison-3.8.2.tar.xz
cd bison-3.8.2
./configure --prefix=/usr
make
make install
cd ..
rm -rf bison-3.8.2
# Perl (circular deps; rebuilt later).
tar -xf perl-5.36.0.tar.xz
cd perl-5.36.0
./Configure -des -Doptimize="$CFLAGS" -Dprefix=/usr -Dvendorprefix=/usr -Dprivlib=/usr/lib/perl5/5.36/core_perl -Darchlib=/usr/lib/perl5/5.36/core_perl -Dsitelib=/usr/lib/perl5/5.36/site_perl -Dsitearch=/usr/lib/perl5/5.36/site_perl -Dvendorlib=/usr/lib/perl5/5.36/vendor_perl -Dvendorarch=/usr/lib/perl5/5.36/vendor_perl
make
make install
cd ..
rm -rf perl-5.36.0
# Python (circular deps; rebuilt later).
tar -xf Python-3.10.7.tar.xz
cd Python-3.10.7
./configure --prefix=/usr --enable-shared --without-ensurepip --disable-test-modules
make
make install
cd ..
rm -rf Python-3.10.7
# Texinfo (circular deps; rebuilt later).
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
cd ..
rm -rf texinfo-6.8
# util-linux (circular deps; rebuilt later).
tar -xf util-linux-2.38.1.tar.xz
cd util-linux-2.38.1
mkdir -p /var/lib/hwclock
./configure ADJTIME_PATH=/var/lib/hwclock/adjtime --libdir=/usr/lib --disable-chfn-chsh --disable-login --disable-nologin --disable-su --disable-setpriv --disable-runuser --disable-pylibmount --disable-static --without-python runstatedir=/run
make
make install
cd ..
rm -rf util-linux-2.38.1
# man-pages.
tar -xf man-pages-5.13.tar.xz
cd man-pages-5.13
make prefix=/usr install
cd ..
rm -rf man-pages-5.13
# iana-etc.
tar -xf iana-etc-20220922.tar.gz
install -t /etc -Dm644 iana-etc-20220922/{protocols,services}
rm -rf iana-etc-20220922
# Neofetch (an enhanced fork since upstream seems to be unmaintained).
tar -xf hyfetch-1.4.0.tar.gz
cd hyfetch-1.4.0
install -t /usr/bin -Dm755 neofetch
install -t /usr/share/man/man1 -Dm644 neofetch.1
install -t /usr/share/licenses/neofetch -Dm644 LICENSE.md
cd ..
rm -rf hyfetch-1.4.0
# Glibc.
tar -xf glibc-2.36.tar.xz
cd glibc-2.36
patch -Np1 -i ../patches/glibc-2.36-multiplefixes.patch
mkdir build; cd build
echo "rootsbindir=/usr/sbin" > configparms
CFLAGS="-O2" CXXFLAGS="-O2" ../configure --prefix=/usr --enable-kernel=3.2 --enable-stack-protector=strong --disable-default-pie --disable-werror --with-headers=/usr/include libc_cv_slibdir=/usr/lib
make
sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile
make install
install -t /usr/share/licenses/glibc -Dm644 ../COPYING ../COPYING.LIB ../LICENSES
sed '/RTLDLIST=/s@/usr@@g' -i /usr/bin/ldd
cp ../nscd/nscd.conf /etc/nscd.conf
mkdir -p /var/cache/nscd
install -Dm644 ../nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf
install -Dm644 ../nscd/nscd.service /usr/lib/systemd/system/nscd.service
mklocales
cat > /etc/nsswitch.conf << END
passwd: files
group: files
shadow: files
hosts: files dns
networks: files
protocols: files
services: files
ethers: files
rpc: files
END
tar -xf ../../tzdata2022d.tar.gz
ZONEINFO=/usr/share/zoneinfo
mkdir -p $ZONEINFO/{posix,right}
for tz in etcetera southamerica northamerica europe africa antarctica asia australasia backward; do
zic -L /dev/null -d $ZONEINFO ${tz}
zic -L /dev/null -d $ZONEINFO/posix ${tz}
zic -L leapseconds -d $ZONEINFO/right ${tz}
done
cp zone.tab zone1970.tab iso3166.tab $ZONEINFO
zic -d $ZONEINFO -p America/New_York
unset ZONEINFO
# Default timezone is UTC, can be changed by the user later.
ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime
cat > /etc/ld.so.conf << END
/usr/local/lib
include /etc/ld.so.conf.d/*.conf
END
cd ../..
rm -rf glibc-2.36
# zlib.
tar -xf zlib-1.2.12.tar.xz
cd zlib-1.2.12
patch -Np1 -i ../patches/zlib-1.2.12-upstreamfix.patch
./configure --prefix=/usr
make
make install
install -dm755 /usr/share/licenses/zlib
cat zlib.h | head -n28 | tail -n25 > /usr/share/licenses/zlib/LICENSE
rm -f /usr/lib/libz.a
cd ..
rm -rf zlib-1.2.12
# bzip2.
tar -xf bzip2-1.0.8.tar.gz
cd bzip2-1.0.8
sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile
sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile
make -f Makefile-libbz2_so CFLAGS="$CFLAGS -fPIC"
make clean
make CFLAGS="$CFLAGS"
make PREFIX=/usr install
cp -a libbz2.so.* /usr/lib
ln -s libbz2.so.1.0.8 /usr/lib/libbz2.so
cp bzip2-shared /usr/bin/bzip2
for i in /usr/bin/{bzcat,bunzip2}; do
ln -sf bzip2 $i
done
rm -f /usr/lib/libbz2.a
install -t /usr/share/licenses/bzip2 -Dm644 LICENSE
cd ..
rm -rf bzip2-1.0.8
# XZ.
tar -xf xz-5.2.7.tar.xz
cd xz-5.2.7
./configure --prefix=/usr --disable-static
make
make install
install -t /usr/share/licenses/xz -Dm644 COPYING COPYING.GPLv2 COPYING.GPLv3 COPYING.LGPLv2.1
cd ..
rm -rf xz-5.2.7
# LZ4.
tar -xf lz4-1.9.4.tar.gz
cd lz4-1.9.4
make PREFIX=/usr CFLAGS="$CFLAGS" -C lib
make PREFIX=/usr CFLAGS="$CFLAGS" -C programs lz4 lz4c
make PREFIX=/usr install
rm -f /usr/lib/liblz4.a
install -t /usr/share/licenses/lz4 -Dm644 LICENSE
cd ..
rm -rf lz4-1.9.4
# ZSTD.
tar -xf zstd-1.5.2.tar.gz
cd zstd-1.5.2
make CFLAGS="$CFLAGS -fPIC"
make prefix=/usr install
rm -f /usr/lib/libzstd.a
sed -i 's|/usr/local|/usr|' /usr/lib/pkgconfig/libzstd.pc
install -t /usr/share/licenses/zstd -Dm644 COPYING LICENSE
cd ..
rm -rf zstd-1.5.2
# pigz.
tar -xf pigz_2.6.orig.tar.xz
cd pigz-2.6
sed -i 's/O3/Os/' Makefile
sed -i 's/LDFLAGS=/LDFLAGS=-s/' Makefile
make
install -m755 pigz /usr/bin/pigz
install -m755 unpigz /usr/bin/unpigz
install -m644 pigz.1 /usr/share/man/man1/pigz.1
install -dm755 /usr/share/licenses/pigz
cat README | tail -n18 > /usr/share/licenses/pigz/LICENSE
cd ..
rm -rf pigz-2.6
# lzip.
tar -xf lzip-1.22.tar.gz
cd lzip-1.22
./configure CXXFLAGS="$CXXFLAGS" --prefix=/usr
make
make install
install -t /usr/share/licenses/lzip -Dm644 COPYING
cd ..
rm -rf lzip-1.22
# Readline.
tar -xf readline-8.2.tar.gz
cd readline-8.2
./configure --prefix=/usr --disable-static --with-curses
make SHLIB_LIBS="-lncursesw"
make SHLIB_LIBS="-lncursesw" install
install -t /usr/share/licenses/readline -Dm644 COPYING
cd ..
rm -rf readline-8.2
# m4.
tar -xf m4-1.4.19.tar.xz
cd m4-1.4.19
./configure --prefix=/usr
make
make install
install -t /usr/share/licenses/m4 -Dm644 COPYING
cd ..
rm -rf m4-1.4.19
# bc.
tar -xf bc-6.0.3.tar.xz
cd bc-6.0.3
CC=gcc ./configure.sh --prefix=/usr --disable-generated-tests
make
make install
install -t /usr/share/licenses/bc -Dm644 LICENSE.md
cd ..
rm -rf bc-6.0.3
# Flex.
tar -xf flex-2.6.4.tar.gz
cd flex-2.6.4
./configure --prefix=/usr --disable-static
make
make install
ln -sf flex /usr/bin/lex
ln -sf flex.1 /usr/share/man/man1/lex.1
ln -sf flex.info /usr/share/info/lex.info
install -t /usr/share/licenses/flex -Dm644 COPYING
cd ..
rm -rf flex-2.6.4
# Tcl.
tar -xf tcl8.6.12-src.tar.gz
cd tcl8.6.12
SRCDIR=$(pwd)
cd unix
./configure --prefix=/usr --mandir=/usr/share/man --enable-64bit
make
sed -e "s|$SRCDIR/unix|/usr/lib|" -e "s|$SRCDIR|/usr/include|" -i tclConfig.sh
sed -e "s|$SRCDIR/unix/pkgs/tdbc1.1.3|/usr/lib/tdbc1.1.3|" -e "s|$SRCDIR/pkgs/tdbc1.1.3/generic|/usr/include|" -e "s|$SRCDIR/pkgs/tdbc1.1.3/library|/usr/lib/tcl8.6|" -e "s|$SRCDIR/pkgs/tdbc1.1.3|/usr/include|" -i pkgs/tdbc1.1.3/tdbcConfig.sh
sed -e "s|$SRCDIR/unix/pkgs/itcl4.2.2|/usr/lib/itcl4.2.2|" -e "s|$SRCDIR/pkgs/itcl4.2.2/generic|/usr/include|" -e "s|$SRCDIR/pkgs/itcl4.2.2|/usr/include|" -i pkgs/itcl4.2.2/itclConfig.sh
unset SRCDIR
make install
chmod u+w /usr/lib/libtcl8.6.so
make install-private-headers
ln -sf tclsh8.6 /usr/bin/tclsh
mv /usr/share/man/man3/{Thread,Tcl_Thread}.3
install -t /usr/share/licenses/tcl -Dm644 ../license.terms
cd ../..
rm -rf tcl8.6.12
# Binutils.
tar -xf binutils-2.39.tar.xz
cd binutils-2.39
mkdir build; cd build
CFLAGS="-O2" CXXFLAGS="-O2" ../configure --prefix=/usr --sysconfdir=/etc --with-pkgversion="MassOS Binutils 2.39" --with-system-zlib --enable-gold --enable-install-libiberty --enable-ld=default --enable-plugins --enable-relro --enable-shared --disable-werror
make tooldir=/usr
make -j1 tooldir=/usr install
rm -f /usr/lib/lib{bfd,ctf,ctf-nobfd,opcodes}.a
install -t /usr/share/licenses/binutils -Dm644 ../COPYING ../COPYING.LIB ../COPYING3 ../COPYING3.LIB
cd ../..
rm -rf binutils-2.39
# GMP.
tar -xf gmp-6.2.1.tar.xz
cd gmp-6.2.1
cp configfsf.guess config.guess
cp configfsf.sub config.sub
./configure --prefix=/usr --enable-cxx --disable-static
make
make install
install -t /usr/share/licenses/gmp -Dm644 COPYING COPYINGv2 COPYINGv3 COPYING.LESSERv3
cd ..
rm -rf gmp-6.2.1
# MPFR.
tar -xf mpfr-4.1.0.tar.xz
cd mpfr-4.1.0
./configure --prefix=/usr --disable-static --enable-thread-safe
make
make install
install -t /usr/share/licenses/mpfr -Dm644 COPYING COPYING.LESSER
cd ..
rm -rf mpfr-4.1.0
# MPC.
tar -xf mpc-1.2.1.tar.gz
cd mpc-1.2.1
./configure --prefix=/usr --disable-static
make
make install
install -t /usr/share/licenses/mpc -Dm644 COPYING.LESSER
cd ..
rm -rf mpc-1.2.1
# Attr.
tar -xf attr-2.5.1.tar.gz
cd attr-2.5.1
./configure --prefix=/usr --disable-static --sysconfdir=/etc
make
make install
install -t /usr/share/licenses/attr -Dm644 doc/COPYING doc/COPYING.LGPL
cd ..
rm -rf attr-2.5.1
# Acl.
tar -xf acl-2.3.1.tar.xz
cd acl-2.3.1
./configure --prefix=/usr --disable-static
make
make install
install -t /usr/share/licenses/acl -Dm644 doc/COPYING doc/COPYING.LGPL
cd ..
rm -rf acl-2.3.1
# Libcap.
tar -xf libcap-2.66.tar.xz
cd libcap-2.66
sed -i '/install -m.*STA/d' libcap/Makefile
make prefix=/usr lib=lib CFLAGS="$CFLAGS -fPIC"
make prefix=/usr lib=lib install
chmod 755 /usr/lib/lib{cap,psx}.so.2.66
install -t /usr/share/licenses/libcap -Dm644 License
cd ..
rm -rf libcap-2.66
# Cracklib.
tar -xf cracklib-2.9.8.tar.bz2
cd cracklib-2.9.8
sed -i '15212 s/.*/am_cv_python_version=3.10/' configure
./configure --prefix=/usr --disable-static --with-default-dict=/usr/lib/cracklib/pw_dict
make
make install
install -dm755 /usr/lib/cracklib
bzip2 -cd ../cracklib-words-2.9.8.bz2 > /usr/share/dict/cracklib-words
ln -sf cracklib-words /usr/share/dict/words
echo "massos" > /usr/share/dict/cracklib-extra-words
create-cracklib-dict /usr/share/dict/cracklib-words /usr/share/dict/cracklib-extra-words
install -t /usr/share/licenses/cracklib -Dm644 COPYING.LIB
cd ..
rm -rf cracklib-2.9.8
# Linux-PAM (initial build, will be rebuilt later to support Audit).
tar -xf Linux-PAM-1.5.2.tar.xz
cd Linux-PAM-1.5.2
./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --enable-securedir=/usr/lib/security --disable-doc --disable-pie
make
make install
chmod 4755 /usr/sbin/unix_chkpwd
install -dm755 /etc/pam.d
cat > /etc/pam.d/system-account << END
account required pam_unix.so
END
cat > /etc/pam.d/system-session << END
session required pam_unix.so
END
cat > /etc/pam.d/other << END
auth required pam_warn.so
auth required pam_deny.so
account required pam_warn.so
account required pam_deny.so
password required pam_warn.so
password required pam_deny.so
session required pam_warn.so
session required pam_deny.so
END
install -t /usr/share/licenses/linux-pam -Dm644 COPYING Copyright
cd ..
rm -rf Linux-PAM-1.5.2
# libpwquality.
tar -xf libpwquality-1.4.4.tar.bz2
cd libpwquality-1.4.4
./configure --prefix=/usr --disable-static --with-securedir=/usr/lib/security --with-python-binary=python3
make
make install
cat > /etc/pam.d/system-password << END
password required pam_pwquality.so authtok_type=UNIX retry=1 difok=1 \
minlen=8 dcredit=0 ucredit=0 \
lcredit=0 ocredit=0 minclass=1 \
maxrepeat=0 maxsequence=0 \
maxclassrepeat=0 geoscheck=0 \
dictcheck=1 usercheck=1 \
enforcing=1 badwords="" \
dictpath=/usr/lib/cracklib/pw_dict
password required pam_unix.so sha512 shadow use_authtok
END
install -t /usr/share/licenses/libpwquality -Dm644 COPYING
cd ..
rm -rf libpwquality-1.4.4
# PAM module for libcap.
tar -xf libcap-2.66.tar.xz
cd libcap-2.66
make CFLAGS="$CFLAGS -fPIC" -C pam_cap
install -m755 pam_cap/pam_cap.so /usr/lib/security
install -m644 pam_cap/capability.conf /etc/security
cat > /etc/pam.d/system-auth << END
auth optional pam_cap.so
auth required pam_unix.so
END
cd ..
rm -rf libcap-2.66
# Shadow (initial build; will be rebuilt later to support AUDIT).
tar -xf shadow-4.12.3.tar.xz
cd shadow-4.12.3
patch -Np1 -i ../patches/shadow-4.12.2-MassOS.patch
touch /usr/bin/passwd
./configure --sysconfdir=/etc --disable-static --with-group-name-max-length=32 --with-libcrack
make
make exec_prefix=/usr install
make -C man install-man
mkdir -p /etc/default
useradd -D --gid 999
sed -i 's/yes/no/' /etc/default/useradd
pwconv
grpconv
for FUNCTION in FAIL_DELAY FAILLOG_ENAB LASTLOG_ENAB MAIL_CHECK_ENAB OBSCURE_CHECKS_ENAB PORTTIME_CHECKS_ENAB QUOTAS_ENAB CONSOLE MOTD_FILE FTMP_FILE NOLOGINS_FILE ENV_HZ PASS_MIN_LEN SU_WHEEL_ONLY CRACKLIB_DICTPATH PASS_CHANGE_TRIES PASS_ALWAYS_WARN CHFN_AUTH ENCRYPT_METHOD ENVIRON_FILE; do sed -i "s/^${FUNCTION}/# &/" /etc/login.defs; done
cat > /etc/pam.d/login << END
auth optional pam_faildelay.so delay=3000000
auth requisite pam_nologin.so
auth include system-auth
account required pam_access.so
account include system-account
session required pam_env.so
session required pam_limits.so
session optional pam_lastlog.so
session include system-session
password include system-password
END
cat > /etc/pam.d/passwd << END
password include system-password
END
cat > /etc/pam.d/su << END
auth sufficient pam_rootok.so
auth include system-auth
auth required pam_wheel.so use_uid
account include system-account
session required pam_env.so
session include system-session
END
cat > /etc/pam.d/chage << END
auth sufficient pam_rootok.so
auth include system-auth
account include system-account
session include system-session
password required pam_permit.so
END
for PROGRAM in chfn chgpasswd chpasswd chsh groupadd groupdel groupmems groupmod newusers useradd userdel usermod; do
install -m644 /etc/pam.d/chage /etc/pam.d/${PROGRAM}
sed -i "s/chage/$PROGRAM/" /etc/pam.d/${PROGRAM}
done
rm -f /etc/login.access /etc/limits
install -t /usr/share/licenses/shadow -Dm644 COPYING
cd ..
rm -rf shadow-4.12.3
# GCC.
tar -xf gcc-12.2.0.tar.xz
cd gcc-12.2.0
mkdir -p isl
tar -xf ../isl-0.25.tar.xz -C isl --strip-components=1
sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
mkdir build; cd build
CFLAGS="-O2" CXXFLAGS="-O2" LD=ld ../configure --prefix=/usr --enable-languages=c,c++ --with-pkgversion="MassOS GCC 12.2.0" --with-system-zlib --enable-default-ssp --enable-linker-build-id --disable-bootstrap --disable-multilib
make
make install
rm -rf /usr/lib/gcc/$(gcc -dumpmachine)/$(gcc -dumpversion)/include-fixed/bits/
ln -sr /usr/bin/cpp /usr/lib
ln -sf ../../libexec/gcc/$(gcc -dumpmachine)/$(gcc -dumpversion)/liblto_plugin.so /usr/lib/bfd-plugins/
mkdir -p /usr/share/gdb/auto-load/usr/lib
mv /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib
find /usr -depth -name x86_64-stage1-linux-gnu\* | xargs rm -rf
install -t /usr/share/licenses/gcc -Dm644 ../COPYING ../COPYING.LIB ../COPYING3 ../COPYING3.LIB ../COPYING.RUNTIME
cd ../..
rm -rf gcc-12.2.0
# pkg-config.
tar -xf pkg-config-0.29.2.tar.gz
cd pkg-config-0.29.2
./configure --prefix=/usr --with-internal-glib --disable-host-tool
make
make install
install -t /usr/share/licenses/pkg-config -Dm644 COPYING
cd ..
rm -rf pkg-config-0.29.2
# Ncurses.
tar -xf ncurses-6.3.tar.gz
cd ncurses-6.3
./configure --prefix=/usr --mandir=/usr/share/man --with-shared --without-debug --without-normal --enable-pc-files --enable-widec --with-pkg-config-libdir=/usr/lib/pkgconfig
make
make install
for lib in ncurses form panel menu; do
rm -f /usr/lib/lib${lib}.so
echo "INPUT(-l${lib}w)" > /usr/lib/lib${lib}.so
ln -sf ${lib}w.pc /usr/lib/pkgconfig/${lib}.pc
done
rm -f /usr/lib/libcursesw.so
echo "INPUT(-lncursesw)" > /usr/lib/libcursesw.so
chmod 755 /usr/lib/libcursesw.so
ln -sf libncurses.so /usr/lib/libcurses.so
rm -f /usr/lib/libncurses++w.a
install -t /usr/share/licenses/ncurses -Dm644 COPYING
cd ..
rm -rf ncurses-6.3
# libedit.
tar -xf libedit-20210910-3.1.tar.gz
cd libedit-20210910-3.1
sed -i 's/history.3//g' doc/Makefile.in
./configure --prefix=/usr --disable-static
make
make install
install -t /usr/share/licenses/libedit -Dm644 COPYING
cd ..
rm -rf libedit-20210910-3.1
# libsigsegv.
tar -xf libsigsegv-2.14.tar.gz
cd libsigsegv-2.14
./configure --prefix=/usr --enable-shared --disable-static
make
make install
install -t /usr/share/licenses/libsigsegv -Dm644 COPYING
cd ..
rm -rf libsigsegv-2.14
# Sed.
tar -xf sed-4.8.tar.xz
cd sed-4.8
./configure --prefix=/usr
make
make install
install -t /usr/share/licenses/sed -Dm644 COPYING
cd ..
rm -rf sed-4.8
# Gettext.
tar -xf gettext-0.21.tar.xz
cd gettext-0.21
./configure --prefix=/usr --disable-static
make
make install
chmod 0755 /usr/lib/preloadable_libintl.so
install -t /usr/share/licenses/gettext -Dm644 COPYING
cd ..
rm -rf gettext-0.21
# Bison.
tar -xf bison-3.8.2.tar.xz
cd bison-3.8.2
./configure --prefix=/usr
make
make install
install -t /usr/share/licenses/bison -Dm644 COPYING
cd ..
rm -rf bison-3.8.2
# Grep.
tar -xf grep-3.8.tar.xz
cd grep-3.8
./configure --prefix=/usr
make
make install
install -t /usr/share/licenses/grep -Dm644 COPYING
cd ..
rm -rf grep-3.8
# Bash.
tar -xf bash-5.2.tar.gz
cd bash-5.2
./configure --prefix=/usr --without-bash-malloc --with-installed-readline
make
make install
ln -sf bash.1 /usr/share/man/man1/sh.1
install -t /usr/share/licenses/bash -Dm644 COPYING
cd ..
rm -rf bash-5.2
# bash-completion.
tar -xf bash-completion-2.11.tar.xz
cd bash-completion-2.11
./configure --prefix=/usr --sysconfdir=/etc
make
make install
install -t /usr/share/licenses/bash-completion -Dm644 COPYING
cd ..
rm -rf bash-completion-2.11
# libtool.
tar -xf libtool-2.4.7.tar.xz
cd libtool-2.4.7
./configure --prefix=/usr
make
make install
rm -f /usr/lib/libltdl.a
install -t /usr/share/licenses/libtool -Dm644 COPYING
cd ..
rm -rf libtool-2.4.7
# GDBM.
tar -xf gdbm-1.23.tar.gz
cd gdbm-1.23
./configure --prefix=/usr --disable-static --enable-libgdbm-compat
make
make install
install -t /usr/share/licenses/gdbm -Dm644 COPYING
cd ..
rm -rf gdbm-1.23
# gperf.
tar -xf gperf-3.1.tar.gz
cd gperf-3.1
./configure --prefix=/usr
make
make install
install -t /usr/share/licenses/gperf -Dm644 COPYING
cd ..
rm -rf gperf-3.1
# Expat.
tar -xf expat-2.4.9.tar.xz
cd expat-2.4.9
./configure --prefix=/usr --disable-static
make
make install
install -t /usr/share/licenses/expat -Dm644 COPYING
cd ..
rm -rf expat-2.4.9
# libmetalink.
tar -xf libmetalink-0.1.3.tar.bz2
cd libmetalink-0.1.3
./configure --prefix=/usr --enable-static=no
make
make install
install -t /usr/share/licenses/libmetalink -Dm644 COPYING
cd ..
rm -rf libmetalink-0.1.3
# Inetutils.
tar -xf inetutils-2.3.tar.xz
cd inetutils-2.3
./configure --prefix=/usr --bindir=/usr/bin --localstatedir=/var --disable-logger --disable-whois --disable-rcp --disable-rexec --disable-rlogin --disable-rsh
make
make install
mv /usr/bin/ifconfig /usr/sbin/ifconfig
install -t /usr/share/licenses/inetutils -Dm644 COPYING
cd ..
rm -rf inetutils-2.3
# Netcat.
tar -xf netcat-0.7.1.tar.bz2
cd netcat-0.7.1
./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
make
make install
install -t /usr/share/licenses/netcat -Dm644 COPYING
cd ..
rm -rf netcat-0.7.1
# Less.
tar -xf less-608.tar.gz
cd less-608
./configure --prefix=/usr --sysconfdir=/etc
make
make install
install -t /usr/share/licenses/less -Dm644 COPYING LICENSE
cd ..
rm -rf less-608
# Lua.
tar -xf lua-5.4.4.tar.gz
cd lua-5.4.4
patch -Np1 -i ../patches/lua-5.4.4-sharedlib+pkgconfig.patch
cat src/lua.h | tail -n24 | head -n20 | sed -e 's/* //g' -e 's/*//g' > COPYING
make MYCFLAGS="$CFLAGS -fPIC" linux-readline
make INSTALL_DATA="cp -d" INSTALL_TOP=/usr INSTALL_MAN=/usr/share/man/man1 TO_LIB="liblua.so liblua.so.5.4 liblua.so.5.4.4" install
install -t /usr/lib/pkgconfig -Dm644 lua.pc
install -t /usr/share/licenses/lua -Dm644 COPYING
cd ..
rm -rf lua-5.4.4
# Perl.
tar -xf perl-5.36.0.tar.xz
cd perl-5.36.0
export BUILD_ZLIB=False BUILD_BZIP2=0
./Configure -des -Doptimize="$CFLAGS" -Dprefix=/usr -Dvendorprefix=/usr -Dprivlib=/usr/lib/perl5/5.36/core_perl -Darchlib=/usr/lib/perl5/5.36/core_perl -Dsitelib=/usr/lib/perl5/5.36/site_perl -Dsitearch=/usr/lib/perl5/5.36/site_perl -Dvendorlib=/usr/lib/perl5/5.36/vendor_perl -Dvendorarch=/usr/lib/perl5/5.36/vendor_perl -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dpager="/usr/bin/less -isR" -Duseshrplib -Dusethreads
make
make install
unset BUILD_ZLIB BUILD_BZIP2
install -t /usr/share/licenses/perl -Dm644 Copying
cd ..
rm -rf perl-5.36.0
# SGMLSpm
tar -xf SGMLSpm-1.1.tar.gz
cd SGMLSpm-1.1
chmod +w MYMETA.yml
perl Makefile.PL
make
make install
rm -f /usr/lib/perl5/5.36/core_perl/perllocal.pod
ln -sf sgmlspl.pl /usr/bin/sgmlspl
install -t /usr/share/licenses/sgmlspm -Dm644 COPYING
cd ..
rm -rf SGMLSpm-1.1
# XML::Parser.
tar -xf XML-Parser-2.46.tar.gz
cd XML-Parser-2.46
perl Makefile.PL
make
make install
cd ..
rm -rf XML-Parser-2.46
# Intltool.
tar -xf intltool-0.51.0.tar.gz
cd intltool-0.51.0
sed -i 's:\\\${:\\\$\\{:' intltool-update.in
./configure --prefix=/usr
make
make install
install -t /usr/share/licenses/intltool -Dm644 COPYING
cd ..
rm -rf intltool-0.51.0
# Autoconf.
tar -xf autoconf-2.71.tar.xz
cd autoconf-2.71
./configure --prefix=/usr
make
make install
install -t /usr/share/licenses/autoconf -Dm644 COPYING COPYINGv3 COPYING.EXCEPTION
cd ..
rm -rf autoconf-2.71
# Autoconf (legacy version 2.13).
tar -xf autoconf-2.13.tar.gz
cd autoconf-2.13
patch -Np1 -i ../patches/autoconf-2.13-consolidated_fixes-1.patch
mv autoconf.texi autoconf213.texi
rm autoconf.info
./configure --prefix=/usr --infodir=/usr/share/info --program-suffix=2.13
make
make install
install -m644 autoconf213.info /usr/share/info
install-info --info-dir=/usr/share/info autoconf213.info
install -t /usr/share/licenses/autoconf213 -Dm644 COPYING
cd ..
rm -rf autoconf-2.13
# Automake.
tar -xf automake-1.16.5.tar.xz
cd automake-1.16.5
./configure --prefix=/usr
make
make install
install -t /usr/share/licenses/automake -Dm644 COPYING
cd ..
rm -rf automake-1.16.5
# autoconf-archive.
tar -xf autoconf-archive-2021.02.19.tar.xz
cd autoconf-archive-2021.02.19
./configure --prefix=/usr
make
make install
cd ..
rm -rf autoconf-archive-2021.02.19
# PSmisc.
tar -xf psmisc-v23.5.tar.bz2
cd psmisc-v23.5
sed -i 's/UNKNOWN/23.5/g' misc/git-version-gen
./autogen.sh
./configure --prefix=/usr
make
make install
install -t /usr/share/licenses/psmisc -Dm644 COPYING
cd ..
rm -rf psmisc-v23.5
# elfutils.
tar -xf elfutils-0.187.tar.bz2
cd elfutils-0.187
CFLAGS="-O2" CXXFLAGS="-O2" ./configure --prefix=/usr --program-prefix="eu-" --disable-debuginfod --enable-libdebuginfod=dummy
make
make install
rm -f /usr/lib/lib{asm,dw,elf}.a
install -t /usr/share/licenses/elfutils -Dm644 COPYING COPYING-GPLV2 COPYING-LGPLV3
cd ..
rm -rf elfutils-0.187
# libbpf.
tar -xf libbpf-1.0.0.tar.gz
cd libbpf-1.0.0/src
make
make LIBSUBDIR=lib install
rm -f /usr/lib/libbpf.a
install -t /usr/share/licenses/libbpf -Dm644 ../LICENSE{,.BSD-2-Clause,.LGPL-2.1}
cd ../..
rm -rf libbpf-1.0.0
# patchelf.
tar -xf patchelf-0.14.5.tar.bz2
cd patchelf-0.14.5
./configure --prefix=/usr
make
make install
install -t /usr/share/licenses/patchelf -Dm644 COPYING
cd ..
rm -rf patchelf-0.14.5
# strace.
tar -xf strace-5.19.tar.xz
cd strace-5.19
./configure --prefix=/usr --with-libdw
make
make install
install -t /usr/share/licenses/strace -Dm644 COPYING LGPL-2.1-or-later
cd ..
rm -rf strace-5.19
# libffi.
tar -xf libffi-3.4.3.tar.gz
cd libffi-3.4.3
./configure --prefix=/usr --disable-static --disable-exec-static-tramp
make
make install
install -t /usr/share/licenses/libffi -Dm644 LICENSE
cd ..
rm -rf libffi-3.4.3
# OpenSSL.
tar -xf openssl-3.0.5.tar.gz
cd openssl-3.0.5
./config --prefix=/usr --openssldir=/etc/ssl --libdir=lib shared zlib-dynamic
make
sed -i '/INSTALL_LIBS/s/libcrypto.a libssl.a//' Makefile
make MANSUFFIX=ssl install
install -t /usr/share/licenses/openssl -Dm644 LICENSE.txt
cd ..
rm -rf openssl-3.0.5
# easy-rsa.
tar -xf EasyRSA-3.1.0.tgz
cd EasyRSA-3.1.0
install -Dm755 easyrsa /usr/bin/easyrsa
install -Dm644 openssl-easyrsa.cnf /etc/easy-rsa/openssl-easyrsa.cnf
install -Dm644 vars.example /etc/easy-rsa/vars
install -dm755 /etc/easy-rsa/x509-types/
install -m644 x509-types/* /etc/easy-rsa/x509-types/
install -t /usr/share/licenses/easy-rsa -Dm644 COPYING.md gpl-2.0.txt
cd ..
rm -rf EasyRSA-3.1.0
# mpdecimal.
tar -xf mpdecimal-2.5.1.tar.gz
cd mpdecimal-2.5.1
./configure --prefix=/usr
make
make install
rm -f /usr/lib/libmpdec{,++}.a
install -t /usr/share/licenses/mpdecimal -Dm644 LICENSE.txt
cd ..
rm -rf mpdecimal-2.5.1
# kmod.
tar -xf kmod-30.tar.xz
cd kmod-30
./configure --prefix=/usr --sysconfdir=/etc --with-xz --with-zstd --with-zlib --with-openssl
make
make install
for target in depmod insmod modinfo modprobe rmmod; do ln -sf ../bin/kmod /usr/sbin/$target; done
ln -sf kmod /usr/bin/lsmod
install -t /usr/share/licenses/kmod -Dm644 COPYING
cd ..
rm -rf kmod-30
# Python (initial build; will be rebuilt later to support SQLite and Tk).
tar -xf Python-3.10.7.tar.xz
cd Python-3.10.7
./configure --prefix=/usr --enable-shared --with-system-expat --with-system-ffi --with-system-libmpdec --with-ensurepip=yes --enable-optimizations --disable-test-modules
make
make install
ln -sf python3 /usr/bin/python
ln -sf pydoc3 /usr/bin/pydoc
ln -sf idle3 /usr/bin/idle
ln -sf python3-config /usr/bin/python-config
ln -sf pip3 /usr/bin/pip
install -t /usr/share/licenses/python -Dm644 LICENSE
cd ..
rm -rf Python-3.10.7
# Sphinx (required to build man pages of some packages).
mkdir -p sphinx
tar -xf sphinx-5.1.1-x86_64-py3.10-venv.tar.xz -C sphinx --strip-components=1
# Ninja.
tar -xf ninja-1.11.1.tar.gz
cd ninja-1.11.1
python configure.py --bootstrap
install -m755 ninja /usr/bin
install -Dm644 misc/bash-completion /usr/share/bash-completion/completions/ninja
install -Dm644 misc/zsh-completion /usr/share/zsh/site-functions/_ninja
install -t /usr/share/licenses/ninja -Dm644 COPYING
cd ..
rm -rf ninja-1.11.1
# Meson.
tar -xf meson-0.63.2.tar.gz
cd meson-0.63.2
python setup.py build
python setup.py install --root=meson-destination-directory
cp -r meson-destination-directory/* /
install -Dm644 data/shell-completions/bash/meson /usr/share/bash-completion/completions/meson
install -Dm644 data/shell-completions/zsh/_meson /usr/share/zsh/site-functions/_meson
install -t /usr/share/licenses/meson -Dm644 COPYING
cd ..
rm -rf meson-0.63.2
# PyParsing.
tar -xf pyparsing_3.0.7.tar.gz
cd pyparsing-pyparsing_3.0.7
python setup.py build
python setup.py install --prefix=/usr --optimize=1
install -t /usr/share/licenses/pyparsing -Dm644 LICENSE
cd ..
rm -rf pyparsing-pyparsing_3.0.7
# packaging (required by UPower since 0.99.18).
tar -xf packaging-21.3.tar.gz
cd packaging-21.3
python setup.py install --optimize=1
install -t /usr/share/licenses/packaging -Dm644 LICENSE{,.APACHE,.BSD}
cd ..
rm -rf packaging-21.3
# six.
tar -xf six-1.16.0.tar.gz
cd six-1.16.0
python setup.py install --optimize=1
install -t /usr/share/licenses/six -Dm644 LICENSE
cd ..
rm -rf six-1.16.0
# distro.
tar -xf distro-1.6.0.tar.gz
cd distro-1.6.0
python setup.py build
python setup.py install --skip-build
install -t /usr/share/licenses/distro -Dm644 LICENSE
cd ..
rm -rf distro-1.6.0
# libseccomp.
tar -xf libseccomp-2.5.4.tar.gz
cd libseccomp-2.5.4
./configure --prefix=/usr --disable-static
make
make install
install -t /usr/share/licenses/libseccomp -Dm644 LICENSE
cd ..
rm -rf libseccomp-2.5.4
# File.
tar -xf file-5.43.tar.gz
cd file-5.43
./configure --prefix=/usr --enable-libseccomp
make
make install
install -t /usr/share/licenses/file -Dm644 COPYING
cd ..
rm -rf file-5.43
# Coreutils.
tar -xf coreutils-9.1.tar.xz
cd coreutils-9.1
patch -Np1 -i ../patches/coreutils-9.1-progressbar.patch
./configure --prefix=/usr --enable-no-install-program=kill,uptime --with-packager="MassOS"
make
make install