summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cooker.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2017-06-09 17:13:51 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-12 15:07:39 +0100
commit833520d2fb8cdef2f6fdc7a0550aba1f67724c27 (patch)
treed9dfe6f06933b4091c0c9c95a7c49da8d0253370 /bitbake/lib/bb/cooker.py
parent3d4c64fb9ff33a074328c37c7803c13ecc95f689 (diff)
downloadpoky-833520d2fb8cdef2f6fdc7a0550aba1f67724c27.tar.gz
bitbake: command / cooker: drop Hob support commands and functions
Drop a number of the commands and support functions that were created solely to support functionality in the now-removed Hob UI. In most cases we now have this functionality elsewhere e.g. to modify config files and recipes we have bb.utils.edit_metadata_file() and friends, and in OE we have oe.recipeutils.patch_recipe_file() and friends which build on top of the former. Additionally, some of it represented pretty egregious incursion of OE metadata-specific references into BitBake code. For now I have left in the find*File functions and commands as they are relatively generic and possibly still useful, but they might be removed in future. (Bitbake rev: a322f13183c66a28d93cc4bc3d839d95fc1d90f4) Signed-off-by: Paul Eggleton <paul.eggleton@linux.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.py193
1 files changed, 0 insertions, 193 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 45b5a61c46..661cd0e3c9 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -389,138 +389,6 @@ class BBCooker:
389 if hasattr(self, "data"): 389 if hasattr(self, "data"):
390 self.data.disableTracking() 390 self.data.disableTracking()
391 391
392 def modifyConfigurationVar(self, var, val, default_file, op):
393 if op == "append":
394 self.appendConfigurationVar(var, val, default_file)
395 elif op == "set":
396 self.saveConfigurationVar(var, val, default_file, "=")
397 elif op == "earlyAssign":
398 self.saveConfigurationVar(var, val, default_file, "?=")
399
400
401 def appendConfigurationVar(self, var, val, default_file):
402 #add append var operation to the end of default_file
403 default_file = bb.cookerdata.findConfigFile(default_file, self.data)
404
405 total = "#added by hob"
406 total += "\n%s += \"%s\"\n" % (var, val)
407
408 with open(default_file, 'a') as f:
409 f.write(total)
410
411 #add to history
412 loginfo = {"op":"append", "file":default_file, "line":total.count("\n")}
413 self.data.appendVar(var, val, **loginfo)
414
415 def saveConfigurationVar(self, var, val, default_file, op):
416
417 replaced = False
418 #do not save if nothing changed
419 if str(val) == self.data.getVar(var, False):
420 return
421
422 conf_files = self.data.varhistory.get_variable_files(var)
423
424 #format the value when it is a list
425 if isinstance(val, list):
426 listval = ""
427 for value in val:
428 listval += "%s " % value
429 val = listval
430
431 topdir = self.data.getVar("TOPDIR", False)
432
433 #comment or replace operations made on var
434 for conf_file in conf_files:
435 if topdir in conf_file:
436 with open(conf_file, 'r') as f:
437 contents = f.readlines()
438
439 lines = self.data.varhistory.get_variable_lines(var, conf_file)
440 for line in lines:
441 total = ""
442 i = 0
443 for c in contents:
444 total += c
445 i = i + 1
446 if i==int(line):
447 end_index = len(total)
448 index = total.rfind(var, 0, end_index)
449
450 begin_line = total.count("\n",0,index)
451 end_line = int(line)
452
453 #check if the variable was saved before in the same way
454 #if true it replace the place where the variable was declared
455 #else it comments it
456 if contents[begin_line-1]== "#added by hob\n":
457 contents[begin_line] = "%s %s \"%s\"\n" % (var, op, val)
458 replaced = True
459 else:
460 for ii in range(begin_line, end_line):
461 contents[ii] = "#" + contents[ii]
462
463 with open(conf_file, 'w') as f:
464 f.writelines(contents)
465
466 if replaced == False:
467 #remove var from history
468 self.data.varhistory.del_var_history(var)
469
470 #add var to the end of default_file
471 default_file = bb.cookerdata.findConfigFile(default_file, self.data)
472
473 #add the variable on a single line, to be easy to replace the second time
474 total = "\n#added by hob"
475 total += "\n%s %s \"%s\"\n" % (var, op, val)
476
477 with open(default_file, 'a') as f:
478 f.write(total)
479
480 #add to history
481 loginfo = {"op":"set", "file":default_file, "line":total.count("\n")}
482 self.data.setVar(var, val, **loginfo)
483
484 def removeConfigurationVar(self, var):
485 conf_files = self.data.varhistory.get_variable_files(var)
486 topdir = self.data.getVar("TOPDIR", False)
487
488 for conf_file in conf_files:
489 if topdir in conf_file:
490 with open(conf_file, 'r') as f:
491 contents = f.readlines()
492
493 lines = self.data.varhistory.get_variable_lines(var, conf_file)
494 for line in lines:
495 total = ""
496 i = 0
497 for c in contents:
498 total += c
499 i = i + 1
500 if i==int(line):
501 end_index = len(total)
502 index = total.rfind(var, 0, end_index)
503
504 begin_line = total.count("\n",0,index)
505
506 #check if the variable was saved before in the same way
507 if contents[begin_line-1]== "#added by hob\n":
508 contents[begin_line-1] = contents[begin_line] = "\n"
509 else:
510 contents[begin_line] = "\n"
511 #remove var from history
512 self.data.varhistory.del_var_history(var, conf_file, line)
513 #remove variable
514 self.data.delVar(var)
515
516 with open(conf_file, 'w') as f:
517 f.writelines(contents)
518
519 def createConfigFile(self, name):
520 path = os.getcwd()
521 confpath = os.path.join(path, "conf", name)
522 open(confpath, 'w').close()
523
524 def parseConfiguration(self): 392 def parseConfiguration(self):
525 # Set log file verbosity 393 # Set log file verbosity
526 verboselogs = bb.utils.to_boolean(self.data.getVar("BB_VERBOSE_LOGS", False)) 394 verboselogs = bb.utils.to_boolean(self.data.getVar("BB_VERBOSE_LOGS", False))
@@ -1041,18 +909,6 @@ class BBCooker:
1041 providerlog.error("conflicting preferences for %s: both %s and %s specified", providee, provider, self.recipecaches[mc].preferred[providee]) 909 providerlog.error("conflicting preferences for %s: both %s and %s specified", providee, provider, self.recipecaches[mc].preferred[providee])
1042 self.recipecaches[mc].preferred[providee] = provider 910 self.recipecaches[mc].preferred[providee] = provider
1043 911
1044 def findCoreBaseFiles(self, subdir, configfile):
1045 corebase = self.data.getVar('COREBASE') or ""
1046 paths = []
1047 for root, dirs, files in os.walk(corebase + '/' + subdir):
1048 for d in dirs:
1049 configfilepath = os.path.join(root, d, configfile)
1050 if os.path.exists(configfilepath):
1051 paths.append(os.path.join(root, d))
1052
1053 if paths:
1054 bb.event.fire(bb.event.CoreBaseFilesFound(paths), self.data)
1055
1056 def findConfigFilePath(self, configfile): 912 def findConfigFilePath(self, configfile):
1057 """ 913 """
1058 Find the location on disk of configfile and if it exists and was parsed by BitBake 914 Find the location on disk of configfile and if it exists and was parsed by BitBake
@@ -1563,55 +1419,6 @@ class BBCooker:
1563 return dump 1419 return dump
1564 1420
1565 1421
1566 def generateNewImage(self, image, base_image, package_queue, timestamp, description):
1567 '''
1568 Create a new image with a "require"/"inherit" base_image statement
1569 '''
1570 if timestamp:
1571 image_name = os.path.splitext(image)[0]
1572 timestr = time.strftime("-%Y%m%d-%H%M%S")
1573 dest = image_name + str(timestr) + ".bb"
1574 else:
1575 if not image.endswith(".bb"):
1576 dest = image + ".bb"
1577 else:
1578 dest = image
1579
1580 basename = False
1581 if base_image:
1582 with open(base_image, 'r') as f:
1583 require_line = f.readline()
1584 p = re.compile("IMAGE_BASENAME *=")
1585 for line in f:
1586 if p.search(line):
1587 basename = True
1588
1589 with open(dest, "w") as imagefile:
1590 if base_image is None:
1591 imagefile.write("inherit core-image\n")
1592 else:
1593 topdir = self.data.getVar("TOPDIR", False)
1594 if topdir in base_image:
1595 base_image = require_line.split()[1]
1596 imagefile.write("require " + base_image + "\n")
1597 image_install = "IMAGE_INSTALL = \""
1598 for package in package_queue:
1599 image_install += str(package) + " "
1600 image_install += "\"\n"
1601 imagefile.write(image_install)
1602
1603 description_var = "DESCRIPTION = \"" + description + "\"\n"
1604 imagefile.write(description_var)
1605
1606 if basename:
1607 # If this is overwritten in a inherited image, reset it to default
1608 image_basename = "IMAGE_BASENAME = \"${PN}\"\n"
1609 imagefile.write(image_basename)
1610
1611 self.state = state.initial
1612 if timestamp:
1613 return timestr
1614
1615 def updateCacheSync(self): 1422 def updateCacheSync(self):
1616 if self.state == state.running: 1423 if self.state == state.running:
1617 return 1424 return