24
24
from jhbuild.commands import Command, register_command
25
from jhbuild.utils.cmds import get_output
25
from jhbuild.utils.cmds import get_output, check_version
26
26
from jhbuild.errors import UsageError, FatalError
28
def check_version(cmd, regexp, minver):
30
data = get_output(cmd)
33
match = re.match(regexp, data, re.MULTILINE)
34
if not match: return False
35
version = match.group(1)
37
version = version.split('.')
38
for i, ver in enumerate(version):
39
part = re.sub(r'^[^\d]*(\d+).*$', r'\1', ver)
43
version[i] = int(part)
44
minver = minver.split('.')
45
for i, ver in enumerate(minver):
46
part = re.sub(r'^[^\d]*(\d+).*$', r'\1', ver)
51
return version >= minver
53
28
def get_aclocal_path(version):
54
29
data = get_output(['aclocal-%s' % version, '--print-ac-dir'])
68
43
if os.path.isfile(os.path.join(dir, filename)):
45
# also check for filename.exe on Windows
46
if sys.platform.startswith('win') and os.path.isfile(os.path.join(dir, filename + '.exe')):
73
51
class cmd_sanitycheck(Command):
74
"""Check that required support tools are available"""
52
doc = N_('Check that required support tools are available')
76
54
name = 'sanitycheck'
79
57
def run(self, config, options, args):
81
raise UsageError('no extra arguments expected')
59
raise UsageError(_('no extra arguments expected'))
83
61
# check whether the checkout root and install prefix are writable
84
62
if not (os.path.isdir(config.checkoutroot) and
85
63
os.access(config.checkoutroot, os.R_OK|os.W_OK|os.X_OK)):
86
print 'checkout root is not writable'
64
uprint(_('checkout root (%s) is not writable') % config.checkoutroot)
87
65
if not (os.path.isdir(config.prefix) and
88
66
os.access(config.prefix, os.R_OK|os.W_OK|os.X_OK)):
89
print 'install prefix is not writable'
67
uprint(_('install prefix (%s) is not writable') % config.prefix)
91
69
# check whether various tools are installed
92
70
if not check_version(['libtoolize', '--version'],
93
71
r'libtoolize \([^)]*\) ([\d.]+)', '1.5'):
94
print 'libtool >= 1.5 not found'
72
uprint(_('%s not found') % 'libtool >= 1.5')
95
73
if not check_version(['gettext', '--version'],
96
74
r'gettext \([^)]*\) ([\d.]+)', '0.10.40'):
97
print 'gettext >= 0.10.40 not found'
75
uprint(_('%s not found') % 'gettext >= 0.10.40')
98
76
if not check_version(['pkg-config', '--version'],
99
77
r'^([\d.]+)', '0.14.0'):
100
print 'pkg-config >= 0.14.0 not found'
78
uprint(_('%s not found') % 'pkg-config >= 0.14.0')
101
79
if not check_version(['db2html', '--version'],
102
80
r'.* ([\d.]+)', '0.0'):
103
print 'db2html not found'
81
uprint(_('%s not found') % 'db2html')
104
82
if not check_version(['autoconf', '--version'],
105
83
r'autoconf \([^)]*\) ([\d.]+)', '2.53'):
106
print 'autoconf >= 2.53 not found'
84
uprint(_('%s not found') % 'autoconf >= 2.53')
107
85
if not check_version(['automake-1.4', '--version'],
108
86
r'automake \([^)]*\) ([\d.]+)', '1.4'):
109
print 'automake-1.4 not found'
87
uprint(_('%s not found') % 'automake-1.4')
110
88
if not check_version(['automake-1.7', '--version'],
111
89
r'automake \([^)]*\) ([\d.]+)', '1.7'):
112
print 'automake-1.7 not found'
90
uprint(_('%s not found') % 'automake-1.7')
113
91
if not check_version(['automake-1.8', '--version'],
114
92
r'automake \([^)]*\) ([\d.]+)', '1.8'):
115
print 'automake-1.8 not found'
93
uprint(_('%s not found') % 'automake-1.8')
116
94
if not check_version(['automake-1.9', '--version'],
117
95
r'automake \([^)]*\) ([\d.]+)', '1.9'):
118
print 'automake-1.9 not found'
96
uprint(_('%s not found') % 'automake-1.9')
120
99
for amver in ('1.4', '1.7', '1.8', '1.9'):
122
101
path = get_aclocal_path(amver)
124
103
continue # exception raised if aclocal-ver not runnable
126
if not inpath('libtool.m4', path):
127
print "aclocal-%s can't see libtool macros" % amver
128
if not inpath('gettext.m4', path):
129
print "aclocal-%s can't see gettext macros" % amver
130
if not inpath('pkg.m4', path):
131
print "aclocal-%s can't see pkg-config macros" % amver
105
macros = ['libtool.m4', 'gettext.m4', 'pkg.m4']
107
if not inpath (macro, path):
108
uprint(_("aclocal-%s can't see %s macros") % (amver, macro.split('.m4')[0]))
109
if not_in_path.count(macro) == 0:
110
not_in_path.append(macro)
112
if len(not_in_path) > 0:
113
uprint(_("Please copy the lacking macros (%s) in one of the following paths: %s"
114
% (', '.join(not_in_path), ', '.join(path))))
133
116
# XML catalog sanity checks
134
117
if not os.access('/etc/xml/catalog', os.R_OK):
135
print 'Could not find XML catalog'
118
uprint(_('Could not find XML catalog'))
137
120
for (item, name) in [('-//OASIS//DTD DocBook XML V4.1.2//EN',
138
121
'DocBook XML DTD V4.1.2'),
142
125
data = get_output(['xmlcatalog', '/etc/xml/catalog', item])
144
print 'Could not find %s in XML catalog' % name
127
uprint(_('Could not find %s in XML catalog') % name )
146
129
# Perl modules used by tools such as intltool:
147
130
for perlmod in [ 'XML::Parser' ]:
149
132
get_output(['perl', '-M%s' % perlmod, '-e', 'exit'])
151
print 'Could not find the perl module %s' % perlmod
134
uprint(_('Could not find the perl module %s') % perlmod)
154
137
if not inpath('cvs', os.environ['PATH'].split(os.pathsep)):
155
print 'cvs not found'
138
uprint(_('%s not found') % 'cvs')
158
141
if not inpath('svn', os.environ['PATH'].split(os.pathsep)):
159
print 'svn not found'
142
uprint(_('%s not found') % 'svn')
162
145
if not inpath('git', os.environ['PATH'].split(os.pathsep)):
163
print 'git not found'
146
uprint(_('%s not found') % 'git')
166
149
git_help = os.popen('git --help', 'r').read()
167
150
if not 'clone' in git_help:
168
print 'Installed git program is not the right git'
151
uprint(_('Installed git program is not the right git'))
153
if not check_version(['git', '--version'],
154
r'git version ([\d.]+)', '1.5.6'):
155
uprint(_('%s not found') % 'git >= 1.5.6')
170
print 'Could not check git program'
173
if not inpath('svn', os.environ['PATH'].split(os.pathsep)):
174
print 'svn not found'
157
uprint(_('Could not check git program'))
176
159
register_command(cmd_sanitycheck)