mirror of
https://github.com/archlinux-jerry/pkgbuilds
synced 2024-11-22 05:50:40 +08:00
add package: kernel-modules-hook-hardlinks
This commit is contained in:
parent
1704b7c7ff
commit
bbb9f075a9
7 changed files with 98 additions and 0 deletions
10
kernel-modules-hook-hardlinks/10-linux-modules-post.hook
Normal file
10
kernel-modules-hook-hardlinks/10-linux-modules-post.hook
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Trigger]
|
||||
Operation = Remove
|
||||
Type = Path
|
||||
Target = usr/lib/modules/*/vmlinuz
|
||||
|
||||
[Action]
|
||||
Description = Restoring Linux kernel modules...
|
||||
When = PostTransaction
|
||||
Exec = /usr/share/libalpm/scripts/linux-modules-restore
|
||||
NeedsTargets
|
11
kernel-modules-hook-hardlinks/10-linux-modules-pre.hook
Normal file
11
kernel-modules-hook-hardlinks/10-linux-modules-pre.hook
Normal file
|
@ -0,0 +1,11 @@
|
|||
[Trigger]
|
||||
Operation = Install
|
||||
Operation = Remove
|
||||
Type = Path
|
||||
Target = usr/lib/modules/*/vmlinuz
|
||||
|
||||
[Action]
|
||||
Description = Saving Linux kernel modules directory (hardlinks)...
|
||||
When = PreTransaction
|
||||
Exec = /usr/share/libalpm/scripts/linux-modules-save
|
||||
NeedsTargets
|
28
kernel-modules-hook-hardlinks/PKGBUILD
Normal file
28
kernel-modules-hook-hardlinks/PKGBUILD
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Maintainer: Max Gautier <mg+archlinux@max.gautier.name>
|
||||
# Contributor: Artoria Pendragon <saber-nyan@ya.ru>
|
||||
_pkgname=kernel-modules-hook
|
||||
pkgname=${_pkgname}-hardlinks
|
||||
pkgver=0.2.3
|
||||
pkgrel=1
|
||||
pkgdesc="Keeps your system fully functional after a kernel upgrade"
|
||||
arch=('any')
|
||||
provides=("$_pkgname")
|
||||
url="https://github.com/VannTen/$_pkgname"
|
||||
license=('GPL3')
|
||||
source=("linux-modules-cleanup.conf"
|
||||
"10-linux-modules-post.hook"
|
||||
"10-linux-modules-pre.hook"
|
||||
"linux-modules-restore"
|
||||
"linux-modules-save"
|
||||
)
|
||||
sha256sums=('950f851eba08dac4d0b93ff62b3fb16ddacd4f8ebb98a2435f80bf05f2ea5a29'
|
||||
'fc4d53dec520c80fe97dfda65b238c7d678e7ef26aaebffc5b43f924477ea4f4'
|
||||
'087e5ed70b2fc512d814fbded9e873955b1da5b6bf1e31975174d704ad143156'
|
||||
'28b995f6ea62899620d43d71e542bfc3432ad3ce90a6582f4ded1173fe8c0837'
|
||||
'5d9092689d9baa3d8e5ac65ae92d1c201e23c4ef42c99d131f9465c99d6505ef')
|
||||
|
||||
package() {
|
||||
install -Dm644 'linux-modules-cleanup.conf' "${pkgdir}/usr/lib/tmpfiles.d/linux-modules-cleanup.conf"
|
||||
install -Dm644 10-linux-modules-{pre,post}.hook -t "${pkgdir}/usr/share/libalpm/hooks/"
|
||||
install -Dm755 linux-modules-{save,restore} -t "${pkgdir}/usr/share/libalpm/scripts/"
|
||||
}
|
12
kernel-modules-hook-hardlinks/README.md
Normal file
12
kernel-modules-hook-hardlinks/README.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# kernel-modules-hook
|
||||
|
||||
This is an alpm hook for Archlinux (or other pacman-based distribution) to keep the kernel modules of the running kernel available during a kernel upgrade.
|
||||
|
||||
It relies on hardlinks and bind mount for saving and restoring, and systemd-tmpfiles for cleanup.
|
||||
|
||||
## Installation
|
||||
|
||||
### Archlinux
|
||||
[AUR](https://aur.archlinux.org/packages/kernel-modules-hook-hardlinks/)
|
||||
|
||||
Use your AUR helper of choise, or use makepkg.
|
2
kernel-modules-hook-hardlinks/linux-modules-cleanup.conf
Normal file
2
kernel-modules-hook-hardlinks/linux-modules-cleanup.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
R! /usr/lib/modules/running-kernel
|
||||
r /usr/lib/modules/*
|
11
kernel-modules-hook-hardlinks/linux-modules-restore
Normal file
11
kernel-modules-hook-hardlinks/linux-modules-restore
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
kver=$(uname -r)
|
||||
while read -r line; do
|
||||
# We only care about the running kernel
|
||||
if [[ "$line" == usr/lib/modules/$kver/vmlinuz && -d "${line/$kver/running-kernel}" ]];then
|
||||
mount --mkdir --bind --options ro /usr/lib/modules/{running-kernel,$kver}
|
||||
# Mounting read-only since the only modification here should be unmounting
|
||||
# when rebooting or reinstalling the running kernel
|
||||
fi
|
||||
done
|
24
kernel-modules-hook-hardlinks/linux-modules-save
Normal file
24
kernel-modules-hook-hardlinks/linux-modules-save
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
kver=$(uname -r)
|
||||
while read -r line; do
|
||||
# We only care about the running kernel
|
||||
if [[ "$line" == "usr/lib/modules/$kver/vmlinuz" ]];then
|
||||
if mountpoint --nofollow --quiet ${line%vmlinuz};then
|
||||
# Mount point is already present
|
||||
# This means we already ran that hook during 'remove case'
|
||||
#
|
||||
# Remove the mount so we can reinstall the kernel
|
||||
umount ${line%vmlinuz}
|
||||
elif [[ -f "$line" && ! -d "/usr/lib/modules/running-kernel/" ]];then
|
||||
# Kernel install is present and we do not have a copy
|
||||
#
|
||||
# This is the removal case, so we save the kernel
|
||||
mkdir /usr/lib/modules/running-kernel
|
||||
cp --archive --link /usr/lib/modules/{$kver}/{kernel,modules*} \
|
||||
/usr/lib/modules/running-kernel/
|
||||
fi
|
||||
# If we are re-removing the running kernel, (after removing + reinstalling),
|
||||
# we already have a backup and this hook is a no-op
|
||||
fi
|
||||
done
|
Loading…
Reference in a new issue