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


Python DebianGitRepository.create_pristine_tar_commits方法代码示例

本文整理汇总了Python中gbp.deb.git.DebianGitRepository.create_pristine_tar_commits方法的典型用法代码示例。如果您正苦于以下问题:Python DebianGitRepository.create_pristine_tar_commits方法的具体用法?Python DebianGitRepository.create_pristine_tar_commits怎么用?Python DebianGitRepository.create_pristine_tar_commits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gbp.deb.git.DebianGitRepository的用法示例。


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

示例1: main

# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import create_pristine_tar_commits [as 别名]
def main(argv):
    ret = 1
    repo = None

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

    if len(args) != 2 or args[0] not in ['commit']:
        gbp.log.err("No action given")
        return 1
    else:
        tarball = args[1]

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

        source = DebianSource('.')
        component_tarballs = get_component_tarballs(source.sourcepkg,
                                                    source.upstream_version,
                                                    tarball,
                                                    options.components)
        upstream_tag = repo.version_to_tag(options.upstream_tag,
                                           source.upstream_version)
        repo.create_pristine_tar_commits(upstream_tag,
                                         tarball,
                                         component_tarballs)
        ret = 0
    except (GitRepositoryError, GbpError, CommandExecFailed) as err:
        if str(err):
            gbp.log.err(err)
    except KeyboardInterrupt:
        gbp.log.err("Interrupted. Aborting.")

    if not ret:
        comp_msg = (' with additional tarballs for %s'
                    % ", ".join([os.path.basename(t[1]) for t in component_tarballs])) if component_tarballs else ''
        gbp.log.info("Successfully committed pristine-tar data for version %s of %s%s" % (source.upstream_version,
                                                                                          tarball,
                                                                                          comp_msg))
    return ret
开发者ID:agx,项目名称:git-buildpackage,代码行数:46,代码来源:pristine_tar.py

示例2: main

# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import create_pristine_tar_commits [as 别名]
def main(argv):
    dirs = dict(top=os.path.abspath(os.curdir))
    needs_repo = False
    ret = 1
    skipped = False

    options, pkg, target = parse_all(argv)
    if not options:
        return ExitCodes.parse_error

    try:
        try:
            repo = DebianGitRepository('.')
            # remember if the was repo initially empty
            repo.empty = repo.is_empty()

            (clean, out) = repo.is_clean()
            if not clean and not repo.empty:
                raise GbpError("Repository has uncommitted changes, commit these first: %s" % out)
        except GitRepositoryError:
            # no repo found, create one
            needs_repo = True

        if options.download:
            dscfile = download_source(pkg,
                                      dirs=dirs,
                                      unauth=options.allow_unauthenticated)
        else:
            dscfile = pkg

        dsc = DscFile.parse(dscfile)
        if dsc.pkgformat not in ['1.0', '3.0']:
            raise GbpError("Importing %s source format not yet supported." % dsc.pkgformat)
        if options.verbose:
            print_dsc(dsc)

        if needs_repo:
            target = target or dsc.pkg
            if os.path.exists(target):
                raise GbpError("Directory '%s' already exists. If you want to import into it, "
                               "please change into this directory otherwise move it away first."
                               % target)
            gbp.log.info("No git repository found, creating one.")
            repo = DebianGitRepository.create(target)
            repo.empty = True
            os.chdir(repo.path)
            repo_setup.set_user_name_and_email(options.repo_user, options.repo_email, repo)

        if repo.bare:
            disable_pristine_tar(options, "Bare repository")

        # unpack
        dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..'))
        source = DebianUpstreamSource(dsc.tgz)
        source.unpack(dirs['tmp'], options.filters)
        for (component, tarball) in dsc.additional_tarballs.items():
            gbp.log.info("Found component tarball '%s'" % os.path.basename(tarball))
            unpack_component_tarball(source.unpacked, component, tarball, options.filters)

        if repo.find_version(options.debian_tag, dsc.version):
            gbp.log.warn("Version %s already imported." % dsc.version)
            if options.allow_same_version:
                gbp.log.info("Moving tag of version '%s' since import forced" % dsc.version)
                move_tag_stamp(repo, options.debian_tag, dsc.version)
            else:
                raise SkipImport

        # import
        if dsc.native:
            import_native(repo, source, dsc, options)
        else:
            imported = False
            commit = repo.find_version(options.upstream_tag, dsc.upstream_version)
            if not repo.find_version(options.upstream_tag, dsc.upstream_version):
                commit = import_upstream(repo, source, dsc, options)
                imported = True

            if not repo.has_branch(options.debian_branch):
                if options.create_missing_branches:
                    repo.create_branch(options.debian_branch, commit)
                else:
                    raise GbpError("Branch %s does not exist, use --create-missing-branches" %
                                   options.debian_branch)

            if dsc.diff or dsc.deb_tgz:
                apply_debian_patch(repo, source, dsc, commit, options)
            else:
                gbp.log.warn("Didn't find a diff to apply.")

            if imported and options.pristine_tar:
                repo.create_pristine_tar_commits(commit,
                                                 dsc.tgz,
                                                 dsc.additional_tarballs.items())

        if repo.get_branch() == options.debian_branch or repo.empty:
            # Update HEAD if we modified the checked out branch
            repo.force_head(options.debian_branch, hard=True)
        ret = 0
    except KeyboardInterrupt:
        gbp.log.err("Interrupted. Aborting.")
#.........这里部分代码省略.........
开发者ID:agx,项目名称:git-buildpackage,代码行数:103,代码来源:import_dsc.py


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