swupdate-image.bbclass 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (C) 2015-2021 Stefano Babic <sbabic@denx.de>
  2. #
  3. # This class is thought to be used in an image recipe.
  4. # It generates a SWU file from the image itself
  5. # User *must* add a sw-descitpion file
  6. #
  7. # To use this class, add the inherit clause of the update image bb file.
  8. # The generated output file is an swu archive ready to be uploaded to a device running
  9. # swupdate.
  10. inherit swupdate-common.bbclass
  11. inherit image-artifact-names
  12. S = "${WORKDIR}/${PN}"
  13. SRC_URI += "file://sw-description"
  14. SWUPDATE_IMAGES += "${IMAGE_BASENAME}"
  15. python do_swupdate_copy_swdescription() {
  16. import shutil
  17. workdir = d.getVar('S', True)
  18. image = d.getVar('IMAGE_BASENAME', True)
  19. filespath = d.getVar('FILESPATH')
  20. sw_desc_path = bb.utils.which(filespath, "sw-description")
  21. shutil.copyfile(sw_desc_path, os.path.join(workdir, "sw-description"))
  22. if d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image) is None:
  23. bb.fatal("SWUPDATE_IMAGES_FSTYPES[%s] is not set !" % image)
  24. }
  25. do_swupdate_copy_swdescription[nostamp] = "1"
  26. addtask swupdate_copy_swdescription before do_image_complete after do_unpack
  27. addtask swuimage after do_swupdate_copy_swdescription do_image_complete before do_build