aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md13
-rwxr-xr-xdist-upgrade35
2 files changed, 45 insertions, 3 deletions
diff --git a/README.md b/README.md
index e4f6dac..c267dd5 100644
--- a/README.md
+++ b/README.md
@@ -24,6 +24,7 @@ Environment:
- `INITRD` initrd to inspect (default `/boot/initrd-generic.img`)
- `LOG` append the non-interactive run, slackpkg output included, to this file
(default `/var/log/dist-upgrade.log`; set it empty to disable)
+- `R8125_DIR` SBo `r8125` SlackBuild directory used for the driver rebuild
A logrotate rule for that log ships in `logrotate.d/dist-upgrade`; install it
to `/etc/logrotate.d/`.
@@ -39,7 +40,12 @@ to `/etc/logrotate.d/`.
initrd's contents,
- the module set against the pre-upgrade snapshot (notices modules lost).
4. Lists any leftover `.new` config files.
-5. Reports whether a reboot is recommended.
+5. If the `r8125` package is installed and the newest kernel has no `r8125`
+ module, rebuilds it from the SBo SlackBuild in `R8125_DIR` (default
+ `/var/lib/sbopkg/SBo-git/network/r8125`) and installs it with `upgradepkg`.
+ The tree is used as-is; sync it first if the new kernel needs a newer
+ driver.
+6. Reports whether a reboot is recommended.
A non-interactive run is appended to `LOG`, with a timestamped header per run,
so an unattended upgrade can be reviewed afterwards. Interactive runs are not
@@ -59,8 +65,9 @@ closing recap reminds you to re-run with `-i` to review and remove them.
## Requirements
Slackware `-current`, run as root. Needs `slackpkg`, `cpio` and `gzip`; `zstd`
-and `xz` are used only if the initrd is compressed with them. The module
-bootability check uses Slackware's own
+and `xz` are used only if the initrd is compressed with them. The `r8125`
+rebuild needs `wget` and the new kernel's `/lib/modules/<ver>/build` tree.
+The module bootability check uses Slackware's own
`/usr/share/mkinitrd/mkinitrd_command_generator.sh` when present.
## Testing
diff --git a/dist-upgrade b/dist-upgrade
index a71d224..d039363 100755
--- a/dist-upgrade
+++ b/dist-upgrade
@@ -20,6 +20,7 @@ export LC_ALL=C
INITRD=${INITRD:-/boot/initrd-generic.img}
MKINITRD_GEN=/usr/share/mkinitrd/mkinitrd_command_generator.sh
LOG=${LOG-/var/log/dist-upgrade.log}
+R8125_DIR=${R8125_DIR:-/var/lib/sbopkg/SBo-git/network/r8125}
INTERACTIVE=0
TMPDIR_SNAP=""
@@ -48,6 +49,9 @@ Environment:
INITRD initrd to inspect (default /boot/initrd-generic.img)
LOG append non-interactive run output here (default
/var/log/dist-upgrade.log; set empty to disable)
+ R8125_DIR SBo r8125 SlackBuild dir, rebuilt when the newest
+ kernel lacks the module (default
+ /var/lib/sbopkg/SBo-git/network/r8125)
EOF
}
@@ -168,6 +172,36 @@ report_leftovers() {
printf '%s\n' "$found"
}
+# ponytail: the SBo tree is used as-is, not synced; sync it first if a new
+# kernel needs a newer r8125
+rebuild_r8125() {
+ local kver=$1 dir
+ compgen -G '/var/lib/pkgtools/packages/r8125-*' >/dev/null || return 0
+ if find "/lib/modules/$kver" -name 'r8125.ko*' 2>/dev/null | grep -q .; then
+ info "r8125: module already present for kernel $kver."
+ return 0
+ fi
+ if [ ! -f "$R8125_DIR/r8125.SlackBuild" ]; then
+ warn "r8125: no SlackBuild in $R8125_DIR; kernel $kver has no r8125 module, the NIC may not come up after reboot"
+ return 1
+ fi
+ info "r8125: rebuilding for kernel $kver from $R8125_DIR"
+ dir="$TMPDIR_SNAP/r8125"
+ # set -e is ignored inside a tested subshell, so the steps are chained
+ # shellcheck source=/dev/null
+ if ! (
+ cp -a "$R8125_DIR" "$dir" && cd "$dir" &&
+ . ./r8125.info &&
+ wget -q -O "${DOWNLOAD##*/}" "$DOWNLOAD" &&
+ printf '%s %s\n' "$MD5SUM" "${DOWNLOAD##*/}" | md5sum -c --quiet &&
+ KERNEL=$kver OUTPUT="$dir/out" TMP="$dir/tmp" bash ./r8125.SlackBuild &&
+ upgradepkg --install-new --reinstall "$dir"/out/r8125-*.t?z
+ ); then
+ warn "r8125: rebuild for kernel $kver failed; the NIC may not come up after reboot"
+ return 1
+ fi
+}
+
snapshot_initrd() {
if [ ! -e "$INITRD" ] && [ ! -L "$INITRD" ]; then
info "snapshot: no initrd at $INITRD, skipping initrd checks."
@@ -329,6 +363,7 @@ fi
running=$(uname -r)
newver=$(newest_kernel)
+[ -n "$newver" ] && rebuild_r8125 "$newver"
if [ -n "$newver" ] && [ "$running" != "$newver" ]; then
info "Reboot recommended: running kernel $running, newest installed $newver."
fi