'Try to guess the type of build system used by a project based on
the contents of its archive or the URL it was downloaded from.'

def __call__(self, stage, url):

    if ('downloads.sourceforge.net/octave/' in url):
        self.build_system = 'octave'
        return
    clues = [('/CMakeLists\\.txt$', 'cmake'), ('/configure$', 'autotools'), ('/configure\\.(in|ac)$', 'autoreconf'), ('/Makefile\\.am$', 'autoreconf'), ('/SConstruct$', 'scons'), ('/waf$', 'waf'), ('/setup\\.py$', 'python'), ('/NAMESPACE$', 'r'), ('/WORKSPACE$', 'bazel'), ('/Build\\.PL$', 'perlbuild'), ('/Makefile\\.PL$', 'perlmake'), ('/.*\\.pro$', 'qmake'), ('/(GNU)?[Mm]akefile$', 'makefile')]
    if stage.archive_file.endswith('.zip'):
        try:
            unzip = which('unzip')
            output = unzip('-lq', stage.archive_file, output=str)
        except:
            output = ''
    else:
        try:
            tar = which('tar')
            output = tar('--exclude=*/*/*', '-tf', stage.archive_file, output=str)
        except:
            output = ''
    lines = output.split('\n')
    for (pattern, bs) in clues:
        if any((re.search(pattern, l) for l in lines)):
            self.build_system = bs
            break
