From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6572151760657317888 X-Received: by 2002:adf:e5c3:: with SMTP id a3-v6mr1250491wrn.19.1530266668471; Fri, 29 Jun 2018 03:04:28 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a1c:f202:: with SMTP id s2-v6ls286920wmc.0.canary-gmail; Fri, 29 Jun 2018 03:04:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd3cnjrSf/T/zjFlqNFi8i6hl3M3QQVevKT0DQk/Ydz9s8lY5KjnE8TIBBD1YgWJyYl2ZlK X-Received: by 2002:a1c:ed14:: with SMTP id l20-v6mr170250wmh.30.1530266668018; Fri, 29 Jun 2018 03:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530266667; cv=none; d=google.com; s=arc-20160816; b=a7O+t+WExejTMFxhSSi4wHZXV7rUFEoGzXRVwFK09mMIQshiZQX72mmq8FME98TAab L8Jw6Z64GLt1wV3TIvAakpn+kJCaqm1ZNB12IVIOqh/w88q3eiI/SVhISJPzNZmXYwlq kMcQLqPkKcIuIz6oGeIs1QqjvG+iBnmoVlnUuVU+bdtK374f3uCEI8Lt5Gfygc0cFq6L RzQqjeayT5Q4dBnDMZtDcdsdaozcAq+v+1DuiN31m3vdA+skTdnhSP3wrc4OTeai936e O4/JdK0dvVrXg0ggxx2jHNzRUsC5H0hzKot6k6aiIqgUHJ4t2tP1Fh0QyIpEyCvrLWM3 P1RQ== 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:organization:from:references:to:subject :arc-authentication-results; bh=MKuKEi8cfshfsLSHaI950srKHx+zt1cuxcl0yFArvPU=; b=sKVD+axmGFVvaIADi0KRJAGB9dhIbEImAEzDwWKkIou+ODLGs3r1XjXLVGsNOvavxZ v3QloIKzt6IruY84oU+seEszaSmOladhC/czbsLHgVmtca5T/OT2lIJnaLExa1pRHYOl nowt3x5gZYr35R/u3GZp7WS8NWaZwIybrog+kCHCoyNyvh2y88UNRv2aaXyE5MxaJ7d6 G4FvPMK2mblHHP8mad96GGth/kPN4AHxxLWEGulS30LB7WOeBEztAmg2If8pmWcP5UnD Yr00y2PEG8/pgDvJkoiT2cobbRh0BeypBzjWQqexo2a1wsiAaf61H7LkXnPNmdwumyj7 HIiA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=mosipov@ilbers.de Return-Path: Received: from aqmola.ilbers.de (aqmola.ilbers.de. [85.214.62.211]) by gmr-mx.google.com with ESMTPS id x21-v6si33082wmc.1.2018.06.29.03.04.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jun 2018 03:04:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) client-ip=85.214.62.211; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=mosipov@ilbers.de Received: from [192.168.50.163] (d51a48a80.access.telenet.be [81.164.138.128]) (authenticated bits=0) by aqmola.ilbers.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id w5TA4PvS027459 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Fri, 29 Jun 2018 12:04:26 +0200 Subject: Re: [PATCH] meta/image: leave BUILD_ID and VARIANT in /etc/os-release To: Henning Schild , isar-users@googlegroups.com References: <20180628150521.15790-1-henning.schild@siemens.com> <20180628170958.2e009d98@md1pvb1c.ad001.siemens.net> From: "Maxim Yu. Osipov" Organization: ilbers GmbH Message-ID: Date: Fri, 29 Jun 2018 12:04:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180628170958.2e009d98@md1pvb1c.ad001.siemens.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: iWefVTd+flk8 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? > > 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="" > -- Maxim Osipov ilbers GmbH Maria-Merian-Str. 8 85521 Ottobrunn Germany +49 (151) 6517 6917 mosipov@ilbers.de http://ilbers.de/ Commercial register Munich, HRB 214197 General Manager: Baurzhan Ismagulov