python required_distro_layers_handler() { import os import bb required_layers = (d.getVar('REQUIRED_LAYERS') or "").split() if not required_layers: return bblayers_conf = os.path.join(d.getVar('TOPDIR'), 'conf/bblayers.conf') if not os.path.exists(bblayers_conf): return # Aktuelle BBLAYERS auslesen bblayers = d.getVar('BBLAYERS') or "" # Pfad zu den Layern bestimmen layers_dir = os.path.abspath(os.path.join(d.getVar('TOPDIR'), '..', 'layers')) # Layer hinzufügen, die noch nicht in BBLAYERS enthalten sind for layer in required_layers: layer_path = os.path.join(layers_dir, layer) if layer_path not in bblayers: bb.note("Adding required layer: %s" % layer_path) d.appendVar('BBLAYERS', " " + layer_path) # BBLAYERS in die Konfigurationsdatei schreiben with open(bblayers_conf, 'r') as f: content = f.read() # Einfach einen Hinweis hinzufügen, damit keine versehentlichen Änderungen vorgenommen werden marker = '# Required layers added by openstlinux-eglfs-dcm distro' if marker not in content: with open(bblayers_conf, 'a') as f: f.write('\n' + marker + '\n') for layer in required_layers: layer_path = os.path.join(layers_dir, layer) if layer_path not in content: f.write('BBLAYERS =+ "%s"\n' % layer_path) } addhandler required_distro_layers_handler required_distro_layers_handler[eventmask] = "bb.event.ConfigParsed"