summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core')
-rw-r--r--meta/recipes-core/os-release/os-release.bb14
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
15OS_RELEASE_FIELDS = "ID ID_LIKE NAME VERSION VERSION_ID PRETTY_NAME" 15OS_RELEASE_FIELDS = "ID ID_LIKE NAME VERSION VERSION_ID PRETTY_NAME"
16OS_RELEASE_UNQUOTED_FIELDS = "ID VERSION_ID VARIANT_ID"
16 17
17ID = "${DISTRO}" 18ID = "${DISTRO}"
18NAME = "${DISTRO_NAME}" 19NAME = "${DISTRO_NAME}"
@@ -22,8 +23,8 @@ PRETTY_NAME = "${DISTRO_NAME} ${VERSION}"
22BUILD_ID ?= "${DATETIME}" 23BUILD_ID ?= "${DATETIME}"
23BUILD_ID[vardepsexclude] = "DATETIME" 24BUILD_ID[vardepsexclude] = "DATETIME"
24 25
25def sanitise_version(ver): 26def 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):
32python do_compile () { 33python 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}
41do_compile[vardeps] += "${OS_RELEASE_FIELDS}" 45do_compile[vardeps] += "${OS_RELEASE_FIELDS}"
42 46