Deal with multiple scriptlet dependency bits in deptype format extension
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 1 Jun 2009 09:53:08 +0000 (12:53 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 1 Jun 2009 09:53:08 +0000 (12:53 +0300)
- rpmbuild permits Requires(post,postun) style notation which gets lumped
  into single dependency, report them all

lib/formats.c

index 50642c2..ff9818f 100644 (file)
@@ -228,31 +228,40 @@ static char * triggertypeFormat(rpmtd td, char * formatPrefix)
  */
 static char * deptypeFormat(rpmtd td, char * formatPrefix)
 {
-    char * val;
+    char *val = NULL;
     if (rpmtdClass(td) != RPM_NUMERIC_CLASS) {
        val = xstrdup(_("(not a number)"));
     } else {
+       ARGV_t sdeps = NULL;
        uint64_t item = rpmtdGetNumber(td);
 
        if (item & RPMSENSE_SCRIPT_PRE)
-           val = xstrdup("pre");
-       else if (item & RPMSENSE_SCRIPT_POST)
-           val = xstrdup("post");
-       else if (item & RPMSENSE_SCRIPT_PREUN)
-           val = xstrdup("preun");
-       else if (item & RPMSENSE_SCRIPT_POSTUN)
-           val = xstrdup("postun");
-       else if (item & RPMSENSE_SCRIPT_VERIFY)
-           val = xstrdup("verify");
-       else if (item & RPMSENSE_RPMLIB)
-           val = xstrdup("rpmlib");
-       else if (item & RPMSENSE_INTERP)
-           val = xstrdup("interp");
-       else if ((item & RPMSENSE_FIND_REQUIRES) || 
-                (item & RPMSENSE_FIND_PROVIDES))
-           val = xstrdup("auto");
-       else
-           val = xstrdup("manual");
+           argvAdd(&sdeps, "pre");
+       if (item & RPMSENSE_SCRIPT_POST)
+           argvAdd(&sdeps, "post");
+       if (item & RPMSENSE_SCRIPT_PREUN)
+           argvAdd(&sdeps, "preun");
+       if (item & RPMSENSE_SCRIPT_POSTUN)
+           argvAdd(&sdeps, "postun");
+       if (item & RPMSENSE_SCRIPT_VERIFY)
+           argvAdd(&sdeps, "verify");
+
+       if (sdeps) {
+           val = argvJoin(sdeps, ",");
+           argvFree(sdeps);
+       } else {
+           if (item & RPMSENSE_RPMLIB)
+               val = xstrdup("rpmlib");
+           else if (item & RPMSENSE_INTERP)
+               val = xstrdup("interp");
+           else if ((item & RPMSENSE_FIND_REQUIRES) || 
+                    (item & RPMSENSE_FIND_PROVIDES))
+               val = xstrdup("auto");
+           else if (item & RPMSENSE_PREREQ)
+               val = xstrdup("prereq");
+           else
+               val = xstrdup("manual");
+       }
     }
     return val;
 }