From 1270b937c32713898d5b260b66def9eccbc161df Mon Sep 17 00:00:00 2001 From: Erica Portnoy Date: Tue, 14 Jul 2020 17:57:10 -0700 Subject: [PATCH] try comparing version numbers in python --- certbot-dns-dnsimple/snap/hooks/post-refresh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/certbot-dns-dnsimple/snap/hooks/post-refresh b/certbot-dns-dnsimple/snap/hooks/post-refresh index 8d849174b..1a1fbcf88 100644 --- a/certbot-dns-dnsimple/snap/hooks/post-refresh +++ b/certbot-dns-dnsimple/snap/hooks/post-refresh @@ -2,8 +2,8 @@ # get certbot version if [ ! -f "$SNAP/certbot-shared/__init__.py" ]; then - echo "No certbot version available; not doing version comparison check" >> "$SNAP_DATA/debuglog" - exit 0 + echo "No certbot version available; not doing version comparison check" >> "$SNAP_DATA/debuglog" + exit 0 fi cb_installed=$(grep -oP "__version__ = '\K.*(?=')" $SNAP/certbot-shared/__init__.py) @@ -13,8 +13,11 @@ echo "cb_installed: $cb_installed" >> "$SNAP_DATA/debuglog" cb_required=$(grep -oP "certbot>=\K.*(?=')" $SNAP/setup.py) echo "cb_required: $cb_required" >> "$SNAP_DATA/debuglog" -if [ "$cb_installed" -lt "$cb_required" ]; then - echo "Certbot is version $cb_installed but needs to be at least $cb_required before \ +python -c 'from distutils.version import LooseVersion;\ + exit(1) if LooseVersion("$cb_installed") < LooseVersion("$cb_required") else exit(0)' + +if [ "$?" -eq 1 ]; then + echo "Certbot is version $cb_installed but needs to be at least $cb_required before \ this plugin can be updated; will try again on next refresh." - exit 1 + exit 1 fi