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

Merge branch 'alpm-hook'

parents 9ae6b1f9 c0ae6a74
No related branches found
No related tags found
No related merge requests found
......@@ -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,11 @@ 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-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
a2x -d manpage \
......
[Trigger]
Type = File
Operation = Remove
Target = usr/lib/modules/*/vmlinuz
[Trigger]
Type = Package
Operation = Remove
Target = mkinitcpio
Target = mkinitcpio-git
[Action]
Description = Removing linux initcpios...
When = PreTransaction
Exec = /usr/share/libalpm/scripts/mkinitcpio-remove
NeedsTargets
[Trigger]
Type = File
Operation = Install
Operation = Upgrade
Target = usr/lib/modules/*/vmlinuz
Target = usr/lib/initcpio/*
[Action]
Description = Updating linux initcpios...
When = PostTransaction
Exec = /usr/share/libalpm/scripts/mkinitcpio-install
NeedsTargets
#!/bin/bash -e
args=()
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
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
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 )) && compgen -G /etc/mkinitcpio.d/"*.preset" > /dev/null; then
# change to use all presets
args=(-P)
fi
if (( ${#args[@]} )); then
mkinitcpio "${args[@]}"
fi
#!/bin/bash -e
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
# 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"
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