From 41ed4123a687f77a2042cf50d89652639075f869 Mon Sep 17 00:00:00 2001 From: Marius Avram Date: Tue, 25 Mar 2014 15:02:35 +0200 Subject: 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 Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 30 ++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'bitbake/lib/bb/ui/crumbs/hobeventhandler.py') diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py index 73d5f98c39..890e05fa02 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): self.set_var_in_file("EXTRA_SETTING", extra_setting, "local.conf") def set_extra_config(self, extra_setting): - old_extra_setting = ast.literal_eval(self.runCommand(["getVariable", "EXTRA_SETTING"]) or "{}") - if extra_setting: - self.set_var_in_file("EXTRA_SETTING", extra_setting, "local.conf") - else: - self.remove_var_from_file("EXTRA_SETTING") + old_extra_setting = self.runCommand(["getVariable", "EXTRA_SETTING"]) or {} + old_extra_setting = str(old_extra_setting) + + old_extra_setting = ast.literal_eval(old_extra_setting) + if not type(old_extra_setting) == dict: + old_extra_setting = {} + + # settings not changed + if old_extra_setting == extra_setting: + return - #remove not needed settings from conf - for key in old_extra_setting: + # remove the old EXTRA SETTING variable + self.remove_var_from_file("EXTRA_SETTING") + + # remove old settings from conf + for key in old_extra_setting.keys(): if key not in extra_setting: self.remove_var_from_file(key) - for key in extra_setting.keys(): - value = extra_setting[key] + + # add new settings + for key, value in extra_setting.iteritems(): self.set_var_in_file(key, value, "local.conf") + if extra_setting: + self.set_var_in_file("EXTRA_SETTING", extra_setting, "local.conf") + def set_http_proxy(self, http_proxy): self.set_var_in_file("http_proxy", http_proxy, "local.conf") -- cgit v1.2.3-54-g00ecf