Message ID | 20240624193151.1645802-3-JPEWhacker@gmail.com |
---|---|
State | New |
Headers | show |
Series | Add SPDX 3.0 support | expand |
There's already an IMAGE_MANIFEST file that's quite different from this? tmp/deploy/core-image-minimal-qemux86-64.rootfs.manifest base-files qemux86_64 3.0.14 base-passwd core2_64 3.6.3 busybox core2_64 1.36.1 So I find the name very confusing. Perhaps call this something completely different, like "result" or do-image-task-output or similar... Regards //Ernst Den mån 24 juni 2024 kl 21:32 skrev Joshua Watt via lists.openembedded.org <JPEWhacker=gmail.com@lists.openembedded.org>: > Downstream tasks may want to know what image files were written so write > out a manifest in do_image_complete. The format of the manifest is the > same as the one in image.bbclass > > Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> > --- > meta/classes-recipe/baremetal-image.bbclass | 30 +++++++++++++++++++-- > 1 file changed, 28 insertions(+), 2 deletions(-) > > diff --git a/meta/classes-recipe/baremetal-image.bbclass > b/meta/classes-recipe/baremetal-image.bbclass > index 4e7d413626e..d7f53803e2a 100644 > --- a/meta/classes-recipe/baremetal-image.bbclass > +++ b/meta/classes-recipe/baremetal-image.bbclass > @@ -30,6 +30,9 @@ BAREMETAL_BINNAME ?= "hello_baremetal_${MACHINE}" > IMAGE_LINK_NAME ?= "baremetal-helloworld-image-${MACHINE}" > IMAGE_NAME_SUFFIX ?= "" > > +IMAGE_FILE_MANIFEST_DIR = "${WORKDIR}/deploy-image-file-manifest" > +IMAGE_FILE_MANIFEST = "${IMAGE_FILE_MANIFEST_DIR}/manifest.json" > + > do_rootfs[dirs] = "${IMGDEPLOYDIR} ${DEPLOY_DIR_IMAGE}" > > do_image(){ > @@ -37,8 +40,28 @@ do_image(){ > install ${D}/${base_libdir}/firmware/${BAREMETAL_BINNAME}.elf > ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.elf > } > > -do_image_complete(){ > - : > +python do_image_complete(){ > + from pathlib import Path > + import json > + > + data = { > + "taskname": "do_image", > + "imagetype": "baremetal-image", > + "images": [] > + } > + > + img_deploy_dir = Path(d.getVar("IMGDEPLOYDIR")) > + > + for child in img_deploy_dir.iterdir(): > + if not child.is_file() or child.is_symlink(): > + continue > + > + data["images"].append({ > + "filename": child.name, > + }) > + > + with open(d.getVar("IMAGE_FILE_MANIFEST"), "w") as f: > + json.dump([data], f) > } > > python do_rootfs(){ > @@ -62,6 +85,7 @@ python do_rootfs(){ > bb.utils.mkdirhier(sysconfdir) > > execute_pre_post_process(d, d.getVar('ROOTFS_POSTPROCESS_COMMAND')) > + execute_pre_post_process(d, d.getVar("ROOTFS_POSTUNINSTALL_COMMAND")) > } > > > @@ -72,6 +96,8 @@ SSTATE_SKIP_CREATION:task-image-complete = '1' > do_image_complete[sstate-inputdirs] = "${IMGDEPLOYDIR}" > do_image_complete[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}" > do_image_complete[stamp-extra-info] = "${MACHINE_ARCH}" > +do_image_complete[sstate-plaindirs] += "${IMAGE_FILE_MANIFEST_DIR}" > +do_image_complete[dirs] += "${IMAGE_FILE_MANIFEST_DIR}" > addtask do_image_complete after do_image before do_build > > python do_image_complete_setscene () { > -- > 2.43.2 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#201104): > https://lists.openembedded.org/g/openembedded-core/message/201104 > Mute This Topic: https://lists.openembedded.org/mt/106856870/4947266 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ > ernstp@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- > >
diff --git a/meta/classes-recipe/baremetal-image.bbclass b/meta/classes-recipe/baremetal-image.bbclass index 4e7d413626e..d7f53803e2a 100644 --- a/meta/classes-recipe/baremetal-image.bbclass +++ b/meta/classes-recipe/baremetal-image.bbclass @@ -30,6 +30,9 @@ BAREMETAL_BINNAME ?= "hello_baremetal_${MACHINE}" IMAGE_LINK_NAME ?= "baremetal-helloworld-image-${MACHINE}" IMAGE_NAME_SUFFIX ?= "" +IMAGE_FILE_MANIFEST_DIR = "${WORKDIR}/deploy-image-file-manifest" +IMAGE_FILE_MANIFEST = "${IMAGE_FILE_MANIFEST_DIR}/manifest.json" + do_rootfs[dirs] = "${IMGDEPLOYDIR} ${DEPLOY_DIR_IMAGE}" do_image(){ @@ -37,8 +40,28 @@ do_image(){ install ${D}/${base_libdir}/firmware/${BAREMETAL_BINNAME}.elf ${IMGDEPLOYDIR}/${IMAGE_LINK_NAME}.elf } -do_image_complete(){ - : +python do_image_complete(){ + from pathlib import Path + import json + + data = { + "taskname": "do_image", + "imagetype": "baremetal-image", + "images": [] + } + + img_deploy_dir = Path(d.getVar("IMGDEPLOYDIR")) + + for child in img_deploy_dir.iterdir(): + if not child.is_file() or child.is_symlink(): + continue + + data["images"].append({ + "filename": child.name, + }) + + with open(d.getVar("IMAGE_FILE_MANIFEST"), "w") as f: + json.dump([data], f) } python do_rootfs(){ @@ -62,6 +85,7 @@ python do_rootfs(){ bb.utils.mkdirhier(sysconfdir) execute_pre_post_process(d, d.getVar('ROOTFS_POSTPROCESS_COMMAND')) + execute_pre_post_process(d, d.getVar("ROOTFS_POSTUNINSTALL_COMMAND")) } @@ -72,6 +96,8 @@ SSTATE_SKIP_CREATION:task-image-complete = '1' do_image_complete[sstate-inputdirs] = "${IMGDEPLOYDIR}" do_image_complete[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}" do_image_complete[stamp-extra-info] = "${MACHINE_ARCH}" +do_image_complete[sstate-plaindirs] += "${IMAGE_FILE_MANIFEST_DIR}" +do_image_complete[dirs] += "${IMAGE_FILE_MANIFEST_DIR}" addtask do_image_complete after do_image before do_build python do_image_complete_setscene () {
Downstream tasks may want to know what image files were written so write out a manifest in do_image_complete. The format of the manifest is the same as the one in image.bbclass Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> --- meta/classes-recipe/baremetal-image.bbclass | 30 +++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-)