From 2a42a220a1221db9e2cbebffb1bba5204f5cdcc7e2511f9ed0ddbeeba60f9d08 Mon Sep 17 00:00:00 2001 From: Thomas ANDREJAK Date: Wed, 1 Nov 2017 19:10:43 +0000 Subject: [PATCH] Accepting request 533474 from home:totol:branches:server:monitoring - Update to 4.0.0 - Create python2-prewikka and python3-prewikka packages since prewikka is python 3 compatible - Move to Python Singlespec - Remove patch prewikka-ez_setup.patch because we can only be compatible with Factory/Tumbleweed because of Python Singlespec - Add patch prewikka-fix_python3.patch to make prewikka fully compatible with Python 3 OBS-URL: https://build.opensuse.org/request/show/533474 OBS-URL: https://build.opensuse.org/package/show/server:monitoring/prewikka?expand=0&rev=12 --- prewikka-3.1.0.tar.gz | 3 - prewikka-4.0.0.tar.gz | 3 + prewikka-ez_setup.patch | 31 ---------- prewikka-fix_python3.patch | 116 +++++++++++++++++++++++++++++++++++++ prewikka.changes | 12 ++++ prewikka.spec | 79 +++++++++++++++++++------ 6 files changed, 193 insertions(+), 51 deletions(-) delete mode 100644 prewikka-3.1.0.tar.gz create mode 100644 prewikka-4.0.0.tar.gz delete mode 100644 prewikka-ez_setup.patch create mode 100644 prewikka-fix_python3.patch diff --git a/prewikka-3.1.0.tar.gz b/prewikka-3.1.0.tar.gz deleted file mode 100644 index fe9eedf..0000000 --- a/prewikka-3.1.0.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f7e27fe9ef2acb0df7e28586e675e9a783a13f3f7b762eb0350f835366200649 -size 1349193 diff --git a/prewikka-4.0.0.tar.gz b/prewikka-4.0.0.tar.gz new file mode 100644 index 0000000..21b411b --- /dev/null +++ b/prewikka-4.0.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9346b9c3d0ea0cfaba4d1685b6bfa28075e26d558b0eaa20c4d8647994f657e5 +size 1365985 diff --git a/prewikka-ez_setup.patch b/prewikka-ez_setup.patch deleted file mode 100644 index 4db66c7..0000000 --- a/prewikka-ez_setup.patch +++ /dev/null @@ -1,31 +0,0 @@ -From: Thomas Andrejak -Date: 2017-02-27 23:25:00 +0100 -References: no -Upstream: no -Subject: Backport ez_setup to be compatible with old (Open)SuSE - ---- ez_setup.py 2016-04-22 23:28:03.000000000 +0200 -+++ ez_setup.py 2016-05-02 00:23:50.498917032 +0200 -@@ -36,7 +36,7 @@ - except ImportError: - USER_SITE = None - --DEFAULT_VERSION = "5.7" -+DEFAULT_VERSION = "5.4.1" - DEFAULT_URL = "https://pypi.python.org/packages/source/s/setuptools/" - - def _python_cmd(*args): -@@ -268,7 +268,7 @@ - Download setuptools from a specified location and return its filename - - `version` should be a valid setuptools version number that is available -- as an sdist for download under the `download_base` URL (which should end -+ as an egg for download under the `download_base` URL (which should end - with a '/'). `to_dir` is the directory where the egg will be downloaded. - `delay` is the number of seconds to pause before an actual download - attempt. -@@ -330,3 +330,4 @@ - - if __name__ == '__main__': - sys.exit(main()) -+ diff --git a/prewikka-fix_python3.patch b/prewikka-fix_python3.patch new file mode 100644 index 0000000..60b2975 --- /dev/null +++ b/prewikka-fix_python3.patch @@ -0,0 +1,116 @@ +From: Thomas Andrejak +Date: 2017-10-04 23:25:00 +0100 +References: no +Upstream: no +Subject: Python 3 compatibility + +--- prewikka/dataprovider/__init__.py 2017-07-18 13:45:57.000000000 +0200 ++++ prewikka/dataprovider/__init__.py 2017-10-07 17:10:09.140721871 +0200 +@@ -22,12 +22,15 @@ + import copy + import time + import types ++import sys + from datetime import datetime + + from prewikka import error, hookmanager, pluginmanager + from prewikka.utils import AttrObj, CachingIterator, compat, json + from prewikka.utils.timeutil import parser + ++if sys.version_info >= (3, 0): ++ long = int + + def _str_to_datetime(date): + if date.isdigit(): +--- prewikka/session/session.py 2017-07-18 13:45:57.000000000 +0200 ++++ prewikka/session/session.py 2017-10-07 17:13:02.224865916 +0200 +@@ -23,6 +23,7 @@ + import os + import struct + import time ++import sys + + from prewikka import database, hookmanager, log, pluginmanager, usergroup, utils + from prewikka.error import PrewikkaUserError, RedirectionError +@@ -137,7 +138,11 @@ + t = time.time() + + self._db.delete_expired_sessions(t - self._expiration) +- sessionid = text_type(binascii.hexlify(os.urandom(16) + struct.pack(b">d", t))) ++ sessionid = binascii.hexlify(os.urandom(16) + struct.pack(b">d", t)) ++ if sys.version_info >= (3, 0): ++ sessionid = sessionid.decode('ascii') ++ ++ sessionid = text_type(sessionid) + + self._db.create_session(sessionid, user, int(t)) + self.__set_session(request, sessionid) +--- prewikka/utils/json.py 2017-07-18 13:45:57.000000000 +0200 ++++ prewikka/utils/json.py 2017-10-07 17:14:59.718248149 +0200 +@@ -21,6 +21,7 @@ + + import datetime + import json ++from six import with_metaclass + + from prewikka.utils import html + +@@ -36,8 +37,7 @@ + return nclass + + +-class JSONObject(object): +- __metaclass__ = _JSONMetaClass ++class JSONObject(with_metaclass(_JSONMetaClass, object)): + + def __jsonobj__(self): + return { "__prewikka_class__": (self.__class__.__name__, self.__json__()) } +--- prewikka/utils/url.py 2017-07-18 13:45:57.000000000 +0200 ++++ prewikka/utils/url.py 2017-10-07 17:16:41.927970738 +0200 +@@ -56,7 +56,11 @@ + else: + authority = tpl[0].encode('idna') + ":%s" % tpl[1] + +- return urlunsplit((scheme.encode(encoding), authority, ++ sc = scheme.encode(encoding) ++ if sys.version_info >= (3, 0): ++ sc = quote(sc, safe) ++ ++ return urlunsplit((sc, authority, + quote(path.encode(encoding), safe), + quote(query.encode(encoding), safe), + quote(frag.encode(encoding), safe))) +--- prewikka/web/request.py 2017-07-18 13:45:57.000000000 +0200 ++++ prewikka/web/request.py 2017-10-07 17:21:21.645737400 +0200 +@@ -40,7 +40,11 @@ + self._buffersize = buffersize + + def flush(self): +- self._wcb(''.join(self._dlist)) ++ if sys.version_info >= (3, 0): ++ self._wcb(''.join((x.decode('utf-8') for x in self._dlist)).encode('utf-8')) ++ else: ++ self._wcb(''.join(self._dlist)) ++ + self._dlist = [] + self._len = 0 + +@@ -97,10 +101,16 @@ + # Join is used in place of concatenation / formatting, because we + # prefer performance over readability in this place + if event: +- self._buffer.write("".join(["event: ", event.encode("utf8"), "\n"])) ++ if sys.version_info >= (3, 0): ++ self._buffer.write("".join(["event: ", text_type(event), "\n"]).encode("utf8")) ++ else: ++ self._buffer.write("".join(["event: ", event.encode('utf-8'), "\n"])) + + if data: +- self._buffer.write("".join(["data: ", data.encode("utf8"), "\n\n"])) ++ if sys.version_info >= (3, 0): ++ self._buffer.write("".join(["data: ", text_type(data), "\n\n"]).encode("utf8")) ++ else: ++ self._buffer.write("".join(["data: ", data.encode('utf-8'), "\n\n"])) + + if sync: + self._buffer.flush() diff --git a/prewikka.changes b/prewikka.changes index 63ebc32..849d129 100644 --- a/prewikka.changes +++ b/prewikka.changes @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Wed Oct 04 07:00:00 UTC 2017 - thomas.andrejak@gmail.com + +- Update to 4.0.0 +- Create python2-prewikka and python3-prewikka + packages since prewikka is python 3 compatible +- Move to Python Singlespec +- Remove patch prewikka-ez_setup.patch because we can only be + compatible with Factory/Tumbleweed because of Python Singlespec +- Add patch prewikka-fix_python3.patch to make prewikka fully + compatible with Python 3 + ------------------------------------------------------------------- Fri Feb 10 00:33:55 UTC 2017 - thomas.andrejak@gmail.com diff --git a/prewikka.spec b/prewikka.spec index 5d96838..110ca5d 100644 --- a/prewikka.spec +++ b/prewikka.spec @@ -16,36 +16,60 @@ # +%{?!python_module:%define python_module() python-%{**} python3-%{**}} + Name: prewikka -Version: 3.1.0 +Version: 4.0.0 Release: 0 Summary: Graphical front-end analysis console for the Prelude Framework License: GPL-2.0+ Group: Productivity/Networking/Web/Frontends Url: https://www.prelude-siem.org Source0: https://www.prelude-siem.org/pkg/src/%{version}/%{name}-%{version}.tar.gz -# Backport ez_setup to be compatible with old (Open)SuSE -Patch0: prewikka-ez_setup.patch +Patch0: prewikka-fix_python3.patch +BuildRequires: %{python_module Babel} +BuildRequires: %{python_module lesscpy} +BuildRequires: %{python_module setuptools} +BuildRequires: fdupes BuildRequires: gettext -BuildRequires: python-cheetah BuildRequires: python-devel -BuildRequires: python-lesscpy -BuildRequires: python-setuptools -Requires: python-babel -Requires: python-cheetah -Requires: python-dateutil +BuildRequires: python-rpm-macros +BuildRequires: python3-devel +Requires: prewikka-core >= %{version} +Requires: prewikka-lang >= %{version} +Requires: python-Babel +Requires: python-Mako +Requires: python-PyYAML +Requires: python-Werkzeug Requires: python-libprelude Requires: python-libpreludedb +Requires: python-python-dateutil Requires: python-pytz Requires: xorg-x11-fonts BuildArch: noarch +%python_subpackages + %description Prewikka is the graphical front-end analysis console for the Prelude Universal SIM. Prewikka provides alert aggregation and sensor and hearbeat views, and has user management and configurable filters, as well as access to external tools such as whois and traceroute. +%package core +Summary: Prewikka core files +Group: Productivity/Networking/Web/Frontends + +%description core +Core files for prewikka. + +%package lang +Summary: Prewikka lang files +Group: Productivity/Networking/Web/Frontends + +%description lang +Lang files for prewikka. + %prep %setup -q %patch0 @@ -53,21 +77,42 @@ well as access to external tools such as whois and traceroute. %build %install -python setup.py install -O1 --root=%{buildroot} +install -d -m 0755 %{buildroot}%{_sbindir} + +%{python_expand $python setup.py install -O1 --force --root %{buildroot} +mv %{buildroot}%{_bindir}/%{name}-httpd %{buildroot}%{_sbindir}/%{name}-httpd-%{$python_bin_suffix} +%fdupes %{buildroot}%{$python_sitelib}/prewikka +} + +ln -s ./%{name}-httpd-%{python3_bin_suffix} %{buildroot}%{_sbindir}/%{name}-httpd + +install -d -m 0755 %{buildroot}%{_datadir}/locale +cp -r %{buildroot}%{python2_sitelib}/%{name}/locale/* %{buildroot}%{_datadir}/locale/ +rm -rf %{buildroot}%{python2_sitelib}/%{name}/locale +rm -rf %{buildroot}%{python3_sitelib}/%{name}/locale +ln -s %{_datadir}/locale %{buildroot}%{python2_sitelib}/%{name}/locale +ln -s %{_datadir}/locale %{buildroot}%{python3_sitelib}/%{name}/locale + +rm %{buildroot}%{_sysconfdir}/%{name}/*-dist + mkdir -p %{buildroot}%{_defaultdocdir}/%{name}-%{version} -mkdir -p %{buildroot}%{_sbindir}/ -mv %{buildroot}/%{_bindir}/%{name}-httpd %{buildroot}/%{_sbindir}/%{name}-httpd -find %{buildroot} -type f -name '*.pyo' -delete + %find_lang %{name} --with-python -%files -f %{name}.lang +%files -n %{name}-core %defattr(-, root, root, -) %attr(0750, -,-) %dir %{_sysconfdir}/%{name}/ %config(noreplace) %attr(0640, -,-) %{_sysconfdir}/%{name}/%{name}.conf +%config(noreplace) %attr(0640, -,-) %{_sysconfdir}/%{name}/menu.yml %{_datadir}/%{name} -%{_sbindir}/%{name}-httpd -%{python_sitelib}/%{name}/ -%{python_sitelib}/%{name}*.egg-info %doc COPYING* AUTHORS README NEWS HACKING.README +%files -n %{name}-lang -f %{name}.lang + +%files %python_files +%{python_sitelib}/prewikka/ +%{python_sitelib}/prewikka*.egg-info +%{_sbindir}/prewikka-httpd-%{python_bin_suffix} +%python3_only %{_sbindir}/prewikka-httpd + %changelog