Skip to contentSkip to conversation

selftest/cases/signing: ignore removal errors when cleaning temporary gpg directory

PATCH Applied [email protected] 2 participants 3 messages Sep 26, 2017 – Sep 27, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 selftest/cases/signing: ignore removal errors when cleaning temporary gpg directory

From: Leonardo Sandoval <[email protected]>

The high-level method tempfile.TemporaryDirectory give us no way to ignore erros on removal thus use tempfile.mkdtemp instead. Ignoring possible issues on removal is neccesary because it contains gpg sockets that are automatically removed by the system once the process terminates, otherwise the following log is observed:

..
..
File "/usr/lib/python3.5/shutil.py", line 436, in _rmtree_safe_fd
os.unlink(name, dir_fd=topfd)
FileNotFoundError: [Errno 2] No such file or directory: 'S.gpg-agent.browser'

[YOCTO #11821]

---
 meta/lib/oeqa/selftest/signing.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
meta/lib/oeqa/selftest/signing.py +5 -2
index 0ac3d1fac9..38e29305d5 100644
@@ -21,14 +21,17 @@ class Signing(oeSelfTest):
         if not shutil.which("gpg"):
             raise AssertionError("This test needs GnuPG")
 
-        cls.gpg_home_dir = tempfile.TemporaryDirectory(prefix="oeqa-signing-")
-        cls.gpg_dir = cls.gpg_home_dir.name
+        cls.gpg_dir = tempfile.mkdtemp(prefix="oeqa-signing-")
 
         cls.pub_key_path = os.path.join(cls.testlayer_path, 'files', 'signing', "key.pub")
         cls.secret_key_path = os.path.join(cls.testlayer_path, 'files', 'signing', "key.secret")
 
         runCmd('gpg --batch --homedir %s --import %s %s' % (cls.gpg_dir, cls.pub_key_path, cls.secret_key_path))
 
+    @classmethod
+    def tearDownClass(cls):
+        shutil.rmtree(cls.gpg_dir, ignore_errors=True)
+
     @testcase(1362)
     def test_signing_packages(self):
         """
Signature · 1 line
2.12.3
#1 lore raw

PATCH 2/2 sign_rpm.bbclass: force rpm serial signing

From: Leonardo Sandoval <[email protected]>

Newer versions of gpg (at least 2.1.5 and 2.2.1) have issues when signing occurs in parallel so (unfortunately) the signing must be done serially. Once the upstream problem is fixed, this patch must be reverted, otherwise we loose all the intrinsic parallelism from bitbake.

[YOCTO #12022]

---
 meta/classes/sign_rpm.bbclass | 6 ++++++
 1 file changed, 6 insertions(+)
meta/classes/sign_rpm.bbclass +6 -0
index bc2e947107..21010b03d6 100644
@@ -44,3 +44,9 @@ python sign_rpm () {
 
 do_package_index[depends] += "signing-keys:do_deploy"
 do_rootfs[depends] += "signing-keys:do_populate_sysroot"
+
+# Newer versions of gpg (at least 2.1.5 and 2.2.1) have issues when signing occurs in parallel
+# so unfortunately the signing must be done serially. Once the upstream problem is fixed,
+# the following line must be removed otherwise we loose all the intrinsic parallelism from
+# bitbake.  For more information, check https://bugzilla.yoctoproject.org/show_bug.cgi?id=12022.
+do_package_write_rpm[lockfiles] += "${TMPDIR}/gpg.lock"
Signature · 1 line
2.12.3
Applied
#2 lore raw
In reply to [email protected]

Leo,

Quoted 7 lines · On 09/26/2017 01:04 PM, [email protected] wrote:

From: Leonardo Sandoval <[email protected]>

The high-level method tempfile.TemporaryDirectory give us no way to ignore erros on removal thus use tempfile.mkdtemp instead. Ignoring possible issues on removal is neccesary because it contains gpg sockets that are automatically removed by the system once the process terminates, otherwise the following log is observed:

Quoted 7 lines

..
..
File "/usr/lib/python3.5/shutil.py", line 436, in _rmtree_safe_fd
os.unlink(name, dir_fd=topfd)
FileNotFoundError: [Errno 2] No such file or directory: 'S.gpg-agent.browser'

[YOCTO #11821]

merged to stagging,
Thanks,
Armin

Quoted 30 lines
---
 meta/lib/oeqa/selftest/signing.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
meta/lib/oeqa/selftest/signing.py +5 -2
index 0ac3d1fac9..38e29305d5 100644
@@ -21,14 +21,17 @@ class Signing(oeSelfTest):
         if not shutil.which("gpg"):
             raise AssertionError("This test needs GnuPG")
 
-        cls.gpg_home_dir = tempfile.TemporaryDirectory(prefix="oeqa-signing-")
-        cls.gpg_dir = cls.gpg_home_dir.name
+        cls.gpg_dir = tempfile.mkdtemp(prefix="oeqa-signing-")
 
         cls.pub_key_path = os.path.join(cls.testlayer_path, 'files', 'signing', "key.pub")
         cls.secret_key_path = os.path.join(cls.testlayer_path, 'files', 'signing', "key.secret")
 
         runCmd('gpg --batch --homedir %s --import %s %s' % (cls.gpg_dir, cls.pub_key_path, cls.secret_key_path))
 
+    @classmethod
+    def tearDownClass(cls):
+        shutil.rmtree(cls.gpg_dir, ignore_errors=True)
+
     @testcase(1362)
     def test_signing_packages(self):
         """