From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6989998000320806912 X-Received: by 2002:a5d:4f8b:: with SMTP id d11mr6036208wru.351.1628179279036; Thu, 05 Aug 2021 09:01:19 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a7b:cc8a:: with SMTP id p10ls5241935wma.1.canary-gmail; Thu, 05 Aug 2021 09:01:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuGj26t27JXG+WvkBbImMtitRQpHjHKR9loVi99f/deRMXq8Iw7lI+0qYLcqjl9CNWTWup X-Received: by 2002:a05:600c:3223:: with SMTP id r35mr15561510wmp.145.1628179278038; Thu, 05 Aug 2021 09:01:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628179278; cv=none; d=google.com; s=arc-20160816; b=LDRpps3RhgUR7UUpZ7iGzmNzWH6O/mEBubRlacos5ScC+n6+ATNwaaFCHJRAlytM9p bag0dpUIKO1NdVfpWpFGUQd9gMUL7ZQ8YePWAhfV4huOsUaCcCzXU/Z9taNEVuuhyitw jwUPjFy3EWtcHkraZ2Nmg/DAoRn0ryxquZx0lWf5kXW2OcmgdPsapDiWoC5UpTbNRtNF 0xgKMuU5sBxggdeWmu57UcP2SBxSzaqoyKqa57id1SxSp/8JEgKFOuzLywjG5zfKpTwl Zq8VuUx/dsqDTB7BgR14HgIe7adVNou1VnTECEfD4Sqv1oqH9zDrVtMlH8+4x/fNQWLf D+kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date; bh=xz+ju1GODq38lWcMh9cO+k1oBkWqT0OpWHhz/gY41mc=; b=hGYC6RZ6rVX0jXFPrmKJNL+3AduRvYs9E/KAKrHuBmQZZ4z1jOzWk0wzi1jbq59Ep9 /IivcevzOMcsOyNzmmLoWrZSvub2P+uV6W1GkpeAgy0D6M5Pqj3XcUY2P6Ba9QbFcZIi cMxwunhEWqJnI8fMu5SzZ22+fU/bmvr+nAeiMxObGX52nWuUjff0SUjyfGyI1wZYKjRg FhK4Du7B8AwRpBIpwl7m3j1C4OgrN9rx8R3Mov8Ib+qSLL1wCubVK9+oVJeATe7J1SgC JIq68WIK67NdhAZcO1GYCZqFTcgxmJy2IkMepjsezQKHahy0TzeP/zg3meoWb4TigfVt /SHQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=henning.schild@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from lizzard.sbs.de (lizzard.sbs.de. [194.138.37.39]) by gmr-mx.google.com with ESMTPS id j20si303900wms.1.2021.08.05.09.01.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Aug 2021 09:01:18 -0700 (PDT) Received-SPF: pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) client-ip=194.138.37.39; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=henning.schild@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id 175G1Hcn020341 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 5 Aug 2021 18:01:17 +0200 Received: from md1za8fc.ad001.siemens.net ([139.25.0.59]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 175G1HuG026334; Thu, 5 Aug 2021 18:01:17 +0200 Date: Thu, 5 Aug 2021 18:01:17 +0200 From: Henning Schild To: Silvano Cirujano Cuesta Cc: Subject: Re: [PATCH v3 3/4] classes: allow more control over container image name and tag Message-ID: <20210805180117.1ad15ecb@md1za8fc.ad001.siemens.net> In-Reply-To: References: <20210802115404.22707-1-henning.schild@siemens.com> <20210802115404.22707-4-henning.schild@siemens.com> <20210802151447.6e4e7ded@md1za8fc.ad001.siemens.net> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TUID: Msgv1b8Hy5dl Am Mon, 2 Aug 2021 15:27:58 +0200 schrieb Silvano Cirujano Cuesta : > On 02/08/2021 15:14, Henning Schild wrote: > > Am Mon, 2 Aug 2021 14:26:02 +0200 > > schrieb Silvano Cirujano Cuesta > > : > >> On 02/08/2021 13:54, Henning Schild wrote: > >>> This patch allows more fine-grained control over how the resulting > >>> container will be tagged. Where the default name will be PN > >>> together with DISTRO and ARCH, and tag will be derived from PV > >>> and PR > >>> > >>> Signed-off-by: Henning Schild > >>> --- > >>> RECIPE-API-CHANGELOG.md | 4 ++++ > >>> doc/user_manual.md | 8 ++++---- > >>> meta/classes/container-img.bbclass | 4 +--- > >>> meta/classes/image-container-extension.bbclass | 11 ++++++----- > >>> meta/classes/image-sdk-extension.bbclass | 2 +- > >>> 5 files changed, 16 insertions(+), 13 deletions(-) > >>> > >>> diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md > >>> index 806c2914f13f..d12d30e192a8 100644 > >>> --- a/RECIPE-API-CHANGELOG.md > >>> +++ b/RECIPE-API-CHANGELOG.md > >>> @@ -292,3 +292,7 @@ Migrate your patches so they can be applied > >>> with "git am", or > >>> Kernel image name for arm64 platforms is vmlinux now. Image > >>> format was not changed (uncompressed executable) but now it is > >>> named correctly. + > >>> +### Change default "TARGET_NAME:TAG" when building container > >>> images + > >>> +The "TARGET_NAME" used to be rather static and the TAG was always > >>> "latest", now the values are derived from recipe variables PN, PV, > >>> PR. diff --git a/doc/user_manual.md b/doc/user_manual.md index > >>> cf7dc2fee35e..e5c07bd41fc5 100644 --- a/doc/user_manual.md > >>> +++ b/doc/user_manual.md > >>> @@ -300,14 +300,14 @@ bitbake mc:qemuarm-buster:isar-image-base > >>> - Load the container image into the Docker Daemon > >>> > >>> ``` > >>> -docker load -i > >>> build/tmp/deploy/images/qemuarm/debian-buster-armhf-docker-archive.tar.xz > >>> +docker load -i > >>> build/tmp/deploy/images/qemuarm/isar-image-base-debian-buster-armhf-1.0-r0-docker-archive.tar.xz > >>> ``` > >>> - Run a container using the container image (following commands > >>> starting with `#~:` are to be run in the container) > >>> > >>> ``` > >>> -docker run --rm -ti --volume "$(pwd):/build" > >>> isar-buster-armhf:latest +docker run --rm -ti --volume > >>> "$(pwd):/build" isar-image-base-debian-buster-armhf:1.0-r0 ``` > >>> > >>> --- > >>> @@ -1070,14 +1070,14 @@ bitbake -c do_populate_sdk > >>> mc:qemuarm-buster:isar-image-base > >>> - Load the SDK container image into the Docker Daemon > >>> > >>> ``` > >>> -docker load -i > >>> build/tmp/deploy/images/qemuarm/sdk-debian-buster-armhf-docker-archive.tar.xz > >>> +docker load -i > >>> build/tmp/deploy/images/qemuarm/isar-image-base-debian-buster-armhf-1.0-r0-docker-archive.tar.xz > >>> ``` > >>> - Run a container using the SDK container image (following > >>> commands starting with `#~:` are to be run in the container) > >>> > >>> ``` > >>> -docker run --rm -ti --volume "$(pwd):/build" > >>> isar-sdk-buster-armhf:latest +docker run --rm -ti --volume > >>> "$(pwd):/build" isar-image-base-debian-buster-armhf:1.0-r0 ``` > >>> > >>> - Check that cross toolchains are installed > >>> diff --git a/meta/classes/container-img.bbclass > >>> b/meta/classes/container-img.bbclass index > >>> 79ef3e8d756b..9928a58ef53d 100644 --- > >>> a/meta/classes/container-img.bbclass +++ > >>> b/meta/classes/container-img.bbclass @@ -9,10 +9,8 @@ > >>> do_container_image[stamp-extra-info] = "${DISTRO}-${MACHINE}" > >>> do_container_image[vardeps] += "CONTAINER_FORMATS" > >>> do_container_image(){ > >>> - rootfs_id="${DISTRO}-${DISTRO_ARCH}" > >>> - > >>> bbdebug 1 "Generate container image in these formats: > >>> ${CONTAINER_FORMATS}" > >>> - containerize_rootfs "${IMAGE_ROOTFS}" "${rootfs_id}" > >>> "${CONTAINER_FORMATS}" > >>> + containerize_rootfs "${IMAGE_ROOTFS}" "${CONTAINER_FORMATS}" > >>> } > >>> > >>> addtask container_image before do_image after do_image_tools > >>> diff --git a/meta/classes/image-container-extension.bbclass > >>> b/meta/classes/image-container-extension.bbclass index > >>> 0e70ba9c1405..4f93d30219f9 100644 --- > >>> a/meta/classes/image-container-extension.bbclass +++ > >>> b/meta/classes/image-container-extension.bbclass @@ -6,15 +6,16 @@ > >>> # This class extends the image.bbclass for containerizing the > >>> root filesystem. > >>> CONTAINER_FORMATS ?= "docker-archive" > >>> +CONTAINER_TARGET_NAME ?= "${PN}-${DISTRO}-${DISTRO_ARCH}" > >> > >> In a comment to patch v2 you mentioned your plan to call it > >> "CONTAINER_TARGET_IMAGE". Have you changed your mind or is it just > >> an error? > > > > Oh right. Picked the wrong one. > > > >>> +CONTAINER_TAG ?= "${PV}-${PR}" > >> > >> Although only container images can have tags and not containers, I > >> still find this name misleading for container newbies (and some > >> ISAR maintainers will probably be). Your argument that "docker > >> tag" only uses "TAG" doesn't convince me ;-) > > > > Ok ... at least you give some insights on the other comment. But you > > started the "CONTAINER_" thingy. Can containers (not images) have > > the format docker-archive ? ;) > > You're fully right. Shame on me :-/ > > Do as I say, not as I do ;-P > > > > >> In general I'd say that both "CONTAINER_TARGET_NAME" and > >> "CONTAINER_TAG" should start with the prefix "CONTAINER_IMAGE_". > >> Both the name and the tag are attributes of a container image. > >> > >> Therefore I'd rather use "CONTAINER_IMAGE_NAME" and > >> "CONTAINER_IMAGE_TAG". But since I'm neither a power user nor a > >> power contributor, my opinion might not be that important. > > > > Usage: docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG] > > > > "CONTAINER_IMAGE_" because that is the name of the class ... and > > pretty close to how other classes expose their "configurables" > > except for the weird extension pattern you took over wrong from > > that truly weird SDK. > > > > Which gives me > > > > CONTAINER_IMAGE_FORMATS > > I agree that for consistency you would have to rename this variable. > Even if it breaks the interface, I think it's worth since this > feature is not being widely used yet. > > > CONTAINER_IMAGE_TAG > > CONTAINER_IMAGE_TARGET_IMAGE > > Why CONTAINER_IMAGE_TARGET_IMAGE? Why not CONTAINER_IMAGE_NAME? > "docker tag" needs the "TARGET_" prefix because it needs to > differentiate it from the source image. > > In fact if you look for the nowadays right manpage "man > docker-image-tag" you'll get an even "better" mixture of > "SOURCE_IMAGE", "TARGET_IMAGE" AND "NAME". But at least the > terminology "NAME" and "TAG" appears here clearly defined. Ok ... read this too late for v5. I will take NAME because it is used in that docker manpage .. and it is somewhat appearing here Usage: podman tag IMAGE TARGET_NAME [TARGET_NAME...] So CONTAINER_IMAGE_NAME:CONTAINER_IMAGE_TAG ... before anyone goes and looks it up in oci standards. Henning > Silvano > > > > > While the last one seems pretty silly ... i will still take it > > because is is prefix+suffix following a clear pattern. > > > > Henning > > > >> Silvano > >> > >>> > >>> containerize_rootfs() { > >>> local cmd="/bin/dash" > >>> local empty_tag="empty" > >>> - local tag="latest" > >>> + local tag="${CONTAINER_TAG}" > >>> local oci_img_dir="${WORKDIR}/oci-image" > >>> local rootfs="$1" > >>> - local rootfs_id="$2" > >>> - local container_formats="$3" > >>> + local container_formats="$2" > >>> > >>> # prepare OCI container image skeleton > >>> bbdebug 1 "prepare OCI container image skeleton" > >>> @@ -42,9 +43,9 @@ containerize_rootfs() { > >>> sudo chown --recursive $(id -u):$(id -g) "${oci_img_dir}" > >>> > >>> # convert the OCI container image to the desired format > >>> - image_name="isar-${rootfs_id}" > >>> + image_name="${CONTAINER_TARGET_NAME}" > >>> for image_type in ${CONTAINER_FORMATS} ; do > >>> - > >>> image_archive="${DEPLOY_DIR_IMAGE}/${rootfs_id}-${image_type}.tar" > >>> + > >>> image_archive="${DEPLOY_DIR_IMAGE}/${image_name}-${tag}-${image_type}.tar" > >>> bbdebug 1 "Creating container image type: ${image_type}" case > >>> "${image_type}" in "docker-archive" | "oci-archive") > >>> diff --git a/meta/classes/image-sdk-extension.bbclass > >>> b/meta/classes/image-sdk-extension.bbclass index > >>> 426b92595554..fa15b588068c 100644 --- > >>> a/meta/classes/image-sdk-extension.bbclass +++ > >>> b/meta/classes/image-sdk-extension.bbclass @@ -80,7 +80,7 @@ > >>> do_populate_sdk() { # generate the SDK in all the desired > >>> container formats if [ -n "${sdk_container_formats}" ] ; then > >>> bbnote "Generating SDK container in > >>> ${sdk_container_formats} format" > >>> - containerize_rootfs "${SDKCHROOT_DIR}" > >>> "sdk-${DISTRO}-${DISTRO_ARCH}" "${sdk_container_formats}" > >>> + containerize_rootfs "${SDKCHROOT_DIR}" > >>> "${sdk_container_formats}" fi > >>> } > >>> > >>> > >