Following up on Andy's comment above (which may or may not have been cargo-cult from an IRC conversation we had), I think a sane approach would be:
1) Create unit files in /var/snap/systemd/foo.{mount,service} 2) Symlink /etc/systemd/system/foo -> /var/snap/systemd/foo
On postrm/purge, you can then do the same list-unit-files trick, but:
1) readlink /etc/systemd/system/foo 2) iff symlink points to /var/snap/systemd/*, remove.
That way, you're not claiming absolutely dominion over a namespace that other packages or the sysadmin may have other ideas about.
Following up on Andy's comment above (which may or may not have been cargo-cult from an IRC conversation we had), I think a sane approach would be:
1) Create unit files in /var/snap/ systemd/ foo.{mount, service} system/ foo -> /var/snap/ systemd/ foo
2) Symlink /etc/systemd/
On postrm/purge, you can then do the same list-unit-files trick, but:
1) readlink /etc/systemd/ system/ foo systemd/ *, remove.
2) iff symlink points to /var/snap/
That way, you're not claiming absolutely dominion over a namespace that other packages or the sysadmin may have other ideas about.