poky-sanity.bbclass 2.1 KB

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