diff options
author | Luca Boccassi <bluca@debian.org> | 2018-06-25 23:37:02 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2018-10-28 12:30:25 +0100 |
commit | ce6b1e755fbd999156dbe8c0bf28ccb180641ba2 (patch) | |
tree | 3424f5f53b51c244af83bf2c4d21aec1379c76a0 /gbp | |
parent | 6b1342253eecd83e514400fccc531205450b13d3 (diff) |
buildpackage{,-rpm}: add preexport hook
Sometimes it is necessary to perform operations before preparing the
tarballs and exporting to the build directory.
One such case is when having to handle extremely large binary assets in
the orig tarball and at the same time complex packaging code, which
makes it desirable to separate the two into different repositories for
easier handling.
A pre-export hook allows to ensure that the tarball repository is
present and checked out at the correct branch.
Closes: #909266
Signed-off-by: Luca Boccassi <bluca@debian.org>
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/config.py | 1 | ||||
-rwxr-xr-x | gbp/scripts/buildpackage.py | 13 | ||||
-rw-r--r-- | gbp/scripts/buildpackage_rpm.py | 13 |
3 files changed, 25 insertions, 2 deletions
diff --git a/gbp/config.py b/gbp/config.py index 76a850de..50411802 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -163,6 +163,7 @@ class GbpOptionParser(OptionParser): 'posttag': '', 'pq-from': 'DEBIAN', 'prebuild': '', + 'preexport': '', 'pristine-tar': 'False', 'pristine-tar-commit': 'False', 'purge': 'True', diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py index d345b468..d3a3222e 100755 --- a/gbp/scripts/buildpackage.py +++ b/gbp/scripts/buildpackage.py @@ -277,7 +277,7 @@ def mangle_export_wc_opts(options): def disable_hooks(options): """Disable all hooks (except for builder)""" - for hook in ['cleaner', 'postexport', 'prebuild', 'postbuild', 'posttag']: + for hook in ['cleaner', 'preexport', 'postexport', 'prebuild', 'postbuild', 'posttag']: if getattr(options, hook): gbp.log.info("Disabling '%s' hook" % hook) setattr(options, hook, '') @@ -406,6 +406,9 @@ def build_parser(name, prefix=None): cmd_group.add_config_file_option(option_name="prebuild", dest="prebuild", help="hook to run before a build, " "default is '%(prebuild)s'") + cmd_group.add_config_file_option(option_name="preexport", dest="preexport", + help="hook to run before exporting the source tree, " + "default is '%(preexport)s'") cmd_group.add_config_file_option(option_name="postexport", dest="postexport", help="hook to run after exporting the source tree, " "default is '%(postexport)s'") @@ -505,6 +508,14 @@ def main(argv): build_dir = export_dir if options.export_dir else repo.path changes_file = changes_file_name(source, build_dir, options.builder, dpkg_args) + # Run preexport hook + if options.export_dir and options.preexport: + Hook('Preexport', options.preexport, + extra_env=Hook.md(hook_env, + {'GBP_GIT_DIR': repo.git_dir, + 'GBP_BUILD_DIR': build_dir}) + )() + # Get/build the upstream tarball if necessary. We delay this in # case of a postexport hook so the hook gets a chance to modify the # sources and create different tarballs (#640382) diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py index 16b5eb56..952ff247 100644 --- a/gbp/scripts/buildpackage_rpm.py +++ b/gbp/scripts/buildpackage_rpm.py @@ -296,7 +296,7 @@ def create_packaging_tag(repo, commit, name, version, options): def disable_hooks(options): """Disable all hooks (except for builder)""" - for hook in ['cleaner', 'postexport', 'prebuild', 'postbuild', 'posttag']: + for hook in ['cleaner', 'preexport', 'postexport', 'prebuild', 'postbuild', 'posttag']: if getattr(options, hook): gbp.log.info("Disabling '%s' hook" % hook) setattr(options, hook, '') @@ -395,6 +395,10 @@ def build_parser(name, prefix=None, git_treeish=None): cmd_group.add_config_file_option(option_name="prebuild", dest="prebuild", help="command to run before a build, default is " "'%(prebuild)s'") + cmd_group.add_config_file_option(option_name="preexport", + dest="preexport", + help="command to run before exporting the source tree, " + "default is '%(preexport)s'") cmd_group.add_config_file_option(option_name="postexport", dest="postexport", help="command to run after exporting the source tree, " @@ -532,6 +536,13 @@ def main(argv): options.export_sourcedir)) spec_dir = makedir(os.path.join(export_dir, options.export_specdir)) + # Run preexport hook + if options.preexport: + RunAtCommand(options.preexport, shell=True, + extra_env={'GBP_GIT_DIR': repo.git_dir, + 'GBP_BUILD_DIR': export_dir} + )() + # Move packaging files to final export dir gbp.log.debug("Exporting packaging files from '%s' to '%s'" % (dump_dir, export_dir)) |