diff options
author | Giancarlo Razzolini <grazzolini@archlinux.org> | 2019-10-09 22:08:59 +0200 |
---|---|---|
committer | Giancarlo Razzolini <grazzolini@archlinux.org> | 2019-10-09 22:08:59 +0200 |
commit | dfa609a6ee5f75af1aa5f94d331aea60b6d076ca (patch) | |
tree | 9c274d1532be405bf81097d5940588e459c41e4d | |
parent | e631c842069efcd661a066e16a6b1aca3ed62817 (diff) | |
download | mkinitcpio-dfa609a6ee5f75af1aa5f94d331aea60b6d076ca.tar.gz mkinitcpio-dfa609a6ee5f75af1aa5f94d331aea60b6d076ca.tar.xz |
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.
-rw-r--r-- | libalpm/scripts/mkinitcpio-install | 38 |
1 files 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[@]}" |