From 64b04685b6fd029f2f70f7017bfd51d26ccb0d11 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 29 Jul 2009 14:33:14 +0100 Subject: bitbake: Add a --revisions-changed commandline option to indicate when floating srcrevs have changed Signed-off-by: Richard Purdie --- bitbake/bin/bitbake | 3 +++ bitbake/lib/bb/cooker.py | 3 +++ bitbake/lib/bb/fetch/__init__.py | 23 ++++++++++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) (limited to 'bitbake') diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake index f3294106ef..842ba0441e 100755 --- a/bitbake/bin/bitbake +++ b/bitbake/bin/bitbake @@ -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) diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 1f31d1203a..b0692431bb 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py @@ -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 diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py index 39a8180a89..a97138d271 100644 --- a/bitbake/lib/bb/fetch/__init__.py +++ b/bitbake/lib/bb/fetch/__init__.py @@ -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 -- cgit 1.2.3-korg