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 <[email protected]>
---
 classes/image-oci-umoci.inc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/classes/image-oci-umoci.inc b/classes/image-oci-umoci.inc
index 58e4668..adca6c1 100644
--- a/classes/image-oci-umoci.inc
+++ b/classes/image-oci-umoci.inc
@@ -105,6 +105,10 @@ IMAGE_CMD:oci() {
     fi
     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
     #  1) image_name.tar: compatible with oci tar format, blobs and rootfs
     #     are at the top level. Can load directly from something like podman
@@ -118,13 +122,13 @@ IMAGE_CMD:oci() {
        tar -cf "$image_name-dir.tar" "$image_name"
 
        # create a convenience symlink
-       ln -sf "$image_name.tar" "${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci.tar"
-       ln -sf "$image_name-dir.tar" 
"${IMAGE_BASENAME}-${OCI_IMAGE_TAG}-oci-dir.tar"
+       ln -sf "$image_name.tar" "${IMAGE_BASENAME}-$image_tag-oci.tar"
+       ln -sf "$image_name-dir.tar" "${IMAGE_BASENAME}-$image_tag-oci-dir.tar"
     fi
 
     # We could make this optional, since the bundle is directly runnable via 
runc
     rm -rf $image_bundle_name
 
     # 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
 }
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#8336): 
https://lists.yoctoproject.org/g/meta-virtualization/message/8336
Mute This Topic: https://lists.yoctoproject.org/mt/101758365/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to