File: lsb-platform.dpatch

package info (click to toggle)
python2.4 2.4.6-1%2Blenny1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 44,888 kB
  • ctags: 86,995
  • sloc: ansic: 306,391; python: 271,931; sh: 10,210; makefile: 4,248; perl: 3,736; lisp: 3,678; xml: 894; objc: 756; cpp: 7; sed: 2
file content (53 lines) | stat: -rw-r--r-- 1,479 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /bin/sh -e

# DP: determine the platform from /etc/lsb-release

dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
    pdir="-d $3"
    dir="$3/"
elif [ $# -ne 1 ]; then
    echo >&2 "usage: `basename $0`: -patch|-unpatch [-d <srcdir>]"
    exit 1
fi
case "$1" in
    -patch)
        patch $pdir -f --no-backup-if-mismatch -p0 < $0
        ;;
    -unpatch)
        patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
        ;;
    *)
	echo >&2 "usage: `basename $0`: -patch|-unpatch [-d <srcdir>]"
        exit 1
esac
exit 0

--- Lib/platform.py~	2005-11-21 18:01:49.000000000 +0100
+++ Lib/platform.py	2006-09-25 13:42:26.584505750 +0200
@@ -236,6 +236,25 @@
     except os.error:
         # Probably not a Unix system
         return distname,version,id
+
+    if os.path.exists('/etc/lsb-release'):
+        for line in open('/etc/lsb-release'):
+            line = line.strip()
+            if not line:
+                continue
+            var, arg = line.split('=', 1)
+            if var.startswith('DISTRIB_'):
+                var = var[8:]
+                if arg.startswith('"') and arg.endswith('"'):
+                    arg = arg[1:-1]
+                if var == 'ID':
+                    distname = arg
+                elif var == 'RELEASE':
+                    version = arg
+                elif var == 'CODENAME':
+                    id = arg
+        return distname,version,id
+
     for file in etc:
         m = _release_filename.match(file)
         if m: