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 /bitbake/lib/bb/cooker.py | |
| 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>
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
| -rw-r--r-- | bitbake/lib/bb/cooker.py | 38 |
1 files changed, 38 insertions, 0 deletions
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) |
