diff options
author | Cristiana Voicu <cristiana.voicu@intel.com> | 2013-10-04 16:19:45 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-10-07 09:37:34 +0100 |
commit | ee7e64f116608ab105ead99c7f1966158054d2b5 (patch) | |
tree | 63336893f45fe80393c28e72a4cf445eca0cfb8c | |
parent | 45392cc67a89afe468b179789c7fbeeb3aa67769 (diff) | |
download | poky-ee7e64f116608ab105ead99c7f1966158054d2b5.tar.gz |
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 <cristiana.voicu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/command.py | 7 | ||||
-rw-r--r-- | bitbake/lib/bb/cooker.py | 38 | ||||
-rw-r--r-- | bitbake/lib/bb/data_smart.py | 8 | ||||
-rwxr-xr-x | bitbake/lib/bb/ui/crumbs/builder.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 17 |
5 files changed, 69 insertions, 3 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py index 21a6de0f62..3ca27a69e0 100644 --- a/bitbake/lib/bb/command.py +++ b/bitbake/lib/bb/command.py | |||
@@ -241,6 +241,13 @@ class CommandsSync: | |||
241 | op = params[3] | 241 | op = params[3] |
242 | command.cooker.modifyConfigurationVar(var, val, default_file, op) | 242 | command.cooker.modifyConfigurationVar(var, val, default_file, op) |
243 | 243 | ||
244 | def removeVarFile(self, command, params): | ||
245 | """ | ||
246 | Remove a variable declaration from a file | ||
247 | """ | ||
248 | var = params[0] | ||
249 | command.cooker.removeConfigurationVar(var) | ||
250 | |||
244 | def createConfigFile(self, command, params): | 251 | def createConfigFile(self, command, params): |
245 | """ | 252 | """ |
246 | Create an extra configuration file | 253 | Create an extra configuration file |
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: | |||
304 | loginfo = {"op":set, "file":default_file, "line":total.count("\n")} | 304 | loginfo = {"op":set, "file":default_file, "line":total.count("\n")} |
305 | self.data.setVar(var, val, **loginfo) | 305 | self.data.setVar(var, val, **loginfo) |
306 | 306 | ||
307 | def removeConfigurationVar(self, var): | ||
308 | conf_files = self.data.varhistory.get_variable_files(var) | ||
309 | topdir = self.data.getVar("TOPDIR") | ||
310 | |||
311 | for conf_file in conf_files: | ||
312 | if topdir in conf_file: | ||
313 | with open(conf_file, 'r') as f: | ||
314 | contents = f.readlines() | ||
315 | f.close() | ||
316 | |||
317 | lines = self.data.varhistory.get_variable_lines(var, conf_file) | ||
318 | for line in lines: | ||
319 | total = "" | ||
320 | i = 0 | ||
321 | for c in contents: | ||
322 | total += c | ||
323 | i = i + 1 | ||
324 | if i==int(line): | ||
325 | end_index = len(total) | ||
326 | index = total.rfind(var, 0, end_index) | ||
327 | |||
328 | begin_line = total.count("\n",0,index) | ||
329 | |||
330 | #check if the variable was saved before in the same way | ||
331 | if contents[begin_line-1]== "#added by bitbake\n": | ||
332 | contents[begin_line-1] = contents[begin_line] = "\n" | ||
333 | else: | ||
334 | contents[begin_line] = "\n" | ||
335 | #remove var from history | ||
336 | self.data.varhistory.del_var_history(var, conf_file, line) | ||
337 | |||
338 | total = "" | ||
339 | for c in contents: | ||
340 | total += c | ||
341 | with open(conf_file, 'w') as f: | ||
342 | f.write(total) | ||
343 | f.close() | ||
344 | |||
307 | def createConfigFile(self, name): | 345 | def createConfigFile(self, name): |
308 | path = os.getcwd() | 346 | path = os.getcwd() |
309 | confpath = os.path.join(path, "conf", name) | 347 | confpath = os.path.join(path, "conf", name) |
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index b6f5b78cda..a1cbaba62b 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py | |||
@@ -281,9 +281,13 @@ class VariableHistory(object): | |||
281 | lines.append(line) | 281 | lines.append(line) |
282 | return lines | 282 | return lines |
283 | 283 | ||
284 | def del_var_history(self, var): | 284 | def del_var_history(self, var, f=None, line=None): |
285 | """If file f and line are not given, the entire history of var is deleted""" | ||
285 | if var in self.variables: | 286 | if var in self.variables: |
286 | self.variables[var] = [] | 287 | if f and line: |
288 | self.variables[var] = [ x for x in self.variables[var] if x['file']!=f and x['line']!=line] | ||
289 | else: | ||
290 | self.variables[var] = [] | ||
287 | 291 | ||
288 | class DataSmart(MutableMapping): | 292 | class DataSmart(MutableMapping): |
289 | def __init__(self, special = COWDictBase.copy(), seen = COWDictBase.copy() ): | 293 | def __init__(self, special = COWDictBase.copy(), seen = COWDictBase.copy() ): |
diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py index 46023cc585..ab6750b741 100755 --- a/bitbake/lib/bb/ui/crumbs/builder.py +++ b/bitbake/lib/bb/ui/crumbs/builder.py | |||
@@ -218,7 +218,7 @@ class Configuration: | |||
218 | handler.set_var_in_file("SDKMACHINE", self.curr_sdk_machine, "local.conf") | 218 | handler.set_var_in_file("SDKMACHINE", self.curr_sdk_machine, "local.conf") |
219 | handler.set_var_in_file("CONF_VERSION", self.conf_version, "local.conf") | 219 | handler.set_var_in_file("CONF_VERSION", self.conf_version, "local.conf") |
220 | handler.set_var_in_file("LCONF_VERSION", self.lconf_version, "bblayers.conf") | 220 | handler.set_var_in_file("LCONF_VERSION", self.lconf_version, "bblayers.conf") |
221 | handler.set_var_in_file("EXTRA_SETTING", self.extra_setting, "local.conf") | 221 | handler.set_extra_config(self.extra_setting) |
222 | handler.set_var_in_file("TOOLCHAIN_BUILD", self.toolchain_build, "local.conf") | 222 | handler.set_var_in_file("TOOLCHAIN_BUILD", self.toolchain_build, "local.conf") |
223 | handler.set_var_in_file("IMAGE_FSTYPES", self.image_fstypes, "local.conf") | 223 | handler.set_var_in_file("IMAGE_FSTYPES", self.image_fstypes, "local.conf") |
224 | if not defaults: | 224 | if not defaults: |
diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py index 3f5bebaca3..393c258e46 100644 --- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py +++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | import gobject | 22 | import gobject |
23 | import logging | 23 | import logging |
24 | import ast | ||
24 | from bb.ui.crumbs.runningbuild import RunningBuild | 25 | from bb.ui.crumbs.runningbuild import RunningBuild |
25 | 26 | ||
26 | class HobHandler(gobject.GObject): | 27 | class HobHandler(gobject.GObject): |
@@ -357,7 +358,20 @@ class HobHandler(gobject.GObject): | |||
357 | def set_incompatible_license(self, incompat_license): | 358 | def set_incompatible_license(self, incompat_license): |
358 | self.set_var_in_file("INCOMPATIBLE_LICENSE", incompat_license, "local.conf") | 359 | self.set_var_in_file("INCOMPATIBLE_LICENSE", incompat_license, "local.conf") |
359 | 360 | ||
361 | def set_extra_setting(self, extra_setting): | ||
362 | self.set_var_in_file("EXTRA_SETTING", extra_setting, "local.conf") | ||
363 | |||
360 | def set_extra_config(self, extra_setting): | 364 | def set_extra_config(self, extra_setting): |
365 | old_extra_setting = ast.literal_eval(self.runCommand(["getVariable", "EXTRA_SETTING"]) or "{}") | ||
366 | if extra_setting: | ||
367 | self.set_var_in_file("EXTRA_SETTING", extra_setting, "local.conf") | ||
368 | else: | ||
369 | self.remove_var_from_file("EXTRA_SETTING") | ||
370 | |||
371 | #remove not needed settings from conf | ||
372 | for key in old_extra_setting: | ||
373 | if key not in extra_setting: | ||
374 | self.remove_var_from_file(key) | ||
361 | for key in extra_setting.keys(): | 375 | for key in extra_setting.keys(): |
362 | value = extra_setting[key] | 376 | value = extra_setting[key] |
363 | self.set_var_in_file(key, value, "local.conf") | 377 | self.set_var_in_file(key, value, "local.conf") |
@@ -477,6 +491,9 @@ class HobHandler(gobject.GObject): | |||
477 | self.server.runCommand(["setVarFile", var, val, default_file, "earlyAssign"]) | 491 | self.server.runCommand(["setVarFile", var, val, default_file, "earlyAssign"]) |
478 | self.runCommand(["disableDataTracking"]) | 492 | self.runCommand(["disableDataTracking"]) |
479 | 493 | ||
494 | def remove_var_from_file(self, var): | ||
495 | self.server.runCommand(["removeVarFile", var]) | ||
496 | |||
480 | def append_var_in_file(self, var, val, default_file=None): | 497 | def append_var_in_file(self, var, val, default_file=None): |
481 | self.server.runCommand(["setVarFile", var, val, default_file, "append"]) | 498 | self.server.runCommand(["setVarFile", var, val, default_file, "append"]) |
482 | 499 | ||