From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6931066459248394240 X-Received: by 2002:a1f:9d43:: with SMTP id g64mr15988738vke.16.1614069521337; Tue, 23 Feb 2021 00:38:41 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a67:5d47:: with SMTP id r68ls629005vsb.10.gmail; Tue, 23 Feb 2021 00:38:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWH8HJyBmNXKYs9lGYRU9tTIuirprfcWYJr3WJTrtlHtFrP1FDgnfyzt1/1zcRe2ZOetSQ X-Received: by 2002:a67:808a:: with SMTP id b132mr16039123vsd.8.1614069520762; Tue, 23 Feb 2021 00:38:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614069520; cv=none; d=google.com; s=arc-20160816; b=ZJEdLCt1qptYpBz99tpHFqdnOeMrlI7z19KID2uGgF6gGPu+iOHGOy1aiYNwSSMgTl PnKwla/4A47FxHe/+sfbsYFL6C+LJ1CzBcicfILDY3zXAsqPvkm77z//T7L7gCVqEhgB XAFO+xAtoSd2ODVIhlViwKJoRUCAuTvEgn3YThfFgIM98MZpRIPYM/mnTZssYH8ecH5c v33or+4ouEAwQldZMiaovwnkin6e0mA7FqhXKAO5ski2lPn7d7TLXllI/R1nWPhd76yE LqNnBx1a6EfR3o+3rQp68QbmK5lwe/ytsH43kmIWhlxmPjNYuW2KsDmzuM0Rsq3UG6xK gk5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=WYCYEEarbeA1lerjK1VHJp3RzRkDyUX76x9nIzQ780I=; b=jIjavqwJFmmuSq1lpZ57D26IFVVoHFWZg5HMQ/yWORlla9IUBP1yjNWDpxh/nWmaLM WtUflT2FRQBxRYJ3yYShQyX1KxwwvdEDdbMX+IzOhUg1ju4z6UvJsTQwlT0QM2Vb1usL kfAF2WUs8lCCqtyYlCgsQD7gWd6TEK2887taIjZIuvMkCr6wAgXiAAopYH0rd04WXbEY 3+lExf5nPLEa+zdfH3GU4UlKQT2GSeA4kBwI9N2CzGXZ1C16lLWNP3wXtKxu/XrdFdeF r+ECTev7q/WCaGWpVniBlg3JC/Ko4RqKfxwKXyDpY5gAEecH7q5TSqBbooanKjX6CSsX MYwQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Nf6dxus4; spf=pass (google.com: domain of vijaikumar.kanagarajan@gmail.com designates 2607:f8b0:4864:20::72c as permitted sender) smtp.mailfrom=vijaikumar.kanagarajan@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com. [2607:f8b0:4864:20::72c]) by gmr-mx.google.com with ESMTPS id t23si131680vst.2.2021.02.23.00.38.40 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Feb 2021 00:38:40 -0800 (PST) Received-SPF: pass (google.com: domain of vijaikumar.kanagarajan@gmail.com designates 2607:f8b0:4864:20::72c as permitted sender) client-ip=2607:f8b0:4864:20::72c; Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Nf6dxus4; spf=pass (google.com: domain of vijaikumar.kanagarajan@gmail.com designates 2607:f8b0:4864:20::72c as permitted sender) smtp.mailfrom=vijaikumar.kanagarajan@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: by mail-qk1-x72c.google.com with SMTP id z190so15399712qka.9 for ; Tue, 23 Feb 2021 00:38:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WYCYEEarbeA1lerjK1VHJp3RzRkDyUX76x9nIzQ780I=; b=Nf6dxus44mU3IKh10MtLVKt5Rl7hg3w9Tm738kmqAMpCGa9WM2nIBdXfqw1I2mOzbj hh3fReBRr75/F0fx4xpnXPDt0QnhXqFPhIZMbm6A4d8P9vEK8Ndj6ffH9BkKiIcPksYr uF//+GiwtakUtgOf9cVtrKY2Gj3N61eFb+eM5g61riA7+ReBfyvL9cBkpSh75ug8jUay UOS99NWaNpL+EowWV/IiA9RFmZY5uTsbcWvX94WCtkxNWzYnce1vxre9rGvCOTGCTcOl EBcyuSyswtkNKUoWqbamxZCSnttH0rZeEsL0SZs1r+mbvQ7T3/coQBOotSUeUZDabmEU 5IwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WYCYEEarbeA1lerjK1VHJp3RzRkDyUX76x9nIzQ780I=; b=kTLJvy7xR4uWd+l/iLcw8XB5m2G3EE5dffA9AX669lecaE7/TI8OAk+z9AsyEGsb+8 HTXZTXpKlBCmvS8f23zaSM4yBc5eD2dAYlXh5HZAm4MC6nGtvH7/mX+WknDdQ1z0vvNV l8S4ZavhcSqtbU5wWkHBGLZBmXepZOFJYdZ+AdOCAh0hEK8Og/6yc2yttvVbIyc74jMQ 5uuc5hWYsoLUM/oUXlGD5DmLD42DLkI962nvw5PJ/VIk8FoM5/O4LSJOaG3APbaSs8B6 yENQ9vS8RtxUS4UNgsjeDC6DY2pxTkxUUro40DvyZEv5jlmb/Omy2LDcNSUS+VvSJFQT pSsw== X-Gm-Message-State: AOAM532buAL8iwqlpz1kI3y9y2EasjIg8cjgD/lXWWNzo3MJ1FIe5MJP I9xEcOUufRWiinS+qDJIDdNNRdBFFTCkNRHqUAI= X-Received: by 2002:a37:9c04:: with SMTP id f4mr24563020qke.203.1614069520188; Tue, 23 Feb 2021 00:38:40 -0800 (PST) MIME-Version: 1.0 References: <20210219195719.29037-1-Vijaikumar_Kanagarajan@mentor.com> <20210219195719.29037-3-Vijaikumar_Kanagarajan@mentor.com> <20210220092859.382eeb3a@md1za8fc.ad001.siemens.net> In-Reply-To: <20210220092859.382eeb3a@md1za8fc.ad001.siemens.net> From: vijai kumar Date: Tue, 23 Feb 2021 14:08:29 +0530 Message-ID: Subject: Re: [RFC PATCH 2/2] recipes-core: Add recipe for base-files To: Henning Schild Cc: Vijai Kumar K , isar-users , ibr@radix10.net, Silvano Cirujano Cuesta Content-Type: text/plain; charset="UTF-8" X-TUID: r/31HzMSYk5v On Sat, Feb 20, 2021 at 1:59 PM Henning Schild wrote: > > Am Sat, 20 Feb 2021 01:27:19 +0530 > schrieb Vijai Kumar K : > > > /etc/os-release is a symlink to /usr/lib/os-release and belongs to > > the base-files package. > > > > ISAR has been modifying the /etc/os-release during postprocessing > > to inject custom data onto it. > > > > Since this file belongs to base-files, an update/reinstall of the > > package would overwrite the file with the one provided by base-files. > > To some degree such an update would be right to do so. The BUILD_ID > will for sure be invalidated, other custom fields might still be valid > though. > > > Instead of modifying the contents of /etc/os-release during > > post-processing, provide a modified base-files recipe in ISAR which > > provides the similar changes in os-release. > > I am beginning to wonder if we have to write certain bits to other > files. Bits that need to go into /etc/os-release could be appended with > a hook > See isar-disable-apt-cache, or we use the divert that Silvano proposed. I have not used hooks before, but looks like it might help in our case. > > > Signed-off-by: Vijai Kumar K > > --- > > .../recipes-core/images/isar-image-base.bb | 2 + > > meta/classes/image-postproc-extension.bbclass | 40 -------------- > > meta/classes/image.bbclass | 20 ------- > > meta/recipes-core/base-files/base-files.bb | 6 ++ > > meta/recipes-core/base-files/base-files.inc | 55 > > +++++++++++++++++++ 5 files changed, 63 insertions(+), 60 deletions(-) > > create mode 100644 meta/recipes-core/base-files/base-files.bb > > create mode 100644 meta/recipes-core/base-files/base-files.inc > > > > diff --git a/meta-isar/recipes-core/images/isar-image-base.bb > > b/meta-isar/recipes-core/images/isar-image-base.bb index > > b381d85..4aa7e66 100644 --- > > a/meta-isar/recipes-core/images/isar-image-base.bb +++ > > b/meta-isar/recipes-core/images/isar-image-base.bb @@ -11,3 +11,5 @@ > > LIC_FILES_CHKSUM = > > "file://${LAYERDIR_core}/licenses/COPYING.GPLv2;md5=751419260 PV = > > "1.0" inherit image > > + > > +IMAGE_INSTALL += "base-files" > > diff --git a/meta/classes/image-postproc-extension.bbclass > > b/meta/classes/image-postproc-extension.bbclass index > > 3f00c21..22c6a95 100644 --- > > a/meta/classes/image-postproc-extension.bbclass +++ > > b/meta/classes/image-postproc-extension.bbclass @@ -1,38 +1,6 @@ > > # This software is a part of ISAR. > > # Copyright (C) Siemens AG, 2019 > > > > -update_etc_os_release() { > > - OS_RELEASE_BUILD_ID="" > > - OS_RELEASE_VARIANT="" > > - OS_RELEASE_VARIANT_VERSION="" > > - while true; do > > - case "$1" in > > - --build-id) OS_RELEASE_BUILD_ID=$2; shift ;; > > - --variant) OS_RELEASE_VARIANT=$2; shift ;; > > - --version) OS_RELEASE_VARIANT_VERSION=$2; shift ;; > > - -*) bbfatal "$0: invalid option specified: $1" ;; > > - *) break ;; > > - esac > > - shift > > - done > > - > > - if [ -n "${OS_RELEASE_BUILD_ID}" ]; then > > - sudo sed -i '/^BUILD_ID=.*/d' > > '${IMAGE_ROOTFS}/etc/os-release' > > - echo "BUILD_ID=\"${OS_RELEASE_BUILD_ID}\"" | \ > > - sudo tee -a '${IMAGE_ROOTFS}/etc/os-release' > > - fi > > - if [ -n "${OS_RELEASE_VARIANT}" ]; then > > - sudo sed -i '/^VARIANT=.*/d' '${IMAGE_ROOTFS}/etc/os-release' > > - echo "VARIANT=\"${OS_RELEASE_VARIANT}\"" | \ > > - sudo tee -a '${IMAGE_ROOTFS}/etc/os-release' > > - fi > > - if [ -n "${OS_RELEASE_VARIANT_VERSION}" ]; then > > - sudo sed -i '/^ISAR_IMAGE_VERSION=.*/d' > > '${IMAGE_ROOTFS}/etc/os-release' > > - echo "VARIANT_VERSION=\"${PV}\"" | \ > > - sudo tee -a '${IMAGE_ROOTFS}/etc/os-release' > > - fi > > -} > > This is in the image for a good reason, it can not be part of a > package, otherwise it would already be and we might not have that evil > postprocess feature. > > Try a run, append a package to IMAGE_PREINSTALL, build again > > I kind of bet that BUILD_ID will be wrong and not show your new commit > or "dirty" Yes, It is wrong. Since we definitely know that we are bringing in a variable that changes everytime when there is a change to the source code, we could very well do do_prepare_build[nostamp]="1". That with some changes should solve this problem. Thanks, Vijai Kumar K > > > ROOTFS_POSTPROCESS_COMMAND =+ "image_postprocess_configure" > > image_postprocess_configure() { > > # Configure root filesystem > > @@ -45,14 +13,6 @@ image_postprocess_configure() { > > fi > > } > > > > -ROOTFS_POSTPROCESS_COMMAND =+ "image_postprocess_mark" > > - > > -image_postprocess_mark() { > > - BUILD_ID=$(get_build_id) > > - update_etc_os_release \ > > - --build-id "${BUILD_ID}" --variant "${DESCRIPTION}" > > --version "${PV}" -} > > - > > ROOTFS_POSTPROCESS_COMMAND =+ "image_postprocess_machine_id" > > image_postprocess_machine_id() { > > # systemd(1) takes care of recreating the machine-id on first > > boot diff --git a/meta/classes/image.bbclass > > b/meta/classes/image.bbclass index eddc444..d849175 100644 > > --- a/meta/classes/image.bbclass > > +++ b/meta/classes/image.bbclass > > @@ -49,9 +49,6 @@ SRC_URI += "${@ cfg_script(d) }" > > > > DEPENDS += "${IMAGE_INSTALL}" > > > > -ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_core} describe --tags > > --dirty --match 'v[0-9].[0-9]*'" -ISAR_RELEASE_CMD ?= > > "${ISAR_RELEASE_CMD_DEFAULT}" - > > image_do_mounts() { > > sudo flock ${MOUNT_LOCKFILE} -c ' \ > > mkdir -p "${BUILDROOT_DEPLOY}" "${BUILDROOT_ROOTFS}" > > "${BUILDROOT_WORK}" @@ -91,23 +88,6 @@ def get_rootfs_size(d): > > > > return base_size + rootfs_extra * 1024 > > > > -# here we call a command that should describe your whole build > > system, -# this could be "git describe" or something similar. > > -# set ISAR_RELEASE_CMD to customize, or override do_mark_rootfs to > > do something -# completely different > > -get_build_id() { > > - if [ $(echo ${BBLAYERS} | wc -w) -ne 2 ] && > > - [ "${ISAR_RELEASE_CMD}" = "${ISAR_RELEASE_CMD_DEFAULT}" > > ]; then > > - bbwarn "You are using external layers that will not > > be" \ > > - "considered in the build_id. Consider > > changing" \ > > - "ISAR_RELEASE_CMD." > > - fi > > - if ! ( ${ISAR_RELEASE_CMD} ) 2>/dev/null; then > > - bbwarn "\"${ISAR_RELEASE_CMD}\" failed, returning > > empty build_id." > > - echo "" > > - fi > > -} > > - > > python set_image_size () { > > rootfs_size = get_rootfs_size(d) > > d.setVar('ROOTFS_SIZE', str(rootfs_size)) > > diff --git a/meta/recipes-core/base-files/base-files.bb > > b/meta/recipes-core/base-files/base-files.bb new file mode 100644 > > index 0000000..d250fc5 > > --- /dev/null > > +++ b/meta/recipes-core/base-files/base-files.bb > > @@ -0,0 +1,6 @@ > > +# This software is a part of ISAR. > > +# Copyright (c) Mentor, A Siemens Business, 2021 > > +# > > +# SPDX-License-Identifier: MIT > > + > > +require base-files.inc > > diff --git a/meta/recipes-core/base-files/base-files.inc > > b/meta/recipes-core/base-files/base-files.inc new file mode 100644 > > index 0000000..68d0e3a > > --- /dev/null > > +++ b/meta/recipes-core/base-files/base-files.inc > > @@ -0,0 +1,55 @@ > > +# This software is a part of ISAR. > > +# Copyright (c) Mentor, A Siemens Business, 2021 > > +# > > +# SPDX-License-Identifier: MIT > > + > > +inherit dpkg > > + > > +SRC_URI = "apt://${PN}" > > + > > +S="${WORKDIR}/${PN}" > > + > > +MAINTAINER = "isar-users " > > +CHANGELOG_V = "+isar" > > Just one such package. We will need for for every single image we build > in the tree. There can be multiple, especially when multiconfig comes > into play, but even without. > > Think of the internal layer you just helped with for a release, it > builds the product and the debug variant, which differ in their > DESCRIPTION and must not share that package. > > I am afraid a package will not work. We would need a package per image. > And that package would need to rebuild every time the BUILD_ID changes. > > But now you still have the problem that someone could install a more > recent "base-files" ... Might as well use preferences to pin it > forever, instead of forking it and giving it a number that will > hopefully never be smaller than the one from debian > > Henning > > > +ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_core} describe --tags > > --dirty --match 'v[0-9].[0-9]*'" +ISAR_RELEASE_CMD ?= > > "${ISAR_RELEASE_CMD_DEFAULT}" +OS_RELEASE_VARIANT = "Isar target > > filesystem" +OS_RELEASE_VARIANT_VERSION = "1.0" > > + > > +# here we call a command that should describe your whole build > > system, +# this could be "git describe" or something similar. > > +# set ISAR_RELEASE_CMD to customize, or override do_mark_rootfs to > > do something +# completely different > > +get_build_id() { > > + if [ $(echo ${BBLAYERS} | wc -w) -ne 2 ] && > > + [ "${ISAR_RELEASE_CMD}" = "${ISAR_RELEASE_CMD_DEFAULT}" ]; > > then > > + bbwarn "You are using external layers that will not be" \ > > + "considered in the build_id. Consider changing" \ > > + "ISAR_RELEASE_CMD." > > + fi > > + if ! ( ${ISAR_RELEASE_CMD} ) 2>/dev/null; then > > + bbwarn "\"${ISAR_RELEASE_CMD}\" failed, returning empty > > build_id." > > + echo "" > > + fi > > +} > > + > > +do_prepare_build() { > > + deb_add_changelog > > + OS_RELEASE_BUILD_ID=$(get_build_id) > > + if [ -n "${OS_RELEASE_BUILD_ID}" ]; then > > + sed -i '/^BUILD_ID=.*/d' '${S}/etc/os-release' > > + echo "BUILD_ID=\"${OS_RELEASE_BUILD_ID}\"" | \ > > + tee -a '${S}/etc/os-release' > > + fi > > + if [ -n "${OS_RELEASE_VARIANT}" ]; then > > + sed -i '/^VARIANT=.*/d' '${S}/etc/os-release' > > + echo "VARIANT=\"${OS_RELEASE_VARIANT}\"" | \ > > + tee -a '${S}/etc/os-release' > > + fi > > + if [ -n "${OS_RELEASE_VARIANT_VERSION}" ]; then > > + sed -i '/^VARIANT_VERSION=.*/d' '${S}/etc/os-release' > > + echo "VARIANT_VERSION=\"${OS_RELEASE_VARIANT_VERSION}\"" | \ > > + tee -a '${S}/etc/os-release' > > + fi > > +} > > -- > 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 on the web visit https://groups.google.com/d/msgid/isar-users/20210220092859.382eeb3a%40md1za8fc.ad001.siemens.net.