~ubuntu-branches/ubuntu/natty/jhbuild/natty

« back to all changes in this revision

Viewing changes to jhbuild/commands/sanitycheck.py

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort, Loic Minier, Emilio Pozuelo Monfort
  • Date: 2009-11-09 20:28:48 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20091109202848-m9ec7dmzptqtchtj
Tags: 2.28.0-1
[ Loic Minier ]
* Cleanups.
* Ship scripts.
* Don't set GNOME_MODULE as it equals the name of the source package.

[ Emilio Pozuelo Monfort ]
* New upstream release. Closes: #524504.
  - Use 'git rev-parse' rather than 'git-rev-parse'. Closes: #544642.
* Ship install-check. Closes: #441008.
* Uploaders list regenerated. Closes: #523542, #554071.
* debian/control.in,
  debian/rules:
  - Stop shipping a copy of subprocess.py. Require python >= 2.4.
  - Switch to python-support.
* debian/control.in:
  - Bump Standards-Version to 3.8.3, no changes needed.
  - Build depend on intltool >= 0.35.0.
  - Build depend on pkg-config, gnome-doc-utils and rarian-compat to build
    the documentation.
  - Make jhbuild arch any since install-check is a binary. Depend on
    ${shlibs:Depends}.
  - Recommend, and not suggest, git-core. Also recommend mercurial.
* debian/watch:
  - Added.
* debian/patches/01_import_from_pkgdatadir.patch:
  - Added, import jhbuild from pkgdatadir if everything else fails.
    This way we can ship the jhbuild private modules in /usr/sharejhbuild.
* debian/jhbuild.docs:
  - Removed, the necessary docs are now installed by the upstream Makefile.
* debian/rules:
  - Include autotools.mk and gnome.mk.
  - Remove all the manual build process, autotools.mk does everything now.
  - Install the jhbuild modules in /usr/share/jhbuild.
* debian/install:
  - Install the modulesets and patches from here since the upstream build
    system doesn't install them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import re
23
23
 
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
27
27
 
28
 
def check_version(cmd, regexp, minver):
29
 
    try:
30
 
        data = get_output(cmd)
31
 
    except:
32
 
        return False
33
 
    match = re.match(regexp, data, re.MULTILINE)
34
 
    if not match: return False
35
 
    version = match.group(1)
36
 
 
37
 
    version = version.split('.')
38
 
    for i, ver in enumerate(version):
39
 
        part = re.sub(r'^[^\d]*(\d+).*$', r'\1', ver)
40
 
        if not part:
41
 
            version[i] = None
42
 
        else:
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)
47
 
        if not part:
48
 
            minver[i] = None
49
 
        else:
50
 
            minver[i] = int(part)
51
 
    return version >= minver
52
 
 
53
28
def get_aclocal_path(version):
54
29
    data = get_output(['aclocal-%s' % version, '--print-ac-dir'])
55
30
    path = [data[:-1]]
67
42
    for dir in path:
68
43
        if os.path.isfile(os.path.join(dir, filename)):
69
44
            return True
 
45
        # also check for filename.exe on Windows
 
46
        if sys.platform.startswith('win') and os.path.isfile(os.path.join(dir, filename + '.exe')):
 
47
            return True
70
48
    return False
71
49
 
72
50
 
73
51
class cmd_sanitycheck(Command):
74
 
    """Check that required support tools are available"""
 
52
    doc = N_('Check that required support tools are available')
75
53
 
76
54
    name = 'sanitycheck'
77
55
    usage_args = ''
78
56
 
79
57
    def run(self, config, options, args):
80
58
        if args:
81
 
            raise UsageError('no extra arguments expected')
 
59
            raise UsageError(_('no extra arguments expected'))
82
60
    
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)
90
68
 
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')
119
97
 
 
98
        not_in_path = []
120
99
        for amver in ('1.4', '1.7', '1.8', '1.9'):
121
100
            try:
122
101
                path = get_aclocal_path(amver)
123
102
            except:
124
103
                continue # exception raised if aclocal-ver not runnable
125
104
 
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']
 
106
            for macro in macros:
 
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)
 
111
 
 
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))))
132
115
 
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'))
136
119
        else:
137
120
            for (item, name) in [('-//OASIS//DTD DocBook XML V4.1.2//EN',
138
121
                                  'DocBook XML DTD V4.1.2'),
141
124
                try:
142
125
                    data = get_output(['xmlcatalog', '/etc/xml/catalog', item])
143
126
                except:
144
 
                    print 'Could not find %s in XML catalog' % name            
 
127
                    uprint(_('Could not find %s in XML catalog') % name            )
145
128
 
146
129
        # Perl modules used by tools such as intltool:
147
130
        for perlmod in [ 'XML::Parser' ]:
148
131
            try:
149
132
                get_output(['perl', '-M%s' % perlmod, '-e', 'exit'])
150
133
            except:
151
 
                print 'Could not find the perl module %s' % perlmod
 
134
                uprint(_('Could not find the perl module %s') % perlmod)
152
135
                
153
136
        # check for cvs:
154
137
        if not inpath('cvs', os.environ['PATH'].split(os.pathsep)):
155
 
            print 'cvs not found'
 
138
            uprint(_('%s not found') % 'cvs')
156
139
 
157
140
        # check for svn:
158
141
        if not inpath('svn', os.environ['PATH'].split(os.pathsep)):
159
 
            print 'svn not found'
 
142
            uprint(_('%s not found') % 'svn')
160
143
 
161
144
        # check for git:
162
145
        if not inpath('git', os.environ['PATH'].split(os.pathsep)):
163
 
            print 'git not found'
 
146
            uprint(_('%s not found') % 'git')
164
147
        else:
165
148
            try:
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'))
 
152
                else:
 
153
                    if not check_version(['git', '--version'],
 
154
                                 r'git version ([\d.]+)', '1.5.6'):
 
155
                         uprint(_('%s not found') % 'git >= 1.5.6')
169
156
            except:
170
 
                print 'Could not check git program'
171
 
 
172
 
        # check for svn:
173
 
        if not inpath('svn', os.environ['PATH'].split(os.pathsep)):
174
 
            print 'svn not found'
 
157
                uprint(_('Could not check git program'))
175
158
 
176
159
register_command(cmd_sanitycheck)