From 6e24be8e1eeac16b9d2221090be10ad44ca61298 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Nov 17 2011 06:53:57 +0000 Subject: Start reworking the mock bits --- diff --git a/r2spec/build.py b/r2spec/build.py index 0a5bea9..fa690e5 100644 --- a/r2spec/build.py +++ b/r2spec/build.py @@ -42,7 +42,7 @@ class Build: self.files = [] # stores the files for the %file section self.deps = [] # stores missing dependencies - def build(self, specname, rpmarg='ba', mock=False): + def build(self, specname, rpmarg='ba', mock_config=False): """ Builds the given specfile and returns the errors if any. :arg specname, the full path to the spec file to build. @@ -51,27 +51,27 @@ class Build: using the given configuration. """ self.log.info('Building the rpm (this may take some time)') - if mock is None or mock is False: - cmd = 'LANG=C rpmbuild -%s %s > %s.build.log 2>&1' % (rpmarg, - specname, specname) - self.buildlog = '%s.build.log' % specname + self.buildlog = '%s.build.log' % specname + if mock_config is None or mock_config is False: + cmd = 'LANG=C rpmbuild -%s %s > %s 2>&1' % (rpmarg, + specname, self.buildlog) self.log.debug(cmd) self.outcode = subprocess.call(cmd, shell=True) else: - cmd = 'LANG=C rpmbuild -bs %s > %s.build.log 2>&1' % ( - specname, specname) - self.buildlog = '%s.build.log' % specname + cmd = 'LANG=C rpmbuild -bs %s > %s 2>&1' % ( + specname, self.buildlog) self.log.debug(cmd) self.outcode = subprocess.call(cmd, shell=True) self.get_rpm() - mockcommand = 'mock -r %s --rebuild %s' % (mock, self.rpm[0]) - cmd = ' LANG=C %s >> %s.build.log 2>&1' % (mockcommand, specname) + mockcommand = 'mock -r %s --no-clean --rebuild %s' % ( + mock_config, self.rpm[0]) + cmd = ' LANG=C %s >> %s.build.log 2>&1' % ( + mockcommand, specname) self.buildlog = '/var/lib/mock/%s/result/build.log' % mock - if os.path.exists(self.buildlog): - os.remove(self.buildlog) self.log.debug(cmd) self.outcode = subprocess.call(cmd, shell=True) + self.get_rpm() def get_rpm(self): """ Parses the build.log to extract the rpm generated.