From 150fcb9d43694078548c103836daf9b0924173bc Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Nov 12 2020 16:13:31 +0000 Subject: Fix build with new mock and python 3.10 --- diff --git a/0001-journal-avoid-warning-about-deprecated-constant.patch b/0001-journal-avoid-warning-about-deprecated-constant.patch new file mode 100644 index 0000000..d9174b7 --- /dev/null +++ b/0001-journal-avoid-warning-about-deprecated-constant.patch @@ -0,0 +1,22 @@ +From 63473b65d0c10268a9e2c9485313c4584027e67e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Wed, 11 Nov 2020 22:36:04 +0100 +Subject: [PATCH 1/2] journal: avoid warning about deprecated constant + +--- + systemd/_reader.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/systemd/_reader.c b/systemd/_reader.c +index c9aa11d43c..8de7f6a963 100644 +--- a/systemd/_reader.c ++++ b/systemd/_reader.c +@@ -1339,7 +1339,7 @@ init_reader(void) + PyModule_AddIntConstant(m, "LOCAL_ONLY", SD_JOURNAL_LOCAL_ONLY) || + PyModule_AddIntConstant(m, "RUNTIME_ONLY", SD_JOURNAL_RUNTIME_ONLY) || + PyModule_AddIntConstant(m, "SYSTEM", SD_JOURNAL_SYSTEM) || +- PyModule_AddIntConstant(m, "SYSTEM_ONLY", SD_JOURNAL_SYSTEM_ONLY) || ++ PyModule_AddIntConstant(m, "SYSTEM_ONLY", SD_JOURNAL_SYSTEM) || + PyModule_AddIntConstant(m, "CURRENT_USER", SD_JOURNAL_CURRENT_USER) || + PyModule_AddIntConstant(m, "OS_ROOT", SD_JOURNAL_OS_ROOT) || + PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION)) { diff --git a/0002-reader-make-PY_SSIZE_T_CLEAN.patch b/0002-reader-make-PY_SSIZE_T_CLEAN.patch new file mode 100644 index 0000000..2c66e03 --- /dev/null +++ b/0002-reader-make-PY_SSIZE_T_CLEAN.patch @@ -0,0 +1,46 @@ +From ab9f2797127b374665c37c06b02121f5dcf7d61c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Thu, 12 Nov 2020 16:55:56 +0100 +Subject: [PATCH 2/2] reader: make PY_SSIZE_T_CLEAN + +--- + systemd/_reader.c | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +diff --git a/systemd/_reader.c b/systemd/_reader.c +index 8de7f6a963..3b6a4d0bbc 100644 +--- a/systemd/_reader.c ++++ b/systemd/_reader.c +@@ -18,7 +18,12 @@ + along with python-systemd; If not, see . + ***/ + ++#define PY_SSIZE_T_CLEAN ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wredundant-decls" + #include ++#pragma GCC diagnostic pop ++ + #include + #include + #include +@@ -710,11 +715,17 @@ PyDoc_STRVAR(Reader_add_match__doc__, + "Match is a string of the form \"FIELD=value\"."); + static PyObject* Reader_add_match(Reader *self, PyObject *args, PyObject *keywds) { + char *match; +- int match_len, r; ++ Py_ssize_t match_len; ++ int r; + if (!PyArg_ParseTuple(args, "s#:add_match", &match, &match_len)) + return NULL; + +- r = sd_journal_add_match(self->j, match, match_len); ++ if (match_len > INT_MAX) { ++ set_error(-ENOBUFS, NULL, NULL); ++ return NULL; ++ } ++ ++ r = sd_journal_add_match(self->j, match, (int) match_len); + if (set_error(r, NULL, "Invalid match") < 0) + return NULL; + diff --git a/0003-test-make-sure-NOTIFY_SOCKET-is-unset-in-test.patch b/0003-test-make-sure-NOTIFY_SOCKET-is-unset-in-test.patch new file mode 100644 index 0000000..ceb0fa4 --- /dev/null +++ b/0003-test-make-sure-NOTIFY_SOCKET-is-unset-in-test.patch @@ -0,0 +1,25 @@ +From 3757c7199b46bb4ac0f14512b3a8eb737a086a47 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Thu, 12 Nov 2020 17:08:02 +0100 +Subject: [PATCH] test: make sure $NOTIFY_SOCKET is unset in test + +When running the tests in Fedora's mock, the test would +fail because NOTIFY_SOCKET is set to /run/systemd/nspawn/notify, and +we get a permission error. +--- + systemd/test/test_daemon.py | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/systemd/test/test_daemon.py b/systemd/test/test_daemon.py +index 1ddb55e94d..425a1bcfc0 100644 +--- a/systemd/test/test_daemon.py ++++ b/systemd/test/test_daemon.py +@@ -257,6 +257,8 @@ def test_listen_fds_default_unset(): + assert listen_fds() == [] + + def test_notify_no_socket(): ++ del os.environ['NOTIFY_SOCKET'] ++ + assert notify('READY=1') is False + with skip_enosys(): + assert notify('FDSTORE=1', fds=[]) is False diff --git a/python-systemd.spec b/python-systemd.spec index 45e9ab6..dbf0544 100644 --- a/python-systemd.spec +++ b/python-systemd.spec @@ -1,12 +1,16 @@ Name: python-systemd Version: 234 -Release: 14%{?dist} +Release: 15%{?dist} Summary: Python module wrapping systemd functionality License: LGPLv2+ URL: https://github.com/systemd/python-systemd Source0: https://github.com/systemd/python-systemd/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz +Patch0001: 0001-journal-avoid-warning-about-deprecated-constant.patch +Patch0002: 0002-reader-make-PY_SSIZE_T_CLEAN.patch +Patch0003: 0003-test-make-sure-NOTIFY_SOCKET-is-unset-in-test.patch + BuildRequires: gcc BuildRequires: systemd-devel BuildRequires: python3-devel @@ -14,12 +18,12 @@ BuildRequires: python3-sphinx BuildRequires: web-assets-devel BuildRequires: python3-pytest -%global _description \ -Python module for native access to the systemd facilities.\ -Functionality includes sending of structured messages to the journal\ -and reading journal files, querying machine and boot identifiers and a\ -lists of message identifiers provided by systemd. Other functionality\ -provided by libsystemd is also wrapped. +%global _description %{expand: +Python module for native access to the systemd facilities. +Functionality includes sending of structured messages to the journal +and reading journal files, querying machine and boot identifiers and a +lists of message identifiers provided by systemd. Other functionality +provided by libsystemd is also wrapped.} %description %_description @@ -74,6 +78,9 @@ make PYTHON=%{__python3} check %doc %{_pkgdocdir}/html %changelog +* Thu Nov 12 2020 Zbigniew Jędrzejewski-Szmek - 234-15 +- Fix build with new mock (#1793022) and python 3.10 (#1891786) + * Wed Jul 29 2020 Fedora Release Engineering - 234-14 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild