diff options
author | Oliver Mangold | 2022-12-02 11:00:24 +0100 |
---|---|---|
committer | Oliver Mangold | 2022-12-02 11:22:48 +0100 |
commit | 7495b8cfdc0dc2056bd0523b4016c391ed5c3d55 (patch) | |
tree | d19d8329be64f5408949ed6498c1418070931cc6 | |
parent | 5133b37d23d45cae8214639e914e906ffc49729f (diff) | |
download | aur-7495b8cfdc0dc2056bd0523b4016c391ed5c3d55.tar.gz |
complete rewrite:
- do not use systemd but, but pacman hooks
- do not use custom modprobe, but symlink from /usr/lib/modules to /var/cache/kmods
-rw-r--r-- | .SRCINFO | 11 | ||||
-rw-r--r-- | PKGBUILD | 14 | ||||
-rw-r--r-- | kmodcache-post.hook | 11 | ||||
-rw-r--r-- | kmodcache-pre.hook | 11 | ||||
-rw-r--r-- | kmodcache.conf | 1 | ||||
-rw-r--r-- | kmodcache.service | 10 | ||||
-rwxr-xr-x | make-kmod-cache | 8 | ||||
-rwxr-xr-x | modprobe | 7 | ||||
-rwxr-xr-x | post-upgrade | 19 | ||||
-rwxr-xr-x | pre-upgrade | 25 |
10 files changed, 76 insertions, 41 deletions
@@ -1,17 +1,16 @@ pkgbase = kmodcache pkgdesc = Scripts to make a copy of installed kernel modules, which will be used for on-demand loading from then point on, thus make reboots unnecessary after kernel updates. - pkgver = 1.2 + pkgver = 1.3 pkgrel = 1 arch = any license = GPL3 - source = kmodcache.conf - source = modprobe - source = make-kmod-cache - source = kmodcache.service + source = pre-upgrade + source = post-upgrade + source = kmodcache-pre.hook + source = kmodcache-post.hook sha256sums = SKIP sha256sums = SKIP sha256sums = SKIP sha256sums = SKIP pkgname = kmodcache - @@ -1,22 +1,18 @@ # Maintainer: Oliver Mangold <o.mangold@gmail.com> pkgname=kmodcache -pkgver=1.2 +pkgver=1.3 pkgrel=1 pkgdesc="Scripts to make a copy of installed kernel modules, which will be used for on-demand loading from then point on, thus make reboots unnecessary after kernel updates." arch=('any') license=('GPL3') depends=() makedepends=() -source=('kmodcache.conf' 'modprobe' 'make-kmod-cache' 'kmodcache.service') +source=(pre-upgrade post-upgrade kmodcache-pre.hook kmodcache-post.hook) sha256sums=('SKIP' 'SKIP' 'SKIP' 'SKIP') package() { - #cd "${pkgname}" - install -m 755 -d "$pkgdir"/usr/lib/modules "$pkgdir"/usr/lib/sysctl.d "$pkgdir"/usr/lib/systemd/system "$pkgdir"/usr/bin "$pkgdir"/usr/local/bin - install -m 755 make-kmod-cache "$pkgdir"/usr/bin - install -m 755 modprobe "$pkgdir"/usr/local/bin - install -m 644 kmodcache.conf "$pkgdir"/usr/lib/sysctl.d - install -m 644 kmodcache.service "$pkgdir"/usr/lib/systemd/system - ln -s /var/cache/kmods "$pkgdir"/usr/lib/modules/cached + install -m 755 -d "$pkgdir"/usr/lib/kmodcache "$pkgdir"/usr/share/libalpm/hooks + install -m 755 {pre,post}-upgrade "$pkgdir"/usr/lib/kmodcache + install -m 644 *.hook "$pkgdir"/usr/share/libalpm/hooks } diff --git a/kmodcache-post.hook b/kmodcache-post.hook new file mode 100644 index 000000000000..5bdf3c465597 --- /dev/null +++ b/kmodcache-post.hook @@ -0,0 +1,11 @@ +[Trigger] +Operation = Upgrade +Type = Package +Target = linux +Target = linux-* +Target = zfs-linux* + +[Action] +Description = Adjust symlink to cache for kernel module directory +When = PostTransaction +Exec = /usr/lib/kmodcache/post-upgrade diff --git a/kmodcache-pre.hook b/kmodcache-pre.hook new file mode 100644 index 000000000000..f1e10e66522a --- /dev/null +++ b/kmodcache-pre.hook @@ -0,0 +1,11 @@ +[Trigger] +Operation = Upgrade +Type = Package +Target = linux +Target = linux-* +Target = zfs-linux* + +[Action] +Description = Copy old kernel module directory to cache +When = PreTransaction +Exec = /usr/lib/kmodcache/pre-upgrade diff --git a/kmodcache.conf b/kmodcache.conf deleted file mode 100644 index 03f70de9a847..000000000000 --- a/kmodcache.conf +++ /dev/null @@ -1 +0,0 @@ -kernel.modprobe = /usr/local/bin/modprobe diff --git a/kmodcache.service b/kmodcache.service deleted file mode 100644 index ec49ba30bfa7..000000000000 --- a/kmodcache.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=update modules cache for active kernel -RequiresMountsFor=/var/cache - -[Service] -Type=oneshot -ExecStart=/usr/bin/make-kmod-cache - -[Install] -WantedBy=multi-user.target diff --git a/make-kmod-cache b/make-kmod-cache deleted file mode 100755 index 22379d8a0939..000000000000 --- a/make-kmod-cache +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -e - -moddir=/lib/modules/`uname -r` -[ -d "$moddir" ] -rm -f /var/cache/kmods/osrelease -rm -rf /var/cache/kmods -cp -r -L --preserve=all --reflink=auto "$moddir" /var/cache/kmods -cp -a /proc/sys/kernel/osrelease /var/cache/kmods/osrelease diff --git a/modprobe b/modprobe deleted file mode 100755 index 97d4cf38f6f0..000000000000 --- a/modprobe +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -if cmp /proc/sys/kernel/osrelease /var/cache/kmods/osrelease 2>/dev/null; then - exec /sbin/modprobe -S "cached" "$@" -else - exec /sbin/modprobe "$@" -fi diff --git a/post-upgrade b/post-upgrade new file mode 100755 index 000000000000..a58ea42abbce --- /dev/null +++ b/post-upgrade @@ -0,0 +1,19 @@ +#!/bin/bash + +set -eu + +read cur_osrelease </proc/sys/kernel/osrelease + +moddir=/usr/lib/modules/$cur_osrelease + +if [ -e "$moddir" ] || [ -L "$moddir" ]; then + exit 0 +fi + +[ -e /var/cache/kmods/osrelease ] || exit 0 + +read prev_osrelease </var/cache/kmods/osrelease + +[ "$cur_osrelease" == "$prev_osrelease" ] || exit 0 + +ln -sT ../../../var/cache/kmods "$moddir" diff --git a/pre-upgrade b/pre-upgrade new file mode 100755 index 000000000000..eb6b7abdc21a --- /dev/null +++ b/pre-upgrade @@ -0,0 +1,25 @@ +#!/bin/bash + +set -eu + +read cur_osrelease </proc/sys/kernel/osrelease + +moddir=/usr/lib/modules/$cur_osrelease +oldlink=$(readlink -m "$moddir") + +if [ "${oldlink}" == /var/cache/kmods ]; then + rm "$moddir" + exit 0 +fi + +if [ -e /var/cache/kmods/osrelease ]; then + read prev_osrelease </var/cache/kmods/osrelease + [ "$cur_osrelease" != "$prev_osrelease" ] || exit 0 +fi + +[ -d "$moddir" ] || exit 0 + +rm -rf /var/cache/kmods + +cp -a "$moddir" /var/cache/kmods +cat /proc/sys/kernel/osrelease >/var/cache/kmods/osrelease |