-
-
Save simonbru/f1bfddeedc3429a04e62 to your computer and use it in GitHub Desktop.
ALPM (pacman) hook compiling dkms modules when necessary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
list_installed_kernels() { | |
for i in /usr/lib/modules/*/build/Kconfig; do | |
sed -rn 's#/usr/lib/modules/(.*)/build/Kconfig#\1#p' <<< "$i" | |
done | |
} | |
build_all_modules() { | |
while read kernel; do | |
dkms autoinstall -k "$kernel" | |
done | |
} | |
# Building missing modules for all installed kernels | |
list_installed_kernels | build_all_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Load DKMS modules | |
[Service] | |
Type=oneshot | |
RemainAfterExit=yes | |
#ExecStart=/bin/sh -c 'for i in $(find /var/lib/dkms -iname "*.ko" | grep $(uname -r)); do m="$(basename "$i")"; modprobe -b "${m%.*}"; done' | |
ExecStart=/bin/sh -c 'for i in $$(find /var/lib/dkms -iname "*.ko" | grep $$(uname -r)); do m="$$(basename "$i")"; modprobe -b "$${m%.*}"; done' | |
ExecStop=/usr/lib/systemd/scripts/dkms stop | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Trigger] | |
Operation = Install | |
Operation = Upgrade | |
Type = File | |
Target = usr/src/* | |
Target = usr/lib/modules/* | |
[Action] | |
Description = Building missing modules for all installed kernels | |
When = PostTransaction | |
Exec = /etc/pacman.d/hooks.bin/dkms | |
Depends = dkms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment