summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Wang <shane.wang@intel.com>2012-06-02 12:54:37 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-06-08 12:13:15 +0100
commit25785d8ddfccfc12af0c677cb519f133be158d1f (patch)
tree6496e41df422a0cad918e26199cb66cf60e4eec6
parentefd977010ea4c9f611089b19cebb81f7a501dafa (diff)
downloadpoky-25785d8ddfccfc12af0c677cb519f133be158d1f.tar.gz
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 <shane.wang@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/builder.py14
-rw-r--r--bitbake/lib/bb/ui/crumbs/template.py17
2 files changed, 28 insertions, 3 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
index 899d0e0c16..bcce41dbb6 100755
--- a/bitbake/lib/bb/ui/crumbs/builder.py
+++ b/bitbake/lib/bb/ui/crumbs/builder.py
@@ -40,6 +40,8 @@ from bb.ui.crumbs.hig import CrumbsMessageDialog, ImageSelectionDialog, \
40from bb.ui.crumbs.persistenttooltip import PersistentTooltip 40from bb.ui.crumbs.persistenttooltip import PersistentTooltip
41import bb.ui.crumbs.utils 41import bb.ui.crumbs.utils
42 42
43hobVer = 20120530
44
43class Configuration: 45class Configuration:
44 '''Represents the data structure of configuration.''' 46 '''Represents the data structure of configuration.'''
45 47
@@ -222,6 +224,7 @@ class Configuration:
222 self.split_proxy("cvs", template.getVar("CVS_PROXY_HOST") + ":" + template.getVar("CVS_PROXY_PORT")) 224 self.split_proxy("cvs", template.getVar("CVS_PROXY_HOST") + ":" + template.getVar("CVS_PROXY_PORT"))
223 225
224 def save(self, template, defaults=False): 226 def save(self, template, defaults=False):
227 template.setVar("VERSION", "%s" % hobVer)
225 # bblayers.conf 228 # bblayers.conf
226 template.setVar("BBLAYERS", " ".join(self.layers)) 229 template.setVar("BBLAYERS", " ".join(self.layers))
227 # local.conf 230 # local.conf
@@ -468,7 +471,7 @@ class Builder(gtk.Window):
468 471
469 def initiate_new_build_async(self): 472 def initiate_new_build_async(self):
470 self.switch_page(self.MACHINE_SELECTION) 473 self.switch_page(self.MACHINE_SELECTION)
471 if self.load_template(TemplateMgr.convert_to_template_pathfilename("default", ".hob/")) == None: 474 if self.load_template(TemplateMgr.convert_to_template_pathfilename("default", ".hob/")) == False:
472 self.handler.init_cooker() 475 self.handler.init_cooker()
473 self.handler.set_extra_inherit("image_types") 476 self.handler.set_extra_inherit("image_types")
474 self.handler.generate_configuration() 477 self.handler.generate_configuration()
@@ -537,9 +540,16 @@ class Builder(gtk.Window):
537 540
538 def load_template(self, path): 541 def load_template(self, path):
539 if not os.path.isfile(path): 542 if not os.path.isfile(path):
540 return None 543 return False
541 544
542 self.template = TemplateMgr() 545 self.template = TemplateMgr()
546 # check compatibility
547 tempVer = self.template.getVersion(path)
548 if not tempVer or int(tempVer) < hobVer:
549 self.template.destroy()
550 self.template = None
551 return False
552
543 try: 553 try:
544 self.template.load(path) 554 self.template.load(path)
545 self.configuration.load(self.template) 555 self.configuration.load(self.template)
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):
101 return self.dictionary[var] 101 return self.dictionary[var]
102 else: 102 else:
103 return "" 103 return ""
104 104
105 def getVersion(self):
106 contents = ConfigFile.readFile(self)
107
108 pattern = "^\s*(\S+)\s*=\s*(\".*?\")"
109
110 for line in contents:
111 match = re.search(pattern, line)
112 if match:
113 if match.group(1) == "VERSION":
114 return match.group(2).strip('"')
115 return None
116
105 def load(self): 117 def load(self):
106 contents = ConfigFile.readFile(self) 118 contents = ConfigFile.readFile(self)
107 self.dictionary.clear() 119 self.dictionary.clear()
@@ -174,6 +186,9 @@ class TemplateMgr(gobject.GObject):
174 self.image_bb.save() 186 self.image_bb.save()
175 self.template_hob.save() 187 self.template_hob.save()
176 188
189 def getVersion(self, path):
190 return HobTemplateFile(path).getVersion()
191
177 def load(self, path): 192 def load(self, path):
178 self.template_hob = HobTemplateFile(path) 193 self.template_hob = HobTemplateFile(path)
179 self.dictionary = self.template_hob.load() 194 self.dictionary = self.template_hob.load()