From: Markus Lehtonen Date: Thu, 14 Jun 2012 16:34:09 +0000 (+0300) Subject: rpm: add --orig-prefix option X-Git-Tag: tizen/0.6.22-20150206~109 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f7861c586cdf41c50e8478047d7606650d10e693;p=tools%2Fgit-buildpackage.git rpm: add --orig-prefix option Adds a new option --orig-prefix that affects the prefix of the generated/imported orig tarballs. For git-buildpackage-rpm, it defines the prefix of tarballs generated by the tool, 'auto' (default) makes gbp to guess the prefix, as before. NOTE: this doesn't affect the tarballs checked out from pristine-tar (i.e. if --pristine-tar is defined) or tarballs that are already present (see --git-tarball-dir option). For git-import-orig, this new option affects the prefix of tarballs imported into pristine-tar branch. If set to 'auto' (default) gbp doesn't mangle the prefix. Other tools (e.g. git-import-srpm) are not affected. Signed-off-by: Markus Lehtonen --- diff --git a/gbp/config.py b/gbp/config.py index 6ae16e02..cbc33a59 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -613,6 +613,7 @@ class GbpOptionParserRpm(GbpOptionParser): 'patch-export-compress' : '0', 'merge' : 'False', 'pristine-tarball-name' : 'auto', + 'orig-prefix' : 'auto', }) help = dict(GbpOptionParser.help) @@ -652,6 +653,9 @@ class GbpOptionParserRpm(GbpOptionParser): 'pristine-tarball-name': "Filename to record to pristine-tar, set to 'auto' to not " "mangle the file name, default is '%(pristine-tarball-name)s'", + 'orig-prefix': + "Prefix (dir) to be used when generating/importing tarballs, " + "default is '%(orig-prefix)s'", }) # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py index 3fff4e95..5e71caa4 100755 --- a/gbp/scripts/buildpackage_rpm.py +++ b/gbp/scripts/buildpackage_rpm.py @@ -46,15 +46,16 @@ from gbp.pkg import (compressor_opts, compressor_aliases) from gbp.scripts.pq_rpm import update_patch_series -def git_archive(repo, spec, output_dir, treeish, comp_level, with_submodules): +def git_archive(repo, spec, output_dir, treeish, prefix, comp_level, with_submodules): "create a compressed orig tarball in output_dir using git_archive" comp_opts = '' if spec.orig_src['compression']: comp_opts = compressor_opts[spec.orig_src['compression']][0] output = os.path.join(output_dir, spec.orig_src['filename']) - prefix = spec.orig_src['prefix'] + # Remove extra slashes from prefix, will be added by git_archive_x funcs + prefix = prefix.strip('/') try: if repo.has_submodules() and with_submodules: repo.update_submodules() @@ -184,6 +185,7 @@ def git_archive_build_orig(repo, spec, output_dir, options): gbp.log.debug("Building upstream source archive with compression '%s -%s'" % (spec.orig_src['compression'], options.comp_level)) if not git_archive(repo, spec, output_dir, upstream_tree, + options.orig_prefix, options.comp_level, options.with_submodules): raise GbpError("Cannot create upstream tarball at '%s'" % output_dir) @@ -326,6 +328,7 @@ def parse_args(argv, prefix): 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'") + orig_group.add_config_file_option(option_name="orig-prefix", dest="orig_prefix") 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") @@ -482,6 +485,14 @@ def main(argv): raise GbpError, "Error exporting files: %s" % err spec.specdir = spec_dir + if options.orig_prefix != 'auto': + options.orig_prefix = options.orig_prefix % dict(spec.version, + version=RpmPkgPolicy.compose_full_version(spec.version), + name=spec.name, + vendor=options.vendor) + elif spec.orig_src: + options.orig_prefix = spec.orig_src['prefix'] + # Get/build the orig tarball if is_native(repo, options): if spec.orig_src: @@ -489,7 +500,7 @@ def main(argv): gbp.log.info("Creating (native) source archive %s from '%s'" % (spec.orig_src['filename'], tree)) if spec.orig_src['compression']: gbp.log.debug("Building source archive with compression '%s -%s'" % (spec.orig_src['compression'], options.comp_level)) - if not git_archive(repo, spec, source_dir, tree, + if not git_archive(repo, spec, source_dir, tree, options.orig_prefix, options.comp_level, options.with_submodules): raise GbpError, "Cannot create source tarball at '%s'" % export_dir # Non-native packages: create orig tarball from upstream diff --git a/gbp/scripts/import_orig_rpm.py b/gbp/scripts/import_orig_rpm.py index 3d204b2c..1653fa68 100755 --- a/gbp/scripts/import_orig_rpm.py +++ b/gbp/scripts/import_orig_rpm.py @@ -174,6 +174,8 @@ def parse_args(argv): dest="filter_pristine_tar") import_group.add_config_file_option(option_name="pristine-tarball-name", dest="pristine_tarball_name") + import_group.add_config_file_option(option_name="orig-prefix", + dest="orig_prefix") import_group.add_config_file_option(option_name="import-msg", dest="import_msg") cmd_group.add_config_file_option(option_name="postimport", dest="postimport") @@ -234,7 +236,7 @@ def main(argv): prepare_sources(source, sourcepackage, version, prepare_pristine, options.filters, options.filter_pristine_tar, - None, tmpdir) + options.orig_prefix, tmpdir) # Don't mess up our repo with git metadata from an upstream tarball if os.path.isdir(os.path.join(unpacked_orig, '.git/')):