Пример #1
0
def _download_git(url, tag, dst, pkg, version):
    name = '{0}-{1}'.format(pkg, version)
    fn = name + '.tar.gz'

    if os.path.isfile(os.path.join(
            dst, fn)) and not os.path.isdir(os.path.join(dst, name)):
        return fn

    safe_rmdir(os.path.join(dst, name))

    cmd = ['git', 'clone', url, name]
    ret, out, err = call(cmd, cwd=dst)
    if ret != 0:
        raise Exception('Download git Failed: {0}'.format(url))

    cmd = ['git', 'checkout', tag]
    ret, out, err = call(cmd, cwd=os.path.join(dst, name))
    if ret != 0:
        raise Exception('Git checkout Failed: {0}'.format(url))

    safe_rmdir(os.path.join(dst, name, '.git'))

    cmd = ['tar', '-czf', fn, name]
    ret, out, err = call(cmd, cwd=dst)
    if ret != 0:
        raise Exception('Tar git repo Failed: {0}'.format(name))

    #safe_rmdir(os.path.join(dst, name))

    return fn
Пример #2
0
def run(param):
    version = param['version']

    tar_filename = param['config_package']['source']['file'].format(
        version=version)
    tar_file = os.path.join(param['package_path']['misc_dir'], 'download',
                            tar_filename)
    main_dir = param['config_package']['source'].get(
        'main', '').format(version=version)

    dst_dir = param['config_package'].get('path', {}).get('source')
    if not dst_dir:
        return {'success': False, 'message': 'Path "source" is not specified'}

    safe_rmdir(dst_dir)
    safe_mkdir(dst_dir)

    if main_dir:
        strip_number = main_dir.strip(os.sep).count(os.sep) + 1
        cmd = [
            'tar', '--strip-components',
            str(strip_number), '-xvf', tar_file, main_dir
        ]
    else:
        cmd = ['tar', '-xvf', tar_file]

    with open(param['log_file'], 'w') as f:
        ret = call_and_log(cmd, log=f, cwd=dst_dir)

    return {'success': ret == 0, 'message': 'Tar exit code: {0}'.format(ret)}
Пример #3
0
def run(param):
    version = param['version']
    url = param['config_package']['source']['url'].format(version=version)

    source_dir = param['config_package'].get('path', {}).get('source')
    if not source_dir:
        return {'success': False, 'message': 'Path "source" is not specified'}

    safe_rmdir(source_dir)
    safe_mkdir(source_dir)

    cmd = ['svn', 'export', '--force', url, source_dir]
    with open(param['log_file'], 'w') as f:
        ret = call_and_log(cmd, log=f)

    return {'success': ret == 0, 'message': 'Svn exit code: {0}'.format(ret)}
Пример #4
0
def run(param):
    version = param['version']

    url = param['config_package']['source']['url'].format(version=version)
    filename = param['config_package']['source']['file'].format(
        version=version)
    md5url = param['config_package']['source'].get('md5url',
                                                   '').format(version=version)
    dst_dir = os.path.join(param['package_path']['misc_dir'], 'download')

    safe_rmdir(dst_dir)
    safe_mkdir(dst_dir)

    with open(param['log_file'], 'w') as f:
        cmd = ['curl', '-v', '-f', '-L', '-s', '-S', '-R', '-O', url]
        ret = call_and_log(cmd, log=f, cwd=dst_dir)
        if ret != 0:
            return {
                'success': False,
                'message':
                'File download error, CURL exit code: {0}'.format(ret)
            }

        if md5url:
            cmd = [
                'curl', '-v', '-f', '-L', '-s', '-S', '-R', '-o', 'md5sum.txt',
                md5url
            ]
            ret = call_and_log(cmd, log=f, cwd=dst_dir)
            if ret != 0:
                return {
                    'success':
                    False,
                    'message':
                    'md5sum download error, CURL exit code: {0}'.format(ret)
                }

            cmd = ['md5sum', '-c', 'md5sum.txt']
            ret = call_and_log(cmd, log=f, cwd=dst_dir)
            if ret != 0:
                return {
                    'success': False,
                    'message': 'md5 checksum error: {0}'.format(ret)
                }

    return {'success': ret == 0, 'message': 'CURL exit code: {0}'.format(ret)}
Пример #5
0
def _install_from_git_repo(src_repo, release_version, version_pattern, dst_dir,
                           git_temp):
    git = Git(dst_dir, git_temp=git_temp)

    versions = list_versions(src_repo, version_pattern, git)

    if release_version not in versions:
        raise ReleaseVersionError(
            'Release version "{0}" does not exist in repo {1}'.format(
                release_version, src_repo))

    release_tag = versions[release_version]

    safe_rmdir(dst_dir)

    git.clone(src_repo)
    git.checkout(release_tag)
    git.clear_git_info()
Пример #6
0
def _download_svn(url, dst, pkg, version):
    name = '{0}-{1}'.format(pkg, version)
    fn = name + '.tar.gz'

    if os.path.isfile(os.path.join(
            dst, fn)) and not os.path.isdir(os.path.join(dst, name)):
        return fn

    cmd = ['svn', 'export', '--force', url, name]
    ret, out, err = call(cmd, cwd=dst)
    if ret != 0:
        raise Exception('Download svn Failed: {0}'.format(url))

    cmd = ['tar', '-czf', fn, name]
    ret, out, err = call(cmd, cwd=dst)
    if ret != 0:
        raise Exception('Tar svn repo Failed: {0}'.format(name))

    safe_rmdir(os.path.join(dst, name))

    return fn
Пример #7
0
def run(param):
    source_dir = param['config_package'].get('path', {}).get('source')
    if not source_dir:
        return {'success': False, 'message': 'Path "source" is not specified'}

    build_dir = param['config_package'].get('path', {}).get('build')
    if not build_dir:
        return {'success': False, 'message': 'Path "build" is not specified'}

    install_dir = param['config_package'].get('path', {}).get('install')
    if not install_dir:
        return {'success': False, 'message': 'Path "install" is not specified'}


    if source_dir != build_dir:
        safe_rmdir(build_dir)
    safe_mkdir(build_dir)


    cmake_args = param['config_package'].get('cmake', {}).get('args', [])
    cmake_args = ensure_list(cmake_args)
    cmake_args = [p.format(**param['config_package_install_path']) for p in cmake_args]

    if not param['config_package'].get('cmake', {}).get('ignore_install_prefix', False):
        cmake_args.insert(0, '-DCMAKE_INSTALL_PREFIX='+install_dir)

    cmake_var = param['config_package'].get('cmake', {}).get('var', {})
    for k, v in cmake_var.items():
        full_value = v.format(**param['config_package_install_path'])
        full_arg = '-D{0}={1}'.format(k, full_value)
        cmake_args.append(full_arg)


    env = param.get('env')

    with open(param['log_file'], 'w') as f:
        cmd = ['cmake', source_dir] + cmake_args
        ret = call_and_log(cmd, log=f, cwd=build_dir, env=env)

    return {'success': ret==0, 'message': 'CMake exit code: {0}'.format(ret)}
Пример #8
0
def run(param):
    clean_dirs = param['config_package'].get('clean', [])

    ['build', 'download', 'source', 'log']
    for d in clean_dirs:
        if d in ['source', 'build']:
            dir_path = param['config_package'].get('path', {}).get(d)
        elif d == 'download':
            dir_path = os.path.join(param['package_path']['misc_dir'],
                                    'download')
        elif d == 'log':
            dir_path = param['package_path']['log_dir']
        else:
            continue

        if dir_path:
            safe_rmdir(dir_path)
            _logger.debug('Clean "{0}": {1}'.format(d, dir_path))
        else:
            _logger.warn('Clean directory not found for: {0}'.format(d))

    return True
Пример #9
0
def run(param):
    source_dir = param['config_package'].get('path', {}).get('source')
    if not source_dir:
        return {'success': False, 'message': 'Path "source" is not specified'}

    build_dir = param['config_package'].get('path', {}).get('build')
    if not build_dir:
        return {'success': False, 'message': 'Path "build" is not specified'}

    install_dir = param['config_package'].get('path', {}).get('install')
    if not install_dir:
        return {'success': False, 'message': 'Path "install" is not specified'}


    if source_dir != build_dir:
        safe_rmdir(build_dir)
    safe_mkdir(build_dir)


    configure_args = param['config_package'].get('configure', {}).get('args', [])
    configure_args = ensure_list(configure_args)
    configure_args = [p.format(**param['config_package_install_path']) for p in configure_args]

    if not param['config_package'].get('configure', {}).get('ignore_install_prefix', False):
        configure_args.insert(0, '--prefix='+install_dir)

    env = param.get('env')
    env_configure = env.copy()
    for k, v in param['config_package'].get('configure', {}).get('env', {}).items():
        env_configure[k] = v.format(**param['config_package_install_path'])

    configure_path = os.path.join(source_dir, 'configure')


    with open(param['log_file'], 'w') as f:
        cmd = [configure_path] + configure_args
        ret = call_and_log(cmd, log=f, cwd=build_dir, env=env_configure)

    return {'success': ret==0, 'message': 'Configure exit code: {0}'.format(ret)}
Пример #10
0
def run(param):
    version = param['version']
    url = param['config_package']['source']['url']
    tag = param['config_package']['source'].get('tag',
                                                '').format(version=version)
    keep_dotgit = param['config_package']['source'].get('keep_dotgit', False)
    branch = param['config_package']['source'].get('branch', 'develop')

    if not tag:
        return {'success': False, 'message': 'Git tag is not specified'}

    source_dir = param['config_package'].get('path', {}).get('source')
    if not source_dir:
        return {'success': False, 'message': 'Path "source" is not specified'}

    safe_rmdir(source_dir)
    safe_mkdir(source_dir)

    with open(param['log_file'], 'w') as f:
        cmd = ['git', 'clone', url, source_dir]
        ret = call_and_log(cmd, log=f)
        if ret != 0:
            return {
                'success': False,
                'message': 'Git clone exit code: {0}'.format(ret)
            }

        cmd = ['git', 'checkout', tag, '-b', branch]
        ret = call_and_log(cmd, log=f, cwd=source_dir)
        if ret != 0:
            return {
                'success': False,
                'message': 'Git checkout tag exit code: {0}'.format(ret)
            }

    if not keep_dotgit:
        safe_rmdir(os.path.join(source_dir, '.git'))

    return {'success': ret == 0, 'message': 'Git OK'}
Пример #11
0
 def clear_git_info(self):
     if self.__path is not None:
         safe_rmdir(os.path.join(self.__path, '.git'))
Пример #12
0
def _install_from_dir(src_dir, dst_dir):
    safe_rmdir(dst_dir)
    safe_cpdir(src_dir, dst_dir)
Пример #13
0
    def execute(self, package, category, subdir, version):
        pkg_path = package_path(self._config['app'], self._config['category'], category, subdir, package, version)

        safe_rmdir(pkg_path['config_dir'])
        safe_rmdir(pkg_path['work_dir'])