コード例 #1
0
def build_parser(name):
    """Create command line argument parser"""
    try:
        parser = GbpOptionParser(command=os.path.basename(name),
                                 prefix='',
                                 usage='%prog [options] repository - clone a '
                                 'remote per-package repository')
    except ConfigParser.ParsingError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser, "branch options",
                                  "branch tracking and layout options")
    parser.add_option_group(branch_group)

    branch_group.add_option(
        "--all",
        action="store_true",
        dest="all",
        help="track all branches, not only packaging and upstream")
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_config_file_option(option_name="packaging-branch",
                                        dest="packaging_branch")
    branch_group.add_option(
        "--depth",
        action="store",
        dest="depth",
        default=0,
        help="git history depth (for creating shallow clones)")

    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    return parser
コード例 #2
0
    def test_param_list(self):
        parser = GbpOptionParser('cmd4')

        branch_group = GbpOptionGroup(parser, "branch options", "branch update and layout options")
        parser.add_option_group(branch_group)
        branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
        branch_group.add_config_file_option("debian-branch", dest="upstream_branch")
        parser.add_config_file_option(option_name="color", dest="color", type='tristate')

        params = parser.valid_options
        self.assertTrue('upstream-branch' in params)
        self.assertTrue('debian-branch' in params)
        self.assertTrue('color' in params)
コード例 #3
0
ファイル: dch.py プロジェクト: pombredanne/git-buildpackage-1
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name),
                                       usage='%prog [options] paths')
    except ConfigParser.ParsingError as err:
        gbp.log.err(err)
        return None

    range_group = GbpOptionGroup(parser, "commit range options",
                                 "which commits to add to the changelog")
    version_group = GbpOptionGroup(parser, "release & version number options",
                                   "what version number and release to use")
    commit_group = GbpOptionGroup(parser, "commit message formatting",
                                  "howto format the changelog entries")
    naming_group = GbpOptionGroup(parser, "branch and tag naming",
                                  "branch names and tag formats")
    custom_group = GbpOptionGroup(parser, "customization",
                                  "options for customization")
    parser.add_option_group(range_group)
    parser.add_option_group(version_group)
    parser.add_option_group(commit_group)
    parser.add_option_group(naming_group)
    parser.add_option_group(custom_group)

    parser.add_boolean_config_file_option(option_name="ignore-branch",
                                          dest="ignore_branch")
    naming_group.add_config_file_option(option_name="debian-branch",
                                        dest="packaging_branch")
    naming_group.add_config_file_option(option_name="upstream-tag",
                                        dest="upstream_tag")
    naming_group.add_config_file_option(option_name="debian-tag",
                                        dest="packaging_tag")
    naming_group.add_config_file_option(
        option_name="snapshot-number",
        dest="snapshot_number",
        help=
        "expression to determine the next snapshot number, default is '%(snapshot-number)s'"
    )
    parser.add_config_file_option(
        option_name="git-log",
        dest="git_log",
        help="options to pass to git-log, default is '%(git-log)s'")
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    range_group.add_option(
        "-s",
        "--since",
        dest="since",
        help="commit to start from (e.g. HEAD^^^, debian/0.4.3)")
    range_group.add_option(
        "-a",
        "--auto",
        action="store_true",
        dest="auto",
        default=False,
        help="autocomplete changelog from last snapshot or tag")
    version_group.add_option("-R",
                             "--release",
                             action="store_true",
                             dest="release",
                             default=False,
                             help="mark as release")
    version_group.add_option("-S",
                             "--snapshot",
                             action="store_true",
                             dest="snapshot",
                             default=False,
                             help="mark as snapshot build")
    version_group.add_option("-D",
                             "--distribution",
                             dest="distribution",
                             help="Set distribution")
    version_group.add_option(
        "--force-distribution",
        action="store_true",
        dest="force_distribution",
        default=False,
        help=
        "Force the provided distribution to be used, even if it doesn't match the list of known distributions"
    )
    version_group.add_option(
        "-N",
        "--new-version",
        dest="new_version",
        help="use this as base for the new version number")
    version_group.add_option("-U",
                             "--urgency",
                             dest="urgency",
                             help="Set urgency level")
    version_group.add_option(
        "--bpo",
        dest="bpo",
        action="store_true",
        default=False,
        help=
        "Increment the Debian release number for an upload to backports, and add a backport upload changelog comment."
    )
    version_group.add_option(
        "--nmu",
        dest="nmu",
        action="store_true",
        default=False,
        help="Increment the Debian release number for a non-maintainer upload")
    version_group.add_option(
        "--qa",
        dest="qa",
        action="store_true",
        default=False,
        help=
        "Increment the Debian release number for a Debian QA Team upload, and add a QA upload changelog comment."
    )
    version_group.add_option(
        "--team",
        dest="team",
        action="store_true",
        default=False,
        help=
        "Increment the Debian release number for a Debian Team upload, and add a Team upload changelog comment."
    )
    version_group.add_option(
        "--security",
        dest="security",
        action="store_true",
        default=False,
        help=
        "Increment the Debian release number for a security upload and add a security upload changelog comment."
    )
    version_group.add_boolean_config_file_option(option_name="git-author",
                                                 dest="use_git_author")
    commit_group.add_boolean_config_file_option(option_name="meta",
                                                dest="meta")
    commit_group.add_config_file_option(option_name="meta-closes",
                                        dest="meta_closes")
    commit_group.add_boolean_config_file_option(option_name="full",
                                                dest="full")
    commit_group.add_config_file_option(
        option_name="id-length",
        dest="idlen",
        help=
        "include N digits of the commit id in the changelog entry, default is '%(id-length)s'",
        type="int",
        metavar="N")
    commit_group.add_config_file_option(
        option_name="ignore-regex",
        dest="ignore_regex",
        help="Ignore commit lines matching regex, default is '%(ignore-regex)s'"
    )
    commit_group.add_boolean_config_file_option(option_name="multimaint",
                                                dest="multimaint")
    commit_group.add_boolean_config_file_option(option_name="multimaint-merge",
                                                dest="multimaint_merge")
    commit_group.add_config_file_option(option_name="spawn-editor",
                                        dest="spawn_editor")
    parser.add_config_file_option(option_name="commit-msg", 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)

    return parser
コード例 #4
0
ファイル: dch.py プロジェクト: dex4er/git-buildpackage
def main(argv):
    ret = 0
    changelog = 'debian/changelog'
    until = 'HEAD'
    found_snapshot_header = False
    version_change = {}

    try:
        parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='',
                                       usage='%prog [options] paths')
    except ConfigParser.ParsingError as err:
        gbp.log.err(err)
        return 1
    range_group = GbpOptionGroup(parser, "commit range options",
                                 "which commits to add to the changelog")
    version_group = GbpOptionGroup(parser, "release & version number options",
                                   "what version number and release to use")
    commit_group = GbpOptionGroup(parser, "commit message formatting",
                                  "howto format the changelog entries")
    naming_group = GbpOptionGroup(parser, "branch and tag naming",
                                  "branch names and tag formats")
    custom_group = GbpOptionGroup(parser, "customization",
                                  "options for customization")
    parser.add_option_group(range_group)
    parser.add_option_group(version_group)
    parser.add_option_group(commit_group)
    parser.add_option_group(naming_group)
    parser.add_option_group(custom_group)

    parser.add_boolean_config_file_option(option_name = "ignore-branch", dest="ignore_branch")
    naming_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    naming_group.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
    naming_group.add_config_file_option(option_name="debian-tag", dest="debian_tag")
    naming_group.add_config_file_option(option_name="snapshot-number", dest="snapshot_number",
                      help="expression to determine the next snapshot number, default is '%(snapshot-number)s'")
    parser.add_config_file_option(option_name="git-log", dest="git_log",
                      help="options to pass to git-log, default is '%(git-log)s'")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    range_group.add_option("-s", "--since", dest="since", help="commit to start from (e.g. HEAD^^^, debian/0.4.3)")
    range_group.add_option("-a", "--auto", action="store_true", dest="auto", default=False,
                      help="autocomplete changelog from last snapshot or tag")
    version_group.add_option("-R", "--release", action="store_true", dest="release", default=False,
                      help="mark as release")
    version_group.add_option("-S", "--snapshot", action="store_true", dest="snapshot", default=False,
                      help="mark as snapshot build")
    version_group.add_option("-N", "--new-version", dest="new_version",
                      help="use this as base for the new version number")
    version_group.add_option("--bpo", dest="bpo", action="store_true", default=False,
                      help="Increment the Debian release number for an upload to backports, and add a backport upload changelog comment.")
    version_group.add_option("--nmu", dest="nmu", action="store_true", default=False,
                      help="Increment the Debian release number for a non-maintainer upload")
    version_group.add_option("--qa", dest="qa", action="store_true", default=False,
                      help="Increment the Debian release number for a Debian QA Team upload, and add a QA upload changelog comment.")
    version_group.add_option("--team", dest="team", action="store_true", default=False,
                      help="Increment the Debian release number for a Debian Team upload, and add a Team upload changelog comment.")
    version_group.add_boolean_config_file_option(option_name="git-author", dest="git_author")
    commit_group.add_boolean_config_file_option(option_name="meta", dest="meta")
    commit_group.add_config_file_option(option_name="meta-closes", dest="meta_closes",
                      help="Meta tags for the bts close commands, default is '%(meta-closes)s'")
    commit_group.add_boolean_config_file_option(option_name="full", dest="full")
    commit_group.add_config_file_option(option_name="id-length", dest="idlen",
                      help="include N digits of the commit id in the changelog entry, default is '%(id-length)s'",
                      type="int", metavar="N")
    commit_group.add_config_file_option(option_name="ignore-regex", dest="ignore_regex",
                      help="Ignore commit lines matching regex, default is '%(ignore-regex)s'")
    commit_group.add_boolean_config_file_option(option_name="multimaint", dest="multimaint")
    commit_group.add_boolean_config_file_option(option_name="multimaint-merge", dest="multimaint_merge")
    commit_group.add_config_file_option(option_name="spawn-editor", dest="spawn_editor")
    parser.add_config_file_option(option_name="commit-msg",
                      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)
    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('.')))

        branch = repo.get_branch()
        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.")

        cp = ChangeLog(filename=changelog)

        if options.since:
            since = options.since
        else:
            since = ''
            if options.auto:
                since = guess_snapshot_commit(cp, repo, options)
                if since:
                    gbp.log.info("Continuing from commit '%s'" % since)
                    found_snapshot_header = True
                else:
                    gbp.log.info("Couldn't find snapshot header, using version info")
            if not since:
                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:
            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'
            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_header and commits:
            # the last version was a release and we have pending commits
            add_section = True
        elif options.snapshot and not found_snapshot_header:
            # the user want to switch to snapshot mode
            add_section = True
        else:
            add_section = False

        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)
                add_changelog_section(distribution="UNRELEASED", msg=commit_msg,
                                      version=version_change,
                                      author=commit_author,
                                      email=commit_email,
                                      dch_options=dch_options,
                                      repo=repo,
                                      options=options,
                                      cp=cp)
                # Adding a section only needs to happen once.
                add_section = False
            else:
                add_changelog_entry(commit_msg, commit_author, commit_email, dch_options)


        # Show a message if there were no commits (not even ignored
        # commits).
        if not commits:
            gbp.log.info("No changes detected from %s to %s." % (since, until))

        if add_section:
            # If we end up here, then there were no commits to include,
            # so we put a dummy message in the new section.
            add_changelog_section(distribution="UNRELEASED", msg=["UNRELEASED"],
                                  version=version_change,
                                  dch_options=dch_options,
                                  repo=repo,
                                  options=options,
                                  cp=cp)

        fixup_trailer(repo, git_author=options.git_author,
                      dch_options=dch_options)

        if options.release:
            do_release(changelog, repo, cp, git_author=options.git_author,
                       dch_options=dch_options)
        elif options.snapshot:
            (snap, version) = do_snapshot(changelog, repo, options.snapshot_number)
            gbp.log.info("Changelog has been prepared for snapshot #%d at %s" % (snap, version))

        if editor_cmd:
            gbpc.Command(editor_cmd, ["debian/changelog"])()

        if options.commit:
            # Get the version from the changelog file (since dch might
            # have incremented it, there's no way we can already know
            # the version).
            version = ChangeLog(filename=changelog).version
            # Commit the changes to the changelog file
            msg = changelog_commit_msg(options, version)
            repo.commit_files([changelog], msg)
            gbp.log.info("Changelog has been committed for version %s" % version)

    except (GbpError, GitRepositoryError, NoChangeLogError) as err:
        if len(err.__str__()):
            gbp.log.err(err)
        ret = 1
    return ret
コード例 #5
0
def build_parser(name):
    """Construct command line parser"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(name),
                                    prefix='',
                                    usage='%prog [options] /path/to/package'
                                          '.src.rpm [target]')
    except GbpError as err:
        gbp.log.err(err)
        return None

    import_group = GbpOptionGroup(parser, "import options",
                                  "pristine-tar and filtering")
    tag_group = GbpOptionGroup(parser, "tag options",
                               "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "version and branch naming options",
                                  "version number and branch layout options")

    for group in [import_group, branch_group, tag_group]:
        parser.add_option_group(group)

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
                      default=False, help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
    parser.add_config_file_option(option_name="vendor", action="store",
                                  dest="vendor")
    parser.add_option("--download", action="store_true", dest="download",
                      default=False, help="download source package")
    branch_group.add_config_file_option(option_name="packaging-branch",
                                        dest="packaging_branch")
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_boolean_config_file_option(
        option_name="create-missing-branches",
        dest="create_missing_branches")
    branch_group.add_option("--orphan-packaging", action="store_true",
                            dest="orphan_packaging", default=False,
                            help="The packaging branch doesn't base on upstream")
    branch_group.add_option("--native", action="store_true",
                            dest="native", default=False,
                            help="This is a dist native package, no separate "
                            "upstream branch")

    tag_group.add_boolean_config_file_option(option_name="sign-tags",
                                             dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid",
                                     dest="keyid")
    tag_group.add_config_file_option(option_name="packaging-tag",
                                     dest="packaging_tag")
    tag_group.add_config_file_option(option_name="upstream-tag",
                                     dest="upstream_tag")

    import_group.add_config_file_option(option_name="filter",
                                        dest="filters", action="append")
    import_group.add_boolean_config_file_option(option_name="pristine-tar",
                                                dest="pristine_tar")
    import_group.add_option("--allow-same-version", action="store_true",
                            dest="allow_same_version", default=False,
                            help="allow to import already imported version")
    import_group.add_boolean_config_file_option(
        option_name="author-is-committer",
        dest="author_is_committer")
    import_group.add_config_file_option(option_name="packaging-dir",
                                        dest="packaging_dir")

    parser.add_config_file_option(option_name="repo-user", dest="repo_user",
                                  choices=['DEBIAN', 'GIT'])
    parser.add_config_file_option(option_name="repo-email", dest="repo_email",
                                  choices=['DEBIAN', 'GIT'])
    return parser
コード例 #6
0
def build_parser(name, prefix=None):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name), prefix=prefix)
    except configparser.ParsingError as err:
        gbp.log.err(err)
        return None

    tag_group = GbpOptionGroup(parser, "tag options", "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "branch options", "branch layout options")
    cmd_group = GbpOptionGroup(parser, "external command options", "how and when to invoke external commands and hooks")
    orig_group = GbpOptionGroup(parser, "orig tarball options", "options related to the creation of the orig tarball")
    export_group = GbpOptionGroup(parser, "export build-tree options", "alternative build tree related options")
    parser.add_option_group(tag_group)
    parser.add_option_group(orig_group)
    parser.add_option_group(branch_group)
    parser.add_option_group(cmd_group)
    parser.add_option_group(export_group)

    parser.add_boolean_config_file_option(option_name = "ignore-new", dest="ignore_new")
    parser.add_option("--git-verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_config_file_option(option_name="notify", dest="notify", type='tristate')
    tag_group.add_option("--git-tag", action="store_true", dest="tag", default=False,
                      help="create a tag after a successful build")
    tag_group.add_option("--git-tag-only", action="store_true", dest="tag_only", default=False,
                      help="don't build, only tag and run the posttag hook")
    tag_group.add_option("--git-retag", action="store_true", dest="retag", default=False,
                      help="don't fail if the tag already exists")
    tag_group.add_boolean_config_file_option(option_name="sign-tags", dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid", dest="keyid")
    tag_group.add_config_file_option(option_name="debian-tag", dest="debian_tag")
    tag_group.add_config_file_option(option_name="debian-tag-msg", dest="debian_tag_msg")
    tag_group.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
    orig_group.add_config_file_option(option_name="upstream-tree", dest="upstream_tree")
    orig_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    orig_group.add_boolean_config_file_option(option_name="pristine-tar-commit",
                                              dest="pristine_tar_commit")
    orig_group.add_config_file_option(option_name="force-create", dest="force_create",
                      help="force creation of orig tarball", action="store_true")
    orig_group.add_config_file_option(option_name="no-create-orig", dest="no_create_orig",
                      help="don't create orig tarball", action="store_true")
    orig_group.add_config_file_option(option_name="tarball-dir", dest="tarball_dir", type="path",
                      help="location to look for external tarballs")
    orig_group.add_config_file_option(option_name="compression", dest="comp_type",
                      help="Compression type, default is '%(compression)s'")
    orig_group.add_config_file_option(option_name="compression-level", dest="comp_level",
                      help="Compression level, default is '%(compression-level)s'")
    orig_group.add_option("--git-subtarball", action="append", metavar='SUBTARBALL',
                          dest="subtarballs", help="subtarsball to generate, can be given multiple times", default=[])
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name = "ignore-branch", dest="ignore_branch")
    branch_group.add_boolean_config_file_option(option_name = "submodules", dest="with_submodules")
    cmd_group.add_config_file_option(option_name="builder", dest="builder",
                      help="command to build the Debian package, default is '%(builder)s'")
    cmd_group.add_config_file_option(option_name="cleaner", dest="cleaner",
                      help="command to clean the working copy, default is '%(cleaner)s'")
    cmd_group.add_config_file_option(option_name="prebuild", dest="prebuild",
                      help="hook to run before a build, default is '%(prebuild)s'")
    cmd_group.add_config_file_option(option_name="postexport", dest="postexport",
                      help="hook to run after exporting the source tree, default is '%(postexport)s'")
    cmd_group.add_config_file_option(option_name="postbuild", dest="postbuild",
                      help="hook run after a successful build, default is '%(postbuild)s'")
    cmd_group.add_config_file_option(option_name="posttag", dest="posttag",
                      help="hook run after a successful tag operation, default is '%(posttag)s'")
    cmd_group.add_boolean_config_file_option(option_name="pbuilder", dest="use_pbuilder")
    cmd_group.add_boolean_config_file_option(option_name="qemubuilder", dest="use_qemubuilder")
    cmd_group.add_config_file_option(option_name="dist", dest="pbuilder_dist")
    cmd_group.add_config_file_option(option_name="arch", dest="pbuilder_arch")
    cmd_group.add_boolean_config_file_option(option_name = "pbuilder-autoconf", dest="pbuilder_autoconf")
    cmd_group.add_config_file_option(option_name="pbuilder-options", dest="pbuilder_options")
    cmd_group.add_boolean_config_file_option(option_name="hooks", dest="hooks")
    export_group.add_config_file_option(option_name="export-dir", dest="export_dir", type="path",
                      help="before building the package export the source into EXPORT_DIR, default is '%(export-dir)s'")
    export_group.add_config_file_option("export", dest="export",
                      help="export treeish object TREEISH, default is '%(export)s'", metavar="TREEISH")
    export_group.add_boolean_config_file_option(option_name="purge", dest="purge")
    export_group.add_option("--git-dont-purge", action="store_true", dest="dont_purge", default=False,
                            help="deprecated, use --git-no-purge instead")
    export_group.add_boolean_config_file_option(option_name="overlay", dest="overlay")
    return parser
コード例 #7
0
ファイル: import_orig.py プロジェクト: agx/git-buildpackage
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='',
                                       usage='%prog [options] /path/to/upstream-version.tar.gz | --uscan')
    except GbpError as err:
        gbp.log.err(err)
        return None

    import_group = GbpOptionGroup(parser, "import options",
                                  "pristine-tar and filtering")
    tag_group = GbpOptionGroup(parser, "tag options",
                               "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "version and branch naming options",
                                  "version number and branch layout options")
    cmd_group = GbpOptionGroup(parser, "external command options",
                               "how and when to invoke external commands and hooks")
    for group in [import_group, branch_group, tag_group, cmd_group]:
        parser.add_option_group(group)

    branch_group.add_option("-u", "--upstream-version", dest="version",
                            help="Upstream Version")
    branch_group.add_config_file_option(option_name="debian-branch",
                                        dest="debian_branch")
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_config_file_option(option_name="upstream-vcs-tag", dest="vcs_tag")
    branch_group.add_boolean_config_file_option(option_name="merge", dest="merge")
    branch_group.add_config_file_option(option_name="merge-mode", dest="merge_mode")

    tag_group.add_boolean_config_file_option(option_name="sign-tags",
                                             dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid",
                                     dest="keyid")
    tag_group.add_config_file_option(option_name="upstream-tag",
                                     dest="upstream_tag")
    import_group.add_config_file_option(option_name="filter",
                                        dest="filters", action="append")
    import_group.add_boolean_config_file_option(option_name="pristine-tar",
                                                dest="pristine_tar")
    import_group.add_boolean_config_file_option(option_name="filter-pristine-tar",
                                                dest="filter_pristine_tar")
    import_group.add_config_file_option(option_name="import-msg",
                                        dest="import_msg")
    import_group.add_boolean_config_file_option(option_name="symlink-orig",
                                                dest="symlink_orig")
    import_group.add_config_file_option("component", action="append", metavar='COMPONENT',
                                        dest="components")
    cmd_group.add_config_file_option(option_name="postimport", dest="postimport")
    cmd_group.add_config_file_option(option_name="postunpack", dest="postunpack")

    parser.add_boolean_config_file_option(option_name="interactive",
                                          dest='interactive')
    parser.add_boolean_config_file_option(option_name="rollback",
                                          dest="rollback")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_option("--uscan", dest='uscan', action="store_true",
                      default=False, help="use uscan(1) to download the new tarball.")

    # Accepted for compatibility
    parser.add_option("--download", dest='download', action="store_true",
                      default=False, help="Ignored. Accepted for compatibility; see EXAMPLES in gbp-import-orig(1).")
    return parser
コード例 #8
0
ファイル: pull.py プロジェクト: marquiz/git-buildpackage-rpm
def build_parser(name):
    try:
        parser = GbpOptionParser(command=os.path.basename(name), prefix='',
                                 usage='%prog [options] [repo] - safely update a repository from remote')
    except GbpError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser, "branch options", "branch update and layout options")
    parser.add_option_group(branch_group)
    branch_group.add_boolean_config_file_option(option_name="ignore-branch", dest="ignore_branch")
    branch_group.add_option("--force", action="store_true", dest="force", default=False,
                            help="force a branch update even if it can't be fast forwarded")
    branch_group.add_option("--redo-pq", action="store_true", dest="redo_pq", default=False,
                            help="redo the patch queue branch after a pull. Warning: this drops the old patch-queue branch")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    branch_group.add_option("--depth", action="store", dest="depth", default=0,
                            help="git history depth (for deepening shallow clones)")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    return parser
コード例 #9
0
def build_parser(name, prefix=None, git_treeish=None):
    """Construct config/option parser"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(name),
                                    prefix=prefix)
    except configparser.ParsingError as err:
        gbp.log.err(err)
        return None

    tag_group = GbpOptionGroup(parser, "tag options",
                    "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "branch options",
                    "branch layout options")
    cmd_group = GbpOptionGroup(parser, "external command options",
                    "how and when to invoke external commands and hooks")
    orig_group = GbpOptionGroup(parser, "orig tarball options",
                    "options related to the creation of the orig tarball")
    export_group = GbpOptionGroup(parser, "export build-tree options",
                    "alternative build tree related options")
    parser.add_option_group(tag_group)
    parser.add_option_group(orig_group)
    parser.add_option_group(branch_group)
    parser.add_option_group(cmd_group)
    parser.add_option_group(export_group)

    parser.add_boolean_config_file_option(option_name="ignore-new",
                    dest="ignore_new")
    parser.add_option("--git-verbose", action="store_true", dest="verbose",
                    default=False, help="verbose command execution")
    parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
    parser.add_config_file_option(option_name="color", dest="color",
                    type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                    dest="color_scheme")
    parser.add_config_file_option(option_name="notify", dest="notify",
                    type='tristate')
    parser.add_config_file_option(option_name="vendor", action="store",
                    dest="vendor")
    tag_group.add_option("--git-tag", action="store_true", dest="tag",
                    default=False,
                    help="create a tag after a successful build")
    tag_group.add_option("--git-tag-only", action="store_true", dest="tag_only",
                    default=False,
                    help="don't build, only tag and run the posttag hook")
    tag_group.add_option("--git-retag", action="store_true", dest="retag",
                    default=False, help="don't fail if the tag already exists")
    tag_group.add_boolean_config_file_option(option_name="sign-tags",
                    dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid", dest="keyid")
    tag_group.add_config_file_option(option_name="packaging-tag",
                    dest="packaging_tag")
    tag_group.add_config_file_option(option_name="packaging-tag-msg",
                    dest="packaging_tag_msg")
    tag_group.add_config_file_option(option_name="upstream-tag",
                    dest="upstream_tag")
    orig_group.add_config_file_option(option_name="upstream-tree",
                    dest="upstream_tree")
    orig_group.add_boolean_config_file_option(option_name="pristine-tar",
                    dest="pristine_tar")
    orig_group.add_boolean_config_file_option(option_name="pristine-tar-commit",
                    dest="pristine_tar_commit")
    orig_group.add_config_file_option(option_name="force-create",
                    dest="force_create", action="store_true",
                    help="force creation of upstream source tarball")
    orig_group.add_config_file_option(option_name="no-create-orig",
                    dest="no_create_orig", action="store_true",
                    help="don't create upstream source tarball")
    orig_group.add_config_file_option(option_name="tarball-dir",
                    dest="tarball_dir", type="path",
                    help="location to look for external tarballs")
    orig_group.add_config_file_option(option_name="compression-level",
                    dest="comp_level",
                    help="Compression level, default is "
                         "'%(compression-level)s'")
    branch_group.add_config_file_option(option_name="upstream-branch",
                    dest="upstream_branch")
    branch_group.add_config_file_option(option_name="packaging-branch",
                    dest="packaging_branch")
    branch_group.add_boolean_config_file_option(option_name = "ignore-branch",
                    dest="ignore_branch")
    branch_group.add_boolean_config_file_option(option_name = "submodules",
                    dest="with_submodules")
    cmd_group.add_config_file_option(option_name="builder", dest="builder",
                    help="command to build the package, default is "
                         "'%(builder)s'")
    cmd_group.add_config_file_option(option_name="cleaner", dest="cleaner",
                    help="command to clean the working copy, default is "
                         "'%(cleaner)s'")
    cmd_group.add_config_file_option(option_name="prebuild", dest="prebuild",
                    help="command to run before a build, default is "
                         "'%(prebuild)s'")
    cmd_group.add_config_file_option(option_name="postexport",
                    dest="postexport",
                    help="command to run after exporting the source tree, "
                         "default is '%(postexport)s'")
    cmd_group.add_config_file_option(option_name="postbuild", dest="postbuild",
                    help="hook run after a successful build, default is "
                         "'%(postbuild)s'")
    cmd_group.add_config_file_option(option_name="posttag", dest="posttag",
                    help="hook run after a successful tag operation, default "
                         "is '%(posttag)s'")
    cmd_group.add_boolean_config_file_option(option_name="mock", dest="use_mock")
    cmd_group.add_config_file_option(option_name="dist", dest="mock_dist")
    cmd_group.add_config_file_option(option_name="arch", dest="mock_arch")
    cmd_group.add_config_file_option(option_name="mock-root", dest="mock_root")
    cmd_group.add_config_file_option(option_name="mock-options", dest="mock_options")
    cmd_group.add_boolean_config_file_option(option_name="hooks", dest="hooks")
    export_group.add_option("--git-no-build", action="store_true",
                    dest="no_build",
                    help="Don't run builder or the associated hooks")
    export_group.add_config_file_option(option_name="export-dir",
                    dest="export_dir", type="path",
                    help="Build topdir, also export the sources under "
                         "EXPORT_DIR, default is '%(export-dir)s'")
    export_group.add_config_file_option(option_name="export-specdir",
                    dest="export_specdir", type="path")
    export_group.add_config_file_option(option_name="export-sourcedir",
                    dest="export_sourcedir", type="path")
    export_group.add_config_file_option("export", dest="export",
                    metavar="TREEISH",
                    help="export treeish object TREEISH, default is "
                         "'%(export)s'")
    export_group.add_config_file_option(option_name="packaging-dir",
                    dest="packaging_dir")
    export_group.add_config_file_option(option_name="spec-file",
                    dest="spec_file")
    return parser
コード例 #10
0
ファイル: pull.py プロジェクト: hzsunzixiang/git-buildpackage
def main(argv):
    retval = 0
    current = None

    parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='',
                             usage='%prog [options] - safely update a repository from remote')
    branch_group = GbpOptionGroup(parser, "branch options", "branch update and layout options")
    parser.add_option_group(branch_group)
    branch_group.add_boolean_config_file_option(option_name = "ignore-branch", dest="ignore_branch")
    branch_group.add_option("--force", action="store_true", dest="force", default=False,
                      help="force a branch update even if it can't be fast forwarded")
    branch_group.add_option("--redo-pq", action="store_true", dest="redo_pq", default=False,
                      help="redo the patch queue branch after a pull. Warning: this drops the old patch-queue branch")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    branch_group.add_option("--depth", action="store", dest="depth", default=0,
                            help="git history depth (for deepening shallow clones)")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")


    (options, args) = parser.parse_args(argv)
    gbp.log.setup(options.color, options.verbose, options.color_scheme)

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

    try:
        branches = []
        try:
            current = repo.get_branch()
        except GitRepositoryError:
            # Not being on any branch is o.k. with --git-ignore-branch
            if  options.ignore_branch:
                current = repo.head
                gbp.log.info("Found detached head at '%s'" % current)
            else:
                raise

        for branch in [ options.debian_branch, options.upstream_branch ]:
            if repo.has_branch(branch):
                branches += [ branch ]

        if repo.has_pristine_tar_branch() and options.pristine_tar:
            branches += [ repo.pristine_tar_branch ]

        (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

        repo.fetch(depth=options.depth)
        repo.fetch(depth=options.depth, tags=True)
        for branch in branches:
            if not fast_forward_branch(branch, repo, options):
                retval = 2

        if options.redo_pq:
            repo.set_branch(options.debian_branch)
            Command("gbp-pq")(["drop"])
            Command("gbp-pq")(["import"])

        repo.set_branch(current)
    except CommandExecFailed:
        retval = 1
    except (GbpError, GitRepositoryError) as err:
        if len(err.__str__()):
            gbp.log.err(err)
        retval = 1

    return retval
コード例 #11
0
ファイル: rpm_ch.py プロジェクト: dcoshea/git-buildpackage
def build_parser(name):
    """Construct command line parser"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(name),
                                    prefix='',
                                    usage='%prog [options] paths')
    except GbpError as err:
        gbp.log.err(err)
        return None

    range_grp = GbpOptionGroup(parser, "commit range options",
                               "which commits to add to the changelog")
    format_grp = GbpOptionGroup(parser, "changelog entry formatting",
                                "how to format the changelog entries")
    naming_grp = GbpOptionGroup(
        parser, "naming",
        "branch names, tag formats, directory and file naming")
    parser.add_option_group(range_grp)
    parser.add_option_group(format_grp)
    parser.add_option_group(naming_grp)

    # Non-grouped options
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
    parser.add_config_file_option(option_name="vendor",
                                  action="store",
                                  dest="vendor")
    parser.add_config_file_option(
        option_name="git-log",
        dest="git_log",
        help="options to pass to git-log, default is '%(git-log)s'")
    parser.add_boolean_config_file_option(option_name="ignore-branch",
                                          dest="ignore_branch")
    parser.add_config_file_option(
        option_name="customizations",
        dest="customization_file",
        help="Load Python code from CUSTOMIZATION_FILE. At the "
        "moment, the only useful thing the code can do is define a "
        "custom ChangelogEntryFormatter class.")

    # Naming group options
    naming_grp.add_config_file_option(option_name="packaging-branch",
                                      dest="packaging_branch")
    naming_grp.add_config_file_option(option_name="packaging-tag",
                                      dest="packaging_tag")
    naming_grp.add_config_file_option(option_name="packaging-dir",
                                      dest="packaging_dir")
    naming_grp.add_config_file_option(option_name="changelog-file",
                                      dest="changelog_file")
    naming_grp.add_config_file_option(option_name="spec-file",
                                      dest="spec_file")
    # Range group options
    range_grp.add_option(
        "-s",
        "--since",
        dest="since",
        help="commit to start from (e.g. HEAD^^^, release/0.1.2)")
    # Formatting group options
    format_grp.add_option(
        "--no-release",
        action="store_false",
        default=True,
        dest="release",
        help="no release, just update the last changelog section")
    format_grp.add_boolean_config_file_option(option_name="git-author",
                                              dest="git_author")
    format_grp.add_boolean_config_file_option(option_name="full", dest="full")
    format_grp.add_config_file_option(
        option_name="id-length",
        dest="idlen",
        help="include N digits of the commit id in the changelog "
        "entry, default is '%(id-length)s'",
        type="int",
        metavar="N")
    format_grp.add_config_file_option(
        option_name="ignore-regex",
        dest="ignore_regex",
        help="Ignore lines in commit message matching regex, "
        "default is '%(ignore-regex)s'")
    format_grp.add_config_file_option(option_name="changelog-revision",
                                      dest="changelog_revision")
    format_grp.add_config_file_option(option_name="spawn-editor",
                                      dest="spawn_editor")
    format_grp.add_config_file_option(option_name="editor-cmd",
                                      dest="editor_cmd")
    return parser
コード例 #12
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='',
                                       usage='%prog [options] /path/to/upstream-version.tar.gz | --uscan')
    except ConfigParser.ParsingError as err:
        gbp.log.err(err)
        return None

    import_group = GbpOptionGroup(parser, "import options",
                      "pristine-tar and filtering")
    tag_group = GbpOptionGroup(parser, "tag options",
                      "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "version and branch naming options",
                      "version number and branch layout options")
    cmd_group = GbpOptionGroup(parser, "external command options", "how and when to invoke external commands and hooks")

    for group in [import_group, branch_group, tag_group, cmd_group ]:
        parser.add_option_group(group)

    branch_group.add_option("-u", "--upstream-version", dest="version",
                      help="Upstream Version")
    branch_group.add_config_file_option(option_name="debian-branch",
                      dest="debian_branch")
    branch_group.add_config_file_option(option_name="upstream-branch",
                      dest="upstream_branch")
    branch_group.add_option("--upstream-vcs-tag", dest="vcs_tag",
                            help="Upstream VCS tag add to the merge commit")
    branch_group.add_boolean_config_file_option(option_name="merge", dest="merge")

    tag_group.add_boolean_config_file_option(option_name="sign-tags",
                      dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid",
                      dest="keyid")
    tag_group.add_config_file_option(option_name="upstream-tag",
                      dest="upstream_tag")
    import_group.add_config_file_option(option_name="filter",
                      dest="filters", action="append")
    import_group.add_boolean_config_file_option(option_name="pristine-tar",
                      dest="pristine_tar")
    import_group.add_boolean_config_file_option(option_name="filter-pristine-tar",
                      dest="filter_pristine_tar")
    import_group.add_config_file_option(option_name="import-msg",
                      dest="import_msg")
    import_group.add_boolean_config_file_option(option_name="symlink-orig",
                                                dest="symlink_orig")
    cmd_group.add_config_file_option(option_name="postimport", dest="postimport")

    parser.add_boolean_config_file_option(option_name="interactive",
                                          dest='interactive')
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")

    # Accepted for compatibility
    parser.add_option("--no-dch", dest='no_dch', action="store_true",
                      default=False, help="deprecated - don't use.")
    parser.add_option("--uscan", dest='uscan', action="store_true",
                      default=False, help="use uscan(1) to download the new tarball.")
    return parser
コード例 #13
0
def build_parser(name):
    try:
        parser = GbpOptionParser(
            command=os.path.basename(name),
            prefix='',
            usage='%prog [options] repository - clone a remote repository')
    except GbpError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser, "branch options",
                                  "branch tracking and layout options")
    cmd_group = GbpOptionGroup(parser, "external command options",
                               "how and when to invoke hooks")
    parser.add_option_group(branch_group)
    parser.add_option_group(cmd_group)

    branch_group.add_option(
        "--all",
        action="store_true",
        dest="all",
        default=False,
        help="track all branches, not only debian and upstream")
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch",
                                        dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar",
                                                dest="pristine_tar")
    branch_group.add_option(
        "--depth",
        action="store",
        dest="depth",
        default=0,
        help="git history depth (for creating shallow clones)")
    branch_group.add_option(
        "--reference",
        action="store",
        dest="reference",
        default=None,
        help="git reference repository (use local copies where possible)")
    cmd_group.add_config_file_option(
        option_name="postclone",
        dest="postclone",
        help="hook to run after cloning the source tree, "
        "default is '%(postclone)s'")
    cmd_group.add_boolean_config_file_option(option_name="hooks", dest="hooks")

    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_config_file_option(option_name="repo-user",
                                  dest="repo_user",
                                  choices=['DEBIAN', 'GIT'])
    parser.add_config_file_option(option_name="repo-email",
                                  dest="repo_email",
                                  choices=['DEBIAN', 'GIT'])
    return parser
コード例 #14
0
ファイル: clone.py プロジェクト: agx/git-buildpackage
def build_parser(name):
    try:
        parser = GbpOptionParser(command=os.path.basename(name), prefix='',
                                 usage='%prog [options] repository - clone a remote repository')
    except GbpError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser, "branch options", "branch tracking and layout options")
    cmd_group = GbpOptionGroup(parser, "external command options", "how and when to invoke hooks")
    parser.add_option_group(branch_group)
    parser.add_option_group(cmd_group)

    branch_group.add_option("--all", action="store_true", dest="all", default=False,
                            help="track all branches, not only debian and upstream")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    branch_group.add_option("--depth", action="store", dest="depth", default=0,
                            help="git history depth (for creating shallow clones)")
    branch_group.add_option("--reference", action="store", dest="reference", default=None,
                            help="git reference repository (use local copies where possible)")
    cmd_group.add_config_file_option(option_name="postclone", dest="postclone",
                                     help="hook to run after cloning the source tree, "
                                     "default is '%(postclone)s'")
    cmd_group.add_boolean_config_file_option(option_name="hooks", dest="hooks")

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_config_file_option(option_name="repo-user", dest="repo_user",
                                  choices=['DEBIAN', 'GIT'])
    parser.add_config_file_option(option_name="repo-email", dest="repo_email",
                                  choices=['DEBIAN', 'GIT'])
    return parser
コード例 #15
0
def parse_args(argv):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='',
                                       usage='%prog [options] /path/to/package.dsc')
    except ConfigParser.ParsingError as err:
        gbp.log.err(err)
        return None, None

    import_group = GbpOptionGroup(parser, "import options",
                      "pristine-tar and filtering")
    tag_group = GbpOptionGroup(parser, "tag options",
                      "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "version and branch naming options",
                      "version number and branch layout options")

    for group in [import_group, branch_group, tag_group ]:
        parser.add_option_group(group)

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_option("--download", action="store_true", dest="download", default=False,
                      help="download source package")
    branch_group.add_config_file_option(option_name="debian-branch",
                      dest="debian_branch")
    branch_group.add_config_file_option(option_name="upstream-branch",
                      dest="upstream_branch")
    branch_group.add_boolean_config_file_option(option_name="create-missing-branches",
                      dest="create_missing_branches")

    tag_group.add_boolean_config_file_option(option_name="sign-tags",
                      dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid",
                      dest="keyid")
    tag_group.add_config_file_option(option_name="debian-tag",
                      dest="debian_tag")
    tag_group.add_config_file_option(option_name="upstream-tag",
                      dest="upstream_tag")
    tag_group.add_option("--skip-debian-tag",dest="skip_debian_tag",
                         action="store_true", default=False,
                         help="Don't add a tag after importing the Debian patch")


    import_group.add_config_file_option(option_name="filter",
                      dest="filters", action="append")
    import_group.add_boolean_config_file_option(option_name="pristine-tar",
                      dest="pristine_tar")
    import_group.add_option("--allow-same-version", action="store_true",
                      dest="allow_same_version", default=False,
                      help="allow to import already imported version")
    import_group.add_boolean_config_file_option(option_name="author-is-committer",
                      dest="author_committer")
    import_group.add_boolean_config_file_option(option_name="author-date-is-committer-date",
                      dest="author_committer_date")
    import_group.add_boolean_config_file_option(option_name="allow-unauthenticated",
                      dest="allow_unauthenticated")

    (options, args) = parser.parse_args(argv[1:])
    gbp.log.setup(options.color, options.verbose)
    gbp.log.setup(options.color, options.verbose, options.color_scheme)
    return options, args
コード例 #16
0
def parse_args(argv):
    """Parse command line and config file options"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(argv[0]),
                                    prefix='',
                                    usage='%prog [options] paths')
    except ConfigParser.ParsingError as err:
        gbp.log.error('invalid config file: %s' % err)
        return None, None

    range_grp = GbpOptionGroup(parser, "commit range options",
                               "which commits to add to the changelog")
    format_grp = GbpOptionGroup(parser, "changelog entry formatting",
                                "how to format the changelog entries")
    naming_grp = GbpOptionGroup(
        parser, "naming",
        "branch names, tag formats, directory and file naming")
    commit_grp = GbpOptionGroup(parser, "commit",
                                "automatic committing and tagging")
    parser.add_option_group(range_grp)
    parser.add_option_group(format_grp)
    parser.add_option_group(naming_grp)
    parser.add_option_group(commit_grp)

    # Non-grouped options
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_config_file_option(option_name="vendor",
                                  action="store",
                                  dest="vendor")
    parser.add_config_file_option(
        option_name="git-log",
        dest="git_log",
        help="options to pass to git-log, default is '%(git-log)s'")
    parser.add_boolean_config_file_option(option_name="ignore-branch",
                                          dest="ignore_branch")
    parser.add_config_file_option(
        option_name="customizations",
        dest="customization_file",
        help="Load Python code from CUSTOMIZATION_FILE. At the "
        "moment, the only useful thing the code can do is "
        "define a custom ChangelogEntryFormatter class.")
    # Naming group options
    naming_grp.add_config_file_option(option_name="packaging-branch",
                                      dest="packaging_branch")
    naming_grp.add_config_file_option(option_name="packaging-tag",
                                      dest="packaging_tag")
    naming_grp.add_config_file_option(option_name="packaging-dir",
                                      dest="packaging_dir")
    naming_grp.add_config_file_option(option_name="changelog-file",
                                      dest="changelog_file")
    naming_grp.add_config_file_option(option_name="spec-file",
                                      dest="spec_file")
    # Range group options
    range_grp.add_option(
        "-s",
        "--since",
        dest="since",
        help="commit to start from (e.g. HEAD^^^, release/0.1.2)")
    range_grp.add_option(
        "--all",
        action="store_true",
        help="use all commits from the Git history, overrides "
        "--since")
    # Formatting group options
    format_grp.add_config_file_option(option_name="meta-bts", dest="meta_bts")
    format_grp.add_option(
        "--no-release",
        action="store_false",
        default=True,
        dest="release",
        help="no release, just update the last changelog section")
    format_grp.add_boolean_config_file_option(option_name="git-author",
                                              dest="git_author")
    format_grp.add_boolean_config_file_option(option_name="full", dest="full")
    format_grp.add_config_file_option(
        option_name="id-length",
        dest="idlen",
        help="include N digits of the commit id in the changelog "
        "entry, default is '%(id-length)s'",
        type="int",
        metavar="N")
    format_grp.add_config_file_option(
        option_name="ignore-regex",
        dest="ignore_regex",
        help="Ignore lines in commit message matching regex, "
        "default is '%(ignore-regex)s'")
    format_grp.add_config_file_option(option_name="changelog-revision",
                                      dest="changelog_revision")
    format_grp.add_config_file_option(option_name="spawn-editor",
                                      dest="spawn_editor")
    format_grp.add_config_file_option(option_name="editor-cmd",
                                      dest="editor_cmd")
    format_grp.add_option(
        "-m",
        '--message',
        help="text to use as new changelog entries - git commit "
        "messages and the --since are ignored in this case")
    # Commit/tag group options
    commit_grp.add_option("-c",
                          "--commit",
                          action="store_true",
                          help="commit changes")
    commit_grp.add_config_file_option(option_name="commit-msg",
                                      dest="commit_msg")
    commit_grp.add_option(
        "--tag",
        action="store_true",
        help="commit the changes and create a packaging/release"
        "tag")
    commit_grp.add_option("--retag",
                          action="store_true",
                          help="Overwrite packaging tag if it already exists")
    commit_grp.add_boolean_config_file_option(option_name="sign-tags",
                                              dest="sign_tags")
    commit_grp.add_config_file_option(option_name="keyid", dest="keyid")

    options, args = parser.parse_args(argv[1:])
    if options.tag:
        options.commit = True
    if not options.changelog_revision:
        options.changelog_revision = RpmPkgPolicy.Changelog.header_rev_format

    gbp.log.setup(options.color, options.verbose, options.color_scheme)

    return options, args
コード例 #17
0
    # Checkout packaging branch
    repo.set_branch(branch)


def parse_args(argv):
    """Parse commandline arguments"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(argv[0]),
                                    prefix='',
                                    usage='%prog [options] /path/to/package'
                                    '.src.rpm')
    except ConfigParser.ParsingError, err:
        gbp.log.err(err)
        return None, None

    import_group = GbpOptionGroup(parser, "import options",
                                  "pristine-tar and filtering")
    tag_group = GbpOptionGroup(parser, "tag options",
                               "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "version and branch naming options",
                                  "version number and branch layout options")

    for group in [import_group, branch_group, tag_group]:
        parser.add_option_group(group)

    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
コード例 #18
0
def parse_args(argv):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='',
                                       usage='%prog [options] /path/to/upstream-version.tar.gz | --uscan')
    except ConfigParser.ParsingError as err:
        gbp.log.err(err)
        return None, None

    import_group = GbpOptionGroup(parser, "import options",
                      "pristine-tar and filtering")
    tag_group = GbpOptionGroup(parser, "tag options",
                      "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "version and branch naming options",
                      "version number and branch layout options")
    cmd_group = GbpOptionGroup(parser, "external command options", "how and when to invoke external commands and hooks")

    for group in [import_group, branch_group, tag_group, cmd_group ]:
        parser.add_option_group(group)

    branch_group.add_option("-u", "--upstream-version", dest="version",
                      help="Upstream Version")
    branch_group.add_config_file_option(option_name="debian-branch",
                      dest="debian_branch")
    branch_group.add_config_file_option(option_name="upstream-branch",
                      dest="upstream_branch")
    branch_group.add_option("--upstream-vcs-tag", dest="vcs_tag",
                            help="Upstream VCS tag add to the merge commit")
    branch_group.add_boolean_config_file_option(option_name="merge", dest="merge")

    tag_group.add_boolean_config_file_option(option_name="sign-tags",
                      dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid",
                      dest="keyid")
    tag_group.add_config_file_option(option_name="upstream-tag",
                      dest="upstream_tag")
    import_group.add_config_file_option(option_name="filter",
                      dest="filters", action="append")
    import_group.add_boolean_config_file_option(option_name="pristine-tar",
                      dest="pristine_tar")
    import_group.add_boolean_config_file_option(option_name="filter-pristine-tar",
                      dest="filter_pristine_tar")
    import_group.add_config_file_option(option_name="import-msg",
                      dest="import_msg")
    import_group.add_boolean_config_file_option(option_name="symlink-orig",
                                                dest="symlink_orig")
    cmd_group.add_config_file_option(option_name="postimport", dest="postimport")

    parser.add_boolean_config_file_option(option_name="interactive",
                                          dest='interactive')
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")

    # Accepted for compatibility
    parser.add_option("--no-dch", dest='no_dch', action="store_true",
                      default=False, help="deprecated - don't use.")
    parser.add_option("--uscan", dest='uscan', action="store_true",
                      default=False, help="use uscan(1) to download the new tarball.")

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

    if options.no_dch:
        gbp.log.warn("'--no-dch' passed. This is now the default, please remove this option.")

    return options, args
コード例 #19
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(
            command=os.path.basename(name),
            prefix='',
            usage='%prog [options] /path/to/upstream-version.tar.gz | --uscan')
    except GbpError as err:
        gbp.log.err(err)
        return None

    import_group = GbpOptionGroup(parser, "import options",
                                  "import related options")
    tag_group = GbpOptionGroup(parser, "tag options", "tag related options ")
    branch_group = GbpOptionGroup(parser, "version and branch naming options",
                                  "version number and branch layout options")
    cmd_group = GbpOptionGroup(
        parser, "external command options",
        "how and when to invoke external commands and hooks")
    for group in [import_group, branch_group, tag_group, cmd_group]:
        parser.add_option_group(group)

    branch_group.add_option(
        "-u",
        "--upstream-version",
        dest="version",
        help="The version number to use for the new version, "
        "default is ''",
        default='')
    branch_group.add_config_file_option(option_name="debian-branch",
                                        dest="debian_branch")
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_config_file_option(
        option_name="upstream-tree",
        dest="upstream_tree",
        help="Where to merge the upstream changes from.",
        default="VERSION")
    branch_group.add_config_file_option(option_name="merge-mode",
                                        dest="merge_mode")

    tag_group.add_boolean_config_file_option(option_name="sign-tags",
                                             dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid", dest="keyid")
    tag_group.add_config_file_option(option_name="upstream-tag",
                                     dest="upstream_tag")
    import_group.add_config_file_option(option_name="import-msg",
                                        dest="import_msg")
    cmd_group.add_config_file_option(option_name="postimport",
                                     dest="postimport")

    parser.add_boolean_config_file_option(option_name="rollback",
                                          dest="rollback")
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    return parser
コード例 #20
0
def parse_args(argv, sections=[]):
    """
    Parse the command line arguments and config files.

    @param argv: the command line arguments
    @type argv: C{list} of C{str}
    @param sections: additional sections to add to the config file parser
        besides the command name
    @type sections: C{list} of C{str}
    """

    # We simpley handle the template section as an additional config file
    # section to parse, this makes e.g. --help work as expected:
    for arg in argv:
        if arg.startswith('--remote-config='):
            sections = ['remote-config %s' % arg.split('=',1)[1]]
            break
    else:
        sections = []

    parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='',
                                   usage='%prog [options] - '
                                   'create a remote repository',
                                   sections=sections)
    branch_group = GbpOptionGroup(parser,
                                  "branch options",
                                  "branch layout and tracking options")
    branch_group.add_config_file_option(option_name="remote-url-pattern",
                                        dest="remote_url")
    parser.add_option_group(branch_group)
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch",
                                        dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar",
                                                dest="pristine_tar")
    branch_group.add_boolean_config_file_option(option_name="track",
                                                dest='track')
    parser.add_option("-v", "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_option("--remote-name",
                      dest="name",
                      default="origin",
                      help="The name of the remote, default is 'origin'")
    parser.add_config_file_option(option_name="template-dir",
                                  dest="template_dir")
    parser.add_config_file_option(option_name="remote-config",
                                  dest="remote_config")

    (options, args) = parser.parse_args(argv)

    return options, args
コード例 #21
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='',
                                       usage='%prog [options] /path/to/package.dsc [target]')
    except GbpError as err:
        gbp.log.err(err)
        return None

    import_group = GbpOptionGroup(parser, "import options",
                                  "pristine-tar and filtering")
    tag_group = GbpOptionGroup(parser, "tag options",
                               "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "version and branch naming options",
                                  "version number and branch layout options")
    for group in [import_group, branch_group, tag_group]:
        parser.add_option_group(group)

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    branch_group.add_config_file_option(option_name="debian-branch",
                                        dest="debian_branch")
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_boolean_config_file_option(option_name="create-missing-branches",
                                                dest="create_missing_branches")

    tag_group.add_boolean_config_file_option(option_name="sign-tags",
                                             dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid",
                                     dest="keyid")
    tag_group.add_config_file_option(option_name="debian-tag",
                                     dest="debian_tag")
    tag_group.add_config_file_option(option_name="upstream-tag",
                                     dest="upstream_tag")
    tag_group.add_option("--skip-debian-tag", dest="skip_debian_tag",
                         action="store_true", default=False,
                         help="Don't add a tag after importing the Debian patch")

    import_group.add_config_file_option(option_name="filter",
                                        dest="filters", action="append")
    import_group.add_boolean_config_file_option(option_name="pristine-tar",
                                                dest="pristine_tar")
    import_group.add_option("--allow-same-version", action="store_true",
                            dest="allow_same_version", default=False,
                            help="allow to import already imported version")
    import_group.add_boolean_config_file_option(option_name="author-is-committer",
                                                dest="author_committer")
    import_group.add_boolean_config_file_option(option_name="author-date-is-committer-date",
                                                dest="author_committer_date")
    import_group.add_boolean_config_file_option(option_name="allow-unauthenticated",
                                                dest="allow_unauthenticated")

    parser.add_config_file_option(option_name="repo-user", dest="repo_user",
                                  choices=['DEBIAN', 'GIT'])
    parser.add_config_file_option(option_name="repo-email", dest="repo_email",
                                  choices=['DEBIAN', 'GIT'])
    parser.add_option("--download", dest='download', action="store_true",
                      default=False, help="Ignored. Accepted for compatibility.")
    return parser
コード例 #22
0
def build_parser(name):
    """Construct command line parser"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(name),
                                    prefix='', usage='%prog [options] paths')
    except GbpError as err:
        gbp.log.err(err)
        return None

    range_grp = GbpOptionGroup(parser, "commit range options",
                               "which commits to add to the changelog")
    format_grp = GbpOptionGroup(parser, "changelog entry formatting",
                                "how to format the changelog entries")
    naming_grp = GbpOptionGroup(parser, "naming",
                                "branch names, tag formats, directory and file naming")
    parser.add_option_group(range_grp)
    parser.add_option_group(format_grp)
    parser.add_option_group(naming_grp)

    # Non-grouped options
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
    parser.add_config_file_option(option_name="vendor", action="store",
                                  dest="vendor")
    parser.add_config_file_option(option_name="git-log", dest="git_log",
                                  help="options to pass to git-log, default is '%(git-log)s'")
    parser.add_boolean_config_file_option(option_name="ignore-branch",
                                          dest="ignore_branch")
    parser.add_config_file_option(option_name="customizations",
                                  dest="customization_file",
                                  help="Load Python code from CUSTOMIZATION_FILE. At the "
                                  "moment, the only useful thing the code can do is define a "
                                  "custom ChangelogEntryFormatter class.")

    # Naming group options
    naming_grp.add_config_file_option(option_name="packaging-branch",
                                      dest="packaging_branch")
    naming_grp.add_config_file_option(option_name="packaging-tag",
                                      dest="packaging_tag")
    naming_grp.add_config_file_option(option_name="packaging-dir",
                                      dest="packaging_dir")
    naming_grp.add_config_file_option(option_name="changelog-file",
                                      dest="changelog_file")
    naming_grp.add_config_file_option(option_name="spec-file", dest="spec_file")
    # Range group options
    range_grp.add_option("-s", "--since", dest="since",
                         help="commit to start from (e.g. HEAD^^^, release/0.1.2)")
    # Formatting group options
    format_grp.add_option("--no-release", action="store_false", default=True,
                          dest="release",
                          help="no release, just update the last changelog section")
    format_grp.add_boolean_config_file_option(option_name="git-author",
                                              dest="git_author")
    format_grp.add_boolean_config_file_option(option_name="full", dest="full")
    format_grp.add_config_file_option(option_name="id-length", dest="idlen",
                                      help="include N digits of the commit id in the changelog "
                                      "entry, default is '%(id-length)s'",
                                      type="int", metavar="N")
    format_grp.add_config_file_option(option_name="ignore-regex",
                                      dest="ignore_regex",
                                      help="Ignore lines in commit message matching regex, "
                                      "default is '%(ignore-regex)s'")
    format_grp.add_config_file_option(option_name="changelog-revision",
                                      dest="changelog_revision")
    format_grp.add_config_file_option(option_name="spawn-editor",
                                      dest="spawn_editor")
    format_grp.add_config_file_option(option_name="editor-cmd",
                                      dest="editor_cmd")
    return parser
コード例 #23
0
def build_parser(name, sections=[]):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='',
                                       usage='%prog [options] - '
                                       'create a remote repository',
                                       sections=sections)
    except configparser.ParsingError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser,
                                  "branch options",
                                  "branch layout and tracking options")
    branch_group.add_config_file_option(option_name="remote-url-pattern",
                                        dest="remote_url")
    parser.add_option_group(branch_group)
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch",
                                        dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar",
                                                dest="pristine_tar")
    branch_group.add_boolean_config_file_option(option_name="track",
                                                dest='track')
    parser.add_option("-v", "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_option("--remote-name",
                      dest="name",
                      default="origin",
                      help="The name of the remote, default is 'origin'")
    parser.add_config_file_option(option_name="template-dir",
                                  dest="template_dir")
    parser.add_config_file_option(option_name="remote-config",
                                  dest="remote_config")
    return parser
コード例 #24
0
def build_parser(name, prefix=None):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name),
                                       prefix=prefix)
    except GbpError as err:
        gbp.log.err(err)
        return None

    tag_group = GbpOptionGroup(parser, "tag options",
                               "options related to git tag creation")
    orig_group = GbpOptionGroup(
        parser, "orig tarball options",
        "options related to the creation of the orig tarball")
    branch_group = GbpOptionGroup(parser, "branch options",
                                  "branch layout options")
    cmd_group = GbpOptionGroup(
        parser, "external command options",
        "how and when to invoke external commands and hooks")
    export_group = GbpOptionGroup(parser, "export build-tree options",
                                  "alternative build tree related options")
    for group in [
            tag_group, orig_group, branch_group, cmd_group, export_group
    ]:
        parser.add_option_group(group)

    parser.add_boolean_config_file_option(option_name="ignore-new",
                                          dest="ignore_new")
    parser.add_option("--git-verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_config_file_option(option_name="notify",
                                  dest="notify",
                                  type='tristate')
    tag_group.add_option("--git-tag",
                         action="store_true",
                         dest="tag",
                         default=False,
                         help="create a tag after a successful build")
    tag_group.add_option("--git-tag-only",
                         action="store_true",
                         dest="tag_only",
                         default=False,
                         help="don't build, only tag and run the posttag hook")
    tag_group.add_option("--git-retag",
                         action="store_true",
                         dest="retag",
                         default=False,
                         help="don't fail if the tag already exists")
    tag_group.add_boolean_config_file_option(option_name="sign-tags",
                                             dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid", dest="keyid")
    tag_group.add_config_file_option(option_name="debian-tag",
                                     dest="debian_tag")
    tag_group.add_config_file_option(option_name="debian-tag-msg",
                                     dest="debian_tag_msg")
    tag_group.add_config_file_option(option_name="upstream-tag",
                                     dest="upstream_tag")
    orig_group.add_config_file_option(option_name="upstream-tree",
                                      dest="upstream_tree")
    orig_group.add_boolean_config_file_option(option_name="pristine-tar",
                                              dest="pristine_tar")
    orig_group.add_boolean_config_file_option(
        option_name="pristine-tar-commit", dest="pristine_tar_commit")
    orig_group.add_config_file_option(option_name="force-create",
                                      dest="force_create",
                                      help="force creation of orig tarball",
                                      action="store_true")
    orig_group.add_config_file_option(option_name="no-create-orig",
                                      dest="no_create_orig",
                                      help="don't create orig tarball",
                                      action="store_true")
    orig_group.add_config_file_option(
        option_name="tarball-dir",
        dest="tarball_dir",
        type="path",
        help="location to look for external tarballs")
    orig_group.add_config_file_option(
        option_name="compression",
        dest="comp_type",
        help="Compression type, default is '%(compression)s'")
    orig_group.add_config_file_option(
        option_name="compression-level",
        dest="comp_level",
        help="Compression level, default is '%(compression-level)s'")
    orig_group.add_config_file_option("component",
                                      action="append",
                                      metavar='COMPONENT',
                                      dest="components")
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch",
                                        dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="ignore-branch",
                                                dest="ignore_branch")
    branch_group.add_boolean_config_file_option(option_name="submodules",
                                                dest="with_submodules")
    cmd_group.add_config_file_option(
        option_name="builder",
        dest="builder",
        help="command to build the Debian package, "
        "default is '%(builder)s'")
    cmd_group.add_config_file_option(option_name="cleaner",
                                     dest="cleaner",
                                     help="command to clean the working copy, "
                                     "default is '%(cleaner)s'")
    cmd_group.add_config_file_option(option_name="prebuild",
                                     dest="prebuild",
                                     help="hook to run before a build, "
                                     "default is '%(prebuild)s'")
    cmd_group.add_config_file_option(
        option_name="postexport",
        dest="postexport",
        help="hook to run after exporting the source tree, "
        "default is '%(postexport)s'")
    cmd_group.add_config_file_option(option_name="postbuild",
                                     dest="postbuild",
                                     help="hook run after a successful build, "
                                     "default is '%(postbuild)s'")
    cmd_group.add_config_file_option(
        option_name="posttag",
        dest="posttag",
        help="hook run after a successful tag operation, "
        "default is '%(posttag)s'")
    cmd_group.add_boolean_config_file_option(option_name="pbuilder",
                                             dest="use_pbuilder")
    cmd_group.add_boolean_config_file_option(option_name="qemubuilder",
                                             dest="use_qemubuilder")
    cmd_group.add_config_file_option(option_name="dist", dest="pbuilder_dist")
    cmd_group.add_config_file_option(option_name="arch", dest="pbuilder_arch")
    cmd_group.add_boolean_config_file_option(option_name="pbuilder-autoconf",
                                             dest="pbuilder_autoconf")
    cmd_group.add_config_file_option(option_name="pbuilder-options",
                                     dest="pbuilder_options")
    cmd_group.add_boolean_config_file_option(option_name="hooks", dest="hooks")
    export_group.add_config_file_option(
        option_name="export-dir",
        dest="export_dir",
        type="path",
        help="before building the package export the source into EXPORT_DIR, "
        "default is '%(export-dir)s'")
    export_group.add_config_file_option("export",
                                        dest="export",
                                        help="export treeish object TREEISH, "
                                        "default is '%(export)s'",
                                        metavar="TREEISH")
    export_group.add_boolean_config_file_option(option_name="purge",
                                                dest="purge")
    export_group.add_option("--git-dont-purge",
                            action="store_true",
                            dest="dont_purge",
                            default=False,
                            help="deprecated, use --git-no-purge instead")
    export_group.add_boolean_config_file_option(option_name="overlay",
                                                dest="overlay")
    return parser
コード例 #25
0
    builder_args = [arg for arg in argv[1:] if arg.find('--%s' % prefix) == -1]

    # We handle these although they don't have a --git- prefix
    for arg in ["--help", "-h", "--version"]:
        if arg in builder_args:
            args.append(arg)

    try:
        parser = GbpOptionParserRpm(command=os.path.basename(argv[0]),
                                    prefix=prefix,
                                    git_treeish=git_treeish)
    except ConfigParser.ParsingError, err:
        gbp.log.err(err)
        return None, None, None

    tag_group = GbpOptionGroup(parser, "tag options",
                               "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "branch options",
                                  "branch layout options")
    cmd_group = GbpOptionGroup(
        parser, "external command options",
        "how and when to invoke external commands and hooks")
    orig_group = GbpOptionGroup(
        parser, "orig tarball options",
        "options related to the creation of the orig tarball")
    export_group = GbpOptionGroup(parser, "export build-tree options",
                                  "alternative build tree related options")
    parser.add_option_group(tag_group)
    parser.add_option_group(orig_group)
    parser.add_option_group(branch_group)
    parser.add_option_group(cmd_group)
    parser.add_option_group(export_group)
コード例 #26
0
def build_parser(name, prefix=None, git_treeish=None):
    """Construct config/option parser"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(name),
                                    prefix=prefix)
    except configparser.ParsingError as err:
        gbp.log.err(err)
        return None

    tag_group = GbpOptionGroup(parser, "tag options",
                               "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "branch options",
                                  "branch layout options")
    cmd_group = GbpOptionGroup(
        parser, "external command options",
        "how and when to invoke external commands and hooks")
    orig_group = GbpOptionGroup(
        parser, "orig tarball options",
        "options related to the creation of the orig tarball")
    export_group = GbpOptionGroup(parser, "export build-tree options",
                                  "alternative build tree related options")
    parser.add_option_group(tag_group)
    parser.add_option_group(orig_group)
    parser.add_option_group(branch_group)
    parser.add_option_group(cmd_group)
    parser.add_option_group(export_group)

    parser.add_boolean_config_file_option(option_name="ignore-new",
                                          dest="ignore_new")
    parser.add_option("--git-verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_config_file_option(option_name="notify",
                                  dest="notify",
                                  type='tristate')
    parser.add_config_file_option(option_name="vendor",
                                  action="store",
                                  dest="vendor")
    parser.add_config_file_option(option_name="native",
                                  dest="native",
                                  type='tristate')
    tag_group.add_option("--git-tag",
                         action="store_true",
                         dest="tag",
                         default=False,
                         help="create a tag after a successful build")
    tag_group.add_option("--git-tag-only",
                         action="store_true",
                         dest="tag_only",
                         default=False,
                         help="don't build, only tag and run the posttag hook")
    tag_group.add_option("--git-retag",
                         action="store_true",
                         dest="retag",
                         default=False,
                         help="don't fail if the tag already exists")
    tag_group.add_boolean_config_file_option(option_name="sign-tags",
                                             dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid", dest="keyid")
    tag_group.add_config_file_option(option_name="packaging-tag",
                                     dest="packaging_tag")
    tag_group.add_config_file_option(option_name="packaging-tag-msg",
                                     dest="packaging_tag_msg")
    tag_group.add_config_file_option(option_name="upstream-tag",
                                     dest="upstream_tag")
    orig_group.add_config_file_option(option_name="upstream-tree",
                                      dest="upstream_tree")
    orig_group.add_boolean_config_file_option(option_name="pristine-tar",
                                              dest="pristine_tar")
    orig_group.add_boolean_config_file_option(
        option_name="pristine-tar-commit", dest="pristine_tar_commit")
    orig_group.add_config_file_option(
        option_name="force-create",
        dest="force_create",
        action="store_true",
        help="force creation of upstream source tarball")
    orig_group.add_config_file_option(
        option_name="no-create-orig",
        dest="no_create_orig",
        action="store_true",
        help="don't create upstream source tarball")
    orig_group.add_config_file_option(
        option_name="tarball-dir",
        dest="tarball_dir",
        type="path",
        help="location to look for external tarballs")
    orig_group.add_config_file_option(option_name="compression-level",
                                      dest="comp_level",
                                      help="Compression level, default is "
                                      "'%(compression-level)s'")
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_config_file_option(option_name="packaging-branch",
                                        dest="packaging_branch")
    branch_group.add_boolean_config_file_option(option_name="ignore-branch",
                                                dest="ignore_branch")
    branch_group.add_boolean_config_file_option(option_name="submodules",
                                                dest="with_submodules")
    cmd_group.add_config_file_option(
        option_name="builder",
        dest="builder",
        help="command to build the package, default is "
        "'%(builder)s'")
    cmd_group.add_config_file_option(
        option_name="cleaner",
        dest="cleaner",
        help="command to clean the working copy, default is "
        "'%(cleaner)s'")
    cmd_group.add_config_file_option(
        option_name="prebuild",
        dest="prebuild",
        help="command to run before a build, default is "
        "'%(prebuild)s'")
    cmd_group.add_config_file_option(
        option_name="postexport",
        dest="postexport",
        help="command to run after exporting the source tree, "
        "default is '%(postexport)s'")
    cmd_group.add_config_file_option(
        option_name="postbuild",
        dest="postbuild",
        help="hook run after a successful build, default is "
        "'%(postbuild)s'")
    cmd_group.add_config_file_option(
        option_name="posttag",
        dest="posttag",
        help="hook run after a successful tag operation, default "
        "is '%(posttag)s'")
    cmd_group.add_boolean_config_file_option(option_name="mock",
                                             dest="use_mock")
    cmd_group.add_config_file_option(option_name="dist", dest="mock_dist")
    cmd_group.add_config_file_option(option_name="arch", dest="mock_arch")
    cmd_group.add_config_file_option(option_name="mock-root", dest="mock_root")
    cmd_group.add_config_file_option(option_name="mock-options",
                                     dest="mock_options")
    cmd_group.add_boolean_config_file_option(option_name="hooks", dest="hooks")
    export_group.add_option("--git-no-build",
                            action="store_true",
                            dest="no_build",
                            help="Don't run builder or the associated hooks")
    export_group.add_config_file_option(
        option_name="export-dir",
        dest="export_dir",
        type="path",
        help="Build topdir, also export the sources under "
        "EXPORT_DIR, default is '%(export-dir)s'")
    export_group.add_config_file_option(option_name="export-specdir",
                                        dest="export_specdir",
                                        type="path")
    export_group.add_config_file_option(option_name="export-sourcedir",
                                        dest="export_sourcedir",
                                        type="path")
    export_group.add_config_file_option(
        "export",
        dest="export",
        metavar="TREEISH",
        help="export treeish object TREEISH, default is "
        "'%(export)s'")
    export_group.add_config_file_option(option_name="packaging-dir",
                                        dest="packaging_dir")
    export_group.add_config_file_option(option_name="spec-file",
                                        dest="spec_file")
    return parser
コード例 #27
0
        gbp.log.info("Bare repository: setting %s option '--no-pristine-tar'")
        options.pristine_tar = False


def build_parser(name):
    """Create command line parser"""
    try:
        parser = GbpOptionParserBB(command=os.path.basename(name),
                                   prefix='',
                                   usage='%prog [options] /path/to/package'
                                          '.src.rpm')
    except ConfigParser.ParsingError, err:
        gbp.log.err(err)
        return None

    import_group = GbpOptionGroup(parser, "import options",
                      "pristine-tar and filtering")
    tag_group = GbpOptionGroup(parser, "tag options",
                      "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "version and branch naming options",
                      "version number and branch layout options")

    for group in [import_group, branch_group, tag_group ]:
        parser.add_option_group(group)

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
                      default=False, help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color",
                      type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
コード例 #28
0
                      ["", " '--no-merge'"][options.merge]))
        options.pristine_tar = False
        options.merge = False


def parse_args(argv):
    try:
        parser = GbpOptionParserRpm(
            command=os.path.basename(argv[0]),
            prefix='',
            usage='%prog [options] /path/to/upstream-version.tar.gz')
    except ConfigParser.ParsingError, err:
        gbp.log.err(err)
        return None, None

    import_group = GbpOptionGroup(parser, "import options",
                                  "pristine-tar and filtering")
    tag_group = GbpOptionGroup(parser, "tag options",
                               "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "version and branch naming options",
                                  "version number and branch layout options")
    cmd_group = GbpOptionGroup(
        parser, "external command options",
        "how and when to invoke external commands and hooks")

    for group in [import_group, branch_group, tag_group, cmd_group]:
        parser.add_option_group(group)

    branch_group.add_option("-u",
                            "--upstream-version",
                            dest="version",
                            help="Upstream Version")
コード例 #29
0
    # Checkout packaging branch
    repo.set_branch(branch)


def parse_args(argv):
    """Parse commandline arguments"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(argv[0]),
                                    prefix='',
                                    usage='%prog [options] /path/to/package'
                                          '.src.rpm')
    except ConfigParser.ParsingError, err:
        gbp.log.err(err)
        return None, None

    import_group = GbpOptionGroup(parser, "import options",
                      "pristine-tar and filtering")
    tag_group = GbpOptionGroup(parser, "tag options",
                      "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "version and branch naming options",
                      "version number and branch layout options")

    for group in [import_group, branch_group, tag_group ]:
        parser.add_option_group(group)

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
                      default=False, help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color",
                      type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
コード例 #30
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(
            command=os.path.basename(name),
            prefix='',
            usage='%prog [options] /path/to/package.dsc [target]')
    except GbpError as err:
        gbp.log.err(err)
        return None

    import_group = GbpOptionGroup(parser, "import options",
                                  "pristine-tar and filtering")
    tag_group = GbpOptionGroup(parser, "tag options",
                               "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "version and branch naming options",
                                  "version number and branch layout options")
    for group in [import_group, branch_group, tag_group]:
        parser.add_option_group(group)

    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    branch_group.add_config_file_option(option_name="debian-branch",
                                        dest="debian_branch")
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_boolean_config_file_option(
        option_name="create-missing-branches", dest="create_missing_branches")

    tag_group.add_boolean_config_file_option(option_name="sign-tags",
                                             dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid", dest="keyid")
    tag_group.add_config_file_option(option_name="debian-tag",
                                     dest="debian_tag")
    tag_group.add_config_file_option(option_name="upstream-tag",
                                     dest="upstream_tag")
    tag_group.add_option(
        "--skip-debian-tag",
        dest="skip_debian_tag",
        action="store_true",
        default=False,
        help="Don't add a tag after importing the Debian patch")

    import_group.add_config_file_option(option_name="filter",
                                        dest="filters",
                                        action="append")
    import_group.add_boolean_config_file_option(option_name="pristine-tar",
                                                dest="pristine_tar")
    import_group.add_option("--allow-same-version",
                            action="store_true",
                            dest="allow_same_version",
                            default=False,
                            help="allow import of already imported version")
    import_group.add_boolean_config_file_option(
        option_name="author-is-committer", dest="author_committer")
    import_group.add_boolean_config_file_option(
        option_name="author-date-is-committer-date",
        dest="author_committer_date")
    import_group.add_boolean_config_file_option(
        option_name="allow-unauthenticated", dest="allow_unauthenticated")

    parser.add_config_file_option(option_name="repo-user",
                                  dest="repo_user",
                                  choices=['DEBIAN', 'GIT'])
    parser.add_config_file_option(option_name="repo-email",
                                  dest="repo_email",
                                  choices=['DEBIAN', 'GIT'])
    parser.add_option("--download",
                      dest='download',
                      action="store_true",
                      default=False,
                      help="Ignored. Accepted for compatibility.")
    return parser
コード例 #31
0
ファイル: dch.py プロジェクト: hemmop/git-buildpackage
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name), usage="%prog [options] paths")
    except ConfigParser.ParsingError as err:
        gbp.log.err(err)
        return None

    range_group = GbpOptionGroup(parser, "commit range options", "which commits to add to the changelog")
    version_group = GbpOptionGroup(parser, "release & version number options", "what version number and release to use")
    commit_group = GbpOptionGroup(parser, "commit message formatting", "howto format the changelog entries")
    naming_group = GbpOptionGroup(parser, "branch and tag naming", "branch names and tag formats")
    custom_group = GbpOptionGroup(parser, "customization", "options for customization")
    parser.add_option_group(range_group)
    parser.add_option_group(version_group)
    parser.add_option_group(commit_group)
    parser.add_option_group(naming_group)
    parser.add_option_group(custom_group)

    parser.add_boolean_config_file_option(option_name="ignore-branch", dest="ignore_branch")
    naming_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    naming_group.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
    naming_group.add_config_file_option(option_name="debian-tag", dest="debian_tag")
    naming_group.add_config_file_option(
        option_name="snapshot-number",
        dest="snapshot_number",
        help="expression to determine the next snapshot number, default is '%(snapshot-number)s'",
    )
    parser.add_config_file_option(
        option_name="git-log", dest="git_log", help="options to pass to git-log, default is '%(git-log)s'"
    )
    parser.add_option(
        "-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose command execution"
    )
    parser.add_config_file_option(option_name="color", dest="color", type="tristate")
    parser.add_config_file_option(option_name="color-scheme", dest="color_scheme")
    range_group.add_option("-s", "--since", dest="since", help="commit to start from (e.g. HEAD^^^, debian/0.4.3)")
    range_group.add_option(
        "-a",
        "--auto",
        action="store_true",
        dest="auto",
        default=False,
        help="autocomplete changelog from last snapshot or tag",
    )
    version_group.add_option(
        "-R", "--release", action="store_true", dest="release", default=False, help="mark as release"
    )
    version_group.add_option(
        "-S", "--snapshot", action="store_true", dest="snapshot", default=False, help="mark as snapshot build"
    )
    version_group.add_option("-D", "--distribution", dest="distribution", help="Set distribution")
    version_group.add_option(
        "--force-distribution",
        action="store_true",
        dest="force_distribution",
        default=False,
        help="Force the provided distribution to be used, even if it doesn't match the list of known distributions",
    )
    version_group.add_option(
        "-N", "--new-version", dest="new_version", help="use this as base for the new version number"
    )
    version_group.add_option("-U", "--urgency", dest="urgency", help="Set urgency level")
    version_group.add_option(
        "--bpo",
        dest="bpo",
        action="store_true",
        default=False,
        help="Increment the Debian release number for an upload to backports, and add a backport upload changelog comment.",
    )
    version_group.add_option(
        "--nmu",
        dest="nmu",
        action="store_true",
        default=False,
        help="Increment the Debian release number for a non-maintainer upload",
    )
    version_group.add_option(
        "--qa",
        dest="qa",
        action="store_true",
        default=False,
        help="Increment the Debian release number for a Debian QA Team upload, and add a QA upload changelog comment.",
    )
    version_group.add_option(
        "--team",
        dest="team",
        action="store_true",
        default=False,
        help="Increment the Debian release number for a Debian Team upload, and add a Team upload changelog comment.",
    )
    version_group.add_option(
        "--security",
        dest="security",
        action="store_true",
        default=False,
        help="Increment the Debian release number for a security upload and add a security upload changelog comment.",
    )
    version_group.add_boolean_config_file_option(option_name="git-author", dest="git_author")
    commit_group.add_boolean_config_file_option(option_name="meta", dest="meta")
    commit_group.add_config_file_option(
        option_name="meta-closes",
        dest="meta_closes",
        help="Meta tags for the bts close commands, default is '%(meta-closes)s'",
    )
    commit_group.add_boolean_config_file_option(option_name="full", dest="full")
    commit_group.add_config_file_option(
        option_name="id-length",
        dest="idlen",
        help="include N digits of the commit id in the changelog entry, default is '%(id-length)s'",
        type="int",
        metavar="N",
    )
    commit_group.add_config_file_option(
        option_name="ignore-regex",
        dest="ignore_regex",
        help="Ignore commit lines matching regex, default is '%(ignore-regex)s'",
    )
    commit_group.add_boolean_config_file_option(option_name="multimaint", dest="multimaint")
    commit_group.add_boolean_config_file_option(option_name="multimaint-merge", dest="multimaint_merge")
    commit_group.add_config_file_option(option_name="spawn-editor", dest="spawn_editor")
    parser.add_config_file_option(option_name="commit-msg", 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)

    return parser
コード例 #32
0
def build_parser(name, sections=[]):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='',
                                       usage='%prog [options] - '
                                       'create a remote repository',
                                       sections=sections)
    except ConfigParser.ParsingError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser,
                                  "branch options",
                                  "branch layout and tracking options")
    branch_group.add_config_file_option(option_name="remote-url-pattern",
                                        dest="remote_url")
    parser.add_option_group(branch_group)
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch",
                                        dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar",
                                                dest="pristine_tar")
    branch_group.add_boolean_config_file_option(option_name="track",
                                                dest='track')
    parser.add_option("-v", "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_option("--remote-name",
                      dest="name",
                      default="origin",
                      help="The name of the remote, default is 'origin'")
    parser.add_config_file_option(option_name="template-dir",
                                  dest="template_dir")
    parser.add_config_file_option(option_name="remote-config",
                                  dest="remote_config")
    return parser
コード例 #33
0
def build_parser(name):
    try:
        parser = GbpOptionParser(command=os.path.basename(name), prefix='',
                                 usage='%prog [options] repository - clone a remote repository')
    except configparser.ParsingError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser, "branch options", "branch tracking and layout options")
    parser.add_option_group(branch_group)

    branch_group.add_option("--all", action="store_true", dest="all", default=False,
                            help="track all branches, not only debian and upstream")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    branch_group.add_option("--depth", action="store", dest="depth", default=0,
                            help="git history depth (for creating shallow clones)")
    branch_group.add_option("--reference", action="store", dest="reference", default=None,
                            help="git reference repository (use local copies where possible)")

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    return parser
コード例 #34
0
ファイル: clone.py プロジェクト: dchenbecker/git-buildpackage
def build_parser(name):
    try:
        parser = GbpOptionParser(command=os.path.basename(name), prefix='',
                                 usage='%prog [options] repository - clone a remote repository')
    except ConfigParser.ParsingError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser, "branch options", "branch tracking and layout options")
    parser.add_option_group(branch_group)

    branch_group.add_option("--all", action="store_true", dest="all", default=False,
                            help="track all branches, not only debian and upstream")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    branch_group.add_option("--depth", action="store", dest="depth", default=0,
                            help="git history depth (for creating shallow clones)")

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    return parser
コード例 #35
0
    # Re-parse recipe from final location
    full_path = os.path.abspath(os.path.join(dump_dir,
                                             os.path.basename(bb_path)))
    return BBFile(full_path, cfg_data)


def build_parser(name, prefix=None, git_treeish=None):
    """Create command line parser"""
    try:
        parser = GbpOptionParserBB(command=os.path.basename(name),
                                   prefix=prefix, git_treeish=git_treeish)
    except ConfigParser.ParsingError, err:
        gbp.log.err(err)
        return None

    tag_group = GbpOptionGroup(parser, "tag options",
                    "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "branch options",
                    "branch layout options")
    cmd_group = GbpOptionGroup(parser, "external command options",
                    "how and when to invoke external commands and hooks")
    orig_group = GbpOptionGroup(parser, "orig tarball options",
                    "options related to the creation of the orig tarball")
    export_group = GbpOptionGroup(parser, "export build-tree options",
                    "alternative build tree related options")
    parser.add_option_group(tag_group)
    parser.add_option_group(orig_group)
    parser.add_option_group(branch_group)
    parser.add_option_group(cmd_group)
    parser.add_option_group(export_group)

    parser.add_boolean_config_file_option(option_name = "ignore-untracked",
コード例 #36
0
def parse_args(argv, prefix):
    args = [ arg for arg in argv[1:] if arg.find('--%s' % prefix) == 0 ]
    dpkg_args = [ arg for arg in argv[1:] if arg.find('--%s' % prefix) == -1 ]

    # We handle these although they don't have a --git- prefix
    for arg in [ "--help", "-h", "--version" ]:
        if arg in dpkg_args:
            args.append(arg)

    try:
        parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix=prefix)
    except ConfigParser.ParsingError as err:
        gbp.log.err(err)
        return None, None, None

    tag_group = GbpOptionGroup(parser, "tag options", "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "branch options", "branch layout options")
    cmd_group = GbpOptionGroup(parser, "external command options", "how and when to invoke external commands and hooks")
    orig_group = GbpOptionGroup(parser, "orig tarball options", "options related to the creation of the orig tarball")
    export_group = GbpOptionGroup(parser, "export build-tree options", "alternative build tree related options")
    parser.add_option_group(tag_group)
    parser.add_option_group(orig_group)
    parser.add_option_group(branch_group)
    parser.add_option_group(cmd_group)
    parser.add_option_group(export_group)

    parser.add_boolean_config_file_option(option_name = "ignore-new", dest="ignore_new")
    parser.add_option("--git-verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="notify", dest="notify", type='tristate')
    tag_group.add_option("--git-tag", action="store_true", dest="tag", default=False,
                      help="create a tag after a successful build")
    tag_group.add_option("--git-tag-only", action="store_true", dest="tag_only", default=False,
                      help="don't build, only tag and run the posttag hook")
    tag_group.add_option("--git-retag", action="store_true", dest="retag", default=False,
                      help="don't fail if the tag already exists")
    tag_group.add_boolean_config_file_option(option_name="sign-tags", dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid", dest="keyid")
    tag_group.add_config_file_option(option_name="debian-tag", dest="debian_tag")
    tag_group.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
    orig_group.add_config_file_option(option_name="upstream-tree", dest="upstream_tree")
    orig_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    orig_group.add_boolean_config_file_option(option_name="pristine-tar-commit",
                                              dest="pristine_tar_commit")
    orig_group.add_config_file_option(option_name="force-create", dest="force_create",
                      help="force creation of orig tarball", action="store_true")
    orig_group.add_config_file_option(option_name="no-create-orig", dest="no_create_orig",
                      help="don't create orig tarball", action="store_true")
    orig_group.add_config_file_option(option_name="tarball-dir", dest="tarball_dir", type="path",
                      help="location to look for external tarballs")
    orig_group.add_config_file_option(option_name="compression", dest="comp_type",
                      help="Compression type, default is '%(compression)s'")
    orig_group.add_config_file_option(option_name="compression-level", dest="comp_level",
                      help="Compression level, default is '%(compression-level)s'")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name = "ignore-branch", dest="ignore_branch")
    branch_group.add_boolean_config_file_option(option_name = "submodules", dest="with_submodules")
    cmd_group.add_config_file_option(option_name="builder", dest="builder",
                      help="command to build the Debian package, default is '%(builder)s'")
    cmd_group.add_config_file_option(option_name="cleaner", dest="cleaner",
                      help="command to clean the working copy, default is '%(cleaner)s'")
    cmd_group.add_config_file_option(option_name="prebuild", dest="prebuild",
                      help="command to run before a build, default is '%(prebuild)s'")
    cmd_group.add_config_file_option(option_name="postexport", dest="postexport",
                      help="command to run after exporting the source tree, default is '%(postexport)s'")
    cmd_group.add_config_file_option(option_name="postbuild", dest="postbuild",
                      help="hook run after a successful build, default is '%(postbuild)s'")
    cmd_group.add_config_file_option(option_name="posttag", dest="posttag",
                      help="hook run after a successful tag operation, default is '%(posttag)s'")
    cmd_group.add_boolean_config_file_option(option_name="pbuilder", dest="use_pbuilder")
    cmd_group.add_boolean_config_file_option(option_name="qemubuilder", dest="use_qemubuilder")
    cmd_group.add_config_file_option(option_name="dist", dest="pbuilder_dist")
    cmd_group.add_config_file_option(option_name="arch", dest="pbuilder_arch")
    cmd_group.add_boolean_config_file_option(option_name = "pbuilder-autoconf", dest="pbuilder_autoconf")
    cmd_group.add_config_file_option(option_name="pbuilder-options", dest="pbuilder_options")
    export_group.add_config_file_option(option_name="export-dir", dest="export_dir", type="path",
                      help="before building the package export the source into EXPORT_DIR, default is '%(export-dir)s'")
    export_group.add_config_file_option("export", dest="export",
                      help="export treeish object TREEISH, default is '%(export)s'", metavar="TREEISH")
    export_group.add_option("--git-dont-purge", action="store_false", dest="purge", default=True,
                      help="retain exported package build directory")
    export_group.add_boolean_config_file_option(option_name="overlay", dest="overlay")
    options, args = parser.parse_args(args)

    gbp.log.setup(options.color, options.verbose)
    if options.retag:
        if not options.tag and not options.tag_only:
            gbp.log.err("'--%sretag' needs either '--%stag' or '--%stag-only'" % (prefix, prefix, prefix))
            return None, None, None

    if options.overlay and not options.export_dir:
        gbp.log.err("Overlay must be used with --git-export-dir")
        return None, None, None

    return options, args, dpkg_args
コード例 #37
0
ファイル: clone.py プロジェクト: pexip/os-git-buildpackage
def parse_args (argv):
    parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='',
                             usage='%prog [options] repository - clone a remote repository')
    branch_group = GbpOptionGroup(parser, "branch options", "branch tracking and layout options")
    parser.add_option_group(branch_group)

    branch_group.add_option("--all", action="store_true", dest="all", default=False,
                            help="track all branches, not only debian and upstream")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    branch_group.add_option("--depth", action="store", dest="depth", default=0,
                            help="git history depth (for creating shallow clones)")

    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")

    (options, args) = parser.parse_args(argv)
    gbp.log.setup(options.color, options.verbose, options.color_scheme)

    return (options, args)
コード例 #38
0
def build_parser(name):
    """Construct command line parser"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(name),
                                    prefix='',
                                    usage='%prog [options] /path/to/package'
                                    '.src.rpm')
    except configparser.ParsingError as err:
        gbp.log.err(err)
        return None

    import_group = GbpOptionGroup(parser, "import options",
                                  "pristine-tar and filtering")
    tag_group = GbpOptionGroup(parser, "tag options",
                               "options related to git tag creation")
    branch_group = GbpOptionGroup(parser, "version and branch naming options",
                                  "version number and branch layout options")

    for group in [import_group, branch_group, tag_group]:
        parser.add_option_group(group)

    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
    parser.add_config_file_option(option_name="vendor",
                                  action="store",
                                  dest="vendor")
    parser.add_option("--download",
                      action="store_true",
                      dest="download",
                      default=False,
                      help="download source package")
    branch_group.add_config_file_option(option_name="packaging-branch",
                                        dest="packaging_branch")
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_boolean_config_file_option(
        option_name="create-missing-branches", dest="create_missing_branches")
    branch_group.add_option(
        "--orphan-packaging",
        action="store_true",
        dest="orphan_packaging",
        default=False,
        help="The packaging branch doesn't base on upstream")
    branch_group.add_option("--native",
                            action="store_true",
                            dest="native",
                            default=False,
                            help="This is a dist native package, no separate "
                            "upstream branch")

    tag_group.add_boolean_config_file_option(option_name="sign-tags",
                                             dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid", dest="keyid")
    tag_group.add_config_file_option(option_name="packaging-tag",
                                     dest="packaging_tag")
    tag_group.add_config_file_option(option_name="upstream-tag",
                                     dest="upstream_tag")

    import_group.add_config_file_option(option_name="filter",
                                        dest="filters",
                                        action="append")
    import_group.add_boolean_config_file_option(option_name="pristine-tar",
                                                dest="pristine_tar")
    import_group.add_option("--allow-same-version",
                            action="store_true",
                            dest="allow_same_version",
                            default=False,
                            help="allow to import already imported version")
    import_group.add_boolean_config_file_option(
        option_name="author-is-committer", dest="author_is_committer")
    import_group.add_config_file_option(option_name="packaging-dir",
                                        dest="packaging_dir")
    return parser
コード例 #39
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='')
    except GbpError as err:
        gbp.log.err(err)
        return None

    tag_group = GbpOptionGroup(parser,
                               "tag options",
                               "options related to git tag creation")
    orig_group = GbpOptionGroup(parser,
                                "orig tarball options",
                                "options related to the creation of the orig tarball")
    branch_group = GbpOptionGroup(parser,
                                  "branch options",
                                  "branch layout options")
    for group in [tag_group, orig_group, branch_group]:
        parser.add_option_group(group)

    parser.add_option("--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color", dest="color", type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    tag_group.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
    orig_group.add_config_file_option(option_name="upstream-tree", dest="upstream_tree")
    orig_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    orig_group.add_config_file_option(option_name="force-create", dest="force_create",
                                      help="force creation of orig tarball", action="store_true")
    orig_group.add_config_file_option(option_name="tarball-dir", dest="tarball_dir", type="path",
                                      help="location to look for external tarballs")
    orig_group.add_config_file_option(option_name="compression", dest="comp_type",
                                      help="Compression type, default is '%(compression)s'")
    orig_group.add_config_file_option(option_name="compression-level", dest="comp_level",
                                      help="Compression level, default is '%(compression-level)s'")
    orig_group.add_config_file_option("component", action="append", metavar='COMPONENT',
                                      dest="components")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_boolean_config_file_option(option_name="submodules", dest="with_submodules")
    return parser
コード例 #40
0
ファイル: pull.py プロジェクト: lamby/git-buildpackage
def build_parser(name):
    try:
        parser = GbpOptionParser(
            command=os.path.basename(name),
            prefix='',
            usage=
            '%prog [options] [repo] - safely update a repository from remote')
    except GbpError as err:
        gbp.log.err(err)
        return None

    branch_group = GbpOptionGroup(parser, "branch options",
                                  "branch update and layout options")
    parser.add_option_group(branch_group)
    branch_group.add_boolean_config_file_option(option_name="ignore-branch",
                                                dest="ignore_branch")
    branch_group.add_option(
        "--force",
        action="store_true",
        dest="force",
        default=False,
        help="force a branch update even if it can't be fast forwarded")
    branch_group.add_option(
        "--redo-pq",
        action="store_true",
        dest="redo_pq",
        default=False,
        help=
        "redo the patch queue branch after a pull. Warning: this drops the old patch-queue branch"
    )
    branch_group.add_config_file_option(option_name="upstream-branch",
                                        dest="upstream_branch")
    branch_group.add_config_file_option(option_name="debian-branch",
                                        dest="debian_branch")
    branch_group.add_boolean_config_file_option(option_name="pristine-tar",
                                                dest="pristine_tar")
    branch_group.add_option(
        "--depth",
        action="store",
        dest="depth",
        default=0,
        help="git history depth (for deepening shallow clones)")
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    return parser
コード例 #41
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(
            command=os.path.basename(name),
            prefix="",
            usage="%prog [options] /path/to/upstream-version.tar.gz | --uscan",
        )
    except configparser.ParsingError as err:
        gbp.log.err(err)
        return None

    import_group = GbpOptionGroup(parser, "import options", "pristine-tar and filtering")
    tag_group = GbpOptionGroup(parser, "tag options", "options related to git tag creation")
    branch_group = GbpOptionGroup(
        parser, "version and branch naming options", "version number and branch layout options"
    )
    cmd_group = GbpOptionGroup(parser, "external command options", "how and when to invoke external commands and hooks")

    for group in [import_group, branch_group, tag_group, cmd_group]:
        parser.add_option_group(group)

    branch_group.add_option("-u", "--upstream-version", dest="version", help="Upstream Version")
    branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
    branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
    branch_group.add_config_file_option(
        option_name="upstream-vcs-tag", dest="vcs_tag", help="Upstream VCS tag add to the merge commit"
    )
    branch_group.add_boolean_config_file_option(option_name="merge", dest="merge")
    branch_group.add_config_file_option(option_name="merge-mode", dest="merge_mode")

    tag_group.add_boolean_config_file_option(option_name="sign-tags", dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid", dest="keyid")
    tag_group.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
    import_group.add_config_file_option(option_name="filter", dest="filters", action="append")
    import_group.add_boolean_config_file_option(option_name="pristine-tar", dest="pristine_tar")
    import_group.add_boolean_config_file_option(option_name="filter-pristine-tar", dest="filter_pristine_tar")
    import_group.add_config_file_option(option_name="import-msg", dest="import_msg")
    import_group.add_boolean_config_file_option(option_name="symlink-orig", dest="symlink_orig")
    cmd_group.add_config_file_option(option_name="postimport", dest="postimport")

    parser.add_boolean_config_file_option(option_name="interactive", dest="interactive")
    parser.add_option(
        "-v", "--verbose", action="store_true", dest="verbose", default=False, help="verbose command execution"
    )
    parser.add_config_file_option(option_name="color", dest="color", type="tristate")
    parser.add_config_file_option(option_name="color-scheme", dest="color_scheme")

    # Accepted for compatibility
    parser.add_option("--no-dch", dest="no_dch", action="store_true", default=False, help="deprecated - don't use.")
    parser.add_option(
        "--uscan", dest="uscan", action="store_true", default=False, help="use uscan(1) to download the new tarball."
    )
    parser.add_option(
        "--download", dest="download", action="store_true", default=False, help="Download from URL via http(s)."
    )
    return parser