]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
os-release: do not add empty parentheses to VERSION
authorDaniel Wagenknecht <dwagenknecht@emlix.com>
Mon, 22 Sep 2025 08:02:08 +0000 (10:02 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 2 Oct 2025 10:27:31 +0000 (11:27 +0100)
Setting DISTRO_CODENAME to an empty string previously led to a VERSION
field in /etc/os-release containing empty parantheses, e.g.
   DISTRO_VERSION = "5.0.12"
   DISTRO_CODENAME = ""
   ==> VERSION = "5.0.12 ()"

This is probably not what a user expects, especially since it is quite
common to set variables to empty strings to disable something in OE
based builds, but using `unset VARNAME` seems pretty uncommon.

Instead of adding the parentheses with the DISTRO_CODENAME if the
variable is in the datastore add them only if the variable is not empty.

Signed-off-by: Daniel Wagenknecht <dwagenknecht@emlix.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/os-release/os-release.bb

index e1906d05d8a62c325c29e3d153825f4506674ce4..1d2bb081865b2aa9f28007b2b0fcd53e3b1e191b 100644 (file)
@@ -22,7 +22,7 @@ OS_RELEASE_UNQUOTED_FIELDS = "ID VERSION_ID VARIANT_ID"
 
 ID = "${DISTRO}"
 NAME = "${DISTRO_NAME}"
-VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in d else ''}"
+VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if (d.getVar('DISTRO_CODENAME') or '') != '' else ''}"
 VERSION_ID = "${DISTRO_VERSION}"
 VERSION_CODENAME = "${@d.getVar('DISTRO_CODENAME') or ''}"
 PRETTY_NAME = "${DISTRO_NAME} ${VERSION}"