poldek: poldek/pkgmisc.h, poldek/poldek_ts.c, poldek/poldek.h, pol...

mis mis at pld-linux.org
Wed Jul 11 00:56:23 CEST 2007


Author: mis                          Date: Tue Jul 10 22:56:23 2007 GMT
Module: poldek                        Tag: HEAD
---- Log message:
- depgraph

---- Files affected:
poldek/poldek:
   pkgmisc.h (1.17 -> 1.18) , poldek_ts.c (1.67 -> 1.68) , poldek.h (1.37 -> 1.38) , poldek_ts.h (1.40 -> 1.41) , pkgset.c (1.98 -> 1.99) 
poldek/poldek/cli:
   op_verify.c (1.17 -> 1.18) 

---- Diffs:

================================================================
Index: poldek/poldek/pkgmisc.h
diff -u poldek/poldek/pkgmisc.h:1.17 poldek/poldek/pkgmisc.h:1.18
--- poldek/poldek/pkgmisc.h:1.17	Sun Jul  8 18:59:15 2007
+++ poldek/poldek/pkgmisc.h	Wed Jul 11 00:56:17 2007
@@ -120,7 +120,7 @@
 
 struct pkgset;
 int packages_verify_dependecies(tn_array *pkgs, struct pkgset *ps);
-int packages_dot_dependency_graph(tn_array *pkgs, struct pkgset *ps,
-                                  const char *dotfile);
+int packages_generate_depgraph(tn_array *pkgs, struct pkgset *ps,
+                               const char *graphspec);
 #endif
 

================================================================
Index: poldek/poldek/poldek_ts.c
diff -u poldek/poldek/poldek_ts.c:1.67 poldek/poldek/poldek_ts.c:1.68
--- poldek/poldek/poldek_ts.c:1.67	Mon Jul  2 18:33:21 2007
+++ poldek/poldek/poldek_ts.c	Wed Jul 11 00:56:17 2007
@@ -262,7 +262,7 @@
         cp_str(&ts->cachedir, ctx->ts->cachedir);
         cp_str(&ts->dumpfile, ctx->ts->dumpfile);
         cp_str(&ts->prifile, ctx->ts->prifile);
-        cp_str(&ts->depgraphfile, ctx->ts->depgraphfile);
+        cp_str(&ts->depgraph, ctx->ts->depgraph);
         
         ts->rpmacros = n_array_dup(ctx->ts->rpmacros, (tn_fn_dup)strdup);
         ts->rpmopts = n_array_dup(ctx->ts->rpmopts, (tn_fn_dup)strdup);
@@ -489,14 +489,11 @@
             }
             break;
 
-        case POLDEK_CONF_DEPGRAPHFILE:
-            if ((vs = va_arg(ap, char*))) {
-                DBGF("dotfile %s\n", vs);
-                ts->depgraphfile = poldek__conf_path(ts->depgraphfile, vs);
-            }
+        case POLDEK_CONF_DEPGRAPH:
+            if ((vs = va_arg(ap, char*)))
+                ts->depgraph = n_strdup(vs);
             break;
 
-
         case POLDEK_CONF_RPMMACROS:
             if ((vs = va_arg(ap, char*)))
                 n_array_push(ts->rpmacros, n_strdup(vs));
@@ -773,8 +770,8 @@
         ts->rootdir = n_strdup("/");
     
     if (ts->getop(ts, POLDEK_OP_RPMTEST)) {
-        if (poldek_VERBOSE < 1)
-            poldek_VERBOSE++;
+        //if (poldek_VERBOSE < 1)
+        //    poldek_set_verbose(poldek_VERBOSE + 1);
         
     } else if (ts->getop_v(ts, POLDEK_OP_JUSTFETCH, POLDEK_OP_JUSTPRINT, 0)) {
         if (!poldek_util_is_rwxdir(ts->rootdir)) {
@@ -806,8 +803,8 @@
 
 /* install summary saved to ts to propagate it to high level api  */
 void poldek__ts_update_summary(struct poldek_ts *ts,
-                               const char *prefix, tn_array *pkgs,
-                               unsigned pmsflags, struct pkgmark_set *pms)
+                               const char *prefix, const tn_array *pkgs,
+                               unsigned pmsflags, const struct pkgmark_set *pms)
 {
     tn_array *supkgs;
     int i;
@@ -946,7 +943,8 @@
     return rc;
 }
 
-extern int in_do_ts_install(struct poldek_ts *ts);
+extern int in_do_poldek_ts_instal(struct poldek_ts *ts);
+//extern int i3_do_poldek_ts_install(struct poldek_ts *ts);
 
 static int ts_run_install(struct poldek_ts *ts) 
 {
@@ -976,8 +974,8 @@
     DBGF("0 arg_packages_size=%d\n", arg_packages_size(ts->aps));
 
     if (ts->ctx->_depengine == 3) { /* hope, soon */
-        msgn(5, "Running poldek3 dependency engine...");
-        n_die("Not implemented yet");
+        msgn(5, "Running #3 dependency engine...");
+        //rc = i3_do_poldek_ts_install(ts);
 
     } else {
         rc = in_do_poldek_ts_install(ts);
@@ -1056,8 +1054,8 @@
     }
 
     if (ts->getop(ts, POLDEK_OP_DEPGRAPH)) {
-        msgn(0, _("Dotting dependency graph..."));
-        if (!packages_dot_dependency_graph(pkgs, ts->ctx->ps, ts->depgraphfile))
+        msgn(0, _("Generating dependency graph %s..."), ts->depgraph);
+        if (!packages_generate_depgraph(pkgs, ts->ctx->ps, ts->depgraph))
             nerr++;
     }
 

================================================================
Index: poldek/poldek/poldek.h
diff -u poldek/poldek/poldek.h:1.37 poldek/poldek/poldek.h:1.38
--- poldek/poldek/poldek.h:1.37	Fri Jul  6 00:28:53 2007
+++ poldek/poldek/poldek.h	Wed Jul 11 00:56:17 2007
@@ -46,7 +46,7 @@
 #define POLDEK_CONF_IGNORE          12
 #define POLDEK_CONF_PM              13
 #define POLDEK_CONF_DESTINATION     14
-#define POLDEK_CONF_DEPGRAPHFILE    15
+#define POLDEK_CONF_DEPGRAPH        15
 #define POLDEK_CONF_LOGFILE         20
 #define POLDEK_CONF_LOGTTY          21
 

================================================================
Index: poldek/poldek/poldek_ts.h
diff -u poldek/poldek/poldek_ts.h:1.40 poldek/poldek/poldek_ts.h:1.41
--- poldek/poldek/poldek_ts.h:1.40	Sun Jul  1 23:04:26 2007
+++ poldek/poldek/poldek_ts.h	Wed Jul 11 00:56:17 2007
@@ -116,7 +116,7 @@
     char               *cachedir;      /* cache directory        */
     char               *dumpfile;      /* file to dump fqpns     */
     char               *prifile;       /* file with package priorities (split*) */
-    char               *depgraphfile;  /* dot file path for graphviz depgraph */
+    char               *depgraph    ;  /* graph type[:path] graphviz and others graphs */
     tn_array           *rpmopts;       /* rpm cmdline opts (char *opts[]) */
     tn_array           *rpmacros;      /* rpm macros to pass to cmdline (char *opts[]) */
     tn_array           *hold_patterns;

================================================================
Index: poldek/poldek/pkgset.c
diff -u poldek/poldek/pkgset.c:1.98 poldek/poldek/pkgset.c:1.99
--- poldek/poldek/pkgset.c:1.98	Mon Jul  9 19:06:25 2007
+++ poldek/poldek/pkgset.c	Wed Jul 11 00:56:17 2007
@@ -655,8 +655,8 @@
     return nerr == 0;
 }
 
-int packages_dot_dependency_graph(tn_array *pkgs, struct pkgset *ps,
-                                  const char *dotfile)
+/* GraphViz */
+static int dot_graph(tn_array *pkgs, struct pkgset *ps, const char *outfile)
 {
     int i, j, n_unmet = 0;
     tn_buf *nbuf;
@@ -701,12 +701,15 @@
         
         
     }
-
-    if ((stream = fopen(dotfile, "w")) == NULL) {
-        logn(LOGERR, _("%s: open failed: %m"), dotfile);
-        n_buf_free(nbuf);
-        return 0;
-    }
+    
+    stream = stdout;
+    
+    if (outfile != NULL)
+        if ((stream = fopen(outfile, "w")) == NULL) {
+            logn(LOGERR, _("%s: open failed: %m"), outfile);
+            n_buf_free(nbuf);
+            return 0;
+        }
 
     fprintf(stream, "digraph repo {\n"
             "rankdir=LR;\n"
@@ -723,10 +726,102 @@
 
     fprintf(stream, "%s", (char*)n_buf_ptr(nbuf));
     fprintf(stream, "\n}\n");
-    fclose(stream);
+    if (stream != stdout)
+        fclose(stream);
     n_buf_free(nbuf);
-    msgn(0, "Graph saved as %s\n", dotfile);
+
+    if (outfile)
+        msgn(0, "Graph saved as %s", outfile);
+    
     return 1;
 }
 
 
+/* See http://xavier.informatics.indiana.edu/lanet-vi/ */
+static int lanvi_graph(tn_array *pkgs, struct pkgset *ps, const char *outfile)
+{
+    int i, j;
+    tn_buf *nbuf;
+    FILE *stream;
+
+    ps = ps;                    /* unused */
+    nbuf = n_buf_new(1024 * 8);
+
+    for (i=0; i < n_array_size(pkgs); i++) {
+        struct pkg *pkg = n_array_nth(pkgs, i);
+        pkg->recno = i + 1;
+    }
+    
+    for (i=0; i < n_array_size(pkgs); i++) {
+        struct pkg *pkg = n_array_nth(pkgs, i);
+        
+        if (pkg->reqpkgs == NULL || n_array_size(pkg->reqpkgs) == 0)
+            continue;
+
+        for (j=0; j < n_array_size(pkg->reqpkgs); j++) {
+            struct reqpkg *rp = n_array_nth(pkg->reqpkgs, j);
+
+            n_buf_printf(nbuf, "%d %d\n", pkg->recno, rp->pkg->recno);
+            
+            if (rp->flags & REQPKG_MULTI) {
+                int n = 0;
+                while (rp->adds[n]) {
+                    n_buf_printf(nbuf, "%d %d\n", pkg->recno, rp->adds[n]->pkg->recno);
+                    n++;
+                }
+            }
+        }
+    }
+    
+    stream = stdout;
+    if (outfile != NULL)
+        if ((stream = fopen(outfile, "w")) == NULL) {
+            logn(LOGERR, _("%s: open failed: %m"), outfile);
+            n_buf_free(nbuf);
+            return 0;
+        }
+    
+    
+    fprintf(stream, "%s", (char*)n_buf_ptr(nbuf));
+    if (stream != stdout)
+        fclose(stream);
+    n_buf_free(nbuf);
+
+    if (outfile)
+        msgn(0, "LanVi graph saved as %s", outfile);
+    
+    return 1;
+}
+
+
+int packages_generate_depgraph(tn_array *pkgs, struct pkgset *ps,
+                               const char *graphspec)
+{
+
+    const char **tl = NULL, *type, *path = NULL;
+
+    if (strchr(graphspec, ':') == NULL)
+        type = graphspec;
+    else {
+        tl = n_str_tokl(graphspec, ":");
+        type = *tl;
+        path = *(tl + 1);
+    }
+    DBGF_F("g %s\n", path);
+    
+    if (n_str_eq(type, "lanvi"))
+        lanvi_graph(pkgs, ps, path);
+    
+    else if (n_str_eq(type, "dot"))
+        dot_graph(pkgs, ps, path);
+
+    else
+        logn(LOGERR, "%s: unknown graph type", type);
+
+    if (tl)
+        n_str_tokl_free(tl);
+    
+    return 1;
+}
+
+            

================================================================
Index: poldek/poldek/cli/op_verify.c
diff -u poldek/poldek/cli/op_verify.c:1.17 poldek/poldek/cli/op_verify.c:1.18
--- poldek/poldek/cli/op_verify.c:1.17	Fri Jun 29 00:28:21 2007
+++ poldek/poldek/cli/op_verify.c	Wed Jul 11 00:56:18 2007
@@ -61,7 +61,8 @@
 {"verify-all",  OPT_ALL, 0, OPTION_HIDDEN,
 N_("Verify dependencies, conflicts, file conflicts and orphaned directories"),
         OPT_GID },
-{"dependency-graph", OPT_DEPGRAPH, "FILE", 0, N_("Print dot dependency graph into FILE"), OPT_GID },
+{"depgraph", OPT_DEPGRAPH, "TYPE[:FILE]", 0,
+        N_("Generate dependency graph, types are dot,lanvi"), OPT_GID },
 { 0, 0, 0, 0, 0, 0 },
 };
 
@@ -215,7 +216,7 @@
             arg_s->verify = 1;
             ts->setop(ts, POLDEK_OP_DEPGRAPH, 1);
             rt->set_major_mode(rt, mode, "depgraph");
-            poldek_ts_configure(ts, POLDEK_CONF_DEPGRAPHFILE, arg);
+            poldek_ts_configure(ts, POLDEK_CONF_DEPGRAPH, arg);
             break;
 
         default:
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/poldek/poldek/pkgmisc.h?r1=1.17&r2=1.18&f=u
    http://cvs.pld-linux.org/poldek/poldek/poldek_ts.c?r1=1.67&r2=1.68&f=u
    http://cvs.pld-linux.org/poldek/poldek/poldek.h?r1=1.37&r2=1.38&f=u
    http://cvs.pld-linux.org/poldek/poldek/poldek_ts.h?r1=1.40&r2=1.41&f=u
    http://cvs.pld-linux.org/poldek/poldek/pkgset.c?r1=1.98&r2=1.99&f=u
    http://cvs.pld-linux.org/poldek/poldek/cli/op_verify.c?r1=1.17&r2=1.18&f=u



More information about the pld-cvs-commit mailing list