why not have mash write a signed rpm out instead of just warning users
when a package has cached signatures, but no signed rpm?

lightly tested patch attached.

rob.
diff --git a/mash/__init__.py b/mash/__init__.py
index 0355c43..d1a400c 100644
--- a/mash/__init__.py
+++ b/mash/__init__.py
@@ -31,6 +31,9 @@ import rpmUtils.arch
 def nevra(pkg):
     return '%s-%s:%s-%s.%s' % (pkg['name'],pkg['epoch'],pkg['version'],pkg['release'],pkg['arch'])
 
+def nvr(pkg):
+    return '%s-%s-%s' % (pkg['name'],pkg['version'],pkg['release'])
+
 class PackageList:
     def __init__(self, config):
         self._packages = {}
@@ -235,9 +238,20 @@ class Mash:
                     z['release'] = builds_hash[pkg['build_id']]['release']
                     p = os.path.join(koji.pathinfo.build(z), koji.pathinfo.signed(pkg, pkg['sigkey']))
                     if not os.path.exists(p):
-                        print "WARNING: package %s has cached signatures (%s), but no signed RPM" % (nevra(pkg), key)
-                        if self.config.strict_keys:
+                        if self.config.write_signed:
+                            command = "/usr/bin/koji write-signed-rpm %s %s" % (key, nvr(pkg))
+                            # NOTE: this should be called on the nvr of the SRPM
+                            print "WARNING: running  %s" % command
+                            try:
+                                os.system(command)
+                            except TypeError:
+                                print "WARNING: error writing signature for %s.  Not an SRPM?" % nvr(pkg)
+                        elif self.config.strict_keys:
                             exit = 1
+                            print "WARNING: please execute: koji write-signed-rpm %s %s" % (key, nvr(pkg))
+                        else:
+                            print "WARNING: package %s has cached signatures (%s), but no signed RPM" % (nevra(pkg), key)
+
         if exit:
             sys.exit(1)
         
diff --git a/mash/arch.py b/mash/arch.py
diff --git a/mash/config.py b/mash/config.py
index 4b84835..cfaa5f2 100644
--- a/mash/config.py
+++ b/mash/config.py
@@ -20,6 +20,7 @@ class MashConfig(config.BaseConfig):
     keys = config.ListOption()
     configdir = config.Option('/etc/mash')
     strict_keys = config.BoolOption(False)
+    write_signed = config.BoolOption(False)
     workdir = config.Option('/var/tmp/mash')
     buildhost = config.Option()
     repodir = config.Option('/mnt/koji')
@@ -42,6 +43,7 @@ class MashDistroConfig(config.BaseConfig):
     inherit = config.BoolOption(True)
     keys = config.Inherit(MashConfig.keys)
     strict_keys = config.Inherit(MashConfig.strict_keys)
+    write_signed = config.Inherit(MashConfig.strict_keys)
     buildhost = config.Inherit(MashConfig.buildhost)
     repodir = config.Inherit(MashConfig.repodir)
     workdir = config.Inherit(MashConfig.workdir)
--
Fedora-buildsys-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/fedora-buildsys-list

Reply via email to