wesbarnett / snap-pac

Pacman hooks that use snapper to create pre/post btrfs snapshots like openSUSE's YaST
GNU General Public License v2.0
183 stars 14 forks source link

Document example pacman hook that symlinks old kernel modules #24

Closed wesbarnett closed 5 years ago

wesbarnett commented 6 years ago

I removed this functionality on the master branch due to all of the issues it brings. We should at least add something to show users how to add it back.

wesbarnett commented 6 years ago

cf. #22

wesbarnett commented 6 years ago

This hook has the same behavior as what has been removed from the main script.

[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = linux

[Action]
Description = Symlinking old kernel modules...
When = PostTransaction
Exec = /usr/bin/bash -c "find /usr/lib/modules -xtype l -delete; ln -sv /.snapshots/$(snapper -c root list -t pre-post | awk 'END{print $1}')/snapshot/usr/lib/modules/$(uname -r) /usr/lib/modules/"
ckotte commented 6 years ago

You could ad this as well.

Systemd unit "delete-old-kernel-module-link.service"

[Unit]
Description=Delete old Kernel module link(s) created by snap-pac

[Service]
ExecStart=/usr/bin/bash -c "find /usr/lib/modules -maxdepth 1 -type l -delete"

[Install]
WantedBy=default.target

This deletes the link of the old kernel during boot.

ckotte commented 6 years ago

The snapper command of the pacman hook should be changed to snapper -c root list | awk 'END{print $3}' or you should explicitly mention that the hook needs to be named zzz-XYZ.hook to force the execution after the zy_snapper-post hook.

snapper -c root list -t pre-post only lists the last pre-post snapshots. If you only have a pre snapshot (if the hook is executed before the post snapshot was created), it won't be displayed with this command. The pre snapshot of the last existing pre-post snapshots will be used instead.