LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-12-2022, 01:13 PM   #16
henca
Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 963

Original Poster
Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650

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
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] No package 'x11' found No package 'xext' found No package 'xdamage' found No package 'xfixes' found No package 'x11-xcb' found Jigsaw Linux From Scratch 14 02-23-2021 08:35 PM
Init script behaving differently when run on machines in the UK vs US BrianK Programming 6 07-21-2011 12:04 AM
[SOLVED] #!/bin/sh vs #!/bin/bash -- script executes differently; each way = different bugs GrapefruiTgirl Programming 21 12-16-2009 05:30 PM
date function working differently between machines johnfman Linux - Software 3 12-21-2007 11:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration