public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] imagetypes_container: Enable customization of CMD and ENTRYPOINT
@ 2025-01-06 15:41 'Jan Kiszka' via isar-users
  2025-01-16  7:01 ` Uladzimir Bely
  0 siblings, 1 reply; 2+ messages in thread
From: 'Jan Kiszka' via isar-users @ 2025-01-06 15:41 UTC (permalink / raw)
  To: isar-users; +Cc: Cirujano-Cuesta, Silvano

From: Jan Kiszka <jan.kiszka@siemens.com>

Enable recipes to define their own CMD value and also ENTRYPOINT. This
permits to build more commonly useful containers.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 meta/classes/imagetypes_container.bbclass | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/meta/classes/imagetypes_container.bbclass b/meta/classes/imagetypes_container.bbclass
index 862ce197..1a6f3669 100644
--- a/meta/classes/imagetypes_container.bbclass
+++ b/meta/classes/imagetypes_container.bbclass
@@ -1,5 +1,5 @@
 # This software is a part of ISAR.
-# Copyright (C) Siemens AG, 2021
+# Copyright (C) Siemens AG, 2021-2025
 #
 # SPDX-License-Identifier: MIT
 #
@@ -11,6 +11,8 @@ USING_CONTAINER = "${@bb.utils.contains_any('IMAGE_BASETYPES', d.getVar('CONTAIN
 
 CONTAINER_IMAGE_NAME ?= "${PN}-${DISTRO}-${DISTRO_ARCH}"
 CONTAINER_IMAGE_TAG ?= "${PV}-${PR}"
+CONTAINER_IMAGE_CMD ?= "/bin/dash"
+CONTAINER_IMAGE_ENTRYPOINT ?= ""
 
 python() {
     if not bb.utils.to_boolean(d.getVar('USING_CONTAINER')):
@@ -24,7 +26,8 @@ python() {
 }
 
 do_containerize() {
-    local cmd="/bin/dash"
+    local cmd="${CONTAINER_IMAGE_CMD}"
+    local entrypoint="${CONTAINER_IMAGE_ENTRYPOINT}"
     local empty_tag="empty"
     local tag="${CONTAINER_IMAGE_TAG}"
     local oci_img_dir="${WORKDIR}/oci-image"
@@ -35,8 +38,14 @@ do_containerize() {
     sudo rm -rf "${oci_img_dir}" "${oci_img_dir}_unpacked"
     sudo umoci init --layout "${oci_img_dir}"
     sudo umoci new --image "${oci_img_dir}:${empty_tag}"
-    sudo umoci config --image "${oci_img_dir}:${empty_tag}" \
-        --config.cmd="${cmd}"
+    if [ -n "${cmd}" ]; then
+        sudo umoci config --image "${oci_img_dir}:${empty_tag}" \
+            --config.cmd="${cmd}"
+    fi
+    if [ -n "${entrypoint}" ]; then
+        sudo umoci config --image "${oci_img_dir}:${empty_tag}" \
+            --config.entrypoint="${entrypoint}"
+    fi
     sudo umoci unpack --image "${oci_img_dir}:${empty_tag}" \
         "${oci_img_dir}_unpacked"
 
-- 
2.43.0

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/9c383301-0a7c-471a-9d6d-454fe3a0be16%40siemens.com.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] imagetypes_container: Enable customization of CMD and ENTRYPOINT
  2025-01-06 15:41 [PATCH] imagetypes_container: Enable customization of CMD and ENTRYPOINT 'Jan Kiszka' via isar-users
@ 2025-01-16  7:01 ` Uladzimir Bely
  0 siblings, 0 replies; 2+ messages in thread
From: Uladzimir Bely @ 2025-01-16  7:01 UTC (permalink / raw)
  To: Jan Kiszka, isar-users

On Mon, 2025-01-06 at 16:41 +0100, 'Jan Kiszka' via isar-users wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> Enable recipes to define their own CMD value and also ENTRYPOINT.
> This
> permits to build more commonly useful containers.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  meta/classes/imagetypes_container.bbclass | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/meta/classes/imagetypes_container.bbclass
> b/meta/classes/imagetypes_container.bbclass
> index 862ce197..1a6f3669 100644
> --- a/meta/classes/imagetypes_container.bbclass
> +++ b/meta/classes/imagetypes_container.bbclass
> @@ -1,5 +1,5 @@
>  # This software is a part of ISAR.
> -# Copyright (C) Siemens AG, 2021
> +# Copyright (C) Siemens AG, 2021-2025
>  #
>  # SPDX-License-Identifier: MIT
>  #
> @@ -11,6 +11,8 @@ USING_CONTAINER =
> "${@bb.utils.contains_any('IMAGE_BASETYPES', d.getVar('CONTAIN
>  
>  CONTAINER_IMAGE_NAME ?= "${PN}-${DISTRO}-${DISTRO_ARCH}"
>  CONTAINER_IMAGE_TAG ?= "${PV}-${PR}"
> +CONTAINER_IMAGE_CMD ?= "/bin/dash"
> +CONTAINER_IMAGE_ENTRYPOINT ?= ""
>  
>  python() {
>      if not bb.utils.to_boolean(d.getVar('USING_CONTAINER')):
> @@ -24,7 +26,8 @@ python() {
>  }
>  
>  do_containerize() {
> -    local cmd="/bin/dash"
> +    local cmd="${CONTAINER_IMAGE_CMD}"
> +    local entrypoint="${CONTAINER_IMAGE_ENTRYPOINT}"
>      local empty_tag="empty"
>      local tag="${CONTAINER_IMAGE_TAG}"
>      local oci_img_dir="${WORKDIR}/oci-image"
> @@ -35,8 +38,14 @@ do_containerize() {
>      sudo rm -rf "${oci_img_dir}" "${oci_img_dir}_unpacked"
>      sudo umoci init --layout "${oci_img_dir}"
>      sudo umoci new --image "${oci_img_dir}:${empty_tag}"
> -    sudo umoci config --image "${oci_img_dir}:${empty_tag}" \
> -        --config.cmd="${cmd}"
> +    if [ -n "${cmd}" ]; then
> +        sudo umoci config --image "${oci_img_dir}:${empty_tag}" \
> +            --config.cmd="${cmd}"
> +    fi
> +    if [ -n "${entrypoint}" ]; then
> +        sudo umoci config --image "${oci_img_dir}:${empty_tag}" \
> +            --config.entrypoint="${entrypoint}"
> +    fi
>      sudo umoci unpack --image "${oci_img_dir}:${empty_tag}" \
>          "${oci_img_dir}_unpacked"
>  
> -- 
> 2.43.0
> 

Applied to next, thanks.

-- 
Best regards,
Uladzimir.

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/4ed31e979ba932719cf9131b759e579176abd09f.camel%40ilbers.de.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-16  7:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-06 15:41 [PATCH] imagetypes_container: Enable customization of CMD and ENTRYPOINT 'Jan Kiszka' via isar-users
2025-01-16  7:01 ` Uladzimir Bely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox