diff options
| -rw-r--r-- | meta/recipes-core/os-release/os-release.bb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/meta/recipes-core/os-release/os-release.bb b/meta/recipes-core/os-release/os-release.bb index d5793c6fed..a29d678125 100644 --- a/meta/recipes-core/os-release/os-release.bb +++ b/meta/recipes-core/os-release/os-release.bb | |||
| @@ -13,6 +13,7 @@ do_configure[noexec] = "1" | |||
| 13 | # Other valid fields: BUILD_ID ID_LIKE ANSI_COLOR CPE_NAME | 13 | # Other valid fields: BUILD_ID ID_LIKE ANSI_COLOR CPE_NAME |
| 14 | # HOME_URL SUPPORT_URL BUG_REPORT_URL | 14 | # HOME_URL SUPPORT_URL BUG_REPORT_URL |
| 15 | OS_RELEASE_FIELDS = "ID ID_LIKE NAME VERSION VERSION_ID PRETTY_NAME" | 15 | OS_RELEASE_FIELDS = "ID ID_LIKE NAME VERSION VERSION_ID PRETTY_NAME" |
| 16 | OS_RELEASE_UNQUOTED_FIELDS = "ID VERSION_ID VARIANT_ID" | ||
| 16 | 17 | ||
| 17 | ID = "${DISTRO}" | 18 | ID = "${DISTRO}" |
| 18 | NAME = "${DISTRO_NAME}" | 19 | NAME = "${DISTRO_NAME}" |
| @@ -22,8 +23,8 @@ PRETTY_NAME = "${DISTRO_NAME} ${VERSION}" | |||
| 22 | BUILD_ID ?= "${DATETIME}" | 23 | BUILD_ID ?= "${DATETIME}" |
| 23 | BUILD_ID[vardepsexclude] = "DATETIME" | 24 | BUILD_ID[vardepsexclude] = "DATETIME" |
| 24 | 25 | ||
| 25 | def sanitise_version(ver): | 26 | def sanitise_value(ver): |
| 26 | # VERSION_ID should be (from os-release(5)): | 27 | # unquoted fields like VERSION_ID should be (from os-release(5)): |
| 27 | # lower-case string (mostly numeric, no spaces or other characters | 28 | # lower-case string (mostly numeric, no spaces or other characters |
| 28 | # outside of 0-9, a-z, ".", "_" and "-") | 29 | # outside of 0-9, a-z, ".", "_" and "-") |
| 29 | ret = ver.replace('+', '-').replace(' ','_') | 30 | ret = ver.replace('+', '-').replace(' ','_') |
| @@ -32,11 +33,14 @@ def sanitise_version(ver): | |||
| 32 | python do_compile () { | 33 | python do_compile () { |
| 33 | with open(d.expand('${B}/os-release'), 'w') as f: | 34 | with open(d.expand('${B}/os-release'), 'w') as f: |
| 34 | for field in d.getVar('OS_RELEASE_FIELDS').split(): | 35 | for field in d.getVar('OS_RELEASE_FIELDS').split(): |
| 36 | unquotedFields = d.getVar('OS_RELEASE_UNQUOTED_FIELDS').split() | ||
| 35 | value = d.getVar(field) | 37 | value = d.getVar(field) |
| 36 | if value and field == 'VERSION_ID': | ||
| 37 | value = sanitise_version(value) | ||
| 38 | if value: | 38 | if value: |
| 39 | f.write('{0}="{1}"\n'.format(field, value)) | 39 | if field in unquotedFields: |
| 40 | value = sanitise_value(value) | ||
| 41 | f.write('{0}={1}\n'.format(field, value)) | ||
| 42 | else: | ||
| 43 | f.write('{0}="{1}"\n'.format(field, value)) | ||
| 40 | } | 44 | } |
| 41 | do_compile[vardeps] += "${OS_RELEASE_FIELDS}" | 45 | do_compile[vardeps] += "${OS_RELEASE_FIELDS}" |
| 42 | 46 | ||
