Skip to contentSkip to conversation

graph-depends: display virtual package with italic style

PATCH New Francois Perrad 5 participants 10 messages Jan 3, 2015 – Mar 14, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 graph-depends: display virtual package with italic style

virtual packages are found by their version,
so we retrieve the version of all packages

---
 package/pkg-generic.mk        |  3 +++
 support/scripts/graph-depends | 30 +++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)
package/pkg-generic.mk +3 -0
index 9643a30..87d8dd8 100644
@@ -565,6 +565,9 @@ $(1)-rsync:		$$($(2)_TARGET_RSYNC)
 $(1)-source:		$$($(2)_TARGET_RSYNC_SOURCE)
 endif
 
+$(1)-show-version:
+			@echo $$($(2)_VERSION)
+
 $(1)-show-depends:
 			@echo $$($(2)_FINAL_DEPENDENCIES)
 
support/scripts/graph-depends +29 -1
index 1ecfeda..28fe2f0 100755
@@ -76,6 +76,28 @@ host_colour = colours[2]
 
 allpkgs = []
 
+# Execute the "make <pkg>-show-version" command to get the version of a given
+# list of packages, and return the version formatted as a Python dictionary.
+def get_version(pkgs):
+    sys.stderr.write("Getting version for %s\n" % pkgs)
+    cmd = ["make", "-s", "--no-print-directory" ]
+    for pkg in pkgs:
+        cmd.append("%s-show-version" % pkg)
+    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
+    output = p.communicate()[0]
+    if p.returncode != 0:
+        sys.stderr.write("Error getting version %s\n" % pkgs)
+        sys.exit(1)
+    output = output.split("\n")
+    if len(output) != len(pkgs) + 1:
+        sys.stderr.write("Error getting version\n")
+        sys.exit(1)
+    version = {}
+    for i in range(0, len(pkgs)):
+        pkg = pkgs[i]
+        version[pkg] = output[i]
+    return version
+
 # Execute the "make show-targets" command to get the list of the main
 # Buildroot TARGETS and return it formatted as a Python list. This
 # list is used as the starting point for full dependency graphs
@@ -257,6 +279,8 @@ def remove_extra_deps(deps):
     return deps
 
 dict_deps = remove_extra_deps(dict_deps)
+dict_version = get_version([pkg for pkg in allpkgs
+                                if pkg != "all" and not pkg.startswith("root")])
 
 # Print the attributes of a node: label and fill-color
 def print_attrs(pkg):
@@ -274,7 +298,11 @@ def print_attrs(pkg):
             color = host_colour
         else:
             color = target_colour
-    print("%s [label = \"%s\"]" % (name, label))
+    version = dict_version.get(pkg)
+    if version == "virtual":
+        print("%s [label = <<I>%s</I>>]" % (name, label))
+    else:
+        print("%s [label = \"%s\"]" % (name, label))
     print("%s [color=%s,style=filled]" % (name, color))
 
 # Print the dependency graph of a package
Signature · 1 line
2.1.0
#1 lore raw

PATCH v2 2/2 graph-depends: add an option --stop-on-virtual

---
 docs/manual/common-usage.txt  |  3 +++
 support/scripts/graph-depends | 11 +++++++++++
 2 files changed, 14 insertions(+)
docs/manual/common-usage.txt +3 -0
index 89cd9fe..966c694 100644
@@ -215,6 +215,9 @@ The +graph-depends+ behaviour can be controlled by setting options in the
   root package (+R+), the target packages (+T+) and the host packages
   (+H+). Defaults to: +lightblue,grey,gainsboro+
 
+* +--stop-on-virtual+, +--dont-stop-on-virtual+, to follow (or not)
+  the dependencies of virtual package
+
 --------------------------------
 BR2_GRAPH_DEPS_OPTS='-d 3 --no-transitive --colours=red,green,blue' make graph-depends
 --------------------------------
support/scripts/graph-depends +11 -0
index 28fe2f0..4e12351 100755
@@ -36,6 +36,9 @@ max_depth = 0
 # Whether to draw the transitive dependencies
 transitive = True
 
+# Stop dependency on virtual package
+stop_on_virtual = False
+
 parser = argparse.ArgumentParser(description="Graph pacakges dependencies")
 parser.add_argument("--package", '-p', metavar="PACKAGE",
                     help="Graph the dependencies of PACKAGE")
@@ -51,6 +54,10 @@ parser.add_argument("--transitive", dest="transitive", action='store_true',
                     default=False)
 parser.add_argument("--no-transitive", dest="transitive", action='store_false',
                     help="Draw (do not draw) transitive dependencies")
+parser.add_argument("--stop-on-virtual", dest="stop_on_virtual", action='store_true',
+                    default=False)
+parser.add_argument("--dont-stop-on-virtual", dest="stop_on_virtual", action='store_false',
+                    help="Stop (or do not stop) on virtual package")
 args = parser.parse_args()
 
 if args.package is None:
@@ -63,6 +70,8 @@ max_depth = args.depth
 
 transitive = args.transitive
 
+stop_on_virtual = args.stop_on_virtual
+
 # Get the colours: we need exactly three colours,
 # so no need not split more than 4
 # We'll let 'dot' validate the colours...
@@ -313,6 +322,8 @@ def print_pkg_deps(depth, pkg):
     print_attrs(pkg)
     if pkg not in dict_deps:
         return
+    if stop_on_virtual and dict_version.get(pkg) == "virtual":
+        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
2.1.0
#2 lore raw

PATCH v2 2/2 graph-depends: add an option --stop-on-virtual

Dear Francois Perrad,

Quoted 5 lines · Francois Perrad
---
 docs/manual/common-usage.txt  |  3 +++
 support/scripts/graph-depends | 11 +++++++++++
 2 files changed, 14 insertions(+)

I'm still not convinced by this one. Shouldn't we instead have a more generic mechanism such as --exclude=<foo>,<bar>, which would allow to exclude packages? And maybe one of the possible values would be a magical value to exclude virtual packages?

There are some cases where ignoring host-pkgconf, or host-automake/host-autoconf/host-libtool may be interesting, for example.

Best regards,

Thomas

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

PATCH v2 2/2 graph-depends: add an option --stop-on-virtual

2015-03-08 22:18 GMT+01:00 Thomas Petazzoni
<[email protected]>:

Quoted 9 lines

Dear Francois Perrad,

Quoted 5 lines · Francois Perrad
---
 docs/manual/common-usage.txt  |  3 +++
 support/scripts/graph-depends | 11 +++++++++++
 2 files changed, 14 insertions(+)
Quoted 9 lines

I'm still not convinced by this one. Shouldn't we instead have a more generic mechanism such as --exclude=<foo>,<bar>, which would allow to exclude packages? And maybe one of the possible values would be a magical value to exclude virtual packages?

There are some cases where ignoring host-pkgconf, or host-automake/host-autoconf/host-libtool may be interesting, for example.

I agree with you.
The graphs become quickly too large.
The current option --depth seems to be only a workaround against an infinite recursion when the graph has a cycle.
But at this time, we haven't found the good way (or the good use cases) to limit the size of the graph.

Fran?ois

Quoted 11 lines

Best regards,

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#4 lore raw

PATCH v2 2/2 graph-depends: add an option --stop-on-virtual

Dear Fran?ois Perrad,

Quoted 4 lines · Fran?ois Perrad

I agree with you.
The graphs become quickly too large.
The current option --depth seems to be only a workaround against an infinite recursion when the graph has a cycle.

Well, I don't really think --depth is meant to avoid infinite
recursion: I don't think it's possible to have infinite recursion since we can't have cyclic dependencies in Buildroot.

Quoted 2 lines

But at this time, we haven't found the good way (or the good use cases) to limit the size of the graph.

I believe being able to exclude certain packages (and their dependency tree) would be useful.

Best regards,

Thomas

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

PATCH v2 2/2 graph-depends: add an option --stop-on-virtual

Thomas, Fran?ois, All,

On 2015-03-09 21:15 +0100, Thomas Petazzoni spake thusly:

Quoted 7 lines · Fran?ois Perrad
Quoted 2 lines

The current option --depth seems to be only a workaround against an infinite recursion when the graph has a cycle.

Well, I don't really think --depth is meant to avoid infinite
recursion: I don't think it's possible to have infinite recursion since we can't have cyclic dependencies in Buildroot.

No, -depth was never meant to be a stop-gap for recursion: we can *not* have recursive depedencies.

What I introduced --depth for, is because often only the first few level of dependencies of a given package are of interest. --depth is essentially meant for use when graphing the dependencies of a single package, like so:

BR2_GRAPH_DEPS_OPTS='--depth 2' make foo-graph-depends

that would limit graphinh the dependencies of 'foo' down to two levels.

Quoted 5 lines
Quoted 2 lines

But at this time, we haven't found the good way (or the good use cases) to limit the size of the graph.

I believe being able to exclude certain packages (and their dependency tree) would be useful.

What about something like:

BR2_GRAPH_DEPS_OPTS='--stop-on PKGS' make graph-depends

where 'PKGS' would be a comma-separated list of packages, possibly a glob or regexp, or even the keyword 'virtual' to stop on virtual packages?

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.  |
'------------------------------^-------^------------------^--------------------'
#6 lore raw

PATCH v2 2/2 graph-depends: add an option --stop-on-virtual

Dear Yann E. MORIN,

Quoted 7 lines · Yann E. MORIN

What about something like:

BR2_GRAPH_DEPS_OPTS='--stop-on PKGS' make graph-depends

where 'PKGS' would be a comma-separated list of packages, possibly a glob or regexp, or even the keyword 'virtual' to stop on virtual packages?

Sounds like a good idea to me.

Thomas

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

PATCH v2 1/2 graph-depends: display virtual package with italic style

In reply to Francois Perrad

Fran?ois, All,

On 2015-01-03 15:29 +0100, Francois Perrad spake thusly:

Quoted 4 lines

virtual packages are found by their version,
so we retrieve the version of all packages

Regards,
Yann E. MORIN.

Quoted 81 lines
---
 package/pkg-generic.mk        |  3 +++
 support/scripts/graph-depends | 30 +++++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)
package/pkg-generic.mk +3 -0
index 9643a30..87d8dd8 100644
@@ -565,6 +565,9 @@ $(1)-rsync:		$$($(2)_TARGET_RSYNC)
 $(1)-source:		$$($(2)_TARGET_RSYNC_SOURCE)
 endif
 
+$(1)-show-version:
+			@echo $$($(2)_VERSION)
+
 $(1)-show-depends:
 			@echo $$($(2)_FINAL_DEPENDENCIES)
 
support/scripts/graph-depends +29 -1
index 1ecfeda..28fe2f0 100755
@@ -76,6 +76,28 @@ host_colour = colours[2]
 
 allpkgs = []
 
+# Execute the "make <pkg>-show-version" command to get the version of a given
+# list of packages, and return the version formatted as a Python dictionary.
+def get_version(pkgs):
+    sys.stderr.write("Getting version for %s\n" % pkgs)
+    cmd = ["make", "-s", "--no-print-directory" ]
+    for pkg in pkgs:
+        cmd.append("%s-show-version" % pkg)
+    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
+    output = p.communicate()[0]
+    if p.returncode != 0:
+        sys.stderr.write("Error getting version %s\n" % pkgs)
+        sys.exit(1)
+    output = output.split("\n")
+    if len(output) != len(pkgs) + 1:
+        sys.stderr.write("Error getting version\n")
+        sys.exit(1)
+    version = {}
+    for i in range(0, len(pkgs)):
+        pkg = pkgs[i]
+        version[pkg] = output[i]
+    return version
+
 # Execute the "make show-targets" command to get the list of the main
 # Buildroot TARGETS and return it formatted as a Python list. This
 # list is used as the starting point for full dependency graphs
@@ -257,6 +279,8 @@ def remove_extra_deps(deps):
     return deps
 
 dict_deps = remove_extra_deps(dict_deps)
+dict_version = get_version([pkg for pkg in allpkgs
+                                if pkg != "all" and not pkg.startswith("root")])
 
 # Print the attributes of a node: label and fill-color
 def print_attrs(pkg):
@@ -274,7 +298,11 @@ def print_attrs(pkg):
             color = host_colour
         else:
             color = target_colour
-    print("%s [label = \"%s\"]" % (name, label))
+    version = dict_version.get(pkg)
+    if version == "virtual":
+        print("%s [label = <<I>%s</I>>]" % (name, label))
+    else:
+        print("%s [label = \"%s\"]" % (name, label))
     print("%s [color=%s,style=filled]" % (name, color))
 
 # Print the dependency graph of a package
Signature · 6 lines
2.1.0

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
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.  |
'------------------------------^-------^------------------^--------------------'
#9 lore raw

PATCH v2 1/2 graph-depends: display virtual package with italic style

In reply to Francois Perrad

Dear Francois Perrad,

Quoted 4 lines · Francois Perrad

virtual packages are found by their version,
so we retrieve the version of all packages

Applied, thanks!

Thomas

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