teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone
Blob Blame History Raw
commit 0bda2faa4de368a87f85084856a5fed701774acb
Author: Panu Matilainen <pmatilai@redhat.com>
Date:   Mon Aug 18 16:31:14 2014 +0300

    Populate manual dependencies into spec pkg headers early too
    
    - Similar to commit 1b41c91431d37295701281ff208f99a51f660c89, rpmspec
      and other tools expect to find manually specified dependencies
      from the headers of a freshly parsed spec. This means we need to
      add this cruft two times: once for the manual dependencies and then
      scratch all that and redo from start after automatic dependencies
      have been discovered at the end of package build.
    - Fixes another regression (rpmspec dependency queries went dead)
      introduced in commit a357c99c58a5e1367160dfa692f26d14bd3a3df1

diff --git a/build/pack.c b/build/pack.c
index dc24fb5..4abca48 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -618,6 +618,11 @@ rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating)
 	headerPutUint32(pkg->header, RPMTAG_BUILDTIME, getBuildTime(), 1);
 
 	for (int i=0; i<PACKAGE_NUM_DEPS; i++) {
+	    /* Nuke any previously added dependencies from the header */
+	    headerDel(pkg->header, rpmdsTagN(pkg->dependencies[i]));
+	    headerDel(pkg->header, rpmdsTagEVR(pkg->dependencies[i]));
+	    headerDel(pkg->header, rpmdsTagF(pkg->dependencies[i]));
+	    /* ...and add again, now with automatic dependencies included */
 	    rpmdsPutToHeader(pkg->dependencies[i], pkg->header);
 	}
 
diff --git a/build/parseSpec.c b/build/parseSpec.c
index b14c3ee..77cf409 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -548,6 +548,11 @@ static void addTargets(Package Pkgs)
 	headerPutString(pkg->header, RPMTAG_PLATFORM, platform);
 	headerPutString(pkg->header, RPMTAG_OPTFLAGS, optflags);
 
+	/* Add manual dependencies early for rpmspec etc to look at */
+	for (int i=0; i<PACKAGE_NUM_DEPS; i++) {
+	    rpmdsPutToHeader(pkg->dependencies[i], pkg->header);
+	}
+
 	pkg->ds = rpmdsThis(pkg->header, RPMTAG_REQUIRENAME, RPMSENSE_EQUAL);
 	addPackageProvides(pkg);
     }