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

login
register
mail settings
Submitter Christopher Larson
Date Dec. 13, 2013, 2:56 p.m.
Message ID <6122710ad05d4a2c1fa2d42fba3025cae6dab5ed.1386946335.git.kergoth@gmail.com>
Download mbox | patch
Permalink /patch/63341/
State New
Headers show

Comments

Christopher Larson - Dec. 13, 2013, 2:56 p.m.
From: Christopher Larson <chris_larson@mentor.com>

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

Signed-off-by: Christopher Larson <kergoth@gmail.com>
---
 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
Martin Jansa - Dec. 13, 2013, 3:08 p.m.
On Fri, Dec 13, 2013 at 07:56:37AM -0700, Christopher Larson wrote:
> From: Christopher Larson <chris_larson@mentor.com>
> 
> This is needed by systemd, among other useful applications. All fields are
> metadata driven, and initial values come from our DISTRO variables.
> 
> Signed-off-by: Christopher Larson <kergoth@gmail.com>
> ---
>  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
> 
> diff --git a/meta/recipes-core/os-release/os-release.bb b/meta/recipes-core/os-release/os-release.bb
> new file mode 100644
> index 0000000..0f67597
> --- /dev/null
> +++ b/meta/recipes-core/os-release/os-release.bb
> @@ -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}"

Isn't this dependency picked automatically?

> +do_install () {
> +    install -d ${D}${sysconfdir}
> +    install -m 0644 os-release ${D}${sysconfdir}/
> +}
> -- 
> 1.8.3.4
> 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
Christopher Larson - Dec. 13, 2013, 3:12 p.m.
On Fri, Dec 13, 2013 at 8:08 AM, Martin Jansa <martin.jansa@gmail.com>wrote:

> > +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.
Christopher Larson - Dec. 13, 2013, 3:18 p.m.
On Fri, Dec 13, 2013 at 8:12 AM, Chris Larson <kergoth@gmail.com> wrote:

> On Fri, Dec 13, 2013 at 8:08 AM, Martin Jansa <martin.jansa@gmail.com>wrote:
>
>> > +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.


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 :)
Mark Hatle - Dec. 13, 2013, 3:56 p.m.
On 12/13/13, 8:56 AM, Christopher Larson wrote:
> From: Christopher Larson <chris_larson@mentor.com>
>
> 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

> Signed-off-by: Christopher Larson <kergoth@gmail.com>
> ---
>   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
>
> diff --git a/meta/recipes-core/os-release/os-release.bb b/meta/recipes-core/os-release/os-release.bb
> new file mode 100644
> index 0000000..0f67597
> --- /dev/null
> +++ b/meta/recipes-core/os-release/os-release.bb
> @@ -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}/
> +}
>
Chris Larson - Dec. 13, 2013, 4:14 p.m.
On Fri, Dec 13, 2013 at 8:56 AM, Mark Hatle <mark.hatle@windriver.com>wrote:

> On 12/13/13, 8:56 AM, Christopher Larson wrote:
>
>> From: Christopher Larson <chris_larson@mentor.com>
>>
>> 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.
Enrico Scholz - Dec. 13, 2013, 4:27 p.m.
Christopher Larson <kergoth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
writes:

> +        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
Koen Kooi - Dec. 13, 2013, 4:30 p.m.
Op 13 dec. 2013, om 17:14 heeft Chris Larson <clarson@kergoth.com> het volgende geschreven:

> 
> On Fri, Dec 13, 2013 at 8:56 AM, Mark Hatle <mark.hatle@windriver.com> wrote:
> On 12/13/13, 8:56 AM, Christopher Larson wrote:
> From: Christopher Larson <chris_larson@mentor.com>
> 
> 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
Koen Kooi - Dec. 13, 2013, 4:31 p.m.
Op 13 dec. 2013, om 15:56 heeft Christopher Larson <kergoth@gmail.com> het volgende geschreven:

> From: Christopher Larson <chris_larson@mentor.com>
> 
> This is needed by systemd, among other useful applications. All fields are
> metadata driven, and initial values come from our DISTRO variables.
> 
> Signed-off-by: Christopher Larson <kergoth@gmail.com>
> ---
> 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
> 
> diff --git a/meta/recipes-core/os-release/os-release.bb b/meta/recipes-core/os-release/os-release.bb
> new file mode 100644
> index 0000000..0f67597
> --- /dev/null
> +++ b/meta/recipes-core/os-release/os-release.bb
> @@ -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}"

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
Martin Jansa - Dec. 13, 2013, 4:33 p.m.
On Fri, Dec 13, 2013 at 08:12:51AM -0700, Chris Larson wrote:
> On Fri, Dec 13, 2013 at 8:08 AM, Martin Jansa <martin.jansa@gmail.com>wrote:
> 
> > > +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.

Ah I see, thanks for explanation.

Patch

diff --git a/meta/recipes-core/os-release/os-release.bb b/meta/recipes-core/os-release/os-release.bb
new file mode 100644
index 0000000..0f67597
--- /dev/null
+++ b/meta/recipes-core/os-release/os-release.bb
@@ -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}/
+}