# Fedora Developer Shell # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # Authors: Yaakov M. Nemoy # from __future__ import with_statement from base.module import Module from base.vars import FEDORA_DIR from base.profiles import ver_rel, Profile from modules.build import Build from modules.package import Package class Mock(Module): def __init__(self, target_dir, name, profile): self.target_dir = target_dir self.name = name self.pkg = Package(name) self.build = Build(name, target_dir) # for now we're using the old profile form, namely a branch # TODO: fix real profiles self.profile = Profile(profile) def build_rpm(self, target_dir=None): if not target_dir: if self.target_dir: target_dir = self.target_dir else: raise ExecutionException(None, 'no Target Dir specified') self.build.build_source_rpm(target_dir, self.profile) self.build.fetch_rpms(target_dir) srpm_name = self.pkg.get_srpm_name(self.profile) mock_cfg = self.profile.mock_cfg result_dir = self.profile.result_dir config_dir = self.profile.config_dir with pwd(self.pkg.code_dir): with file('mock.log', 'w') as mock_out: with pwd(FEDORA_DIR): p = Popen(['/usr/bin/mock', '-r %s' % mock_cfg, '--configdir=%s' % config_dir, '--resultdir=%s' % result_dir, srpm_name], stdout=mock_out, stderr=mock_out) log.info('quick compiling %s... please wait' % srpm_name) p.wait() __all__ = ['Mock']