From 439c59b425cf403355571875b3fa714782dcf15b Mon Sep 17 00:00:00 2001 From: Willy Tu Date: Tue, 9 Feb 2021 16:29:27 -0800 Subject: meta-phosphor: os-release: Set weak default to DISTRO_VERSION Improved practice to use DISTRO_VERSION instead of the undocumented VERSION_ID. DISTRO_VERSION is documented in yocto https://www.yoctoproject.org/docs/latest/ref-manual/ref-manual.html and specified in this section about creating your own distribution. https://docs.yoctoproject.org/dev-manual/common-tasks.html#creating-your-own-distribution VERSION_ID is undocumented and will more likely be changed compared to the documented DISTRO_VERSION. The VERSION_ID is set to DISTRO_VERSION in poky/.../os-release.bb Use weak default to DISTRO_VERSION instead of overriding VERSION_ID. This allows other layers to override in *.bbappend or *.conf. Tested: ``` root@romulus:~# cat /etc/os-release ID=openbmc-openpower NAME="Phosphor OpenBMC (Phosphor OpenBMC Project Reference Distro)" VERSION="2.11.0-dev" VERSION_ID=2.11.0-dev-165-g20885c497 PRETTY_NAME="Phosphor OpenBMC (Phosphor OpenBMC Project Reference Distro) 2.11.0-dev" BUILD_ID="2.11.0-dev" OPENBMC_TARGET_MACHINE="romulus" ``` Signed-off-by: Willy Tu Change-Id: I25b5a165b764e6562fa8008c9d2a75a82fb09139 --- meta-phosphor/recipes-core/os-release/os-release.bbappend | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'meta-phosphor/recipes-core/os-release/os-release.bbappend') diff --git a/meta-phosphor/recipes-core/os-release/os-release.bbappend b/meta-phosphor/recipes-core/os-release/os-release.bbappend index 15852327f..f42235e4c 100644 --- a/meta-phosphor/recipes-core/os-release/os-release.bbappend +++ b/meta-phosphor/recipes-core/os-release/os-release.bbappend @@ -15,7 +15,7 @@ def run_git(d, cmd): bb.warn("Unexpected exception from 'git' call: %s" % e) pass -VERSION_ID := "${@run_git(d, 'describe --dirty')}" +DISTRO_VERSION ??= "${@run_git(d, 'describe --dirty')}" VERSION = "${@'-'.join(d.getVar('VERSION_ID').split('-')[0:2])}" BUILD_ID := "${@run_git(d, 'describe --abbrev=0')}" -- cgit v1.2.3 From 24d05d0bba777238227121f79f3e8b02bb2bb535 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Wed, 30 Jun 2021 16:15:45 -0500 Subject: meta-phosphor: os-release: fix task caching with DISTRO_VERSION It was reported that the following sequence would not cause `os-release` to rebuild: ``` bitbake os-release git commit --amend bitbake os-release ``` This is due to how bitbake task hashing is implemented with respect to weak variables. In 439c59b, DISTRO_VERSION was changed to a weak variable, but it is included in the 'vardeps' chain for 'do_compile'. When bitbake computes the hash for a task, typically the contents of the variables are used for the hashing, but for weak variables only the definition is used. (Confirmed by adding bb.note debugs to `poky/bitbake/lib/bb/data.py`) The new, weak DISTRO_VERSION is intended to be populated with contents from a `git describe` operation. Those contents must be used in the hashing of the 'do_compile' task and not the definition. This can be accomplished by creating an indirection using a strong variable. The dependency chain and hash evaluation will be as follows: ``` do_compile -> DISTRO_VERSION -> PHOSPHOR_OS_RELEASE_DISTRO_VERSION hash(do_compile) = ... + DISTRO_VERSION:${PHOSPHOR_OS_RELEASE_DISTRO_VERSION} + PHOSPHOR_...DISTRO_VERSION=2.11.0-dev-... ``` Prior to this fix the hash evaluation was: ``` hash(do_compile) = ... + DISTRO_VERSION:${@run_git...} ``` Fixes 439c59b425cf403355571875b3fa714782dcf15b. Tested: Ensure the above reported sequence causes a rebuild of os-release with expected data. Signed-off-by: Patrick Williams Change-Id: I0bd93d3d88bf62dfe03549419fe98ab85f10a68c --- meta-phosphor/recipes-core/os-release/os-release.bbappend | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'meta-phosphor/recipes-core/os-release/os-release.bbappend') diff --git a/meta-phosphor/recipes-core/os-release/os-release.bbappend b/meta-phosphor/recipes-core/os-release/os-release.bbappend index f42235e4c..1a3b22898 100644 --- a/meta-phosphor/recipes-core/os-release/os-release.bbappend +++ b/meta-phosphor/recipes-core/os-release/os-release.bbappend @@ -15,7 +15,15 @@ def run_git(d, cmd): bb.warn("Unexpected exception from 'git' call: %s" % e) pass -DISTRO_VERSION ??= "${@run_git(d, 'describe --dirty')}" +# DISTRO_VERSION can be overridden by a bbappend or config, so it must be a +# weak override. But, when a variable is weakly overridden the definition +# and not the contents are used in the task-hash (for sstate reuse). We need +# a strong variable in the vardeps chain for do_compile so that we get the +# contents of the 'git describe --dirty' call. Create a strong/immediate +# indirection via PHOSPHOR_OS_RELEASE_DISTRO_VERSION. +PHOSPHOR_OS_RELEASE_DISTRO_VERSION := "${@run_git(d, 'describe --dirty')}" +DISTRO_VERSION ??= "${PHOSPHOR_OS_RELEASE_DISTRO_VERSION}" + VERSION = "${@'-'.join(d.getVar('VERSION_ID').split('-')[0:2])}" BUILD_ID := "${@run_git(d, 'describe --abbrev=0')}" -- cgit v1.2.3