Commit e2aadf6d authored by Birger Schacht's avatar Birger Schacht

Initial debian packaging

parent 77231b28
errbot (5.2.0+ds-1) unstable; urgency=medium
* Initial release. Closes: #803347
-- Birger Schacht <birger@rantanplan.org> Sun, 17 Feb 2019 17:34:02 +0100
Source: errbot
Section: net
Priority: optional
Maintainer: Birger Schacht <birger@rantanplan.org>
Build-Depends:
debhelper-compat (= 12),
dh-python,
git-core,
localehelper,
python3-all,
python3-ansi,
python3-bottle,
python3-colorlog,
python3-dnspython,
python3-jinja2,
python3-markdown,
python3-mock,
python3-openssl,
python3-pygments,
python3-pytest,
python3-requests,
python3-setuptools,
python3-webtest,
python3-yapsy,
Standards-Version: 4.3.0
Homepage: http://errbot.io
Package: errbot
Architecture: any
Multi-Arch: foreign
Depends:
python3,
python3-ansi,
python3-bottle,
python3-colorlog,
python3-dnspython,
python3-irc,
python3-jinja2,
python3-markdown,
python3-openssl,
python3-pyasn1,
python3-pyasn1-modules,
python3-pygments,
python3-requests,
python3-setuptools,
python3-sleekxmpp,
python3-webtest,
python3-yapsy,
${misc:Depends},
${python3:Depends}
Description: Chatbot designed to be simple to extend with plugins written in Python
Errbot is a chatbot. It allows you to start scripts interactively from your
chatrooms for any reason: random humour, chatops, starting a build, monitoring
commits, triggering alerts...
.
It is written and easily extensible in Python.
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: errbot
Source: https://github.com/errbotio/errbot
Files-Excluded: docs/_static/fancybox
Files: *
License: GPL-3+
Copyright: 2013-2018 Guillaume Binet, Tali Davidovich Petrover and Nick Groenen
Upstream-Contact: info@errbot.io
Files: debian/*
License: GPL-3+
Copyright: 2019 Birger Schacht <birger@rantanplan.org>
License: GPL-3+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
From fbe6084bfb9c9a9e42495cecf3b1af0a50b046d1 Mon Sep 17 00:00:00 2001
From: Birger Schacht <birger@rantanplan.org>
Date: Sun, 17 Feb 2019 18:40:50 +0100
Subject: [PATCH] Disable the webserver plugin
The webserver plugin uses rocket, which is not packaged for Debian.
According to upstream, it will be replaced with flask in the next
version.
---
errbot/core_plugins/webserver.plug | 10 --
errbot/core_plugins/webserver.py | 187 -----------------------------
2 files changed, 197 deletions(-)
delete mode 100644 errbot/core_plugins/webserver.plug
delete mode 100644 errbot/core_plugins/webserver.py
diff --git a/errbot/core_plugins/webserver.plug b/errbot/core_plugins/webserver.plug
deleted file mode 100644
index 930c7b4..0000000
--- a/errbot/core_plugins/webserver.plug
+++ /dev/null
@@ -1,10 +0,0 @@
-[Core]
-Name = Webserver
-Module = webserver
-Core = True
-
-[Documentation]
-Description = This is a plugin for enabling webhooks and web interface to Errbot.
-
-[Python]
-Version = 2+
\ No newline at end of file
diff --git a/errbot/core_plugins/webserver.py b/errbot/core_plugins/webserver.py
deleted file mode 100644
index 8b4d742..0000000
--- a/errbot/core_plugins/webserver.py
+++ /dev/null
@@ -1,187 +0,0 @@
-import sys
-import os
-from json import loads
-from random import randrange
-from webtest import TestApp
-
-from errbot import botcmd, BotPlugin, webhook
-from errbot.core_plugins.wsview import bottle_app
-from rocket import Rocket
-
-from urllib.request import unquote
-
-try:
- from OpenSSL import crypto
- has_crypto = True
-except ImportError:
- has_crypto = False
-
-TEST_REPORT = """*** Test Report
-URL : %s
-Detected your post as : %s
-Status code : %i
-"""
-
-
-def make_ssl_certificate(key_path, cert_path):
- """
- Generate a self-signed certificate
-
- The generated key will be written out to key_path, with the corresponding
- certificate itself being written to cert_path.
- :param cert_path: path where to write the certificate.
- :param key_path: path where to write the key.
- """
- cert = crypto.X509()
- cert.set_serial_number(randrange(1, sys.maxsize))
- cert.gmtime_adj_notBefore(0)
- cert.gmtime_adj_notAfter(60 * 60 * 24 * 365)
-
- subject = cert.get_subject()
- subject.CN = '*'
- subject.O = 'Self-Signed Certificate for Err'
-
- issuer = cert.get_issuer()
- issuer.CN = 'Self-proclaimed Authority'
- issuer.O = 'Self-Signed'
-
- pkey = crypto.PKey()
- pkey.generate_key(crypto.TYPE_RSA, 4096)
- cert.set_pubkey(pkey)
- cert.sign(pkey, 'sha256')
-
- f = open(cert_path, 'w')
- f.write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert).decode('utf-8'))
- f.close()
-
- f = open(key_path, 'w')
- f.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey).decode('utf-8'))
- f.close()
-
-
-class Webserver(BotPlugin):
-
- def __init__(self, *args, **kwargs):
- self.webserver = None
- self.webchat_mode = False
- self.ssl_context = None
- self.test_app = TestApp(bottle_app)
- super().__init__(*args, **kwargs)
-
- def get_configuration_template(self):
- return {'HOST': '0.0.0.0',
- 'PORT': 3141,
- 'SSL': {'enabled': False,
- 'host': '0.0.0.0',
- 'port': 3142,
- 'certificate': "",
- 'key': ""}}
-
- def check_configuration(self, configuration):
- # it is a pain, just assume a default config if SSL is absent or set to None
- if configuration.get('SSL', None) is None:
- configuration['SSL'] = {'enabled': False, 'host': '0.0.0.0', 'port': 3142, 'certificate': "", 'key': ""}
- super().check_configuration(configuration)
-
- def activate(self):
- if not self.config:
- self.log.info('Webserver is not configured. Forbid activation')
- return
-
- host = self.config['HOST']
- port = self.config['PORT']
- ssl = self.config['SSL']
- interfaces = [(host, port)]
- if ssl['enabled']:
- # noinspection PyTypeChecker
- interfaces.append((ssl['host'], ssl['port'], ssl['key'], ssl['certificate']))
- self.log.info('Firing up the Rocket')
- self.webserver = Rocket(interfaces=interfaces,
- app_info={'wsgi_app': bottle_app}, )
- self.webserver.start(background=True)
- self.log.debug('Liftoff!')
-
- super().activate()
-
- def deactivate(self):
- if self.webserver is not None:
- self.log.debug('Sending signal to stop the webserver')
- self.webserver.stop()
- super().deactivate()
-
- # noinspection PyUnusedLocal
- @botcmd(template='webstatus')
- def webstatus(self, msg, args):
- """
- Gives a quick status of what is mapped in the internal webserver
- """
- return {'rules': (((route.rule, route.name) for route in bottle_app.routes))}
-
- @webhook
- def echo(self, incoming_request):
- """
- A simple test webhook
- """
- self.log.debug("Your incoming request is :" + str(incoming_request))
- return str(incoming_request)
-
- @botcmd(split_args_with=' ')
- def webhook_test(self, _, args):
- """
- Test your webhooks from within err.
-
- The syntax is :
- !webhook test [relative_url] [post content]
-
- It triggers the notification and generate also a little test report.
- """
- url = args[0]
- content = ' '.join(args[1:])
-
- # try to guess the content-type of what has been passed
- try:
- # try if it is plain json
- loads(content)
- contenttype = 'application/json'
- except ValueError:
- # try if it is a form
- splitted = content.split('=')
- # noinspection PyBroadException
- try:
- payload = '='.join(splitted[1:])
- loads(unquote(payload))
- contenttype = 'application/x-www-form-urlencoded'
- except Exception as _:
- contenttype = 'text/plain' # dunno what it is
-
- self.log.debug('Detected your post as : %s' % contenttype)
-
- response = self.test_app.post(url, params=content, content_type=contenttype)
- return TEST_REPORT % (url, contenttype, response.status_code)
-
- @botcmd(admin_only=True)
- def generate_certificate(self, _, args):
- """
- Generate a self-signed SSL certificate for the Webserver
- """
- if not has_crypto:
- yield ("It looks like pyOpenSSL isn't installed. Please install this "
- "package using for example `pip install pyOpenSSL`, then try again")
- return
-
- yield ("Generating a new private key and certificate. This could take a "
- "while if your system is slow or low on entropy")
- key_path = os.sep.join((self.bot_config.BOT_DATA_DIR, "webserver_key.pem"))
- cert_path = os.sep.join((self.bot_config.BOT_DATA_DIR, "webserver_certificate.pem"))
- make_ssl_certificate(key_path=key_path, cert_path=cert_path)
- yield "Certificate successfully generated and saved in {}".format(self.bot_config.BOT_DATA_DIR)
-
- suggested_config = self.config
- suggested_config['SSL']['enabled'] = True
- suggested_config['SSL']['host'] = suggested_config['HOST']
- suggested_config['SSL']['port'] = suggested_config['PORT'] + 1
- suggested_config['SSL']['key'] = key_path
- suggested_config['SSL']['certificate'] = cert_path
- yield ("To enable SSL with this certificate, the following config "
- "is recommended:")
- yield "{!r}".format(suggested_config)
--
2.20.1
From: Birger Schacht <birger@rantanplan.org>
Date: Tue, 4 Jul 2017 09:16:00 +0200
Subject: fix slack test
---
tests/backend_tests/slack_test.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tests/backend_tests/slack_test.py b/tests/backend_tests/slack_test.py
index cb1aeec..fbdf12c 100644
--- a/tests/backend_tests/slack_test.py
+++ b/tests/backend_tests/slack_test.py
@@ -10,6 +10,11 @@ from errbot.bootstrap import bot_config_defaults
log = logging.getLogger(__name__)
try:
+ import slack
+except ImportError:
+ _has_slack = None
+
+try:
from errbot.backends import slack
class TestSlackBackend(slack.SlackBackend):
@@ -44,7 +49,7 @@ except SystemExit:
log.exception("Can't import backends.slack for testing")
-@unittest.skipIf(not slack, "package slackclient not installed")
+@unittest.skipIf(not _has_slack, "package slackclient not installed")
class SlackTests(unittest.TestCase):
def setUp(self):
0001-Disable-the-webserver-plugin.patch
0002-fix-slack-test.patch
dnspython3 python3-dnspython
#!/usr/bin/make -f
export DH_VERBOSE = 1
export PYBUILD_NAME=errbot
#export PYBUILD_SYSTEM=distutils
export PYBUILD_DESTDIR_python3=debian/python3-errbot/
export PYBUILD_DESTDIR_python3-dbg=debian/python3-errbot-dbg/
# most of the disabled tests are because we don't ship
# rocket-errbot and thus the webserver plugin wont work
# (everything starting from test_not_configured_url_returns_404)
export PYBUILD_TEST_ARGS=-k "not test_plugin_cycle and \
not test_logtail and \
not test_backup and \
not test_generate_certificate_creates_usable_cert and \
not test_check_dependencies_requirements_file_all_installed and \
not test_first and \
not test_broken_plugin and \
not test_not_configured_url_returns_404 and \
not test_webserver_plugin_ok and \
not test_trailing_no_slash_ok and \
not test_trailing_slash_also_ok and \
not test_json_is_automatically_decoded and \
not test_json_on_custom_url_is_automatically_decoded and \
not test_post_form_on_webhook_without_form_param_is_automatically_decoded and \
not test_post_form_on_webhook_with_custom_url_and_without_form_param_is_automatically_decoded and \
not test_webhooks_with_form_parameter_decode_json_automatically and \
not test_webhooks_with_form_parameter_on_custom_url_decode_json_automatically and \
not test_webhooks_with_raw_request and \
not test_webhooks_with_naked_decorator_raw_request and \
not test_generate_certificate_creates_usable_cert and \
not test_custom_headers_and_status_codes and \
not test_lambda_webhook and \
not test_config_cycle and \
not test_webserver_webhook_test"
%:
dh $@ --with python3 --buildsystem=pybuild
override_dh_install:
python3 setup.py install --root=debian/errbot/ --install-layout=deb
dh_install --exclude=usr/lib/python3.6/* --exclude=*webserver.py
override_dh_auto_test:
localehelper LANG=en_US.UTF-8 dh_auto_test
Name: errbot
Repository: https://github.com/errbotio/errbot.git
Repository-Browse: https://github.com/errbotio/errbot
# You must remove unused comment lines for the released package.
version=3
opts=filenamemangle=s/.+\/v?(\d\S+)\.tar\.gz/errbot-$1\.tar\.gz/ \
https://github.com/errbotio/errbot/tags .*/v?(\d\S+)\.tar\.gz
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment