From b85056e0096172d01ff6ce5f7c14c3ca5664a939 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Wed, 9 Oct 2019 00:05:33 -0300 Subject: Add a new mkinitcpio pacman hook This hook runs on mkinitcpio updates as well as on kernels containing the pkgbase file on their modules directory. It calls the mkinitcpio script. --- libalpm/hooks/90-mkinitcpio.hook | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 libalpm/hooks/90-mkinitcpio.hook diff --git a/libalpm/hooks/90-mkinitcpio.hook b/libalpm/hooks/90-mkinitcpio.hook new file mode 100644 index 0000000..7599eae --- /dev/null +++ b/libalpm/hooks/90-mkinitcpio.hook @@ -0,0 +1,17 @@ +[Trigger] +Type = Package +Operation = Install +Operation = Upgrade +Target = mkinitcpio* + +[Trigger] +Type = File +Operation = Install +Operation = Upgrade +Target = usr/lib/modules/*/pkgbase + +[Action] +Description = Updating linux initcpios... +When = PostTransaction +Exec = /usr/share/libalpm/scripts/mkinitcpio.script +NeedsTargets -- cgit v1.2.3-24-g4f1b From e8106a8e24588c1ba65f4c563d55a4275b0e4b70 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Wed, 9 Oct 2019 00:08:21 -0300 Subject: Add a mkinitcpio pacman script This script runs on mkinitcpio package updates as well as on kernel updates that have the pkgbase file on their modules directory. It will use the contents of that file to determine which preset to run or, in case not pkgbase file is passed to it, it will run all presets with -P. --- libalpm/scripts/mkinitcpio.script | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 libalpm/scripts/mkinitcpio.script diff --git a/libalpm/scripts/mkinitcpio.script b/libalpm/scripts/mkinitcpio.script new file mode 100644 index 0000000..70c9784 --- /dev/null +++ b/libalpm/scripts/mkinitcpio.script @@ -0,0 +1,14 @@ +#!/bin/bash + +args=('-p') + +while read -r line; do + if [[ $line = usr/lib/modules/+([^/])/pkgbase ]]; then + mapfile -O ${#targets[@]} -t targets < "/$line" + else + args=('-P') # all presets + break + fi +done + +mkinitcpio "${args[@]}" "${targets[@]}" -- cgit v1.2.3-24-g4f1b From 9347ed6bee0fdbb03847238ca60a21ce7a27c40e Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Wed, 9 Oct 2019 00:10:13 -0300 Subject: Add the pacman hook and script files to the installation Changed the Makefile to properly install the pacman hook and script. --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 94c90de..f3ffa82 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,9 @@ DIRS = \ /usr/share/man/man1 \ /usr/share/mkinitcpio \ /usr/lib/systemd/system/shutdown.target.wants \ - /usr/lib/tmpfiles.d + /usr/lib/tmpfiles.d \ + /usr/share/libalpm/hooks \ + /usr/share/libalpm/scripts BASH_SCRIPTS = \ mkinitcpio \ @@ -70,6 +72,9 @@ install: all ln -s mkinitcpio $(DESTDIR)/usr/share/bash-completion/completions/lsinitcpio install -m644 shell/zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_mkinitcpio + install -m644 libalpm/hooks/90-mkinitcpio.hook $(DESTDIR)/usr/share/libalpm/hooks/90-mkinitcpio.hook + install -m755 libalpm/scripts/mkinitcpio.script $(DESTDIR)/usr/share/libalpm/scripts/mkinitcpio.script + doc: $(MANPAGES) man/%: man/%.txt Makefile a2x -d manpage \ -- cgit v1.2.3-24-g4f1b From ace8c6de2b01d7d7b23c5d6db88daeac80df9448 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Wed, 9 Oct 2019 14:38:25 -0300 Subject: Add a preset to be used by the pacman hook to create presets on the fly This will be used by the pacman hook to create presets on the fly for new kernels being installed based on pkgbase. --- mkinitcpio.d/hook.preset | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 mkinitcpio.d/hook.preset diff --git a/mkinitcpio.d/hook.preset b/mkinitcpio.d/hook.preset new file mode 100644 index 0000000..66709a8 --- /dev/null +++ b/mkinitcpio.d/hook.preset @@ -0,0 +1,14 @@ +# mkinitcpio preset file for the '%PKGBASE%' package + +ALL_config="/etc/mkinitcpio.conf" +ALL_kver="/boot/vmlinuz-%PKGBASE%" + +PRESETS=('default' 'fallback') + +#default_config="/etc/mkinitcpio.conf" +default_image="/boot/initramfs-%PKGBASE%.img" +#default_options="" + +#fallback_config="/etc/mkinitcpio.conf" +fallback_image="/boot/initramfs-%PKGBASE%-fallback.img" +fallback_options="-S autodetect" -- cgit v1.2.3-24-g4f1b From 2adc98944dfe0c40da44b6a2d8877af68b1f2bbe Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Wed, 9 Oct 2019 14:43:36 -0300 Subject: Change the hook name and change the name of the script called by it The hook was renamed to reflect it will be triggered only on install (or upgrades). This is because we will have a hook/script pair running on kernels removals as well. --- libalpm/hooks/90-mkinitcpio-install.hook | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 libalpm/hooks/90-mkinitcpio-install.hook diff --git a/libalpm/hooks/90-mkinitcpio-install.hook b/libalpm/hooks/90-mkinitcpio-install.hook new file mode 100644 index 0000000..a13451e --- /dev/null +++ b/libalpm/hooks/90-mkinitcpio-install.hook @@ -0,0 +1,17 @@ +[Trigger] +Type = Package +Operation = Install +Operation = Upgrade +Target = mkinitcpio* + +[Trigger] +Type = File +Operation = Install +Operation = Upgrade +Target = usr/lib/modules/*/pkgbase + +[Action] +Description = Updating linux initcpios... +When = PostTransaction +Exec = /usr/share/libalpm/scripts/mkinitcpio-install +NeedsTargets -- cgit v1.2.3-24-g4f1b From dfcdcf483c1b27dbb9fb91bc53f745cedba709cb Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Wed, 9 Oct 2019 14:48:42 -0300 Subject: Rework the script to create the preset and install the actual kernel to /boot The script now will use a prepared preset to create presets when new kernels are installed. It will also always copy the vmlinuz kernel to /boot. --- libalpm/scripts/mkinitcpio-install | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 libalpm/scripts/mkinitcpio-install diff --git a/libalpm/scripts/mkinitcpio-install b/libalpm/scripts/mkinitcpio-install new file mode 100644 index 0000000..88876e2 --- /dev/null +++ b/libalpm/scripts/mkinitcpio-install @@ -0,0 +1,19 @@ +#!/bin/bash + +args=('-p') + +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 + fi +done + +mkinitcpio "${args[@]}" "${pkgbase}" -- cgit v1.2.3-24-g4f1b From bccd41015aaa55d1e661c503e74a414c86290b61 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Wed, 9 Oct 2019 14:50:48 -0300 Subject: Change the Makefile to reflect the change in the names of the hook and script --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f3ffa82..7b19ddb 100644 --- a/Makefile +++ b/Makefile @@ -72,8 +72,8 @@ install: all ln -s mkinitcpio $(DESTDIR)/usr/share/bash-completion/completions/lsinitcpio install -m644 shell/zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_mkinitcpio - install -m644 libalpm/hooks/90-mkinitcpio.hook $(DESTDIR)/usr/share/libalpm/hooks/90-mkinitcpio.hook - install -m755 libalpm/scripts/mkinitcpio.script $(DESTDIR)/usr/share/libalpm/scripts/mkinitcpio.script + install -m644 libalpm/hooks/90-mkinitcpio-install.hook $(DESTDIR)/usr/share/libalpm/hooks/90-mkinitcpio-install.hook + install -m755 libalpm/scripts/mkinitcpio-install $(DESTDIR)/usr/share/libalpm/scripts/mkinitcpio-install doc: $(MANPAGES) man/%: man/%.txt Makefile -- cgit v1.2.3-24-g4f1b From 6a68249f84ff72e7f38bc0b7edae55c861fdfb3c Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Wed, 9 Oct 2019 14:51:23 -0300 Subject: Rename of the hook and script --- libalpm/hooks/90-mkinitcpio.hook | 17 ----------------- libalpm/scripts/mkinitcpio.script | 14 -------------- 2 files changed, 31 deletions(-) delete mode 100644 libalpm/hooks/90-mkinitcpio.hook delete mode 100644 libalpm/scripts/mkinitcpio.script diff --git a/libalpm/hooks/90-mkinitcpio.hook b/libalpm/hooks/90-mkinitcpio.hook deleted file mode 100644 index 7599eae..0000000 --- a/libalpm/hooks/90-mkinitcpio.hook +++ /dev/null @@ -1,17 +0,0 @@ -[Trigger] -Type = Package -Operation = Install -Operation = Upgrade -Target = mkinitcpio* - -[Trigger] -Type = File -Operation = Install -Operation = Upgrade -Target = usr/lib/modules/*/pkgbase - -[Action] -Description = Updating linux initcpios... -When = PostTransaction -Exec = /usr/share/libalpm/scripts/mkinitcpio.script -NeedsTargets diff --git a/libalpm/scripts/mkinitcpio.script b/libalpm/scripts/mkinitcpio.script deleted file mode 100644 index 70c9784..0000000 --- a/libalpm/scripts/mkinitcpio.script +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -args=('-p') - -while read -r line; do - if [[ $line = usr/lib/modules/+([^/])/pkgbase ]]; then - mapfile -O ${#targets[@]} -t targets < "/$line" - else - args=('-P') # all presets - break - fi -done - -mkinitcpio "${args[@]}" "${targets[@]}" -- cgit v1.2.3-24-g4f1b From e631c842069efcd661a066e16a6b1aca3ed62817 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Wed, 9 Oct 2019 17:07:01 -0300 Subject: Changed the trigger to vmlinuz All the kernels install the kernel to the file vmlinuz, so triggering on it makes more sense. The pkgbase file is still used on the script. --- libalpm/hooks/90-mkinitcpio-install.hook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libalpm/hooks/90-mkinitcpio-install.hook b/libalpm/hooks/90-mkinitcpio-install.hook index a13451e..700350f 100644 --- a/libalpm/hooks/90-mkinitcpio-install.hook +++ b/libalpm/hooks/90-mkinitcpio-install.hook @@ -8,7 +8,7 @@ Target = mkinitcpio* Type = File Operation = Install Operation = Upgrade -Target = usr/lib/modules/*/pkgbase +Target = usr/lib/modules/*/vmlinuz [Action] Description = Updating linux initcpios... -- cgit v1.2.3-24-g4f1b 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 From 59bdecbf138936f1eb61c9616d7270d92a5deac5 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Wed, 9 Oct 2019 18:34:33 -0300 Subject: Change the script to abort on errors and quote the glob on compgen --- libalpm/scripts/mkinitcpio-install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libalpm/scripts/mkinitcpio-install b/libalpm/scripts/mkinitcpio-install index 215640b..ab952a7 100644 --- a/libalpm/scripts/mkinitcpio-install +++ b/libalpm/scripts/mkinitcpio-install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e args=() all=0 @@ -26,7 +26,7 @@ if (( all )); then args=(-P) fi -if ! compgen -G /etc/mkinitcpio.d/*.preset > /dev/null; then +if ! compgen -G /etc/mkinitcpio.d/"*.preset" > /dev/null; then exit 0 fi -- cgit v1.2.3-24-g4f1b From 0791321ed88bc480b193889c26cf4c356f1c78f7 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Thu, 10 Oct 2019 18:21:51 -0300 Subject: Change the install hook to trigger on usr/lib/initcpio/* instead of mkinitcpio* package Since not only mkinitcpio* packages touch /usr/lib/initcpio, switch the hook to triggering on that. --- libalpm/hooks/90-mkinitcpio-install.hook | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libalpm/hooks/90-mkinitcpio-install.hook b/libalpm/hooks/90-mkinitcpio-install.hook index 700350f..48e6a1e 100644 --- a/libalpm/hooks/90-mkinitcpio-install.hook +++ b/libalpm/hooks/90-mkinitcpio-install.hook @@ -1,14 +1,9 @@ -[Trigger] -Type = Package -Operation = Install -Operation = Upgrade -Target = mkinitcpio* - [Trigger] Type = File Operation = Install Operation = Upgrade Target = usr/lib/modules/*/vmlinuz +Target = usr/lib/initcpio/* [Action] Description = Updating linux initcpios... -- cgit v1.2.3-24-g4f1b From 9c1e0f3dd01151b79e9b557ea8510605616c1369 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Thu, 10 Oct 2019 18:40:23 -0300 Subject: 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. --- libalpm/scripts/mkinitcpio-install | 29 ++++++++++++++++++++--------- 1 file 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[@]}" -- cgit v1.2.3-24-g4f1b From f949879ce6de354e02e06daa81e9257fdab07699 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Mon, 14 Oct 2019 23:28:04 -0300 Subject: Add a remove hook This hook triggers when a kernel is removed or when the mkinitcpio package itself is being removed. --- libalpm/hooks/60-mkinitcpio-remove.hook | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 libalpm/hooks/60-mkinitcpio-remove.hook diff --git a/libalpm/hooks/60-mkinitcpio-remove.hook b/libalpm/hooks/60-mkinitcpio-remove.hook new file mode 100644 index 0000000..ba2b649 --- /dev/null +++ b/libalpm/hooks/60-mkinitcpio-remove.hook @@ -0,0 +1,15 @@ +[Trigger] +Type = File +Operation = Remove +Target = usr/lib/modules/*/vmlinuz + +[Trigger] +Type = Package +Operation = Remove +Target = mkinitcpio + +[Action] +Description = Removing linux initcpios... +When = PostTransaction +Exec = /usr/share/libalpm/scripts/mkinitcpio-remove +NeedsTargets -- cgit v1.2.3-24-g4f1b From b22d1f578396cae9adec0389bc470cf321ae139f Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Mon, 28 Oct 2019 22:30:10 -0300 Subject: libalpm/hooks: Change the remove hook to PreTransaction and also match on mkinitcpio-git. Since the hook actually needs to be able to match on a kernel pkgbase, it needs to be ran PreTransaction and not Post. Also add an additional target on mkinitcpio-git, to aid development. --- libalpm/hooks/60-mkinitcpio-remove.hook | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libalpm/hooks/60-mkinitcpio-remove.hook b/libalpm/hooks/60-mkinitcpio-remove.hook index ba2b649..ab71ed6 100644 --- a/libalpm/hooks/60-mkinitcpio-remove.hook +++ b/libalpm/hooks/60-mkinitcpio-remove.hook @@ -7,9 +7,10 @@ Target = usr/lib/modules/*/vmlinuz Type = Package Operation = Remove Target = mkinitcpio +Target = mkinitcpio-git [Action] Description = Removing linux initcpios... -When = PostTransaction +When = PreTransaction Exec = /usr/share/libalpm/scripts/mkinitcpio-remove NeedsTargets -- cgit v1.2.3-24-g4f1b From d5e3f26dcdf623099c4f0fe5cceb72f34cebdc49 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Mon, 28 Oct 2019 22:31:59 -0300 Subject: Makefile: Add the remove hook and script to install Add the remove hook and remove script as part of the installation. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 7b19ddb..9ef0f6a 100644 --- a/Makefile +++ b/Makefile @@ -74,6 +74,8 @@ install: all install -m644 libalpm/hooks/90-mkinitcpio-install.hook $(DESTDIR)/usr/share/libalpm/hooks/90-mkinitcpio-install.hook install -m755 libalpm/scripts/mkinitcpio-install $(DESTDIR)/usr/share/libalpm/scripts/mkinitcpio-install + install -m644 libalpm/hooks/60-mkinitcpio-remove.hook $(DESTDIR)/usr/share/libalpm/hooks/60-mkinitcpio-remove.hook + install -m755 libalpm/scripts/mkinitcpio-remove $(DESTDIR)/usr/share/libalpm/scripts/mkinitcpio-remove doc: $(MANPAGES) man/%: man/%.txt Makefile -- cgit v1.2.3-24-g4f1b From 9b0dfc9fbed73c9a70fa9ad7aea58c3b4f47ad0c Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Tue, 29 Oct 2019 09:52:45 -0300 Subject: libalpm/scripts: Add a remove script Add a remove script that cleans up kernels, images and presets upon kernel removals. It also handles mkinitcpio removal, by cleaning up presets. --- libalpm/scripts/mkinitcpio-remove | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 libalpm/scripts/mkinitcpio-remove diff --git a/libalpm/scripts/mkinitcpio-remove b/libalpm/scripts/mkinitcpio-remove new file mode 100644 index 0000000..dbce860 --- /dev/null +++ b/libalpm/scripts/mkinitcpio-remove @@ -0,0 +1,39 @@ +#!/bin/bash -x + +package=0 + +while read -r line; do + if [[ $line != */vmlinuz ]]; then + # triggers when it's a change to usr/lib/initcpio/* + package=1 + continue + fi + + if ! read -r pkgbase > /dev/null 2>&1 < "${line%/vmlinuz}/pkgbase"; then + # if the kernel has no pkgbase, we skip it + continue + fi + + # remove the actual kernel and images for the package being removed + kernel="/boot/vmlinuz-${pkgbase}" + preset="/etc/mkinitcpio.d/${pkgbase}.preset" + initramfs="/boot/initramfs-${pkgbase}.img" + fallback_initramfs="/boot/initramfs-${pkgbase}-fallback.img" + if [[ -e $kernel ]]; then + # remove the installed kernel + rm $kernel + fi + if [[ -e $preset ]]; then + # remove the preset + rm $preset + fi + if [[ -e $initramfs && -e $fallback_initramfs ]]; then + # remove the images + rm $initramfs $fallback_initramfs + fi +done + +if (( package )) && compgen -G /etc/mkinitcpio.d/"*.preset" > /dev/null; then + # remove all presets + rm /etc/mkinitcpio.d/*.preset +fi -- cgit v1.2.3-24-g4f1b From c0ae6a74f30a586c91fb4a4f2ad773f1c018d8b6 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Tue, 29 Oct 2019 10:04:27 -0300 Subject: mkinitcpio-remove: Fix the script to use -e Changed the script to use -e for exiting in case of uncaught errors. --- libalpm/scripts/mkinitcpio-remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libalpm/scripts/mkinitcpio-remove b/libalpm/scripts/mkinitcpio-remove index dbce860..86838e4 100644 --- a/libalpm/scripts/mkinitcpio-remove +++ b/libalpm/scripts/mkinitcpio-remove @@ -1,4 +1,4 @@ -#!/bin/bash -x +#!/bin/bash -e package=0 -- cgit v1.2.3-24-g4f1b