LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   My apporach on how to keep Slackware-current upgraded (https://www.linuxquestions.org/questions/slackware-14/my-apporach-on-how-to-keep-slackware-current-upgraded-4175654810/)

denydias 05-29-2019 07:08 PM

My apporach on how to keep Slackware-current upgraded
 
Earlier this month a fellow LQ newbie asked us How to maintain a sane slackware64-current with Eric Hameleers multilib and ktown? Well, I gave my two cents there.

Now I'm here to expand on how I keep up with Slacware-current evolution in a safe manner, i.e. by avoiding system breakage between upgrades. Keep in mind that even if all this works perfectly for me and I haven't had not a single glitch in this process in the past couple years, it is solely my approach to the task. I have no intention at all that this may become an ultimate approach to it. It's just my way of doing things that could eventually help others with ideas.

The scripts are here:

https://gist.github.com/denydias/a10...08b8c1bec63ac8

And this is how they work:
  • 1_mirror.sh: this is my mirroring script. It runs everyday on my NAS to keep up with Slackware-current and AlienBOB's Ktown. It also performs a very important task to anyone avoiding bad things to happen: package preservation.
  • 2_minskyup.sh: this one upgrades Slackware-current according to the best practices exposed in Upgrading Slackware to a New Release. There are different functions for system and kernel upgrades. The later includes automation to preserve the last working kernel version so you can have a working system if the new kernel don't boot. It also includes the recovery and memtest images from Slackware's usbboot.img, meaning that if something goes really, really wrong, you'll have the tools to fix it right there. There are also functions to upgrade many of the tools of my daily workflow, that for one reason or another I decided to use the upstream binaries instead of a ready made package or SlackBuild out there: virtualbox, vagrant, docker, aws-cli, cli53, (git)hub, jq, ngrok, phpmyadmin, spectre-meltdown-checker, testssl, asciinema, calibre, pup, Synology Drive and zoom.
  • 3_minskyup_completion.sh: this one goes in /etc/bash_completion.d/ to offer tab completion for minskyup.
  • 4_lilo.conf: an example of my boot entries so the kernel upgrades works as expected.
But how it works? Whenever a see a new Slackware64 -current ChangeLog entry, or anytime I want, I run:

Code:

$ sudo minskyup mirror && sudo minskyup slack --force
This will upgrade any packages but kernel. When there is a ktown upgrade, I go to init 3 and run it without --force as it's not advisable to upgrade KDE stuff with X running.

If the changelog entry also contains a new kernel version, then I run:

Code:

$ sudo minskyup kernel
This command will ask me to confirm all the changes it detects, so I have the information I need to decide where or not is safe to move on.

As for the other minskyup options, they are pretty self explanatory. For instance, to upgrade virtualbox:

Code:

$ sudo minskyup virtualbox
It'll detect the currently installed version and the latest one from Oracle. If the installed one is outdated, it moves on and upgrades.

But there are some other tools that do not provide a way to discover which the latest version is. In that case you have to check first, but it's quite simple too:

Code:

$ sudo minskyup docker
Docker CE version is required. Example:

minskyup docker 18.06.0

See https://download.docker.com/linux/static/stable/x86_64/ for available versions.
Currently installed: Docker version 18.06.0-ce
$ sudo minskyup docker 18.06.3

And so on...

So, this is how I do it. WFM. Damn, really WFM! :D

PS: why minskyup? My box is named after Marvin Minsky. :cool:

luvr 06-23-2019 09:29 AM

1 Attachment(s)
Thank you for your highly interesting post!

I am taking a far less ambitious approach to keeping my Slackware systems up-to-date, but now that I finally got around to finishing my script for maintaining the Linux kernel under Slackware, I thought I’d share the procedure that I follow. Now, as you said:
Quote:

Originally Posted by denydias (Post 6000224)
I have no intention at all that this may become an ultimate approach to it. It's just my way of doing things that could eventually help others with ideas.

I actually restarted writing my script from scratch some four or five times, since I found it got too complex while I worked on it, and I then began to read various sources (man pages, the slackpkg source code, etc.), which taught me about quite a few useful features that could make my script so much simpler and more straightforward.

I maintain a local copy of the Slackware repository, which I keep up-to-date with the rsync utility.
I blacklisted the kernel packages (as well as ‘SBo’, ‘alien’, and ‘compat32’) in my ‘/etc/slackpkg/blacklist’ file, and to install the Slackware updates, I run the typical command sequence:
Code:

# slackpkg update
# slackpkg install-new
# slackpkg upgrade-all
# slackpkg clean-system

Then, to maintain the Linux kernel versions on my Slackware system, I simply run my ‘upgrade-kernel.sh’ script without any parameters:
Code:

# upgrade-kernel.sh
The script presents a dialog-based interface that, depending on the circumstances, will let me install the latest kernel version and/or remove selected kernel versions (except for the currently running one).

In case anyone is interested, I attach the script (with an extension of “.txt” instead of “.sh”) to this post.

denydias 06-26-2019 02:21 AM

I'm glad you liked it. Thank you.

Quote:

Originally Posted by luvr (Post 6008220)
In case anyone is interested, I attach the script (with an extension of “.txt” instead of “.sh”) to this post.

That's what I call useful comments! Well done. ;)

marcusmaria 07-26-2019 12:49 AM

Dear denydias,

thanks for sharing your workflow. I have one question concerning ktown. Is it really necessary to:

Code:

# slackpkg upgrade ktown
before:

Code:

# slackpkg upgrade-all
Doesn't the latter also upgrade ktown as well?

Greetings
Marcus

marcusmaria 07-27-2019 02:27 AM

@luvr thanks for providing your script. Is it necessary in order to make it work to use a local mirror or does it also work with a remote? If the latter is the case, could you please share your opinion on why it's better to use a local mirror?

Greetings
Marcus

luvr 07-27-2019 02:55 AM

Quote:

Originally Posted by marcusmaria (Post 6018989)
Reason: solved it on my own.

Glad you figured it out.

In case anyone ever runs into the same issue: After you rsync your local repository, a new kernel (or, by extension, any new or updated package) won’t get picked up until you run
Code:

# slackpkg update
Since I usually run the common sequence of
Code:

# slackpkg update
# slackpkg install-new
# slackpkg upgrade-all
# slackpkg clean-system

right after the rsync, and only then run my kernel update script, I won’t normally run into this issue.

marcusmaria 07-27-2019 10:38 AM

That was exactly the point, thanks. Have you seen my additional question:

Quote:

Is it necessary in order to make it work to use a local mirror or does it also work with a remote? If the latter is the case, could you please share your opinion on why it's better to use a local mirror?

dugan 07-27-2019 10:46 AM

For me it's usually:

Code:

slackpkg update
slackpkg upgrade-all
compat32pkg --convert-updates all
upgradepkg /var/cache/compat32pkg/compat-32/*.t?z
compat32pkg --clear-cache all

A couple more steps (including "geninitrd" and running the NVidia driver installer with "-K -k") if there's a kernel upgrade.

marcusmaria 07-27-2019 10:50 AM

@dugan what is the compat32pkg about that you are using? Are you converting the regular packages in multilib with that? Would it also be possible to use aliens multilib repository instead?

dugan 07-27-2019 01:16 PM

http://compat32pkg.sourceforge.net/

I've found that Alien's multilib repo is often out of date.

luvr 07-27-2019 01:37 PM

Quote:

Originally Posted by marcusmaria (Post 6018989)
Is it necessary in order to make it work to use a local mirror or does it also work with a remote?

As it stands, the script requires a local mirror.

The immediate reason is that it looks for an active “file:” line in your ‘/etc/slackpkg/mirrors’ file, and it will quit if it doesn’t find one.

The more fundamental reason is that the ‘installpkg’ command (which the script runs to install the new kernel packages) only installs packages that are available locally. Therefore, to support a remote mirror, the script will have to download the packages to a local directory before installing them. While I did consider implementing this (using something like ‘wget’ or ‘curl’), I decided in the end that it wasn’t worth the hassle. After all, the script was really just meant for my own use—“just a hobby, won't be big and professional like gnu”… ;)

Quote:

[…] could you please share your opinion on why it's better to use a local mirror?
To be honest, I really didn’t give this question all that much thought. When I looked into Slackware package management for the first time (long before I even envisaged ever installing Slackware permanently and for real), the Slackware documentation kind of suggested using a local mirror, and that’s really the primary reason why I’m still using a local mirror.

marcusmaria 07-27-2019 01:45 PM

@luvr thanks for the reply. I can imagine that a local mirror is also a bit more 'safe' especially for upgrades from stable to -current. I am using it now as you have implemented and till now I am very happy with it. Thanks for the work.

lioh 08-09-2019 04:08 AM

@luvr I have noticed one little thing concerning your script: I had the local mirror configured without the trailing slash first, like: file://home/ftp/pub/Linux/Slackware/slackware64-current and your script exited when it tried to detect the local mirror. After modifying the slackpkg mirror configuration so that it looked like this: file://home/ftp/pub/Linux/Slackware/slackware64-current/ everything worked as expected.

luvr 08-10-2019 08:17 AM

Quote:

Originally Posted by lioh (Post 6023218)
@luvr I have noticed one little thing concerning your script: I had the local mirror configured without the trailing slash first, like: file://home/ftp/pub/Linux/Slackware/slackware64-current and your script exited when it tried to detect the local mirror. After modifying the slackpkg mirror configuration so that it looked like this: file://home/ftp/pub/Linux/Slackware/slackware64-current/ everything worked as expected.

That’s correct—initially, I made the trailing slash optional, but then I saw the following note in the ‘/etc/slackpkg/mirrors’ file (emphasis mine):
Code:

# Slackpkg only needs to point to the directory that contains
# "ChangeLog.txt", and don't forget the trailing slash.

So I reasoned that, since the trailing slash was required anyway, I could just as well enforce it.

Having said that, making the trailing slash optional requires just one simple change to the script (replacing a single ‘+’-sign with an asterisk), as implemented by the following patch:
Code:

--- upgrade-kernel.sh_orig        2019-08-10 15:02:21.158041934 +0200
+++ upgrade-kernel.sh        2019-08-10 15:03:06.550043756 +0200
@@ -900,7 +900,7 @@
      #*************************************************************************************************************************
      sed --silent                                                        \
          --regexp-extended                                                \
-          --expression='s~^[[:space:]]*file:/+(.+)/+[[:space:]]*$~/\1~p'  \
+          --expression='s~^[[:space:]]*file:/+(.+)/*[[:space:]]*$~/\1~p'  \
          "${SLACKWARE_MIRROR_CONFIGURATION}"
 
    )

To apply the patch, save it to a file (say, ‘/tmp/plus2asterisk.patch’), then ‘cd’ to the directory where you keep the ‘upgrade-kernel.sh’ script file, and run:
Code:

# patch < /tmp/plus2asterisk.patch

lioh 08-11-2019 09:02 AM

@luvr thanks for pointing that out and for the patch. I think I will let it like this now as it works perfectly. I have to admit that I did not read the note in the slackpkg mirrors config. I have just tried the script without having the trailing slash set before and then I have realized that in your script there was one, so I have added it an it worked.

luvr 08-14-2019 02:44 PM

OOPS! My script does not pick up today’s upgraded kernel.
 
Today’s “Current (pre-release) ChangeLog for x86_64” announces availability of an upgraded kernel in the repositories:
Code:

Wed Aug 14 05:24:55 UTC 2019
a/kernel-generic-4.19.66-x86_64-2.txz: Upgraded.
      Recompiled with gcc-9.2.0.
a/kernel-huge-4.19.66-x86_64-2.txz: Upgraded.
      Recompiled with gcc-9.2.0.
a/kernel-modules-4.19.66-x86_64-2.txz: Upgraded.
      Recompiled with gcc-9.2.0.

My ‘upgrade-kernel.sh’ script, however, doesn’t pick up this new kernel, because kernel version “4.19.66” is already installed on my computer. Consequently, the script believes that there is no new kernel version available for installation. The script considers only the version number, and ignores the build number, which was incremented from “1” to “2”, while the version was left unchanged.

That makes me wonder what would be the recommended way to install this new kernel version. If you used ‘installpkg’, then, surely, it would get installed, but I guess you would then end up with a “broken /var/log/packages - with two versions of the same package”, wouldn’t you? Even so, I’m not aware of any real problems that this would cause; the only irregularity, as far as I can tell, would be a seemingly innocent warning from ‘slackpkg’ about the issue.

Anyway, to get my ‘upgrade-kernel.sh’ script, as it currently stands, to install this upgraded kernel, you can do the following:
  • Reboot the system with an older kernel that is still installed. (If you don’t have any, then you’re out of luck… Sorry!)
  • Run the script and instruct it to remove the latest kernel—i.e., in this case, version 4.19.66.
  • Rerun the script to install the new kernel version.
I’m not entirely sure if it would be worth it to try and adapt my script so it would handle this type of condition. Is this a common occurrence, or is it pretty much exceptional? In any case, this is the first time that I’m seeing it.

lioh 08-15-2019 01:30 AM

@luvr thanks for pointing that out. It would be great if you could find a way that your script could handle those edge cases. Could you please elaborate how you handle the parallel installation? As far as I have seen on my system /var/log/packages shows several versions of the same package (which I have also expected to be like that). As I have blacklisted the kernels in slackpkg there is also no warning about it.

ehartman 08-15-2019 05:19 AM

Quote:

Originally Posted by luvr (Post 6025165)
I’m not entirely sure if it would be worth it to try and adapt my script so it would handle this type of condition. Is this a common occurrence, or is it pretty much exceptional? In any case, this is the first time that I’m seeing it.

It happened before, although it isn't all that usual for the kernel to get a recompile, especially in -current, where upgrades happen that often that it mostly will be a version upgrade anyway.
A quick search in the ChangeLog's found a case in 14.1, where the kernel (3.10.17) even was rebuilt twice, within a few days:
Quote:

Thu Oct 24 01:22:57 UTC 2013
a/kernel-generic-3.10.17-i486-3.txz: Rebuilt.
+--------------------------+
Mon Oct 21 07:30:10 UTC 2013
a/kernel-generic-3.10.17-i486-2.txz: Rebuilt.
There may be more, but I only did a limited quick search.

BTW: the current (last) updated kernel for 14.1 is a -2 build too:
linux-3.10.107/kernel-generic-3.10.107-i486-2.txz
because of a security vulnerability.

luvr 08-15-2019 02:57 PM

It seems to me that it is not an option to leave two (or even more) builds of the same kernel version installed side-by-side, since they use the exact same names for the files that they install.

For instance:
Code:

$ tar -tvf kernel-generic-4.19.66-x86_64-1.txz
drwxr-xr-x root/root        0 2019-08-09 22:34 ./
drwxr-xr-x root/root        0 2019-08-09 22:34 boot/
-rw-r--r-- root/root  3554153 2019-08-09 22:34 boot/System.map-generic-4.19.66
-rw-r--r-- root/root    185303 2019-08-09 22:34 boot/config-generic-4.19.66.x64
-rw-r--r-- root/root  6068096 2019-08-09 22:34 boot/vmlinuz-generic-4.19.66
drwxr-xr-x root/root        0 2019-08-09 22:34 install/
-rw-r--r-- root/root      354 2019-08-09 22:34 install/doinst.sh
-rw-r--r-- root/root      1086 2019-08-09 22:34 install/slack-desc
$ tar -tvf kernel-generic-4.19.66-x86_64-2.txz
drwxr-xr-x root/root        0 2019-08-14 01:03 ./
drwxr-xr-x root/root        0 2019-08-14 01:03 boot/
-rw-r--r-- root/root  3553963 2019-08-14 01:03 boot/System.map-generic-4.19.66
-rw-r--r-- root/root    185303 2019-08-14 01:03 boot/config-generic-4.19.66.x64
-rw-r--r-- root/root  6068096 2019-08-14 01:03 boot/vmlinuz-generic-4.19.66
drwxr-xr-x root/root        0 2019-08-14 01:03 install/
-rw-r--r-- root/root      354 2019-08-14 01:03 install/doinst.sh
-rw-r--r-- root/root      1086 2019-08-14 01:03 install/slack-desc

So, if I were to install Build “-2” without removing Build “-1” first, then the files from Build “-1” would be overwritten. In effect, there would, then, be two packages claiming ownership of the files.

In other words, I guess that if there’s a rebuild available of an already installed kernel version, then it shouldn’t be installed over the previous build, but the previous one should be removed first.

Any thoughts?

ehartman 08-15-2019 03:41 PM

Quote:

Originally Posted by luvr (Post 6025497)
In other words, I guess that if there’s a rebuild available of an already installed kernel version, then it shouldn’t be installed over the previous build, but the previous one should be removed first.

Of course build -2 must be an UPGRADE to build-1, because, as you said, they will need the same (but possible recompiled) modules, include files etc.

Chuck56 08-15-2019 04:27 PM

If you use slackpkg then you get a dialog screen and the output from removepkg. The tools check the newer rebuilt package Skipping over duplicate file names. The net effect is that the older package is removed from the package list but the newer rebuilt files remain in place.

Code:

root@xxx:~# slackpkg remove kernel-generic-4.19.66-x86_64-1                                       
                                                                                                   
Looking for kernel-generic-4.19.66-x86_64-1 in package list. Please wait... DONE                   


 slackpkg 2.83.0
 ──────────────────────────────────────────────────────────────────────────────────────────────────


              ┌──────────────────────────────remove────────────────────────────────┐
              │ Choose packages to remove:                                        │ 
              │ ┌────────────────────────────────────────────────────────────────┐ │ 
              │ │[*] kernel-generic-4.19.66-x86_64-1                │ │ 
              │ │                                                                │ │ 
              │ │                                                                │ │ 
              │ │                                                                │ │ 
              │ │                                                                │ │ 
              │ │                                                                │ │ 
              │ │                                                                │ │ 
              │ │                                                                │ │ 
              │ │                                                                │ │ 
              │ │                                                                │ │ 
              │ │                                                                │ │ 
              │ │                                                                │ │ 
              │ │                                                                │ │ 
              ├─└────────────────────────────────────────────────────────────────┘─┤ 
              │                  <  OK  >          <Cancel>                      │ 
              └────────────────────────────────────────────────────────────────────┘ 

Package: kernel-generic-4.19.66-x86_64-1
        Removing...
Removing package: kernel-generic-4.19.66-x86_64-1
Removing files:
  --> /boot/System.map (symlink) was found in another package. Skipping.
  --> /boot/config (symlink) was found in another package. Skipping.
  --> /boot/vmlinuz (symlink) was found in another package. Skipping.
  --> /boot/vmlinuz-generic (symlink) was found in another package. Skipping.
  --> /boot/System.map-generic-4.19.66 was found in another package. Skipping.
  --> /boot/config-generic-4.19.66.x64 was found in another package. Skipping.
  --> /boot/vmlinuz-generic-4.19.66 was found in another package. Skipping.

root@xxx:~#

Or you can directly use removepkg, not get the dialog screen and just get the Skipping messages. The same end result is the older package is removed from the package list and the newer rebuilt package & files remain.

Code:

root@xxx:~# removepkg kernel-huge-4.19.66-x86_64-1
Removing package: kernel-huge-4.19.66-x86_64-1
Removing files:
  --> /boot/System.map (symlink) was found in another package. Skipping.
  --> /boot/config (symlink) was found in another package. Skipping.
  --> /boot/vmlinuz (symlink) was found in another package. Skipping.
  --> /boot/vmlinuz-huge (symlink) was found in another package. Skipping.
  --> /boot/System.map-huge-4.19.66 was found in another package. Skipping.
  --> /boot/config-huge-4.19.66.x64 was found in another package. Skipping.
  --> /boot/vmlinuz-huge-4.19.66 was found in another package. Skipping.
root@xxx:~#


luvr 08-16-2019 03:34 PM

Quote:

Originally Posted by ehartman (Post 6025516)
Of course build -2 must be an UPGRADE to build-1, because, as you said, they will need the same (but possible recompiled) modules, include files etc.

True, but are you suggesting that I use ‘upgradepkg’ to install Build-2? Wouldn’t that remove all earlier kernel versions? Or could I use the “oldpackagename%newpackagename” construct to tell ‘upgradepkg’ that Build-2 (i.e., the new package) is an upgrade to Build-1 (i.e., the old package), and would it, then, leave the older versions alone?

(I’m really just thinking aloud here. If no-one has the answer to these questions, I will try out the “oldpackagename%newpackagename” construct and see what gives.)

luvr 08-16-2019 03:39 PM

Quote:

Originally Posted by Chuck56 (Post 6025527)
If you use slackpkg then you get a dialog screen and the output from removepkg. The tools check the newer rebuilt package Skipping over duplicate file names. The net effect is that the older package is removed from the package list but the newer rebuilt files remain in place.

So, if I understand you correctly, your suggestion would be to ‘installpkg’ the new build first, and subsequently ‘removepkg’ the old one? In any case, that sounds to me like it should work.

Chuck56 08-16-2019 03:48 PM

Quote:

Originally Posted by luvr (Post 6025878)
So, if I understand you correctly, your suggestion would be to ‘installpkg’ the new build first, and subsequently ‘removepkg’ the old one? In any case, that sounds to me like it should work.

Correct, that works.

I've been using scripts that follow that exact workflow for system upgrades (including the kernel). The scripts leverage slackpkg and manage the upgrade process from beginning to end including managing EFI & LILO files.

ehartman 08-16-2019 10:40 PM

Quote:

Originally Posted by luvr (Post 6025878)
So, if I understand you correctly, your suggestion would be to ‘installpkg’ the new build first, and subsequently ‘removepkg’ the old one? In any case, that sounds to me like it should work.

That's actually what "upgradepkg" does, it removes the existing package (you can even specify explicitly WHICH one instead of letting it search for it).
Quote:

Upgradepkg upgrades a Slackware package (.tgz, .tbz, .tlz, .txz) from an older version to a newer one. It does this by INSTALLING the new package onto the system, and then REMOVING any files from the old package that aren't in the new package. If the old and new packages have the same name, a single argument is all that is required. If the packages have different names, supply the name of the old package followed by a percent
symbol (%), then the name of the new package. Do not add any extra whitespace between pairs of old/new package names.
(from /sbin/upgradepkg).

It will never remove multiple old packages, only the one that is superceeded BY the newly installed one.

lioh 08-23-2019 02:23 AM

@luvr one thing that would be nice is to automatically create symlinks to the previous kernel (the one which is actively running) like: /boot/vmlinuz-generic-prev

denydias 08-23-2019 03:02 AM

Hey! I'm sorry for the late reply. For an unknown reason I'm not receiving LQ's reply notification messages.

Quote:

Originally Posted by marcusmaria (Post 6018699)
Doesn't the latter also upgrade ktown as well?

Yes, it does. But I want to make sure to upgrade ktown before other stuff.

Quote:

Originally Posted by luvr (Post 6025165)
My ‘upgrade-kernel.sh’ script, however, doesn’t pick up this new kernel, because kernel version “4.19.66” is already installed on my computer. Consequently, the script believes that there is no new kernel version available for installation. The script considers only the version number, and ignores the build number, which was incremented from “1” to “2”, while the version was left unchanged.

My script slipped on that too. A fix is in my personal backlog. I'm planning to use the approach to replace only the current kernel (build N) with the newer one (build N+1) and leave the previous one alone. I don't know how long I'll take to come up with that fix as I'm having busy days here.

luvr 08-23-2019 03:21 AM

Quote:

Originally Posted by denydias (Post 6028502)
I'm planning to use the approach to replace only the current kernel (build N) with the newer one (build N+1) and leave the previous one alone.

That was my initial idea, too, but I've come to the conclusion that that won't work, since the new build will overwrite the previous one anyway.

lioh 08-23-2019 03:27 AM

From how I understood it, the only way to handle those edge cases is to replace the old version using the upgradepkg old2%new2 feature, right?

denydias 08-23-2019 03:52 AM

Quote:

Originally Posted by luvr (Post 6028507)
That was my initial idea, too, but I've come to the conclusion that that won't work, since the new build will overwrite the previous one anyway.

The sequence bellow may work just fine for the case:

Code:

removepkg kernel-source-$KCUR-1
removepkg kernel-headers-$KCUR-1
removepkg kernel-modules-$KCUR-1
removepkg kernel-generic-$KCUR-1
installpkg $SLACK/k/kernel-source-$KCUR-2.txz
installpkg $SLACK/d/kernel-headers-$KCUR-2.txz
installpkg $SLACK/a/kernel-modules-$KCUR-2.txz
installpkg $SLACK/a/kernel-generic-$KCUR-2.txz

This does not look like it will mess with the previous one, being the previous kernel a version older then $KCUR, which in this particular use case happens to have only the build number increased. I don't see it touching modules and generic for the previous kernel.

On the other hand, the only way to preserve headers and source for the previous kernel is to copying their files before the installpkg/upgradepkg of them, but I don't really see the need for this. In the event of the new kernel don't boot, I'll use the previous one just to inspect the situation, fix it and boot into the new one asap.

lioh 08-23-2019 04:02 AM

I would like to know how often it really happens that a new kernel does not boot. I must admit that i am using the huge kernel and never had any issues with it, neither on stable nor on -current. I can imagine that an upgrade could eventually cause issues when one is using LVM / Full-Disk-Encryption or things like that.

For me the the main issues when using the -generic kernel is that I always have to remember to run lilo afterwards, which I sometimes forget and then (and only then) I have to boot the old kernel and fix the initrd.

So I am really interested in your real-life experience and would be happy if you could share some of the situations you had on kernel upgrades.

denydias 08-23-2019 04:12 AM

Quote:

Originally Posted by lioh (Post 6028515)
I would like to know how often it really happens that a new kernel does not boot. I must admit that i am using the huge kernel and never had any issues with it, neither on stable nor on -current. I can imagine that an upgrade could eventually cause issues when one is using LVM / Full-Disk-Encryption or things like that.

LVM / Full-Disk-Encryption is my use case. I can't afford have no way around with a faulty new kernel. It never happened before, but who knows when...

Quote:

Originally Posted by lioh (Post 6028515)
For me the the main issues when using the -generic kernel is that I always have to remember to run lilo afterwards, which I sometimes forget and then (and only then) I have to boot the old kernel and fix the initrd.

That's the reason why I decided to automate it and to keep the previous working kernel. Before that I had a TFTP server at home so I could boot to the rescue image and fix things, which also involves to mess with BIOS network and boot settings as I always keep my notebook pretty closed to booting with anything I can't control. There was one time I was away from home. You could imagine the rest. My current approach gives me all the tools I need to recover from a faulty upgrade, anywhere.

Chuck56 08-23-2019 08:56 AM

autoslackpkg-0.4 RC1
 
I've been using my own Slackware upgrade scripts since last year. At that time I had 3 systems on current and the kernel upgrades were becoming robotic for me. Hopefully the scripts are ready for others to test drive. I named the scripts "autoslackpkg".

https://www.go4it2day.com/news/autoslackpkg-0.4.html

The scripts leverage slackpkg and manage kernel changes from start to finish on both EFI or LILO systems. The key to successfully using the scripts is to make sure 4 config files are appropriately customized. There are rudimentary help screens that try to explain the config customizations.
Code:

/etc/slackpkg/blacklist/usr/sbin/usermod
/etc/mkinitrd.conf
/etc/lilo.conf
/boot/efi/.../elilo.conf (location can vary)

I use the scripts on 11 systems currently, 14.2 & current, x86 & x86_64, desktops, servers, gateways & LXC containers. I've tried to hit all my edge cases but I'm sure there are others I haven't run into yet. You're welcome to use them or tear them apart for ideas for your own scripts.

Enjoy!

luvr 08-23-2019 04:09 PM

Quote:

Originally Posted by denydias (Post 6028512)
This does not look like it will mess with the previous one, being the previous kernel a version older then $KCUR, which in this particular use case happens to have only the build number increased. I don't see it touching modules and generic for the previous kernel.

That is absolutely correct, but when I mentioned the "previous" kernel, I actually meant the earlier build of the $KCUR version. That will, obviously, get overwritten. Any earlier kernel versions that are still installed will, clearly, not be touched. Should the new build, for any reason, fail to boot up, then you can still fall back on such an older version - PROVIDED that you kept at least one of those.

Quote:

Originally Posted by lioh (Post 6028492)
@luvr one thing that would be nice is to automatically create symlinks to the previous kernel (the one which is actively running) like: /boot/vmlinuz-generic-prev

Sounds like a great suggestion, and would make such a fallback a whole lot easier, should it ever be required. I'll look into it. Sure seems pretty much doable anyway.

denydias 08-23-2019 10:33 PM

I had some spare time today and could face the kernel build bump problem in my script. Follow are the results (with mocked values, of course).

First with a regular kernel upgrade, e.g. 4.19.66 to 4.19.67:

Code:

$ minskyup kernel
NEW kernel 4.19.67 available, current kernel is 4.19.66, upgrading boot menu:

- Slackware: 4.19.67 = /media/nas/mirrors/slackware64-current/slackware64/a/kernel-generic-4.19.66-x86_64-2.txz
- Slackprev: 4.19.66 = /boot/vmlinuz-generic-4.19.66
- DELETE  : 4.19.65 = /boot/vmlinuz-generic-4.19.65

The following resources will be upgraded:

- Packages: kernel-{source,headers,modules,generic}
- Images  : initrd, initrd-prev, recovery and memtest

Press [CTRL-C] to abort or [Enter] to continue...

Now with just a kernel build bump, e.g. 4.19.66-1 to 4.19.66-2:

Code:

$ minskyup kernel
BUMPED kernel 4.19.66-2 available, current kernel is 4.19.66-1, upgrading boot menu:

- Slackware: BUMP 4.19.66-1 -> 4.19.66-2 = /media/nas/mirrors/slackware64-current/slackware64/a/kernel-generic-4.19.66-x86_64-2.txz
- Slackprev: KEPT 4.19.65 = /boot/vmlinuz-generic-4.19.65
- DELETE  : NONE

The following resources will be upgraded:

- Packages: kernel-{modules,generic}
- Images  : initrd, initrd-prev, recovery and memtest

Press [CTRL-C] to abort or [Enter] to continue...

Now let the kernels come so I can found the bugs in my logic... :cool:

luvr 08-24-2019 11:37 AM

Quote:

Originally Posted by luvr (Post 6025877)
(I’m really just thinking aloud here. If no-one has the answer to these questions, I will try out the “oldpackagename%newpackagename” construct and see what gives.)

Hmmm... I have just tried the following (while “kernel-source-4.19.66-noarch-1” was the highest kernel-source version installed):
Code:

# upgradepkg kernel-source-4.19.66-noarch-1%kernel-source-4.19.66-noarch-2.txz
It doesn’t do what I intended, though, in that it removes all earlier versions of the kernel-source package, then installs the specified new package. Come to think of it, this doesn’t really come as a surprise; after all, it just performs the upgrade that I request—which, by definition, will remove all earlier versions of the package to be upgraded.

Thus, a sequence of ‘removepkg’ and ‘installpkg’ will be the way to go in order to upgrade an installed kernel version to a newer build.

denydias 08-24-2019 12:35 PM

Quote:

Originally Posted by luvr (Post 6029000)
Thus, a sequence of ‘removepkg’ and ‘installpkg’ will be the way to go in order to upgrade an installed package version to a newer build.

Only if you want to keep the previous working kernel and its source so you can recompile it for any reason. But kernel-headers won't work that way, as it always replace the previous files.

My approach is a little different: although I keep the previous kernel, I do so only to count on a booting system in case the worst happens, i.e. the just installed new kernel won't boot at all. As I have no intention to recompile the previous kernel, nor compile anything in the system against it anymore, I don't need kernel-source nor kernel-headers of the previous kernel.

As such, when a new kernel arrives (like 4.19.67 to replace 4.19.66), my script just upgradepkg kernel-source and kernel-headers, effectively replacing them with the newer versions. On the other hand, when the kernel upgrade is just a bump (like 4.19.66-1 to 4.19.66-2), there is no need to touch kernel-source and kernel-headers, so my script just skip this step.

In any case, version or bump upgrades, my script actively removepkg the selected kernel then installpkg the new one. I prefer this way to avoid conflicts that may left orphan files or dead links around in the system.

luvr 08-24-2019 01:21 PM

Quote:

Originally Posted by denydias (Post 6029011)
My approach is a little different: although I keep the previous kernel, I do so only to count on a booting system in case the worst happens, i.e. the just installed new kernel won't boot at all. As I have no intention to recompile the previous kernel, nor compile anything in the system against it anymore, I don't need kernel-source nor kernel-headers of the previous kernel.

Good catch… looking at it like that, I don’t actually need the older sources or headers either.
For now, it doesn’t hurt to keep them around either, but I’ll think it through a little further before I make up my mind about how to handle them in the future.

Quote:

Originally Posted by denydias (Post 6029011)
As such, when a new kernel arrives (like 4.19.67 to replace 4.19.66), my script just upgradepkg kernel-source and kernel-headers, effectively replacing them with the newer versions.

Indeed, you'll wipe out the earlier versions… which are, in effect, just dead weight when you leave them installed.

Quote:

On the other hand, when the kernel upgrade is just a bump (like 4.19.66-1 to 4.19.66-2), there is no need to touch kernel-source and kernel-headers, so my script just skip this step.
That idea hadn't even crossed my mind just yet, but you're absolutely right!

Quote:

In any case, version or bump upgrades, my script actively removepkg the selected kernel then installpkg the new one. I prefer this way to avoid conflicts that may left orphan files or dead links around in the system.
I think I’ll experiment a little further to see what works best for me… but your comments certainly make sense. In any case, I remove the links that come with a kernel installation, and I create and maintain my own set of links—so far, without issues.

I do have an updated version of my script ready now, which maintains an additional set of links to the ‘previous’ kernel files (i.e., to the kernel version that is running when the script is being executed), but I’ll have to double-check that it doesn’t do any crazy things when it has to remove kernel packages.

luvr 08-25-2019 02:35 PM

UPDATE to my 'upgrade-kernel.sh' script.
 
1 Attachment(s)
Attached to this post is an update to my ‘upgrade-kernel.sh’ script.

NEW FEATURE:
  • The script now maintains a set of symlinks to the “previous” kernel version—i.e., the one that is active at the time a new kernel is being installed. These symlinks will have the same names as their “new-kernel” counterparts, but with a suffix of ‘-prev’ appended.
Caveat: When you remove one or more kernel versions while no new kernel version is available, these ‘-prev’ symlinks will be recreated to point to the kernel version that is running at that time. As a consequence, if you’re running the latest installed kernel version at that time (which you normally will), then the ‘-prev’ and the “new-kernel” symlinks will both be made to point to that latest version. I don’t consider this a significant problem, because:
  1. the primary goal of the script is to install kernel upgrades—at which time it will let you remove any versions that you no longer want to keep;
  2. the currently active kernel is known to be good anyway, since otherwise you wouldn’t be running it in the first place.
TO DO:
  • Add support for installing a new build of an already installed kernel version.
I will be testing this support on my Slackware-current install, which I temporarily reverted back to kernel version 4.19.66, Build 1. I’m using a test version of the script that I point to what it thinks is my local repository mirror, but is in reality a simple folder into which I can copy any kernel version and build that I want to test with.

denydias 08-27-2019 12:46 AM

Quote:

Originally Posted by denydias (Post 6028836)
Now let the kernels come so I can found the bugs in my logic... :cool:

Kernel 4.19.68 upgrade handled as usual. Now let's wait for a bump (e.g. 4.19.68-1 to 4.19.68-2) to test this case. It may take years though.

luvr 08-28-2019 03:22 PM

Next update to my 'upgrade-kernel.sh' script.
 
3 Attachment(s)
Attached to this post is the next update to my ‘upgrade-kernel.sh’ script.

NEW FEATURE:
  • The script now supports installation of a new build of an already installed kernel version.
    To install a new build of the latest installed kernel version, it will first install the new build, and next remove the previously installed one. In this way, the removal operation is really only required in order to clean up installation registration of the overridden (and overwritten) build.
KNOWN ISSUE:
  • It remains a bad idea to remove the latest installed kernel version, since the version-independent symbolic links to the kernel files will then be left behind, but they will become “dangling” pointers—i.e., they will point to ‘nowhere’.
    Note that the script won’t even let you remove the latest kernel version anyway, unless you are running an earlier kernel version and there is no new kernel available for installation.
EXTRAS:
  • Script ‘fix-kernel-symlinks.sh’ will recreate the version-independent symbolic links to the latest installed kernel files.
    It will also allow you to select the kernel version to which you want to point the fallback (i.e., “previous”) symbolic links.
  • Script ‘rebuild-kernel-initrd.sh’ allows you to select the installed kernel versions for which you want to rebuild the Initial RAM Disks (“initrd”).

lioh 08-29-2019 07:09 AM

Thank luvr, I am going to try it out soon and give some feedback. The dangling symlinks is not so much an issue in my point of view.

Could you elaborate a bit more why exactly now three scripts are needed instead of one like before? Wouldn't it be possible to merge all the functionality into the main script?

luvr 08-30-2019 04:04 PM

Quote:

Originally Posted by lioh (Post 6030970)
Could you elaborate a bit more why exactly now three scripts are needed instead of one like before? Wouldn't it be possible to merge all the functionality into the main script?

The main script, ‘upgrade-kernel.sh’, is the only one that’s needed. The other two, ‘fix-kernel-symlinks.sh’ and ‘rebuild-kernel-initrd.sh’ are just quick hacks that should not be required, but that can be used to repair anomalies with the symlinks or the initrds, should that ever be necessary. The ‘fix-kernel-symlinks.sh’ script for instance, will fix the “dangling pointer” issue for you, should you ever run into it.

I used the ‘fix-kernel-symlinks.sh’ while I was developing the latest version of my ‘upgrade-kernel.sh’ script, so I could verify if the latter behaved properly under various conditions. I haven’t encountered a situation in which the ‘rebuild-kernel-initrd.sh’ was useful, but you never know.

Thus, to recapitulate: Under normal conditions, you should still only really need the main ‘upgrade-kernel.sh’ script.

lioh 10-02-2019 07:31 AM

Thanks for pointing that out. I have to add some options to the mkintrd generation. Can I just modify the following line to look e.g. like this:

$(/usr/share/mkinitrd/mkinitrd_command_generator.sh -a -l sg-latin1 -h /dev/cryptvg/swap '-o '"${INITRD}" --run "${KERNEL}")

Greetings

Lioh

luvr 10-02-2019 07:49 AM

Quote:

Originally Posted by lioh (Post 6042869)
Can I just modify the following line to look e.g. like this:

$(/usr/share/mkinitrd/mkinitrd_command_generator.sh -a -l sg-latin1 -h /dev/cryptvg/swap '-o '"${INITRD}" --run "${KERNEL}")

Yes, that will work fine.

lioh 11-04-2019 01:34 AM

@luvr. I am actually not sure what caused this situation but currently the following broken symlink has been created:

initrd-*-prev -> initrd-*-4.19.80*

I have used the script for the first time on a newly installed system and this link has been generated on the first kernel update. The 'old' initrd was named just initrd.gz, maybe that's the root cause.

luvr 11-04-2019 01:53 AM

Quote:

Originally Posted by lioh (Post 6053821)
@luvr. I am actually not sure what caused this situation but currently the following broken symlink has been created:

initrd-*-prev -> initrd-*-4.19.80*

I have used the script for the first time on a newly installed system and this link has been generated on the first kernel update. The 'old' initrd was named just initrd.gz, maybe that's the root cause.

What a coincidence... I have just run into the same issue myself. It happens because one of the patterns to find existing initrds does not find any files and thus returns just the pattern unchanged.

I now have an updated version of the script available, which I will upload later. (I don't have my Slackware system handy at the moment, but the solution is as simple as inserting an appropriate "shopt" command near the top of the script.)

Thanks for reporting this issue. It reminds me to upload the new version.

lioh 11-04-2019 02:36 AM

Thanks for the reply. I will wait for the updated version. As far as I understood this can only happen on the first run/migration to your script.

luvr 11-04-2019 03:04 AM

Quote:

Originally Posted by lioh (Post 6053846)
Thanks for the reply. I will wait for the updated version. As far as I understood this can only happen on the first run/migration to your script.

Yes, that's correct.

luvr 11-04-2019 08:49 AM

UPDATE to my 'upgrade-kernel.sh' script: BUG FIX.
 
3 Attachment(s)
Attached to this post is the next update to my ‘upgrade-kernel.sh’ script. It fixes a bug where, the first time that it is run on a freshly installed Slackware system, it will create a broken symlink, such as:
Code:

initrd-*-prev -> initrd-*-4.19.81*
(where the version string, ‘4.19.81’, will be replaced by the actual kernel version, of course.)

To fix this bug, the script now sets the ‘nullglob’ shell option when it begins execution:
Code:

shopt -s nullglob
(Previously, this option got set in one of the functions defined in the script, but the function was called too late to prevent the broken symlink.) As the bash man page explains, the ‘nullglob’ shell option allows patterns that do not match any files to expand to a null string, rather than themselves.

As before, only the main script, ‘upgrade-kernel.sh’, is required.

Helper scripts ‘fix-kernel-symlinks.sh’ and ‘rebuild-kernel-initrd.sh’ let you recreate the symbolic links to the installed kernel files and rebuild the initrd, respectively, just in case.


All times are GMT -5. The time now is 04:57 PM.