diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2012-06-14 19:34:09 +0300 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2014-11-14 14:45:07 +0200 |
commit | f7861c586cdf41c50e8478047d7606650d10e693 (patch) | |
tree | 0c6500747e79be53f457d7853358339862c12072 | |
parent | 666e35fda776b811b2636692272f1507d46231f9 (diff) | |
download | git-buildpackage-f7861c586cdf41c50e8478047d7606650d10e693.tar.gz git-buildpackage-f7861c586cdf41c50e8478047d7606650d10e693.tar.bz2 git-buildpackage-f7861c586cdf41c50e8478047d7606650d10e693.zip |
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 <markus.lehtonen@linux.intel.com>
-rw-r--r-- | gbp/config.py | 4 | ||||
-rwxr-xr-x | gbp/scripts/buildpackage_rpm.py | 17 | ||||
-rwxr-xr-x | gbp/scripts/import_orig_rpm.py | 4 |
3 files changed, 21 insertions, 4 deletions
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/')): |