From f9a10ebd045abe18fd05f1743c7cf63870685ab0 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Wed, 14 Jul 2010 20:56:14 -0700 Subject: Fix ver rel output when subpackages are involved. The idea here came from Xavier Lamien. I just modified it slightly. --- src/pyfedpkg/__init__.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py index c5a30c3..06ade47 100644 --- a/src/pyfedpkg/__init__.py +++ b/src/pyfedpkg/__init__.py @@ -869,28 +869,36 @@ class PackageModule: cmd = ['rpm'] cmd.extend(self.rpmdefines) - cmd.extend(['-q', '--qf', '%{VERSION}', '--specfile', + # We make sure there is a space at the end of our query so that + # we can split it later. When ther eare sub packages, we get a + # listing for each subpackage. We only care about the first. + cmd.extend(['-q', '--qf', '"%{VERSION} "', '--specfile', os.path.join(self.path, self.spec)]) try: output = subprocess.Popen(' '.join(cmd), shell=True, stdout=subprocess.PIPE).communicate() except subprocess.CalledProcessError, e: raise FedpkgError('Could not get version of %s: %s' % (self.module, e)) - return output[0] + # Get just the output, then split it by space, grab the first + return output[0].split()[0] def getrel(self): """Return the version-release of a package module.""" cmd = ['rpm'] cmd.extend(self.rpmdefines) - cmd.extend(['-q', '--qf', '%{RELEASE}', '--specfile', + # We make sure there is a space at the end of our query so that + # we can split it later. When ther eare sub packages, we get a + # listing for each subpackage. We only care about the first. + cmd.extend(['-q', '--qf', '"%{RELEASE} "', '--specfile', os.path.join(self.path, self.spec)]) try: output = subprocess.Popen(' '.join(cmd), shell=True, stdout=subprocess.PIPE).communicate() except subprocess.CalledProcessError, e: raise FedpkgError('Could not get release of %s: %s' % (self.module, e)) - return output[0] + # Get just the output, then split it by space, grab the first + return output[0].split()[0] def gimmespec(self): """Return the name of a specfile within a package module""" -- cgit