aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/scripts/buildpackage.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-08-11 15:42:55 -0300
committerGuido Günther <agx@sigxcpu.org>2017-08-12 15:55:21 -0300
commit4642150cccf518064e981d1c28debe03b4c2610d (patch)
treec7f20fb8ddb2c1d888c4fbc6894ffa76e0f4abb2 /gbp/scripts/buildpackage.py
parentb7c34cc4285dec65822ec209e50d4a30046f4fbf (diff)
buildpackage: set variables upfront
This makes it far simpler to shift blocks of code around without hitting unset variables. Gbp-Dch: Ignore
Diffstat (limited to 'gbp/scripts/buildpackage.py')
-rwxr-xr-xgbp/scripts/buildpackage.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py
index 482fce40..bc60be80 100755
--- a/gbp/scripts/buildpackage.py
+++ b/gbp/scripts/buildpackage.py
@@ -298,6 +298,14 @@ def changes_file_suffix(dpkg_args):
return os.getenv('ARCH', None) or du.get_arch()
+def changes_file_name(source, build_dir, dpkg_args):
+ return os.path.abspath("%s/../%s_%s_%s.changes" %
+ (build_dir,
+ source.changelog.name,
+ source.changelog.noepoch,
+ changes_file_suffix(dpkg_args)))
+
+
def build_parser(name, prefix=None):
try:
parser = GbpOptionParserDebian(command=os.path.basename(name), prefix=prefix)
@@ -475,6 +483,13 @@ def main(argv):
if not options.tag_only:
output_dir = prepare_output_dir(options.export_dir)
tarball_dir = options.tarball_dir or output_dir
+ tmp_dir = os.path.join(output_dir, "%s-tmp" % source.sourcepkg)
+ build_env, hook_env = setup_pbuilder(options, repo, source.is_native())
+ major = (source.debian_version if source.is_native()
+ else source.upstream_version)
+ export_dir = os.path.join(output_dir, "%s-%s" % (source.sourcepkg, major))
+ build_dir = export_dir if options.export_dir else repo.path
+ changes_file = changes_file_name(source, build_dir, dpkg_args)
# 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
@@ -488,11 +503,8 @@ def main(argv):
prepare_upstream_tarballs(repo, source, options, tarball_dir,
output_dir)
- build_env, hook_env = setup_pbuilder(options, repo, source.is_native())
-
# Export to another build dir if requested:
if options.export_dir:
- tmp_dir = os.path.join(output_dir, "%s-tmp" % source.sourcepkg)
export_source(repo, tree, source, options, tmp_dir, tarball_dir)
# Run postexport hook
@@ -503,9 +515,6 @@ def main(argv):
'GBP_TMP_DIR': tmp_dir})
)(dir=tmp_dir)
- major = (source.debian_version if source.is_native()
- else source.upstream_version)
- export_dir = os.path.join(output_dir, "%s-%s" % (source.sourcepkg, major))
gbp.log.info("Moving '%s' to '%s'" % (tmp_dir, export_dir))
move_old_export(export_dir)
os.rename(tmp_dir, export_dir)
@@ -514,10 +523,6 @@ def main(argv):
if not source.is_native() and options.postexport:
prepare_upstream_tarballs(repo, source, options, tarball_dir,
output_dir)
- build_dir = export_dir
- else:
- build_dir = repo.path
-
if options.prebuild:
Hook('Prebuild', options.prebuild,
extra_env=Hook.md(hook_env,
@@ -533,15 +538,10 @@ def main(argv):
{'GBP_BUILD_DIR': build_dir})
)(dir=build_dir)
if options.postbuild:
- changes = os.path.abspath("%s/../%s_%s_%s.changes" %
- (build_dir,
- source.changelog.name,
- source.changelog.noepoch,
- changes_file_suffix(dpkg_args)))
- gbp.log.debug("Looking for changes file %s" % changes)
+ gbp.log.debug("Looking for changes file %s" % changes_file)
Hook('Postbuild', options.postbuild,
extra_env=Hook.md(hook_env,
- {'GBP_CHANGES_FILE': changes,
+ {'GBP_CHANGES_FILE': changes_file,
'GBP_BUILD_DIR': build_dir})
)()
if options.tag or options.tag_only: