mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 16:19:13 +02:00
Make externally snapped plugin updates more stable (#8145)
Fixes #7863. Connect command is `sudo snap connect certbot-dns-dnsimple:certbot-metadata certbot:certbot-metadata` Logs are `cat /var/snap/certbot-dns-dnsimple/current/debuglog` Echos in hook are only printed to terminal when it exits 0; otherwise, check logs in `debuglog` mentioned above. Manual tests include all iterations of connected, unconnected, installed for the first, second time, etc, with passing and failing version checks. * Make dnsimple not update if certbot is too old * create an interface to read cb version * add missing newline * fix syntax * trying to figure out the consumer syntax * trying to figure out the consumer syntax, again * only check post first install * valid setting name * test for first install differently * snapctl doesn't error if it fails I guess * time to do some print debugging * continue playing with syntax * once again, fooled by bash int vs string comparisons! * debugging * if we use post and pre together we can do this * is this how content interface syntax works * it's a directory? * more debug * what's that error message again? * try other syntax * if it's not documented just guess at syntax * actually, I think this is the syntax * oops didn't set for new hook * test passing information along connection * interface attributes can only be set during the execution of prepare hooks * just do it with main connection * undo last few test changes * Add some printing to make sure we understand what's going on * create empty directory to bind to * put mkdir in the correct part * let's inspect the environment * it can't run bash directly. * perhaps only directories can be shared via the contente interface * update name of folder * echo to debug log to understand what's going on exactly. we have file access though! * update grep for new file * more printing * echo to the debug log * ok NOW all print statements are going to the log * why does echo need two >s * remove unnecessary extra check, just check if the init file is available * check if certbot version will be available post-refresh after all * pre-refresh hook is not necessary to get certbot version * update mkdir so we don't have to clean each time * try comparing version numbers in python * it's python3 * we need different prints for if we succeed or if we fail. * improve bash syntax * remove some debugging code * Remove debug script * remove spaces for clarity * consolidate parts and remove more test code * s/certbot-version/certbot-metadata/g * use sys.exit instead of exit * find and save certbot version on the certbot side * change presence test to new file * switch to using packaging.version.parse instead of LooseVersion * switch to requiring certbot version >= plugin version * add plugin snap changes to generate script * Add comment to generation file saying not to edit generated files manually * Create post-refresh hook for all plugins with script * generate files using new script * update snapcraft.yaml files for plugins * bin/sh comes first * Add packaging to install_requires * Check that refresh is allowed in integration test * switch plug and slot names in integration test * Update tools/generate_dnsplugins_postrefreshhook.sh Co-authored-by: Brad Warren <bmw@users.noreply.github.com> * small bash fixes * Update snap readme with new instructions * Run tools/generate_dnsplugins_postrefreshhook.sh * Update tools/snap/generate_dnsplugins_postrefreshhook.sh Co-authored-by: Brad Warren <bmw@users.noreply.github.com> Co-authored-by: Brad Warren <bmw@users.noreply.github.com>
This commit is contained in:
co-authored by
Brad Warren
parent
14dfbdbea5
commit
9ee4831f78
@@ -17,14 +17,16 @@ install_requires = [
|
||||
'zope.interface',
|
||||
]
|
||||
|
||||
if not os.environ.get('EXCLUDE_CERTBOT_DEPS'):
|
||||
if not os.environ.get('SNAP_BUILD'):
|
||||
install_requires.extend([
|
||||
'acme>=0.31.0',
|
||||
'certbot>=1.1.0',
|
||||
])
|
||||
elif 'bdist_wheel' in sys.argv[1:]:
|
||||
raise RuntimeError('Unset EXCLUDE_CERTBOT_DEPS when building wheels '
|
||||
raise RuntimeError('Unset SNAP_BUILD when building wheels '
|
||||
'to include certbot dependencies.')
|
||||
if os.environ.get('SNAP_BUILD'):
|
||||
install_requires.append('packaging')
|
||||
|
||||
setuptools_known_environment_markers = (LooseVersion(setuptools_version) >= LooseVersion('36.2'))
|
||||
if setuptools_known_environment_markers:
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh -e
|
||||
# This file is generated by tools/generate_dnsplugins_postrefreshhook.sh and should not be edited manually.
|
||||
|
||||
# get certbot version
|
||||
if [ ! -f "$SNAP/certbot-shared/certbot-version.txt" ]; then
|
||||
echo "No certbot version available; not doing version comparison check" >> "$SNAP_DATA/debuglog"
|
||||
exit 0
|
||||
fi
|
||||
cb_installed=$(cat $SNAP/certbot-shared/certbot-version.txt)
|
||||
|
||||
# get required certbot version for plugin. certbot version must be at least the plugin's
|
||||
# version. note that this is not the required version in setup.py, but the version number itself.
|
||||
cb_required=$(grep -oP "version = '\K.*(?=')" $SNAP/setup.py)
|
||||
|
||||
|
||||
$SNAP/bin/python3 -c "import sys; from packaging import version; sys.exit(1) if version.parse('$cb_installed') < version.parse('$cb_required') else sys.exit(0)" || exit_code=$?
|
||||
if [ "$exit_code" -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
|
||||
fi
|
||||
@@ -1,3 +1,4 @@
|
||||
# This file is generated by tools/generate_dnsplugins_snapcraft.sh and should not be edited manually.
|
||||
name: certbot-dns-luadns
|
||||
summary: LuaDNS Authenticator plugin for Certbot
|
||||
description: LuaDNS Authenticator plugin for Certbot
|
||||
@@ -15,9 +16,16 @@ parts:
|
||||
snapcraftctl pull
|
||||
snapcraftctl set-version `grep ^version $SNAPCRAFT_PART_SRC/setup.py | cut -f2 -d= | tr -d "'[:space:]"`
|
||||
build-environment:
|
||||
- EXCLUDE_CERTBOT_DEPS: "True"
|
||||
- SNAP_BUILD: "True"
|
||||
# To build cryptography and cffi if needed
|
||||
build-packages: [gcc, libffi-dev, libssl-dev, python3-dev]
|
||||
certbot-metadata:
|
||||
plugin: dump
|
||||
source: .
|
||||
stage: [setup.py, certbot-shared]
|
||||
override-pull: |
|
||||
snapcraftctl pull
|
||||
mkdir -p $SNAPCRAFT_PART_SRC/certbot-shared
|
||||
|
||||
slots:
|
||||
certbot:
|
||||
@@ -25,3 +33,9 @@ slots:
|
||||
content: certbot-1
|
||||
read:
|
||||
- $SNAP/lib/python3.8/site-packages
|
||||
|
||||
plugs:
|
||||
certbot-metadata:
|
||||
interface: content
|
||||
content: metadata-1
|
||||
target: $SNAP/certbot-shared
|
||||
|
||||
Reference in New Issue
Block a user