[yocto] [meta-security][PATCH] openscap-daemon: backport patch to fix build error with python 3.7

Yi Zhao yi.zhao at windriver.com
Thu Mar 7 00:32:59 PST 2019


Fixes build error:
  | Traceback (most recent call last):
  |   File "setup.py", line 25, in <module>
  |     from openscap_daemon import version
  |   File "/buildarea/build/tmp/work/core2-64-poky-linux/openscap-daemon/0.1.10-r0/git/openscap_daemon/__init__.py", line 22, in <module>
  |     from openscap_daemon.system import System
  |   File "/buildarea/build/tmp/work/core2-64-poky-linux/openscap-daemon/0.1.10-r0/git/openscap_daemon/system.py", line 29
  |     from openscap_daemon import async
  |                                     ^
  | SyntaxError: invalid syntax

Signed-off-by: Yi Zhao <yi.zhao at windriver.com>
---
 ...-module-and-variables-to-get-rid-of-async.patch | 130 +++++++++++++++++++++
 .../openscap-daemon/openscap-daemon_0.1.10.bb      |   4 +-
 2 files changed, 133 insertions(+), 1 deletion(-)
 create mode 100644 meta-security-compliance/recipes-openscap/openscap-daemon/files/0001-Renamed-module-and-variables-to-get-rid-of-async.patch

diff --git a/meta-security-compliance/recipes-openscap/openscap-daemon/files/0001-Renamed-module-and-variables-to-get-rid-of-async.patch b/meta-security-compliance/recipes-openscap/openscap-daemon/files/0001-Renamed-module-and-variables-to-get-rid-of-async.patch
new file mode 100644
index 0000000..2a518bf
--- /dev/null
+++ b/meta-security-compliance/recipes-openscap/openscap-daemon/files/0001-Renamed-module-and-variables-to-get-rid-of-async.patch
@@ -0,0 +1,130 @@
+From c34349720a57997d30946286756e2ba9dbab6ace Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Mat=C4=9Bj=20T=C3=BD=C4=8D?= <matyc at redhat.com>
+Date: Mon, 2 Jul 2018 11:21:19 +0200
+Subject: [PATCH] Renamed module and variables to get rid of async.
+
+async is a reserved word in Python 3.7.
+
+Upstream-Status: Backport
+[https://github.com/OpenSCAP/openscap-daemon/commit/c34349720a57997d30946286756e2ba9dbab6ace]
+
+Signed-off-by: Yi Zhao <yi.zhao at windriver.com>
+---
+ openscap_daemon/{async.py => async_tools.py} |  0
+ openscap_daemon/dbus_daemon.py               |  2 +-
+ openscap_daemon/system.py                    | 16 ++++++++--------
+ tests/unit/test_basic_update.py              |  3 ++-
+ 4 files changed, 11 insertions(+), 10 deletions(-)
+ rename openscap_daemon/{async.py => async_tools.py} (100%)
+
+diff --git a/openscap_daemon/async.py b/openscap_daemon/async_tools.py
+similarity index 100%
+rename from openscap_daemon/async.py
+rename to openscap_daemon/async_tools.py
+diff --git a/openscap_daemon/dbus_daemon.py b/openscap_daemon/dbus_daemon.py
+index e6eadf9..cb6a8b6 100644
+--- a/openscap_daemon/dbus_daemon.py
++++ b/openscap_daemon/dbus_daemon.py
+@@ -81,7 +81,7 @@ class OpenSCAPDaemonDbus(dbus.service.Object):
+     @dbus.service.method(dbus_interface=dbus_utils.DBUS_INTERFACE,
+                          in_signature="", out_signature="a(xsi)")
+     def GetAsyncActionsStatus(self):
+-        return self.system.async.get_status()
++        return self.system.async_manager.get_status()
+ 
+     @dbus.service.method(dbus_interface=dbus_utils.DBUS_INTERFACE,
+                          in_signature="s", out_signature="(sssn)")
+diff --git a/openscap_daemon/system.py b/openscap_daemon/system.py
+index 2012f6e..85c2680 100644
+--- a/openscap_daemon/system.py
++++ b/openscap_daemon/system.py
+@@ -26,7 +26,7 @@ import logging
+ from openscap_daemon.task import Task
+ from openscap_daemon.config import Configuration
+ from openscap_daemon import oscap_helpers
+-from openscap_daemon import async
++from openscap_daemon import async_tools
+ 
+ 
+ class ResultsNotAvailable(Exception):
+@@ -40,7 +40,7 @@ TASK_ACTION_PRIORITY = 10
+ 
+ class System(object):
+     def __init__(self, config_file):
+-        self.async = async.AsyncManager()
++        self.async_manager = async_tools.AsyncManager()
+ 
+         logging.info("Loading configuration from '%s'.", config_file)
+         self.config = Configuration()
+@@ -90,7 +90,7 @@ class System(object):
+             input_file, tailoring_file, None
+         )
+ 
+-    class AsyncEvaluateSpecAction(async.AsyncAction):
++    class AsyncEvaluateSpecAction(async_tools.AsyncAction):
+         def __init__(self, system, spec):
+             super(System.AsyncEvaluateSpecAction, self).__init__()
+ 
+@@ -113,7 +113,7 @@ class System(object):
+             return "Evaluate Spec '%s'" % (self.spec)
+ 
+     def evaluate_spec_async(self, spec):
+-        return self.async.enqueue(
++        return self.async_manager.enqueue(
+             System.AsyncEvaluateSpecAction(
+                 self,
+                 spec
+@@ -488,7 +488,7 @@ class System(object):
+ 
+         return ret
+ 
+-    class AsyncUpdateTaskAction(async.AsyncAction):
++    class AsyncUpdateTaskAction(async_tools.AsyncAction):
+         def __init__(self, system, task_id, reference_datetime):
+             super(System.AsyncUpdateTaskAction, self).__init__()
+ 
+@@ -536,7 +536,7 @@ class System(object):
+ 
+                 if task.should_be_updated(reference_datetime):
+                     self.tasks_scheduled.add(task.id_)
+-                    self.async.enqueue(
++                    self.async_manager.enqueue(
+                         System.AsyncUpdateTaskAction(
+                             self,
+                             task.id_,
+@@ -662,7 +662,7 @@ class System(object):
+             fix_type
+         )
+ 
+-    class AsyncEvaluateCVEScannerWorkerAction(async.AsyncAction):
++    class AsyncEvaluateCVEScannerWorkerAction(async_tools.AsyncAction):
+         def __init__(self, system, worker):
+             super(System.AsyncEvaluateCVEScannerWorkerAction, self).__init__()
+ 
+@@ -680,7 +680,7 @@ class System(object):
+             return "Evaluate CVE Scanner Worker '%s'" % (self.worker)
+ 
+     def evaluate_cve_scanner_worker_async(self, worker):
+-        return self.async.enqueue(
++        return self.async_manager.enqueue(
+             System.AsyncEvaluateCVEScannerWorkerAction(
+                 self,
+                 worker
+diff --git a/tests/unit/test_basic_update.py b/tests/unit/test_basic_update.py
+index 6f683e6..7f953f7 100755
+--- a/tests/unit/test_basic_update.py
++++ b/tests/unit/test_basic_update.py
+@@ -37,8 +37,9 @@ class BasicUpdateTest(unit_test_harness.APITest):
+         print(self.system.tasks)
+         self.system.schedule_tasks()
+ 
+-        while len(self.system.async.actions) > 0:
++        while len(self.system.async_manager.actions) > 0:
+             time.sleep(1)
+ 
++
+ if __name__ == "__main__":
+     BasicUpdateTest.run()
+-- 
+2.7.4
+
diff --git a/meta-security-compliance/recipes-openscap/openscap-daemon/openscap-daemon_0.1.10.bb b/meta-security-compliance/recipes-openscap/openscap-daemon/openscap-daemon_0.1.10.bb
index a6a9373..ca6e030 100644
--- a/meta-security-compliance/recipes-openscap/openscap-daemon/openscap-daemon_0.1.10.bb
+++ b/meta-security-compliance/recipes-openscap/openscap-daemon/openscap-daemon_0.1.10.bb
@@ -9,7 +9,9 @@ LICENSE = "LGPL-2.1"
 DEPENDS = "python3-dbus"
 
 SRCREV = "f25b16afb6ac761fea13132ff406fba4cdfd2b76"
-SRC_URI = "git://github.com/OpenSCAP/openscap-daemon.git"
+SRC_URI = "git://github.com/OpenSCAP/openscap-daemon.git \
+           file://0001-Renamed-module-and-variables-to-get-rid-of-async.patch \
+          "
 
 inherit setuptools3
 
-- 
2.7.4



More information about the yocto mailing list