summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-05-12 21:09:51 +0100
committerCarl Hetherington <cth@carlh.net>2019-05-12 21:09:51 +0100
commit0dfe69c0ca347ab237d13d61ae63fe49a804d1a7 (patch)
treef863071201b33644fd66942e4a97defb3dfdef3a
parent86776ba375c08c4f94c62fe9202682d16bf3b9e7 (diff)
Cleanup on package failure.
-rwxr-xr-xcdist37
1 files changed, 21 insertions, 16 deletions
diff --git a/cdist b/cdist
index a9c5d48..fa25c46 100755
--- a/cdist
+++ b/cdist
@@ -1047,27 +1047,32 @@ def main():
if args.target is None:
raise Error('you must specify -t or --target')
- target = target_factory(args)
+ target = None
+ try:
+ target = target_factory(args)
- if target.platform == 'linux' and target.detail != "appimage":
- if target.distro != 'arch':
- output_dir = os.path.join(args.output, '%s-%s-%d' % (target.distro, target.version, target.bits))
+ if target.platform == 'linux' and target.detail != "appimage":
+ if target.distro != 'arch':
+ output_dir = os.path.join(args.output, '%s-%s-%d' % (target.distro, target.version, target.bits))
+ else:
+ output_dir = os.path.join(args.output, '%s-%d' % (target.distro, target.bits))
else:
- output_dir = os.path.join(args.output, '%s-%d' % (target.distro, target.bits))
- else:
- output_dir = args.output
+ output_dir = args.output
- makedirs(output_dir)
-
- # Start with the options passed on the command line
- options = copy.copy(argument_options(args))
- # Fill in the defaults
- tree = globals.trees.get(args.project, args.checkout, target)
- tree.add_defaults(options)
+ makedirs(output_dir)
- target.package(args.project, args.checkout, output_dir, options)
+ # Start with the options passed on the command line
+ options = copy.copy(argument_options(args))
+ # Fill in the defaults
+ tree = globals.trees.get(args.project, args.checkout, target)
+ tree.add_defaults(options)
+ target.package(args.project, args.checkout, output_dir, options)
+ except Error as e:
+ if target is not None and not args.keep:
+ target.cleanup()
+ raise
- if not args.keep:
+ if target is not None and not args.keep:
target.cleanup()
elif globals.command == 'release':