Пример #1
0
def run(cmd):
    if os.geteuid() != 0:
        cmd.err("This script must be run as root")
        return 1
    if not os.path.exists(cmd.opts.output_dir):
        os.mkdir(cmd.opts.output_dir)
    if cmd.opts.proxy_ip is None:
        proxy_ip = socket.gethostname()
    else:
        proxy_ip = cmd.opts.proxy_ip
        if not valid_ip(proxy_ip):
            cmd.err('Not a recognised IP address %r', proxy_ip)
            return 1
    vm_ip_part = cmd.args[0]
    if not '.' in vm_ip_part:
        vm_ip = '192.168.100.'+vm_ip_part
    else:
        vm_ip = vm_ip_part
        vm_ip_part = vm_ip.split('.')[-1]
    if not valid_ip(vm_ip):
        cmd.err('Not a recognised IP address %r', vm_ip)
        return 1
    if vm_ip_part in ['0','1','255','254']:
        cmd.err('The VM IP address cannot end with .%s', host_ip_part)
        return 1
    opts = stacks.str_keys(cmd.opts, ignore=['help', 'proxy_ip'])
    base_ip='.'.join(vm_ip.split('.')[:3])
    result = build(cmd, vm_ip_part, base_ip, proxy_ip=proxy_ip, arch=cmd.dist.determine_arch(), **opts)
Пример #2
0
def run(cmd):
    src_dir = cmd.args[0]
    ## Check for errors
    count = 0
    for name in ['deb', 'rpm', 'debian_dir']:
        if cmd.opts[name]:
            count += 1
    if not count:
        cmd.err('ERROR: Expected at least one of --deb, --rpm or debian_dir')
        return 1
    if not os.path.exists(src_dir):
        cmd.err('ERROR: No such directory %r', src_dir)
        return 1
    opts = stacks.str_keys(cmd.opts, ignore=['help', 'license_file'])
    if opts.no_package and opts.rpm:
        cmd.err('ERROR: You can\'t specify both --rpm and --no-package options together')
        return 1
    ## Prepare the options
    opts['license_text'] = ''
    if cmd.opts.license_file is not None:
        fp = open(cmd.opts.license_file, 'r')
        opts['license_text'] = fp.read()
        fp.close()
    # See if any pip requirements have changed
    conflict_modules = {}
    for dep in cmd.opts.conflict_module:
        k, v = dep.split('->')
        conflict_modules[k.strip()] = v.strip()
    opts['conflict_module'] = conflict_modules
    deps_rename = {}
    for dep in cmd.opts.deps_rename:
        k, v = dep.split('->')
        deps_rename[k.strip()] = v.strip()
    opts['deps_rename'] = deps_rename
    build_dir = os.path.join(src_dir, 'build')
    if not cmd.opts.output_dir:
        if not os.path.exists(os.path.join(src_dir, 'dist')):
            os.mkdir(os.path.join(src_dir, 'dist'))
        if not os.path.exists(os.path.join(src_dir, 'dist', 'buildkit')):
            os.mkdir(os.path.join(src_dir, 'dist', 'buildkit'))
        opts['output_dir'] = os.path.join(src_dir, 'dist', 'buildkit')
    if not os.path.exists(build_dir):
        os.mkdir(build_dir)
    bk_build_dir = os.path.join(build_dir, 'buildkit')
    if not os.path.exists(bk_build_dir):
        os.mkdir(bk_build_dir)
    opts['build_env_dir'] = os.path.join(bk_build_dir, 'env')
    results = []
    build_python(cmd, opts, results)
    for result in results:
        if result.error:
            cmd.err(result.error)
            return 1
    cmd.out('Building took place in %r', opts['build_env_dir'])
    cmd.out('Packages were placed in %r', opts['output_dir'])
Пример #3
0
def run(cmd):
    count = 0
    for name in ['deb', 'rpm']:
        if cmd.opts[name]:
            count += 1
    if not count:
        cmd.err('ERROR: Expected at least one of --deb or --rpm')
        return 1
    if not os.path.exists(cmd.args[0]):
        cmd.err('ERROR: No such directory %r', cmd.args[0])
        return 1
    opts = stacks.str_keys(cmd.opts, ignore=['help'])
    if opts.has_key('output_dir'):
        opts['output_dir'] = stacks.uniform_path(opts['output_dir'])
    result = cmd.parent.dist.build_non_python(
        stacks.uniform_path(cmd.args[0]),
        **opts
    )
    if result.get('error'):
        cmd.err(result.error)
        return 1