meta-virtualization.lists.yoctoproject.org archive mirror
 help / color / mirror / Atom feed
From: Joshua Watt <jpewhacker@gmail.com>
To: meta-virtualization@lists.yoctoproject.org
Cc: Joshua Watt <JPEWhacker@gmail.com>
Subject: [meta-virtualization][PATCH] classes/image-oci-umoci: Replace ":" in image file name
Date: Wed,  4 Oct 2023 10:02:12 -0600	[thread overview]
Message-ID: <20231004160212.3574826-1-JPEWhacker@gmail.com> (raw)

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>
---
 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



             reply	other threads:[~2023-10-04 16:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04 16:02 Joshua Watt [this message]
2023-10-16 18:06 ` [meta-virtualization][PATCH] classes/image-oci-umoci: Replace ":" in image file name Bruce Ashfield
2023-10-16 18:35   ` Joshua Watt
2023-10-24 18:59     ` Bruce Ashfield

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231004160212.3574826-1-JPEWhacker@gmail.com \
    --to=jpewhacker@gmail.com \
    --cc=meta-virtualization@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).