graph-depends: display virtual package with italic style
authorFrancois Perrad <fperrad@gmail.com>
Sat, 3 Jan 2015 14:29:12 +0000 (15:29 +0100)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Sun, 8 Mar 2015 21:17:11 +0000 (22:17 +0100)
virtual packages are found by their version,
so we retrieve the version of all packages

Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Tested-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/pkg-generic.mk
support/scripts/graph-depends

index 1b0995563164b51a2cf0796854d22b467d8d21b6..c1b379bf87847ed446681c6d55e8f08db4c7ac77 100644 (file)
@@ -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)
 
index 1ecfedac7a195cccdc6d516978abc16c96c893f8..28fe2f0010a195b90ef094bdc4f444a408c87600 100755 (executable)
@@ -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