Patchwork [Bitbake-dev] Add ability to query dependent packages

login
register
mail settings
Submitter Paul Sokolovsky
Date Feb. 28, 2011, 5:01 p.m.
Message ID <20110228190118.1bf80704@widy.localdomain>
Download mbox | patch
Permalink /patch/835/
State New
Headers show

Comments

Paul Sokolovsky - Feb. 28, 2011, 5:01 p.m.
Hello,

User stories:

A novice user wants to know what's inside Bitbake's black box, in
particular, what dependent packages get built if one asks to build
something.

Am experienced user still wants the same information, for debugging
dependency issues, figuring out which ASSUME_PROVIDEDs to use, etc.

Patches (there're 2) are against 1.10 branch.


From a15aa44890718d97b4196fea22cc11dba43d9ebd Mon Sep 17 00:00:00 2001
From: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Date: Thu, 16 Dec 2010 15:38:52 +0200
Subject: [PATCH 2/3] Add --show-depends switch to show PN on which given packages depend.

Essentially a plain-text version of .dot rendering, shows just names
in dependency set.

Signed-off-by: Paul Sokolovsky <pfalcon@users.sourceforge.net>
---
 bin/bitbake       |    3 +++
 lib/bb/command.py |   11 +++++++++++
 lib/bb/cooker.py  |   14 ++++++++++++++
 3 files changed, 28 insertions(+), 0 deletions(-)

Patch

diff --git a/bin/bitbake b/bin/bitbake
index 8ab99e6..b0339c8 100755
--- a/bin/bitbake
+++ b/bin/bitbake
@@ -118,6 +118,9 @@  Default BBFILES are the .bb files in the current directory.""" )
     parser.add_option( "-s", "--show-versions", help = "show current and preferred versions of all packages",
                action = "store_true", dest = "show_versions", default = False )
 
+    parser.add_option( "--show-depends", help = "show dependendcies of the specified packages",
+               action = "store_true", dest = "show_depends", default = False )
+
     parser.add_option( "-e", "--environment", help = "show the global or per-package environment (this is what used to be bbread)",
                action = "store_true", dest = "show_environment", default = False )
 
diff --git a/lib/bb/command.py b/lib/bb/command.py
index 06bd203..f5c08d0 100644
--- a/lib/bb/command.py
+++ b/lib/bb/command.py
@@ -196,6 +196,17 @@  class CommandsAsync:
         command.finishAsyncCommand()
     generateDotGraph.needcache = True
 
+    def showDepends(self, command, params):
+        """
+        Dump dependency names to stdout
+        """
+        pkgs_to_build = params[0]
+        task = params[1]
+
+        command.cooker.showDepends(pkgs_to_build, task)
+        command.finishAsyncCommand()
+    showDepends.needcache = True
+
     def showVersions(self, command, params):
         """
         Show the currently selected versions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index ca01558..6c9607d 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -158,6 +158,12 @@  class BBCooker:
             else:
                 self.commandlineAction = None
                 bb.error("Please specify a package name for dependency graph generation.")
+        elif self.configuration.show_depends:
+            if self.configuration.pkgs_to_build:
+                self.commandlineAction = ["showDepends", self.configuration.pkgs_to_build, self.configuration.cmd]
+            else:
+                self.commandlineAction = None
+                bb.error("Please specify a package name for dependency graph generation.")
         else:
             if self.configuration.pkgs_to_build:
                 self.commandlineAction = ["buildTargets", self.configuration.pkgs_to_build, self.configuration.cmd]
@@ -398,6 +404,14 @@  class BBCooker:
         depgraph = self.generateDepTreeData(pkgs_to_build, task)
         bb.event.fire(bb.event.DepTreeGenerated(depgraph), self.configuration.data)
 
+    def showDepends(self, pkgs_to_build, task):
+        """
+	Dump dependency list of a pkgs_to_build.
+	"""
+        depgraph = self.generateDepTreeData(pkgs_to_build, task)
+        for pn in depgraph["pn"]:
+            print pn
+
     def generateDotGraphFiles(self, pkgs_to_build, task):
         """
         Create a task dependency graph of pkgs_to_build.
-- 
1.7.3.4



From 42fcae0761f680338bfc5baaf29a2911bf940ee3 Mon Sep 17 00:00:00 2001
From: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Date: Thu, 16 Dec 2010 16:18:15 +0200
Subject: [PATCH 3/3] Record which ASSUME_PROVIDED PNs were looked up, dump them with --show-depends.

Signed-off-by: Paul Sokolovsky <pfalcon@users.sourceforge.net>
---
 lib/bb/cache.py    |    1 +
 lib/bb/cooker.py   |    7 ++++++-
 lib/bb/taskdata.py |    2 ++
 3 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/lib/bb/cache.py b/lib/bb/cache.py
index 3085786..8aac604 100644
--- a/lib/bb/cache.py
+++ b/lib/bb/cache.py
@@ -529,6 +529,7 @@  class CacheData:
         (set elsewhere)
         """
         self.ignored_dependencies = []
+        self.ignored_dependencies_hit = set()
         self.world_target = set()
         self.bbfile_priority = {}
         self.bbfile_config_priorities = []
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 6c9607d..c35040a 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -337,6 +337,7 @@  class BBCooker:
         depend_tree["depends"] = {}
         depend_tree["tdepends"] = {}
         depend_tree["pn"] = {}
+        depend_tree["ignored-pn"] = set()
         depend_tree["rdepends-pn"] = {}
         depend_tree["packages"] = {}
         depend_tree["rdepends-pkg"] = {}
@@ -393,6 +394,7 @@  class BBCooker:
                         depend_tree["packages"][package]["filename"] = fn
                         depend_tree["packages"][package]["version"] = version
 
+        depend_tree["ignored-pn"] = self.status.ignored_dependencies_hit
         return depend_tree
 
 
@@ -409,7 +411,10 @@  class BBCooker:
 	Dump dependency list of a pkgs_to_build.
 	"""
         depgraph = self.generateDepTreeData(pkgs_to_build, task)
-        for pn in depgraph["pn"]:
+        for pn in sorted(depgraph["pn"]):
+            print pn
+        print "-- Dependencies ignored per ASSUME_PROVIDED: --"
+        for pn in sorted(depgraph["ignored-pn"]):
             print pn
 
     def generateDotGraphFiles(self, pkgs_to_build, task):
diff --git a/lib/bb/taskdata.py b/lib/bb/taskdata.py
index 3e5e006..0b3c977 100644
--- a/lib/bb/taskdata.py
+++ b/lib/bb/taskdata.py
@@ -277,6 +277,7 @@  class TaskData:
         unresolved = []
         for target in self.build_names_index:
             if re_match_strings(target, dataCache.ignored_dependencies):
+                dataCache.ignored_dependencies_hit.add(target)
                 continue
             if self.build_names_index.index(target) in self.failed_deps:
                 continue
@@ -292,6 +293,7 @@  class TaskData:
         unresolved = []
         for target in self.run_names_index:
             if re_match_strings(target, dataCache.ignored_dependencies):
+                dataCache.ignored_dependencies_hit.add(target)
                 continue
             if self.run_names_index.index(target) in self.failed_rdeps:
                 continue