[PATCH 3/3] Implement abort command
From: Joachim Breitner <mail@joachim-breitner.de>
---
scripts/wb | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/scripts/wb b/scripts/wb
index a30938b..ebca773 100755
--- a/scripts/wb
+++ b/scripts/wb
@@ -114,7 +114,7 @@ def main():
##
-commands = [ 'bp', 'gb', 'dw', 'nmu', 'fail', 'forget', 'info', 'help' ]
+commands = [ 'bp', 'gb', 'dw', 'nmu', 'fail', 'forget', 'info', 'help', 'abort' ]
def do_command(args, fatal_errors=True, transactional=False):
try:
@@ -140,6 +140,18 @@ def do_command(args, fatal_errors=True, transactional=False):
usage()
return
+ if command == 'abort':
+ if transactional:
+ abort()
+ sys.exit(1)
+ else:
+ print >>sys.stderr, 'E: abort only valid in a transaction'
+ if fatal_errors:
+ sys.exit(1)
+ else:
+ return
+
+
# pkgs/arch split
try:
idx = args.index('.')
@@ -358,6 +370,22 @@ def release_transaction_locks():
status and ': exit status %d' % status or '')
if output:
print ''.join(' | ' + x for x in output)
+##
+
+def abort():
+ for arch in DEFAULT_ARCHITECTURES:
+ cmd = [ 'wanna-build', '-b', '%s/build-db' % arch ]
+ cmd.extend(['--unlock-for', str(os.getpid())])
+
+ p = subprocess.Popen(cmd, stdout=PIPE, stderr=PIPE)
+ status = p.wait()
+ output = p.stdout.readlines() + p.stderr.readlines()
+
+ if status or output:
+ print '* Releasing lock for %s%s' % (arch,
+ status and ': exit status %d' % status or '')
+ if output:
+ print ''.join(' | ' + x for x in output)
##
--
1.6.3.3
Reply to: