aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/scripts/import_orig.py
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2020-03-05 16:14:23 +0100
committerGuido Günther <agx@sigxcpu.org>2020-08-25 18:19:45 +0200
commit297c5ff32bcd6e90bc2c63f497528c8fb10c1d43 (patch)
tree90d0547f54c8de0ca3e10adfd30474b5de6f9528 /gbp/scripts/import_orig.py
parent9fc3f1b3edc9def944854206ebcf7dd51fd05185 (diff)
import-orig: Allow the post-unpack hook to filter tarball files
With post-unpack scripts is currently possible to filter out files that are not needed from the upstream branch, however it is not possible to use it to filter files that will end up in the orig file, and in some scenarios this is not easily doable just using a filter list. So, run the post-unpack hook just after unpacking and before repacking the tar. Add tests to verify this both when using with regular --filter option and by itself. Closes: #812721
Diffstat (limited to 'gbp/scripts/import_orig.py')
-rw-r--r--gbp/scripts/import_orig.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py
index 2947235a..215bc8ad 100644
--- a/gbp/scripts/import_orig.py
+++ b/gbp/scripts/import_orig.py
@@ -293,12 +293,17 @@ def debian_branch_merge_by_merge(repo, tag, version, options):
repo.set_branch(branch)
-def unpack_tarballs(name, sources, version, options):
+def unpack_tarballs(repo, name, sources, version, options):
tmpdir = tempfile.mkdtemp(dir='../')
if not sources[0].is_dir(): # Unpack main tarball
sources[0].unpack(tmpdir, options.filters)
gbp.log.debug("Unpacked '%s' to '%s'" % (sources[0].path, sources[0].unpacked))
+ try:
+ postunpack_hook(repo, tmpdir, sources, options)
+ except gbpc.CommandExecFailed:
+ raise GbpError() # The hook already printed an error message
+
if orig_needs_repack(sources[0], options):
gbp.log.debug("Filter pristine-tar: repacking '%s' from '%s'" % (sources[0].path,
sources[0].unpacked))
@@ -473,11 +478,7 @@ def main(argv):
if repo.bare:
set_bare_repo_options(options)
- sources, tmpdir = unpack_tarballs(name, sources, version, options)
- try:
- postunpack_hook(repo, tmpdir, sources, options)
- except gbpc.CommandExecFailed:
- raise GbpError() # The hook already printed an error message
+ sources, tmpdir = unpack_tarballs(repo, name, sources, version, options)
if options.verbose:
for source in sources: