Skip to contentSkip to conversation

Add /etc/os-release

RFC PATCH In review Christopher Larson 6 participants 12 messages Dec 13, 2013

lore
Share & tools
lore
#0 lore raw

cover Add /etc/os-release

systemd wants /etc/os-release, and it's useful for other software, and the user as well. This adds it as a separate recipe which generates the metadata using our config metadata variables (e.g. DISTRO_*), and rreccomends it from systemd. I think this is a reasonablea pproach, but I wanted to run it by folks, and also pursue an answer to my open question on this, should base-files pull it in instead of systemd, or something else, for non-systemd images? Do we care if it's missing from those? Thoughts?

The following changes since commit 62849843a4a83b10316bc6cb1e4b3f0622391dea:

gdb-7.6.1: fix cygwin check in configure script (2013-12-12 22:41:13 +0000)

are available in the git repository at:

[email protected]:kergoth/oe-core.git os-release

for you to fetch changes up to b00a526527b3248c9014bc3c0e5c606ef97e0838:

systemd: rrecommend os-release (2013-12-13 07:41:08 -0700)

----------------------------------------------------------------
Christopher Larson (2):
os-release: add new operating system identification recipe
systemd: rrecommend os-release

 meta/recipes-core/os-release/os-release.bb | 42 ++++++++++++++++++++++++++++++
 meta/recipes-core/systemd/systemd_208.bb   |  1 +
 2 files changed, 43 insertions(+)
 create mode 100644 meta/recipes-core/os-release/os-release.bb
Signature · 1 line
1.8.3.4
#1 lore raw

RFC 1/2 os-release: add new operating system identification recipe

From: Christopher Larson <[email protected]>

This is needed by systemd, among other useful applications. All fields are metadata driven, and initial values come from our DISTRO variables.

---
 meta/recipes-core/os-release/os-release.bb | 42 ++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 meta/recipes-core/os-release/os-release.bb
meta/recipes-core/os-release/os-release.bb new file +42 -0
new file mode 100644
index 0000000..0f67597
@@ -0,0 +1,42 @@
+inherit allarch
+
+SUMMARY = "Operating system identification"
+DESCRIPTION = "The /etc/os-release file contains operating system identification data."
+LICENSE = "MIT"
+INHIBIT_DEFAULT_DEPS = "1"
+
+do_fetch[noexec] = "1"
+do_unpack[noexec] = "1"
+do_patch[noexec] = "1"
+do_configure[noexec] = "1"
+
+# Other valid fields: BUILD_ID ANSI_COLOR CPE_NAME HOME_URL SUPPORT_URL BUG_REPORT_URL
+OS_RELEASE_FIELDS = "ID ID_LIKE NAME VERSION VERSION_ID PRETTY_NAME"
+
+export ID = "${DISTRO}"
+export NAME = "${DISTRO_NAME}"
+export VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in d else ''}"
+export VERSION_ID = "${DISTRO_VERSION}"
+export PRETTY_NAME = "${DISTRO_NAME} ${VERSION}"
+
+export BUILD_ID ?= "${DATETIME}"
+export ID_LIKE
+export ANSI_COLOR
+export CPE_NAME
+export HOME_URL
+export SUPPORT_URL
+export BUG_REPORT_URL
+
+do_compile () {
+    for field in ${OS_RELEASE_FIELDS}; do
+        if eval "test -n \"\$$field\""; then
+            eval "printf \"%s=%s\n\" \"\$field\" \"\$$field\""
+        fi
+    done >os-release
+}
+do_compile[vardeps] += "${OS_RELEASE_FIELDS}"
+
+do_install () {
+    install -d ${D}${sysconfdir}
+    install -m 0644 os-release ${D}${sysconfdir}/
+}
Signature · 1 line
1.8.3.4
#11 lore raw

RFC 2/2 systemd: rrecommend os-release

In reply to Christopher Larson

From: Christopher Larson <[email protected]>

---
 meta/recipes-core/systemd/systemd_208.bb | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-core/systemd/systemd_208.bb +1 -0
index c1f8d77..4c2fbc6 100644
@@ -223,6 +223,7 @@ RRECOMMENDS_${PN} += "systemd-serialgetty systemd-compat-units \
                       util-linux-agetty \
                       util-linux-fsck e2fsprogs-e2fsck \
                       kernel-module-autofs4 kernel-module-unix kernel-module-ipv6 \
+                      os-release \
 "
 
 PACKAGES =+ "udev-dbg udev udev-utils udev-hwdb"
Signature · 1 line
1.8.3.4
#2 lore raw

Re: [RFC 1/2] os-release: add new operating system identification recipe

In reply to Christopher Larson
Quoted 44 lines · Christopher Larson

From: Christopher Larson <[email protected]>

This is needed by systemd, among other useful applications. All fields are metadata driven, and initial values come from our DISTRO variables.

---
 meta/recipes-core/os-release/os-release.bb | 42 ++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 meta/recipes-core/os-release/os-release.bb
meta/recipes-core/os-release/os-release.bb new file +27 -0
new file mode 100644
index 0000000..0f67597
@@ -0,0 +1,42 @@
+inherit allarch
+
+SUMMARY = "Operating system identification"
+DESCRIPTION = "The /etc/os-release file contains operating system identification data."
+LICENSE = "MIT"
+INHIBIT_DEFAULT_DEPS = "1"
+
+do_fetch[noexec] = "1"
+do_unpack[noexec] = "1"
+do_patch[noexec] = "1"
+do_configure[noexec] = "1"
+
+# Other valid fields: BUILD_ID ANSI_COLOR CPE_NAME HOME_URL SUPPORT_URL BUG_REPORT_URL
+OS_RELEASE_FIELDS = "ID ID_LIKE NAME VERSION VERSION_ID PRETTY_NAME"
+
+export ID = "${DISTRO}"
+export NAME = "${DISTRO_NAME}"
+export VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in d else ''}"
+export VERSION_ID = "${DISTRO_VERSION}"
+export PRETTY_NAME = "${DISTRO_NAME} ${VERSION}"
+
+export BUILD_ID ?= "${DATETIME}"
+export ID_LIKE
+export ANSI_COLOR
+export CPE_NAME
+export HOME_URL
+export SUPPORT_URL

meta/recipes-core/os-release/os-release.bb line 37

Quoted 10 lines
meta/recipes-core/os-release/os-release.bb new file +10 -0
+export BUG_REPORT_URL
+
+do_compile () {
+    for field in ${OS_RELEASE_FIELDS}; do
+        if eval "test -n \"\$$field\""; then
+            eval "printf \"%s=%s\n\" \"\$field\" \"\$$field\""
+        fi
+    done >os-release
+}
+do_compile[vardeps] += "${OS_RELEASE_FIELDS}"

Isn't this dependency picked automatically?

Quoted 11 lines
meta/recipes-core/os-release/os-release.bb new file +4 -0
+do_install () {
+    install -d ${D}${sysconfdir}
+    install -m 0644 os-release ${D}${sysconfdir}/
+}
Signature · 6 lines
1.8.3.4

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#3 lore raw

Re: [RFC 1/2] os-release: add new operating system identification recipe

Quoted 11 lines · Martin Jansa

meta/recipes-core/os-release/os-release.bb line 37

Quoted 8 lines
meta/recipes-core/os-release/os-release.bb new file +8 -0
+do_compile () {
+    for field in ${OS_RELEASE_FIELDS}; do
+        if eval "test -n \"\$$field\""; then
+            eval "printf \"%s=%s\n\" \"\$field\" \"\$$field\""
+        fi
+    done >os-release
+}
+do_compile[vardeps] += "${OS_RELEASE_FIELDS}"

Isn't this dependency picked automatically?

No, this is expanded, so this adds the dependency on the variables whose names are in the OS_RELEASE_FIELDS variable, not just on OS_RELEASE_FIELDS itself. Due to the use of eval, bitbake doesn’t know we’re using the iterated values as variable names.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#4 lore raw

Re: [RFC 1/2] os-release: add new operating system identification recipe

Quoted 14 lines · Chris Larson
Quoted 11 lines · Martin Jansa

meta/recipes-core/os-release/os-release.bb line 37

Quoted 8 lines
meta/recipes-core/os-release/os-release.bb new file +8 -0
+do_compile () {
+    for field in ${OS_RELEASE_FIELDS}; do
+        if eval "test -n \"\$$field\""; then
+            eval "printf \"%s=%s\n\" \"\$field\" \"\$$field\""
+        fi
+    done >os-release
+}
+do_compile[vardeps] += "${OS_RELEASE_FIELDS}"

Isn't this dependency picked automatically?

Quoted 4 lines

No, this is expanded, so this adds the dependency on the variables whose names are in the OS_RELEASE_FIELDS variable, not just on OS_RELEASE_FIELDS itself. Due to the use of eval, bitbake doesn’t know we’re using the iterated values as variable names.

To put it perhaps more clearly and succinctly, do_compile[vardeps] += “OS_RELEASE_FIELDS” would be unnecessary, do_compile[vardeps] += “${OS_RELEASE_FIELDS}” isn’t :)

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#6 lore raw

Re: [RFC 1/2] os-release: add new operating system identification recipe

In reply to Christopher Larson
Quoted 4 lines · Christopher Larson

From: Christopher Larson <[email protected]>

This is needed by systemd, among other useful applications. All fields are metadata driven, and initial values come from our DISTRO variables.

I thought there was a part of the lsb-release recipe that did this same thing.

It doesn't set the 'os-release' file, but the 'lsb-release' file. Maybe it would make sense to consolidate this stuff into a base-file-...

--Mark

Quoted 55 lines
---
  meta/recipes-core/os-release/os-release.bb | 42 ++++++++++++++++++++++++++++++
  1 file changed, 42 insertions(+)

create mode 100644 meta/recipes-core/os-release/os-release.bb

meta/recipes-core/os-release/os-release.bb new file +42 -0
new file mode 100644
index 0000000..0f67597
@@ -0,0 +1,42 @@
+inherit allarch
+
+SUMMARY = "Operating system identification"
+DESCRIPTION = "The /etc/os-release file contains operating system identification data."
+LICENSE = "MIT"
+INHIBIT_DEFAULT_DEPS = "1"
+
+do_fetch[noexec] = "1"
+do_unpack[noexec] = "1"
+do_patch[noexec] = "1"
+do_configure[noexec] = "1"
+
+# Other valid fields: BUILD_ID ANSI_COLOR CPE_NAME HOME_URL SUPPORT_URL BUG_REPORT_URL
+OS_RELEASE_FIELDS = "ID ID_LIKE NAME VERSION VERSION_ID PRETTY_NAME"
+
+export ID = "${DISTRO}"
+export NAME = "${DISTRO_NAME}"
+export VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in d else ''}"
+export VERSION_ID = "${DISTRO_VERSION}"
+export PRETTY_NAME = "${DISTRO_NAME} ${VERSION}"
+
+export BUILD_ID ?= "${DATETIME}"
+export ID_LIKE
+export ANSI_COLOR
+export CPE_NAME
+export HOME_URL
+export SUPPORT_URL
+export BUG_REPORT_URL
+
+do_compile () {
+    for field in ${OS_RELEASE_FIELDS}; do
+        if eval "test -n \"\$$field\""; then
+            eval "printf \"%s=%s\n\" \"\$field\" \"\$$field\""
+        fi
+    done >os-release
+}
+do_compile[vardeps] += "${OS_RELEASE_FIELDS}"
+
+do_install () {
+    install -d ${D}${sysconfdir}
+    install -m 0644 os-release ${D}${sysconfdir}/
+}
#7 lore raw

Re: [RFC 1/2] os-release: add new operating system identification recipe

Quoted 8 lines · Mark Hatle
Quoted 5 lines · Christopher Larson

From: Christopher Larson <[email protected]>

This is needed by systemd, among other useful applications. All fields are metadata driven, and initial values come from our DISTRO variables.

Quoted 5 lines

I thought there was a part of the lsb-release recipe that did this same thing.

It doesn't set the 'os-release' file, but the 'lsb-release' file. Maybe it would make sense to consolidate this stuff into a base-file-...

Yeah, that’s part of why I posted this as an RFC, there’s this question of whether such things should just get folded into base-files, or stay separate. I don’t have a very strong opinion on it either way, myself.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
#9 lore raw

Re: [RFC 1/2] os-release: add new operating system identification recipe

In reply to Christopher Larson

Christopher Larson <[email protected]>

meta/recipes-core/os-release/os-release.bb line 33

Quoted 2 lines · writes:
meta/recipes-core/os-release/os-release.bb new file +2 -0
+        if eval "test -n \"\$$field\""; then
+            eval "printf \"%s=%s\n\" \"\$field\" \"\$$field\""

I think, this can be expressed without the complicated quoting as

eval val=\$$field
if test -n "$val"; then
printf '%s="%s"\n' "$field" "$val"

Enrico

#8 lore raw

Re: [RFC 1/2] os-release: add new operating system identification recipe

In reply to Chris Larson

Op 13 dec. 2013, om 17:14 heeft Chris Larson <[email protected]> het volgende geschreven:

Quoted 13 lines · Mark Hatle

On 12/13/13, 8:56 AM, Christopher Larson wrote:
From: Christopher Larson <[email protected]>

This is needed by systemd, among other useful applications. All fields are metadata driven, and initial values come from our DISTRO variables.

I thought there was a part of the lsb-release recipe that did this same thing.

It doesn't set the 'os-release' file, but the 'lsb-release' file. Maybe it would make sense to consolidate this stuff into a base-file-...

Yeah, that’s part of why I posted this as an RFC, there’s this question of whether such things should just get folded into base-files, or stay separate. I don’t have a very strong opinion on it either way, myself.

Angstrom has both lsb_release and os-release in its 'angstrom-release' package. It looks like this release could provide os-release in a more generic way.

regards,

Koen

#10 lore raw

Re: [RFC 1/2] os-release: add new operating system identification recipe

In reply to Christopher Larson

Op 13 dec. 2013, om 15:56 heeft Christopher Larson <[email protected]> het volgende geschreven:

Quoted 27 lines

From: Christopher Larson <[email protected]>

This is needed by systemd, among other useful applications. All fields are metadata driven, and initial values come from our DISTRO variables.

---
meta/recipes-core/os-release/os-release.bb | 42 ++++++++++++++++++++++++++++++

1 file changed, 42 insertions(+)

create mode 100644 meta/recipes-core/os-release/os-release.bb

meta/recipes-core/os-release/os-release.bb new file +10 -0
new file mode 100644
index 0000000..0f67597
@@ -0,0 +1,42 @@
+inherit allarch
+
+SUMMARY = "Operating system identification"
+DESCRIPTION = "The /etc/os-release file contains operating system identification data."
+LICENSE = "MIT"
+INHIBIT_DEFAULT_DEPS = "1"
+
+do_fetch[noexec] = "1"
+do_unpack[noexec] = "1"
+do_patch[noexec] = "1"

meta/recipes-core/os-release/os-release.bb line 20

Quoted 10 lines
meta/recipes-core/os-release/os-release.bb new file +10 -0
+do_configure[noexec] = "1"
+
+# Other valid fields: BUILD_ID ANSI_COLOR CPE_NAME HOME_URL SUPPORT_URL BUG_REPORT_URL
+OS_RELEASE_FIELDS = "ID ID_LIKE NAME VERSION VERSION_ID PRETTY_NAME"
+
+export ID = "${DISTRO}"
+export NAME = "${DISTRO_NAME}"
+export VERSION = "${DISTRO_VERSION}${@' (%s)' % DISTRO_CODENAME if 'DISTRO_CODENAME' in d else ''}"
+export VERSION_ID = "${DISTRO_VERSION}"
+export PRETTY_NAME = "${DISTRO_NAME} ${VERSION}"

Is DISTRO_NAME allowed to have spaces and weird characters? In OE-classic is was used as part of the outputnames in various things, but it looks that's safe in OE-core (not in meta-angstrom, though).

regards,

Koen

#5 lore raw

Re: [RFC 1/2] os-release: add new operating system identification recipe

In reply to Chris Larson
Quoted 14 lines · Chris Larson
Quoted 11 lines · Martin Jansa

meta/recipes-core/os-release/os-release.bb line 37

Quoted 8 lines
meta/recipes-core/os-release/os-release.bb new file +8 -0
+do_compile () {
+    for field in ${OS_RELEASE_FIELDS}; do
+        if eval "test -n \"\$$field\""; then
+            eval "printf \"%s=%s\n\" \"\$field\" \"\$$field\""
+        fi
+    done >os-release
+}
+do_compile[vardeps] += "${OS_RELEASE_FIELDS}"

Isn't this dependency picked automatically?

Quoted 4 lines

No, this is expanded, so this adds the dependency on the variables whose names are in the OS_RELEASE_FIELDS variable, not just on OS_RELEASE_FIELDS itself. Due to the use of eval, bitbake doesn’t know we’re using the iterated values as variable names.

Ah I see, thanks for explanation.

Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]