~ubuntu-branches/ubuntu/natty/python3.1/natty-security

« back to all changes in this revision

Viewing changes to debian/patches/platform-lsbrelease.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-07-06 16:52:42 UTC
  • mfrom: (1.2.1 upstream) (2.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20100706165242-2xv4i019r3et6c0j
Tags: 3.1.2+20100706-1ubuntu1
* Merge with Debian; remaining changes:
  - Regenerate the control file.
  - Add debian/patches/overwrite-semaphore-check for Lucid buildds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh -e
2
 
 
3
 
# DP: Use /etc/lsb-release to identify the platform.
4
 
 
5
 
dir=
6
 
if [ $# -eq 3 -a "$2" = '-d' ]; then
7
 
    pdir="-d $3"
8
 
    dir="$3/"
9
 
elif [ $# -ne 1 ]; then
10
 
    echo >&2 "usage: `basename $0`: -patch|-unpatch [-d <srcdir>]"
11
 
    exit 1
12
 
fi
13
 
case "$1" in
14
 
    -patch)
15
 
        patch $pdir -f --no-backup-if-mismatch -p0 < $0
16
 
        ;;
17
 
    -unpatch)
18
 
        patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
19
 
        ;;
20
 
    *)
21
 
        echo >&2 "usage: `basename $0`: -patch|-unpatch [-d <srcdir>]"
22
 
        exit 1
23
 
esac
24
 
exit 0
25
 
 
26
 
--- Lib/platform.py.orig        2008-10-25 17:49:17.000000000 +0200
27
 
+++ Lib/platform.py     2009-03-19 10:50:23.000000000 +0100
28
 
@@ -266,6 +266,10 @@
29
 
             id = ''
30
 
     return '', version, id
31
 
 
32
 
+_distributor_id_file_re = re.compile("(?:DISTRIB_ID\s*=)\s*(.*)", re.I)
33
 
+_release_file_re = re.compile("(?:DISTRIB_RELEASE\s*=)\s*(.*)", re.I)
34
 
+_codename_file_re = re.compile("(?:DISTRIB_CODENAME\s*=)\s*(.*)", re.I)
35
 
+
36
 
 def linux_distribution(distname='', version='', id='',
37
 
 
38
 
                        supported_dists=_supported_dists,
39
 
@@ -290,6 +294,25 @@
40
 
         args given as parameters.
41
 
 
42
 
     """
43
 
+    # check for the Debian/Ubuntu /etc/lsb-release file first, needed so
44
 
+    # that the distribution doesn't get identified as Debian.
45
 
+    try:
46
 
+        etclsbrel = open("/etc/lsb-release", "rU")
47
 
+        for line in etclsbrel:
48
 
+            m = _distributor_id_file_re.search(line)
49
 
+            if m:
50
 
+                _u_distname = m.group(1).strip()
51
 
+            m = _release_file_re.search(line)
52
 
+            if m:
53
 
+                _u_version = m.group(1).strip()
54
 
+            m = _codename_file_re.search(line)
55
 
+            if m:
56
 
+                _u_id = m.group(1).strip()
57
 
+        if _u_distname and _u_version:
58
 
+            return (_u_distname, _u_version, _u_id)
59
 
+    except (EnvironmentError, UnboundLocalError):
60
 
+            pass
61
 
+
62
 
     try:
63
 
         etc = os.listdir('/etc')
64
 
     except os.error: