How can I find the revision number of the snap that is being refreshed inside of a hook?
My project writes a parameter file (lets call it /tmp/parameters.yaml) that needs to be backed up before refreshing and restored after refresh depending on the snap revision number.
For example, let’s say I run “snap list” and get:
Name Version Rev Tracking Publisher Notes
...
myawesomesnap 0.1.2 9 latest/edge me -
...
and that I have released revision 10. When I execute the refresh I want the pre-refresh hook to back up the parameters of revision 9 (lets call it /tmp/parameters.yaml.rev-9) and I want the post-refresh hook to look for the backed up parameters for the revision being installed ( /tmp/parameters.yaml.rev-10) and restore the parameters file if the backup exists.
I have defined the following hooks:
hooks:
configure:
plugs: []
pre-refresh:
plugs: []
post-refresh:
plugs: []
the corresponding scripts in the folder “snap/hooks” exist and are executed properly. How can I find the information that I need?
Thanks in advance for your help