return path
-def git_archive(repo, spec, output_dir, treeish, comp_level,
+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 = ''
output = os.path.join(output_dir, spec.orig_src['filename'])
+ # Remove extra slashes from prefix, will be added by git_archive_x funcs
+ prefix = prefix.strip('/')
try:
if repo.has_submodules(treeish) and with_submodules:
repo.update_submodules()
- git_archive_submodules(repo, treeish, output,
- spec.orig_src['prefix'],
+ git_archive_submodules(repo, treeish, output, prefix,
spec.orig_src['compression'],
comp_level, comp_opts,
spec.orig_src['archive_fmt'])
else:
- git_archive_single(repo, treeish, output, spec.orig_src['prefix'],
+ git_archive_single(repo, treeish, output, prefix,
spec.orig_src['compression'], comp_level,
comp_opts, spec.orig_src['archive_fmt'])
except (GitRepositoryError, CommandExecFailed):
"'%s -%s'" % (spec.orig_src['compression'],
options.comp_level))
if not git_archive(repo, spec, output_dir, upstream_tree,
- options.comp_level, options.with_submodules):
+ options.orig_prefix, options.comp_level,
+ options.with_submodules):
raise GbpError("Cannot create upstream tarball at '%s'" % \
output_dir)
return upstream_tree
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",
raise GbpError("Error exporting packaging files: %s" % err)
spec.specdir = os.path.abspath(spec_dir)
+ if options.orig_prefix != 'auto':
+ orig_prefix_fields = dict(spec.version,
+ version = spec.upstreamversion,
+ name=spec.name)
+ options.orig_prefix = format_str(options.orig_prefix,
+ orig_prefix_fields)
+ 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 and not options.no_create_orig:
(spec.orig_src['compression'],
options.comp_level))
if not git_archive(repo, spec, source_dir, tree,
- options.comp_level,
+ options.orig_prefix, options.comp_level,
options.with_submodules):
raise GbpError("Cannot create source tarball at '%s'" %
source_dir)
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")
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/')):