Skip to content

Instantly share code, notes, and snippets.

@jkhsjdhjs
Last active August 21, 2018 06:32
Show Gist options
  • Save jkhsjdhjs/228ddd6e961cec005e8efefcbcf4c52c to your computer and use it in GitHub Desktop.
Save jkhsjdhjs/228ddd6e961cec005e8efefcbcf4c52c to your computer and use it in GitHub Desktop.
nvidia hooks to trigger initramfs image generation on install/update/remove
#!/usr/bin/env bash
workdir="$(cd "$(dirname "$0")" && pwd)"
xargs -I % rm "${workdir}/%" < "${workdir}/nvidia_hooks_filenames.txt" && rm "${workdir}/nvidia_hooks_filenames.txt"
[Trigger]
Type = Package
Operation = Install
Operation = Upgrade
Operation = Remove
Target = nvidia
[Action]
Description = Removing overwritten hook(s)
Depends = bash
Depends = coreutils
When = PostTransaction
Exec = /etc/pacman.d/hooks/nvidia_post.bash
#!/usr/bin/env bash
workdir="$(cd "$(dirname "$0")" && pwd)"
mkinitcpio_hooks="$(grep -Pl '^Exec\s*=\s*[/\w]*mkinitcpio' /usr/share/libalpm/hooks/*)"
mkinitcpio_hooks_basename="$(echo "$mkinitcpio_hooks" | xargs -I % basename %)"
echo "$mkinitcpio_hooks" | xargs -I % cp % "$workdir" \
&& echo "$mkinitcpio_hooks_basename" | xargs -I % bash -c "cat ${workdir}/nvidia_trigger.txt >> ${workdir}/%" \
&& echo "$mkinitcpio_hooks_basename" > "${workdir}/nvidia_hooks_filenames.txt"
[Trigger]
Type = Package
Operation = Install
Operation = Upgrade
Operation = Remove
Target = nvidia
[Action]
Description = Triggering mkinitcpio
Depends = bash
Depends = coreutils
Depends = grep
When = PreTransaction
Exec = /etc/pacman.d/hooks/nvidia_pre.bash
[Trigger]
Type = Package
Operation = Install
Operation = Upgrade
Operation = Remove
Target = nvidia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment