aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2019-04-25 17:15:21 +0200
committerGuido Günther <agx@sigxcpu.org>2019-04-25 17:34:00 +0200
commitb12b85a18c4fc06d820e4aabbb2730e39fee917e (patch)
treeef7f33f4a08e3a5c2a74104b00e5b5ccc399ef42
parentd6ae3931935abb4ddf359ff97a4d708aef8a94fe (diff)
import-orig: Allow to run a post unpack hook
The working directory of the hook is the top temporary directory the tarballs are being unpacked into.
-rw-r--r--gbp/config.py4
-rw-r--r--gbp/scripts/import_orig.py13
-rw-r--r--tests/component/deb/test_import_orig.py1
3 files changed, 18 insertions, 0 deletions
diff --git a/gbp/config.py b/gbp/config.py
index 50411802..d9a3cfaa 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -160,6 +160,7 @@ class GbpOptionParser(OptionParser):
'postedit': '',
'postexport': '',
'postimport': '',
+ 'postunpack': '',
'posttag': '',
'pq-from': 'DEBIAN',
'prebuild': '',
@@ -321,6 +322,9 @@ class GbpOptionParser(OptionParser):
'postimport':
"hook run after a successful import, "
"default is '%(postimport)s'",
+ 'postunpack':
+ "hook run after a unpacking the tarballs, "
+ "default is '%(postimport)s'",
'hooks':
"Enable running all hooks, default is %(hooks)s",
'time-machine':
diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py
index 9c859f24..01b1fc6d 100644
--- a/gbp/scripts/import_orig.py
+++ b/gbp/scripts/import_orig.py
@@ -210,6 +210,14 @@ def postimport_hook(repo, tag, version, options):
extra_env=env)()
+def postunpack_hook(repo, tmp_dir, options):
+ if options.postunpack:
+ Hook('Postunpack', options.postunpack,
+ extra_env={'GBP_GIT_DIR': repo.git_dir,
+ 'GBP_TMP_DIR': tmp_dir}
+ )(dir=tmp_dir)
+
+
def is_30_quilt(repo, options):
format_file = DebianSourceFormat.format_file
try:
@@ -353,6 +361,7 @@ def build_parser(name):
import_group.add_config_file_option("component", action="append", metavar='COMPONENT',
dest="components")
cmd_group.add_config_file_option(option_name="postimport", dest="postimport")
+ cmd_group.add_config_file_option(option_name="postunpack", dest="postunpack")
parser.add_boolean_config_file_option(option_name="interactive",
dest='interactive')
@@ -442,6 +451,10 @@ def main(argv):
set_bare_repo_options(options)
upstream, tmpdir = unpack_tarballs(name, upstream, version, component_tarballs, options)
+ try:
+ postunpack_hook(repo, tmpdir, options)
+ except gbpc.CommandExecFailed:
+ raise GbpError() # The hook already printed an error message
(pristine_orig, linked) = prepare_pristine_tar(upstream.path,
name,
diff --git a/tests/component/deb/test_import_orig.py b/tests/component/deb/test_import_orig.py
index 58b72c5b..d7136822 100644
--- a/tests/component/deb/test_import_orig.py
+++ b/tests/component/deb/test_import_orig.py
@@ -100,6 +100,7 @@ class TestImportOrig(ComponentTestBase):
orig = self._orig('2.8')
ok_(import_orig(['arg0',
'--postimport=printenv > ../postimport.out',
+ '--postunpack=printenv > ../postunpack.out',
'--no-interactive', '--pristine-tar', orig]) == 0)
self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8'])