Use newPackage() to initialize source package too
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 15 Apr 2013 12:16:11 +0000 (15:16 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 7 Jun 2013 09:22:24 +0000 (12:22 +0300)
- As newPackage() initializes the pkg header too, we now need
  a different way of checking whether initSourceHeader() has
  already been called. Checking RPMTAG_NAME should suffice for the job...
(cherry picked from commit 0db12898c5d270fd4bbc7b4bad677dee4f34a617)

build/parsePreamble.c
build/parseSpec.c

index 99a2ef1..159330e 100644 (file)
@@ -996,6 +996,7 @@ int parsePreamble(rpmSpec spec, int initialPackage)
        headerPutString(pkg->header, RPMTAG_NAME, NVR);
     } else {
        NVR = xstrdup("(main package)");
+       spec->sourcePackage = newPackage(NULL);
     }
 
     if ((rc = readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS)) > 0) {
index 933a52b..1bd6b0d 100644 (file)
@@ -452,14 +452,12 @@ static const rpmTagVal sourceTags[] = {
 
 static void initSourceHeader(rpmSpec spec)
 {
-    Package sourcePkg;
+    Package sourcePkg = spec->sourcePackage;
     struct Source *srcPtr;
 
-    if (spec->sourcePackage)
+    if (headerIsEntry(sourcePkg->header, RPMTAG_NAME))
        return;
 
-    sourcePkg = spec->sourcePackage = xcalloc(1, sizeof(*sourcePkg));
-    sourcePkg->header = headerNew();
     /* Only specific tags are added to the source package header */
     headerCopyTags(spec->packages->header, sourcePkg->header, sourceTags);