From 62232e8ae33f7d41f4db153d649276fd93ff9aff Mon Sep 17 00:00:00 2001 From: DorianCoding <108593662+DorianCoding@users.noreply.github.com> Date: Sun, 13 Oct 2024 17:06:13 +0200 Subject: [PATCH] Snap test --- .gitignore | 3 +++ setup.py | 2 +- snap/hooks/post-refresh | 21 +++++++++++++++ snap/snapcraft.yaml | 58 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 snap/hooks/post-refresh create mode 100644 snap/snapcraft.yaml diff --git a/.gitignore b/.gitignore index 2283895..205eeae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +#Snap +certbot-dns-ionos_20240108_amd64.snap +snap-constraints.txt # File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig # Created by https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,python diff --git a/setup.py b/setup.py index 931408b..859e168 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from setuptools import setup from setuptools import find_packages -version = "2024.01.08" +version = '20240108' install_requires = [ "acme>=1.8.0", diff --git a/snap/hooks/post-refresh b/snap/hooks/post-refresh new file mode 100644 index 0000000..717714c --- /dev/null +++ b/snap/hooks/post-refresh @@ -0,0 +1,21 @@ +#!/bin/sh -e +# This file is generated automatically 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 diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 0000000..460e9e5 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,58 @@ +# This file is generated automatically and should not be edited manually. +name: certbot-dns-ionos +summary: IONOS DNS Authenticator plugin for Certbot +description: IONOS DNS Authenticator plugin for Certbot +confinement: strict +grade: stable +base: core24 +adopt-info: certbot-dns-ionos + +parts: + certbot-dns-ionos: + plugin: python + source: . + override-pull: | + craftctl default + craftctl set version=$(grep ^version $SNAPCRAFT_PART_SRC/setup.py | cut -f2 -d= | tr -d "'[:space:]") + build-environment: + # We set this environment variable while building to try and increase the + # stability of fetching the rust crates needed to build the cryptography + # library. + - CARGO_NET_GIT_FETCH_WITH_CLI: "true" + # Constraints are passed through the environment variable PIP_CONSTRAINTS instead of using the + # parts.[part_name].constraints option available in snapcraft.yaml when the Python plugin is + # used. This is done to let these constraints be applied not only on the certbot package + # build, but also on any isolated build that pip could trigger when building wheels for + # dependencies. See https://github.com/certbot/certbot/pull/8443 for more info. + - PIP_CONSTRAINT: $SNAPCRAFT_PART_SRC/snap-constraints.txt + - SNAP_BUILD: "True" + # To build cryptography and cffi if needed + build-packages: + - gcc + - git + - build-essential + - libssl-dev + - libffi-dev + - python3-dev + - cargo + - pkg-config + certbot-metadata: + plugin: dump + source: . + stage: [setup.py, certbot-shared] + override-pull: | + craftctl default + mkdir -p $SNAPCRAFT_PART_SRC/certbot-shared + +slots: + certbot: + interface: content + content: certbot-1 + read: + - $SNAP/lib/python3.12/site-packages + +plugs: + certbot-metadata: + interface: content + content: metadata-1 + target: $SNAP/certbot-shared