[ -x $i ] && $SUDO $i stop
done
$SUDO killall pg_autovacuum postmaster postgres
-$SUDO rm -rf /etc/postgresql /var/lib/postgresql/ /var/log/postgresql/ /tmp/postgresql-testsuite/ /var/run/postgresql/*
+$SUDO rm -rf /etc/postgresql /var/lib/postgresql/ /var/log/postgresql/* /tmp/postgresql-testsuite/ /var/run/postgresql/*
--- /dev/null
+#!/usr/bin/python
+
+import subprocess, re, sys
+
+lpbugs_re = re.compile(r'lp: #([0-9, ]+)', re.I)
+
+bzr = subprocess.Popen(['bzr', 'diff', 'NEWS'], stdout=subprocess.PIPE)
+raw_msg = bzr.communicate()[0].strip()
+if bzr.returncode != 1:
+ print >> sys.stderr, 'bzr diff NEWS failed'
+ sys.exit(1)
+
+# parse/format message
+msg = ''
+for l in raw_msg.splitlines():
+ if not l.startswith('+ '):
+ continue
+ if msg:
+ msg += ' '
+ msg += l[2:].strip()
+
+if msg.startswith('-'):
+ msg = msg[1:].strip()
+
+print '-- commit message: --'
+print msg
+print '---'
+
+if not msg:
+ print >> sys.stderr, 'No message in NEWS, aborting'
+ sys.exit(1)
+
+# parse Launchpad bugs
+lpbugs = []
+for b_grp in lpbugs_re.finditer(msg):
+ for b in b_grp.group(1).split(','):
+ lpbugs.append(b.strip())
+print 'Fixed LP bugs:', ' '.join(lpbugs)
+
+# commit
+argv = ['bzr', 'commit', '-m', msg]
+for b in lpbugs:
+ argv += ['--fixes', 'lp:' + b]
+
+sys.exit(subprocess.call(argv))
+