Пример #1
0
def main(argv=None):
    """Main function"""

    ret = 0
    try:
        args = parse_args(argv)
        args.outdir = os.path.abspath(args.outdir)

        if args.verbose == 'yes':
            gbplog.setup(color='auto', verbose=True)
            LOGGER.setLevel(gbplog.DEBUG)
            gbp_repocache.LOGGER.setLevel(gbplog.DEBUG)
            gbs_log.setup(verbose=True)
        else:
            gbplog.setup(color='auto', verbose=False)
            gbs_log.setup(verbose=False)

        LOGGER.info('Starting GBS source service')

        config = read_config(args.config)
        # Create / update cached repository
        repo = CachedRepo(config['repo-cache-dir'], args.url)
        args.revision = repo.update_working_copy(args.revision,
                                                 submodules=False)
        # Create outdir
        try:
            os.makedirs(args.outdir)
        except OSError as err:
            if err.errno != os.errno.EEXIST:
                raise ServiceError('Failed to create outdir: %s' % err, 1)
        os.chdir(repo.repodir)
        LOGGER.info('args.spec %s' % args.spec)
        if args.spec is None:
            spec_name=os.path.basename(args.url)
            if spec_name.endswith(".git"):
                  spec_name=spec_name[:-4]
            args.spec = findBestSpecFile('./packaging', spec_name)
        else:
            args.spec = findBestSpecFile('./packaging', args.spec)
        if args.spec is None:
            LOGGER.error('no spec file available in packaging'
                                                         ' directory')
            return 2

        read_localconf(".")
        # Export sources with GBS
        gbs_export(repo, args)

    except ServiceError as err:
        LOGGER.error(err[0])
        ret = err[1]
    except CachedRepoError as err:
        LOGGER.error('RepoCache: %s' % err)
        ret = 1

    return ret
Пример #2
0
                           '--include-all')

    obs_repo = args.repository
    obs_arch = args.arch

    if args.buildlog and None in (obs_repo, obs_arch):
        raise GbsError('please specify arch(-A) and repository(-R)')

    try:
        repo = RpmGitRepository(args.gitdir)
    except GitRepositoryError, err:
        raise GbsError(str(err))

    workdir = repo.path

    utils.read_localconf(workdir)

    if not (args.buildlog or args.status):
        utils.git_status_checker(repo, args)

    packaging_dir = get_packaging_dir(args)

    if args.commit:
        commit = args.commit
    elif args.include_all:
        commit = 'WC.UNTRACKED'
    else:
        commit = 'HEAD'

    relative_spec = utils.guess_spec(workdir, packaging_dir,
                                     args.spec, commit)[0]
Пример #3
0
        raise GbsError("Repository error: %s" % excobj)


def main(args):
    """gbs export entry point."""

    if args.commit and args.include_all:
        raise Usage("--commit can't be specified together with --include-all")

    workdir = args.gitdir
    try:
        repo = RpmGitRepository(workdir)
    except GitRepositoryError, err:
        raise GbsError(str(err))

    utils.read_localconf(repo.path)
    utils.git_status_checker(repo, args)
    workdir = repo.path


    # Only guess spec filename here, parse later when we have the correct
    # spec file at hand
    if args.commit:
        commit = args.commit
    elif args.include_all:
        commit = 'WC.UNTRACKED'
    else:
        commit = 'HEAD'
    orphan_packaging = configmgr.get('packaging_branch', 'orphan-devel')
    spec_commit_id = orphan_packaging if orphan_packaging else commit
    packaging_dir = get_packaging_dir(args)
Пример #4
0
def main(args):
    """gbs build entry point."""

    global TMPDIR
    TMPDIR = os.path.join(configmgr.get('tmpdir', 'general'),
                          '%s-gbs' % USERID)

    if args.commit and args.include_all:
        raise Usage('--commit can\'t be specified together with '\
                    '--include-all')
    if args.noinit and (args.clean or args.clean_once):
        raise Usage('--noinit can\'t be specified together with '\
                    '--clean or --clean-once')
    workdir = args.gitdir

    try:
        repo = RpmGitRepository(workdir)
        workdir = repo.path
    except GitRepositoryError:
        if args.spec:
            raise GbsError("git project can't be found for --spec, "
                           "give it in argument or cd into it")

    read_localconf(workdir)

    hostarch = os.uname()[4]
    if args.arch:
        buildarch = args.arch
    else:
        buildarch = hostarch
        log.info('No arch specified, using system arch: %s' % hostarch)

    if not buildarch in SUPPORTEDARCHS:
        raise GbsError('arch %s not supported, supported archs are: %s ' % \
                       (buildarch, ','.join(SUPPORTEDARCHS)))

    profile = get_profile(args)
    if args.buildroot:
        build_root = args.buildroot
    elif 'TIZEN_BUILD_ROOT' in os.environ:
        build_root = os.environ['TIZEN_BUILD_ROOT']
    elif profile.buildroot:
        build_root = profile.buildroot
    else:
        build_root = configmgr.get('buildroot', 'general')
    build_root = os.path.expanduser(build_root)
    # transform variables from shell to python convention ${xxx} -> %(xxx)s
    build_root = re.sub(r'\$\{([^}]+)\}', r'%(\1)s', build_root)
    sanitized_profile_name = re.sub("[^a-zA-Z0-9:._-]", "_", profile.name)
    build_root = build_root % {
        'tmpdir': TMPDIR,
        'profile': sanitized_profile_name
    }
    if profile.exclude_packages:
        log.info('the following packages have been excluded build from gbs '
                 'config:\n   %s' % '\n   '.join(profile.exclude_packages))
        if args.exclude:
            args.exclude += ',' + ','.join(profile.exclude_packages)
        else:
            args.exclude = ','.join(profile.exclude_packages)
    os.environ['TIZEN_BUILD_ROOT'] = os.path.abspath(build_root)

    # get virtual env from system env first
    if 'VIRTUAL_ENV' in os.environ:
        cmd = ['%s/usr/bin/depanneur' % os.environ['VIRTUAL_ENV']]
    else:
        cmd = ['depanneur']

    cmd += ['--arch=%s' % buildarch]

    if args.clean:
        cmd += ['--clean']

    # check & prepare repos and build conf
    if not args.noinit:
        cmd += prepare_repos_and_build_conf(args, buildarch, profile)
    else:
        cmd += ['--noinit']

    cmd += ['--path=%s' % workdir]

    if args.ccache:
        cmd += ['--ccache']

    if args.extra_packs:
        cmd += ['--extra-packs=%s' % args.extra_packs]

    if hostarch != buildarch and buildarch in CHANGE_PERSONALITY:
        cmd = [CHANGE_PERSONALITY[buildarch]] + cmd

    # Extra depanneur special command options
    cmd += prepare_depanneur_opts(args)

    # Extra options for gbs export
    if args.include_all:
        cmd += ['--include-all']
    if args.commit:
        cmd += ['--commit=%s' % args.commit]

    if args.upstream_branch:
        cmd += ['--upstream-branch=%s' % args.upstream_branch]
    if args.upstream_tag:
        cmd += ['--upstream-tag=%s' % args.upstream_tag]
    if args.squash_patches_until:
        cmd += ['--squash-patches-until=%s' % args.squash_patches_until]
    if args.no_patch_export:
        cmd += ['--no-patch-export']

    if args.define:
        cmd += [('--define="%s"' % i) for i in args.define]
    if args.spec:
        cmd += ['--spec=%s' % args.spec]

    # Determine if we're on devel branch
    orphan_packaging = configmgr.get('packaging_branch', 'orphan-devel')
    if orphan_packaging:
        cmd += ['--spec-commit=%s' % orphan_packaging]

    log.debug("running command: %s" % ' '.join(cmd))
    retcode = os.system(' '.join(cmd))
    if retcode != 0:
        raise GbsError('some packages failed to be built')
    else:
        log.info('Done')
Пример #5
0
def main(args):
    """gbs build entry point."""

    global TMPDIR
    TMPDIR = os.path.join(configmgr.get('tmpdir', 'general'), '%s-gbs' % USERID)

    if args.commit and args.include_all:
        raise Usage('--commit can\'t be specified together with '\
                    '--include-all')
    if args.noinit and (args.clean or args.clean_once):
        raise Usage('--noinit can\'t be specified together with '\
                    '--clean or --clean-once')
    workdir = args.gitdir

    try:
        repo = RpmGitRepository(workdir)
        workdir = repo.path
    except GitRepositoryError:
        if args.spec:
            raise GbsError("git project can't be found for --spec, "
                           "give it in argument or cd into it")

    read_localconf(workdir)

    hostarch = os.uname()[4]
    if args.arch:
        buildarch = args.arch
    else:
        buildarch = hostarch
        log.info('No arch specified, using system arch: %s' % hostarch)

    if not buildarch in SUPPORTEDARCHS:
        raise GbsError('arch %s not supported, supported archs are: %s ' % \
                       (buildarch, ','.join(SUPPORTEDARCHS)))

    profile = get_profile(args)
    if args.buildroot:
        build_root = args.buildroot
    elif 'TIZEN_BUILD_ROOT' in os.environ:
        build_root = os.environ['TIZEN_BUILD_ROOT']
    elif profile.buildroot:
        build_root = profile.buildroot
    else:
        build_root = configmgr.get('buildroot', 'general')
    build_root = os.path.expanduser(build_root)
    # transform variables from shell to python convention ${xxx} -> %(xxx)s
    build_root = re.sub(r'\$\{([^}]+)\}', r'%(\1)s', build_root)
    sanitized_profile_name = re.sub("[^a-zA-Z0-9:._-]", "_", profile.name)
    build_root = build_root % {'tmpdir': TMPDIR,
                               'profile': sanitized_profile_name}
    if profile.exclude_packages:
        log.info('the following packages have been excluded build from gbs '
                 'config:\n   %s' % '\n   '.join(profile.exclude_packages))
        if args.exclude:
            args.exclude += ',' + ','.join(profile.exclude_packages)
        else:
            args.exclude = ','.join(profile.exclude_packages)
    os.environ['TIZEN_BUILD_ROOT'] = os.path.abspath(build_root)

    # get virtual env from system env first
    if 'VIRTUAL_ENV' in os.environ:
        cmd = ['%s/usr/bin/depanneur' % os.environ['VIRTUAL_ENV']]
    else:
        cmd = ['depanneur']

    cmd += ['--arch=%s' % buildarch]

    if args.clean:
        cmd += ['--clean']

    # check & prepare repos and build conf
    if not args.noinit:
        cmd += prepare_repos_and_build_conf(args, buildarch, profile)
    else:
        cmd += ['--noinit']

    cmd += ['--path=%s' % workdir]

    if args.ccache:
        cmd += ['--ccache']

    if args.extra_packs:
        cmd += ['--extra-packs=%s' % args.extra_packs]

    if hostarch != buildarch and buildarch in CHANGE_PERSONALITY:
        cmd = [CHANGE_PERSONALITY[buildarch]] + cmd

    # Extra depanneur special command options
    cmd += prepare_depanneur_opts(args)

    # Extra options for gbs export
    if args.include_all:
        cmd += ['--include-all']
    if args.commit:
        cmd += ['--commit=%s' % args.commit]

    if args.upstream_branch:
        cmd += ['--upstream-branch=%s' % args.upstream_branch]
    if args.upstream_tag:
        cmd += ['--upstream-tag=%s' % args.upstream_tag]

    if args.conf and args.conf != '.gbs.conf':
        fallback = configmgr.get('fallback_to_native')
    else:
        fallback = ''
    if args.fallback_to_native or config_is_true(fallback):
        cmd += ['--fallback-to-native']

    if args.squash_patches_until:
        cmd += ['--squash-patches-until=%s' % args.squash_patches_until]
    if args.no_patch_export:
        cmd += ['--no-patch-export']

    if args.define:
        cmd += [('--define="%s"' % i) for i in args.define]
    if args.spec:
        cmd += ['--spec=%s' % args.spec]

    # Determine if we're on devel branch
    orphan_packaging = configmgr.get('packaging_branch', 'orphan-devel')
    if orphan_packaging:
        cmd += ['--spec-commit=%s' % orphan_packaging]

    log.debug("running command: %s" % ' '.join(cmd))
    retcode = os.system(' '.join(cmd))
    if retcode != 0:
        raise GbsError('some packages failed to be built')
    else:
        log.info('Done')