Skip to contentSkip to conversation

os-release: Fix VERSION_CODENAME in case it is empty

PATCH In review Daniel Semkowicz 2 participants 4 messages Jun 20, 2024 – Jun 28, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 os-release: Fix VERSION_CODENAME in case it is empty

If DISTRO_CODENAME was not set, VERSION_CODENAME field was populated with unparsed string. This resulted in the following line in os-release file:

  VERSION_CODENAME="${DISTRO_CODENAME}"

According to systemd documentation, this field is optional. Fix the problem by setting VERSION_CODENAME conditionally, only if DISTRO_CODENAME was set.

---
 meta/recipes-core/os-release/os-release.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/os-release/os-release.bb +1 -1
index 8906906bc3..93af08c182 100644
@@ -24,7 +24,7 @@ ID = "${DISTRO}"
 NAME = "${DISTRO_NAME}"
 VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in d else ''}"
 VERSION_ID = "${DISTRO_VERSION}"
-VERSION_CODENAME = "${DISTRO_CODENAME}"
+VERSION_CODENAME = "${@d.getVar('DISTRO_CODENAME') or ''}"
 PRETTY_NAME = "${DISTRO_NAME} ${VERSION}"
 
 # The vendor field is hardcoded to "openembedded" deliberately. We'd
Signature · 1 line
2.45.2
#1 lore raw

If you want to set VERSION_CODENAME to empty you can just add:
DISTRO_CODENAME ??= ""
to make sure it's always expanded to at least empty string.

Quoted 42 lines · Daniel Semkowicz via lists.openembedded.org

If DISTRO_CODENAME was not set, VERSION_CODENAME field was populated with unparsed string. This resulted in the following line in os-release file:

  VERSION_CODENAME="${DISTRO_CODENAME}"

According to systemd documentation, this field is optional. Fix the problem by setting VERSION_CODENAME conditionally, only if DISTRO_CODENAME was set.

---
 meta/recipes-core/os-release/os-release.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/os-release/os-release.bb +1 -2
index 8906906bc3..93af08c182 100644
@@ -24,7 +24,7 @@ ID = "${DISTRO}"
 NAME = "${DISTRO_NAME}"
 VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in d else ''}"
 VERSION_ID = "${DISTRO_VERSION}"
-VERSION_CODENAME = "${DISTRO_CODENAME}"
+VERSION_CODENAME = "${@d.getVar('DISTRO_CODENAME') or ''}"
 PRETTY_NAME = "${DISTRO_NAME} ${VERSION}"
 
 # The vendor field is hardcoded to "openembedded" deliberately. We'd
--

2.45.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#200952): https://lists.openembedded.org/g/openembedded-core/message/200952
Mute This Topic: https://lists.openembedded.org/mt/106779331/3617156
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

Unfortunately, settings DISTRO_CODENAME to empty string triggers VERSION variable to be suffixed with "()", because:

VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if
'DISTRO_CODENAME' in d else ''}"

Which is not a desirable effect.

Quoted 50 lines · Martin Jansa

If you want to set VERSION_CODENAME to empty you can just add:
DISTRO_CODENAME ??= ""
to make sure it's always expanded to at least empty string.

Quoted 42 lines · Daniel Semkowicz via lists.openembedded.org

If DISTRO_CODENAME was not set, VERSION_CODENAME field was populated with unparsed string. This resulted in the following line in os-release file:

  VERSION_CODENAME="${DISTRO_CODENAME}"

According to systemd documentation, this field is optional. Fix the problem by setting VERSION_CODENAME conditionally, only if DISTRO_CODENAME was set.

---
 meta/recipes-core/os-release/os-release.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/os-release/os-release.bb +1 -2
index 8906906bc3..93af08c182 100644
@@ -24,7 +24,7 @@ ID = "${DISTRO}"
 NAME = "${DISTRO_NAME}"
 VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in d else ''}"
 VERSION_ID = "${DISTRO_VERSION}"
-VERSION_CODENAME = "${DISTRO_CODENAME}"
+VERSION_CODENAME = "${@d.getVar('DISTRO_CODENAME') or ''}"
 PRETTY_NAME = "${DISTRO_NAME} ${VERSION}"
 
 # The vendor field is hardcoded to "openembedded" deliberately. We'd
--

2.45.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#200952): https://lists.openembedded.org/g/openembedded-core/message/200952
Mute This Topic: https://lists.openembedded.org/mt/106779331/3617156
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw

Hello Steve,

Would it be possible to backport this fix to scarthgap branch? The same problem occurs also there.

Commit on master branch: 70a0b8bc1d846c857be90ce2e97e60c5ee32558e

Best regards
Daniel Semkowicz

Quoted 60 lines · Daniel Semkowicz

Unfortunately, settings DISTRO_CODENAME to empty string triggers VERSION variable to be suffixed with "()", because:

VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if
'DISTRO_CODENAME' in d else ''}"

Which is not a desirable effect.

Quoted 50 lines · Martin Jansa

If you want to set VERSION_CODENAME to empty you can just add:
DISTRO_CODENAME ??= ""
to make sure it's always expanded to at least empty string.

Quoted 42 lines · Daniel Semkowicz via lists.openembedded.org

If DISTRO_CODENAME was not set, VERSION_CODENAME field was populated with unparsed string. This resulted in the following line in os-release file:

  VERSION_CODENAME="${DISTRO_CODENAME}"

According to systemd documentation, this field is optional. Fix the problem by setting VERSION_CODENAME conditionally, only if DISTRO_CODENAME was set.

---
 meta/recipes-core/os-release/os-release.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/os-release/os-release.bb +1 -2
index 8906906bc3..93af08c182 100644
@@ -24,7 +24,7 @@ ID = "${DISTRO}"
 NAME = "${DISTRO_NAME}"
 VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in d else ''}"
 VERSION_ID = "${DISTRO_VERSION}"
-VERSION_CODENAME = "${DISTRO_CODENAME}"
+VERSION_CODENAME = "${@d.getVar('DISTRO_CODENAME') or ''}"
 PRETTY_NAME = "${DISTRO_NAME} ${VERSION}"
 
 # The vendor field is hardcoded to "openembedded" deliberately. We'd
--

2.45.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#200952): https://lists.openembedded.org/g/openembedded-core/message/200952
Mute This Topic: https://lists.openembedded.org/mt/106779331/3617156
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-