From ee7e64f116608ab105ead99c7f1966158054d2b5 Mon Sep 17 00:00:00 2001 From: Cristiana Voicu Date: Fri, 4 Oct 2013 16:19:45 +0300 Subject: bitbake: bitbake/hob: removing extra parameters from conf files using hob In Hob settings, there is a tab to add/remove extra settings. This patch implements a way to "remove" variables from conf files, through bitbake. But, to keep the history assigment of the variables synchronized, instead of removing, it replaces the lines with blank lines. [YOCTO #5284] (Bitbake rev: bd720fb63cef6b399619b8fbcaeb8d7710f2d6df) Signed-off-by: Cristiana Voicu Signed-off-by: Richard Purdie --- bitbake/lib/bb/cooker.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'bitbake/lib/bb/cooker.py') diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index ce7ca43d2a..d17716d39e 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py @@ -304,6 +304,44 @@ class BBCooker: loginfo = {"op":set, "file":default_file, "line":total.count("\n")} self.data.setVar(var, val, **loginfo) + def removeConfigurationVar(self, var): + conf_files = self.data.varhistory.get_variable_files(var) + topdir = self.data.getVar("TOPDIR") + + for conf_file in conf_files: + if topdir in conf_file: + with open(conf_file, 'r') as f: + contents = f.readlines() + f.close() + + lines = self.data.varhistory.get_variable_lines(var, conf_file) + for line in lines: + total = "" + i = 0 + for c in contents: + total += c + i = i + 1 + if i==int(line): + end_index = len(total) + index = total.rfind(var, 0, end_index) + + begin_line = total.count("\n",0,index) + + #check if the variable was saved before in the same way + if contents[begin_line-1]== "#added by bitbake\n": + contents[begin_line-1] = contents[begin_line] = "\n" + else: + contents[begin_line] = "\n" + #remove var from history + self.data.varhistory.del_var_history(var, conf_file, line) + + total = "" + for c in contents: + total += c + with open(conf_file, 'w') as f: + f.write(total) + f.close() + def createConfigFile(self, name): path = os.getcwd() confpath = os.path.join(path, "conf", name) -- cgit v1.2.3-54-g00ecf