Skip to content
Snippets Groups Projects
Verified Commit 3340dbc2 authored by Giancarlo Razzolini's avatar Giancarlo Razzolini
Browse files

libalpm/scripts/mkinitcpio-remove: Added the patch for the pacsave functionality

When removing kernels, detect if the preset was changes and save it as a .pacsave,
instead of removing it.
parent ab34e08b
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,20 @@
package=0
process_preset() {
if [[ -n "${pkgbase}" && -e $preset ]]; then
if ! cmp $preset > /dev/null 2>&1 <(sed "s|%PKGBASE%|${pkgbase}|g" /usr/share/mkinitcpio/hook.preset); then
if [[ ! -e $preset.pacsave ]]; then
# save the preset as pacsave
mv $preset $preset.pacsave && return 0
fi
else
# remove the preset
rm $preset && return 0
fi
fi
}
while read -r line; do
if [[ $line != */vmlinuz ]]; then
# triggers when it's a change to usr/lib/initcpio/*
......@@ -23,17 +37,25 @@ while read -r line; do
# remove the installed kernel
rm $kernel
fi
if [[ -e $preset ]]; then
# remove the preset
rm $preset
process_preset "${pkgbase}" $preset
if [[ -e $initramfs ]]; then
# remove the main image
rm $initramfs
fi
if [[ -e $initramfs && -e $fallback_initramfs ]]; then
# remove the images
rm $initramfs $fallback_initramfs
if [[ -e $fallback_initramfs ]]; then
# remove the fallback image
rm $fallback_initramfs
fi
done
if (( package )) && compgen -G /etc/mkinitcpio.d/"*.preset" > /dev/null; then
# remove all presets
rm /etc/mkinitcpio.d/*.preset
shopt -s nullglob
for preset in /etc/mkinitcpio.d/*.preset; do
pkgbase=${preset##*/}
pkgbase=${pkgbase%.preset}
process_preset "${pkgbase}" $preset
done
shopt -u nullglob
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment