Esempio n. 1
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='',
                                       usage='%prog [options] /path/to/package.dsc')
    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_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")
    return parser
Esempio n. 2
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
Esempio n. 3
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name),
                                   usage="%prog [options] action - maintain patches on a patch queue branch\n"
        "Actions:\n"
        "  export         export the patch queue associated to the current branch\n"
        "                 into a quilt patch series in debian/patches/ and update the\n"
        "                 series file.\n"
        "  import         create a patch queue branch from quilt patches in debian/patches.\n"
        "  rebase         switch to patch queue branch associated to the current\n"
        "                 branch and rebase against current branch.\n"
        "  drop           drop (delete) the patch queue associated to the current branch.\n"
        "  apply          apply a patch\n"
        "  switch         switch to patch-queue branch and vice versa")
    except ConfigParser.ParsingError as err:
        gbp.log.err(err)
        return None

    parser.add_boolean_config_file_option(option_name="patch-numbers", dest="patch_numbers")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_option("--topic", dest="topic", help="in case of 'apply' topic (subdir) to put patch into")
    parser.add_config_file_option(option_name="time-machine", dest="time_machine", type="int")
    parser.add_boolean_config_file_option("drop", dest='drop')
    parser.add_boolean_config_file_option(option_name="commit", dest="commit")
    parser.add_option("--force", dest="force", action="store_true", default=False,
                      help="in case of import even import if the branch already exists")
    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="meta-closes", dest="meta_closes")
    return parser
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_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")

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

    return options, args
Esempio n. 5
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
def build_parser(name, sections=[]):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='',
                                       usage='%prog [options] - '
                                       'create a remote repository',
                                       sections=sections)
    except (GbpError, configparser.NoSectionError) 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')
    branch_group.add_boolean_config_file_option(option_name="bare",
                                                dest='bare')
    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
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name), prefix='',
                                       usage=usage_msg())
    except GbpError as err:
        gbp.log.err(err)
        return None

    parser.add_config_file_option(option_name="upstream-tag",
                                  dest="upstream_tag")
    parser.add_config_file_option("component", action="append", metavar='COMPONENT',
                                  dest="components")
    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
Esempio n. 8
0
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
Esempio n. 9
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
Esempio n. 10
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name),
                                       usage=usage_msg())
    except GbpError as err:
        gbp.log.err(err)
        return None

    parser.add_boolean_config_file_option(option_name="patch-numbers", dest="patch_numbers")
    parser.add_config_file_option(option_name="patch-num-format", dest="patch_num_format")
    parser.add_boolean_config_file_option(option_name="renumber", dest="renumber")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_option("--topic", dest="topic", help="in case of 'apply' topic (subdir) to put patch into")
    parser.add_config_file_option(option_name="time-machine", dest="time_machine", type="int")
    parser.add_boolean_config_file_option("drop", dest='drop')
    parser.add_boolean_config_file_option(option_name="commit", dest="commit")
    parser.add_config_file_option(option_name="abbrev", dest="abbrev", type="int")
    parser.add_option("--force", dest="force", action="store_true", default=False,
                      help="in case of import even import if the branch already exists")
    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="meta-closes", dest="meta_closes")
    parser.add_config_file_option(option_name="meta-closes-bugnum", dest="meta_closes_bugnum")
    parser.add_config_file_option(option_name="pq-from", dest="pq_from", choices=['DEBIAN', 'TAG'])
    parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
    return parser
Esempio n. 11
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name),
                                       usage='%prog [options]')
    except GbpError as err:
        gbp.log.err(err)
        return None

    parser.add_option("--retag", action="store_true", dest="retag", default=False,
                      help="don't fail if the tag already exists")
    parser.add_config_file_option(option_name="debian-branch",
                                  dest="debian_branch")
    parser.add_config_file_option(option_name="debian-tag",
                                  dest="debian_tag")
    parser.add_config_file_option(option_name="debian-tag-msg", dest="debian_tag_msg")
    parser.add_boolean_config_file_option(option_name="sign-tags", dest="sign_tags")
    parser.add_config_file_option(option_name="keyid", dest="keyid")
    parser.add_config_file_option(option_name="posttag", dest="posttag",
                                  help="hook run after a successful tag operation, "
                                  "default is '%(posttag)s'")
    parser.add_boolean_config_file_option(option_name="ignore-branch", dest="ignore_branch")
    parser.add_boolean_config_file_option(option_name="ignore-new", dest="ignore_new")
    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("--verbose", action="store_true", dest="verbose",
                      default=False, help="verbose command execution")
    return parser
Esempio n. 12
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(
        option_name="upstream-signatures",
        dest="upstream_signatures",
        help="use upstream signatures, default is auto",
        type='tristate')
    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="preexport",
        dest="preexport",
        help="hook to run before exporting the source tree, "
        "default is '%(preexport)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_boolean_config_file_option(option_name="overlay",
                                                dest="overlay")
    return parser
Esempio n. 13
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name),
                                       usage='%prog [options] paths')
    except GbpError 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="upstream-branch", dest="upstream_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_config_file_option("urgency", dest="urgency")
    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_config_file_option(option_name="meta-closes-bugnum", dest="meta_closes_bugnum")
    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")
    parser.add_config_file_option(option_name="dch-opt",
                                  dest="dch_opts", action="append",
                                  help="option to pass to dch verbatim, "
                                  "can be given multiple times",
                                  metavar="DCH_OPT")

    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)
    custom_group.add_config_file_option(option_name="postedit", dest="postedit",
                                        help="Hook to run after changes to the changelog file"
                                        "have been finalized default is '%(postedit)s'")
    return parser
Esempio n. 14
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name),
                                       usage='%prog [options]')
    except GbpError as err:
        gbp.log.err(err)
        return None

    parser.add_option("-d",
                      "--dry-run",
                      dest="dryrun",
                      default=False,
                      action="store_true",
                      help="dry run, don't push.")
    parser.add_config_file_option(option_name="upstream-branch",
                                  dest="upstream_branch")
    parser.add_config_file_option(option_name="upstream-tag",
                                  dest="upstream_tag")
    parser.add_config_file_option(option_name="debian-branch",
                                  dest="debian_branch")
    parser.add_config_file_option(option_name="debian-tag", dest="debian_tag")
    parser.add_boolean_config_file_option(option_name="pristine-tar",
                                          dest="pristine_tar")
    parser.add_boolean_config_file_option(option_name="ignore-branch",
                                          dest="ignore_branch")
    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("--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    return parser
Esempio n. 15
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(
            command=os.path.basename(name),
            prefix='',
            usage='%prog [options] -u<upstream-version>')
    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
Esempio n. 16
0
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
Esempio n. 17
0
def main(argv):
    retval = 0

    parser = GbpOptionParserDebian(command=os.path.basename(argv[0]), prefix='',
                                   usage="%prog [options] action - maintain patches on a patch queue branch\n"
        "Actions:\n"
        "  export         export the patch queue associated to the current branch\n"
        "                 into a quilt patch series in debian/patches/ and update the\n"
        "                 series file.\n"
        "  import         create a patch queue branch from quilt patches in debian/patches.\n"
        "  rebase         switch to patch queue branch associated to the current\n"
        "                 branch and rebase against current branch.\n"
        "  drop           drop (delete) the patch queue associated to the current branch.\n"
        "  apply          apply a patch\n"
        "  switch         switch to patch-queue branch and vice versa")
    parser.add_boolean_config_file_option(option_name="patch-numbers", dest="patch_numbers")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_option("--topic", dest="topic", help="in case of 'apply' topic (subdir) to put patch into")
    parser.add_config_file_option(option_name="time-machine", dest="time_machine", type="int")
    parser.add_option("--force", dest="force", action="store_true", default=False,
                      help="in case of import even import if the branch already exists")
    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)

    if len(args) < 2:
        gbp.log.err("No action given.")
        return 1
    else:
        action = args[1]

    if args[1] in ["export", "import", "rebase", "drop", "switch"]:
        pass
    elif args[1] in ["apply"]:
        if len(args) != 3:
            gbp.log.err("No patch name given.")
            return 1
        else:
            patchfile = args[2]
    else:
        gbp.log.err("Unknown action '%s'." % args[1])
        return 1

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

    try:
        current = repo.get_branch()
        if action == "export":
            export_patches(repo, current, options)
        elif action == "import":
            series = SERIES_FILE
            tries = options.time_machine if (options.time_machine > 0) else 1
            import_quilt_patches(repo, current, series, tries, options.force)
            current = repo.get_branch()
            gbp.log.info("Patches listed in '%s' imported on '%s'" %
                          (series, current))
        elif action == "drop":
            drop_pq(repo, current)
        elif action == "rebase":
            rebase_pq(repo, current)
        elif action == "apply":
            patch = Patch(patchfile)
            maintainer = get_maintainer_from_control(repo)
            apply_single_patch(repo, current, patch, maintainer, options.topic)
        elif action == "switch":
            switch_pq(repo, current)
    except CommandExecFailed:
        retval = 1
    except (GbpError, GitRepositoryError) as err:
        if len(err.__str__()):
            gbp.log.err(err)
        retval = 1

    return retval
Esempio n. 18
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
Esempio n. 19
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name),
                                       usage='%prog [options]')
    except GbpError as err:
        gbp.log.err(err)
        return None

    parser.add_option("-d", "--dry-run", dest="dryrun", default=False,
                      action="store_true", help="dry run, don't push.")
    parser.add_config_file_option(option_name="upstream-branch",
                                  dest="upstream_branch")
    parser.add_config_file_option(option_name="upstream-tag",
                                  dest="upstream_tag")
    parser.add_config_file_option(option_name="debian-branch",
                                  dest="debian_branch")
    parser.add_config_file_option(option_name="debian-tag",
                                  dest="debian_tag")
    parser.add_boolean_config_file_option(option_name="pristine-tar",
                                          dest="pristine_tar")
    parser.add_boolean_config_file_option(option_name="ignore-branch", dest="ignore_branch")
    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("--verbose", action="store_true", dest="verbose",
                      default=False, help="verbose command execution")
    return parser
Esempio n. 20
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name),
                                       usage='%prog [options]')
    except GbpError as err:
        gbp.log.err(err)
        return None

    parser.add_option("--retag",
                      action="store_true",
                      dest="retag",
                      default=False,
                      help="don't fail if the tag already exists")
    parser.add_config_file_option(option_name="debian-branch",
                                  dest="debian_branch")
    parser.add_config_file_option(option_name="debian-tag", dest="debian_tag")
    parser.add_config_file_option(option_name="debian-tag-msg",
                                  dest="debian_tag_msg")
    parser.add_boolean_config_file_option(option_name="sign-tags",
                                          dest="sign_tags")
    parser.add_config_file_option(option_name="keyid", dest="keyid")
    parser.add_config_file_option(
        option_name="posttag",
        dest="posttag",
        help="hook run after a successful tag operation, "
        "default is '%(posttag)s'")
    parser.add_boolean_config_file_option(option_name="ignore-branch",
                                          dest="ignore_branch")
    parser.add_boolean_config_file_option(option_name="ignore-new",
                                          dest="ignore_new")
    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("--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    return parser
Esempio n. 21
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",
                                  "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
Esempio n. 22
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",
                                  "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")
    import_group.add_config_file_option("component",
                                        action="append",
                                        metavar='COMPONENT',
                                        dest="components")
    cmd_group.add_config_file_option(option_name="postimport",
                                     dest="postimport")

    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
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
Esempio n. 24
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(command=os.path.basename(name),
                                       usage=usage_msg())
    except GbpError as err:
        gbp.log.err(err)
        return None

    parser.add_boolean_config_file_option(option_name="patch-numbers", dest="patch_numbers")
    parser.add_config_file_option(option_name="patch-num-format", dest="patch_num_format")
    parser.add_boolean_config_file_option(option_name="renumber", dest="renumber")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
                      help="verbose command execution")
    parser.add_option("--topic", dest="topic", help="in case of 'apply' topic (subdir) to put patch into")
    parser.add_config_file_option(option_name="time-machine", dest="time_machine", type="int")
    parser.add_boolean_config_file_option("drop", dest='drop')
    parser.add_boolean_config_file_option(option_name="commit", dest="commit")
    parser.add_option("--force", dest="force", action="store_true", default=False,
                      help="in case of import even import if the branch already exists")
    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="meta-closes", dest="meta_closes")
    parser.add_config_file_option(option_name="meta-closes-bugnum", dest="meta_closes_bugnum")
    parser.add_config_file_option(option_name="pq-from", dest="pq_from", choices=['DEBIAN', 'TAG'])
    parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
    return parser
Esempio n. 25
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
Esempio n. 26
0
def build_parser(name):
    try:
        parser = GbpOptionParserDebian(
            command=os.path.basename(name),
            usage=
            "%prog [options] action - maintain patches on a patch queue branch\n"
            "Actions:\n"
            "  export         export the patch queue associated to the current branch\n"
            "                 into a quilt patch series in debian/patches/ and update the\n"
            "                 series file.\n"
            "  import         create a patch queue branch from quilt patches in debian/patches.\n"
            "  rebase         switch to patch queue branch associated to the current\n"
            "                 branch and rebase against current branch.\n"
            "  drop           drop (delete) the patch queue associated to the current branch.\n"
            "  apply          apply a patch\n"
            "  switch         switch to patch-queue branch and vice versa")
    except configparser.ParsingError as err:
        gbp.log.err(err)
        return None

    parser.add_boolean_config_file_option(option_name="patch-numbers",
                                          dest="patch_numbers")
    parser.add_config_file_option(option_name="patch-num-format",
                                  dest="patch_num_format")
    parser.add_boolean_config_file_option(option_name="renumber",
                                          dest="renumber")
    parser.add_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="verbose command execution")
    parser.add_option(
        "--topic",
        dest="topic",
        help="in case of 'apply' topic (subdir) to put patch into")
    parser.add_config_file_option(option_name="time-machine",
                                  dest="time_machine",
                                  type="int")
    parser.add_boolean_config_file_option("drop", dest='drop')
    parser.add_boolean_config_file_option(option_name="commit", dest="commit")
    parser.add_option(
        "--force",
        dest="force",
        action="store_true",
        default=False,
        help="in case of import even import if the branch already exists")
    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="meta-closes",
                                  dest="meta_closes")
    parser.add_config_file_option(option_name="meta-closes-bugnum",
                                  dest="meta_closes_bugnum")
    return parser