diff options
| author | Joshua Watt <JPEWhacker@gmail.com> | 2025-11-07 14:14:41 +0100 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2025-11-14 06:45:29 -0800 |
| commit | a905366ee12aabecd2073b264545c1058bc6925a (patch) | |
| tree | 8f5f95a6a414d1ba41aa46ee593326be14d2746d /meta/classes-recipe | |
| parent | b5184d1487160d3d340371a5a38d1628a4a16297 (diff) | |
| download | poky-a905366ee12aabecd2073b264545c1058bc6925a.tar.gz | |
classes-recipe/image: Add image file manifest
Downstream tasks may want to know what image files were written by the
do_image family of tasks (e.g. SPDX) so have each task write out a
manifest file that describes the files it produced, then aggregate them
in do_image_complete
(From OE-Core rev: 5da5e2c528e8f4c78d389d60b03725323ff1527c)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 5e55ed4c5b9d5af3c96b82805af34af1512fc3d1)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/classes-recipe')
| -rw-r--r-- | meta/classes-recipe/image.bbclass | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/meta/classes-recipe/image.bbclass b/meta/classes-recipe/image.bbclass index 1f0ee1861e..00f1d58f23 100644 --- a/meta/classes-recipe/image.bbclass +++ b/meta/classes-recipe/image.bbclass | |||
| @@ -88,6 +88,11 @@ PACKAGE_INSTALL_ATTEMPTONLY ?= "${FEATURE_INSTALL_OPTIONAL}" | |||
| 88 | 88 | ||
| 89 | IMGDEPLOYDIR = "${WORKDIR}/deploy-${PN}-image-complete" | 89 | IMGDEPLOYDIR = "${WORKDIR}/deploy-${PN}-image-complete" |
| 90 | 90 | ||
| 91 | IMGMANIFESTDIR = "${WORKDIR}/image-task-manifest" | ||
| 92 | |||
| 93 | IMAGE_OUTPUT_MANIFEST_DIR = "${WORKDIR}/deploy-image-output-manifest" | ||
| 94 | IMAGE_OUTPUT_MANIFEST = "${IMAGE_OUTPUT_MANIFEST_DIR}/manifest.json" | ||
| 95 | |||
| 91 | # Images are generally built explicitly, do not need to be part of world. | 96 | # Images are generally built explicitly, do not need to be part of world. |
| 92 | EXCLUDE_FROM_WORLD = "1" | 97 | EXCLUDE_FROM_WORLD = "1" |
| 93 | 98 | ||
| @@ -277,14 +282,28 @@ fakeroot python do_image () { | |||
| 277 | execute_pre_post_process(d, pre_process_cmds) | 282 | execute_pre_post_process(d, pre_process_cmds) |
| 278 | } | 283 | } |
| 279 | do_image[dirs] = "${TOPDIR}" | 284 | do_image[dirs] = "${TOPDIR}" |
| 285 | do_image[cleandirs] += "${IMGMANIFESTDIR}" | ||
| 280 | addtask do_image after do_rootfs | 286 | addtask do_image after do_rootfs |
| 281 | 287 | ||
| 282 | fakeroot python do_image_complete () { | 288 | fakeroot python do_image_complete () { |
| 283 | from oe.utils import execute_pre_post_process | 289 | from oe.utils import execute_pre_post_process |
| 290 | from pathlib import Path | ||
| 291 | import json | ||
| 284 | 292 | ||
| 285 | post_process_cmds = d.getVar("IMAGE_POSTPROCESS_COMMAND") | 293 | post_process_cmds = d.getVar("IMAGE_POSTPROCESS_COMMAND") |
| 286 | 294 | ||
| 287 | execute_pre_post_process(d, post_process_cmds) | 295 | execute_pre_post_process(d, post_process_cmds) |
| 296 | |||
| 297 | image_manifest_dir = Path(d.getVar('IMGMANIFESTDIR')) | ||
| 298 | |||
| 299 | data = [] | ||
| 300 | |||
| 301 | for manifest_path in image_manifest_dir.glob("*.json"): | ||
| 302 | with manifest_path.open("r") as f: | ||
| 303 | data.extend(json.load(f)) | ||
| 304 | |||
| 305 | with open(d.getVar("IMAGE_OUTPUT_MANIFEST"), "w") as f: | ||
| 306 | json.dump(data, f) | ||
| 288 | } | 307 | } |
| 289 | do_image_complete[dirs] = "${TOPDIR}" | 308 | do_image_complete[dirs] = "${TOPDIR}" |
| 290 | SSTATETASKS += "do_image_complete" | 309 | SSTATETASKS += "do_image_complete" |
| @@ -292,6 +311,8 @@ SSTATE_SKIP_CREATION:task-image-complete = '1' | |||
| 292 | do_image_complete[sstate-inputdirs] = "${IMGDEPLOYDIR}" | 311 | do_image_complete[sstate-inputdirs] = "${IMGDEPLOYDIR}" |
| 293 | do_image_complete[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}" | 312 | do_image_complete[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}" |
| 294 | do_image_complete[stamp-extra-info] = "${MACHINE_ARCH}" | 313 | do_image_complete[stamp-extra-info] = "${MACHINE_ARCH}" |
| 314 | do_image_complete[sstate-plaindirs] += "${IMAGE_OUTPUT_MANIFEST_DIR}" | ||
| 315 | do_image_complete[dirs] += "${IMAGE_OUTPUT_MANIFEST_DIR}" | ||
| 295 | addtask do_image_complete after do_image before do_build | 316 | addtask do_image_complete after do_image before do_build |
| 296 | python do_image_complete_setscene () { | 317 | python do_image_complete_setscene () { |
| 297 | sstate_setscene(d) | 318 | sstate_setscene(d) |
| @@ -501,12 +522,14 @@ python () { | |||
| 501 | d.setVar(task, '\n'.join(cmds)) | 522 | d.setVar(task, '\n'.join(cmds)) |
| 502 | d.setVarFlag(task, 'func', '1') | 523 | d.setVarFlag(task, 'func', '1') |
| 503 | d.setVarFlag(task, 'fakeroot', '1') | 524 | d.setVarFlag(task, 'fakeroot', '1') |
| 525 | d.setVarFlag(task, 'imagetype', t) | ||
| 504 | 526 | ||
| 505 | d.appendVarFlag(task, 'prefuncs', ' ' + debug + ' set_image_size') | 527 | d.appendVarFlag(task, 'prefuncs', ' ' + debug + ' set_image_size') |
| 506 | d.prependVarFlag(task, 'postfuncs', 'create_symlinks ') | 528 | d.prependVarFlag(task, 'postfuncs', 'create_symlinks ') |
| 507 | d.appendVarFlag(task, 'subimages', ' ' + ' '.join(subimages)) | 529 | d.appendVarFlag(task, 'subimages', ' ' + ' '.join(subimages)) |
| 508 | d.appendVarFlag(task, 'vardeps', ' ' + ' '.join(vardeps)) | 530 | d.appendVarFlag(task, 'vardeps', ' ' + ' '.join(vardeps)) |
| 509 | d.appendVarFlag(task, 'vardepsexclude', ' DATETIME DATE ' + ' '.join(vardepsexclude)) | 531 | d.appendVarFlag(task, 'vardepsexclude', ' DATETIME DATE ' + ' '.join(vardepsexclude)) |
| 532 | d.appendVarFlag(task, 'postfuncs', ' write_image_output_manifest') | ||
| 510 | 533 | ||
| 511 | bb.debug(2, "Adding task %s before %s, after %s" % (task, 'do_image_complete', after)) | 534 | bb.debug(2, "Adding task %s before %s, after %s" % (task, 'do_image_complete', after)) |
| 512 | bb.build.addtask(task, 'do_image_complete', after, d) | 535 | bb.build.addtask(task, 'do_image_complete', after, d) |
| @@ -604,6 +627,41 @@ python create_symlinks() { | |||
| 604 | bb.note("Skipping symlink, source does not exist: %s -> %s" % (dst, src)) | 627 | bb.note("Skipping symlink, source does not exist: %s -> %s" % (dst, src)) |
| 605 | } | 628 | } |
| 606 | 629 | ||
| 630 | python write_image_output_manifest() { | ||
| 631 | import json | ||
| 632 | from pathlib import Path | ||
| 633 | |||
| 634 | taskname = d.getVar("BB_CURRENTTASK") | ||
| 635 | image_deploy_dir = Path(d.getVar('IMGDEPLOYDIR')) | ||
| 636 | image_manifest_dir = Path(d.getVar('IMGMANIFESTDIR')) | ||
| 637 | manifest_path = image_manifest_dir / ("do_" + d.getVar("BB_CURRENTTASK") + ".json") | ||
| 638 | |||
| 639 | image_name = d.getVar("IMAGE_NAME") | ||
| 640 | image_basename = d.getVar("IMAGE_BASENAME") | ||
| 641 | machine = d.getVar("MACHINE") | ||
| 642 | |||
| 643 | subimages = (d.getVarFlag("do_" + taskname, 'subimages', False) or "").split() | ||
| 644 | imagetype = d.getVarFlag("do_" + taskname, 'imagetype', False) | ||
| 645 | |||
| 646 | data = { | ||
| 647 | "taskname": taskname, | ||
| 648 | "imagetype": imagetype, | ||
| 649 | "images": [] | ||
| 650 | } | ||
| 651 | |||
| 652 | for type in subimages: | ||
| 653 | image_filename = image_name + "." + type | ||
| 654 | image_path = image_deploy_dir / image_filename | ||
| 655 | if not image_path.exists(): | ||
| 656 | continue | ||
| 657 | data["images"].append({ | ||
| 658 | "filename": image_filename, | ||
| 659 | }) | ||
| 660 | |||
| 661 | with manifest_path.open("w") as f: | ||
| 662 | json.dump([data], f) | ||
| 663 | } | ||
| 664 | |||
| 607 | MULTILIBRE_ALLOW_REP += "${base_bindir} ${base_sbindir} ${bindir} ${sbindir} ${libexecdir} ${sysconfdir} ${nonarch_base_libdir}/udev /lib/modules/[^/]*/modules.*" | 665 | MULTILIBRE_ALLOW_REP += "${base_bindir} ${base_sbindir} ${bindir} ${sbindir} ${libexecdir} ${sysconfdir} ${nonarch_base_libdir}/udev /lib/modules/[^/]*/modules.*" |
| 608 | MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py" | 666 | MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py" |
| 609 | MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib" | 667 | MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib" |
