summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xpuppethost.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/puppethost.py b/puppethost.py
index b980e6a..1d83f7e 100755
--- a/puppethost.py
+++ b/puppethost.py
@@ -124,7 +124,7 @@ class PuppetHost(object):
self._cleanup(tmpdir)
raise
- specfile = '%s/puppet-%s.spec' % (tmpdir, self.hostname)
+ spec = '%s/puppet-%s.spec' % (tmpdir, self.hostname)
text = open(self.opts['template']).read()
text = text.replace('__HOSTNAME__', self.hostname)
@@ -132,14 +132,13 @@ class PuppetHost(object):
text = text.replace('__RELEASE__', self.opts['release'])
text = text.replace('__SSLDIR__', self.opts['destssldir'])
- spec = open(specfile, 'w')
- spec.write(text)
- spec.close()
+ specfp = open(spec, 'w')
+ specfp.write(text)
+ specfp.close()
- build_name_fmt = '%{N}-%{V}-%{R}.%{ARCH}.rpm'
- rpmfilecmd = 'rpm -q --qf "%s/%s" --specfile %s' % (
- rpmdir, build_name_fmt, specfile)
- status, rpm = commands.getstatusoutput(rpmfilecmd)
+ rpm_fmt = '%{N}-%{V}-%{R}.%{ARCH}.rpm'
+ cmd = 'rpm -q --qf "%s/%s" --specfile %s' % (rpmdir, rpm_fmt, spec)
+ status, rpm = commands.getstatusoutput(cmd)
if status:
self._cleanup(tmpdir)
raise PuppetHostError('Failed to get rpm filename:\n%s' % rpm)
@@ -151,13 +150,13 @@ class PuppetHost(object):
if self.opts['verbose']:
print 'Creating rpm...',
- rpmbuild = 'rpmbuild -bb'
- rpmbuild += ' --define "_build_name_fmt %s"' % build_name_fmt
+ cmd = 'rpmbuild -bb'
+ cmd += ' --define "_build_name_fmt %s"' % rpm_fmt
for i in ['_builddir', '_sourcedir', '_specdir', '_srcrpmdir']:
- rpmbuild += ' --define "%s %s"' % (i, tmpdir)
- rpmbuild += ' --define "_rpmdir %s" %s' % (rpmdir, specfile)
+ cmd += ' --define "%s %s"' % (i, tmpdir)
+ cmd += ' --define "_rpmdir %s" %s' % (rpmdir, spec)
- status, output = commands.getstatusoutput(rpmbuild)
+ status, output = commands.getstatusoutput(cmd)
if status or not os.path.exists(rpm):
self._cleanup(tmpdir)
raise PuppetHostError('Error building rpm:\n', output)