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][RFC] image-oci-umoci: Set image name and tag
Date: Wed,  4 Oct 2023 08:54:33 -0600	[thread overview]
Message-ID: <20231004145433.3544915-1-JPEWhacker@gmail.com> (raw)

umoci treats the --image parameter as <DIRECTORY>:<NAME>, where the OCI
spec ref.name for the image it set to <NAME>. Therefore, if the
intention is for the ref.name to be in the format <IMAGE_NAME>:<TAG> (as
is expected by e.g. `podman load`, then the complete argument that is
passed to umoci must be `--image <DIRECTORY>:<IMAGE_NAME>:<TAG>`

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 classes/image-oci-umoci.inc | 52 +++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/classes/image-oci-umoci.inc b/classes/image-oci-umoci.inc
index 58e4668..a58cb4c 100644
--- a/classes/image-oci-umoci.inc
+++ b/classes/image-oci-umoci.inc
@@ -35,14 +35,16 @@ IMAGE_CMD:oci() {
     fi
 
     if [ -z "${OCI_IMAGE_TAG}" ]; then
-	OCI_IMAGE_TAG="initial-tag"
-    fi
+	image_spec="$image_name:${IMAGE_BASENAME}:initial-tag"
+    else
+	image_spec="$image_name:${IMAGE_BASENAME}:${OCI_IMAGE_TAG}"
+   fi
 
     if [ -n "$new_image" ]; then
 	bbdebug 1 "OCI: umoci init --layout $image_name"
 	umoci init --layout $image_name
-	umoci new --image $image_name:${OCI_IMAGE_TAG}
-	umoci unpack --rootless --image $image_name:${OCI_IMAGE_TAG} $image_bundle_name
+	umoci new --image $image_spec
+	umoci unpack --rootless --image $image_spec $image_bundle_name
     else
 	# todo: create a different tag, after checking if the passed one exists
 	true
@@ -52,58 +54,58 @@ IMAGE_CMD:oci() {
     bbdebug 1 "OCI: cp -r ${IMAGE_ROOTFS}/* $image_bundle_name/rootfs/"
     cp -r ${IMAGE_ROOTFS}/* $image_bundle_name/rootfs
 
-    bbdebug 1 "OCI: umoci repack --image $image_name:${OCI_IMAGE_TAG} $image_bundle_name"
-    umoci repack --image $image_name:${OCI_IMAGE_TAG} $image_bundle_name
+    bbdebug 1 "OCI: umoci repack --image $image_spec $image_bundle_name"
+    umoci repack --image $image_spec $image_bundle_name
 
     bbdebug 1 "OCI: configuring image"
     if [ -n "${OCI_IMAGE_LABELS}" ]; then
 	for l in ${OCI_IMAGE_LABELS}; do
-	    bbdebug 1 "OCI: umoci config --image $image_name:${OCI_IMAGE_TAG} --config.label $l"
-	    umoci config --image $image_name:${OCI_IMAGE_TAG} --config.label $l
+	    bbdebug 1 "OCI: umoci config --image $image_spec --config.label $l"
+	    umoci config --image $image_spec --config.label $l
 	done
     fi
     if [ -n "${OCI_IMAGE_ENV_VARS}" ]; then
 	for l in ${OCI_IMAGE_ENV_VARS}; do
-	    bbdebug 1 "umoci config --image $image_name:${OCI_IMAGE_TAG} --config.env $l"
-	    umoci config --image $image_name:${OCI_IMAGE_TAG} --config.env $l
+	    bbdebug 1 "umoci config --image $image_spec --config.env $l"
+	    umoci config --image $image_spec --config.env $l
 	done
     fi
     if [ -n "${OCI_IMAGE_PORTS}" ]; then
 	for l in ${OCI_IMAGE_PORTS}; do
-	    bbdebug 1 "umoci config --image $image_name:${OCI_IMAGE_TAG} --config.exposedports $l"
-	    umoci config --image $image_name:${OCI_IMAGE_TAG} --config.exposedports $l
+	    bbdebug 1 "umoci config --image $image_spec --config.exposedports $l"
+	    umoci config --image $image_spec --config.exposedports $l
 	done
     fi
     if [ -n "${OCI_IMAGE_RUNTIME_UID}" ]; then
-	bbdebug 1 "umoci config --image $image_name:${OCI_IMAGE_TAG}  --config.user ${OCI_IMAGE_RUNTIME_UID}"
-	umoci config --image $image_name:${OCI_IMAGE_TAG} --config.user ${OCI_IMAGE_RUNTIME_UID}
+	bbdebug 1 "umoci config --image $image_spec  --config.user ${OCI_IMAGE_RUNTIME_UID}"
+	umoci config --image $image_spec --config.user ${OCI_IMAGE_RUNTIME_UID}
     fi
     if [ -n "${OCI_IMAGE_WORKINGDIR}" ]; then
-	bbdebug 1 "umoci config --image $image_name:${OCI_IMAGE_TAG}  --config.workingdir ${OCI_IMAGE_WORKINGDIR}"
-	umoci config --image $image_name:${OCI_IMAGE_TAG} --config.workingdir ${OCI_IMAGE_WORKINGDIR}
+	bbdebug 1 "umoci config --image $image_spec  --config.workingdir ${OCI_IMAGE_WORKINGDIR}"
+	umoci config --image $image_spec --config.workingdir ${OCI_IMAGE_WORKINGDIR}
     fi
     if [ -n "${OCI_IMAGE_STOPSIGNAL}" ]; then
-	bbdebug 1 "umoci config --image $image_name:${OCI_IMAGE_TAG}  --config.stopsignal ${OCI_IMAGE_STOPSIGNAL}"
-	umoci config --image $image_name:${OCI_IMAGE_TAG} --config.stopsignal ${OCI_IMAGE_STOPSIGNAL}
+	bbdebug 1 "umoci config --image $image_spec  --config.stopsignal ${OCI_IMAGE_STOPSIGNAL}"
+	umoci config --image $image_spec --config.stopsignal ${OCI_IMAGE_STOPSIGNAL}
     fi
     if [ -n "${OCI_IMAGE_OS}" ]; then
-	bbdebug 1 "umoci config --image $image_name:${OCI_IMAGE_TAG}  --os ${OCI_IMAGE_OS}"
-	umoci config --image $image_name:${OCI_IMAGE_TAG} --os ${OCI_IMAGE_OS}
+	bbdebug 1 "umoci config --image $image_spec  --os ${OCI_IMAGE_OS}"
+	umoci config --image $image_spec --os ${OCI_IMAGE_OS}
     fi
 
-    bbdebug 1 "umoci config --image $image_name:${OCI_IMAGE_TAG}  --architecture ${OCI_IMAGE_ARCH}"
-    umoci config --image $image_name:${OCI_IMAGE_TAG} --architecture ${OCI_IMAGE_ARCH}
+    bbdebug 1 "umoci config --image $image_spec  --architecture ${OCI_IMAGE_ARCH}"
+    umoci config --image $image_spec --architecture ${OCI_IMAGE_ARCH}
     # NOTE: umoci doesn't currently expose setting the architecture variant,
     #       so if you need it use sloci instead
     if [ -n "${OCI_IMAGE_SUBARCH}" ]; then
 	bbnote "OCI: image subarch is set to: ${OCI_IMAGE_SUBARCH}, but umoci does not"
 	bbnote "     expose variants. use sloci instead if this is important"
     fi
-    umoci config --image $image_name:${OCI_IMAGE_TAG} --config.entrypoint ${OCI_IMAGE_ENTRYPOINT}
+    umoci config --image $image_spec --config.entrypoint ${OCI_IMAGE_ENTRYPOINT}
     if [ -n "${OCI_IMAGE_ENTRYPOINT_ARGS}" ]; then
-	umoci config --image $image_name:${OCI_IMAGE_TAG} --config.cmd "${OCI_IMAGE_ENTRYPOINT_ARGS}"
+	umoci config --image $image_spec --config.cmd "${OCI_IMAGE_ENTRYPOINT_ARGS}"
     fi
-    umoci config --image $image_name:${OCI_IMAGE_TAG} --author ${OCI_IMAGE_AUTHOR_EMAIL}
+    umoci config --image $image_spec --author ${OCI_IMAGE_AUTHOR_EMAIL}
 
     # make a tar version of the image direcotry
     #  1) image_name.tar: compatible with oci tar format, blobs and rootfs
-- 
2.34.1



             reply	other threads:[~2023-10-04 14:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04 14:54 Joshua Watt [this message]
2023-10-16 18:04 ` [meta-virtualization][RFC] image-oci-umoci: Set image name and tag Bruce Ashfield
2023-10-16 19:33   ` Joshua Watt
2023-10-24 18:58     ` Bruce Ashfield
2023-10-27 15:25       ` Joshua Watt
2023-10-27 19:19         ` 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=20231004145433.3544915-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).