Add support for fileattr dependency namespacing
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 23 May 2011 10:40:39 +0000 (13:40 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 23 May 2011 11:19:27 +0000 (14:19 +0300)
- This allows automatically wrapping generated dependencies into
  macro-expanded namespaces, eg foo(depname) by specifying
  __attr_namespace in the file attribute definition.
- Current generator scripts hardcode their namespaces but doing this
  on rpm-level gives extra flexibility eg when building for alternative
  versions/environments and frees generators from having to take care of
  the formatting.

build/rpmfc.c

index 7107c89..f71110f 100644 (file)
@@ -472,6 +472,7 @@ static int rpmfcHelper(rpmfc fc, const char *nsdep, const char *depname,
 {
     ARGV_t pav = NULL;
     const char * fn = fc->fn[fc->ix];
+    char *namespace = rpmfcAttrMacro(nsdep, NULL, "namespace");
     int pac;
     regex_t *exclude = NULL;
     regex_t *exclude_from = NULL;
@@ -513,7 +514,13 @@ static int rpmfcHelper(rpmfc fc, const char *nsdep, const char *depname,
            EVR = pav[i];
        }
 
-       ds = rpmdsSingle(tagN, N, EVR, Flags);
+       if (namespace) {
+           char *NSN = rpmExpand(namespace, "(", N, ")", NULL);
+           ds = rpmdsSingle(tagN, NSN, EVR, Flags);
+           free(NSN);
+       } else {
+           ds = rpmdsSingle(tagN, N, EVR, Flags);
+       }
 
        /* Add to package and file dependencies unless filtered */
        if (regMatch(exclude, rpmdsDNEVR(ds)+2) == 0) {
@@ -529,6 +536,7 @@ static int rpmfcHelper(rpmfc fc, const char *nsdep, const char *depname,
 exit:
     regFree(exclude);
     regFree(exclude_from);
+    free(namespace);
     return 0;
 }