From ef16e3ac0a88e6376490b9a7e5bc66a7e05844c6 Mon Sep 17 00:00:00 2001 From: airone01 <21955960+airone01@users.noreply.github.com> Date: Thu, 12 Feb 2026 18:02:52 +0100 Subject: [PATCH] feat: ft_linux --- .gitattributes | 4 + pcc/ft_linux/.gitignore | 5 + pcc/ft_linux/README.md | 39 ++++ pcc/ft_linux/downloads/LFS-BOOK-12.4.pdf | Bin 0 -> 132 bytes pcc/ft_linux/downloads/check_host_deps.sh | 80 ++++++++ .../downloads/lfs-bootscripts-20250827.tar.xz | 3 + pcc/ft_linux/downloads/md5sums | 94 +++++++++ pcc/ft_linux/downloads/wget-list | 95 ++++++++++ pcc/ft_linux/lfs.sh | 179 ++++++++++++++++++ 9 files changed, 499 insertions(+) create mode 100644 pcc/ft_linux/.gitignore create mode 100644 pcc/ft_linux/README.md create mode 100755 pcc/ft_linux/downloads/LFS-BOOK-12.4.pdf create mode 100755 pcc/ft_linux/downloads/check_host_deps.sh create mode 100755 pcc/ft_linux/downloads/lfs-bootscripts-20250827.tar.xz create mode 100755 pcc/ft_linux/downloads/md5sums create mode 100755 pcc/ft_linux/downloads/wget-list create mode 100755 pcc/ft_linux/lfs.sh diff --git a/.gitattributes b/.gitattributes index 5ca71036..ea3e3282 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,3 +3,7 @@ *.jpg filter=lfs diff=lfs merge=lfs -text *.png filter=lfs diff=lfs merge=lfs -text *.jpeg filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text diff --git a/pcc/ft_linux/.gitignore b/pcc/ft_linux/.gitignore new file mode 100644 index 00000000..64a42ca6 --- /dev/null +++ b/pcc/ft_linux/.gitignore @@ -0,0 +1,5 @@ +images/ +lfs*.tar.gz +tooling*.tar.gz +*.iso* + diff --git a/pcc/ft_linux/README.md b/pcc/ft_linux/README.md new file mode 100644 index 00000000..215c5e31 --- /dev/null +++ b/pcc/ft_linux/README.md @@ -0,0 +1,39 @@ +# LFS + +This project is a home-made distro made by following [Linux From Scratch](https://www.linuxfromscratch.org/lfs/). +This was made as [42](https://42.fr/en/homepage/)'s `ft_linux` project. + +## Subject + +The subject provided by 42 asks students to implement LFS, and then make some +changes to the final LFS implementation. I will not be detailing those changes +here, because 42 is awesome and I don't want to leak the subjects. +Come to 42 if you want to find out! + +## Implementation details + +- This distro was made by following [LFS 12.4](https://www.linuxfromscratch.org/lfs/view/12.4/) ([permalink](https://web.archive.org/web/20250922045138/https://www.linuxfromscratch.org/lfs/view/12.4/)) and some parts of BLFS. +- The "host" distro was actually an Alpine system I set up on another qcow2. +- The kernel version is 6.16 + +## What I learned + +- 24 cores CPU and 16GB RAM is good, but what gives speed is not running the VM on an USB stick. Learned the hard way. +- I dreaded compiling the kernel, but it wasn't nearly as bad as compiling GCC 3 times. +- The more I read documentation, compiled and tested packages, the more I understood why those packages and why they were made this way. + - So I would like to ask forgiveness for the gods and goddesses of GNU/Linux who have blessed us with this amazing OS for all the times I complained about how anything worked. +- Turns out `autoconf` and `automake` are fucking awesome. +- I now truly understand the need for a deterministic build system, and hence why Nix and Guix exist. +- Why is Python the only package that has its archive name starting with a capital "P"? (except XML-Parser, but I really want to hate on Python, let's just pretend `XML-Parser-2.47.tar.gz` is spelled in snake case like the rest) +- LFS team, thank you for taking the time to make the `wget-list` and `md5sums` files. + - And thank you for LFS. It rocks. + - And thank you for all the little notes and comments, saved me hours of rebuilding. +- Saying RTFM is a dick move but turns out you do get better by reading docs. + +## Submission + +Nothing for this project is submitted through a git repo, all is in the VM, so this repository is pointless, except for the cool utility script. + +But I did make the repo anyways as you can see, just to brag that I finished LFS. So here we are. +You can see some screenshots below because of course I took screenshots. + diff --git a/pcc/ft_linux/downloads/LFS-BOOK-12.4.pdf b/pcc/ft_linux/downloads/LFS-BOOK-12.4.pdf new file mode 100755 index 0000000000000000000000000000000000000000..bbc6e491122d2487c71a934d8e301172ebb0fb26 GIT binary patch literal 132 zcmWN|yAi`63;@vHQ?NkH&q&~HKtSLw3BCxs$nWu+ P /dev/null 2> /dev/null || bail "grep does not work" +sed '' /dev/null || bail "sed does not work" +sort /dev/null || bail "sort does not work" +ver_check() +{ +if ! type -p $2 &>/dev/null +then +echo "ERROR: Cannot find $2 ($1)"; return 1; +fi +v=$($2 --version 2>&1 | grep -E -o '[0-9]+\.[0-9\.]+[a-z]*' | head -n1) +if printf '%s\n' $3 $v | sort --version-sort --check &>/dev/null +then +printf "OK: %-9s %-6s >= $3\n" "$1" "$v"; return 0; +else +printf "ERROR: %-9s is TOO OLD ($3 or later required)\n" "$1"; +return 1; +fi +} +ver_kernel() +{ + kver=$(uname -r | grep -E -o '^[0-9\.]+') +if printf '%s\n' $1 $kver | sort --version-sort --check &>/dev/null +then +printf "OK: Linux Kernel $kver >= $1\n"; return 0; +else +printf "ERROR: Linux Kernel ($kver) is TOO OLD ($1 or later required)\n" "$kver"; +return 1; +fi +} +# Coreutils first because --version-sort needs Coreutils >= 7.0 +ver_check Coreutils sort 8.1 || bail "Coreutils too old, stop" +ver_check Bash bash 3.2 +ver_check Binutils ld 2.13.1 +ver_check Bison bison 2.7 +ver_check Diffutils diff 2.8.1 +ver_check Findutils find 4.2.31 +ver_check Gawk gawk 4.0.1 +ver_check GCC gcc 5.4 +ver_check "GCC (C++)" g++ 5.4 +ver_check Grep grep 2.5.1a +ver_check Gzip gzip 1.3.12 +ver_check M4 m4 1.4.10 +ver_check Make make 4.0 +ver_check Patch patch 2.5.4 +ver_check Perl perl 5.8.8 +ver_check Python python3 3.4 +ver_check Sed sed 4.1.5 +ver_check Tar tar 1.22 +ver_check Texinfo texi2any 5.0 +ver_check Xz xz 5.0.0 +ver_kernel 5.4 +if mount | grep -q 'devpts on /dev/pts' && [ -e /dev/ptmx ] +then echo "OK: Linux Kernel supports UNIX 98 PTY"; +else echo "ERROR: Linux Kernel does NOT support UNIX 98 PTY"; fi +alias_check() { +if $1 --version 2>&1 | grep -qi $2 +then printf "OK: %-4s is $2\n" "$1"; +else printf "ERROR: %-4s is NOT $2\n" "$1"; fi +} +echo "Aliases:" +alias_check awk GNU +alias_check yacc Bison +alias_check sh Bash +echo "Compiler check:" +if printf "int main(){}" | g++ -x c++ - +then echo "OK: g++ works"; +else echo "ERROR: g++ does NOT work"; fi +rm -f a.out +if [ "$(nproc)" = "" ]; then +echo "ERROR: nproc is not available or it produces empty output" +else +echo "OK: nproc reports $(nproc) logical cores are available" +fi diff --git a/pcc/ft_linux/downloads/lfs-bootscripts-20250827.tar.xz b/pcc/ft_linux/downloads/lfs-bootscripts-20250827.tar.xz new file mode 100755 index 00000000..f30bf3e6 --- /dev/null +++ b/pcc/ft_linux/downloads/lfs-bootscripts-20250827.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:13ee5d50b7a35f4d94760d9f7617a3f17af3e0a33118f415eb898a0276db47b3 +size 34196 diff --git a/pcc/ft_linux/downloads/md5sums b/pcc/ft_linux/downloads/md5sums new file mode 100755 index 00000000..c4813aa4 --- /dev/null +++ b/pcc/ft_linux/downloads/md5sums @@ -0,0 +1,94 @@ +590765dee95907dbc3c856f7255bd669 acl-2.3.2.tar.xz +227043ec2f6ca03c0948df5517f9c927 attr-2.5.2.tar.gz +1be79f7106ab6767f18391c5e22be701 autoconf-2.72.tar.xz +cea31dbf1120f890cbf2a3032cfb9a68 automake-1.18.1.tar.xz +977c8c0c5ae6309191e7768e28ebc951 bash-5.3.tar.gz +ad4db5a0eb4fdbb3f6813be4b6b3da74 bc-7.0.3.tar.xz +dee5b4267e0305a99a3c9d6131f45759 binutils-2.45.tar.xz +c28f119f405a2304ff0a7ccdcc629713 bison-3.8.2.tar.xz +67e051268d0c475ea773822f7500d0e5 bzip2-1.0.8.tar.gz +6b7285faf7d5eb91592bdd689270d3f1 coreutils-9.7.tar.xz +68c5208c58236eba447d7d6d1326b821 dejagnu-1.6.3.tar.gz +d1b18b20868fb561f77861cd90b05de4 diffutils-3.12.tar.xz +113d7a7ee0710d2a670a44692a35fd2e e2fsprogs-1.47.3.tar.gz +ceefa052ded950a4c523688799193a44 elfutils-0.193.tar.bz2 +9f0c266ff4b9720beae0c6bd53ae4469 expat-2.7.1.tar.xz +00fce8de158422f5ccd2666512329bd2 expect5.45.4.tar.gz +459da2d4b534801e2e2861611d823864 file-5.46.tar.gz +870cfd71c07d37ebe56f9f4aaf4ad872 findutils-4.10.0.tar.xz +2882e3179748cc9f9c23ec593d6adc8d flex-2.6.4.tar.gz +c538415c1f27bd69cbbbf3cdd5135d39 flit_core-3.12.0.tar.gz +b7014650c5f45e5d4837c31209dc0037 gawk-5.3.2.tar.xz +b861b092bf1af683c46a8aa2e689a6fd gcc-15.2.0.tar.xz +aaa600665bc89e2febb3c7bd90679115 gdbm-1.26.tar.gz +8e14e926f088e292f5f2bce95b81d10e gettext-0.26.tar.xz +23c6f5a27932b435cae94e087cb8b1f5 glibc-2.42.tar.xz +956dc04e864001a9c22429f761f2c283 gmp-6.3.0.tar.xz +31753b021ea78a21f154bf9eecb8b079 gperf-3.3.tar.gz +5d9301ed9d209c4a88c8d3a6fd08b9ac grep-3.12.tar.xz +5e4f40315a22bb8a158748e7d5094c7d groff-1.23.0.tar.gz +60c564b1bdc39d8e43b3aab4bc0fb140 grub-2.12.tar.xz +4bf5a10f287501ee8e8ebe00ef62b2c2 gzip-1.14.tar.xz +de0a909103d4ff59d1424c5ec7ac9e4a iana-etc-20250807.tar.gz +401d7d07682a193960bcdecafd03de94 inetutils-2.6.tar.xz +12e517cac2b57a0121cda351570f1e63 intltool-0.51.0.tar.gz +80e1f91bf59d572acc15d5c6eb4f3e7c iproute2-6.16.0.tar.xz +66d4c25ff43d1deaf9637ccda523dec8 jinja2-3.1.6.tar.gz +24b5d24f7483726b88f214dc6c77aa41 kbd-2.8.0.tar.xz +36f2cc483745e81ede3406fa55e1065a kmod-34.2.tar.xz +0386dc14f6a081a94dfb4c2413864eed less-679.tar.gz +3f661c64c2dfb55025767ed56074d059 lfs-bootscripts-20250827.tar.xz +449ade7d620b5c4eeb15a632fbaa4f74 libcap-2.76.tar.xz +92af9efad4ba398995abf44835c5d9e9 libffi-3.5.2.tar.gz +17ac6969b2015386bcb5d278a08a40b5 libpipeline-1.5.8.tar.gz +22e0a29df8af5fdde276ea3a7d351d30 libtool-2.5.4.tar.xz +1796a5d20098e9dd9e3f576803c83000 libxcrypt-4.4.38.tar.xz +32d45755e4b39d06e9be58f6817445ee linux-6.16.1.tar.xz +dead9f5f1966d9ae56e1e32761e4e675 lz4-1.10.0.tar.gz +6eb2ebed5b24e74b6e890919331d2132 m4-1.4.20.tar.xz +c8469a3713cbbe04d955d4ae4be23eeb make-4.4.1.tar.gz +b6335533cbeac3b24cd7be31fdee8c83 man-db-2.13.1.tar.xz +16f68d70139dd2bbcae4102be4705753 man-pages-6.15.tar.xz +cb0071711b573b155cc8f86e1de72167 markupsafe-3.0.2.tar.gz +08221d2f515e759686f666ff6409a903 meson-1.8.3.tar.gz +5c9bc658c9fd0f940e8e3e0f09530c62 mpc-1.3.1.tar.gz +7c32c39b8b6e3ae85f25156228156061 mpfr-4.2.2.tar.xz +679987405412f970561cc85e1e6428a2 ncurses-6.5-20250809.tgz +c35f8f55f4cf60f1a916068d8f45a0f8 ninja-1.13.1.tar.gz +890fc59f86fc21b5e4d1c031a698dbde openssl-3.5.2.tar.gz +ab0ef21ddebe09d1803575120d3f99f8 packaging-25.0.tar.gz +149327a021d41c8f88d034eab41c039f patch-2.8.tar.xz +7a6950a9f12d01eb96a9d2ed2f4e0072 perl-5.42.0.tar.xz +3291128c917fdb8fccd8c9e7784b643b pkgconf-2.5.1.tar.xz +90803e64f51f192f3325d25c3335d057 procps-ng-4.0.5.tar.xz +53eae841735189a896d614cba440eb10 psmisc-23.7.tar.xz +256cdb3bbf45cdce7499e52ba6c36ea3 Python-3.13.7.tar.xz +b84c0d81b2758398bb7f5b7411d3d908 python-3.13.7-docs-html.tar.bz2 +25a73bfb2a3ad7146c5e9d4408d9f6cd readline-8.3.tar.gz +6aac9b2dbafcd5b7a67a8a9bcb8036c3 sed-4.9.tar.xz +82e1d67883b713f9493659b50d13b436 setuptools-80.9.0.tar.gz +30ef46f54363db1d624587be68794ef2 shadow-4.18.0.tar.xz +af60786956a2dc84054fbf46652e515e sysklogd-2.7.2.tar.gz +25fe5d328e22641254761f1baa74cee0 systemd-257.8.tar.gz +a44063e2ec0cf4adfd2ed5c9e9e095c5 systemd-man-pages-257.8.tar.xz +bc6890b975d19dc9db42d0c7364dd092 sysvinit-3.14.tar.xz +a2d8042658cfd8ea939e6d911eaf4152 tar-1.35.tar.xz +eaef5d0a27239fb840f04af8ec608242 tcl8.6.16-src.tar.gz +750c221bcb6f8737a6791c1fbe98b684 tcl8.6.16-html.tar.gz +11939a7624572814912a18e76c8d8972 texinfo-7.2.tar.xz +ad65154c48c74a9b311fe84778c5434f tzdata2025b.tar.gz +acd4360d8a5c3ef320b9db88d275dae6 udev-lfs-20230818.tar.xz +7e5e68845e2f347cf96f5448165f1764 util-linux-2.41.1.tar.xz +4f856c3233c1c4570bc17572e4f9e8e4 vim-9.1.1629.tar.gz +65e09ee84af36821e3b1e9564aa91bd5 wheel-0.46.1.tar.gz +89a8e82cfd2ad948b349c0a69c494463 XML-Parser-2.47.tar.gz +cf5e1feb023d22c6bdaa30e84ef3abe3 xz-5.8.1.tar.xz +9855b6d802d7fe5b7bd5b196a2271655 zlib-1.3.1.tar.gz +780fc1896922b1bc52a4e90980cdda48 zstd-1.5.7.tar.gz +6a5ac7e89b791aae556de0f745916f7f bzip2-1.0.8-install_docs-1.patch +96382a5aa85d6651a74f94ffb61785d9 coreutils-9.7-upstream_fix-1.patch +33ebfad32b2dfb8417c3335c08671206 coreutils-9.7-i18n-1.patch +0ca4d6bb8d572fbcdb13cb36cd34833e expect-5.45.4-gcc15-1.patch +9a5997c3452909b1769918c759eff8a2 glibc-2.42-fhs-1.patch +f75cca16a38da6caa7d52151f7136895 kbd-2.8.0-backspace-1.patch +3af8fd8e13cad481eeeaa48be4247445 sysvinit-3.14-consolidated-1.patch diff --git a/pcc/ft_linux/downloads/wget-list b/pcc/ft_linux/downloads/wget-list new file mode 100755 index 00000000..994814e7 --- /dev/null +++ b/pcc/ft_linux/downloads/wget-list @@ -0,0 +1,95 @@ +https://download.savannah.gnu.org/releases/acl/acl-2.3.2.tar.xz +https://download.savannah.gnu.org/releases/attr/attr-2.5.2.tar.gz +https://ftp.gnu.org/gnu/autoconf/autoconf-2.72.tar.xz +https://ftp.gnu.org/gnu/automake/automake-1.18.1.tar.xz +https://ftp.gnu.org/gnu/bash/bash-5.3.tar.gz +https://github.com/gavinhoward/bc/releases/download/7.0.3/bc-7.0.3.tar.xz +https://sourceware.org/pub/binutils/releases/binutils-2.45.tar.xz +https://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.xz +https://www.sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz +https://ftp.gnu.org/gnu/coreutils/coreutils-9.7.tar.xz +https://dbus.freedesktop.org/releases/dbus/dbus-1.16.2.tar.xz +https://ftp.gnu.org/gnu/dejagnu/dejagnu-1.6.3.tar.gz +https://ftp.gnu.org/gnu/diffutils/diffutils-3.12.tar.xz +https://downloads.sourceforge.net/project/e2fsprogs/e2fsprogs/v1.47.3/e2fsprogs-1.47.3.tar.gz +https://sourceware.org/ftp/elfutils/0.193/elfutils-0.193.tar.bz2 +https://github.com/libexpat/libexpat/releases/download/R_2_7_1/expat-2.7.1.tar.xz +https://prdownloads.sourceforge.net/expect/expect5.45.4.tar.gz +https://astron.com/pub/file/file-5.46.tar.gz +https://ftp.gnu.org/gnu/findutils/findutils-4.10.0.tar.xz +https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz +https://pypi.org/packages/source/f/flit-core/flit_core-3.12.0.tar.gz +https://ftp.gnu.org/gnu/gawk/gawk-5.3.2.tar.xz +https://ftp.gnu.org/gnu/gcc/gcc-15.2.0/gcc-15.2.0.tar.xz +https://ftp.gnu.org/gnu/gdbm/gdbm-1.26.tar.gz +https://ftp.gnu.org/gnu/gettext/gettext-0.26.tar.xz +https://ftp.gnu.org/gnu/glibc/glibc-2.42.tar.xz +https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz +https://ftp.gnu.org/gnu/gperf/gperf-3.3.tar.gz +https://ftp.gnu.org/gnu/grep/grep-3.12.tar.xz +https://ftp.gnu.org/gnu/groff/groff-1.23.0.tar.gz +https://ftp.gnu.org/gnu/grub/grub-2.12.tar.xz +https://ftp.gnu.org/gnu/gzip/gzip-1.14.tar.xz +https://github.com/Mic92/iana-etc/releases/download/20250807/iana-etc-20250807.tar.gz +https://ftp.gnu.org/gnu/inetutils/inetutils-2.6.tar.xz +https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz +https://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-6.16.0.tar.xz +https://pypi.org/packages/source/J/Jinja2/jinja2-3.1.6.tar.gz +https://www.kernel.org/pub/linux/utils/kbd/kbd-2.8.0.tar.xz +https://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-34.2.tar.xz +https://www.greenwoodsoftware.com/less/less-679.tar.gz +https://www.linuxfromscratch.org/lfs/downloads/12.4/lfs-bootscripts-20250827.tar.xz +https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.76.tar.xz +https://github.com/libffi/libffi/releases/download/v3.5.2/libffi-3.5.2.tar.gz +https://download.savannah.gnu.org/releases/libpipeline/libpipeline-1.5.8.tar.gz +https://ftp.gnu.org/gnu/libtool/libtool-2.5.4.tar.xz +https://github.com/besser82/libxcrypt/releases/download/v4.4.38/libxcrypt-4.4.38.tar.xz +https://www.kernel.org/pub/linux/kernel/v6.x/linux-6.16.1.tar.xz +https://github.com/lz4/lz4/releases/download/v1.10.0/lz4-1.10.0.tar.gz +https://ftp.gnu.org/gnu/m4/m4-1.4.20.tar.xz +https://ftp.gnu.org/gnu/make/make-4.4.1.tar.gz +https://download.savannah.gnu.org/releases/man-db/man-db-2.13.1.tar.xz +https://www.kernel.org/pub/linux/docs/man-pages/man-pages-6.15.tar.xz +https://pypi.org/packages/source/M/MarkupSafe/markupsafe-3.0.2.tar.gz +https://github.com/mesonbuild/meson/releases/download/1.8.3/meson-1.8.3.tar.gz +https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz +https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.2.tar.xz +https://invisible-mirror.net/archives/ncurses/current/ncurses-6.5-20250809.tgz +https://github.com/ninja-build/ninja/archive/v1.13.1/ninja-1.13.1.tar.gz +https://github.com/openssl/openssl/releases/download/openssl-3.5.2/openssl-3.5.2.tar.gz +https://files.pythonhosted.org/packages/source/p/packaging/packaging-25.0.tar.gz +https://ftp.gnu.org/gnu/patch/patch-2.8.tar.xz +https://www.cpan.org/src/5.0/perl-5.42.0.tar.xz +https://distfiles.ariadne.space/pkgconf/pkgconf-2.5.1.tar.xz +https://sourceforge.net/projects/procps-ng/files/Production/procps-ng-4.0.5.tar.xz +https://sourceforge.net/projects/psmisc/files/psmisc/psmisc-23.7.tar.xz +https://www.python.org/ftp/python/3.13.7/Python-3.13.7.tar.xz +https://www.python.org/ftp/python/doc/3.13.7/python-3.13.7-docs-html.tar.bz2 +https://ftp.gnu.org/gnu/readline/readline-8.3.tar.gz +https://ftp.gnu.org/gnu/sed/sed-4.9.tar.xz +https://pypi.org/packages/source/s/setuptools/setuptools-80.9.0.tar.gz +https://github.com/shadow-maint/shadow/releases/download/4.18.0/shadow-4.18.0.tar.xz +https://github.com/troglobit/sysklogd/releases/download/v2.7.2/sysklogd-2.7.2.tar.gz +https://github.com/systemd/systemd/archive/v257.8/systemd-257.8.tar.gz +https://anduin.linuxfromscratch.org/LFS/systemd-man-pages-257.8.tar.xz +https://github.com/slicer69/sysvinit/releases/download/3.14/sysvinit-3.14.tar.xz +https://ftp.gnu.org/gnu/tar/tar-1.35.tar.xz +https://downloads.sourceforge.net/tcl/tcl8.6.16-src.tar.gz +https://downloads.sourceforge.net/tcl/tcl8.6.16-html.tar.gz +https://ftp.gnu.org/gnu/texinfo/texinfo-7.2.tar.xz +https://www.iana.org/time-zones/repository/releases/tzdata2025b.tar.gz +https://anduin.linuxfromscratch.org/LFS/udev-lfs-20230818.tar.xz +https://www.kernel.org/pub/linux/utils/util-linux/v2.41/util-linux-2.41.1.tar.xz +https://github.com/vim/vim/archive/v9.1.1629/vim-9.1.1629.tar.gz +https://pypi.org/packages/source/w/wheel/wheel-0.46.1.tar.gz +https://cpan.metacpan.org/authors/id/T/TO/TODDR/XML-Parser-2.47.tar.gz +https://github.com//tukaani-project/xz/releases/download/v5.8.1/xz-5.8.1.tar.xz +https://zlib.net/fossils/zlib-1.3.1.tar.gz +https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz +https://www.linuxfromscratch.org/patches/lfs/12.4/bzip2-1.0.8-install_docs-1.patch +https://www.linuxfromscratch.org/patches/lfs/12.4/coreutils-9.7-upstream_fix-1.patch +https://www.linuxfromscratch.org/patches/lfs/12.4/coreutils-9.7-i18n-1.patch +https://www.linuxfromscratch.org/patches/lfs/12.4/expect-5.45.4-gcc15-1.patch +https://www.linuxfromscratch.org/patches/lfs/12.4/glibc-2.42-fhs-1.patch +https://www.linuxfromscratch.org/patches/lfs/12.4/kbd-2.8.0-backspace-1.patch +https://www.linuxfromscratch.org/patches/lfs/12.4/sysvinit-3.14-consolidated-1.patch diff --git a/pcc/ft_linux/lfs.sh b/pcc/ft_linux/lfs.sh new file mode 100755 index 00000000..be8f2783 --- /dev/null +++ b/pcc/ft_linux/lfs.sh @@ -0,0 +1,179 @@ +#!/usr/bin/env bash + +# ============================================================================== +# Configuration +# ============================================================================== + +# Determine ROOT_DIR based on the script's location (assumes script is in ROOT/scripts/) +ROOT_DIR=$(realpath $( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )) + +# Path definitions +DISK_IMG_MAIN="$ROOT_DIR/images/tooling.qcow2" +DISK_IMG_LFS="$ROOT_DIR/images/lfs.qcow2" + +# VM Resources +# LFS_NPROC="20" +LFS_NPROC="$(nproc)" +LFS_RAM="8" + +# Rclone Target +RCLONE_TARGET="GDrive:/LinuxBackups/lsb" + +# ============================================================================== +# Helper Functions +# ============================================================================== + +confirm_and_run() { + local cmd_str="$1" + + echo -e "\n\033[1;33mPreparing to execute:\033[0m" + echo -e "\033[0;32m$ $cmd_str\033[0m" + + read -p "Execute this command? [y/N] " response + if [[ "$response" =~ ^[yY]$ ]]; then + eval "$cmd_str" + else + echo "Operation cancelled." + fi + + echo + read -p "Press Enter to continue..." +} + +run_backup_tooling() { + local max_id=0 + + # Loop through files matching the pattern in ROOT_DIR + # We use nullglob to handle the case where no files exist + shopt -s nullglob + for archive in "$ROOT_DIR"/tooling.*.tar.gz; do + # Extract filename + local fname=$(basename "$archive") + # Extract the number between 'tooling.' and '.tar.gz' + local num="${fname#tooling.}" + num="${num%.tar.gz}" + + # Check if it is an integer and greater than current max + if [[ "$num" =~ ^[0-9]+$ ]] && (( num > max_id )); then + max_id=$num + fi + done + shopt -u nullglob + + local next_id=$((max_id + 1)) + local backup_file="$ROOT_DIR/tooling.${next_id}.tar.gz" + + local total_size=$(du -cb "$DISK_IMG_MAIN" 2>/dev/null | tail -n1 | awk '{print $1}') + + read -p "Enter compression level for tooling (recommended 6) [0-9]: " level + while [[ ! "$level" =~ ^[0-9]$ ]] || [ "$level" -lt 0 ] || [ "$level" -gt 9 ]; do + echo "Invalid input. Please enter a number between 0 and 9." + read -p "Enter compression level for tooling (recommended 6) [0-9]: " level + done + + local cmd="tar -C \"$ROOT_DIR/images/\" -cf - \"tooling.qcow2\" | pv -s $total_size | gzip -$level > \"$backup_file\"" + + confirm_and_run "$cmd" +} + +run_backup_lfs() { + local max_id=0 + + # Loop through files matching the pattern in ROOT_DIR + # We use nullglob to handle the case where no files exist + shopt -s nullglob + for archive in "$ROOT_DIR"/lfs.*.tar.gz; do + # Extract filename + local fname=$(basename "$archive") + # Extract the number between 'lfs.' and '.tar.gz' + local num="${fname#lfs.}" + num="${num%.tar.gz}" + + # Check if it is an integer and greater than current max + if [[ "$num" =~ ^[0-9]+$ ]] && (( num > max_id )); then + max_id=$num + fi + done + shopt -u nullglob + + local next_id=$((max_id + 1)) + local backup_file="$ROOT_DIR/lfs.${next_id}.tar.gz" + + local total_size=$(du -cb "$DISK_IMG_LFS" 2>/dev/null | tail -n1 | awk '{print $1}') + + read -p "Enter compression level for LFS (recommended 6) [0-9]: " level + while [[ ! "$level" =~ ^[0-9]$ ]] || [ "$level" -lt 0 ] || [ "$level" -gt 9 ]; do + echo "Invalid input. Please enter a number between 0 and 9." + read -p "Enter compression level for LFS (recommended 6) [0-9]: " level + done + + local cmd="tar -C \"$ROOT_DIR/images/\" -cf - \"lfs.qcow2\" | pv -s $total_size | gzip -$level > \"$backup_file\"" + + confirm_and_run "$cmd" +} + +display_title() { + echo -e "\033[1;35m __ ________" + echo " / / / __/ __/ __ _ ___ ____ ___ ____ ____ ____" + echo " / /__/ _/_\\ \\ / ' \\/ _ \`/ _ \\/ _ \`/ _ \`/ -_) __/" + echo "/____/_/ /___/ /_/_/_/\\_,_/_//_/\\_,_/\\_, /\\__/_/" + echo -e " LFS 12.4 /___/\033[0m" + echo +} + +# ============================================================================== +# Main Menu +# ============================================================================== + +PS3="Select an option (Ctrl+D to quit): " +options=( + "Start LFS (GUI)" + "Start tooling distro (GUI)" + "Start tooling distro (headless)" + "Compress and backup the tooling disk" + "Compress and backup the LFS disk" + "Sync to Google Drive (rclone)" +) + +display_title + +select opt in "${options[@]}" +do + case $opt in + "Start LFS (GUI)") + CMD="qemu-system-x86_64 -enable-kvm -m ${LFS_RAM}G -smp $LFS_NPROC -drive file=\"$DISK_IMG_LFS\",format=qcow2 -nic user,model=virtio-net-pci,hostfwd=tcp::2222-:22 -vga virtio" + confirm_and_run "$CMD" + ;; + "Start LFS (headless)") + CMD="qemu-system-x86_64 -enable-kvm -m ${LFS_RAM}G -smp $LFS_NPROC -drive file=\"$DISK_IMG_LFS\",format=qcow2 -nic user,model=virtio-net-pci,hostfwd=tcp::2222-:22 -nographic" + confirm_and_run "$CMD" + ;; + "Start tooling distro (GUI)") + CMD="qemu-system-x86_64 -enable-kvm -m ${LFS_RAM}G -smp $LFS_NPROC -drive file=\"$DISK_IMG_MAIN\",format=qcow2 -drive file=\"$DISK_IMG_LFS\",format=qcow2 -nic user,model=virtio-net-pci,hostfwd=tcp::2222-:22 -vga virtio" + confirm_and_run "$CMD" + ;; + "Start tooling distro (headless)") + echo "Note: Press 'Ctrl+A' then 'x' to terminate the VM." + CMD="qemu-system-x86_64 -enable-kvm -m ${LFS_RAM}G -smp $LFS_NPROC -drive file=\"$DISK_IMG_MAIN\",format=qcow2 -drive file=\"$DISK_IMG_LFS\",format=qcow2 -nic user,model=virtio-net-pci,hostfwd=tcp::2222-:22 -nographic" + confirm_and_run "$CMD" + ;; + "Compress and backup the tooling disk") + run_backup_tooling + ;; + "Compress and backup the LFS disk") + run_backup_lfs + ;; + "Sync to Google Drive (rclone)") + CMD="rclone sync -P \"$ROOT_DIR\" \"$RCLONE_TARGET\" --exclude \"images/**\"" + confirm_and_run "$CMD" + ;; + *) + # Standard bash 'select' behavior is to just reprint the prompt + # if input is invalid, but we can explicitly scold the user if desired. + echo "Invalid option \"$REPLY\". Please try again." + ;; + esac +done + +# If loop ends via ^D +exit 0