From 16366e882c48b0b85dfd3c8279d822d4c1b9e245 Mon Sep 17 00:00:00 2001 From: YellowJacketLinux Date: Fri, 4 Oct 2024 07:21:33 -0700 Subject: [PATCH] cleanup --- CH7Build/0-CH07-Prep.sh | 101 +++++++++++++++++++++++++++ CH7Build/CH07-Master.sh | 149 ++++++++++++++++++---------------------- 2 files changed, 166 insertions(+), 84 deletions(-) create mode 100644 CH7Build/0-CH07-Prep.sh diff --git a/CH7Build/0-CH07-Prep.sh b/CH7Build/0-CH07-Prep.sh new file mode 100644 index 0000000..630174f --- /dev/null +++ b/CH7Build/0-CH07-Prep.sh @@ -0,0 +1,101 @@ +#!/bin/bash + +mkdir -pv /{boot,home,mnt,opt,srv} + +mkdir -pv /etc/{opt,sysconfig} +mkdir -pv /lib/firmware +mkdir -pv /media/{floppy,cdrom} +mkdir -pv /usr/{,local/}{include,src} +mkdir -pv /usr/lib/locale +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 + +# + +ln -sv /proc/self/mounts /etc/mtab + +cat > /etc/hosts << EOF +127.0.0.1 localhost $(hostname) +::1 localhost +EOF + +cat > /etc/passwd << "EOF" +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:65534:65534:Unprivileged User:/dev/null:/usr/bin/false +EOF + +cat > /etc/group << "EOF" +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: +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: +users:x:999: +nogroup:x:65534: +EOF + +localedef -i C -f UTF-8 C.UTF-8 + +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 + +echo "Execute the following: " +echo +echo "exec /usr/bin/bash --login" + + + diff --git a/CH7Build/CH07-Master.sh b/CH7Build/CH07-Master.sh index b881888..076e0b3 100644 --- a/CH7Build/CH07-Master.sh +++ b/CH7Build/CH07-Master.sh @@ -1,100 +1,81 @@ #!/bin/bash -mkdir -pv /{boot,home,mnt,opt,srv} +/bin/bash CH07.01-gettext.sh -mkdir -pv /etc/{opt,sysconfig} -mkdir -pv /lib/firmware -mkdir -pv /media/{floppy,cdrom} -mkdir -pv /usr/{,local/}{include,src} -mkdir -pv /usr/lib/locale -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} +if [ $? -ne 0 ]; then + echo "failed CH07.01-gettext.sh" + exit 1 +else + echo "LFS Chapter 7 Gettext Complete" + sleep 3 +fi -ln -sfv /run /var/run -ln -sfv /run/lock /var/lock +/bin/bash CH07.02-bison.sh -install -dv -m 0750 /root -install -dv -m 1777 /tmp /var/tmp +if [ $? -ne 0 ]; then + echo "failed CH07.02-bison.sh" + exit 1 +else + echo "LFS Chapter 7 Bison Complete" + sleep 3 +fi -# +/bin/bash CH07.03-perl.sh -ln -sv /proc/self/mounts /etc/mtab +if [ $? -ne 0 ]; then + echo "failed CH07.03-perl.sh" + exit 1 +else + echo "LFS Chapter 7 Perl Complete" + sleep 3 +fi -cat > /etc/hosts << EOF -127.0.0.1 localhost $(hostname) -::1 localhost -EOF +/bin/bash CH07.04-python.sh -cat > /etc/passwd << "EOF" -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:65534:65534:Unprivileged User:/dev/null:/usr/bin/false -EOF +if [ $? -ne 0 ]; then + echo "failed CH07.04-python.sh" + exit 1 +else + echo "LFS Chapter 7 Python Complete" + sleep 3 +fi -cat > /etc/group << "EOF" -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: -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: -users:x:999: -nogroup:x:65534: -EOF +/bin/bash CH07.05-texinfo.sh -localedef -i C -f UTF-8 C.UTF-8 +if [ $? -ne 0 ]; then + echo "failed CH07.05-texinfo.sh" + exit 1 +else + echo "LFS Chapter 7 Texinfo Complete" + sleep 3 +fi -echo "tester:x:101:101::/home/tester:/bin/bash" >> /etc/passwd -echo "tester:x:101:" >> /etc/group -install -o tester -d /home/tester +/bin/bash CH07.06-util-linux.sh -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 +if [ $? -ne 0 ]; then + echo "failed CH07.06-util-linux.sh" + exit 1 +else + echo "LFS Chapter 7 Util-Linux Complete" + sleep 3 +fi -echo "Execute the following: " +LFS=/mnt/newlfs + +rm -rf /usr/share/{info,man,doc}/* +find /usr/{lib,libexec} -name \*.la -delete +rm -rf /tools + +echo "leave the chroot environment and unmount virtual file systems." echo -echo "exec /usr/bin/bash --login" - +echo "execute the following commands:" +echo +echo "exit" +echo "mountpoint -q ${LFS}/dev/shm && umount ${LFS}/dev/shm" +echo "umount ${LFS}/dev/pts" +echo "umount ${LFS}/{sys,proc,run,dev}" +echo +echo "cd ${LFS}" +echo "tar -cJpf ${HOME}/lfs-temp-tools-12.2-systemd.tar.xz ." +exit 0