Use hardlinks, bind mount and systemd-tmpfiles to simplify the logic
Hi folks,
I propose to simplify the logic by relying on bind mount and systemd-tmpfiles instead of cleaning up ourselves.
High-level view of new workflow :
On kernel upgrade / or removal :
- cp the whole /usr/lib/modules/$(kver) tree using hardlinks before the transaction to /usr/lib/modules/backup-$(kver)
- after the transaction, bind mount /usr/lib/modules/backup-$(kver) to /usr/lib/modules/$(kver)
- On next boot, bind mount is gone so :
-> we delete recursively dir matching
/usr/lib/modules/backup-*-> we delete empty dir matching/usr/lib/modules/*(installed kernel is not emtpy so it will not be deleted, but the mount point for the old kernel is)
That's a pretty big change ; I'm ok forking if you think it does not fit that project.
Thanks.
Brilliant idea. But there's one little flaw: what if the user would like to revert back to the running kernel without a reboot? The bind mounted old kernel would essentially block the downgrade path.
Good point.
Maybe it can be solved with another hook which removes the bind mount on upgrade if there is one matching the current kernel.
I'll think about that, a bit busy with life right now.
Hi o/
So I reworked a bit the hooks:
The pre-hook:
- check if the path exist -> detect whether we install or remove
- only copy if the copy does not exist yet (multiple install/uninstall case)
- checks if there is already a mount only when triggered by "Install" (-> the case where the user reinstall the running kernel after having installed another version)
- Also, we only copy the kernel/ directy and all modules* files, which should supersede #12 (when other scripts have problem with duplicate pkgbase)
WARNING: I haven't tested it yet.
Thoughts ?
Great job!
Your script is faulty in several ways fix: https://github.com/archlinux-jerry/pkgbuilds/commit/512e59c17da6b2e35fc053ac4cc45adda27317b3 and https://github.com/archlinux-jerry/pkgbuilds/commit/d49e7113e283159fc3448acca875e4091b4c064e
It's actually worse than that, because rollback is really problematic. You end up with files present conflicting with files pacman want to place in the fs.
A proper solution should be to use depmod to tell the kernel where the modules are, but I need to look at documenation for that and I've been missing the time.
I don't see any file conflict.
should have removed the mount point after umount https://github.com/archlinux-jerry/pkgbuilds/commit/f69c1abf352613767dc458a61b12b46d3b582b59