summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Avram <marius.avram@intel.com>2014-03-25 13:02:35 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-25 13:26:55 (GMT)
commit41ed4123a687f77a2042cf50d89652639075f869 (patch)
tree9b935cfcc7ee24974bc5b731eaa94423498e9e3b
parent22af8031cdb3090330c5c4c965855963e24a3ba2 (diff)
downloadpoky-41ed4123a687f77a2042cf50d89652639075f869.tar.gz
bitbake: hob: fix set_extra_setting function
The function is used to save additional variables in the configuration file when the user adds a new (key, value) pair from the Settings->Others. There was a problem though when the function was trying to retrieve an older instance of EXTRA_SETTINGS from the configuration file. Sometimes its value was returned as a dictionary and sometimes a string, which caused a crash when calling ast.literal_eval(). The reason of the problem must be a change in bitbake's parsing system. The changes will fix this issues. While analysing this problem I discovered that the variables were not saved properly in the configuration file after consecutive changes to Settings->Others because of the way saveConfigurationVar() from cooker.py works. This patch will also solve this issue. [YOCTO #5989] (Bitbake rev: bdbcd8866104c315fc9da631407d4280433dbfde) Signed-off-by: Marius Avram <marius.avram@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/ui/crumbs/hobeventhandler.py30
1 files changed, 21 insertions, 9 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
index 73d5f98..890e05f 100644
--- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
+++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
@@ -359,20 +359,32 @@ class HobHandler(gobject.GObject):
359 self.set_var_in_file("EXTRA_SETTING", extra_setting, "local.conf") 359 self.set_var_in_file("EXTRA_SETTING", extra_setting, "local.conf")
360 360
361 def set_extra_config(self, extra_setting): 361 def set_extra_config(self, extra_setting):
362 old_extra_setting = ast.literal_eval(self.runCommand(["getVariable", "EXTRA_SETTING"]) or "{}") 362 old_extra_setting = self.runCommand(["getVariable", "EXTRA_SETTING"]) or {}
363 if extra_setting: 363 old_extra_setting = str(old_extra_setting)
364 self.set_var_in_file("EXTRA_SETTING", extra_setting, "local.conf") 364
365 else: 365 old_extra_setting = ast.literal_eval(old_extra_setting)
366 self.remove_var_from_file("EXTRA_SETTING") 366 if not type(old_extra_setting) == dict:
367 old_extra_setting = {}
368
369 # settings not changed
370 if old_extra_setting == extra_setting:
371 return
367 372
368 #remove not needed settings from conf 373 # remove the old EXTRA SETTING variable
369 for key in old_extra_setting: 374 self.remove_var_from_file("EXTRA_SETTING")
375
376 # remove old settings from conf
377 for key in old_extra_setting.keys():
370 if key not in extra_setting: 378 if key not in extra_setting:
371 self.remove_var_from_file(key) 379 self.remove_var_from_file(key)
372 for key in extra_setting.keys(): 380
373 value = extra_setting[key] 381 # add new settings
382 for key, value in extra_setting.iteritems():
374 self.set_var_in_file(key, value, "local.conf") 383 self.set_var_in_file(key, value, "local.conf")
375 384
385 if extra_setting:
386 self.set_var_in_file("EXTRA_SETTING", extra_setting, "local.conf")
387
376 def set_http_proxy(self, http_proxy): 388 def set_http_proxy(self, http_proxy):
377 self.set_var_in_file("http_proxy", http_proxy, "local.conf") 389 self.set_var_in_file("http_proxy", http_proxy, "local.conf")
378 390