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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
import os
import re
from jhbuild.commands import Command, register_command
from jhbuild.utils.cmds import get_output
def _check_command_success(args):
pid = os.fork()
if not pid:
os.execvp(args[0], args)
return os.wait()[1] == 0
def _check_module(module, version):
args = [ 'pkg-config', module, '--atleast-version', version ]
return _check_command_success(args)
def _check_command(cmd, regexp, minver):
try:
data = get_output(cmd)
except:
return False
match = re.search(regexp, data, re.MULTILINE)
if not match: return False
version = match.group(1)
version = version.split('.')
for i, ver in enumerate(version):
part = re.sub(r'^[^\d]*(\d+).*$', r'\1', ver)
if not part:
version[i] = None
else:
version[i] = int(part)
minver = minver.split('.')
for i, ver in enumerate(minver):
part = re.sub(r'^[^\d]*(\d+).*$', r'\1', ver)
if not part:
minver[i] = None
else:
minver[i] = int(part)
return version >= minver
class DependencyChecker:
def __init__(self):
self._missing = []
self._base_dir = os.path.abspath(os.path.dirname(__file__))
def check_python(self, version):
if not _check_command(['python', '-V'],
r'Python ([\d.]+)', '2.5'):
self._missing.append('python %s' % version)
def check_python_headers(self):
cmd = os.path.join(self._base_dir, 'check-python-headers')
if not _check_command_success([ cmd ]):
self._missing.append('python (headers)')
def check_automake(self, version):
if not _check_command(['automake-%s' % version, '--version'],
r'automake \([^)]*\) ([\d.]+)', version):
self._missing.append('automake %s' % version)
def check_libtool(self, version):
if not _check_command(['libtoolize', '--version'],
r'libtoolize \([^)]*\) ([\d.]+)', version):
self._missing.append('libtool %s' % version)
def check_intltool(self, version):
if not _check_command(['intltoolize', '--version'],
r'intltoolize \([^)]*\) ([\d.]+)', version):
self._missing.append('intltoolize %s' % version)
def check_library(self, name, version):
if not _check_module(name, version):
self._missing.append('%s %s' % (name, version))
def get_missing(self):
return self._missing
class cmd_sanitycheck(Command):
name = 'sanitycheck'
usage_args = ''
def run(self, config, options, args):
checker = DependencyChecker()
checker.check_automake('1.9')
checker.check_libtool('1.5')
checker.check_intltool('0.35.0')
checker.check_library('gstreamer-0.10', '0.10')
checker.check_library('gstreamer-plugins-base-0.10', '0.10')
if len(checker.get_missing()) > 0:
print 'Missing external dependencies:'
for missing in checker.get_missing():
print missing
#sys.exit(1)
checker = DependencyChecker()
checker.check_python('2.5')
checker.check_python_headers()
checker.check_library('glib-2.0', '2.12')
checker.check_library('gtk+-2.0', '2.10')
checker.check_library('pygtk-2.0', '2.10')
checker.check_library('pycairo', '1.2')
# FIXME Check gecko
if len(checker.get_missing()) > 0:
print 'Missing dependencies:'
for missing in checker.get_missing():
print missing
register_command(cmd_sanitycheck)
|