summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Keating <jkeating@redhat.com>2011-01-21 15:36:02 -0800
committerJesse Keating <jkeating@redhat.com>2011-01-21 15:36:02 -0800
commitd4bab75fe9d4ef0316fbb6a14c024685bdc504d3 (patch)
tree9d680ba4b684e058b5291dab22ceed21ff66099a
parenta1e7754c630b0d7cea8eeaec87f956f6555517e4 (diff)
downloadfedora-packager-d4bab75fe9d4ef0316fbb6a14c024685bdc504d3.zip
fedora-packager-d4bab75fe9d4ef0316fbb6a14c024685bdc504d3.tar.gz
fedora-packager-d4bab75fe9d4ef0316fbb6a14c024685bdc504d3.tar.xz
Get package name from the specfile. (Ticket 75)
We can't trust the name of the specfile to match, so get the name as defined within the specfile.
-rw-r--r--src/pyfedpkg/__init__.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py
index 16dc291..54dcb74 100644
--- a/src/pyfedpkg/__init__.py
+++ b/src/pyfedpkg/__init__.py
@@ -95,6 +95,21 @@ def _hash_file(file, hashtype):
input.close()
return sum.hexdigest()
+def _name_from_spec(spec):
+ """Return the base package name from the spec."""
+
+ # get the name
+ cmd = ['rpm', '-q', '--qf', '%{NAME} ', '--specfile', spec]
+ # Run the command
+ log.debug('Running: %s' % ' '.join(cmd))
+ try:
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ output, error = proc.communicate()
+ except OSError, e:
+ raise FedpkgError(e)
+ return output.split()[0]
+
def _run_command(cmd, shell=False, env=None, pipe=[], cwd=None):
"""Run the given command.
@@ -741,7 +756,7 @@ def sources(path, outdir=None):
break
if not spec:
raise FedpkgError('%s is not a valid repo' % path)
- module = spec.split('.spec')[0]
+ module = _name_from_spec(os.path.join(path, spec))
try:
archives = open(os.path.join(path, 'sources'),
'r').readlines()
@@ -1042,7 +1057,7 @@ class PackageModule:
self.lookaside = LOOKASIDE
self.lookasidehash = LOOKASIDEHASH
self.spec = self.gimmespec()
- self.module = self.spec.split('.spec')[0]
+ self.module = _name_from_spec(os.path.join(self.path, self.spec))
self.localarch = self._getlocalarch()
# Set the default mock config to None, not all branches have a config
self.mockconfig = None