All of lore.kernel.org
 help / color / mirror / Atom feed
* [morty][PATCH 0/4] rpm signing fixes
@ 2017-03-03 12:37 Markus Lehtonen
  2017-03-03 12:37 ` [morty][PATCH 1/4] lib/oe/gpg_sign: sign rpm packages in chunks of 100 Markus Lehtonen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Markus Lehtonen @ 2017-03-03 12:37 UTC (permalink / raw)
  To: openembedded-core

This patchset backports two fixes to gpg signing of rpm packages. The first
patch fixes signing of packages with a large amount of subpackages (e.g.
glibc-locale). The last three patches makes rpm package signing possible with
gpg version > 2.1.


The following changes since commit 55c835c73cc41b6fc809c941c295d62a612e49e0:

  build-appliance-image: Update to morty head revision (2017-02-08 12:00:29 +0000)

are available in the git repository at:

  git://git.openembedded.org/openembedded-core-contrib marquiz/morty
  http://git.openembedded.org/openembedded-core-contrib/log/?h=marquiz/morty


Markus Lehtonen (4):
  lib/oe/gpg_sign: sign rpm packages in chunks of 100
  rpm: support customizing gpg command line
  lib/oe/gpg_sign: make gpg version a property of the signer
  lib/oe/gpg_sign: fix rpm signing with gpg > 2.1

 meta/lib/oe/gpg_sign.py                            | 21 ++++++-----
 .../0001-macros-add-_gpg_sign_cmd_extra_args.patch | 43 ++++++++++++++++++++++
 meta/recipes-devtools/rpm/rpm_5.4.16.bb            |  1 +
 3 files changed, 56 insertions(+), 9 deletions(-)
 create mode 100644 meta/recipes-devtools/rpm/rpm/0001-macros-add-_gpg_sign_cmd_extra_args.patch

-- 
2.6.6



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [morty][PATCH 1/4] lib/oe/gpg_sign: sign rpm packages in chunks of 100
  2017-03-03 12:37 [morty][PATCH 0/4] rpm signing fixes Markus Lehtonen
@ 2017-03-03 12:37 ` Markus Lehtonen
  2017-03-03 12:37 ` [morty][PATCH 2/4] rpm: support customizing gpg command line Markus Lehtonen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Markus Lehtonen @ 2017-03-03 12:37 UTC (permalink / raw)
  To: openembedded-core

Split the file list into chunks in order to avoid
"OSError: [Errno 7] Argument list too long"

This would happend when a package has huge amount of subpackages, e.g.
glibc-locale.

[YOCTO #11069]

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
(cherry picked from commit 874f5016fd4dc76bc867b68470297fe59e78a9e6)
---
 meta/lib/oe/gpg_sign.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/meta/lib/oe/gpg_sign.py b/meta/lib/oe/gpg_sign.py
index 38eb0cb..683ae5b 100644
--- a/meta/lib/oe/gpg_sign.py
+++ b/meta/lib/oe/gpg_sign.py
@@ -35,11 +35,12 @@ class LocalSigner(object):
             cmd += "--define '%%__gpg %s' " % self.gpg_bin
         if self.gpg_path:
             cmd += "--define '_gpg_path %s' " % self.gpg_path
-        cmd += ' '.join(files)
 
-        status, output = oe.utils.getstatusoutput(cmd)
-        if status:
-            raise bb.build.FuncFailed("Failed to sign RPM packages: %s" % output)
+        # Sign in chunks of 100 packages
+        for i in range(0, len(files), 100):
+            status, output = oe.utils.getstatusoutput(cmd + ' '.join(files[i:i+100]))
+            if status:
+                raise bb.build.FuncFailed("Failed to sign RPM packages: %s" % output)
 
     def detach_sign(self, input_file, keyid, passphrase_file, passphrase=None, armor=True):
         """Create a detached signature of a file"""
-- 
2.6.6



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [morty][PATCH 2/4] rpm: support customizing gpg command line
  2017-03-03 12:37 [morty][PATCH 0/4] rpm signing fixes Markus Lehtonen
  2017-03-03 12:37 ` [morty][PATCH 1/4] lib/oe/gpg_sign: sign rpm packages in chunks of 100 Markus Lehtonen
@ 2017-03-03 12:37 ` Markus Lehtonen
  2017-03-03 12:37 ` [morty][PATCH 3/4] lib/oe/gpg_sign: make gpg version a property of the signer Markus Lehtonen
  2017-03-03 12:37 ` [morty][PATCH 4/4] lib/oe/gpg_sign: fix rpm signing with gpg > 2.1 Markus Lehtonen
  3 siblings, 0 replies; 5+ messages in thread
From: Markus Lehtonen @ 2017-03-03 12:37 UTC (permalink / raw)
  To: openembedded-core

Add a new %_gpg_sign_cmd_extra_args macro that allows customizing the
gpg options used when signing rpm packages. This is needed to be able to
sign packages with gpg 2.1 which requires "--pinentry-mode loopback" to
allow non-interactive signing.

[YOCTO #11054]

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
(cherry picked from commit 373a7146d596d27376a003014df0d06f3df5348d)
---
 .../0001-macros-add-_gpg_sign_cmd_extra_args.patch | 43 ++++++++++++++++++++++
 meta/recipes-devtools/rpm/rpm_5.4.16.bb            |  1 +
 2 files changed, 44 insertions(+)
 create mode 100644 meta/recipes-devtools/rpm/rpm/0001-macros-add-_gpg_sign_cmd_extra_args.patch

diff --git a/meta/recipes-devtools/rpm/rpm/0001-macros-add-_gpg_sign_cmd_extra_args.patch b/meta/recipes-devtools/rpm/rpm/0001-macros-add-_gpg_sign_cmd_extra_args.patch
new file mode 100644
index 0000000..eb43a87
--- /dev/null
+++ b/meta/recipes-devtools/rpm/rpm/0001-macros-add-_gpg_sign_cmd_extra_args.patch
@@ -0,0 +1,43 @@
+From fa9726ff69f86d6a87c4c4bd7e3d2881999a872a Mon Sep 17 00:00:00 2001
+From: Markus Lehtonen <markus.lehtonen@linux.intel.com>
+Date: Thu, 23 Feb 2017 11:14:20 +0200
+Subject: [PATCH] macros: add %_gpg_sign_cmd_extra_args
+
+Similar to what rpm4 has. This macro can be used to customize the
+gpg command line options when signing packages. This is needed for
+gpg 2.1 which requires "--pinentry-mode loopback" to allow
+non-interactive signing.
+
+Upstream-Status: Pending
+
+Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
+---
+ macros/macros.in | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/macros/macros.in b/macros/macros.in
+index 8bc5840..fda3c66 100644
+--- a/macros/macros.in
++++ b/macros/macros.in
+@@ -524,7 +524,9 @@ $_arbitrary_tags_tests	Foo:Bar
+ %_gpg_passphrase_way %{?_gpg_passphrase:--passphrase "%{_gpg_passphrase}"}%{!?_gpg_passphrase:--passphrase-fd 3}
+ 
+ %__gpg_check_password_cmd	%{__gpg} \
+-	gpg --batch --no-verbose %{_gpg_passphrase_way} -u "%{_gpg_name}" -so -
++	gpg --batch --no-verbose %{_gpg_passphrase_way} \
++	%{?_gpg_sign_cmd_extra_args:%{_gpg_sign_cmd_extra_args}} \
++	-u "%{_gpg_name}" -so -
+ #%__pgp_check_password_cmd	%{__pgp} \
+ #	pgp +batchmode=on +verbose=0 "%{_pgp_name}" -sf
+ #%__pgp5_check_password_cmd	%{__pgp} \
+@@ -532,6 +534,7 @@ $_arbitrary_tags_tests	Foo:Bar
+ 
+ %__gpg_sign_cmd			%{__gpg} \
+ 	gpg --batch --no-verbose --no-armor %{_gpg_passphrase_way}  --no-secmem-warning \
++	%{?_gpg_sign_cmd_extra_args:%{_gpg_sign_cmd_extra_args}} \
+ 	-u "%{_gpg_name}" -sbo %{__signature_filename} %{__plaintext_filename}
+ #%__pgp_sign_cmd			%{__pgp} \
+ #	pgp +batchmode=on +verbose=0 +armor=off \
+-- 
+2.10.2
+
diff --git a/meta/recipes-devtools/rpm/rpm_5.4.16.bb b/meta/recipes-devtools/rpm/rpm_5.4.16.bb
index 85eb5fe..497af8e 100644
--- a/meta/recipes-devtools/rpm/rpm_5.4.16.bb
+++ b/meta/recipes-devtools/rpm/rpm_5.4.16.bb
@@ -119,6 +119,7 @@ SRC_URI += " \
 	   file://gcc6-stdlib.patch \
 	   file://0001-system.h-query.c-support-nosignature.patch \
 	   file://rpm-ensure-rpm2cpio-call-rpm-relocation-code.patch \
+	   file://0001-macros-add-_gpg_sign_cmd_extra_args.patch \
 "
 
 # OE specific changes
-- 
2.6.6



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [morty][PATCH 3/4] lib/oe/gpg_sign: make gpg version a property of the signer
  2017-03-03 12:37 [morty][PATCH 0/4] rpm signing fixes Markus Lehtonen
  2017-03-03 12:37 ` [morty][PATCH 1/4] lib/oe/gpg_sign: sign rpm packages in chunks of 100 Markus Lehtonen
  2017-03-03 12:37 ` [morty][PATCH 2/4] rpm: support customizing gpg command line Markus Lehtonen
@ 2017-03-03 12:37 ` Markus Lehtonen
  2017-03-03 12:37 ` [morty][PATCH 4/4] lib/oe/gpg_sign: fix rpm signing with gpg > 2.1 Markus Lehtonen
  3 siblings, 0 replies; 5+ messages in thread
From: Markus Lehtonen @ 2017-03-03 12:37 UTC (permalink / raw)
  To: openembedded-core

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
(cherry picked from commit a00a362e3dc18ba04230cbbd6f91264e5d76f40d)
---
 meta/lib/oe/gpg_sign.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/meta/lib/oe/gpg_sign.py b/meta/lib/oe/gpg_sign.py
index 683ae5b..16eb7f8 100644
--- a/meta/lib/oe/gpg_sign.py
+++ b/meta/lib/oe/gpg_sign.py
@@ -10,6 +10,7 @@ class LocalSigner(object):
         self.gpg_bin = d.getVar('GPG_BIN', True) or \
                   bb.utils.which(os.getenv('PATH'), 'gpg')
         self.gpg_path = d.getVar('GPG_PATH', True)
+        self.gpg_version = self.get_gpg_version()
         self.rpm_bin = bb.utils.which(os.getenv('PATH'), "rpm")
 
     def export_pubkey(self, output_file, keyid, armor=True):
@@ -59,9 +60,7 @@ class LocalSigner(object):
 
         #gpg > 2.1 supports password pipes only through the loopback interface
         #gpg < 2.1 errors out if given unknown parameters
-        dots = self.get_gpg_version().split('.')
-        assert len(dots) >= 2
-        if int(dots[0]) >= 2 and int(dots[1]) >= 1:
+        if self.gpg_version > (2,1,):
             cmd += ['--pinentry-mode', 'loopback']
 
         cmd += [input_file]
@@ -88,10 +87,11 @@ class LocalSigner(object):
 
 
     def get_gpg_version(self):
-        """Return the gpg version"""
+        """Return the gpg version as a tuple of ints"""
         import subprocess
         try:
-            return subprocess.check_output((self.gpg_bin, "--version")).split()[2].decode("utf-8")
+            ver_str = subprocess.check_output((self.gpg_bin, "--version")).split()[2].decode("utf-8")
+            return tuple([int(i) for i in ver_str.split('.')])
         except subprocess.CalledProcessError as e:
             raise bb.build.FuncFailed("Could not get gpg version: %s" % e)
 
-- 
2.6.6



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [morty][PATCH 4/4] lib/oe/gpg_sign: fix rpm signing with gpg > 2.1
  2017-03-03 12:37 [morty][PATCH 0/4] rpm signing fixes Markus Lehtonen
                   ` (2 preceding siblings ...)
  2017-03-03 12:37 ` [morty][PATCH 3/4] lib/oe/gpg_sign: make gpg version a property of the signer Markus Lehtonen
@ 2017-03-03 12:37 ` Markus Lehtonen
  3 siblings, 0 replies; 5+ messages in thread
From: Markus Lehtonen @ 2017-03-03 12:37 UTC (permalink / raw)
  To: openembedded-core

We need to check the gpg version and alter its command line options
accordingly.

[YOCTO #11054]

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
(cherry picked from commit 44a44b7e582a5a654baf21829d168568481c13d9)
---
 meta/lib/oe/gpg_sign.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/meta/lib/oe/gpg_sign.py b/meta/lib/oe/gpg_sign.py
index 16eb7f8..ba61f98 100644
--- a/meta/lib/oe/gpg_sign.py
+++ b/meta/lib/oe/gpg_sign.py
@@ -32,6 +32,8 @@ class LocalSigner(object):
 
         cmd = self.rpm_bin + " --addsign --define '_gpg_name %s'  " % keyid
         cmd += "--define '_gpg_passphrase %s' " % passphrase
+        if self.gpg_version > (2,1,):
+            cmd += "--define '_gpg_sign_cmd_extra_args --pinentry-mode=loopback' "
         if self.gpg_bin:
             cmd += "--define '%%__gpg %s' " % self.gpg_bin
         if self.gpg_path:
-- 
2.6.6



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-03-03 12:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03 12:37 [morty][PATCH 0/4] rpm signing fixes Markus Lehtonen
2017-03-03 12:37 ` [morty][PATCH 1/4] lib/oe/gpg_sign: sign rpm packages in chunks of 100 Markus Lehtonen
2017-03-03 12:37 ` [morty][PATCH 2/4] rpm: support customizing gpg command line Markus Lehtonen
2017-03-03 12:37 ` [morty][PATCH 3/4] lib/oe/gpg_sign: make gpg version a property of the signer Markus Lehtonen
2017-03-03 12:37 ` [morty][PATCH 4/4] lib/oe/gpg_sign: fix rpm signing with gpg > 2.1 Markus Lehtonen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.