So, it all ended up with pushing out 6 packages:
The follwoing 3 standard packages from Slackware patches:
- kernel-source-5.15.80-noarch-1.txz
- kernel-modules-5.15.80-x86_64-1.txz
- kernel-headers-5.15.80-x86-1.txz
The standard Slackware packages with huge and generic kernels were replaced with my own custom packages:
- module-patches-5.15.80-x86_64-10.tgz
- kernel-patches-5.15.80-x86_64-10.tgz
At the time of this writing, the module-patches package is only a place holder for the day that I will need to patch the kernel sources in a way which affects some modules. Those patched kernel modules will then replace their unpatched variants from the standard kernel-modules package.
My kernel-patches package only contains a doinst.sh which is rather big as it contains self extracting archives, the file looks something like this:
Code:
#!/bin/bash
kernel=`file boot/vmlinuz | colrm 1 31 | xargs -0 dirname`
if [ "$kernel" == "." ]; then
# Fallback for old machines not having kernel in subdir of /boot
kernel=huge.s
ln -sf ${kernel}/bzImage boot/vmlinuz
ln -sf ${kernel}/config boot/config
ln -sf ${kernel}/System.map boot/System.map
fi
case "$kernel" in
huge.s)
mkdir -p boot/old_kernels
mv boot/$kernel boot/old_kernels/${kernel}.`date +%y%m%d` || true
base64 -d << 'EOF' | tar -C boot -xvf -
aHVnZS5zLwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
...
AAAAAAAAAA==
EOF
;;
*)
echo New kernel for $kernel is missing!
;;
esac
gunzip boot/${kernel}/System.map.gz
chown -R root.root boot
if [ -d boot/efi/EFI/Boot ]; then
# This machine boots with UEFI
cp -p boot/${kernel}/bzImage boot/efi/EFI/Boot/vmlinuz
else
# Do not run lilo if extlinux is used to boot
if [ ! -r boot/extlinux.conf ]; then
# Doing this more than once might help against "volid read error" from
# removable discs
lilo -r .
sleep 1
lilo -r .
sleep 1
lilo -r .
fi
fi
The final package is the one which updates nVidia drivers if installed:
- nvidia_upgrade-15.0-x86_64-hc2.tgz
That package also only contains a doinst.sh:
Code:
# This assumes that only the latest version of current and legacy
# nvidia drivers are in opt directory
# NOLOCK # avoid deadlock from recursive call to upgradepkg
ROOT='pwd' ; upgradepkg --reinstall /auto/slack150/opt/nvidia-*.t?z
The kernel-patches and module-patches packages are created by a Makefile using the following rules:
Code:
$(KERNEL_PATCH_PKG): $(KERNEL_BUILD_DIR) $(BZIMAGES) \
kernel_and_patches/doinst.sh
( echo " Patched kernel" && echo && \
tail -9 kernel_and_patches/patches.txt | \
awk '{$$1=""; print $$0}' && printf "\n\n\n\n\n\n\n\n\n\n" ) | \
sed -e 's/^/kernel-patches:/' | head -11 > \
$(KERNEL_PATCH_PKG:%.tgz=%.txt)
mkdir -p $(PKG_BUILD_DIR)/install
cp kernel_and_patches/doinst.sh $(PKG_BUILD_DIR)/install
cd $(PKG_BUILD_DIR) && fakeroot /sbin/makepkg -c n $(KERNEL_PATCH_PKG)
$(RM) -r $(PKG_BUILD_DIR)
mkdir -p $(PKG_BUILD_DIR)/lib/modules/$(KERNEL_VERSION)/kernel
cd $(KERNEL_BUILD_DIR) && tar -cf - $(PATCHED_MODULES) | \
(cd $(PKG_BUILD_DIR)/lib/modules/$(KERNEL_VERSION)/kernel; tar -xvf -)
mkdir $(PKG_BUILD_DIR)/install
echo chroot . /sbin/depmod -a > $(PKG_BUILD_DIR)/install/doinst.sh
cd $(PKG_BUILD_DIR) && fakeroot /sbin/makepkg -c y $(MODULE_PATCH_PKG)
find $(CUS_PKG_DIR) -type l -exec rm {} \;
ln -s ../`basename $(KERNEL_PATCH_PKG_DIR)`/$(MODULE_PATCH_PKG_FILE) \
$(CUS_PKG_DIR)
$(RM) -r $(KERNEL_BUILD_DIR)
kernel_and_patches/doinst.sh: kernel_and_patches/d1.sh \
kernel_and_patches/d2.sh \
kernel_and_patches/d3.sh
cat $^ > $@
kernel_and_patches/d2.sh: $(BZIMAGES)
for krn in $(KERNELS) ; do echo $${krn}")" >> $@; \
echo mkdir -p boot/old_kernels >> $@; \
echo 'mv boot/$$kernel boot/old_kernels/$${kernel}.`date +%y%m%d` || true' >> $@; \
echo "base64 -d << 'EOF' | tar -C boot -xvf -" >> $@; \
tar -C kernels -cf - $${krn} | base64 >> $@; \
echo EOF >> $@; \
echo ";;" >> $@ ; done
echo "*)" >> $@
echo 'echo New kernel for $$kernel is missing!' >> $@
echo ";;" >> $@
This Makefile creates doinst.sh by concatinating 3 files, d1.sh d2.sh and d3.sh. The contents of d1.sh and d3.sh is the rather static content at the beginning and end of doinst.sh. The file d2.sh is generated by Makefile to contain self extracting scripts for different kernel configurations.
This all worked rather OK, but machines with nVidia drivers installed would fail to run any OpenGL program or other things like nvidia-smi which depends upon the nVidia libraries. The updated libraries complain about not being compatible with the old kernels nvidia driver module until the machine is rebooted.
regards Henrik