Correctly expand %{obsoletes}, %{requires}, etc. in spec (RhBug:555926)
authorJindrich Novy <jnovy@redhat.com>
Sat, 16 Jan 2010 11:43:16 +0000 (12:43 +0100)
committerJindrich Novy <jnovy@redhat.com>
Sat, 16 Jan 2010 11:43:16 +0000 (12:43 +0100)
- tags declared multiple times in spec were simply overwritten so
  referencing it via %{} just showed contents of the last one

build/parsePreamble.c

index e31af74..269736e 100644 (file)
@@ -688,8 +688,23 @@ static int handlePreambleTag(rpmSpec spec, Package pkg, rpmTag tag,
        return RPMRC_FAIL;
     }
 
-    if (macro)
-       addMacro(spec->macros, macro, NULL, field, RMIL_SPEC);
+    if (macro) {
+       char *macro_expanded = NULL,
+            *macro_token = NULL,
+            *field_set = NULL;
+       
+       rasprintf(&macro_token, "%%%s", macro);
+       macro_expanded = rpmExpand(macro_token);
+       if (!strcmp(macro_expanded, macro_token)) {
+               field_set = xstrdup(field);
+       } else {
+               rasprintf(&field_set, "%s %s", macro_expanded, field);
+       }
+       addMacro(spec->macros, macro, NULL, field_set, RMIL_SPEC);
+       free(macro_expanded);
+       free(macro_token);
+       free(field_set);
+    }
     
     return RPMRC_OK;
 }