Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpgritti@gmail.com>2008-09-29 12:01:11 (GMT)
committer Marco Pesenti Gritti <mpgritti@gmail.com>2008-09-29 12:01:11 (GMT)
commit8946a7a8caca50ae090700a568da6875c02f0ed1 (patch)
tree360c76c90205f43c15b910153e0cce648e10ede1 /scripts
parentf68e51871f2e868ac8b966e102f82d93ff852fc5 (diff)
Reqork ubuntu/debian sysdeps checks.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/sysdeps.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/scripts/sysdeps.py b/scripts/sysdeps.py
index d321beb..10ca122 100644
--- a/scripts/sysdeps.py
+++ b/scripts/sysdeps.py
@@ -7,9 +7,7 @@ scripts_dir = os.path.dirname(__file__)
base_dir = os.path.dirname(scripts_dir)
def get_distribution():
- name = None
- version = None
-
+ # Fedora
if os.path.exists('/etc/fedora-release'):
name = 'fedora'
@@ -21,14 +19,24 @@ def get_distribution():
version = 'rawhide'
else:
version = full_name.split(' ')[2]
- elif os.path.exists('/etc/lsb-release'):
- name = os.popen('lsb_release -is', 'r').read().strip().lower()
- version = os.popen('lsb_release -rs', 'r').read().strip()
+
+ return name, version
+
+ # Debian and Ubuntu
+ try:
+ out, err = subprocess.call(['lsb_release', '-is']).communicate()
+ name = out.strip().lower()
+ out, err = subprocess.call(['lsb_release', '-is']).communicate()
+ version = out.strip()
if name == 'debian' and version == 'testing':
version = 'unstable'
- return name, version
+ return name, version
+ except OSError:
+ pass
+
+ return None, None
def check_package(package):
name, version = get_distribution()
@@ -36,8 +44,9 @@ def check_package(package):
ret = subprocess.call(['rpm', '--quiet', '-q', package])
return ret == 0
elif name in ['ubuntu', 'debian']:
- status = os.popen("dpkg-query -f='${status}' -W %s" % package).read()
- return status.find('install ok installed') != -1
+ cmd = ["dpkg-query", "-f='${status}'", "-W %s"]
+ stdout, stderr = subprocess.call(cmd).communicate()
+ return stdout.find('install ok installed') != -1
return None