Beispiel #1
0
def test_program(lst,
                 program,
                 minimal,
                 description='',
                 package=None,
                 env={},
                 logger=sys.stderr):
    if not package:
        package = program
    if not description:
        description = package
    key = (program.upper().replace('+-', 'X_'))
    logger.write('Checking for %(program)s ... ' % locals())
    if key in list(env.keys()):
        f = env[key]
        logger.write('(cached) ')
    else:
        f = misc.path_find(os.environ['PATH'], program)
        env[key] = f
    if not f:
        logger.write('not found\n')
        entry = (description, package, minimal, program, 'not installed')
        if not entry in lst:
            lst.append(entry)
        return 0
    logger.write(f + '\n')
    if minimal:
        return test_version(lst, program, minimal, description, package,
                            logger)
    return 1
Beispiel #2
0
    def execute (self, logger):
        package = self.package
        autodir = package.expand ('%(autodir)s')
        PATH = package.expand ('%(PATH)s')
        if os.path.exists (os.path.join (autodir, 'autogen.sh')):
            s = open ('%(autodir)s/autogen.sh' % locals ()).read ()
            noconfigure = ' --help'
            if '--noconfigure' in s:
                noconfigure = ' --noconfigure' + noconfigure
            self.system ('cd %(autodir)s && NOCONFIGURE=1 sh autogen.sh %(noconfigure)s' % locals (),
                         logger)
        elif (os.path.exists (os.path.join (autodir, 'bootstrap'))
              and not 'CC=' in open (os.path.join (autodir, 'bootstrap')).read ()):
            self.system ('cd %(autodir)s && ./bootstrap' % locals (), logger)
        elif (os.path.exists (os.path.join (autodir, 'bootstrap.sh'))
              and not 'CC=' in open (os.path.join (autodir, 'bootstrap.sh')).read ()):
            self.system ('cd %(autodir)s && ./bootstrap.sh' % locals (), logger)
        else:
            libtoolize = misc.path_find (PATH, 'libtoolize')
            if libtoolize:
                s = open (libtoolize).read ()
                libtoolize = 'libtoolize --copy --force'
                # --automake is mandatory for libtool-1.5.2x, but breaks with libtool-2.2.x
                # --install is mandatory for libtool-2.2.x, but breaks with libtool-1.5.2x
                # mandatory means: so that config.guess, config.sub are refreshed iso removed
                if '--automake' in s:
                    libtoolize += ' --automake'
                if '--install' in s:
                    libtoolize += ' --install'
                if (os.path.isdir (os.path.join (autodir, 'ltdl'))
                    or os.path.isdir (os.path.join (autodir, 'libltdl'))):
                    libtoolize += ' --ltdl'
                self.system ('rm -rf %(autodir)s/libltdl %(autodir)s/ltdl && cd %(autodir)s && %(libtoolize)s'
                             % locals (), logger)
            aclocal_flags = ''
            for dir in package.aclocal_path ():
                d = package.expand (dir)
                if os.path.exists (d):
                    aclocal_flags += ' -I%(d)s' % locals ()
            headcmd = ''
            configure_ac = ''
            for c in ('configure.in','configure.ac'):
                try:
                    string = open ('%(autodir)s/%(c)s' % locals ()).read ()
                    configure_ac = c
                    m = re.search ('A[CM]_CONFIG_HEADER', string)
                    string = 0   ## don't want to expand string
                    if m:
                        headcmd = 'cd %(autodir)s && autoheader %(aclocal_flags)s' % locals ()
                        break
                except IOError:
                    pass
            if configure_ac:
                self.system ('''
cd %(autodir)s && aclocal %(aclocal_flags)s
%(headcmd)s
cd %(autodir)s && autoconf %(aclocal_flags)s
''' % locals (), logger)
            if os.path.exists ('%(autodir)s/Makefile.am' % locals ()):
                self.system ('cd %(autodir)s && automake --add-missing --copy --foreign' % locals (), logger)
Beispiel #3
0
def test_program (lst, program, minimal, description='', package=None, env={}, logger=sys.stderr):
    if not package:
        package = program
    if not description:
        description = package
    key = (program.upper ()
           .replace ('+-', 'X_'))
    logger.write ('Checking for %(program)s ... ' % locals ())
    if key in list (env.keys ()):
        f = env[key]
        logger.write ('(cached) ')
    else:
        f = misc.path_find (os.environ['PATH'], program)
        env[key] = f
    if not f:
        logger.write ('not found\n')
        entry = (description, package, minimal, program, 'not installed')
        if not entry in lst:
            lst.append (entry)
        return 0
    logger.write (f + '\n')
    if minimal:
        return test_version (lst, program, minimal, description, package, logger)
    return 1
Beispiel #4
0
    def execute(self, logger):
        package = self.package
        autodir = package.expand('%(autodir)s')
        PATH = package.expand('%(PATH)s')
        if os.path.exists(os.path.join(autodir, 'autogen.sh')):
            s = open('%(autodir)s/autogen.sh' % locals()).read()
            noconfigure = ' --help'
            if '--noconfigure' in s:
                noconfigure = ' --noconfigure' + noconfigure
            self.system(
                'cd %(autodir)s && NOCONFIGURE=1 sh autogen.sh %(noconfigure)s'
                % locals(), logger)
        elif (os.path.exists(os.path.join(autodir, 'bootstrap')) and
              not 'CC=' in open(os.path.join(autodir, 'bootstrap')).read()):
            self.system('cd %(autodir)s && ./bootstrap' % locals(), logger)
        elif (os.path.exists(os.path.join(autodir, 'bootstrap.sh')) and
              not 'CC=' in open(os.path.join(autodir, 'bootstrap.sh')).read()):
            self.system('cd %(autodir)s && ./bootstrap.sh' % locals(), logger)
        else:
            libtoolize = misc.path_find(PATH, 'libtoolize')
            if libtoolize:
                s = open(libtoolize).read()
                libtoolize = 'libtoolize --copy --force'
                # --automake is mandatory for libtool-1.5.2x, but breaks with libtool-2.2.x
                # --install is mandatory for libtool-2.2.x, but breaks with libtool-1.5.2x
                # mandatory means: so that config.guess, config.sub are refreshed iso removed
                if '--automake' in s:
                    libtoolize += ' --automake'
                if '--install' in s:
                    libtoolize += ' --install'
                if (os.path.isdir(os.path.join(autodir, 'ltdl'))
                        or os.path.isdir(os.path.join(autodir, 'libltdl'))):
                    libtoolize += ' --ltdl'
                self.system(
                    'rm -rf %(autodir)s/libltdl %(autodir)s/ltdl && cd %(autodir)s && %(libtoolize)s'
                    % locals(), logger)
            aclocal_flags = ''
            for dir in package.aclocal_path():
                d = package.expand(dir)
                if os.path.exists(d):
                    aclocal_flags += ' -I%(d)s' % locals()
            headcmd = ''
            configure_ac = ''
            for c in ('configure.in', 'configure.ac'):
                try:
                    string = open('%(autodir)s/%(c)s' % locals()).read()
                    configure_ac = c
                    m = re.search('A[CM]_CONFIG_HEADER', string)
                    string = 0  ## don't want to expand string
                    if m:
                        headcmd = 'cd %(autodir)s && autoheader %(aclocal_flags)s' % locals(
                        )
                        break
                except IOError:
                    pass
            if configure_ac:
                self.system(
                    '''
cd %(autodir)s && aclocal %(aclocal_flags)s
%(headcmd)s
cd %(autodir)s && autoconf %(aclocal_flags)s
''' % locals(), logger)
            if os.path.exists('%(autodir)s/Makefile.am' % locals()):
                self.system(
                    'cd %(autodir)s && automake --add-missing --copy --foreign'
                    % locals(), logger)