Add pacman hook for installing kernel in host.
This commit is contained in:
parent
30ab328780
commit
325d121fe2
12
pacman_hooks/hooks/90-dracut-install.hook
Normal file
12
pacman_hooks/hooks/90-dracut-install.hook
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[Trigger]
|
||||||
|
Type = Path
|
||||||
|
Operation = Install
|
||||||
|
Operation = Upgrade
|
||||||
|
Target = usr/lib/modules/*/pkgbase
|
||||||
|
Target = usr/lib/dracut/*
|
||||||
|
|
||||||
|
[Action]
|
||||||
|
Description = Updating linux initcpios in host...
|
||||||
|
When = PostTransaction
|
||||||
|
Exec = /usr/share/libalpm/scripts/dracut-install
|
||||||
|
NeedsTargets
|
34
pacman_hooks/scripts/dracut-install
Executable file
34
pacman_hooks/scripts/dracut-install
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
kernels=()
|
||||||
|
dracut_update=0
|
||||||
|
|
||||||
|
while read -r line; do
|
||||||
|
if [[ $line != 'usr/lib/modules/'+([^/])'/pkgbase' ]]; then
|
||||||
|
dracut_update=1 # Dracut files have been updated
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -r pkgbase < "/${line}"
|
||||||
|
kernels+=("${pkgbase}")
|
||||||
|
done
|
||||||
|
|
||||||
|
if (( dracut_update )); then
|
||||||
|
kernels=()
|
||||||
|
for file in /lib/modules/*/pkgbase; do
|
||||||
|
if read -r pkgbase &> /dev/null < "$file"; then
|
||||||
|
kernels+=("${pkgbase}")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
for kernel in "${kernels[@]}"; do
|
||||||
|
path="$(grep -lE "^${kernel}\$" /usr/lib/modules/*/pkgbase)"
|
||||||
|
version=$(basename "${path%/pkgbase}")
|
||||||
|
read -r pkgbase < "$path"
|
||||||
|
|
||||||
|
install -Dm0644 "/${path%'/pkgbase'}/vmlinuz" "/boot/vmlinuz-${pkgbase}"
|
||||||
|
|
||||||
|
echo ":: Building initramfs for $kernel-$version in host..."
|
||||||
|
chroot /var/host /bin/su -c "dracut -f \"/boot/initramfs-${kernel}.img\" --kver \"${version}\""
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user