aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-core
diff options
context:
space:
mode:
authorJoshua Lock <joshua.g.lock@intel.com>2016-02-24 14:52:14 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-28 11:32:37 +0000
commitd3975099af20d78b634c23b3ddd073049b016b05 (patch)
treea4bd11745e777d0e124c77ee4a42628bd97a375f /meta/recipes-core
parentc8be8890e0a9c9d5f1532c4ee4fe9a346ed3ca5b (diff)
downloadopenembedded-core-contrib-d3975099af20d78b634c23b3ddd073049b016b05.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. Signed-off-by: Joshua Lock <joshua.g.lock@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta/recipes-core')
-rw-r--r--meta/recipes-core/os-release/os-release.bb9
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 58364ea2491..f519addd8d6 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}"
BUILD_ID ?= "${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 () {
import shutil
with open(d.expand('${B}/os-release'), 'w') as f:
for field in d.getVar('OS_RELEASE_FIELDS', True).split():
value = d.getVar(field, True)
+ if value and field == 'VERSION_ID':
+ value = sanitise_version(value)
if value:
f.write('{0}="{1}"\n'.format(field, value))
}