classes/image-oci-umoci: Replace ":" in image file name

The OCI_IMAGE_TAG variable can contain a ":" if the user wants to give
the image a name and a tag, as in:

    OCI_IMAGE_TAG = "${IMAGE_BASENAME}:latest"

However, while this is valid for tag name, the ":" is illegal in OCI
image file names so replace it with "_" when naming the symlinks

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
This commit is contained in:
Joshua Watt 2023-10-04 10:02:12 -06:00 committed by Bruce Ashfield
parent d1d50f9861
commit 4275f25388

View File

@ -106,6 +106,10 @@ IMAGE_CMD:oci() {
fi fi
umoci config --image $image_name:${OCI_IMAGE_TAG} --author ${OCI_IMAGE_AUTHOR_EMAIL} umoci config --image $image_name:${OCI_IMAGE_TAG} --author ${OCI_IMAGE_AUTHOR_EMAIL}
# OCI_IMAGE_TAG may contain ":", but these are not allowed in OCI file
# names so replace them
image_tag="${@d.getVar("OCI_IMAGE_TAG").replace(":", "_")}"
# make a tar version of the image direcotry # make a tar version of the image direcotry
# 1) image_name.tar: compatible with oci tar format, blobs and rootfs # 1) image_name.tar: compatible with oci tar format, blobs and rootfs
# are at the top level. Can load directly from something like podman # are at the top level. Can load directly from something like podman
@ -119,13 +123,13 @@ IMAGE_CMD:oci() {
tar -cf "$image_name-dir.tar" "$image_name" tar -cf "$image_name-dir.tar" "$image_name"
# create a convenience symlink # create a convenience symlink
ln -sf "$image_name.tar" "${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci.tar" ln -sf "$image_name.tar" "${IMAGE_BASENAME}-$image_tag-oci.tar"
ln -sf "$image_name-dir.tar" "${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci-dir.tar" ln -sf "$image_name-dir.tar" "${IMAGE_BASENAME}-$image_tag-oci-dir.tar"
fi fi
# We could make this optional, since the bundle is directly runnable via runc # We could make this optional, since the bundle is directly runnable via runc
rm -rf $image_bundle_name rm -rf $image_bundle_name
# This is the OCI image directory, which is technically the "image" as specified # This is the OCI image directory, which is technically the "image" as specified
ln -sf $image_name ${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci ln -sf $image_name ${IMAGE_BASENAME}-$image_tag-oci
} }