[oe-commits] [openembedded-core] 55/116: os-release: sanitise VERSION_ID field

git at git.openembedded.org git at git.openembedded.org
Sun Feb 28 11:29:41 UTC 2016


rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit c77be0322be46b665a0df4c6f590165a791b69b4
Author: Joshua Lock <joshua.g.lock at intel.com>
AuthorDate: Wed Feb 24 14:52:14 2016 +0000

    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 at intel.com>
    Signed-off-by: Ross Burton <ross.burton at intel.com>
---
 meta/recipes-core/os-release/os-release.bb | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/meta/recipes-core/os-release/os-release.bb b/meta/recipes-core/os-release/os-release.bb
index 58364ea..f519add 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))
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list