aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Guenther <agx@sigxcpu.org>2006-09-11 18:32:32 +0200
committerGuido Guenther <agx@bogon.sigxcpu.org>2006-09-11 18:32:32 +0200
commitd4d6d38ad6c90b19664ec7a6a9f89bf6753e82cf (patch)
treefa7b8d21fc08afed797eba3d40c96d7085eaf207
parente4138a607c371f7c297fd50db7cc9e3dee5d3935 (diff)
git-debuild: at least do some error checking
-rwxr-xr-xgit-debuild33
1 files changed, 24 insertions, 9 deletions
diff --git a/git-debuild b/git-debuild
index cc139515..712c8b00 100755
--- a/git-debuild
+++ b/git-debuild
@@ -8,6 +8,9 @@
import sys,os,commands,re
import optparse
+build_cmd='debuild'
+clean_cmd='%s clean' % build_cmd
+
def get_version():
versionre=re.compile('^Version:\s+(?P<version>[\d\w~\-\.]+)$')
(status, out) = commands.getstatusoutput('dpkg-parsechangelog')
@@ -16,6 +19,15 @@ def get_version():
if m:
return m.group('version')
+def exec_command(cmd):
+ print "Running:", cmd
+ ret=os.system(cmd)
+ if ret:
+ print >>sys.stderr,"%s failed" % cmd
+ return False, ret
+ else:
+ return True, 0
+
def main(argv):
args = [ arg for arg in argv[1:] if arg.find('--git-') == 0 ]
dpkg_args = [ arg for arg in argv[1:] if arg.find('--git-') == -1 ]
@@ -27,18 +39,21 @@ def main(argv):
help="build with uncommited changes in the source tree")
(options, args) = parser.parse_args(args)
- (status, out) = commands.getstatusoutput('git status')
- msgs=out.split('\n')
- if msgs[0] != 'nothing to commit' and not options.ignore_new:
- print out
- sys.exit(1)
- cmd='debuild -i.git '+" ".join(dpkg_args)
- print "Running:", cmd
- os.system('debuild -i.git '+" ".join(dpkg_args))
+ if not options.ignore_new:
+ if not exec_command(clean_cmd)[0]: sys.exit(1)
+ (status, out) = commands.getstatusoutput('git status')
+ msgs=out.split('\n')
+ if msgs[0] != 'nothing to commit':
+ print "You have uncommitted changes in your source tree:"
+ print out
+ print "Use --git-ignore_new to ovverride"
+ sys.exit(1)
+ cmd=build_cmd+' -i.git '+" ".join(dpkg_args)
+ if not exec_command(cmd)[0]: sys.exit(1)
version=get_version()
if version and options.tag:
print "Tagging", version
- os.system('git-tag %s' % version)
+ if not exec_command('git-tag %s' % version)[0]: sys.exit(1)
else:
print >>sys.stderr,"Can't parse version from changes file"