From dfa609a6ee5f75af1aa5f94d331aea60b6d076ca Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Wed, 9 Oct 2019 17:08:59 -0300 Subject: Rework of the script to cover all cases The script did not work properly for the cases where more than one kernel was being installed, or only when mkinitcpio without a kernel is installed. Now the script runs properly on all cases. --- libalpm/scripts/mkinitcpio-install | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/libalpm/scripts/mkinitcpio-install b/libalpm/scripts/mkinitcpio-install index 88876e2..215640b 100644 --- a/libalpm/scripts/mkinitcpio-install +++ b/libalpm/scripts/mkinitcpio-install @@ -1,19 +1,33 @@ #!/bin/bash -args=('-p') +args=() +all=0 while read -r line; do - if [[ $line = usr/lib/modules/+([^/])/pkgbase ]]; then - pkgbase=$(< "/$line") - if [[ ! -e /etc/mkinitcpio.d/"${pkgbase}".preset ]]; then - sed "s|%PKGBASE%|${pkgbase}|g" /usr/share/mkinitcpio/hook.preset | install -Dm644 /dev/stdin \ - /etc/mkinitcpio.d/"${pkgbase}".preset - fi - install -Dm644 $(dirname $line)/vmlinuz /boot/vmlinuz-"${pkgbase}" - else - args=('-P') # all presets - break + if [[ $line != */vmlinuz ]]; then + all=1 + continue fi + + pkgbase=$(<"${line%/vmlinuz}/pkgbase") + [[ -n ${pkgbase} ]] + + preset="/etc/mkinitcpio.d/${pkgbase}.preset" + if [[ ! -e $preset ]]; then + sed "s|%PKGBASE%|${pkgbase}|g" /usr/share/mkinitcpio/hook.preset \ + | install -Dm644 /dev/stdin "$preset" + fi + + install -Dm644 "${line}" "/boot/vmlinuz-${pkgbase}" + args+=(-p "${pkgbase}") done -mkinitcpio "${args[@]}" "${pkgbase}" +if (( all )); then + args=(-P) +fi + +if ! compgen -G /etc/mkinitcpio.d/*.preset > /dev/null; then + exit 0 +fi + +mkinitcpio "${args[@]}" -- cgit v1.2.3-24-g4f1b