summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO11
-rw-r--r--PKGBUILD14
-rw-r--r--kmodcache-post.hook11
-rw-r--r--kmodcache-pre.hook11
-rw-r--r--kmodcache.conf1
-rw-r--r--kmodcache.service10
-rwxr-xr-xmake-kmod-cache8
-rwxr-xr-xmodprobe7
-rwxr-xr-xpost-upgrade19
-rwxr-xr-xpre-upgrade25
10 files changed, 76 insertions, 41 deletions
diff --git a/.SRCINFO b/.SRCINFO
index b95b4cdca2b9..3c46cea88340 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -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
-
diff --git a/PKGBUILD b/PKGBUILD
index 3101f834f76f..e36e64660b15 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -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