Panu Matilainen 5f4984
commit 0bda2faa4de368a87f85084856a5fed701774acb
Panu Matilainen 5f4984
Author: Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen 5f4984
Date:   Mon Aug 18 16:31:14 2014 +0300
Panu Matilainen 5f4984
Panu Matilainen 5f4984
    Populate manual dependencies into spec pkg headers early too
Panu Matilainen 5f4984
    
Panu Matilainen 5f4984
    - Similar to commit 1b41c91431d37295701281ff208f99a51f660c89, rpmspec
Panu Matilainen 5f4984
      and other tools expect to find manually specified dependencies
Panu Matilainen 5f4984
      from the headers of a freshly parsed spec. This means we need to
Panu Matilainen 5f4984
      add this cruft two times: once for the manual dependencies and then
Panu Matilainen 5f4984
      scratch all that and redo from start after automatic dependencies
Panu Matilainen 5f4984
      have been discovered at the end of package build.
Panu Matilainen 5f4984
    - Fixes another regression (rpmspec dependency queries went dead)
Panu Matilainen 5f4984
      introduced in commit a357c99c58a5e1367160dfa692f26d14bd3a3df1
Panu Matilainen 5f4984
Panu Matilainen 5f4984
diff --git a/build/pack.c b/build/pack.c
Panu Matilainen 5f4984
index dc24fb5..4abca48 100644
Panu Matilainen 5f4984
--- a/build/pack.c
Panu Matilainen 5f4984
+++ b/build/pack.c
Panu Matilainen 5f4984
@@ -618,6 +618,11 @@ rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating)
Panu Matilainen 5f4984
 	headerPutUint32(pkg->header, RPMTAG_BUILDTIME, getBuildTime(), 1);
Panu Matilainen 5f4984
 
Panu Matilainen 5f4984
 	for (int i=0; i
Panu Matilainen 5f4984
+	    /* Nuke any previously added dependencies from the header */
Panu Matilainen 5f4984
+	    headerDel(pkg->header, rpmdsTagN(pkg->dependencies[i]));
Panu Matilainen 5f4984
+	    headerDel(pkg->header, rpmdsTagEVR(pkg->dependencies[i]));
Panu Matilainen 5f4984
+	    headerDel(pkg->header, rpmdsTagF(pkg->dependencies[i]));
Panu Matilainen 5f4984
+	    /* ...and add again, now with automatic dependencies included */
Panu Matilainen 5f4984
 	    rpmdsPutToHeader(pkg->dependencies[i], pkg->header);
Panu Matilainen 5f4984
 	}
Panu Matilainen 5f4984
 
Panu Matilainen 5f4984
diff --git a/build/parseSpec.c b/build/parseSpec.c
Panu Matilainen 5f4984
index b14c3ee..77cf409 100644
Panu Matilainen 5f4984
--- a/build/parseSpec.c
Panu Matilainen 5f4984
+++ b/build/parseSpec.c
Panu Matilainen 5f4984
@@ -548,6 +548,11 @@ static void addTargets(Package Pkgs)
Panu Matilainen 5f4984
 	headerPutString(pkg->header, RPMTAG_PLATFORM, platform);
Panu Matilainen 5f4984
 	headerPutString(pkg->header, RPMTAG_OPTFLAGS, optflags);
Panu Matilainen 5f4984
 
Panu Matilainen 5f4984
+	/* Add manual dependencies early for rpmspec etc to look at */
Panu Matilainen 5f4984
+	for (int i=0; i
Panu Matilainen 5f4984
+	    rpmdsPutToHeader(pkg->dependencies[i], pkg->header);
Panu Matilainen 5f4984
+	}
Panu Matilainen 5f4984
+
Panu Matilainen 5f4984
 	pkg->ds = rpmdsThis(pkg->header, RPMTAG_REQUIRENAME, RPMSENSE_EQUAL);
Panu Matilainen 5f4984
 	addPackageProvides(pkg);
Panu Matilainen 5f4984
     }