#!/usr/bin/python -t # -*- mode: Python; indent-tabs-mode: nil; -*- # # 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; either version 2 of the License, or # (at your option) any later version. # # 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 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 ## Run extras-repoclosure for a given dist release *including* ## packages in the needsign queue. Mail findings only to the package ## owners. import errno, os, sys import fnmatch, shutil, time import Utils, Push, WhatsNew, RepoSupport, BlackList from BuildSys import LocalPlague from BuildReport import NoBuildReportManager if __name__ == '__main__': if len(sys.argv) < 3: print 'Usage: %s [-x]\n' % os.path.basename(sys.argv[0]) sys.exit(errno.EINVAL) cfg = Utils.load_config_module(sys.argv[1]) os.umask(cfg.signersumask) Utils.signer_gid_check(cfg.signersgid) dist = sys.argv[2] distdir = '%s-%s-%s' % (cfg.distro, dist, cfg.project) needsignroot = os.path.join(cfg.stagesdir, distdir) br = LocalPlague(needsignroot) br.PruneBuildResults() # optional results = br.GetBuildResults() mailowners = True if (len(sys.argv)>3 and sys.argv[3]=='-x'): results = BlackList.get_filtered_build_results(cfg,dist,results) # Blacklisted pkgs can cause false positives, so don't mail the # owners when we check needsign with excluded pkgs. mailowners = False import tempfile print 'Copying build results to temporary working directory:' signtmpdir = tempfile.mkdtemp('','.push',cfg.treedir) if signtmpdir == cfg.treedir: # paranoid, should never happen sys.exit(errno.EPERM) try: for br in results: print ' ', br newhome = os.path.join(signtmpdir,br.__str__()) shutil.copytree(br.GetHome(),newhome) br.SetHome(newhome) br.origin = None # disconnect from needsign (very important!) except: # everything is fatal print 'ERROR: Creating temporary working copy failed.' shutil.rmtree(signtmpdir) raise print 'Installing into temporary repository:' Push.cfg = cfg Push.srpmlocdict = {} tmpdir = tempfile.mkdtemp('','tmp-repo-') tmprepo = os.path.join(tmpdir,dist) os.makedirs(tmprepo) Utils.make_std_repodirs(cfg,dist,tmprepo) try: WhatsNew.load(cfg.rundir) buildreport = NoBuildReportManager() for br in results: Push.push(br,dist,tmprepo,buildreport) for arch in cfg.archdict[dist]: Utils.create_repository(cfg,dist,os.path.join(tmprepo,arch),debuginfo=True) except: # everything is fatal print 'ERROR: Creating temporary working copy failed.' shutil.rmtree(tmpdir) shutil.rmtree(signtmpdir) raise shutil.rmtree(signtmpdir) if mailowners: mailopts = '--mail=owners' else: mailopts = '' cmd = '/srv/extras-push/work/extras-repoclosure/rc-run.py %s --needsign=file://%s %s' % (mailopts,tmpdir+'/%s/%s/',dist) print 'Running', cmd rc = os.system(cmd) shutil.rmtree(tmpdir) sys.exit(0)