summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/command.py60
-rw-r--r--bitbake/lib/bb/cooker.py193
2 files changed, 0 insertions, 253 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index a919f58d24..36891b923f 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -233,60 +233,11 @@ class CommandsSync:
233 command.cooker.configuration.postfile = postfiles 233 command.cooker.configuration.postfile = postfiles
234 setPrePostConfFiles.needconfig = False 234 setPrePostConfFiles.needconfig = False
235 235
236 def getCpuCount(self, command, params):
237 """
238 Get the CPU count on the bitbake server
239 """
240 return bb.utils.cpu_count()
241 getCpuCount.readonly = True
242 getCpuCount.needconfig = False
243
244 def matchFile(self, command, params): 236 def matchFile(self, command, params):
245 fMatch = params[0] 237 fMatch = params[0]
246 return command.cooker.matchFile(fMatch) 238 return command.cooker.matchFile(fMatch)
247 matchFile.needconfig = False 239 matchFile.needconfig = False
248 240
249 def generateNewImage(self, command, params):
250 image = params[0]
251 base_image = params[1]
252 package_queue = params[2]
253 timestamp = params[3]
254 description = params[4]
255 return command.cooker.generateNewImage(image, base_image,
256 package_queue, timestamp, description)
257
258 def ensureDir(self, command, params):
259 directory = params[0]
260 bb.utils.mkdirhier(directory)
261 ensureDir.needconfig = False
262
263 def setVarFile(self, command, params):
264 """
265 Save a variable in a file; used for saving in a configuration file
266 """
267 var = params[0]
268 val = params[1]
269 default_file = params[2]
270 op = params[3]
271 command.cooker.modifyConfigurationVar(var, val, default_file, op)
272 setVarFile.needconfig = False
273
274 def removeVarFile(self, command, params):
275 """
276 Remove a variable declaration from a file
277 """
278 var = params[0]
279 command.cooker.removeConfigurationVar(var)
280 removeVarFile.needconfig = False
281
282 def createConfigFile(self, command, params):
283 """
284 Create an extra configuration file
285 """
286 name = params[0]
287 command.cooker.createConfigFile(name)
288 createConfigFile.needconfig = False
289
290 def setEventMask(self, command, params): 241 def setEventMask(self, command, params):
291 handlerNum = params[0] 242 handlerNum = params[0]
292 llevel = params[1] 243 llevel = params[1]
@@ -646,17 +597,6 @@ class CommandsAsync:
646 command.finishAsyncCommand() 597 command.finishAsyncCommand()
647 generateTargetsTree.needcache = True 598 generateTargetsTree.needcache = True
648 599
649 def findCoreBaseFiles(self, command, params):
650 """
651 Find certain files in COREBASE directory. i.e. Layers
652 """
653 subdir = params[0]
654 filename = params[1]
655
656 command.cooker.findCoreBaseFiles(subdir, filename)
657 command.finishAsyncCommand()
658 findCoreBaseFiles.needcache = False
659
660 def findConfigFiles(self, command, params): 600 def findConfigFiles(self, command, params):
661 """ 601 """
662 Find config files which provide appropriate values 602 Find config files which provide appropriate values
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