How to copy a file to $SNAP_COMMON in a classical snap?


I’m updating a classical snap and i’m struggling to copy a .conf file to $SNAP_COMMON/etc/foo.conf

I tried this:

     plugin: dump
     source: src/logrotate/
       - etc/logrotate.conf

But it copies the file to /snap/foo/current/etc/logrotate.conf, but i need it in /var/snap/foo/common/etc/logrotate.conf.

I tried many variations of this segment and still did not manage to put the file in the expected place.

How should I do it? Layouts dod not work with classical snaps.

snaps are compressed (readonly) squashfs filesystem images. when you build a snap your files get copied into that filesystem …

/snap/foo/current/ is the place where the squashfs file of the “foo” snap gets mounted (this corresponds to $SNAP) at install time …

at runtime /var/snap/foo/common and /var/snap/foo/current can be used as writable space (these translate to $SNAP_COMMON and $SNAP_DATA) …

the dump plugin just defines where in your squashfs your files will go, nothing else … if you want a file somewhere in the writable space at runtime, you can copy that file from the squashfs to the writable place from either an install hook or from a command-chain wrapper that runs at startup of your app.




I see. Thanks for the info, @ogra!