Determine target version revision in snap pre-refresh hook


is it possible to get information about the target version / revision in the pre-refresh hook? E.g. by using an environment variable “REFRESH_TO_REV” “1234”?

Idea is to prevent downgrade of a snap using pre-refresh.

Will epoch 1* only hide snaps from the past (epoch 0) or also prevent installation (e.g. when sideloading)?


Regarding REFRESH_TO_REV or something like that, this information is not directly available, but you can record the previous revision info via a file or a snapctl setting that is then read from the post-refresh hook.

Thanks for the feedback.

We tried with epoch 1* and it blocks the downgrade successfully. Is there a way to force the downgrade with snapd? We need the possibility to enforce it in case of the restoration of a backup, using snapshots to downgrade the data before installing the old snap.