diff options
author | Ross Burton <ross.burton@intel.com> | 2016-04-12 18:04:22 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-04-13 10:12:52 +0100 |
commit | 175263e5847cbd5eb2f272a76084238ef6835ab7 (patch) | |
tree | 363b5de0b0f14417d3eb33ee40ed308e560234f0 | |
parent | 9262d2ff39f898605fe6f4224a4684e782439497 (diff) | |
download | poky-175263e5847cbd5eb2f272a76084238ef6835ab7.tar.gz |
lib/oe/lsb: sanitise the distro identifier
The distribution identifier is often used to create filenames, so it needs to be
safe to use as a filename. Whilst most distributions have e.g. Fedora or Debian
as their name, it is possible that the name contains special characters.
To ensure this doesn't cause a problem strip out any non-alphanumerics from the
distribution name before returning it.
[ YOCTO #9443 ]
(From OE-Core rev: 8a96a7207561e00eb92e4fb69e7340f20bfa2053)
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oe/lsb.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/meta/lib/oe/lsb.py b/meta/lib/oe/lsb.py index ddfe71b6b5..e0bdfba255 100644 --- a/meta/lib/oe/lsb.py +++ b/meta/lib/oe/lsb.py | |||
@@ -62,6 +62,8 @@ def distro_identifier(adjust_hook=None): | |||
62 | """Return a distro identifier string based upon lsb_release -ri, | 62 | """Return a distro identifier string based upon lsb_release -ri, |
63 | with optional adjustment via a hook""" | 63 | with optional adjustment via a hook""" |
64 | 64 | ||
65 | import re | ||
66 | |||
65 | lsb_data = release_dict() | 67 | lsb_data = release_dict() |
66 | if lsb_data: | 68 | if lsb_data: |
67 | distro_id, release = lsb_data['Distributor ID'], lsb_data['Release'] | 69 | distro_id, release = lsb_data['Distributor ID'], lsb_data['Release'] |
@@ -76,6 +78,9 @@ def distro_identifier(adjust_hook=None): | |||
76 | distro_id, release = adjust_hook(distro_id, release) | 78 | distro_id, release = adjust_hook(distro_id, release) |
77 | if not distro_id: | 79 | if not distro_id: |
78 | return "Unknown" | 80 | return "Unknown" |
81 | # Filter out any non-alphanumerics | ||
82 | distro_id = re.sub(r'\W', '', distro_id) | ||
83 | |||
79 | if release: | 84 | if release: |
80 | id_str = '{0}-{1}'.format(distro_id, release) | 85 | id_str = '{0}-{1}'.format(distro_id, release) |
81 | else: | 86 | else: |