aboutsummaryrefslogtreecommitdiffstats
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:02:07 +0100
commitd5dd9a7af9d35c588528f9937430d1ef5de216c6 (patch)
tree06fd0c0f2d292f1689daf396754218d60b86dc90
parentd44af0185985cc46ba07a82875bbb4cd4a6d3dec (diff)
downloadbitbake-d5dd9a7af9d35c588528f9937430d1ef5de216c6.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] Signed-off-by: Shane Wang <shane.wang@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xlib/bb/ui/crumbs/builder.py14
-rw-r--r--lib/bb/ui/crumbs/template.py17
2 files changed, 28 insertions, 3 deletions
diff --git a/lib/bb/ui/crumbs/builder.py b/lib/bb/ui/crumbs/builder.py
index 899d0e0c1..bcce41dbb 100755
--- a/lib/bb/ui/crumbs/builder.py
+++ b/lib/bb/ui/crumbs/builder.py
@@ -40,6 +40,8 @@ from bb.ui.crumbs.hig import CrumbsMessageDialog, ImageSelectionDialog, \
from bb.ui.crumbs.persistenttooltip import PersistentTooltip
import bb.ui.crumbs.utils
+hobVer = 20120530
+
class Configuration:
'''Represents the data structure of configuration.'''
@@ -222,6 +224,7 @@ class Configuration:
self.split_proxy("cvs", template.getVar("CVS_PROXY_HOST") + ":" + template.getVar("CVS_PROXY_PORT"))
def save(self, template, defaults=False):
+ template.setVar("VERSION", "%s" % hobVer)
# bblayers.conf
template.setVar("BBLAYERS", " ".join(self.layers))
# local.conf
@@ -468,7 +471,7 @@ class Builder(gtk.Window):
def initiate_new_build_async(self):
self.switch_page(self.MACHINE_SELECTION)
- if self.load_template(TemplateMgr.convert_to_template_pathfilename("default", ".hob/")) == None:
+ if self.load_template(TemplateMgr.convert_to_template_pathfilename("default", ".hob/")) == False:
self.handler.init_cooker()
self.handler.set_extra_inherit("image_types")
self.handler.generate_configuration()
@@ -537,9 +540,16 @@ class Builder(gtk.Window):
def load_template(self, path):
if not os.path.isfile(path):
- return None
+ return False
self.template = TemplateMgr()
+ # check compatibility
+ tempVer = self.template.getVersion(path)
+ if not tempVer or int(tempVer) < hobVer:
+ self.template.destroy()
+ self.template = None
+ return False
+
try:
self.template.load(path)
self.configuration.load(self.template)
diff --git a/lib/bb/ui/crumbs/template.py b/lib/bb/ui/crumbs/template.py
index cbed2708d..7309bb646 100644
--- a/lib/bb/ui/crumbs/template.py
+++ b/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()