Compute parent and no. of children for each package.
authorjbj <devnull@localhost>
Sat, 5 Jan 2002 03:23:42 +0000 (03:23 +0000)
committerjbj <devnull@localhost>
Sat, 5 Jan 2002 03:23:42 +0000 (03:23 +0000)
Use rpmsort to display equivalence tree using graphwiz.

CVS patchset: 5232
CVS date: 2002/01/05 03:23:42

lib/depends.c
lib/rpmte.c
lib/rpmte.h
po/rpm.pot
tools/rpmsort.c

index 3a64714..2ee2ab2 100644 (file)
@@ -1269,6 +1269,8 @@ int rpmdepOrder(rpmTransactionSet ts)
 #else
     int oType = 0;
 #endif
+    int treex;
+    int depth;
     int qlen;
     int i, j;
 
@@ -1377,11 +1379,23 @@ fprintf(stderr, "*** rpmdepOrder(%p) order %p[%d]\n", ts, ts->order, ts->orderCo
     }
     pi = teFreeIterator(pi);
 
-    /* Save predecessor count. */
+    /* Save predecessor count and mark tree roots. */
+    treex = 0;
     pi = teInitIterator(ts);
     while ((p = teNext(pi, oType)) != NULL) {
+       int npreds;
 
-       (void) teSetNpreds(p, teGetTSI(p)->tsi_count);
+       npreds = teGetTSI(p)->tsi_count;
+
+       (void) teSetNpreds(p, npreds);
+
+       if (npreds == 0)
+           (void) teSetTree(p, treex++);
+       else
+           (void) teSetTree(p, -1);
+#ifdef UNNECESSARY
+       (void) teSetParent(p, NULL);
+#endif
 
 /*@-modfilesystem -nullpass @*/
 if (_tso_debug)
@@ -1392,7 +1406,7 @@ if (_tso_debug)
     pi = teFreeIterator(pi);
 
     /* T4. Scan for zeroes. */
-    rpmMessage(RPMMESS_DEBUG, _("========== tsorting packages (order, #predecessors, #succesors, depth)\n"));
+    rpmMessage(RPMMESS_DEBUG, _("========== tsorting packages (order, #predecessors, #succesors, tree, depth)\n"));
 
 rescan:
     if (pi != NULL) pi = teFreeIterator(pi);
@@ -1440,13 +1454,17 @@ prtTSI(" p", teGetTSI(p));
        }
        deptypechar = (teGetType(q) == TR_REMOVED ? '-' : '+');
 
-       rpmMessage(RPMMESS_DEBUG, "%5d%5d%5d%5d %*s%c%s\n",
+       rpmMessage(RPMMESS_DEBUG, "%5d%5d%5d%5d%5d %*s%c%s\n",
                        orderingCount, teGetNpreds(q),
-                       teGetTSI(q)->tsi_qcnt, teGetDepth(q),
+                       teGetTSI(q)->tsi_qcnt, teGetTree(q), teGetDepth(q),
                        (2 * teGetDepth(q)), "",
                        deptypechar,
                        (teGetNEVR(q) ? teGetNEVR(q) : "???"));
 
+       treex = teGetTree(q);
+       depth = teGetDepth(q);
+       (void) teSetDegree(q, 0);
+
        ordering[orderingCount] = teGetAddedKey(q);
        orderingCount++;
        qlen--;
@@ -1460,6 +1478,12 @@ prtTSI(" p", teGetTSI(p));
            tsi->tsi_next = NULL;
            p = tsi->tsi_suc;
            if (p && (--teGetTSI(p)->tsi_count) <= 0) {
+
+               (void) teSetTree(p, treex);
+               (void) teSetDepth(p, depth+1);
+               (void) teSetParent(p, q);
+               (void) teSetDegree(q, teGetDegree(q)+1);
+
                /* XXX TODO: add control bit. */
                teGetTSI(p)->tsi_suc = NULL;
                addQ(p, &teGetTSI(q)->tsi_suc, &r);
index b6eccf8..9ebfe7f 100644 (file)
@@ -244,6 +244,51 @@ int teSetNpreds(transactionElement te, int npreds)
     return opreds;
 }
 
+int teGetTree(transactionElement te)
+{
+    return (te != NULL ? te->tree : 0);
+}
+
+int teSetTree(transactionElement te, int ntree)
+{
+    int otree = 0;
+    if (te != NULL) {
+       otree = te->tree;
+       te->tree = ntree;
+    }
+    return otree;
+}
+
+transactionElement teGetParent(transactionElement te)
+{
+    return (te != NULL ? te->parent : NULL);
+}
+
+transactionElement teSetParent(transactionElement te, transactionElement pte)
+{
+    transactionElement opte = NULL;
+    if (te != NULL) {
+       opte = te->parent;
+       te->parent = pte;
+    }
+    return opte;
+}
+
+int teGetDegree(transactionElement te)
+{
+    return (te != NULL ? te->degree : 0);
+}
+
+int teSetDegree(transactionElement te, int ndegree)
+{
+    int odegree = 0;
+    if (te != NULL) {
+       odegree = te->degree;
+       te->degree = ndegree;
+    }
+    return odegree;
+}
+
 tsortInfo teGetTSI(transactionElement te)
 {
     /*@-compdef -retalias -retexpose -usereleased @*/
index 0c7d46f..ecd4500 100644 (file)
@@ -66,8 +66,11 @@ struct transactionElement_s {
 /*@only@*/ /*@null@*/
     const char * os;           /*!< Operating system hint. */
 
-    int npreds;                        /*!< No. of predecessors. */
+    transactionElement parent; /*!< Parent transaction element. */
+    int degree;                        /*!< No. of immediate children. */
     int depth;                 /*!< Max. depth in dependency tree. */
+    int npreds;                        /*!< No. of predecessors. */
+    int tree;                  /*!< Tree index. */
 /*@owned@*/
     tsortInfo tsi;             /*!< Dependency ordering chains. */
 
@@ -259,13 +262,64 @@ int teGetNpreds(transactionElement te)
 /**
  * Set tsort no. of predecessors of transaction element.
  * @param te           transaction element
- * @param ndepth       new no. of predecessors
+ * @param npreds       new no. of predecessors
  * @return             previous no. of predecessors
  */
 int teSetNpreds(transactionElement te, int npreds)
        /*@modifies te @*/;
 
 /**
+ * Retrieve tree index of transaction element.
+ * @param te           transaction element
+ * @return             tree index
+ */
+int teGetTree(transactionElement te)
+       /*@*/;
+
+/**
+ * Set tree index of transaction element.
+ * @param te           transaction element
+ * @param ntree                new tree index
+ * @return             previous tree index
+ */
+int teSetTree(transactionElement te, int ntree)
+       /*@modifies te @*/;
+
+/**
+ * Retrieve parent transaction element.
+ * @param te           transaction element
+ * @return             parent transaction element
+ */
+transactionElement teGetParent(transactionElement te)
+       /*@*/;
+
+/**
+ * Set parent transaction element.
+ * @param te           transaction element
+ * @param pte          new parent transaction element
+ * @return             previous parent transaction element
+ */
+transactionElement teSetParent(transactionElement te, transactionElement pte)
+       /*@modifies te @*/;
+
+/**
+ * Retrieve number of children of transaction element.
+ * @param te           transaction element
+ * @return             tree index
+ */
+int teGetDegree(transactionElement te)
+       /*@*/;
+
+/**
+ * Set number of children of transaction element.
+ * @param te           transaction element
+ * @param ntree                new number of children
+ * @return             previous number of children
+ */
+int teSetDegree(transactionElement te, int ntree)
+       /*@modifies te @*/;
+
+/**
  * Retrieve tsort info for transaction element.
  * @param te           transaction element
  * @return             tsort info
index 0c14d7b..52d3c91 100644 (file)
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2002-01-04 12:12-0500\n"
+"POT-Creation-Date: 2002-01-04 21:38-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -1463,30 +1463,31 @@ msgid "removing %s \"%s\" from tsort relations.\n"
 msgstr ""
 
 #. Record all relations.
-#: lib/depends.c:1301
+#: lib/depends.c:1303
 msgid "========== recording tsort relations\n"
 msgstr ""
 
 #. T4. Scan for zeroes.
-#: lib/depends.c:1395
+#: lib/depends.c:1409
 msgid ""
-"========== tsorting packages (order, #predecessors, #succesors, depth)\n"
+"========== tsorting packages (order, #predecessors, #succesors, tree, "
+"depth)\n"
 msgstr ""
 
-#: lib/depends.c:1478
+#: lib/depends.c:1502
 msgid "========== successors only (presentation order)\n"
 msgstr ""
 
-#: lib/depends.c:1548
+#: lib/depends.c:1572
 msgid "LOOP:\n"
 msgstr ""
 
-#: lib/depends.c:1583
+#: lib/depends.c:1607
 msgid "========== continuing tsort ...\n"
 msgstr ""
 
 #. Return no. of packages that could not be ordered.
-#: lib/depends.c:1588
+#: lib/depends.c:1612
 #, c-format
 msgid "rpmdepOrder failed, %d elements remain\n"
 msgstr ""
index a765b3e..62b6e43 100644 (file)
@@ -236,13 +236,23 @@ restart:
 
 fprintf(stdout, "digraph XXX {\n");
 
+fprintf(stdout, "  rankdir=LR\n");
+
 fprintf(stdout, "//===== Packages:\n");
        pi = teInitIterator(ts);
        while ((p = teNext(pi, oType)) != NULL) {
+fprintf(stdout, "//%5d%5d %s\n", teGetTree(p), teGetDepth(p), teGetN(p));
+           q = teGetParent(p);
+           if (q != NULL)
+fprintf(stdout, "  \"%s\" -> \"%s\"\n", teGetN(p), teGetN(q));
+           else {
 fprintf(stdout, "  \"%s\"\n", teGetN(p));
+fprintf(stdout, "  { rank=max ; \"%s\" }\n", teGetN(p));
+           }
        }
        pi = teFreeIterator(pi);
 
+#ifdef NOTNOW
 fprintf(stdout, "//===== Relations:\n");
        pi = teInitIterator(ts);
        while ((p = teNext(pi, oType)) != NULL) {
@@ -314,6 +324,27 @@ fprintf(stdout, "//===== Relations:\n");
                    continue;
                selected[i] = 1;
 
+               if (teGetTree(p) == teGetTree(q)) {
+                   int pdepth = teGetDepth(p);
+                   int qdepth = teGetDepth(q);
+
+#if 0
+                   if (pdepth == qdepth)
+                       continue;
+                   if (pdepth < qdepth) {
+                       if ((qdepth - pdepth) > 1)      continue;
+                       if (!strcmp(teGetN(q), "glibc"))        continue;
+                       if (!strcmp(teGetN(q), "bash")) continue;
+                   }
+#endif
+                   if (pdepth > qdepth) {
+                       if (!strcmp(teGetN(q), "glibc"))        continue;
+                       if (!strcmp(teGetN(q), "bash"))         continue;
+                       if (!strcmp(teGetN(q), "info"))         continue;
+                       if (!strcmp(teGetN(q), "mktemp"))       continue;
+                   }
+               }
+
 if (!printed) {
 fprintf(stdout, "// %s\n", teGetN(p));
 printed = 1;
@@ -325,6 +356,7 @@ fprintf(stdout, "\t\"%s\" -> \"%s\"\n", teGetN(p), teGetN(q));
 
        }
        pi = teFreeIterator(pi);
+#endif /* NOTNOW */
 
 fprintf(stdout, "}\n");