示例#1
0
文件: base.py 项目: BeIP/novabuild
    def uncompress_tarball(self, module, destination):
        filename = os.path.join('tarballs', module['Basename'])
        if not os.path.exists(filename):
            fetch(module)

        dest_parent = os.path.dirname(destination)

        print blue("Uncompressing '%s'" % filename)
        if filename.endswith('.tar.bz2') or filename.endswith('.tbz'):
            check_code(system('tar xjf %s -C %s' % (filename, dest_parent)),
                       module)
        elif filename.endswith('.tar.gz') or filename.endswith('.tgz'):
            check_code(system('tar xzf %s -C %s' % (filename, dest_parent)),
                       module)
        elif filename.endswith('.zip'):
            check_code(system('unzip %s -d %s' % (filename, dest_parent)),
                       module)
        else:
            raise Exception("Cannot find the type of the archive.")

        # Put the directory in the tarball in the right directory
        if not os.path.exists(destination):
            contents = os.listdir(dest_parent)
            if len(contents) == 1 and os.path.isdir(
                    '%s/%s' % (dest_parent, contents[0])):
                check_code(
                    system('mv "%s/%s" %s' %
                           (dest_parent, contents[0], destination)), module)
            else:
                check_code(system('mkdir %s' % destination), module)
                files = [os.path.join(dest_parent, file) for file in contents]
                check_code(system('mv %s %s' % (' '.join(files), destination)),
                           module)
示例#2
0
文件: base.py 项目: BeIP/novabuild
    def uncompress_tarball(self, module, destination):
        filename = os.path.join('tarballs', module['Basename'])
        if not os.path.exists(filename):
            fetch(module)

        dest_parent = os.path.dirname(destination)

        print blue("Uncompressing '%s'" % filename)
        if filename.endswith('.tar.bz2') or filename.endswith('.tbz'):
            check_code(system('tar xjf %s -C %s' % (filename, dest_parent)), module)
        elif filename.endswith('.tar.gz') or filename.endswith('.tgz'):
            check_code(system('tar xzf %s -C %s' % (filename, dest_parent)), module)
        elif filename.endswith('.zip'):
            check_code(system('unzip %s -d %s' % (filename, dest_parent)), module)
        else:
            raise Exception("Cannot find the type of the archive.")

        # Put the directory in the tarball in the right directory
        if not os.path.exists(destination):
            contents = os.listdir(dest_parent)
            if len(contents) == 1 and os.path.isdir('%s/%s' % (dest_parent, contents[0])):
                check_code(system('mv "%s/%s" %s' % (dest_parent, contents[0], destination)), module)
            else:
                check_code(system('mkdir %s' % destination), module)
                files = [os.path.join(dest_parent, file) for file in contents]
                check_code(system('mv %s %s' % (' '.join(files), destination)), module)
示例#3
0
def main(args):
    for mod_name in sorted(args.moduleset):
        try:
            module = args.moduleset[mod_name]
            print blue("Fetching '%s' from '%s'" % (module.name, module['Source']))
            fetch(module)
        except Exception, e:
            print red(e)
            status = 1
示例#4
0
def main(args):
    for mod_name in sorted(args.moduleset):
        try:
            module = args.moduleset[mod_name]
            print blue("Fetching '%s' from '%s'" %
                       (module.name, module['Source']))
            fetch(module)
        except Exception, e:
            print red(e)
            status = 1