diff options
author | Giancarlo Razzolini <grazzolini@archlinux.org> | 2020-07-16 16:08:11 +0200 |
---|---|---|
committer | Giancarlo Razzolini <grazzolini@archlinux.org> | 2020-07-16 16:08:11 +0200 |
commit | 3340dbc2ed92a0d9e58193d2d4082a588c1d84ca (patch) | |
tree | 6ca85d008f5abec8ed40668e7bbca73efb734cdf /libalpm/scripts | |
parent | ab34e08b4624d1a212b66cc0f2c0a2c5b9feb325 (diff) | |
download | mkinitcpio-3340dbc2ed92a0d9e58193d2d4082a588c1d84ca.tar.gz mkinitcpio-3340dbc2ed92a0d9e58193d2d4082a588c1d84ca.tar.xz |
libalpm/scripts/mkinitcpio-remove: Added the patch for the pacsave functionalityv28
When removing kernels, detect if the preset was changes and save it as a .pacsave,
instead of removing it.
Diffstat (limited to 'libalpm/scripts')
-rw-r--r-- | libalpm/scripts/mkinitcpio-remove | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/libalpm/scripts/mkinitcpio-remove b/libalpm/scripts/mkinitcpio-remove index 86838e4..17b4b31 100644 --- a/libalpm/scripts/mkinitcpio-remove +++ b/libalpm/scripts/mkinitcpio-remove @@ -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 |