]> code.ossystems Code Review - openembedded-core.git/commitdiff
bitbake: Add a --revisions-changed commandline option to indicate when floating srcre...
authorRichard Purdie <rpurdie@linux.intel.com>
Wed, 29 Jul 2009 13:33:14 +0000 (14:33 +0100)
committerRichard Purdie <rpurdie@linux.intel.com>
Wed, 29 Jul 2009 13:33:14 +0000 (14:33 +0100)
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
bitbake-dev/bin/bitbake
bitbake-dev/lib/bb/command.py
bitbake-dev/lib/bb/cooker.py
bitbake-dev/lib/bb/fetch/__init__.py
bitbake-dev/lib/bb/ui/knotty.py
bitbake/bin/bitbake
bitbake/lib/bb/cooker.py
bitbake/lib/bb/fetch/__init__.py

index f4cd0cb69aafa2effa558cf3e3a75a6f4b92044e..d9aa910422d3e303795639a0fff8da23f34df9d3 100755 (executable)
@@ -124,6 +124,9 @@ Default BBFILES are the .bb files in the current directory.""" )
     parser.add_option( "-u", "--ui", help = "userinterface to use",
                action = "store", dest = "ui")
 
+    parser.add_option( "", "--revisions-changed", help = "Set the exit code depending on whether upstream floating revisions have changed or not",
+               action = "store_true", dest = "revisions_changed", default = False )
+
     options, args = parser.parse_args(sys.argv)
 
     configuration = BBConfiguration(options)
index 9226a2772fe78d12c96320c7734b153dd5364917..e7c3770ffce960bf280172eece0500595883af86 100644 (file)
@@ -233,6 +233,14 @@ class CommandsAsync:
         command.finishAsyncCommand()
     parseFiles.needcache = True
 
+    def compareRevisions(self, command, params):
+        """
+        Parse the .bb files
+        """
+        command.cooker.compareRevisions()
+        command.finishAsyncCommand()
+    compareRevisions.needcache = True
+
 #
 # Events
 #
@@ -251,3 +259,14 @@ class CookerCommandFailed(bb.event.Event):
     def  __init__(self, data, error):
         bb.event.Event.__init__(self, data)
         self.error = error
+
+class CookerCommandSetExitCode(bb.event.Event):
+    """
+    Set the exit code for a cooker command
+    """
+    def  __init__(self, data, exitcode):
+        bb.event.Event.__init__(self, data)
+        self.exitcode = int(exitcode)
+
+
+
index bec6c3535ca6ee873a900254a33f42bc994cca0a..b2b237b4c7f0d6cc942d4c4b51126f539c8b14d8 100644 (file)
@@ -147,6 +147,8 @@ class BBCooker:
                 self.commandlineAction = ["showEnvironment", self.configuration.buildfile]
         elif self.configuration.buildfile is not None:
             self.commandlineAction = ["buildFile", self.configuration.buildfile, self.configuration.cmd]
+        elif self.configuration.revisions_changed:
+            self.commandlineAction = ["compareRevisions"]
         elif self.configuration.show_versions:
             self.commandlineAction = ["showVersions"]
         elif self.configuration.parse_only:
@@ -241,6 +243,10 @@ class BBCooker:
 
             bb.msg.plain("%-35s %25s %25s" % (p, lateststr, prefstr))
 
+    def compareRevisions(self):
+        ret = bb.fetch.fetcher_compare_revisons(self.configuration.data)
+        bb.event.fire(bb.command.CookerCommandSetExitCode(self.configuration.event_data, ret))
+
     def showEnvironment(self, buildfile = None, pkgs_to_build = []):
         """
         Show the outer or per-package environment
index 39a577b2eb58e31798c405c805d856ef99017070..8ddcd3870627f1d7e8cc9d5a63c0e7cfb80fe2c5 100644 (file)
@@ -91,13 +91,34 @@ def fetcher_init(d):
         bb.msg.debug(1, bb.msg.domain.Fetcher, "Keeping SRCREV cache due to cache policy of: %s" % srcrev_policy)
     elif srcrev_policy == "clear":
         bb.msg.debug(1, bb.msg.domain.Fetcher, "Clearing SRCREV cache due to cache policy of: %s" % srcrev_policy)
-        pd.delDomain("BB_URI_HEADREVS")
+        pd.renameDomain("BB_URI_HEADREVS", "BB_URI_HEADREVS_PREVIOUS")
     else:
         bb.msg.fatal(bb.msg.domain.Fetcher, "Invalid SRCREV cache policy of: %s" % srcrev_policy)
     # Make sure our domains exist
     pd.addDomain("BB_URI_HEADREVS")
+    pd.addDomain("BB_URI_HEADREVS_PREVIOUS")
     pd.addDomain("BB_URI_LOCALCOUNT")
 
+def fetcher_compare_revisons(d):
+    """
+    Compare the revisions in the persistant cache with current values and
+    return true/false on whether they've changed.
+    """
+
+    pd = persist_data.PersistData(d)
+    data = pd.getKeyValues("BB_URI_HEADREVS")
+    data2 = pd.getKeyValues("BB_URI_HEADREVS_PREVIOUS")
+
+    changed = False
+    for key in data:
+        if key not in data2 or data2[key] != data[key]:
+            bb.msg.debug(1, bb.msg.domain.Fetcher, "%s changed" % key)
+            changed = True
+            return True
+        else:
+            bb.msg.debug(2, bb.msg.domain.Fetcher, "%s did not change" % key)
+    return False
+
 # Function call order is usually:
 #   1. init
 #   2. go
index a334c2977efa3ca55664831d97bcd8432a7e3f17..031fa715787607e4385c24075f8d9259dd26b1a0 100644 (file)
@@ -120,6 +120,9 @@ def init(server, eventHandler):
 
             if event[0] == 'bb.command.CookerCommandCompleted':
                 break
+            if event[0] == 'bb.command.CookerCommandSetExitCode':
+                return_value = event[1]['exitcode']
+                continue
             if event[0] == 'bb.command.CookerCommandFailed':
                 return_value = 1
                 print "Command execution failed: %s" % event[1]['error']
index f3294106ef2e6af35dd8fda9422dbdf0eef593a2..842ba0441e2fdc3e1891ec57ac1949ef26b18d5c 100755 (executable)
@@ -108,6 +108,9 @@ Default BBFILES are the .bb files in the current directory.""" )
     parser.add_option( "-P", "--profile", help = "profile the command and print a report",
                action = "store_true", dest = "profile", default = False )
 
+    parser.add_option( "", "--revisions-changed", help = "Set the exit code depending on whether upstream floating revisions have changed or not",
+               action = "store_true", dest = "revisions_changed", default = False )
+
     options, args = parser.parse_args(sys.argv)
 
     configuration = BBConfiguration(options)
index 1f31d1203ad738ffdcac8c7d2c04306fb049c0b5..b0692431bb7f8a61737c2130801cc2fef0f83c7a 100644 (file)
@@ -612,6 +612,9 @@ class BBCooker:
         # initialise the parsing status now we know we will need deps
         self.updateCache()
 
+        if self.configuration.revisions_changed:
+            sys.exit(bb.fetch.fetcher_compare_revisons(self.configuration.data))
+
         if self.configuration.parse_only:
             bb.msg.note(1, bb.msg.domain.Collection, "Requested parsing .bb files only.  Exiting.")
             return 0
index 39a8180a8999141e04953495df9fddf42ead1399..a97138d2715648552cc08619107c5219c2168fd4 100644 (file)
@@ -97,13 +97,34 @@ def fetcher_init(d):
         bb.msg.debug(1, bb.msg.domain.Fetcher, "Keeping SRCREV cache due to cache policy of: %s" % srcrev_policy)
     elif srcrev_policy == "clear":
         bb.msg.debug(1, bb.msg.domain.Fetcher, "Clearing SRCREV cache due to cache policy of: %s" % srcrev_policy)
-        pd.delDomain("BB_URI_HEADREVS")
+        pd.renameDomain("BB_URI_HEADREVS", "BB_URI_HEADREVS_PREVIOUS")
     else:
         bb.msg.fatal(bb.msg.domain.Fetcher, "Invalid SRCREV cache policy of: %s" % srcrev_policy)
     # Make sure our domains exist
     pd.addDomain("BB_URI_HEADREVS")
+    pd.addDomain("BB_URI_HEADREVS_PREVIOUS")
     pd.addDomain("BB_URI_LOCALCOUNT")
 
+def fetcher_compare_revisons(d):
+    """
+    Compare the revisions in the persistant cache with current values and
+    return true/false on whether they've changed.
+    """
+
+    pd = persist_data.PersistData(d)
+    data = pd.getKeyValues("BB_URI_HEADREVS")
+    data2 = pd.getKeyValues("BB_URI_HEADREVS_PREVIOUS")
+
+    changed = False
+    for key in data:
+        if key not in data2 or data2[key] != data[key]:
+            bb.msg.debug(1, bb.msg.domain.Fetcher, "%s changed" % key)
+            changed = True
+            return True
+        else:
+            bb.msg.debug(2, bb.msg.domain.Fetcher, "%s did not change" % key)
+    return False
+
 # Function call order is usually:
 #   1. init
 #   2. go