diff options
author | Joshua Lock <joshua.g.lock@intel.com> | 2016-02-24 14:52:14 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-02-28 11:33:02 +0000 |
commit | 2269f90b9f01564b99c282c6c927e15d593ad3e7 (patch) | |
tree | 101a476732e045a53ae66541acdd160792dc2788 /meta/recipes-core/os-release | |
parent | 9d86b268f26609366e42360a81c39d38f7a1eb99 (diff) | |
download | poky-2269f90b9f01564b99c282c6c927e15d593ad3e7.tar.gz |
os-release: sanitise VERSION_ID field
Per os-release(5) the VERSION_ID field should be:
a lower-case string (mostly numeric, no spaces or other characters
outside of 0-9, a-z, ".", "_" and "-")
Do some string manipulation to try and ensure the VERSION_ID field
we write is valid.
(From OE-Core rev: d3975099af20d78b634c23b3ddd073049b016b05)
Signed-off-by: Joshua Lock <joshua.g.lock@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/os-release')
-rw-r--r-- | meta/recipes-core/os-release/os-release.bb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/meta/recipes-core/os-release/os-release.bb b/meta/recipes-core/os-release/os-release.bb index 58364ea249..f519addd8d 100644 --- a/meta/recipes-core/os-release/os-release.bb +++ b/meta/recipes-core/os-release/os-release.bb | |||
@@ -23,11 +23,20 @@ PRETTY_NAME = "${DISTRO_NAME} ${VERSION}" | |||
23 | BUILD_ID ?= "${DATETIME}" | 23 | BUILD_ID ?= "${DATETIME}" |
24 | BUILD_ID[vardepsexclude] = "DATETIME" | 24 | BUILD_ID[vardepsexclude] = "DATETIME" |
25 | 25 | ||
26 | def sanitise_version(ver): | ||
27 | # VERSION_ID should be (from os-release(5)): | ||
28 | # lower-case string (mostly numeric, no spaces or other characters | ||
29 | # outside of 0-9, a-z, ".", "_" and "-") | ||
30 | ret = ver.replace('+', '-').replace(' ','_') | ||
31 | return ret.lower() | ||
32 | |||
26 | python do_compile () { | 33 | python do_compile () { |
27 | import shutil | 34 | import shutil |
28 | with open(d.expand('${B}/os-release'), 'w') as f: | 35 | with open(d.expand('${B}/os-release'), 'w') as f: |
29 | for field in d.getVar('OS_RELEASE_FIELDS', True).split(): | 36 | for field in d.getVar('OS_RELEASE_FIELDS', True).split(): |
30 | value = d.getVar(field, True) | 37 | value = d.getVar(field, True) |
38 | if value and field == 'VERSION_ID': | ||
39 | value = sanitise_version(value) | ||
31 | if value: | 40 | if value: |
32 | f.write('{0}="{1}"\n'.format(field, value)) | 41 | f.write('{0}="{1}"\n'.format(field, value)) |
33 | } | 42 | } |