Skip to content

Commit

Permalink
Add files to create a snap package
Browse files Browse the repository at this point in the history
  • Loading branch information
kmpm committed Oct 8, 2021
1 parent 8c79477 commit 6af1c90
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ dist/
tmp/
venv/
credentials.ini
*.snap
16 changes: 15 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,23 @@ DNS01 challange for domains managed on `Loopia <https://www.loopia.se/>`_ DNS.

Installing
----------

Via snap (requires certbot to be installed via snap)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block::
$ sudo snap install certbot-dns-loopia
$ sudo snap set certbot trust-plugin-with-root=ok
$ sudo snap connect certbot:plugin certbot-dns-loopia
$ sudo snap connect certbot-dns-loopia:certbot-metadata certbot:certbot-metadata
Via pip3
~~~~~~~~
.. code-block::
$ sudo pip install certbot-dns-loopia
$ sudo pip3 install certbot-dns-loopia
Note that you should normally install this as ``root``, unless you know what
you are doing.
Expand Down
87 changes: 51 additions & 36 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,67 @@
import os
from setuptools import setup


try:
long_desc = open("README.rst").read()
except FileNotFoundError:
print("Skipping README.rst for long description as it was not found")
long_desc = None
version = '1.0.0'
cb_required = '1.8.0'

install_requires = [
'loopialib>=0.2.0',
'zope.interface>=4.4.0',
]


if not os.environ.get('SNAP_BUILD'):
install_requires.extend([
f'acme>={cb_required}',
f'certbot>={cb_required}',
])


if os.environ.get('SNAP_BUILD'):
install_requires.append('packaging')


BASE_PATH = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(BASE_PATH, 'README.rst')) as f:
long_desc = f.read()



setup(
name="certbot-dns-loopia",
version="1.0.0",
description="Loopia DNS authentication plugin for Certbot",
name='certbot-dns-loopia',
version=version,
description='Loopia DNS authentication plugin for Certbot',
long_description=long_desc,
license="BSD",
author="Andreas Runfalk",
author_email="[email protected]",
url="https://www.github.com/runfalk/certbot-loopia",
py_modules=["certbot_dns_loopia"],
install_requires=[
"acme>=1.8.0",
"certbot>=1.7.0",
"loopialib>=0.2.0",
"zope.interface>=4.4.0",
],
license='BSD',
author='Andreas Runfalk',
author_email='[email protected]',
url='https://www.github.com/runfalk/certbot-loopia',
py_modules=['certbot_dns_loopia'],
install_requires=install_requires,
extras_require={
"dev": [
"pytest",
"wheel",
'dev': [
'pytest',
'wheel',
],
},
entry_points={
"certbot.plugins": [
"dns-loopia = certbot_dns_loopia:LoopiaAuthenticator",
'certbot.plugins': [
'dns-loopia = certbot_dns_loopia:LoopiaAuthenticator',
],
},
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Environment :: Plugins",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Internet :: Name Service (DNS)",
"Topic :: System :: Systems Administration",
"Topic :: Utilities",
'Development Status :: 2 - Pre-Alpha',
'Environment :: Plugins',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Topic :: Internet :: Name Service (DNS)',
'Topic :: System :: Systems Administration',
'Topic :: Utilities',
],
)
21 changes: 21 additions & 0 deletions snap/hooks/post-refresh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh -e
# This file is based on tools/snap/generate_dnsplugins_postrefreshhook.sh of Certbot
# 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 "cb_required = '\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
39 changes: 39 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: certbot-dns-loopia
summary: Loopia DNS authentication plugin for Certbot
description: Loopia DNS authentication plugin for Certbot
confinement: strict
grade: stable
base: core20

adopt-info: certbot-dns-loopia

parts:
certbot-dns-loopia:
plugin: python
source: .
override-pull: |
snapcraftctl pull
snapcraftctl set-version `grep ^version $SNAPCRAFT_PART_SRC/setup.py | cut -f2 -d= | tr -d "'[:space:]"`
build-environment:
- SNAP_BUILD: "True"

certbot-metadata:
plugin: dump
source: .
stage: [setup.py, certbot-shared]
override-pull: |
snapcraftctl pull
mkdir -p $SNAPCRAFT_PART_SRC/certbot-shared
slots:
certbot:
interface: content
content: certbot-1
read:
- $SNAP/lib/python3.8/site-packages

plugs:
certbot-metadata:
interface: content
content: metadata-1
target: $SNAP/certbot-shared

0 comments on commit 6af1c90

Please sign in to comment.