From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6572151760657317888 X-Received: by 2002:a2e:3819:: with SMTP id f25-v6mr504484lja.32.1530272783172; Fri, 29 Jun 2018 04:46:23 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a2e:3c14:: with SMTP id j20-v6ls1066420lja.2.gmail; Fri, 29 Jun 2018 04:46:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLKaduEIphKYxMpbTXeUoLzT6G6p/r0WcxuKy17pS+L1+le2TjedLpiRiED2J2jGZ7Rp7X3 X-Received: by 2002:a2e:6e18:: with SMTP id j24-v6mr746524ljc.0.1530272782709; Fri, 29 Jun 2018 04:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530272782; cv=none; d=google.com; s=arc-20160816; b=bqog9uGwFdxNfQCt8SnX+dsBFe14i/JxqVjqTvMXczBrRuSLRPLiL60kT7IpmpyODu ro4I3LZi6g1K288jH5LEIqkgAWoM1BFqSXx7xBGjV9TpbIwkvOnluuALtspfNrLU1kw2 JUs41eVbuPWCkxfXEeA0LFq4QRvN8anmNTl0i2Ei8v+tWzpSuPNDcJMsNl4Ywqz25KqP L9diqZzYy3kOZIQM80P7oChk7B9GuU43EWpsMAuim4kGyQRIe+Q9/QmyPXBeBbrDs3z0 kNpmUfwW4LGOWwwJRvxfyfoys4fUjr8RNcHHl8Oqh+cQJKmkAXsue9gZ0vhhNxBnbjCL V34w== 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:arc-authentication-results; bh=8PYw1/O5E3sx8pS25BTBhoFu1fvYty827Sy3l5VbN+4=; b=S82r1P4eAcU+W7FruA4ivhuJQspR2elG1YGICVu4ZRsehka3XqG5XR70vVJMJZgMwH OOe1/OW7InEJnBJpN6wPcSowsYqBw6EJeLU9b2s40ajXZZBEgcEE1OsmLi3dIfRbuaad cdKk9/B2gvgHgrToMrEathjUxivxw0x/INloz300unzCo8gnnS0b0cBnsLo0FKDAYRGf Re/hO92a7wEZoxgvns/ZocqWLV1L56yezs2zavgIsfEfrKZVCunEnYkYFn1TTS0AFPvy bVjo/aicEpFB9cUeLu/FZK1GG/A4Id6q8y9aHS+F8PLNK7PQq86yv7RAKkn4v1vyuT8P vuyw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Return-Path: Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id c4-v6si278832lfk.0.2018.06.29.04.46.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jun 2018 04:46:22 -0700 (PDT) Received-SPF: pass (google.com: domain of henning.schild@siemens.com designates 192.35.17.14 as permitted sender) client-ip=192.35.17.14; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Received: from mail2.siemens.de (mail2.siemens.de [139.25.208.11]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w5TBkLfY022595 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jun 2018 13:46:21 +0200 Received: from md1pvb1c.ad001.siemens.net (md1pvb1c.ad001.siemens.net [139.25.68.40]) by mail2.siemens.de (8.15.2/8.15.2) with ESMTP id w5TBkL91009156; Fri, 29 Jun 2018 13:46:21 +0200 Date: Fri, 29 Jun 2018 13:46:20 +0200 From: Henning Schild To: "Maxim Yu. Osipov" Cc: Subject: Re: [PATCH] meta/image: leave BUILD_ID and VARIANT in /etc/os-release Message-ID: <20180629134620.1a0a1832@md1pvb1c.ad001.siemens.net> In-Reply-To: References: <20180628150521.15790-1-henning.schild@siemens.com> <20180628170958.2e009d98@md1pvb1c.ad001.siemens.net> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TUID: 5y0L8CagUN6/ Am Fri, 29 Jun 2018 12:04:25 +0200 schrieb "Maxim Yu. Osipov" : > Hi Henning, > > On 06/28/2018 05:09 PM, Henning Schild wrote: > > Am Thu, 28 Jun 2018 17:05:21 +0200 > > schrieb Henning Schild : > > > >> This commit adds support for leaving a mark in the resulting image. > >> That should allow you to tell what code you used to create it. By > >> default "git describe" will be used on Isar itself to come up with > >> a BUILD_ID. And the DESCRIPTION of the image will become the > >> VARIANT. > >> > >> see > >> https://www.freedesktop.org/software/systemd/man/os-release.html > >> > >> Signed-off-by: Henning Schild > >> --- > >> meta-isar/recipes-core/images/isar-image-base.bb | 2 ++ > >> meta/classes/image.bbclass | 27 > >> ++++++++++++++++++++++++ > >> meta/classes/isar-bootstrap-helper.bbclass | 26 > >> +++++++++++++++++++++++ 3 files changed, 55 insertions(+) > >> > >> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb > >> b/meta-isar/recipes-core/images/isar-image-base.bb index > >> 6cdc6b2..c72bfdb 100644 --- > >> a/meta-isar/recipes-core/images/isar-image-base.bb +++ > >> b/meta-isar/recipes-core/images/isar-image-base.bb @@ -24,6 +24,8 > >> @@ IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge" > >> WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}" > >> > >> +ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}" > >> + > >> do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \ > >> ${IMAGE_ROOTFS}/isar-apt" > >> > >> diff --git a/meta/classes/image.bbclass > >> b/meta/classes/image.bbclass index 3bdcb2f..00040e5 100644 > >> --- a/meta/classes/image.bbclass > >> +++ b/meta/classes/image.bbclass > >> @@ -34,6 +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 > >> +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))): > >> + 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"], > > > > Here i am not sure what arguments to use. That also depends on the > > tagging of the project. We might want to make this configurable, > > since the "most significant" layer might use different tagging. > > Opinions? > > In my opinion 'git describe --dirty --match "v[0-9].[0-9]*" would be > enough. > > It would be nice to add document describing versioning > docs/VERSIONING.md. Something like that: > > >>> > ISAR Versioning > > ISAR uses for release versioning unsigned, annotated tag > in format "v[0-9].[0-9]*". > > The following procedure has to be followed for release versioning: > > 1) Update CHANGELOG.md in ISAR root directory. > > 2) Before creation of final release, prepare release candidate(s) > with the help of command 'git tag -a ', > where has the format > "v[0-9].[0-9]-rc[0-9]" > > 3) When final release is ready create annotated tag > with the help of command 'git tag -a ', where > has the format "v[0-9].[0-9]" > > BUILD_ID field in /etc/os-release keeps ISAR repository version > derived with the help of command 'git describe --dirty --match > "v[0-9].[0-9]*'. > > This command finds the most recent annotated tag that is reachable > from a commit. > If the tag points to the commit, then only the tag is shown. > Otherwise, it suffixes the tag name with the number of additional > commits on top of the tagged object and the abbreviated object name > of the most recent commit. If the working tree is modified '-dirty' > will be appended to the end of the version string. > > For example, BUILD_ID may have the values like > - "v3.0-rc2" for 3.0 release candidate 2 > - "v3.0" for released 3.0 version > - "v3.0-112-g118cd4b" for developer's version, > meaning that 112 commits exist since recent release and the most > recent commit has abbreviated name 118cd4b. > - "v3.0-112-g118cd4b-dirty" for developer's version, > meaning that 112 commits exist since recent release, the most > recent commit has abbreviated name 118cd4b and the working tree > is modified. > >>> > > Is it OK? Thanks for citing half of the manpage ;). I think you can do whatever you want. The point is that get_build_id should be generic enough to also work for repos calling their tags completely differently, or not using tags at all. Think of a private layer-repo that happens to use Isar but has another versioning policy. The BUILD_ID in the image should be the one of that layer, set by ISAR_GIT_RELEASE_PATH. People that do not use git at all override do_mark_rootfs, but for the ones using git it would be nice if they would not have to. Henning > > > > > In that regard i realized that the tags on Isar are not consistent. > > v0.3 seems to be the last annotated one. > > Thank you for pointing this out - after applying your patch we will > start to follow well defined versioning/release policy. > > Kind regards, > Maxim. > > > > > Henning > > > >> universal_newlines=True) > >> + return v.rstrip() > >> + return "" > >> + > >> python set_image_size () { > >> rootfs_size = get_rootfs_size(d) > >> d.setVar('ROOTFS_SIZE', str(rootfs_size)) > >> @@ -56,6 +75,14 @@ do_rootfs() { > >> addtask rootfs before do_build after do_unpack > >> do_rootfs[deptask] = "do_deploy_deb" > >> > >> +do_mark_rootfs() { > >> + update_etc_os_release \ > >> + --build-id "${@get_build_id(d)}" --variant > >> "${DESCRIPTION}" \ > >> + "${IMAGE_ROOTFS}" > >> +} > >> + > >> +addtask mark_rootfs before do_copy_boot_files after do_rootfs > >> + > >> do_copy_boot_files() { > >> KERNEL_IMAGE=${@get_image_name(d, 'vmlinuz')[1]} > >> if [ -n "${KERNEL_IMAGE}" ]; then > >> diff --git a/meta/classes/isar-bootstrap-helper.bbclass > >> b/meta/classes/isar-bootstrap-helper.bbclass index 3c10fc7..f375853 > >> 100644 --- a/meta/classes/isar-bootstrap-helper.bbclass > >> +++ b/meta/classes/isar-bootstrap-helper.bbclass > >> @@ -14,6 +14,32 @@ def reverse_bb_array(d, varname): > >> array = reversed(array.split()) > >> return " ".join(i for i in array) > >> > >> +update_etc_os_release() { > >> + OS_RELEASE_BUILD_ID="" > >> + OS_RELEASE_VARIANT="" > >> + while true; do > >> + case "$1" in > >> + --build-id) OS_RELEASE_BUILD_ID=$2; shift ;; > >> + --variant) OS_RELEASE_VARIANT=$2; shift ;; > >> + -*) bbfatal "$0: invalid option specified: $1" ;; > >> + *) break ;; > >> + esac > >> + shift > >> + done > >> + ROOTFSDIR="$1" > >> + > >> + if [ -n "${OS_RELEASE_BUILD_ID}" ]; then > >> + sudo sed -i '/^BUILD_ID=.*/d' ${ROOTFSDIR}/etc/os-release > >> + echo "BUILD_ID=\"${OS_RELEASE_BUILD_ID}\"" | \ > >> + sudo tee -a ${ROOTFSDIR}/etc/os-release > >> + fi > >> + if [ -n "${OS_RELEASE_VARIANT}" ]; then > >> + sudo sed -i '/^VARIANT=.*/d' ${ROOTFSDIR}/etc/os-release > >> + echo "VARIANT=\"${OS_RELEASE_VARIANT}\"" | \ > >> + sudo tee -a ${ROOTFSDIR}/etc/os-release > >> + fi > >> +} > >> + > >> setup_root_file_system() { > >> CLEAN="" > >> FSTAB="" > > > >