The entrypoint to a container is actually an array of the executable to
run and the arguments to pass to it. It is useful to be able to specify
the entire list as the entrypoint when creating containers so that
then entrypoint can be encoded with argument, e.g.

    ENTRYPOINT ["/usr/bin/python3", "my-script"]

The current way that image-oci-umoci.bbclass handles this is equivalent
to:

    ENTRYPOINT ["/usr/bin/python3"]
    CMD ["my-script"]

But this is undesirable as it means if the user passes arguments when
running the container, it will override the "my-script" argument and the
arguments will instead get passed to the python interpreter, which may
not be desired.

Instead, pass all the entry point arguments to umoci in a single
invocation using multiple --config.entrypoint arguments, which correctly
make the list as described above. The entire ENTRYPOINT list will start
with OCI_IMAGE_ENTRYPOINT, then have OCI_IMAGE_ENRTYPOINT_ARGS split by
spaces concatenated after it.

Signed-off-by: Joshua Watt <[email protected]>
---
 classes/image-oci-umoci.inc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/classes/image-oci-umoci.inc b/classes/image-oci-umoci.inc
index 58e4668..245dae5 100644
--- a/classes/image-oci-umoci.inc
+++ b/classes/image-oci-umoci.inc
@@ -99,10 +99,10 @@ IMAGE_CMD:oci() {
        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}
-    if [ -n "${OCI_IMAGE_ENTRYPOINT_ARGS}" ]; then
-       umoci config --image $image_name:${OCI_IMAGE_TAG} --config.cmd 
"${OCI_IMAGE_ENTRYPOINT_ARGS}"
-    fi
+    umoci config --image $image_name:${OCI_IMAGE_TAG} \
+       --config.entrypoint "${OCI_IMAGE_ENTRYPOINT}" \
+       ${@" ".join("--config.entrypoint %s" % s for s in 
d.getVar("OCI_IMAGE_ENTRYPOINT_ARGS").split())}
+
     umoci config --image $image_name:${OCI_IMAGE_TAG} --author 
${OCI_IMAGE_AUTHOR_EMAIL}
 
     # make a tar version of the image direcotry
-- 
2.34.1

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

Reply via email to