Skip to contentSkip to conversation

misc graph-depends enhancements (branch yem/graph-depends)

PATCH Superseded Yann E. MORIN 2 participants 7 messages Mar 24, 2015 – Mar 31, 2015

lore
Share & tools
lore
#0 lore raw

v2 cover misc graph-depends enhancements (branch yem/graph-depends)

Hello All!

This series introduces a few enhancements to graph-depends, with two new options:
- --stop-on/-s PKG: to stop graphing on package PKG;
- --exclude/-x PKG: like --stop-on, but also omit PKG from the graph.

PKG can be one of an actual package name, a glob or the keyword 'virtual' (to stop on / exclude virtual packages). Stoping on, or excluding host packages can easily be done by using the glob 'host-*'

Note: I did not introduce the keyword 'host' because 'host' is an existing package, and even though we do not package it so far, it would have clashed, should we eventually have it.

Changes v1 -> v2:
- small eye-candy fixes (Samuel)

Regards,
Yann E. MORIN.

The following changes since commit 22014e038047dfa2a303fecce0a22d1c5811b6a5:

mongoose: bump to version 5.6 (2015-03-23 23:17:32 +0100)

are available in the git repository at:

git://git.busybox.net/~ymorin/git/buildroot yem/graph-depends

for you to fetch changes up to 8a743ff9947bda250791bb5032d62e288c30f7c5:

docs/manual: document new graph-depends options (2015-03-24 23:13:37 +0100)

----------------------------------------------------------------
Yann E. MORIN (4):
support/graph-depends: add option to stop on specific packages support/graph-depends: accepts globs to stop on package support/graph-depends: add option to completely exclude a package docs/manual: document new graph-depends options

 docs/manual/common-usage.txt  |  8 ++++++++
 support/scripts/graph-depends | 34 +++++++++++++++++++++++++++++++---
 2 files changed, 39 insertions(+), 3 deletions(-)
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH v2 1/4 support/graph-depends: add option to stop on specific packages

Add a new option to graph-depends, that users can set to stop the graph on a specific (set of) package(s).

This accepts any actual package name, or the 'virtual' keyword to stop on virtual packages.

---
Changes v1 -> v2:
- capitalise help (Samuel)

---
 support/scripts/graph-depends | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
support/scripts/graph-depends +13 -1
index 5b9b195..93844c7 100755
@@ -36,11 +36,14 @@ max_depth = 0
 # Whether to draw the transitive dependencies
 transitive = True
 
-parser = argparse.ArgumentParser(description="Graph pacakges dependencies")
+parser = argparse.ArgumentParser(description="Graph packages dependencies")
 parser.add_argument("--package", '-p', metavar="PACKAGE",
                     help="Graph the dependencies of PACKAGE")
 parser.add_argument("--depth", '-d', metavar="DEPTH", dest="depth", type=int, default=0,
                     help="Limit the dependency graph to DEPTH levels; 0 means no limit.")
+parser.add_argument("--stop-on", "-s", metavar="PACKAGE", dest="stop_list", action="append",
+                    help="Do not graph past this package (can be given multiple times)." \
+                       + " 'virtual' to stop on virtual packages.")
 parser.add_argument("--colours", "-c", metavar="COLOR_LIST", dest="colours",
                     default="lightblue,grey,gainsboro",
                     help="Comma-separated list of the three colours to use" \
@@ -61,6 +64,11 @@ else:
 
 max_depth = args.depth
 
+if args.stop_list is None:
+    stop_list = []
+else:
+    stop_list = args.stop_list
+
 transitive = args.transitive
 
 # Get the colours: we need exactly three colours,
@@ -304,6 +312,10 @@ def print_pkg_deps(depth, pkg):
     print_attrs(pkg)
     if pkg not in dict_deps:
         return
+    if pkg in stop_list:
+        return
+    if dict_version.get(pkg) == "virtual" and "virtual" in stop_list:
+        return
     if max_depth == 0 or depth < max_depth:
         for d in dict_deps[pkg]:
             print("%s -> %s" % (pkg_node_name(pkg), pkg_node_name(d)))
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/4 support/graph-depends: accepts globs to stop on package

In reply to Yann E. MORIN

---
Changes v1 -> v2:
- code format (Samuel)

---
 support/scripts/graph-depends | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
support/scripts/graph-depends +5 -2
index 93844c7..b0202e6 100755
@@ -24,6 +24,7 @@
 import sys
 import subprocess
 import argparse
+from fnmatch import fnmatch
 
 # Modes of operation:
 MODE_FULL = 1   # draw full dependency graph for all selected packages
@@ -43,6 +44,7 @@ parser.add_argument("--depth", '-d', metavar="DEPTH", dest="depth", type=int, de
                     help="Limit the dependency graph to DEPTH levels; 0 means no limit.")
 parser.add_argument("--stop-on", "-s", metavar="PACKAGE", dest="stop_list", action="append",
                     help="Do not graph past this package (can be given multiple times)." \
+                       + " Can be a package name or a glob, or" \
                        + " 'virtual' to stop on virtual packages.")
 parser.add_argument("--colours", "-c", metavar="COLOR_LIST", dest="colours",
                     default="lightblue,grey,gainsboro",
@@ -312,8 +314,9 @@ def print_pkg_deps(depth, pkg):
     print_attrs(pkg)
     if pkg not in dict_deps:
         return
-    if pkg in stop_list:
-        return
+    for p in stop_list:
+        if fnmatch(pkg, p):
+            return
     if dict_version.get(pkg) == "virtual" and "virtual" in stop_list:
         return
     if max_depth == 0 or depth < max_depth:
Signature · 1 line
1.9.1
#3 lore raw

PATCH v2 3/4 support/graph-depends: add option to completely exclude a package

In reply to Yann E. MORIN

Similar to --stop-on, but also omits the package from the graph.

---
 support/scripts/graph-depends | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
support/scripts/graph-depends +15 -2
index b0202e6..c1fc042 100755
@@ -46,6 +46,8 @@ parser.add_argument("--stop-on", "-s", metavar="PACKAGE", dest="stop_list", acti
                     help="Do not graph past this package (can be given multiple times)." \
                        + " Can be a package name or a glob, or" \
                        + " 'virtual' to stop on virtual packages.")
+parser.add_argument("--exclude", "-x", metavar="PACKAGE", dest="exclude_list", action="append",
+                    help="Like --stop-on, but do not add PACKAGE to the graph.")
 parser.add_argument("--colours", "-c", metavar="COLOR_LIST", dest="colours",
                     default="lightblue,grey,gainsboro",
                     help="Comma-separated list of the three colours to use" \
@@ -71,6 +73,11 @@ if args.stop_list is None:
 else:
     stop_list = args.stop_list
 
+if args.exclude_list is None:
+    exclude_list = []
+else:
+    exclude_list = args.exclude_list
+
 transitive = args.transitive
 
 # Get the colours: we need exactly three colours,
@@ -321,8 +328,14 @@ def print_pkg_deps(depth, pkg):
         return
     if max_depth == 0 or depth < max_depth:
         for d in dict_deps[pkg]:
-            print("%s -> %s" % (pkg_node_name(pkg), pkg_node_name(d)))
-            print_pkg_deps(depth+1, d)
+            add = True
+            for p in exclude_list:
+                if fnmatch(d,p):
+                    add = False
+                    break
+            if add:
+                print("%s -> %s" % (pkg_node_name(pkg), pkg_node_name(d)))
+                print_pkg_deps(depth+1, d)
 
 # Start printing the graph data
 print("digraph G {")
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 4/4 docs/manual: document new graph-depends options

In reply to Yann E. MORIN
---
 docs/manual/common-usage.txt | 8 ++++++++
 1 file changed, 8 insertions(+)
docs/manual/common-usage.txt +8 -0
index 89cd9fe..5b27b1f 100644
@@ -208,6 +208,14 @@ The +graph-depends+ behaviour can be controlled by setting options in the
 * +--depth N+, +-d N+, to limit the dependency depth to +N+ levels. The
   default, +0+, means no limit.
 
+* +--stop-on PKG+, +-s PKG+, to stop the graph on the package +PKG+.
+  +PKG+ can be an actual package name, a glob, or the keyword 'virtual'
+  (to stop on virtual packages). The package is still present on the
+  graph, but its dependencies are not.
+
+* +--exclude PKG+, +-x PKG+, like +--stop-on+, but also omits +PKG+ from
+  the graph.
+
 * +--transitive+, +--no-transitive+, to draw (or not) the transitive
   dependencies. The default is to not draw transitive dependencies.
 
Signature · 1 line
1.9.1
#5 lore raw

v2 cover misc graph-depends enhancements (branch yem/graph-depends)

In reply to Yann E. MORIN

Dear Yann E. MORIN,

Quoted 7 lines · Yann E. MORIN

Hello All!

This series introduces a few enhancements to graph-depends, with two new options:
- --stop-on/-s PKG: to stop graphing on package PKG;
- --exclude/-x PKG: like --stop-on, but also omit PKG from the graph.

Quoted 7 lines

PKG can be one of an actual package name, a glob or the keyword 'virtual' (to stop on / exclude virtual packages). Stoping on, or excluding host packages can easily be done by using the glob 'host-*'

Note: I did not introduce the keyword 'host' because 'host' is an existing package, and even though we do not package it so far, it would have clashed, should we eventually have it.

Series applied, thanks.

One thing that bothered me a bit is that --stop-on supports the keyword 'virtual', but not --exclude.

Thanks a lot!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#6 lore raw

v2 cover misc graph-depends enhancements (branch yem/graph-depends)

Thomas, All,

On 2015-04-01 00:02 +0200, Thomas Petazzoni spake thusly:

Quoted 5 lines · Yann E. MORIN
Quoted 4 lines

This series introduces a few enhancements to graph-depends, with two new options:
- --stop-on/-s PKG: to stop graphing on package PKG;
- --exclude/-x PKG: like --stop-on, but also omit PKG from the graph.

[--SNIP--]

Quoted 2 lines

One thing that bothered me a bit is that --stop-on supports the keyword 'virtual', but not --exclude.

Right, I'll fix that.

Thanks! :-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'