From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6572151760657317888 X-Received: by 2002:a1c:f90e:: with SMTP id x14-v6mr1028172wmh.14.1532328052224; Sun, 22 Jul 2018 23:40:52 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a1c:3582:: with SMTP id c124-v6ls1853643wma.6.gmail; Sun, 22 Jul 2018 23:40:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe+URFdp+FdWfxzjsBhyrCv8qMJGvphunpMRcnn8aoBqm+wFYTBt4mITMqbEqAm+u4nBlEm X-Received: by 2002:a7b:c081:: with SMTP id r1-v6mr1072268wmh.26.1532328051588; Sun, 22 Jul 2018 23:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532328051; cv=none; d=google.com; s=arc-20160816; b=Ft0ffqA9s8k8swPsLs6YNrlkngjdDnPbWhnY2PF9TxtdNnldX5+mC201L7Hda3XrhU lR9Vhqe6X/oN1LXs8thq/R2DOSgus1eRUTteL+89pA6JTY5RaHmcgcc5s8HFNL1O5swv DDbGMCMyPtGI2Ku5iHu7NUH5fLEvuwMKjI4E+6CT1P7giRBhukyMqde3INlNud792i1A bEYz3XTuJbmihZLz2yjL14Xuci2qciZG5O6kxXYgJ0VUWlBi5TMIXf8jee02BTEz3MTf EdIRaFgsPZyYgbGewAGfRXuyV7nyWfWT8OyEB7y9YlOiuOiSuopEWw6TpajZXktHhtau 34gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:references:cc:to:from:subject :arc-authentication-results; bh=6iYtU9wAWXoskvRRlsIm3cdIYnU4qC7GlUF63+YY6/w=; b=VoM2+b4evVUoQSRUwJWOhGEoOuj+4p9SxSS1Mxc3jQ8qW7S6Wf8S25IDjXTHM2doxC T800uRB6PLVerbARRRCgXEtZOaMD9AM7xLgI4uP4v1+68W/GQzsGURw5RouKyQiHTceM YM0/P1uM/hp3oEHuArxhJkika8Ip76IYeDryfV7hhbyHtBrsvKigtxWpf1pXFJN2Bosg Q1IBFgD77bp3sYUVEN6m4d9Z7vpktRJm4kJ9LYgn9izUUfy967X9lLiHVEx54Ndk1TjV v/NjmJDhrTDdBkrM/RGIQANp9stb+eCvhoEUiLz1tF/GitQir7ynatQXpw5m4vk5ZNB2 j3XQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Return-Path: Received: from gecko.sbs.de (gecko.sbs.de. [194.138.37.40]) by gmr-mx.google.com with ESMTPS id h2-v6si265507wri.1.2018.07.22.23.40.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jul 2018 23:40:51 -0700 (PDT) Received-SPF: pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.40 as permitted sender) client-ip=194.138.37.40; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by gecko.sbs.de (8.15.2/8.15.2) with ESMTPS id w6N6epQX017158 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Jul 2018 08:40:51 +0200 Received: from [139.22.37.206] ([139.22.37.206]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id w6N6eoSg002324; Mon, 23 Jul 2018 08:40:50 +0200 Subject: Re: [PATCH] meta/image: allow customization of command we use fo BUILD_ID From: Jan Kiszka To: Henning Schild , isar-users@googlegroups.com Cc: "Maxim Yu . Osipov" References: <4cb847ca-f5ce-6765-602e-9d5263746a3f@ilbers.de> <20180703073928.25857-1-henning.schild@siemens.com> <7301e609-8b14-cb64-f402-dd71d2451fa5@siemens.com> Message-ID: <81c1ee82-5981-e20f-9182-8a808daf8151@siemens.com> Date: Mon, 23 Jul 2018 08:40:50 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 In-Reply-To: <7301e609-8b14-cb64-f402-dd71d2451fa5@siemens.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-TUID: keRZOrC8BQOH On 2018-07-23 08:38, Jan Kiszka wrote: > On 2018-07-03 09:39, Henning Schild wrote: >> One of the previous patches introduced the feature to leave some build >> system information in the rootfs. The git command to derive that >> information was kept pretty repository agnostic. >> >> This patch makes the command Isar-specific and allows users to customize >> the command to their needs if they use a different tagging scheme in >> their repository, or if they do not use git at all. >> >> Signed-off-by: Henning Schild >> --- >>   meta-isar/recipes-core/images/isar-image-base.bb |  3 ++- >>   meta/classes/image.bbclass                       | 27 >> ++++++++++++------------ >>   2 files changed, 16 insertions(+), 14 deletions(-) >> >> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb >> b/meta-isar/recipes-core/images/isar-image-base.bb >> index c72bfdb..a24aa3e 100644 >> --- a/meta-isar/recipes-core/images/isar-image-base.bb >> +++ b/meta-isar/recipes-core/images/isar-image-base.bb >> @@ -24,7 +24,8 @@ IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge" >>   WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}" >> -ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}" >> +ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_isar} describe --tags >> --dirty --match 'v[0-9].[0-9]*'" > > I think we should keep ISAR_GIT_RELEASE_PATH as overridable API > variable. Many project will use the default pattern and just deviate in > the layer name. > Just to clarify: We should have *both* ISAR_GIT_RELEASE_PATH and ISAR_RELEASE_CMD as API. The former for the common customizations, the latter for deviating tag schemes or different version control systems. Jan >> +ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}" >>   do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \ >>                                ${IMAGE_ROOTFS}/isar-apt" >> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass >> index 7935b69..077c550 100644 >> --- a/meta/classes/image.bbclass >> +++ b/meta/classes/image.bbclass >> @@ -34,24 +34,25 @@ def get_rootfs_size(d): >>       return base_size + rootfs_extra * 1024 >> -# we assume that one git commit can describe the whole image, so you >> should be >> -# using submodules, kas, or something like that >> -# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer >> -# when not using git, override do_mark_rootfs >> +# 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 >>   def get_build_id(d): >>       import subprocess >>       if (len(d.getVar("BBLAYERS", True).strip().split(' ')) != 2 and >> -        (d.getVar("ISAR_GIT_RELEASE_PATH", True) == >> -         d.getVar("LAYERDIR_isar", True))): >> +        (d.getVar("ISAR_RELEASE_CMD", True) == >> +         d.getVar("ISAR_RELEASE_CMD_DEFAULT", True))): >>           bb.warn('You are using external layers that will not be >> considered' + >> -                ' in the build_id. Considder setting >> ISAR_GIT_RELEASE_PATH.') >> -    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)] >> -    if (0 == subprocess.call(base + ["rev-parse"])): >> -        v = subprocess.check_output(base + >> -                                    ["describe", "--long", "--dirty", >> -                                     "--always"], >> universal_newlines=True) >> +                ' in the build_id. Consider changing ISAR_RELEASE_CMD.') >> +    cmd = d.getVar("ISAR_RELEASE_CMD", True) >> +    try: >> +        v = subprocess.check_output(cmd, shell=True, >> universal_newlines=True) >>           return v.rstrip() >> -    return "" >> +    except subprocess.CalledProcessError as e: >> +        bb.warn('\"%s\" returned %d, returning empty build_id' % >> +                (e.cmd, e.returncode)) >> +        return "" >>   python set_image_size () { >>       rootfs_size = get_rootfs_size(d) >> > > -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux