def build_parser(name, prefix=None, git_treeish=None):
    """Construct config/option parser"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(name),
                                    prefix=prefix)
    except configparser.ParsingError as err:
        gbp.log.err(err)
        return None

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

    parser.add_boolean_config_file_option(option_name="ignore-new",
                    dest="ignore_new")
    parser.add_option("--git-verbose", action="store_true", dest="verbose",
                    default=False, help="verbose command execution")
    parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
    parser.add_config_file_option(option_name="color", dest="color",
                    type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                    dest="color_scheme")
    parser.add_config_file_option(option_name="notify", dest="notify",
                    type='tristate')
    parser.add_config_file_option(option_name="vendor", action="store",
                    dest="vendor")
    tag_group.add_option("--git-tag", action="store_true", dest="tag",
                    default=False,
                    help="create a tag after a successful build")
    tag_group.add_option("--git-tag-only", action="store_true", dest="tag_only",
                    default=False,
                    help="don't build, only tag and run the posttag hook")
    tag_group.add_option("--git-retag", action="store_true", dest="retag",
                    default=False, help="don't fail if the tag already exists")
    tag_group.add_boolean_config_file_option(option_name="sign-tags",
                    dest="sign_tags")
    tag_group.add_config_file_option(option_name="keyid", dest="keyid")
    tag_group.add_config_file_option(option_name="packaging-tag",
                    dest="packaging_tag")
    tag_group.add_config_file_option(option_name="packaging-tag-msg",
                    dest="packaging_tag_msg")
    tag_group.add_config_file_option(option_name="upstream-tag",
                    dest="upstream_tag")
    orig_group.add_config_file_option(option_name="upstream-tree",
                    dest="upstream_tree")
    orig_group.add_boolean_config_file_option(option_name="pristine-tar",
                    dest="pristine_tar")
    orig_group.add_boolean_config_file_option(option_name="pristine-tar-commit",
                    dest="pristine_tar_commit")
    orig_group.add_config_file_option(option_name="force-create",
                    dest="force_create", action="store_true",
                    help="force creation of upstream source tarball")
    orig_group.add_config_file_option(option_name="no-create-orig",
                    dest="no_create_orig", action="store_true",
                    help="don't create upstream source tarball")
    orig_group.add_config_file_option(option_name="tarball-dir",
                    dest="tarball_dir", type="path",
                    help="location to look for external tarballs")
    orig_group.add_config_file_option(option_name="compression-level",
                    dest="comp_level",
                    help="Compression level, default is "
                         "'%(compression-level)s'")
    branch_group.add_config_file_option(option_name="upstream-branch",
                    dest="upstream_branch")
    branch_group.add_config_file_option(option_name="packaging-branch",
                    dest="packaging_branch")
    branch_group.add_boolean_config_file_option(option_name = "ignore-branch",
                    dest="ignore_branch")
    branch_group.add_boolean_config_file_option(option_name = "submodules",
                    dest="with_submodules")
    cmd_group.add_config_file_option(option_name="builder", dest="builder",
                    help="command to build the package, default is "
                         "'%(builder)s'")
    cmd_group.add_config_file_option(option_name="cleaner", dest="cleaner",
                    help="command to clean the working copy, default is "
                         "'%(cleaner)s'")
    cmd_group.add_config_file_option(option_name="prebuild", dest="prebuild",
                    help="command to run before a build, default is "
                         "'%(prebuild)s'")
    cmd_group.add_config_file_option(option_name="postexport",
                    dest="postexport",
                    help="command to run after exporting the source tree, "
                         "default is '%(postexport)s'")
    cmd_group.add_config_file_option(option_name="postbuild", dest="postbuild",
                    help="hook run after a successful build, default is "
                         "'%(postbuild)s'")
    cmd_group.add_config_file_option(option_name="posttag", dest="posttag",
                    help="hook run after a successful tag operation, default "
                         "is '%(posttag)s'")
    cmd_group.add_boolean_config_file_option(option_name="mock", dest="use_mock")
    cmd_group.add_config_file_option(option_name="dist", dest="mock_dist")
    cmd_group.add_config_file_option(option_name="arch", dest="mock_arch")
    cmd_group.add_config_file_option(option_name="mock-root", dest="mock_root")
    cmd_group.add_config_file_option(option_name="mock-options", dest="mock_options")
    cmd_group.add_boolean_config_file_option(option_name="hooks", dest="hooks")
    export_group.add_option("--git-no-build", action="store_true",
                    dest="no_build",
                    help="Don't run builder or the associated hooks")
    export_group.add_config_file_option(option_name="export-dir",
                    dest="export_dir", type="path",
                    help="Build topdir, also export the sources under "
                         "EXPORT_DIR, default is '%(export-dir)s'")
    export_group.add_config_file_option(option_name="export-specdir",
                    dest="export_specdir", type="path")
    export_group.add_config_file_option(option_name="export-sourcedir",
                    dest="export_sourcedir", type="path")
    export_group.add_config_file_option("export", dest="export",
                    metavar="TREEISH",
                    help="export treeish object TREEISH, default is "
                         "'%(export)s'")
    export_group.add_config_file_option(option_name="packaging-dir",
                    dest="packaging_dir")
    export_group.add_config_file_option(option_name="spec-file",
                    dest="spec_file")
    return parser
Esempio n. 2
0
def build_parser(name):
    """Construct command line parser"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(name),
                                    prefix='',
                                    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_option("-v",
                      "--verbose",
                      action="store_true",
                      dest="verbose",
                      default=False,
                      help="Verbose command execution")
    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="tmp-dir", dest="tmp_dir")
    parser.add_config_file_option(option_name="abbrev",
                                  dest="abbrev",
                                  type="int")
    parser.add_config_file_option(option_name="upstream-tag",
                                  dest="upstream_tag")
    parser.add_config_file_option(option_name="spec-file", dest="spec_file")
    parser.add_config_file_option(option_name="packaging-dir",
                                  dest="packaging_dir")
    return parser
Esempio n. 3
0
def build_parser(name):
    """Construct command line parser"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(name),
                                    prefix='',
                                    usage='%prog [options] /path/to/package'
                                    '.src.rpm')
    except configparser.ParsingError as err:
        gbp.log.err(err)
        return None

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

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

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

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

    import_group.add_config_file_option(option_name="filter",
                                        dest="filters",
                                        action="append")
    import_group.add_boolean_config_file_option(option_name="pristine-tar",
                                                dest="pristine_tar")
    import_group.add_option("--allow-same-version",
                            action="store_true",
                            dest="allow_same_version",
                            default=False,
                            help="allow to import already imported version")
    import_group.add_boolean_config_file_option(
        option_name="author-is-committer", dest="author_is_committer")
    import_group.add_config_file_option(option_name="packaging-dir",
                                        dest="packaging_dir")
    return parser
def build_parser(name, prefix=None, git_treeish=None):
    """Construct config/option parser"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(name),
                                    prefix=prefix)
    except configparser.ParsingError as err:
        gbp.log.err(err)
        return None

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

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

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

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

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

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

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

    parser.add_config_file_option(option_name="repo-user", dest="repo_user",
                                  choices=['DEBIAN', 'GIT'])
    parser.add_config_file_option(option_name="repo-email", dest="repo_email",
                                  choices=['DEBIAN', 'GIT'])
    return parser
Esempio n. 6
0
def build_parser(name):
    """Construct command line parser"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(name),
                                    prefix='', usage='%prog [options] paths')
    except GbpError as err:
        gbp.log.err(err)
        return None

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

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

    # Naming group options
    naming_grp.add_config_file_option(option_name="packaging-branch",
                                      dest="packaging_branch")
    naming_grp.add_config_file_option(option_name="packaging-tag",
                                      dest="packaging_tag")
    naming_grp.add_config_file_option(option_name="packaging-dir",
                                      dest="packaging_dir")
    naming_grp.add_config_file_option(option_name="changelog-file",
                                      dest="changelog_file")
    naming_grp.add_config_file_option(option_name="spec-file", dest="spec_file")
    # Range group options
    range_grp.add_option("-s", "--since", dest="since",
                         help="commit to start from (e.g. HEAD^^^, release/0.1.2)")
    # Formatting group options
    format_grp.add_option("--no-release", action="store_false", default=True,
                          dest="release",
                          help="no release, just update the last changelog section")
    format_grp.add_boolean_config_file_option(option_name="git-author",
                                              dest="git_author")
    format_grp.add_boolean_config_file_option(option_name="full", dest="full")
    format_grp.add_config_file_option(option_name="id-length", dest="idlen",
                                      help="include N digits of the commit id in the changelog "
                                      "entry, default is '%(id-length)s'",
                                      type="int", metavar="N")
    format_grp.add_config_file_option(option_name="ignore-regex",
                                      dest="ignore_regex",
                                      help="Ignore lines in commit message matching regex, "
                                      "default is '%(ignore-regex)s'")
    format_grp.add_config_file_option(option_name="changelog-revision",
                                      dest="changelog_revision")
    format_grp.add_config_file_option(option_name="spawn-editor",
                                      dest="spawn_editor")
    format_grp.add_config_file_option(option_name="editor-cmd",
                                      dest="editor_cmd")
    return parser
Esempio n. 7
0
def build_parser(name):
    """Construct command line parser"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(name),
                                    prefix='', usage=
"""%prog [options] action - maintain patches on a patch queue branch
tions:
export         Export the patch queue / devel branch associated to the
               current branch into a patch series in and update the spec file
import         Create a patch queue / devel branch from spec file
               and patches in current dir.
rebase         Switch to patch queue / devel branch associated to the current
               branch and rebase against upstream.
drop           Drop (delete) the patch queue /devel branch associated to
               the current branch.
apply          Apply a patch
switch         Switch to patch-queue branch and vice versa.""")

    except configparser.ParsingError as err:
        gbp.log.err('Invalid config file: %s' % 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("--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="tmp-dir", dest="tmp_dir")
    parser.add_config_file_option(option_name="upstream-tag",
            dest="upstream_tag")
    parser.add_config_file_option(option_name="spec-file", dest="spec_file")
    parser.add_config_file_option(option_name="packaging-dir",
            dest="packaging_dir")
    return parser
Esempio n. 8
0
def build_parser(name):
    """Construct command line parser"""
    try:
        parser = GbpOptionParserRpm(
            command=os.path.basename(name),
            prefix='',
            usage=
            """%prog [options] action - maintain patches on a patch queue branch
tions:
export         Export the patch queue / devel branch associated to the
               current branch into a patch series in and update the spec file
import         Create a patch queue / devel branch from spec file
               and patches in current dir.
rebase         Switch to patch queue / devel branch associated to the current
               branch and rebase against upstream.
drop           Drop (delete) the patch queue /devel branch associated to
               the current branch.
apply          Apply a patch
switch         Switch to patch-queue branch and vice versa.""")

    except configparser.ParsingError as err:
        gbp.log.err('Invalid config file: %s' % 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(
        "--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="tmp-dir", dest="tmp_dir")
    parser.add_config_file_option(option_name="upstream-tag",
                                  dest="upstream_tag")
    parser.add_config_file_option(option_name="spec-file", dest="spec_file")
    parser.add_config_file_option(option_name="packaging-dir",
                                  dest="packaging_dir")
    return parser
Esempio n. 9
0
def build_parser(name):
    """Construct command line parser"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(name),
                                    prefix='', 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_option("-v", "--verbose", action="store_true", dest="verbose",
                      default=False, help="Verbose command execution")
    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="tmp-dir", dest="tmp_dir")
    parser.add_config_file_option(option_name="abbrev", dest="abbrev", type="int")
    parser.add_config_file_option(option_name="upstream-tag",
                                  dest="upstream_tag")
    parser.add_config_file_option(option_name="spec-file", dest="spec_file")
    parser.add_config_file_option(option_name="packaging-dir",
                                  dest="packaging_dir")
    return parser
Esempio n. 10
0
def build_parser(name):
    """Construct command line parser"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(name),
                                    prefix='',
                                    usage='%prog [options] paths')
    except GbpError as err:
        gbp.log.err(err)
        return None

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

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

    # Naming group options
    naming_grp.add_config_file_option(option_name="packaging-branch",
                                      dest="packaging_branch")
    naming_grp.add_config_file_option(option_name="packaging-tag",
                                      dest="packaging_tag")
    naming_grp.add_config_file_option(option_name="packaging-dir",
                                      dest="packaging_dir")
    naming_grp.add_config_file_option(option_name="changelog-file",
                                      dest="changelog_file")
    naming_grp.add_config_file_option(option_name="spec-file",
                                      dest="spec_file")
    # Range group options
    range_grp.add_option(
        "-s",
        "--since",
        dest="since",
        help="commit to start from (e.g. HEAD^^^, release/0.1.2)")
    # Formatting group options
    format_grp.add_option(
        "--no-release",
        action="store_false",
        default=True,
        dest="release",
        help="no release, just update the last changelog section")
    format_grp.add_boolean_config_file_option(option_name="git-author",
                                              dest="git_author")
    format_grp.add_boolean_config_file_option(option_name="full", dest="full")
    format_grp.add_config_file_option(
        option_name="id-length",
        dest="idlen",
        help="include N digits of the commit id in the changelog "
        "entry, default is '%(id-length)s'",
        type="int",
        metavar="N")
    format_grp.add_config_file_option(
        option_name="ignore-regex",
        dest="ignore_regex",
        help="Ignore lines in commit message matching regex, "
        "default is '%(ignore-regex)s'")
    format_grp.add_config_file_option(option_name="changelog-revision",
                                      dest="changelog_revision")
    format_grp.add_config_file_option(option_name="spawn-editor",
                                      dest="spawn_editor")
    format_grp.add_config_file_option(option_name="editor-cmd",
                                      dest="editor_cmd")
    return parser
Esempio n. 11
0
def main(argv):
    """Main function for the gbp pq-rpm command"""
    retval = 0

    try:
        parser = GbpOptionParserRpm(command=os.path.basename(argv[0]),
                                    prefix='',
                                    usage=USAGE_STRING)
    except ConfigParser.ParsingError as err:
        gbp.log.err('Invalid config file: %s' % err)
        return 1

    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(
        "--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="vendor",
                                  action="store",
                                  dest="vendor")
    parser.add_config_file_option(option_name="color",
                                  dest="color",
                                  type='tristate')
    parser.add_config_file_option(option_name="color-scheme",
                                  dest="color_scheme")
    parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
    parser.add_config_file_option(option_name="upstream-tag",
                                  dest="upstream_tag")
    parser.add_config_file_option(option_name="spec-file", dest="spec_file")
    parser.add_config_file_option(option_name="packaging-dir",
                                  dest="packaging_dir")
    parser.add_option(
        "--new-packaging-dir",
        help="Packaging directory in the new packaging branch. Only "
        "relevant for the 'convert' action. If not defined, defaults "
        "to '--packaging-dir'")
    parser.add_config_file_option(
        option_name="packaging-branch",
        dest="packaging_branch",
        help="Branch the packaging is being maintained on. Only relevant "
        "if a invariable/single pq-branch is defined, in which case "
        "this is used as the 'base' branch. Default is "
        "'%(packaging-branch)s'")
    parser.add_config_file_option(option_name="pq-branch", dest="pq_branch")
    parser.add_config_file_option(option_name="import-files",
                                  dest="import_files",
                                  type="string",
                                  action="callback",
                                  callback=opt_split_cb)
    parser.add_option(
        "--retain-history",
        action="store_true",
        help="When doing convert, preserve as much of the git history as "
        "possible, i.e. create one commit per commit. Only "
        "relevant for the 'convert' action.")
    parser.add_option(
        "--export-rev",
        action="store",
        dest="export_rev",
        default="",
        help="Export patches from treeish object TREEISH instead of head "
        "of patch-queue branch",
        metavar="TREEISH")
    parser.add_config_file_option("patch-export-compress",
                                  dest="patch_export_compress")
    parser.add_config_file_option("patch-export-squash-until",
                                  dest="patch_export_squash_until")
    parser.add_config_file_option("patch-export-ignore-path",
                                  dest="patch_export_ignore_path")

    (options, args) = parser.parse_args(argv)
    gbp.log.setup(options.color, options.verbose, options.color_scheme)
    options.patch_export_compress = string_to_int(
        options.patch_export_compress)
    if options.new_packaging_dir is None:
        options.new_packaging_dir = options.packaging_dir

    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", "convert"]:
        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 = RpmGitRepository(os.path.curdir)
    except GitRepositoryError:
        gbp.log.err("%s is not a git repository" % (os.path.abspath('.')))
        return 1

    if os.path.abspath('.') != repo.path:
        gbp.log.warn("Switching to topdir before running commands")
        os.chdir(repo.path)

    try:
        # Create base temporary directory for this run
        options.tmp_dir = tempfile.mkdtemp(dir=options.tmp_dir,
                                           prefix='gbp-pq-rpm_')
        if action == "export":
            export_patches(repo, options)
        elif action == "import":
            import_spec_patches(repo, options)
        elif action == "drop":
            drop_pq_rpm(repo, options)
        elif action == "rebase":
            rebase_pq(repo, options)
        elif action == "apply":
            apply_single_patch(repo, patchfile, options)
        elif action == "switch":
            switch_pq(repo, options)
        elif action == "convert":
            convert_package(repo, options)
    except CommandExecFailed:
        retval = 1
    except GitRepositoryError as err:
        gbp.log.err("Git command failed: %s" % err)
        retval = 1
    except GbpError, err:
        if len(err.__str__()):
            gbp.log.err(err)
        retval = 1
Esempio n. 12
0
def parse_args(argv):
    """Parse command line and config file options"""
    try:
        parser = GbpOptionParserRpm(command=os.path.basename(argv[0]),
                                    prefix='',
                                    usage='%prog [options] paths')
    except ConfigParser.ParsingError as err:
        gbp.log.error('invalid config file: %s' % err)
        return None, None

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

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

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

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

    return options, args