def main(argv=None):
    """Main function"""

    args = parse_args(argv)

    LOGGER.info('Starting git-buildpackage source service')
    if args.verbose == 'yes':
        gbplog.setup(color='auto', verbose=True)
        LOGGER.setLevel(gbplog.DEBUG)
        gbp_repocache.LOGGER.setLevel(gbplog.DEBUG)

    config = read_config(args.config)

    # Create / update cached repository
    try:
        repo = CachedRepo(config['repo-cache-dir'], args.url)
        args.revision = repo.update_working_copy(args.revision)
    except CachedRepoError as err:
        LOGGER.error('RepoCache: %s' % str(err))
        return 1

    # Export sources with GBP
    rpm_args, deb_args = construct_gbp_args(args)
    orig_dir = os.path.abspath(os.curdir)
    try:
        os.chdir(repo.repodir)
        if args.rpm in ['yes','auto']:
            if args.spec is None:
                specs_path = get_spec('.')
            else:
                specs_path = get_spec('.', name=args.spec)
            if specs_path is None:
                LOGGER.error('no spec file available in packaging'
                                                         ' directory')
                return 2
            rpm_args.append('--git-spec-file=%s' % specs_path)
            LOGGER.info('Exporting RPM packaging files with GBP')
            LOGGER.debug('git-buildpackage-rpm args: %s' % ' '.join(rpm_args))
            ret = gbp_rpm(rpm_args)
            if ret:
                LOGGER.error('Git-buildpackage-rpm failed, unable to export '
                             'RPM packaging files')
                return 2
        if args.deb == 'yes' or (args.deb== 'auto' and os.path.isdir('debian')):
            LOGGER.info('Exporting Debian source package with GBP')
            LOGGER.debug('git-buildpackage args: %s' % ' '.join(deb_args))
            ret = gbp_deb(deb_args)
            if ret:
                LOGGER.error('Git-buildpackage failed, unable to export Debian '
                             'sources package files')
                return 3
    finally:
        os.chdir(orig_dir)

    return 0
Пример #2
0
    def test_option_builder(self):
        """Test --git-builder option and it's args"""
        self.init_test_repo('gbp-test-native')
        base_args = ['arg0', '--git-notify=off']

        # Try rpmbuild with default args
        eq_(gbp_rpm(base_args + ['--git-builder=rpmbuild', '--nodeps']), 0)

        # Build without builder args
        builder_script = 'echo -n $* > builder_args.txt'
        eq_(gbp_rpm(base_args + ['--git-builder=%s' % builder_script]), 0)
        with open('../rpmbuild/builder_args.txt') as fobj:
            args = fobj.read()
        eq_(args, 'gbp-test-native.spec')

        # Build with builder args
        eq_(gbp_rpm(base_args + ['--git-builder=%s' % builder_script,
                                 '--arg1', '--arg2']), 0)
        with open('../rpmbuild/builder_args.txt') as fobj:
            args = fobj.read()
        eq_(args, '--arg1 --arg2 gbp-test-native.spec')
Пример #3
0
    def test_option_builder(self):
        """Test --git-builder option and it's args"""
        self.init_test_repo('gbp-test-native')
        base_args = ['arg0', '--git-notify=off']

        # Try rpmbuild with default args
        eq_(gbp_rpm(base_args + ['--git-builder=rpmbuild', '--nodeps']), 0)

        # Build without builder args
        builder_script = 'echo -n $* > builder_args.txt'
        eq_(gbp_rpm(base_args + ['--git-builder=%s' % builder_script]), 0)
        with open('../rpmbuild/builder_args.txt') as fobj:
            args = fobj.read()
        eq_(args, 'gbp-test-native.spec')

        # Build with builder args
        eq_(gbp_rpm(base_args + ['--git-builder=%s' % builder_script,
                                 '--arg1', '--arg2']), 0)
        with open('../rpmbuild/builder_args.txt') as fobj:
            args = fobj.read()
        eq_(args, '--arg1 --arg2 gbp-test-native.spec')
Пример #4
0
def mock_gbp(args):
    """Wrapper for gbp-buildpackage-rpm"""
    with capture.capture_stderr():
        return gbp_rpm(['arg0', '--git-notify=off'] + args +
                       ['-ba', '--clean', '--target=noarch', '--nodeps'])
Пример #5
0
def mock_gbp(args):
    """Wrapper for gbp-buildpackage-rpm"""
    with capture.capture_stderr():
        return gbp_rpm(['arg0', '--git-notify=off'] + args +
                       ['-ba', '--clean', '--target=noarch', '--nodeps'])
Пример #6
0
def mock_gbp(args):
    """Wrapper for gbp-buildpackage-rpm"""
    return gbp_rpm(['arg0', '--git-notify=off', '--git-ignore-branch'] + args +
                   ['-ba', '--clean', '--target=noarch', '--nodeps'])
def mock_gbp(args):
    """Wrapper for gbp-buildpackage-rpm"""
    return gbp_rpm(
        ["arg0", "--git-notify=off", "--git-ignore-branch"] + args + ["-ba", "--clean", "--target=noarch", "--nodeps"]
    )
def mock_gbp(args):
    """Wrapper for gbp-buildpackage-rpm"""
    return gbp_rpm(['arg0', '--git-notify=off','--git-ignore-branch']
                   + args
                   + ['-ba', '--clean', '--target=noarch', '--nodeps'])