aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/scripts/buildpackage.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-11-22 20:58:01 +0100
committerGuido Günther <agx@sigxcpu.org>2011-11-22 22:15:54 +0100
commit69d348c3eb868f58efd769603f425bb88bb74f1d (patch)
treebdf9f5ae768c3dd5c465c4db192f1cdd9786539d /gbp/scripts/buildpackage.py
parent29b8b036102f3bb0cb4fa19d66bf8fae274d5537 (diff)
Support postexport hooks
Heavily based on a patch by Jan Čapek Closes: #640982
Diffstat (limited to 'gbp/scripts/buildpackage.py')
-rw-r--r--gbp/scripts/buildpackage.py27
1 files changed, 24 insertions, 3 deletions
diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py
index 13186e75..c6dccbcc 100644
--- a/gbp/scripts/buildpackage.py
+++ b/gbp/scripts/buildpackage.py
@@ -401,6 +401,8 @@ def parse_args(argv, prefix):
help="command to clean the working copy, default is '%(cleaner)s'")
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="postexport", dest="postexport",
+ help="command to run after exporting the source tree, default is '%(postexport)s'")
cmd_group.add_config_file_option(option_name="postbuild", dest="postbuild",
help="hook run after a successful build, default is '%(postbuild)s'")
cmd_group.add_config_file_option(option_name="posttag", dest="posttag",
@@ -486,10 +488,17 @@ def main(argv):
else:
tarball_dir = output_dir
- # Get/build the upstream tarball if necessary:
+ # Get/build the upstream tarball if necessary. We delay this in
+ # case of a postexport so the hook gets chance to modify the
+ # sources and create different tarballs (#640382)
+ # We don't delay it in general since we want to fail early if the
+ # tarball is missing.
if not du.is_native(cp):
- prepare_upstream_tarball(repo, cp, options, tarball_dir,
- output_dir)
+ if options.postexport:
+ gbp.log.info("Postexport hook set, delaying tarball creation")
+ else:
+ prepare_upstream_tarball(repo, cp, options, tarball_dir,
+ output_dir)
# Export to another build dir if requested:
if options.export_dir:
@@ -513,12 +522,24 @@ def main(argv):
gbp.log.info("Exporting '%s' to '%s'" % (options.export, tmp_dir))
if not dump_tree(repo, tmp_dir, tree, options.with_submodules):
raise GbpError
+
+ # Run postexport hook
+ if options.postexport:
+ RunAtCommand(options.postexport, shell=True,
+ extra_env={'GBP_GIT_DIR': repo.git_dir,
+ 'GBP_TMP_DIR': tmp_dir})(dir=tmp_dir)
+
cp = du.parse_changelog(filename=os.path.join(tmp_dir, 'debian', 'changelog'))
export_dir = os.path.join(output_dir, "%s-%s" % (cp['Source'], major))
gbp.log.info("Moving '%s' to '%s'" % (tmp_dir, export_dir))
move_old_export(export_dir)
os.rename(tmp_dir, export_dir)
+ # Delayed tarball creation in case a postexport hook is used:
+ if not du.is_native(cp) and options.postexport:
+ prepare_upstream_tarball(repo, cp, options, tarball_dir,
+ output_dir)
+
if options.export_dir:
build_dir = export_dir
else: