summaryrefslogtreecommitdiffstats
path: root/libalpm
diff options
context:
space:
mode:
authorGiancarlo Razzolini <grazzolini@archlinux.org>2019-10-10 23:40:23 +0200
committerGiancarlo Razzolini <grazzolini@archlinux.org>2019-10-10 23:40:23 +0200
commit9c1e0f3dd01151b79e9b557ea8510605616c1369 (patch)
treea7e09e6dab8ea5f13811f7ca5ecf3cef9dfddfd5 /libalpm
parent0791321ed88bc480b193889c26cf4c356f1c78f7 (diff)
downloadmkinitcpio-9c1e0f3dd01151b79e9b557ea8510605616c1369.tar.gz
mkinitcpio-9c1e0f3dd01151b79e9b557ea8510605616c1369.tar.xz
Rework the install script a bit more
Added comments to make the flow more understandable. We now actively bail when we encounter a kernel with no pkgbase. Also, if the preset does not exist yet, and there is a .pacsave, we move that instead of copying from the template. Move the preset check alongside the check if all was passed and finally, check if the args array is not empty, before trying to run mkinitcpio.
Diffstat (limited to 'libalpm')
-rw-r--r--libalpm/scripts/mkinitcpio-install29
1 files changed, 20 insertions, 9 deletions
diff --git a/libalpm/scripts/mkinitcpio-install b/libalpm/scripts/mkinitcpio-install
index ab952a7..d2e5041 100644
--- a/libalpm/scripts/mkinitcpio-install
+++ b/libalpm/scripts/mkinitcpio-install
@@ -5,29 +5,40 @@ all=0
while read -r line; do
if [[ $line != */vmlinuz ]]; then
+ # triggers when it's a change to usr/lib/initcpio/*
all=1
continue
fi
- pkgbase=$(<"${line%/vmlinuz}/pkgbase")
- [[ -n ${pkgbase} ]]
+ if ! read -r pkgbase > /dev/null 2>&1 < "${line%/vmlinuz}/pkgbase"; then
+ # if the kernel has no pkgbase, we skip it
+ continue
+ fi
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"
+ if [[ -e $preset.pacsave ]]; then
+ # move the pacsave to the template
+ mv "${preset}.pacsave" "$preset"
+ else
+ # create the preset from the template
+ sed "s|%PKGBASE%|${pkgbase}|g" /usr/share/mkinitcpio/hook.preset \
+ | install -Dm644 /dev/stdin "$preset"
+ fi
fi
+ # always install the kernel
install -Dm644 "${line}" "/boot/vmlinuz-${pkgbase}"
+
+ # compound args for each kernel
args+=(-p "${pkgbase}")
done
-if (( all )); then
+if (( all )) && compgen -G /etc/mkinitcpio.d/"*.preset" > /dev/null; then
+ # change to use all presets
args=(-P)
fi
-if ! compgen -G /etc/mkinitcpio.d/"*.preset" > /dev/null; then
- exit 0
+if (( ${#args[@]} )); then
+ mkinitcpio "${args[@]}"
fi
-
-mkinitcpio "${args[@]}"