richardphibel / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
Blob Blame History Raw
From 4a3d73081cb7db6673fa6775fbf5f6655f846241 Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Mon, 4 Jul 2016 18:34:44 +0200
Subject: [PATCH] Fix rpmbuild --sign --quiet which relies on the output of
 rpmbuild

by reproducing the output of the librpmbuild in the rpmbuild tool.
---
 rpmbuild.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/rpmbuild.c b/rpmbuild.c
index 02d2655..aa63f97 100644
--- a/rpmbuild.c
+++ b/rpmbuild.c
@@ -12,6 +12,7 @@
 #include <rpm/rpmdb.h>
 #include <rpm/rpmps.h>
 #include <rpm/rpmts.h>
+#include "build/rpmbuild_internal.h"
 #include "lib/signature.h"
 #include "cliutils.h"
 
@@ -517,6 +518,36 @@ static int buildForTarget(rpmts ts, const char * arg, BTA_t ba)
     if (rpmSpecBuild(spec, ba)) {
 	goto exit;
     }
+    /* Output generated package files for the --sign alias */
+    if (quiet && rpmcliPipeOutput &&
+	strncmp(rpmcliPipeOutput, "rpm --addsign", 13)) {
+	rpmSetVerbosity(RPMLOG_INFO);
+	if (buildAmount&RPMBUILD_PACKAGESOURCE) {
+	    char *fn = rpmGetPath("%{_srcrpmdir}/", spec->sourceRpmName,NULL);
+	    rpmlog(RPMLOG_INFO, _("Wrote: %s\n"), fn);
+	    fn = _free(fn);
+	}
+	if (buildAmount&RPMBUILD_PACKAGEBINARY) {
+	    rpmSpecPkgIter pkgiter = rpmSpecPkgIterInit(spec);
+	    for (rpmSpecPkg pkg = rpmSpecPkgIterNext(pkgiter);
+		 pkg;
+		 pkg = rpmSpecPkgIterNext(pkgiter)) {
+		char *binFormat = rpmGetPath("%{_rpmfilename}", NULL);
+		char *binRpm, *fn;
+		const char *errorString;
+		Header h = rpmSpecPkgHeader(pkg);
+		if (h) {
+		    binRpm = headerFormat(h, binFormat, &errorString);
+		    fn = rpmGetPath("%{_rpmdir}/", binRpm, NULL);
+		    free(binRpm);
+		    rpmlog(RPMLOG_INFO, _("Wrote: %s\n"), fn);
+		    free(fn);
+		}
+		free(binFormat);
+	    }
+	}
+	rpmSetVerbosity(RPMLOG_WARNING);
+    }
     
     if (buildMode == 't')
 	(void) unlink(specFile);
-- 
2.5.5