diff options
author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2020-03-05 16:04:49 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2020-08-25 18:19:45 +0200 |
commit | 9fc3f1b3edc9def944854206ebcf7dd51fd05185 (patch) | |
tree | eae684d79bae8f8bf147918278994d5c66ef8745 | |
parent | 4e5fc40a00557b5adeef944e01e755cf86ab9325 (diff) |
import-orig: expose unpacked sources dir to the postunpack hook
Use an $GBP_SOURCES_DIR to expose the post-unpack sources dir to the hook.
Include a test that checks that all the expected env variables are set.
-rw-r--r-- | docs/manpages/gbp-import-orig.xml | 6 | ||||
-rw-r--r-- | gbp/scripts/import_orig.py | 7 | ||||
-rw-r--r-- | tests/component/deb/test_import_orig.py | 15 |
3 files changed, 25 insertions, 3 deletions
diff --git a/docs/manpages/gbp-import-orig.xml b/docs/manpages/gbp-import-orig.xml index 79274d32..7581da66 100644 --- a/docs/manpages/gbp-import-orig.xml +++ b/docs/manpages/gbp-import-orig.xml @@ -347,6 +347,12 @@ </para></listitem> </varlistentry> <varlistentry> + <term><envar>GBP_SOURCES_DIR</envar></term> + <listitem><para> + The temporary directory where the unpacked sources are. + </para></listitem> + </varlistentry> + <varlistentry> <term><envar>GBP_GIT_DIR</envar></term> <listitem><para> The directory of the git repository where the tarball diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py index 3a0d2d97..2947235a 100644 --- a/gbp/scripts/import_orig.py +++ b/gbp/scripts/import_orig.py @@ -227,11 +227,12 @@ def postimport_hook(repo, tag, version, options): extra_env=env)() -def postunpack_hook(repo, tmp_dir, options): +def postunpack_hook(repo, tmp_dir, sources, options): if options.postunpack: Hook('Postunpack', options.postunpack, extra_env={'GBP_GIT_DIR': repo.git_dir, - 'GBP_TMP_DIR': tmp_dir} + 'GBP_TMP_DIR': tmp_dir, + 'GBP_SOURCES_DIR': sources[0].unpacked} )(dir=tmp_dir) @@ -474,7 +475,7 @@ def main(argv): sources, tmpdir = unpack_tarballs(name, sources, version, options) try: - postunpack_hook(repo, tmpdir, options) + postunpack_hook(repo, tmpdir, sources, options) except gbpc.CommandExecFailed: raise GbpError() # The hook already printed an error message diff --git a/tests/component/deb/test_import_orig.py b/tests/component/deb/test_import_orig.py index b95b874d..ef75919e 100644 --- a/tests/component/deb/test_import_orig.py +++ b/tests/component/deb/test_import_orig.py @@ -401,3 +401,18 @@ class TestImportOrig(ComponentTestBase): ("GBP_TAG", "upstream/2.8"), ("GBP_UPSTREAM_VERSION", "2.8"), ("GBP_DEBIAN_VERSION", "2.8-1")]) + + def test_postunpack_env_vars(self): + """ + Test that the expected environment variables are set during + postunpack hook. + """ + repo = ComponentTestGitRepository.create(self.pkg) + os.chdir(self.pkg) + orig = self._orig('2.8') + ok_(import_orig(['arg0', + '--postunpack=printenv > ../postunpack.out', + '--no-interactive', '--pristine-tar', orig]) == 0) + self.check_hook_vars('../postunpack', ["GBP_GIT_DIR", + "GBP_TMP_DIR", + "GBP_SOURCES_DIR"]) |