diff options
author | Raphaël Doursenaud | 2017-09-26 12:36:07 +0200 |
---|---|---|
committer | Raphaël Doursenaud | 2017-09-26 12:37:27 +0200 |
commit | a3378fb2a38404d4300372d6915f7bf3d379bbea (patch) | |
tree | 4e3094f16f65b4ac7862a764fdff0f53f5276e0a | |
parent | 36b9effd8bf0ea6f1fd191590f6f91d7e14953c2 (diff) | |
download | aur-a3378fb2a38404d4300372d6915f7bf3d379bbea.tar.gz |
Python 3 compatibility
Arch Linux now ships certbot using Python 3.
Patched and updaded the package accordingly.
Waiting for upstream integration.
-rw-r--r-- | .SRCINFO | 15 | ||||
-rw-r--r-- | 0001-Update-setuptools-entry-point-to-certbot.patch | 26 | ||||
-rw-r--r-- | 0002-Python-3-compatibility.patch | 227 | ||||
-rw-r--r-- | PKGBUILD | 23 |
4 files changed, 279 insertions, 12 deletions
@@ -1,18 +1,23 @@ # Generated by mksrcinfo v8 -# Fri Feb 17 15:44:51 UTC 2017 +# Tue Sep 26 10:37:27 UTC 2017 pkgbase = letsencrypt-gandi-git pkgdesc = Gandi plugin for Let's Encrypt - pkgver = r31.4f724cd + pkgver = r37.cf35ab7 pkgrel = 1 url = https://github.com/Gandi/letsencrypt-gandi arch = any license = APACHE makedepends = git - makedepends = python2-setuptools - makedepends = python2-mock + makedepends = python-setuptools + makedepends = python-mock + makedepends = openssh depends = certbot source = git+https://github.com/Gandi/letsencrypt-gandi - md5sums = SKIP + source = 0001-Update-setuptools-entry-point-to-certbot.patch + source = 0002-Python-3-compatibility.patch + sha512sums = SKIP + sha512sums = bf1ed0b6f2f75cd0b819c0f0908da76934bb6182162a2ab365b55eb4106b787645401a318ff85fd53d604d2b5fafa1105443fe7de308bb8b2a96031fa78d4e7c + sha512sums = 1fedb9f5808f7352b4e3f75035ea57066ff965fc7da2d36a590da02f932786e28e068acdb6ab59406982095145354677822acdfbcc5c1d3189e916a6d8b1d104 pkgname = letsencrypt-gandi-git diff --git a/0001-Update-setuptools-entry-point-to-certbot.patch b/0001-Update-setuptools-entry-point-to-certbot.patch new file mode 100644 index 000000000000..bf06fda03c00 --- /dev/null +++ b/0001-Update-setuptools-entry-point-to-certbot.patch @@ -0,0 +1,26 @@ +From cf3f6783060dafd955a24aa68ed31fffad85c3ad Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= <rdoursenaud@gpcsolutions.fr> +Date: Fri, 21 Jul 2017 19:04:07 +0200 +Subject: [PATCH 1/2] Update setuptools entry point to certbot + +See: https://certbot.eff.org/docs/contributing.html#writing-your-own-plugin +--- + setup.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/setup.py b/setup.py +index dc839d9..b3ac39d 100644 +--- a/setup.py ++++ b/setup.py +@@ -47,7 +47,7 @@ setup( + include_package_data=True, + install_requires=install_requires, + entry_points={ +- 'letsencrypt.plugins': [ ++ 'certbot.plugins': [ + 'gandi-shs = letsencrypt_gandi.shs:GandiSHSConfigurator', + ], + }, +-- +2.14.1 + diff --git a/0002-Python-3-compatibility.patch b/0002-Python-3-compatibility.patch new file mode 100644 index 000000000000..2eac52062f7e --- /dev/null +++ b/0002-Python-3-compatibility.patch @@ -0,0 +1,227 @@ +From d8baff07042e64d4e36f131e633c5a9d3ff5dc3e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= <rdoursenaud@gpcsolutions.fr> +Date: Fri, 21 Jul 2017 19:06:50 +0200 +Subject: [PATCH 2/2] Python 3 compatibility + +--- + letsencrypt_gandi/shs.py | 111 +++++++++++++++++++++-------------------------- + 1 file changed, 49 insertions(+), 62 deletions(-) + +diff --git a/letsencrypt_gandi/shs.py b/letsencrypt_gandi/shs.py +index 5a4e455..644c129 100644 +--- a/letsencrypt_gandi/shs.py ++++ b/letsencrypt_gandi/shs.py +@@ -3,7 +3,10 @@ + import logging + import os + import re +-import xmlrpclib ++try: ++ import xmlrpclib ++except ImportError: ++ import xmlrpc.client as xmlrpclib + import tempfile + import subprocess + +@@ -44,6 +47,8 @@ def get_user_environment(): + return new_env + + ++@zope.interface.implementer(interfaces.IAuthenticator, interfaces.IInstaller) ++@zope.interface.provider(interfaces.IPluginFactory) + class GandiSHSConfigurator(common.Plugin): + # pylint: disable=too-many-instance-attributes,too-many-public-methods + +@@ -53,9 +58,6 @@ class GandiSHSConfigurator(common.Plugin): + :type config: :class:`~letsencrypt.interfaces.IConfig` + """ + +- zope.interface.implements(interfaces.IAuthenticator, interfaces.IInstaller) +- zope.interface.classProvides(interfaces.IPluginFactory) +- + description = "Gandi Simple Hosting - Alpha" + + htaccess_content = None +@@ -192,7 +194,7 @@ class GandiSHSConfigurator(common.Plugin): + + def _base_path(self): + if re.match('^php', self.shs_info['type']): +- return 'vhosts/{vhost}/htdocs/'.format(vhost=self.vhost) ++ return 'vhosts/{vhost}/htdocs'.format(vhost=self.vhost) + elif re.match('^(python|nodejs)', self.shs_info['type']): + return 'vhosts/default' + # if ruby +@@ -246,18 +248,16 @@ class GandiSHSConfigurator(common.Plugin): + sftp = subprocess.Popen(process, stdin=subprocess.PIPE, close_fds=True, + env=get_user_environment()) + +- print >> sftp.stdin, 'exit' +- +- ret = sftp.wait() ++ sftp.communicate('exit\n'.encode()) + +- if ret != 0: ++ if sftp.returncode != 0: + raise errors.PluginError("Couldn't connect to the instance at {url}" + .format(url=sftp_url)) + + def _upload_tmpfile(self, tmpfile, user, sftp_url, path, destfile, mkdir): + + process = ['sftp', '-b', '-', +- '-o', 'UserKnownHostsFile={home}/.ssh/known_hosts'.format(home=get_user_environment()['HOME']), ++ '-o', 'UserKnownHostsFile={home}/.ssh/known_hosts'.format(home=get_user_environment()['HOME']), + '{user}@{sftp_url}'.format(user=user, sftp_url=sftp_url)] + + logger.info("sftp %s", process) +@@ -265,6 +265,7 @@ class GandiSHSConfigurator(common.Plugin): + sftp = subprocess.Popen(process, stdin=subprocess.PIPE, close_fds=True, + env=get_user_environment()) + ++ commands = '' + for p in mkdir: + # sftp will abort if any of the following commands fail: + # get, put, reget, reput, rename, ln, rm, mkdir, chdir, ls, lchdir, +@@ -273,17 +274,16 @@ class GandiSHSConfigurator(common.Plugin): + # prefixing the command with a '-' character (for example, + # -rm /tmp/blah*). + +- print >> sftp.stdin, '-mkdir {path}'.format(path=p) ++ commands += '-mkdir {path}\n'.format(path=p) + +- print >> sftp.stdin, 'cd {path}'.format(path=path) +- print >> sftp.stdin, 'put {tmpfile} {destfile}'.format( +- tmpfile=tmpfile, destfile=destfile) +- print >> sftp.stdin, 'chmod 444 {destfile}'.format(destfile=destfile) +- print >> sftp.stdin, 'exit' ++ commands += 'cd {path}\n'.format(path=path) ++ commands += 'put {tmpfile} {destfile}\n'.format(tmpfile=tmpfile, destfile=destfile) ++ commands += 'chmod 444 {destfile}\n'.format(destfile=destfile) ++ commands += 'exit\n' + +- ret = sftp.wait() ++ sftp.communicate(commands.encode()) + +- if ret != 0: ++ if sftp.returncode != 0: + raise errors.PluginError("Couldn't place file in domain: {0}" + .format(path)) + +@@ -302,18 +302,13 @@ class GandiSHSConfigurator(common.Plugin): + sftp = subprocess.Popen(process, stdin=subprocess.PIPE, close_fds=True, + env=get_user_environment()) + +- print >> sftp.stdin, 'cd {path}/.well-known'.format(path=path) +- try: +- tmpfile = tempfile.mkstemp(suffix='.letsencrypt.gandi.shs') +- print >> sftp.stdin, 'get .htaccess {tmpfile}'.format( +- tmpfile=tmpfile[1]) +- print >> sftp.stdin, 'exit' +- sftp.wait() +- with open(tmpfile[1], 'r') as htaccess: +- content = htaccess.read() +- finally: +- os.close(tmpfile[0]) +- os.remove(tmpfile[1]) ++ commands = '' ++ commands += 'cd {path}/.well-known\n'.format(path=path) ++ with tempfile.NamedTemporaryFile(suffix='.letsencrypt.gandi.shs') as htaccess: ++ commands += 'get .htaccess {tmpfile}\n'.format(tmpfile=htaccess.name) ++ commands += 'exit\n' ++ sftp.communicate(commands.encode()) ++ content = htaccess.read() + + if content: + new_content = content + HTACCESS_PATCH +@@ -323,21 +318,16 @@ class GandiSHSConfigurator(common.Plugin): + sftp = subprocess.Popen(process, stdin=subprocess.PIPE, close_fds=True, + env=get_user_environment()) + +- print >> sftp.stdin, 'cd {path}/.well-known'.format(path=path) +- try: +- # Patch +- tmpfile = tempfile.mkstemp(suffix='.letsencrypt.gandi.shs') +- os.write(tmpfile[0], new_content) ++ commands = '' ++ commands += 'cd {path}/.well-known\n'.format(path=path) ++ with tempfile.NamedTemporaryFile(suffix='.letsencrypt.gandi.shs') as htaccess: ++ htaccess.write(new_content.encode()) + + # Upload with patch +- print >> sftp.stdin, 'put {tmpfile} .htaccess'.format( +- tmpfile=tmpfile[1]) +- print >> sftp.stdin, 'chmod 644 .htaccess' +- print >> sftp.stdin, 'exit' +- sftp.wait() +- finally: +- os.close(tmpfile[0]) +- os.remove(tmpfile[1]) ++ commands += 'put {tmpfile} .htaccess\n'.format(tmpfile=htaccess.name) ++ commands += 'chmod 644 .htaccess\n' ++ commands += 'exit\n' ++ sftp.communicate(commands.encode()) + + return content + +@@ -354,23 +344,19 @@ class GandiSHSConfigurator(common.Plugin): + sftp = subprocess.Popen(process, stdin=subprocess.PIPE, close_fds=True, + env=get_user_environment()) + ++ commands = '' + if not self.htaccess_content: +- print >> sftp.stdin, 'cd {path}/.well-known'.format(path=path) +- print >> sftp.stdin, '-rm .htaccess' +- print >> sftp.stdin, 'exit' +- sftp.wait() ++ commands += 'cd {path}/.well-known\n'.format(path=path) ++ commands += '-rm .htaccess\n' ++ commands += 'exit\n' ++ sftp.communicate(commands.encode()) + else: +- print >> sftp.stdin, 'cd {path}/.well-known'.format(path=path) +- try: +- tmpfile = tempfile.mkstemp(suffix='.letsencrypt.gandi.shs') +- os.write(tmpfile[0], self.htaccess_content) +- print >> sftp.stdin, 'put {tmpfile} .htaccess'.format( +- tmpfile=tmpfile[1]) +- print >> sftp.stdin, 'exit' +- sftp.wait() +- finally: +- os.close(tmpfile[0]) +- os.remove(tmpfile[1]) ++ commands += 'cd {path}/.well-known\n'.format(path=path) ++ with tempfile.mkstemp(suffix='.letsencrypt.gandi.shs') as tmpfile: ++ os.write(tmpfile[0], self.htaccess_content.encode()) ++ commands += 'put {tmpfile} .htaccess\n'.format(tmpfile=tmpfile[1]) ++ commands += 'exit\n' ++ sftp.communicate(commands.encode()) + + def cleanup(self, achalls): + """Revert all challenges.""" +@@ -397,7 +383,8 @@ class GandiSHSConfigurator(common.Plugin): + sftp = subprocess.Popen(process, stdin=subprocess.PIPE, close_fds=True, + env=get_user_environment()) + +- print >> sftp.stdin, 'rm {path}'.format(path=path) ++ commands = '' ++ commands += 'rm {path}\n'.format(path=path) + for p in dirs: + # sftp will abort if any of the following commands fail: + # get, put, reget, reput, rename, ln, rm, mkdir, chdir, ls, lchdir, +@@ -406,11 +393,11 @@ class GandiSHSConfigurator(common.Plugin): + # prefixing the command with a '-' character (for example, + # -rm /tmp/blah*). + +- print >> sftp.stdin, 'rmdir {path}'.format(path=p) ++ commands += '-rmdir {path}\n'.format(path=p) + +- print >> sftp.stdin, 'exit' ++ commands += 'exit\n' + +- sftp.wait() ++ sftp.communicate(commands.encode()) + + # + # Installer Section +-- +2.14.1 + @@ -1,6 +1,6 @@ # Maintainer: Raphaël Doursenaud <rdoursenaud@gmail.com> pkgname=letsencrypt-gandi-git -pkgver=r31.4f724cd +pkgver=r37.cf35ab7 pkgrel=1 pkgdesc="Gandi plugin for Let's Encrypt" arch=(any) @@ -8,16 +8,20 @@ url="https://github.com/Gandi/letsencrypt-gandi" license=('APACHE') groups=() depends=('certbot') -makedepends=('git' 'python2-setuptools' 'python2-mock') +makedepends=('git' 'python-setuptools' 'python-mock' 'openssh') provides=() conflicts=() replaces=() backup=() options=() install= -source=('git+https://github.com/Gandi/letsencrypt-gandi') +source=('git+https://github.com/Gandi/letsencrypt-gandi' + '0001-Update-setuptools-entry-point-to-certbot.patch' + '0002-Python-3-compatibility.patch') noextract=() -md5sums=('SKIP') +sha512sums=('SKIP' + 'bf1ed0b6f2f75cd0b819c0f0908da76934bb6182162a2ab365b55eb4106b787645401a318ff85fd53d604d2b5fafa1105443fe7de308bb8b2a96031fa78d4e7c' + '1fedb9f5808f7352b4e3f75035ea57066ff965fc7da2d36a590da02f932786e28e068acdb6ab59406982095145354677822acdfbcc5c1d3189e916a6d8b1d104') _gitroot=https://github.com/Gandi/letsencrypt-gandi _gitname=letsencrypt-gandi @@ -39,7 +43,12 @@ build() { rm -rf "$srcdir/$_gitname-build" git clone "$srcdir/$_gitname" "$srcdir/$_gitname-build" cd "$srcdir/$_gitname-build" - python2 setup.py build + + # Python 3 compatibility (See: https://github.com/Gandi/letsencrypt-gandi/pull/33) + patch -Np1 -i "${srcdir}/0001-Update-setuptools-entry-point-to-certbot.patch" + patch -Np1 -i "${srcdir}/0002-Python-3-compatibility.patch" + + python setup.py build } pkgver() { @@ -51,12 +60,12 @@ pkgver() { } check() { cd "$srcdir/$_gitname-build" - python2 setup.py test + python setup.py test } package() { cd "$srcdir/$_gitname-build" - python2 setup.py install --optimize=1 --root="$pkgdir/" + python setup.py install --optimize=1 --root="$pkgdir/" } # vim:set ts=2 sw=2 et: |