All of lore.kernel.org
 help / color / mirror / Atom feed
* Failure Inheriting rpm_sign
@ 2017-01-06 11:52 Chris Trobridge
  2017-01-09 18:47 ` Khem Raj
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Trobridge @ 2017-01-06 11:52 UTC (permalink / raw)
  To: Yocto List

I am getting "Exception: OSError: [Errno 7] Argument list too long" for sign_rpm in the do_package_write_rpm tasks for the 
linux-yocto and glibc-locale recipes.

This is building core-image-minimal (and also my own image) with morty (5aa481d) on Fedora 25.

I have enabled the rpm signing with:

INHERIT += " sign_rpm"
RPM_GPG_NAME = "{name}"
RPM_GPG_PASSPHRASE = "{passphrase}"
IMAGE_INSTALL_append = " signing-keys-rpm"

The error message makes some sense in as much as these recipes produce a lot of packages (for example, glibc-locale produces 1791 packages) and the command line in the log is pretty big, although reading around I didn't find a consensus on what the max command line should be.

The code to sign rpms is in meta/lib/oe/gpg_sign.py b/meta/lib/oe/gpg_sign.py and it builds up one command line with all the packages.

I changed the code (patch appended) to sign each rpm in a separate command and the build completed successfully.  The signing operations take a large amount of time so I think this might be a reasonable change but you may have other concerns.

Regards,
Chris

diff --git a/meta/lib/oe/gpg_sign.py b/meta/lib/oe/gpg_sign.py
index 38eb0cb..a386b1f 100644
--- a/meta/lib/oe/gpg_sign.py
+++ b/meta/lib/oe/gpg_sign.py
@@ -29,17 +29,18 @@ class LocalSigner(object):
     def sign_rpms(self, files, keyid, passphrase):
         """Sign RPM files"""
 
-        cmd = self.rpm_bin + " --addsign --define '_gpg_name %s'  " % keyid
-        cmd += "--define '_gpg_passphrase %s' " % passphrase
-        if self.gpg_bin:
-            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)
+        for file in files:
+            cmd = self.rpm_bin + " --addsign --define '_gpg_name %s'  " % keyid
+            cmd += "--define '_gpg_passphrase %s' " % passphrase
+            if self.gpg_bin:
+                cmd += "--define '%%__gpg %s' " % self.gpg_bin
+            if self.gpg_path:
+                cmd += "--define '_gpg_path %s' " % self.gpg_path
+            cmd += file
+
+            status, output = oe.utils.getstatusoutput(cmd)
+            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"""


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

* Re: Failure Inheriting rpm_sign
  2017-01-06 11:52 Failure Inheriting rpm_sign Chris Trobridge
@ 2017-01-09 18:47 ` Khem Raj
  2017-01-11 12:33   ` Chris Trobridge
       [not found]   ` <718C63C6-EC5D-474D-8FC2-18573E1B7DBA@hotmail.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Khem Raj @ 2017-01-09 18:47 UTC (permalink / raw)
  To: Chris Trobridge; +Cc: Yocto List

On Fri, Jan 6, 2017 at 3:52 AM, Chris Trobridge
<christrobridge@hotmail.com> wrote:
> I am getting "Exception: OSError: [Errno 7] Argument list too long" for sign_rpm in the do_package_write_rpm tasks for the
> linux-yocto and glibc-locale recipes.
>
> This is building core-image-minimal (and also my own image) with morty (5aa481d) on Fedora 25.
>
> I have enabled the rpm signing with:
>
> INHERIT += " sign_rpm"
> RPM_GPG_NAME = "{name}"
> RPM_GPG_PASSPHRASE = "{passphrase}"
> IMAGE_INSTALL_append = " signing-keys-rpm"
>
> The error message makes some sense in as much as these recipes produce a lot of packages (for example, glibc-locale produces 1791 packages) and the command line in the log is pretty big, although reading around I didn't find a consensus on what the max command line should be.
>
> The code to sign rpms is in meta/lib/oe/gpg_sign.py b/meta/lib/oe/gpg_sign.py and it builds up one command line with all the packages.
>
> I changed the code (patch appended) to sign each rpm in a separate command and the build completed successfully.  The signing operations take a large amount of time so I think this might be a reasonable change but you may have other concerns.

This certainly is useful, perhaps the signing bits can be moved to individual
recipe packaging tasks that way it may be parallelized a bit

>
> Regards,
> Chris
>
> diff --git a/meta/lib/oe/gpg_sign.py b/meta/lib/oe/gpg_sign.py
> index 38eb0cb..a386b1f 100644
> --- a/meta/lib/oe/gpg_sign.py
> +++ b/meta/lib/oe/gpg_sign.py
> @@ -29,17 +29,18 @@ class LocalSigner(object):
>      def sign_rpms(self, files, keyid, passphrase):
>          """Sign RPM files"""
>
> -        cmd = self.rpm_bin + " --addsign --define '_gpg_name %s'  " % keyid
> -        cmd += "--define '_gpg_passphrase %s' " % passphrase
> -        if self.gpg_bin:
> -            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)
> +        for file in files:
> +            cmd = self.rpm_bin + " --addsign --define '_gpg_name %s'  " % keyid
> +            cmd += "--define '_gpg_passphrase %s' " % passphrase
> +            if self.gpg_bin:
> +                cmd += "--define '%%__gpg %s' " % self.gpg_bin
> +            if self.gpg_path:
> +                cmd += "--define '_gpg_path %s' " % self.gpg_path
> +            cmd += file
> +
> +            status, output = oe.utils.getstatusoutput(cmd)
> +            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"""
> --
> _______________________________________________
> yocto mailing list
> yocto@yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto


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

* Re: Failure Inheriting rpm_sign
  2017-01-09 18:47 ` Khem Raj
@ 2017-01-11 12:33   ` Chris Trobridge
  2017-01-11 16:28     ` Khem Raj
       [not found]   ` <718C63C6-EC5D-474D-8FC2-18573E1B7DBA@hotmail.com>
  1 sibling, 1 reply; 5+ messages in thread
From: Chris Trobridge @ 2017-01-11 12:33 UTC (permalink / raw)
  To: Khem Raj; +Cc: Yocto List

On Mon, 2017-01-09 at 10:47 -0800, Khem Raj wrote:
> On Fri, Jan 6, 2017 at 3:52 AM, Chris Trobridge
> <christrobridge@hotmail.com> wrote:
> > I am getting "Exception: OSError: [Errno 7] Argument list too long"
> > for sign_rpm in the do_package_write_rpm tasks for the
> > linux-yocto and glibc-locale recipes.
> > 
> > This is building core-image-minimal (and also my own image) with
> > morty (5aa481d) on Fedora 25.
> > 
> > I have enabled the rpm signing with:
> > 
> > INHERIT += " sign_rpm"
> > RPM_GPG_NAME = "{name}"
> > RPM_GPG_PASSPHRASE = "{passphrase}"
> > IMAGE_INSTALL_append = " signing-keys-rpm"
> > 
> > The error message makes some sense in as much as these recipes
> > produce a lot of packages (for example, glibc-locale produces 1791
> > packages) and the command line in the log is pretty big, although
> > reading around I didn't find a consensus on what the max command
> > line should be.
> > 
> > The code to sign rpms is in meta/lib/oe/gpg_sign.py
> > b/meta/lib/oe/gpg_sign.py and it builds up one command line with
> > all the packages.
> > 
> > I changed the code (patch appended) to sign each rpm in a separate
> > command and the build completed successfully.  The signing
> > operations take a large amount of time so I think this might be a
> > reasonable change but you may have other concerns.
> 
> This certainly is useful, perhaps the signing bits can be moved to
> individual
> recipe packaging tasks that way it may be parallelized a bit
> 

Thanks Raj,

Something needs to be done as, unless I've messed up somewhere, you
cannot build even core-image-minimal with rpm signing enabled so the
sign_rpm class is effectively broken.

The change I made works, but it's true is less efficient than signing
rpms individually.  The expense of the signature generation meant it
wasn't inefficient to sign each package in a recipe with a separate
command.

However, looking in package_rpm.bbclass, the end of do_package_rpm()
has:

if d.getVar('RPM_SIGN_PACKAGES', True) == '1':
    bb.build.exec_func("sign_rpm", d)

So, to avoid confusion, all the rpms in one recipe are packaged in
task, and then that task calls the function  sign all the packages.  I
don't know if there's a way for do_package_rpm() to spawn tasks to sign
each package individually.

I also found I needed 'IMAGE_INSTALL_append = " signing-keys-rpm"'
local.conf, to deploy the public key but in sign_rpms.bbclass there is:

do_package_index[depends] += "signing-keys:do_deploy"
do_rootfs[depends] += "signing-keys:do_populate_sysroot"

It may be this isn't quite what is required.

Regards,
Chris


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

* Re: Failure Inheriting rpm_sign
  2017-01-11 12:33   ` Chris Trobridge
@ 2017-01-11 16:28     ` Khem Raj
  0 siblings, 0 replies; 5+ messages in thread
From: Khem Raj @ 2017-01-11 16:28 UTC (permalink / raw)
  To: Chris Trobridge; +Cc: Yocto List

On Wed, Jan 11, 2017 at 4:33 AM, Chris Trobridge
<christrobridge@hotmail.com> wrote:
> On Mon, 2017-01-09 at 10:47 -0800, Khem Raj wrote:
>> On Fri, Jan 6, 2017 at 3:52 AM, Chris Trobridge
>> <christrobridge@hotmail.com> wrote:
>> > I am getting "Exception: OSError: [Errno 7] Argument list too long"
>> > for sign_rpm in the do_package_write_rpm tasks for the
>> > linux-yocto and glibc-locale recipes.
>> >
>> > This is building core-image-minimal (and also my own image) with
>> > morty (5aa481d) on Fedora 25.
>> >
>> > I have enabled the rpm signing with:
>> >
>> > INHERIT += " sign_rpm"
>> > RPM_GPG_NAME = "{name}"
>> > RPM_GPG_PASSPHRASE = "{passphrase}"
>> > IMAGE_INSTALL_append = " signing-keys-rpm"
>> >
>> > The error message makes some sense in as much as these recipes
>> > produce a lot of packages (for example, glibc-locale produces 1791
>> > packages) and the command line in the log is pretty big, although
>> > reading around I didn't find a consensus on what the max command
>> > line should be.
>> >
>> > The code to sign rpms is in meta/lib/oe/gpg_sign.py
>> > b/meta/lib/oe/gpg_sign.py and it builds up one command line with
>> > all the packages.
>> >
>> > I changed the code (patch appended) to sign each rpm in a separate
>> > command and the build completed successfully.  The signing
>> > operations take a large amount of time so I think this might be a
>> > reasonable change but you may have other concerns.
>>
>> This certainly is useful, perhaps the signing bits can be moved to
>> individual
>> recipe packaging tasks that way it may be parallelized a bit
>>
>
> Thanks Raj,
>
> Something needs to be done as, unless I've messed up somewhere, you
> cannot build even core-image-minimal with rpm signing enabled so the
> sign_rpm class is effectively broken.

Its possible. I personally dont use rpm package management system, so
dont have first hand usecase here. may be you can open a bug as well


>
> The change I made works, but it's true is less efficient than signing
> rpms individually.  The expense of the signature generation meant it
> wasn't inefficient to sign each package in a recipe with a separate
> command.

existing logic must have worked at some point of time. It just is that
some bug has creeped in over period of time, may be due to it being
a less tested combination

>
> However, looking in package_rpm.bbclass, the end of do_package_rpm()
> has:
>
> if d.getVar('RPM_SIGN_PACKAGES', True) == '1':
>     bb.build.exec_func("sign_rpm", d)
>
> So, to avoid confusion, all the rpms in one recipe are packaged in
> task, and then that task calls the function  sign all the packages.  I
> don't know if there's a way for do_package_rpm() to spawn tasks to sign
> each package individually.

I think it could be made so that all rpms coming out of a given recipe are
signed together

>
> I also found I needed 'IMAGE_INSTALL_append = " signing-keys-rpm"'
> local.conf, to deploy the public key but in sign_rpms.bbclass there is:
>
> do_package_index[depends] += "signing-keys:do_deploy"
> do_rootfs[depends] += "signing-keys:do_populate_sysroot"
>
> It may be this isn't quite what is required.

Perhaps turning this into a distro feature is a better option.

>
> Regards,
> Chris
>


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

* Re: Failure Inheriting rpm_sign
       [not found]   ` <718C63C6-EC5D-474D-8FC2-18573E1B7DBA@hotmail.com>
@ 2017-01-13 11:25     ` Markus Lehtonen
  0 siblings, 0 replies; 5+ messages in thread
From: Markus Lehtonen @ 2017-01-13 11:25 UTC (permalink / raw)
  To: Chris Trobridge, Khem Raj; +Cc: Yocto List

On 11/01/2017, 14.33, "Chris Trobridge" <yocto-bounces@yoctoproject.org on
behalf of christrobridge@hotmail.com> wrote:

>On Mon, 2017-01-09 at 10:47 -0800, Khem Raj wrote:
>> On Fri, Jan 6, 2017 at 3:52 AM, Chris Trobridge
>> <christrobridge@hotmail.com> wrote:
>> > I am getting "Exception: OSError: [Errno 7] Argument list too long"
>> > for sign_rpm in the do_package_write_rpm tasks for the
>> > linux-yocto and glibc-locale recipes.
>> > 
>> > This is building core-image-minimal (and also my own image) with
>> > morty (5aa481d) on Fedora 25.
>> > 
>> > I have enabled the rpm signing with:
>> > 
>> > INHERIT += " sign_rpm"
>> > RPM_GPG_NAME = "{name}"
>> > RPM_GPG_PASSPHRASE = "{passphrase}"
>> > IMAGE_INSTALL_append = " signing-keys-rpm"
>> > 
>> > The error message makes some sense in as much as these recipes
>> > produce a lot of packages (for example, glibc-locale produces 1791
>> > packages) and the command line in the log is pretty big, although
>> > reading around I didn't find a consensus on what the max command
>> > line should be.
>> > 
>> > The code to sign rpms is in meta/lib/oe/gpg_sign.py
>> > b/meta/lib/oe/gpg_sign.py and it builds up one command line with
>> > all the packages.
>> > 
>> > I changed the code (patch appended) to sign each rpm in a separate
>> > command and the build completed successfully.  The signing
>> > operations take a large amount of time so I think this might be a
>> > reasonable change but you may have other concerns.
>> 
>> This certainly is useful, perhaps the signing bits can be moved to
>> individual
>> recipe packaging tasks that way it may be parallelized a bit
>> 
>
>Thanks Raj,
>
>Something needs to be done as, unless I've messed up somewhere, you
>cannot build even core-image-minimal with rpm signing enabled so the
>sign_rpm class is effectively broken.

Signing should not break this way. Could you create a bug about this.



>The change I made works, but it's true is less efficient than signing
>rpms individually.  The expense of the signature generation meant it
>wasn't inefficient to sign each package in a recipe with a separate
>command.
>
>However, looking in package_rpm.bbclass, the end of do_package_rpm()
>has:
>
>if d.getVar('RPM_SIGN_PACKAGES', True) == '1':
>    bb.build.exec_func("sign_rpm", d)
>
>So, to avoid confusion, all the rpms in one recipe are packaged in
>task, and then that task calls the function  sign all the packages.  I
>don't know if there's a way for do_package_rpm() to spawn tasks to sign
>each package individually.

Probably an easy solution would be to sign packages in batches of, say,
100 packages. That way almost all recipes would be signed in one go. Few
packages would require multiple invocations of rpm but that shouldn't be
significant total overhead.



>I also found I needed 'IMAGE_INSTALL_append = " signing-keys-rpm"'
>local.conf, to deploy the public key but in sign_rpms.bbclass there is:

Yes, you need to add that package if you want to get the signing keys
installed in the image.



>
>do_package_index[depends] += "signing-keys:do_deploy"
>do_rootfs[depends] += "signing-keys:do_populate_sysroot"
>
>It may be this isn't quite what is required.

These are needed at build time and they do not install anything in the
final image. The first one is needed for creating rpm package feeds (or
repositories). The second one is needed needed for rpm-native to have the
correct keys when it is installing packages to create the rootfs.



Thanks,
   Markus




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

end of thread, other threads:[~2017-01-13 11:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-06 11:52 Failure Inheriting rpm_sign Chris Trobridge
2017-01-09 18:47 ` Khem Raj
2017-01-11 12:33   ` Chris Trobridge
2017-01-11 16:28     ` Khem Raj
     [not found]   ` <718C63C6-EC5D-474D-8FC2-18573E1B7DBA@hotmail.com>
2017-01-13 11:25     ` 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.