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 <jpewhac...@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

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#8335): 
https://lists.yoctoproject.org/g/meta-virtualization/message/8335
Mute This Topic: https://lists.yoctoproject.org/mt/101756743/21656
Group Owner: meta-virtualization+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to