1*4882a593Smuzhiyun# Provide some extensions to sanity.bbclass to handle poky-specific conf file upgrades 2*4882a593Smuzhiyun 3*4882a593Smuzhiyunpython poky_update_bblayersconf() { 4*4882a593Smuzhiyun current_version = int(d.getVar('POKY_BBLAYERS_CONF_VERSION', True) or -1) 5*4882a593Smuzhiyun latest_version = int(d.getVar('REQUIRED_POKY_BBLAYERS_CONF_VERSION', True) or -1) 6*4882a593Smuzhiyun if current_version == -1 or latest_version == -1: 7*4882a593Smuzhiyun # one or the other missing => malformed configuration 8*4882a593Smuzhiyun raise NotImplementedError("You need to update bblayers.conf manually for this version transition") 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun success = True 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun # check for out of date templateconf.cfg file 13*4882a593Smuzhiyun lines = [] 14*4882a593Smuzhiyun fn = os.path.join(d.getVar('TOPDIR', True), 'conf/templateconf.cfg') 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun lines = sanity_conf_read(fn) 17*4882a593Smuzhiyun index, meta_yocto_line = sanity_conf_find_line(r'^meta-yocto/', lines) 18*4882a593Smuzhiyun if meta_yocto_line: 19*4882a593Smuzhiyun lines[index] = meta_yocto_line.replace('meta-yocto', 'meta-poky') 20*4882a593Smuzhiyun with open(fn, "w") as f: 21*4882a593Smuzhiyun f.write(''.join(lines)) 22*4882a593Smuzhiyun bb.note("Your conf/templateconf.cfg file was updated from meta-yocto to meta-poky") 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun # add any additional layer checks/changes here 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun if success: 27*4882a593Smuzhiyun current_version = latest_version 28*4882a593Smuzhiyun bblayers_fn = bblayers_conf_file(d) 29*4882a593Smuzhiyun lines = sanity_conf_read(bblayers_fn) 30*4882a593Smuzhiyun # sanity_conf_update() will erroneously find a match when the var name 31*4882a593Smuzhiyun # is used in a comment, so do our own here. The code below can be 32*4882a593Smuzhiyun # removed when sanity_conf_update() is fixed in OE-Core. 33*4882a593Smuzhiyun #sanity_conf_update(bblayers_fn, lines, 'POKY_BBLAYERS_CONF_VERSION', current_version) 34*4882a593Smuzhiyun index, line = sanity_conf_find_line(r'^POKY_BBLAYERS_CONF_VERSION', lines) 35*4882a593Smuzhiyun lines[index] = 'POKY_BBLAYERS_CONF_VERSION = "%d"\n' % current_version 36*4882a593Smuzhiyun with open(bblayers_fn, "w") as f: 37*4882a593Smuzhiyun f.write(''.join(lines)) 38*4882a593Smuzhiyun bb.note("Your conf/bblayers.conf has been automatically updated.") 39*4882a593Smuzhiyun if success: 40*4882a593Smuzhiyun return 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun raise NotImplementedError("You need to update bblayers.conf manually for this version transition") 43*4882a593Smuzhiyun} 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun# ensure our function runs after the OE-Core one 46*4882a593SmuzhiyunBBLAYERS_CONF_UPDATE_FUNCS += "conf/bblayers.conf:POKY_BBLAYERS_CONF_VERSION:REQUIRED_POKY_BBLAYERS_CONF_VERSION:poky_update_bblayersconf" 47