public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: "[ext] Silvano Cirujano Cuesta"
	<silvano.cirujano-cuesta@siemens.com>,
	Henning Schild <henning.schild@siemens.com>
Cc: isar-users@googlegroups.com
Subject: Re: [RFC PATCH 1/2] sdk: support creation of container image
Date: Tue, 12 Jan 2021 19:04:46 +0100	[thread overview]
Message-ID: <3d1a0d3d-a56f-1a69-ed3d-724db91f4a08@siemens.com> (raw)
In-Reply-To: <75752029-677f-c07c-fb93-c6754ff1bad3@siemens.com>

On 12.01.21 18:54, [ext] Silvano Cirujano Cuesta wrote:
> 
> On 12/01/2021 18:36, Henning Schild wrote:
>> Am Tue, 12 Jan 2021 11:33:37 +0100
>> schrieb "[ext] Silvano Cirujano Cuesta"
>> <silvano.cirujano-cuesta@siemens.com>:
>>
>>> Extend task "populate_sdk" to support the creation of a container
>>> image containing the SDK.
>>>
>>> Signed-off-by: Silvano Cirujano Cuesta
>>> <silvano.cirujano-cuesta@siemens.com> ---
>>>  meta/classes/image-sdk-extension.bbclass | 99
>>> ++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 7
>>> deletions(-)
>>>
>>> diff --git a/meta/classes/image-sdk-extension.bbclass
>>> b/meta/classes/image-sdk-extension.bbclass index a8c708a..9317256
>>> 100644 --- a/meta/classes/image-sdk-extension.bbclass
>>> +++ b/meta/classes/image-sdk-extension.bbclass
>>> @@ -6,10 +6,77 @@
>>>  # This class extends the image.bbclass to supply the creation of a
>>> sdk 
>>>  SDK_INCLUDE_ISAR_APT ?= "0"
>>> +SDK_GENERATE_FORMATS = "${@d.getVar("SDK_FORMATS", "tar")}"
>>> +
>>> +sdk_tar() {
>>> +    # Copy mount_chroot.sh for convenience
>>> +    sudo cp ${SCRIPTSDIR}/mount_chroot.sh ${SDKCHROOT_DIR}
>>> +
>>> +    # Create SDK archive
>>> +    cd -P ${SDKCHROOT_DIR}/..
>>> +    sudo tar --transform="s|^rootfs|sdk-${DISTRO}-${DISTRO_ARCH}|" \
>>> +        -c rootfs | xz -T0 >
>>> ${DEPLOY_DIR_IMAGE}/sdk-${DISTRO}-${DISTRO_ARCH}.tar.xz +}
>>> +
>>> +sdk_container_images() {
>>> +    local cmd="/bin/dash"
>>> +    local empty_tag="empty"
>>> +    local full_tag="latest"
>>> +    local oci_img_dir="${WORKDIR}/oci-image"
>>> +    local sdk_container_formats="$1"
>>> +
>>> +    # prepare OCI container image skeleton
>>> +    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}"
>>> +    sudo umoci unpack --image "${oci_img_dir}:${empty_tag}" \
>>> +        "${oci_img_dir}_unpacked"
>>> +
>>> +    # add SDK root filesystem as the flesh of the skeleton
>>> +    sudo cp -a "${SDKCHROOT_DIR}"/* "${oci_img_dir}_unpacked/rootfs/"
>>> +
>>> +    # pack container image
>>> +    sudo umoci repack --image "${oci_img_dir}:${full_tag}" \
>>> +        "${oci_img_dir}_unpacked"
>>> +    sudo umoci remove --image "${oci_img_dir}:${empty_tag}"
>>> +    sudo rm -rf "${oci_img_dir}_unpacked"
>>> +
>>> +    # no root needed anymore
>>> +    sudo chown --recursive $(id -u):$(id -g) "${oci_img_dir}"
>>> +
>>> +    # convert the OCI container image to the desired format
>>> +    sdk_id="sdk-${DISTRO}-${DISTRO_ARCH}"
>>> +    image_name="isar-${sdk_id}"
>>> +    image_archive="${DEPLOY_DIR_IMAGE}/${sdk_id}-${sdk_format}.tar"
>>> +    for sdk_format in ${sdk_container_formats} ; do
>>> +        case "${sdk_format}" in
>>> +            "docker-archive" | "oci-archive")
>>> +                if [ "${sdk_format}" = "oci-archive" ] ; then
>>> +                    target="${sdk_format}:${image_archive}:latest"
>>> +                else
>>> +
>>> target="${sdk_format}:${image_archive}:${image_name}:latest"
>>> +                fi
>>> +                skopeo --insecure-policy copy \
>>> +                    "oci:${oci_img_dir}:${full_tag}" "${target}"
>>> +                xz -T0 "${image_archive}"
>>> +                ;;
>>> +            "oci")
>>> +                tar --create --xz --directory "${oci_img_dir}" \
>>> +                    --file "${image_archive}.xz" .
>>> +                ;;
>>> +            "docker-daemon" | "containers-storage")
>>> +                skopeo --insecure-policy copy \
>>> +                    "oci:${oci_img_dir}:${full_tag}" \
>>> +                    "${sdk_format}:${image_name}:latest"
>>> +                ;;
>> Jan proposed to make the SDK class wider than x86(64). How is this
>> going to affect docker? (i intentionally use "docker" as synonym for all
>> sorts of ...)
> I intentionally use container instead of Docker where it's not docker-only.
>>
>> The proposed changes should be tested for riscv and arm64 as well.
> 
> Do you mean hosts or targets? Assuming you're talking about RISC-V and ARM64 targets...
> 
> This functionality is merely packaging the cross-buildchain that up-to-now could be generated with "populate_sdk", whatever was supported should be supported by this patch.
> 
> Of course, the changes should be tested for different combinations. Feel free to test it for those architectures, as long as we are in the discussion round I'm fine with the "whatever was supported should be supported by this patch" that I've written above. I'd really test if only before contributing the final patches for integration.
> 

Agreed. I don't see any arch-specific blocker here. Both skopeo and
umoci are available for our "new" host arch, arm64. RISC-V is still no
official Debian target, thus may break for any reason on any day.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux

  reply	other threads:[~2021-01-12 18:04 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 10:33 [RFC PATCH 0/2] support generation of sdk container images Silvano Cirujano Cuesta
2021-01-12 10:33 ` [RFC PATCH 1/2] sdk: support creation of container image Silvano Cirujano Cuesta
2021-01-12 11:36   ` Henning Schild
2021-01-12 11:50     ` Silvano Cirujano Cuesta
2021-01-12 14:50       ` Jan Kiszka
2021-01-12 17:08         ` Silvano Cirujano Cuesta
2021-01-12 17:36   ` Henning Schild
2021-01-12 17:54     ` Silvano Cirujano Cuesta
2021-01-12 18:04       ` Jan Kiszka [this message]
2021-01-12 20:46         ` Silvano Cirujano Cuesta
2021-01-12 10:33 ` [RFC PATCH 2/2] docs: document usage of sdk container images Silvano Cirujano Cuesta
2021-01-12 11:40   ` Henning Schild
2021-01-12 12:03     ` Silvano Cirujano Cuesta
2021-01-12 12:18       ` Henning Schild
2021-01-12 14:52         ` Silvano Cirujano Cuesta
2021-01-12 14:56           ` Jan Kiszka
2021-01-12 15:12             ` Silvano Cirujano Cuesta
2021-01-12 15:14               ` Jan Kiszka
2021-01-12 15:11           ` Henning Schild
2021-01-12 16:26             ` Silvano Cirujano Cuesta
2021-01-14 13:56 ` [RFC PATCH 0/2] support generation " Silvano Cirujano Cuesta
2021-01-14 18:32   ` Henning Schild
2021-01-15  8:11     ` Silvano Cirujano Cuesta
2021-01-15  7:09   ` Jan Kiszka
2021-01-15  8:16     ` Silvano Cirujano Cuesta

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=3d1a0d3d-a56f-1a69-ed3d-724db91f4a08@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=henning.schild@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=silvano.cirujano-cuesta@siemens.com \
    /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