summaryrefslogtreecommitdiff
path: root/gbp
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2013-04-29 22:33:37 +0200
committerGuido Günther <agx@sigxcpu.org>2013-04-29 22:33:46 +0200
commitf270a1803613d256e22ff220374776bcb557423a (patch)
tree01f6f7fa921644b0a9681b8d1ad7f3511ee24da5 /gbp
parent8541450530477273798747c4f778049c8a6bb8bd (diff)
downloadgit-buildpackage-f270a1803613d256e22ff220374776bcb557423a.tar.gz
git-buildpackage-f270a1803613d256e22ff220374776bcb557423a.tar.bz2
git-buildpackage-f270a1803613d256e22ff220374776bcb557423a.zip
Silence dpkg --compare-versions
and add the error detail to the exception message. This silences the testsuite and makes sure we have error message and exception output in sync.
Diffstat (limited to 'gbp')
-rw-r--r--gbp/command_wrappers.py3
-rw-r--r--gbp/deb/__init__.py22
2 files changed, 18 insertions, 7 deletions
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py
index 6c97624c..8a131e11 100644
--- a/gbp/command_wrappers.py
+++ b/gbp/command_wrappers.py
@@ -124,7 +124,8 @@ class Command(object):
def call(self, args):
"""
- Like __call__ but let the caller handle the return status.
+ Like __call__ but let the caller handle the return status and don't
+ use the logging api for errors.
>>> Command("/bin/true").call(["foo", "bar"])
0
diff --git a/gbp/deb/__init__.py b/gbp/deb/__init__.py
index 41fc8fdf..8015e6e1 100644
--- a/gbp/deb/__init__.py
+++ b/gbp/deb/__init__.py
@@ -28,23 +28,33 @@ from gbp.deb.changelog import ChangeLog, NoChangeLogError
from gbp.deb.policy import DebianPkgPolicy
class DpkgCompareVersions(gbpc.Command):
- cmd='/usr/bin/dpkg'
+ dpkg = '/usr/bin/dpkg'
def __init__(self):
- if not os.access(self.cmd, os.X_OK):
- raise GbpError("%s not found - cannot use compare versions" % self.cmd)
- gbpc.Command.__init__(self, self.cmd, ['--compare-versions'])
+ if not os.access(self.dpkg, os.X_OK):
+ raise GbpError("%s not found - cannot use compare versions" % self.dpkg)
+ gbpc.Command.__init__(self, self.dpkg, ['--compare-versions'], capture_stderr=True)
def __call__(self, version1, version2):
+ """
+ Compare two package versions. Return 0 if the versions are equal, -1 1 if version1 < version2,
+ and 1 oterwise.
+
+ @raises CommandExecFailed: if the version comparison fails
+ """
self.run_error = "Couldn't compare %s with %s" % (version1, version2)
- res = gbpc.Command.call(self, [ version1, 'lt', version2 ])
+ res = self.call([ version1, 'lt', version2 ])
if res not in [ 0, 1 ]:
+ if self.stderr:
+ self.run_error += ' (%s)' % self.stderr
raise gbpc.CommandExecFailed("%s: bad return code %d" % (self.run_error, res))
if res == 0:
return -1
elif res == 1:
- res = gbpc.Command.call(self, [ version1, 'gt', version2 ])
+ res = self.call([ version1, 'gt', version2 ])
if res not in [ 0, 1 ]:
+ if self.stderr:
+ self.run_error += ' (%s)' % self.stderr
raise gbpc.CommandExecFailed("%s: bad return code %d" % (self.run_error, res))
if res == 0:
return 1