当前位置: 首页>>代码示例>>Python>>正文


Python source.DebianSource类代码示例

本文整理汇总了Python中gbp.deb.source.DebianSource的典型用法代码示例。如果您正苦于以下问题:Python DebianSource类的具体用法?Python DebianSource怎么用?Python DebianSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DebianSource类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_is_native_file_3_git

    def test_is_native_file_3_git(self):
        """Test native package of format 3 from git"""
        self._commit_format('3.0', 'native')
        source = DebianSource(GitVfs(self.repo))
        self.assertTrue(source.is_native(False))

        self._commit_format('3.0', 'quilt')
        source = DebianSource(GitVfs(self.repo))
        self.assertFalse(source.is_native(True))
开发者ID:pexip,项目名称:os-git-buildpackage,代码行数:9,代码来源:15_test_DebianSource.py

示例2: source_vfs

def source_vfs(repo, options, tree):
    """Init source package info either from git or from working copy"""
    vfs = GitVfs(repo, tree) if tree else FileVfs('.')
    try:
        source = DebianSource(vfs)
        source.is_native()  # check early if this works
    except Exception as e:
        raise GbpError("Can't determine package type: %s" % e)
    return source
开发者ID:agx,项目名称:git-buildpackage,代码行数:9,代码来源:buildpackage.py

示例3: source_vfs

def source_vfs(repo, options, tree):
    """Init source package info either from git or from working copy"""
    # FIXME: just init the correct vfs
    try:
        if tree:
            source = DebianSource(GitVfs(repo, tree))
        else:
            source = DebianSource('.')
            source.is_native() # check early if this works
    except Exception as e:
        raise GbpError("Can't determine package type: %s" % e)
    return source
开发者ID:andrewlukoshko,项目名称:git-buildpackage,代码行数:12,代码来源:buildpackage.py

示例4: test_is_native_file_3_file

    def test_is_native_file_3_file(self):
        """Test native package of format 3"""
        source = DebianSource('.')
        os.makedirs('debian/source')

        dsf = DebianSourceFormat.from_content("3.0", "native")
        self.assertEqual(dsf.type, 'native')
        self.assertTrue(source.is_native(False))

        dsf = DebianSourceFormat.from_content("3.0", "quilt")
        self.assertEqual(dsf.type, 'quilt')
        self.assertFalse(source.is_native(True))
开发者ID:pexip,项目名称:os-git-buildpackage,代码行数:12,代码来源:15_test_DebianSource.py

示例5: test_is_releasable

    def test_is_releasable(self):
        os.makedirs('debian/')
        with open('debian/changelog', 'w') as f:
            f.write("""git-buildpackage (0.2.3) unstable; urgency=low

  * git doesn't like '~' in tag names so replace this with a dot when tagging

 -- Guido Guenther <[email protected]>  Mon,  2 Oct 2006 18:30:20 +0200
""")
        source = DebianSource('.')
        self.assertEquals(source.changelog.distribution, "unstable")
        self.assertTrue(source.is_releasable())
开发者ID:agx,项目名称:git-buildpackage,代码行数:12,代码来源:15_test_DebianSource.py

示例6: source_vfs

def source_vfs(repo, options, tree):
    """Init source package info either from git or from working copy"""
    # FIXME: just init the correct vfs
    try:
        if tree:
            gbp.log.debug('source_vfs returning DebianSource(GitVfs(repo=%s, tree=%s))' % (repo, tree))
            source = DebianSource(GitVfs(repo, tree))
        else:
            gbp.log.debug('source_vfs returning DebianSource(\'.\') with cwd = %s' % (os.getcwd(),))
            source = DebianSource('.')
            source.is_native() # check early if this works
    except Exception as e:
        raise GbpError("Can't determine package type: %s" % e)
    return source
开发者ID:kelleyk,项目名称:git-buildpackage,代码行数:14,代码来源:buildpackage.py

示例7: main

def main(argv):
    retval = 0
    source = None

    options, args = parse_args(argv, '')

    if args or not options:
        return ExitCodes.parse_error

    try:
        repo = DebianGitRepository(os.path.curdir, toplevel=False)
    except GitRepositoryError:
        gbp.log.err("%s is not inside a git repository" % (os.path.abspath('.')))
        return 1

    try:
        try:
            source = DebianSource(repo.path)
            source.is_native()
        except Exception as e:
            raise GbpError("Can't determine package type: %s" % e)

        if options.tarball_dir and source.upstream_version is not None:
            options.tarball_dir = PkgPolicy.version_subst(options.tarball_dir,
                                                          source.upstream_version)

        output_dir = options.tarball_dir or os.path.join(repo.path, '..')

        if source.is_native():
            gbp.log.info("Nothing to be done for native package")
            return 0

        prepare_upstream_tarballs(repo, source, options, output_dir,
                                  output_dir)
    except KeyboardInterrupt:
        retval = 1
        gbp.log.err("Interrupted. Aborting.")
    except CommandExecFailed:
        retval = 1
    except (GbpError, GitRepositoryError) as err:
        if str(err):
            gbp.log.err(err)
        retval = 1
    except DebianSourceError as err:
        gbp.log.err(err)
        source = None
        retval = 1

    return retval
开发者ID:agx,项目名称:git-buildpackage,代码行数:49,代码来源:export_orig.py

示例8: test_is_native_fallback_file

    def test_is_native_fallback_file(self):
        """Test native package without a debian/source/format file"""
        source = DebianSource('.')
        os.makedirs('debian/')
        self.assertRaises(DebianSourceError,
                          source.is_native)

        with open('debian/changelog', 'w') as f:
            f.write("""git-buildpackage (0.2.3) git-buildpackage; urgency=low

  * git doesn't like '~' in tag names so replace this with a dot when tagging

 -- Guido Guenther <[email protected]>  Mon,  2 Oct 2006 18:30:20 +0200
""")
        source = DebianSource('.')
        self.assertTrue(source.is_native())
开发者ID:pombreda,项目名称:git-buildpackage-rpm,代码行数:16,代码来源:15_test_DebianSource.py

示例9: main

def main(argv):
    retval = 0
    prefix = "git-"
    source = None
    branch = None

    options, gbp_args, dpkg_args = parse_args(argv, prefix)
    
    if not options:
        return 1

    try:
        repo = DebianGitRepository(os.path.curdir)
    except GitRepositoryError:
        gbp.log.err("%s is not a git repository" % (os.path.abspath('.')))
        return 1
    else:
        repo_dir = os.path.abspath(os.path.curdir)

    try:
        Command(options.cleaner, shell=True)()
        if not options.ignore_new:
            (ret, out) = repo.is_clean()
            if not ret:
                gbp.log.err("You have uncommitted changes in your source tree:")
                gbp.log.err(out)
                raise GbpError("Use --git-ignore-new to ignore.")

        try:
            branch = repo.get_branch()
        except GitRepositoryError:
            # Not being on any branch is o.k. with --git-ignore-branch
            if not options.ignore_branch:
                raise

        if not options.ignore_new and not options.ignore_branch:
            if branch != options.debian_branch:
                gbp.log.err("You are not on branch '%s' but on '%s'" % (options.debian_branch, branch))
                raise GbpError("Use --git-ignore-branch to ignore or --git-debian-branch to set the branch name.")

        head = repo.head
        tree = write_tree(repo, options)
        source = source_vfs(repo, options, tree)

        check_tag(options, repo, source)

        if not options.tag_only:
            output_dir = prepare_output_dir(options.export_dir)
            tarball_dir = options.tarball_dir or output_dir

            # Get/build the upstream tarball if necessary. We delay this in
            # case of a postexport hook so the hook gets a chance to modify the
            # sources and create different tarballs (#640382)
            # We don't delay it in general since we want to fail early if the
            # tarball is missing.
            is_native = source.is_native()
            gbp.log.debug('Is the package Debian-native? %s' % (is_native,))
            if not is_native:
                if options.postexport:
                    gbp.log.info("Postexport hook set, delaying tarball creation")
                else:
                    gbp.log.info('Preparing upstream tarball (not delayed)...')
                    prepare_upstream_tarball(repo, source.changelog, options, tarball_dir,
                                             output_dir)

            # Export to another build dir if requested:
            if options.export_dir:
                gbp.log.debug('export_dir is set...')
                sourcepkg = source.sourcepkg
                assert sourcepkg is not None
                gbp.log.debug('sourcepkg = %s' % (sourcepkg,))
                tmp_dir = os.path.join(output_dir, "%s-tmp" % sourcepkg)
                export_source(repo, tree, source, options, tmp_dir, output_dir)

                # XXX: @KK:
                gbp.log.debug('Changing source to use tmp_dir=%s' % (tmp_dir,))
                source = DebianSource(tmp_dir)
                
                # Run postexport hook
                gbp.log.debug('running post-export hook...') 
                if options.postexport:
                    Hook('Postexport', options.postexport, shell=True,
                         extra_env={'GBP_GIT_DIR': repo.git_dir,
                                    'GBP_TMP_DIR': tmp_dir})(dir=tmp_dir)

                    # @KK: This is unnecessary because we are creating a new DebianSource object above now, anyhow.
                    assert source._changelog is None
                    # # XXX: Using source.sourcepkg causes debian/changelog to be parsed (and then
                    # # cached); but we want our post-export hook to be able to change it!
                    # source._changelog = None

                if source.changelog.upstream_version is None and not source.is_native():
                    raise GbpError('This package is not Debian-native (according to debian/source/format), but the '
                                   'last version number in debian/changelog does not seem to contain a dash (-) to  '
                                   'separate the Debian version from the upstream version.  (The raw version string '
                                   'is {!r}.)'.format(source.changelog.version))
                    
                major = (source.changelog.debian_version if source.is_native()
                         else source.changelog.upstream_version)
                if major is None:
#.........这里部分代码省略.........
开发者ID:kelleyk,项目名称:git-buildpackage,代码行数:101,代码来源:buildpackage.py

示例10: test_is_native_fallback_file

 def test_is_native_fallback_file(self):
     """Test native package without a debian/source/format file"""
     source = DebianSource('.')
     os.makedirs('debian/')
     self.assertFalse(source.is_native(True))
     self.assertTrue(source.is_native(False))
开发者ID:pexip,项目名称:os-git-buildpackage,代码行数:6,代码来源:15_test_DebianSource.py

示例11: main

def main(argv):
    retval = 1
    branch = None
    dest = None
    to_push = {
        'refs': [],
        'tags': [],
    }

    (options, args) = parse_args(argv)
    if not options:
        return ExitCodes.parse_error

    if len(args) > 2:
        gbp.log.err("Only a single remote repository can be given")
    elif len(args) == 2:
        dest = args[1]

    gbp.log.setup(options.color, options.verbose, options.color_scheme)
    try:
        repo = DebianGitRepository(os.path.curdir, toplevel=False)
    except GitRepositoryError:
        gbp.log.err("%s is not inside a git repository" % (os.path.abspath('.')))
        return 1

    try:
        source = DebianSource(repo.path)
        branch = repo.branch
        if not options.ignore_branch:
            if branch != options.debian_branch:
                gbp.log.err("You are not on branch '%s' but %s" %
                            (options.debian_branch,
                             "on '%s'" % branch if branch else 'in detached HEAD state'))
                raise GbpError("Use --ignore-branch to ignore or --debian-branch to set the branch name.")

        if not dest:
            dest = get_remote(repo, branch)

        if options.debian_tag != '':
            dtag = repo.version_to_tag(options.debian_tag, source.version)
            if repo.has_tag(dtag):
                to_push['tags'].append(dtag)

        if source.is_releasable() and branch:
            ref = 'refs/heads/%s' % branch
            to_push['refs'].append((ref, get_push_src(repo, ref, dtag)))

        if not source.is_native():
            if options.upstream_tag != '':
                utag = repo.version_to_tag(options.upstream_tag,
                                           source.upstream_version)
                if repo.has_tag(utag):
                    to_push['tags'].append(utag)

            if options.upstream_branch != '':
                ref = 'refs/heads/%s' % options.upstream_branch
                to_push['refs'].append((ref, get_push_src(repo, ref, utag)))

            if options.pristine_tar:
                commit = repo.get_pristine_tar_commit(source)
                if commit:
                    ref = 'refs/heads/pristine-tar'
                    to_push['refs'].append((ref, get_push_src(repo, ref, commit)))

        if do_push(repo, [dest], to_push, dry_run=options.dryrun):
            retval = 0
        else:
            gbp.log.err("Failed to push some refs.")
            retval = 1
    except (GbpError, GitRepositoryError, DebianSourceError) as err:
        if str(err):
            gbp.log.err(err)
    except KeyboardInterrupt:
        gbp.log.err("Interrupted. Aborting.")

    return retval
开发者ID:agx,项目名称:git-buildpackage,代码行数:76,代码来源:push.py

示例12: main

def main(argv):
    ret = 0
    changelog = "debian/changelog"
    until = "HEAD"
    found_snapshot_banner = False
    version_change = {}
    branch = None

    options, args, dch_options, editor_cmd = parse_args(argv)

    try:
        try:
            repo = DebianGitRepository(".")
        except GitRepositoryError:
            raise GbpError("%s is not a git repository" % (os.path.abspath(".")))

        try:
            branch = repo.get_branch()
        except GitRepositoryError:
            # Not being on any branch is o.k. with --ignore-branch
            if not options.ignore_branch:
                raise

        if options.debian_branch != branch and not options.ignore_branch:
            gbp.log.err("You are not on branch '%s' but on '%s'" % (options.debian_branch, branch))
            raise GbpError("Use --ignore-branch to ignore or --debian-branch to set the branch name.")

        source = DebianSource(".")
        cp = source.changelog

        if options.since:
            since = options.since
        else:
            since = ""
            if options.auto:
                since = guess_documented_commit(cp, repo, options.debian_tag)
                if since:
                    msg = "Continuing from commit '%s'" % since
                else:
                    msg = "Starting from first commit"
                gbp.log.info(msg)
                found_snapshot_banner = has_snapshot_banner(cp)
            else:  # Fallback: continue from last tag
                since = repo.find_version(options.debian_tag, cp["Version"])
                if not since:
                    raise GbpError("Version %s not found" % cp["Version"])

        if args:
            gbp.log.info("Only looking for changes on '%s'" % " ".join(args))
        commits = repo.get_commits(since=since, until=until, paths=args, options=options.git_log.split(" "))
        commits.reverse()

        # add a new changelog section if:
        if options.new_version or options.bpo or options.nmu or options.qa or options.team or options.security:
            if options.bpo:
                version_change["increment"] = "--bpo"
            elif options.nmu:
                version_change["increment"] = "--nmu"
            elif options.qa:
                version_change["increment"] = "--qa"
            elif options.team:
                version_change["increment"] = "--team"
            elif options.security:
                version_change["increment"] = "--security"
            else:
                version_change["version"] = options.new_version
            # the user wants to force a new version
            add_section = True
        elif cp["Distribution"] != "UNRELEASED" and not found_snapshot_banner and commits:
            # the last version was a release and we have pending commits
            add_section = True
        elif options.snapshot and not found_snapshot_banner:
            # the user want to switch to snapshot mode
            add_section = True
        else:
            add_section = False

        if add_section and not version_change and not source.is_native():
            # Get version from upstream if none provided
            v = guess_version_from_upstream(repo, options.upstream_tag, cp)
            if v:
                version_change["version"] = v

        i = 0
        for c in commits:
            i += 1
            parsed = parse_commit(repo, c, options, last_commit=i == len(commits))
            commit_msg, (commit_author, commit_email) = parsed
            if not commit_msg:
                # Some commits can be ignored
                continue

            if add_section:
                # Add a section containing just this message (we can't
                # add an empty section with dch)
                cp.add_section(
                    distribution="UNRELEASED",
                    msg=commit_msg,
                    version=version_change,
                    author=commit_author,
#.........这里部分代码省略.........
开发者ID:hemmop,项目名称:git-buildpackage,代码行数:101,代码来源:dch.py

示例13: main


#.........这里部分代码省略.........
                      dest="commit_msg")
    parser.add_option("-c", "--commit", action="store_true", dest="commit", default=False,
                      help="commit changelog file after generating")

    help_msg = ('Load Python code from CUSTOMIZATION_FILE.  At the moment,'
                ' the only useful thing the code can do is define a custom'
                ' format_changelog_entry() function.')
    custom_group.add_config_file_option(option_name="customizations",
                                        dest="customization_file",
                                        help=help_msg)

    (options, args) = parser.parse_args(argv[1:])
    gbp.log.setup(options.color, options.verbose, options.color_scheme)
    dch_options = process_options(options, parser)
    editor_cmd = process_editor_option(options)

    try:
        try:
            repo = DebianGitRepository('.')
        except GitRepositoryError:
            raise GbpError("%s is not a git repository" % (os.path.abspath('.')))

        try:
            branch = repo.get_branch()
        except GitRepositoryError:
            # Not being on any branch is o.k. with --ignore-branch
            if not options.ignore_branch:
                raise

        if options.debian_branch != branch and not options.ignore_branch:
            gbp.log.err("You are not on branch '%s' but on '%s'" % (options.debian_branch, branch))
            raise GbpError("Use --ignore-branch to ignore or --debian-branch to set the branch name.")

        source = DebianSource('.')
        cp = source.changelog

        if options.since:
            since = options.since
        else:
            since = ''
            if options.auto:
                since = guess_documented_commit(cp, repo, options.debian_tag)
                if since:
                    msg = "Continuing from commit '%s'" % since
                else:
                    msg = "Starting from first commit"
                gbp.log.info(msg)
                found_snapshot_banner = has_snapshot_banner(cp)
            else: # Fallback: continue from last tag
                since = repo.find_version(options.debian_tag, cp['Version'])
                if not since:
                    raise GbpError("Version %s not found" % cp['Version'])

        if args:
            gbp.log.info("Only looking for changes on '%s'" % " ".join(args))
        commits = repo.get_commits(since=since, until=until, paths=args,
                                   options=options.git_log.split(" "))
        commits.reverse()

        # add a new changelog section if:
        if (options.new_version or options.bpo or options.nmu or options.qa or
            options.team or options.security):
            if options.bpo:
                version_change['increment'] = '--bpo'
            elif options.nmu:
                version_change['increment'] = '--nmu'
开发者ID:pexip,项目名称:os-git-buildpackage,代码行数:67,代码来源:dch.py


注:本文中的gbp.deb.source.DebianSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。