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>
This commit is contained in:
parent
9d86b268f2
commit
2269f90b9f
|
@ -23,11 +23,20 @@ PRETTY_NAME = "${DISTRO_NAME} ${VERSION}"
|
||||||
BUILD_ID ?= "${DATETIME}"
|
BUILD_ID ?= "${DATETIME}"
|
||||||
BUILD_ID[vardepsexclude] = "DATETIME"
|
BUILD_ID[vardepsexclude] = "DATETIME"
|
||||||
|
|
||||||
|
def sanitise_version(ver):
|
||||||
|
# VERSION_ID should be (from os-release(5)):
|
||||||
|
# lower-case string (mostly numeric, no spaces or other characters
|
||||||
|
# outside of 0-9, a-z, ".", "_" and "-")
|
||||||
|
ret = ver.replace('+', '-').replace(' ','_')
|
||||||
|
return ret.lower()
|
||||||
|
|
||||||
python do_compile () {
|
python do_compile () {
|
||||||
import shutil
|
import shutil
|
||||||
with open(d.expand('${B}/os-release'), 'w') as f:
|
with open(d.expand('${B}/os-release'), 'w') as f:
|
||||||
for field in d.getVar('OS_RELEASE_FIELDS', True).split():
|
for field in d.getVar('OS_RELEASE_FIELDS', True).split():
|
||||||
value = d.getVar(field, True)
|
value = d.getVar(field, True)
|
||||||
|
if value and field == 'VERSION_ID':
|
||||||
|
value = sanitise_version(value)
|
||||||
if value:
|
if value:
|
||||||
f.write('{0}="{1}"\n'.format(field, value))
|
f.write('{0}="{1}"\n'.format(field, value))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue