From 9d73d30759ed24f86a26a9c8facbccadc5ccb832 Mon Sep 17 00:00:00 2001 From: YellowJacketLinux Date: Sat, 12 Oct 2024 19:23:21 -0700 Subject: [PATCH] ready to try a kernel build... --- CHROOT.sh | 4 ++ KernelBuild/02-linux-kernel.sh | 77 ++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 KernelBuild/02-linux-kernel.sh diff --git a/CHROOT.sh b/CHROOT.sh index 9af4450..22ebd04 100644 --- a/CHROOT.sh +++ b/CHROOT.sh @@ -18,6 +18,10 @@ LFS="/mnt/newlfs" cp versions.sh ${LFS}/sources/CH7Build/ cp versions.sh ${LFS}/sources/CH8Build/ cp versions.sh ${LFS}/sources/KernelBuild/ +cp KernelBuild/lts-kernel-config ${LFS}/sources/ + +# TEMPORARY, REMOVE BEFORE FINAL BUILD +touch ${LFS}/sources/SKIPTESTS chown --from lfs -R root:root ${LFS}/{usr,lib,var,etc,bin,sbin,tools} diff --git a/KernelBuild/02-linux-kernel.sh b/KernelBuild/02-linux-kernel.sh new file mode 100644 index 0000000..000512d --- /dev/null +++ b/KernelBuild/02-linux-kernel.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +source versions.sh + +GLSOURCES="/sources" + +KVSTRING="${linux_lts_version}-lfs-12.2-systemd" + +pushd ${GLSOURCES} > /dev/null 2>&1 || myfail "Failed to move to ${GLSOURCES}" + +[ -d linux-${linux_lts_version} ] && rm -rf linux-${linux_lts_version} + +tar -Jxf ${linux_lts_tarball} + +cd linux-${linux_lts_version} + +make mrproper +cp ../lts-kernel-config ./.config + +make oldconfig +if [ $? -ne 0 ]; then + myfail "Failed building kernel" +fi + +make modules_install +if [ $? -ne 0 ]; then + myfail "Failed building kernel modules" +fi + +rm -f /lib/modules/${linux_lts_version}/build +rm -f /lib/modules/${linux_lts_version}/source +install -D -m644 .config /boot/config-${KVSTRING} +install -m644 System.map /boot/System.map-${KVSTRING} +install -m644 arch/x86_64/boot/bzImage /boot/vmlinuz-${KVSTRING} + +cp -r Documentation /usr/share/doc/linux/linux-${linux_lts_version} + +popd + +# cleanup + +pushd ${GLSOURCES} + +rm -rf linux-${linux_lts_version} + +# only write grub configuration for USBFlash +if [ ! -f /USBFlash ]; then + echo "Manually update the /boot/grub/grub.cfg file." + echo "In theory, you can shut down, remove the thumb drive, and boot!" + exit 0 +fi + +[ ! -d /boot/grub ] && mkdir /boot/grub + +cat > /boot/grub/grub.cfg << "EOF" +# Begin /boot/grub/grub.cfg +set default=0 +set timeout=5 + +insmod part_gpt +insmod ext2 +set root=(hd0,2) + +EOF + +echo "root=(hd0,2)" >> /boot/grub/grub.cfg +echo "" >> /boot/grub/grub.cfg +echo " menuentry \"GNU/Linux, Linux ${KVSTRING}\" {" \ + >> /boot/grub/grub.cfg +echo " linux /boot/vmlinuz-${KVSTRING} root=/dev/sda2 ro" \ + >> /boot/grub/grub.cfg +echo "}" >> /boot/grub/grub.cfg + +echo "Please verify /boot/grub/grub.cfg is correct." +echo "If so, exit the chroot and run grub-install on USB Flash device" +echo "and set device as bootable." +