alexk / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
2a5b6a
From 4a3d73081cb7db6673fa6775fbf5f6655f846241 Mon Sep 17 00:00:00 2001
2a5b6a
From: Florian Festi <ffesti@redhat.com>
2a5b6a
Date: Mon, 4 Jul 2016 18:34:44 +0200
2a5b6a
Subject: [PATCH] Fix rpmbuild --sign --quiet which relies on the output of
2a5b6a
 rpmbuild
2a5b6a
2a5b6a
by reproducing the output of the librpmbuild in the rpmbuild tool.
2a5b6a
---
2a5b6a
 rpmbuild.c | 31 +++++++++++++++++++++++++++++++
2a5b6a
 1 file changed, 31 insertions(+)
2a5b6a
2a5b6a
diff --git a/rpmbuild.c b/rpmbuild.c
2a5b6a
index 02d2655..aa63f97 100644
2a5b6a
--- a/rpmbuild.c
2a5b6a
+++ b/rpmbuild.c
2a5b6a
@@ -12,6 +12,7 @@
2a5b6a
 #include <rpm/rpmdb.h>
2a5b6a
 #include <rpm/rpmps.h>
2a5b6a
 #include <rpm/rpmts.h>
2a5b6a
+#include "build/rpmbuild_internal.h"
2a5b6a
 #include "lib/signature.h"
2a5b6a
 #include "cliutils.h"
2a5b6a
 
2a5b6a
@@ -517,6 +518,36 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
2a5b6a
     if (rpmSpecBuild(spec, ba)) {
2a5b6a
 	goto exit;
2a5b6a
     }
2a5b6a
+    /* Output generated package files for the --sign alias */
2a5b6a
+    if (quiet && rpmcliPipeOutput &&
2a5b6a
+	strncmp(rpmcliPipeOutput, "rpm --addsign", 13)) {
2a5b6a
+	rpmSetVerbosity(RPMLOG_INFO);
2a5b6a
+	if (buildAmount&RPMBUILD_PACKAGESOURCE) {
2a5b6a
+	    char *fn = rpmGetPath("%{_srcrpmdir}/", spec->sourceRpmName,NULL);
2a5b6a
+	    rpmlog(RPMLOG_INFO, _("Wrote: %s\n"), fn);
2a5b6a
+	    fn = _free(fn);
2a5b6a
+	}
2a5b6a
+	if (buildAmount&RPMBUILD_PACKAGEBINARY) {
2a5b6a
+	    rpmSpecPkgIter pkgiter = rpmSpecPkgIterInit(spec);
2a5b6a
+	    for (rpmSpecPkg pkg = rpmSpecPkgIterNext(pkgiter);
2a5b6a
+		 pkg;
2a5b6a
+		 pkg = rpmSpecPkgIterNext(pkgiter)) {
2a5b6a
+		char *binFormat = rpmGetPath("%{_rpmfilename}", NULL);
2a5b6a
+		char *binRpm, *fn;
2a5b6a
+		const char *errorString;
2a5b6a
+		Header h = rpmSpecPkgHeader(pkg);
2a5b6a
+		if (h) {
2a5b6a
+		    binRpm = headerFormat(h, binFormat, &errorString);
2a5b6a
+		    fn = rpmGetPath("%{_rpmdir}/", binRpm, NULL);
2a5b6a
+		    free(binRpm);
2a5b6a
+		    rpmlog(RPMLOG_INFO, _("Wrote: %s\n"), fn);
2a5b6a
+		    free(fn);
2a5b6a
+		}
2a5b6a
+		free(binFormat);
2a5b6a
+	    }
2a5b6a
+	}
2a5b6a
+	rpmSetVerbosity(RPMLOG_WARNING);
2a5b6a
+    }
2a5b6a
     
2a5b6a
     if (buildMode == 't')
2a5b6a
 	(void) unlink(specFile);
2a5b6a
-- 
2a5b6a
2.5.5
2a5b6a