From 25785d8ddfccfc12af0c677cb519f133be158d1f Mon Sep 17 00:00:00 2001 From: Shane Wang Date: Sat, 2 Jun 2012 12:54:37 +0800 Subject: Hob: add versions for compatibility check between Hob and templates If a user uses a very old version of Hob and does some work, later on he/she upgrade to the latest version of Hob, because Hob may change the settings (add more config option into the Adv. Settings dialog or remove some), then the old templates are not loadable and workable for the new Hob. Even though the user hasn't save any template before, the Hob could remember the settings between Hob sessions as a default template, (Remember we have a bug to ask Hob remember between sessions?), the new Hob will also load the default template. By adding versions, we can easily to fix the issue. If the versions don't match, Hob will remove the old default template first and initiate a new build, which has very very little impact on the user. (Just can't remember from the previous session after the user upgrades to a new and incompatible Hob) [Yocto #2492] (Bitbake rev: d5dd9a7af9d35c588528f9937430d1ef5de216c6) Signed-off-by: Shane Wang Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/crumbs/template.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'bitbake/lib/bb/ui/crumbs/template.py') diff --git a/bitbake/lib/bb/ui/crumbs/template.py b/bitbake/lib/bb/ui/crumbs/template.py index cbed2708de..7309bb6467 100644 --- a/bitbake/lib/bb/ui/crumbs/template.py +++ b/bitbake/lib/bb/ui/crumbs/template.py @@ -101,7 +101,19 @@ class HobTemplateFile(ConfigFile): return self.dictionary[var] else: return "" - + + def getVersion(self): + contents = ConfigFile.readFile(self) + + pattern = "^\s*(\S+)\s*=\s*(\".*?\")" + + for line in contents: + match = re.search(pattern, line) + if match: + if match.group(1) == "VERSION": + return match.group(2).strip('"') + return None + def load(self): contents = ConfigFile.readFile(self) self.dictionary.clear() @@ -174,6 +186,9 @@ class TemplateMgr(gobject.GObject): self.image_bb.save() self.template_hob.save() + def getVersion(self, path): + return HobTemplateFile(path).getVersion() + def load(self, path): self.template_hob = HobTemplateFile(path) self.dictionary = self.template_hob.load() -- cgit v1.2.3-54-g00ecf