diff options
author | Guido Günther <agx@sigxcpu.org> | 2013-04-29 22:33:37 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2013-04-29 22:33:46 +0200 |
commit | f270a1803613d256e22ff220374776bcb557423a (patch) | |
tree | 01f6f7fa921644b0a9681b8d1ad7f3511ee24da5 /gbp/deb | |
parent | 8541450530477273798747c4f778049c8a6bb8bd (diff) | |
download | git-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/deb')
-rw-r--r-- | gbp/deb/__init__.py | 22 |
1 files changed, 16 insertions, 6 deletions
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 |