Pass the entire package struct to addReqProv()
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 15 Apr 2013 12:23:37 +0000 (15:23 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 7 Jun 2013 09:22:24 +0000 (12:22 +0300)
- Still doesn't make much difference as it is, but further pre-requisites
  for sanitizing the way dependencies are carried around.
- Change rpmSpecDS() to return the ds based on the actual source package
  header, not buildRestrictions. Using buildRestrictions was probably
  kinda wrong to begin with but its more so now as the actual
  requires and conflicts go to the "real" header, not buildRestrictions.
(cherry picked from commit 42b2f78e724e02d677974314d460cc6dec5cbc5b)

build/parseReqs.c
build/parseScript.c
build/reqprov.c
build/rpmbuild_internal.h
build/spec.c

index 5ad0501..89135bf 100644 (file)
@@ -43,7 +43,6 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
     char * N = NULL, * EVR = NULL;
     rpmTagVal nametag = RPMTAG_NOT_FOUND;
     rpmsenseFlags Flags;
-    Header h = pkg->header; /* everything except buildrequires go here */
     rpmRC rc = RPMRC_FAIL; /* assume failure */
 
     switch (tagN) {
@@ -89,11 +88,11 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
     case RPMTAG_BUILDREQUIRES:
        nametag = RPMTAG_REQUIRENAME;
        tagflags |= RPMSENSE_ANY;
-       h = spec->buildRestrictions;
+       pkg = spec->sourcePackage;
        break;
     case RPMTAG_BUILDCONFLICTS:
        nametag = RPMTAG_CONFLICTNAME;
-       h = spec->buildRestrictions;
+       pkg = spec->sourcePackage;
        break;
     }
 
@@ -161,7 +160,7 @@ rpmRC parseRCPOT(rpmSpec spec, Package pkg, const char *field, rpmTagVal tagN,
        } else
            EVR = NULL;
 
-       if (addReqProv(h, nametag, N, EVR, Flags, index)) {
+       if (addReqProv(pkg, nametag, N, EVR, Flags, index)) {
            emsg = _("invalid dependency");
            goto exit;
        }
index 2800f7b..3937d7d 100644 (file)
@@ -301,7 +301,7 @@ int parseScript(rpmSpec spec, int parsePart)
                 spec->lineNum, progArgv[0]);
        goto exit;
     } else {
-        (void) addReqProv(pkg->header, RPMTAG_REQUIRENAME,
+        (void) addReqProv(pkg, RPMTAG_REQUIRENAME,
                progArgv[0], NULL, (tagflags | RPMSENSE_INTERP), 0);
     }
 
index 4e39bab..68f567c 100644 (file)
@@ -42,7 +42,7 @@ static int isNewDep(Header h, rpmTagVal nametag,
     return isnew;
 }
 
-int addReqProv(Header h, rpmTagVal tagN,
+int addReqProv(Package pkg, rpmTagVal tagN,
                const char * N, const char * EVR, rpmsenseFlags Flags,
                uint32_t index)
 {
@@ -50,6 +50,7 @@ int addReqProv(Header h, rpmTagVal tagN,
     rpmTagVal flagtag = 0;
     rpmTagVal indextag = 0;
     rpmsenseFlags extra = RPMSENSE_ANY;
+    Header h = pkg->header; /* just a shortcut */
 
     switch (tagN) {
     case RPMTAG_PROVIDENAME:
@@ -114,7 +115,7 @@ int rpmlibNeedsFeature(Package pkg, const char * feature, const char * featureEV
 
     rasprintf(&reqname, "rpmlib(%s)", feature);
 
-    res = addReqProv(pkg->header, RPMTAG_REQUIRENAME, reqname, featureEVR,
+    res = addReqProv(pkg, RPMTAG_REQUIRENAME, reqname, featureEVR,
                     RPMSENSE_RPMLIB|(RPMSENSE_LESS|RPMSENSE_EQUAL), 0);
 
     free(reqname);
index 67a40e0..54301d7 100644 (file)
@@ -394,8 +394,8 @@ RPM_GNUC_INTERNAL
 rpmRC packageSources(rpmSpec spec, char **cookie);
 
 /** \ingroup rpmbuild
- * Add dependency to header, filtering duplicates.
- * @param h            header
+ * Add dependency to package, filtering duplicates.
+ * @param pkg          package
  * @param tagN         tag, identifies type of dependency
  * @param N            (e.g. Requires: foo < 0:1.2-3, "foo")
  * @param EVR          (e.g. Requires: foo < 0:1.2-3, "0:1.2-3")
@@ -404,7 +404,7 @@ rpmRC packageSources(rpmSpec spec, char **cookie);
  * @return             0 on success, 1 on error
  */
 RPM_GNUC_INTERNAL
-int addReqProv(Header h, rpmTagVal tagN,
+int addReqProv(Package pkg, rpmTagVal tagN,
                const char * N, const char * EVR, rpmsenseFlags Flags,
                uint32_t index);
 
index a4b1f7b..e8c7704 100644 (file)
@@ -279,7 +279,7 @@ Header rpmSpecSourceHeader(rpmSpec spec)
 
 rpmds rpmSpecDS(rpmSpec spec, rpmTagVal tag)
 {
-    return (spec != NULL) ? rpmdsNew(spec->buildRestrictions, tag, 0) : NULL;
+    return (spec != NULL) ? rpmdsNew(spec->sourcePackage->header, tag, 0) : NULL;
 }
 
 rpmps rpmSpecCheckDeps(rpmts ts, rpmSpec spec)