diff options
Diffstat (limited to 'debian/patches/platform-lsbrelease')
-rw-r--r-- | debian/patches/platform-lsbrelease | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/debian/patches/platform-lsbrelease b/debian/patches/platform-lsbrelease new file mode 100644 index 0000000..d5f3204 --- /dev/null +++ b/debian/patches/platform-lsbrelease @@ -0,0 +1,55 @@ +From: Stefano Rivera <stefanor@debian.org> +Date: Sat, 7 Oct 2017 09:38:58 +0200 +Subject: Use /etc/lsb-release to identify the platform + +Author: Matthias Klose <doko@debian.org> +Bug-Ubuntu: https://bugs.launchpad.net/bugs/196526 +Bug-cpython: http://bugs.python.org/issue1322 +Bug-cpython: http://bugs.python.org/issue9514 +Origin: cpython Debian packaging +Last-Update: 2011-12-19 +--- + lib-python/2.7/platform.py | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +diff --git a/lib-python/2.7/platform.py b/lib-python/2.7/platform.py +index 55f2fa8..e4dc14a 100755 +--- a/lib-python/2.7/platform.py ++++ b/lib-python/2.7/platform.py +@@ -290,6 +290,10 @@ def _parse_release_file(firstline): + id = l[1] + return '', version, id + ++_distributor_id_file_re = re.compile("(?:DISTRIB_ID\s*=)\s*(.*)", re.I) ++_release_file_re = re.compile("(?:DISTRIB_RELEASE\s*=)\s*(.*)", re.I) ++_codename_file_re = re.compile("(?:DISTRIB_CODENAME\s*=)\s*(.*)", re.I) ++ + def linux_distribution(distname='', version='', id='', + + supported_dists=_supported_dists, +@@ -314,6 +318,25 @@ def linux_distribution(distname='', version='', id='', + args given as parameters. + + """ ++ # check for the Debian/Ubuntu /etc/lsb-release file first, needed so ++ # that the distribution doesn't get identified as Debian. ++ try: ++ etclsbrel = open("/etc/lsb-release", "rU") ++ for line in etclsbrel: ++ m = _distributor_id_file_re.search(line) ++ if m: ++ _u_distname = m.group(1).strip() ++ m = _release_file_re.search(line) ++ if m: ++ _u_version = m.group(1).strip() ++ m = _codename_file_re.search(line) ++ if m: ++ _u_id = m.group(1).strip() ++ if _u_distname and _u_version: ++ return (_u_distname, _u_version, _u_id) ++ except (EnvironmentError, UnboundLocalError): ++ pass ++ + try: + etc = os.listdir('/etc') + except os.error: |