diff options
-rwxr-xr-x | bin/bitbake | 3 | ||||
-rw-r--r-- | lib/bb/command.py | 19 | ||||
-rw-r--r-- | lib/bb/cooker.py | 6 | ||||
-rw-r--r-- | lib/bb/fetch/__init__.py | 25 | ||||
-rw-r--r-- | lib/bb/fetch/wget.py | 2 | ||||
-rw-r--r-- | lib/bb/persist_data.py | 11 |
6 files changed, 65 insertions, 1 deletions
diff --git a/bin/bitbake b/bin/bitbake index f02630b10..b2edcf48f 100755 --- a/bin/bitbake +++ b/bin/bitbake @@ -135,6 +135,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) diff --git a/lib/bb/command.py b/lib/bb/command.py index 32befc059..1a1bf00b3 100644 --- a/lib/bb/command.py +++ b/lib/bb/command.py @@ -232,6 +232,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 # @@ -250,3 +258,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) + + + diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py index bec6c3535..b2b237b4c 100644 --- a/lib/bb/cooker.py +++ b/lib/bb/cooker.py @@ -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 diff --git a/lib/bb/fetch/__init__.py b/lib/bb/fetch/__init__.py index df4eb961f..a9a47fcde 100644 --- a/lib/bb/fetch/__init__.py +++ b/lib/bb/fetch/__init__.py @@ -78,6 +78,7 @@ def uri_replace(uri, uri_find, uri_replace, d): methods = [] urldata_cache = {} +saved_headrevs = {} def fetcher_init(d): """ @@ -91,6 +92,10 @@ 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) + try: + bb.fetch.saved_headrevs = pd.getKeyValues("BB_URI_HEADREVS") + except: + pass pd.delDomain("BB_URI_HEADREVS") else: bb.msg.fatal(bb.msg.domain.Fetcher, "Invalid SRCREV cache policy of: %s" % srcrev_policy) @@ -98,6 +103,26 @@ def fetcher_init(d): pd.addDomain("BB_URI_HEADREVS") 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 = bb.fetch.saved_headrevs + + 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 diff --git a/lib/bb/fetch/wget.py b/lib/bb/fetch/wget.py index 2a899c580..a0dca9404 100644 --- a/lib/bb/fetch/wget.py +++ b/lib/bb/fetch/wget.py @@ -95,7 +95,7 @@ class Wget(Fetch): # Sanity check since wget can pretend it succeed when it didn't # Also, this used to happen if sourceforge sent us to the mirror page - if not os.path.exists(ud.localpath): + if not os.path.exists(ud.localpath) and not checkonly: bb.msg.debug(2, bb.msg.domain.Fetcher, "The fetch command for %s returned success but %s doesn't exist?..." % (uri, ud.localpath)) return False diff --git a/lib/bb/persist_data.py b/lib/bb/persist_data.py index 79e7448be..bc4045fe8 100644 --- a/lib/bb/persist_data.py +++ b/lib/bb/persist_data.py @@ -69,6 +69,17 @@ class PersistData: """ self.connection.execute("DROP TABLE IF EXISTS %s;" % domain) + def getKeyValues(self, domain): + """ + Return a list of key + value pairs for a domain + """ + ret = {} + data = self.connection.execute("SELECT key, value from %s;" % domain) + for row in data: + ret[str(row[0])] = str(row[1]) + + return ret + def getValue(self, domain, key): """ Return the value of a key for a domain |