extras-buildsys/utils/pushscript BuildReport.py, NONE, 1.1 Push.py, 1.39, 1.40
Michael Schwendt (mschwendt)
fedora-extras-commits at redhat.com
Sun May 6 16:00:54 UTC 2007
Author: mschwendt
Update of /cvs/fedora/extras-buildsys/utils/pushscript
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31258
Modified Files:
Push.py
Added Files:
BuildReport.py
Log Message:
Drop the plain ascii build report log files and replace them with pickle files, which store more information about pushed builds. -> Easier formatting.
--- NEW FILE BuildReport.py ---
#!/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
import errno, os, sys
import pickle
class BuildInfo:
def __init__(self,pkgid=None,summary=None,new=False,invalid=False):
self.pkgid = pkgid
self.summary = summary
self.new = new
self.invalid = invalid
class BuildReportManager:
def __init__(self,workdir,id):
self.fname = os.path.join(workdir,'%s.buildreport.pickle'%id)
self.builds = []
self._load(self.fname)
def Add(self,buildinfo):
if not buildinfo:
return
self.builds.append(buildinfo)
self._save(self.fname)
def Clear(self):
self.builds = []
self._save(self.fname)
def GetCount(self):
return len(self.builds)
def GetReport(self):
def cmplc(a,b): # case-insensitive cmp for Python < 2.4 sort()
return cmp(a.lower(),b.lower())
def cmpbuilds(a,b):
return cmplc(a.pkgid,b.pkgid)
builds = self.builds
builds.sort(cmpbuilds)
report = []
for b in builds:
if b.new:
s = 'NEW '
elif b.invalid:
s = '(!) '
else:
s = ' '
s += b.pkgid
if b.summary:
s += ' : ' + b.summary
report.append(s)
return '\n'.join(report)
def _load(self,fname):
try:
f = file(fname,'r')
self.builds = pickle.load(f)
f.close()
except IOError, (err, strerr):
if err != 2: # everything but file_not_found is unexpected
print 'ERROR: %s: %s' % (strerr,self.fname)
raise IOError, (err, strerr)
def _save(self,fname):
f = file(fname,'w')
pickle.dump(self.builds,f)
f.close()
class NoBuildReportManager(BuildReportManager):
def __init__(self,workdir=None,id=None):
self.builds = []
def Add(self,buildinfo):
pass
Index: Push.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/Push.py,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- Push.py 3 Mar 2007 18:41:53 -0000 1.39
+++ Push.py 6 May 2007 16:00:52 -0000 1.40
@@ -29,6 +29,7 @@
import RepoBuild, RepoPrune, RepoView
from LockFile import LockFile, LockFileLocked
from BuildSys import LocalPlague
+from BuildReport import *
DEBUG = False
Utils.setdebug(DEBUG)
@@ -44,37 +45,6 @@
ts = rpmUtils.transaction.initReadOnlyTransaction()
# Further globals: cfg, srpmlocdict
-
-def getrunfilename(dist):
- runfilename = os.path.join(cfg.rundir, dist)
- if DEBUG:
- runfilename += '.DEBUG'
- return runfilename
-
-
-def getlinesfromrunfile(dist):
- runfilename = getrunfilename(dist)
- pkglist = []
- try:
- pkglist = file(runfilename).read().splitlines()
- except IOError, (err, strerr):
- if err != 2: # everything but file_not_found is unexpected
- print 'ERROR: %s: %s' % (strerr,runfilename)
- sys.exit(err)
- return pkglist
-
-
-def emptyrunfile(dist):
- runfilename = getrunfilename(dist)
- if not os.path.exists(runfilename):
- return
- try:
- os.remove(runfilename)
- except:
- print 'ERROR: Could not remove %s' % runfilename
- pass
-
-
# ====================================================================
def getexcludearch(pkgpath,reporoot):
@@ -126,7 +96,7 @@
pass
-def push(br,dist,destroot,buildreport=True):
+def push(br,dist,destroot,buildreport):
"""push the files found within a single package build-results directory"""
rollback = []
try:
@@ -146,15 +116,6 @@
def push_with_rollback(rollback,br,dist,destroot,buildreport):
print ' ', br
- buildreportinfo = None
-
- # In the run-file we store the package NVR ids for the build report.
- # Content in that file also serves as an indication whether there is
- # a "push" to finish, i.e. whether we need to sync the repository
- # to the public master site.
- runfilename = getrunfilename(dist)
- rundirfile = open(runfilename,'a')
-
# go through each package and move it to the right arch location
# if it is a src.rpm package, move it into the SRPMS location
# if it is a noarch package, copy2 it to all arch locations
@@ -162,14 +123,13 @@
if len(br.filedict['srpm']) != 1:
br.MarkPushed()
- buildreportinfo = '%s : INVALID build results, not published! INV\n' % br
- if buildreport:
- rundirfile.write(buildreportinfo)
- rundirfile.close()
+ bi = BuildInfo(br.__str__(),'INVALID build results, not published!',False,True)
+ buildreport.Add(bi)
raise PushWarning, 'WARNING: %d source rpms in %s' % (len(br.filedict['srpm']),br.GetHome())
package = br.filedict['srpm'][0]
(n,a,e,v,r) = Utils.naevr(package)
+ summary = Utils.get_pkg_header(package)['summary'].rstrip()
pkg_fn = os.path.basename(package)
global srpmlocdict # debug only
srpmlocdict[pkg_fn] = package # debug only
@@ -178,15 +138,13 @@
rollback.append(destloc)
Utils.install_move(package,destloc)
if WhatsNew.queryname(dist,n):
- buildreportinfo = '%s-%s-%s\n' % (n,v,r)
+ buildreportinfo = BuildInfo('%s-%s-%s' % (n,v,r))
else:
- buildreportinfo = '%s-%s-%s NEW\n' % (n,v,r)
+ buildreportinfo = BuildInfo('%s-%s-%s' % (n,v,r), summary, True)
else: # src.rpm published before, exclude entire build job
br.MarkPushed()
- buildreportinfo = '%s : INVALID rebuild, not published! INV\n' % br
- if buildreport:
- rundirfile.write(buildreportinfo)
- rundirfile.close()
+ bi = BuildInfo(br.__str__(),'INVALID rebuild, not published!',False,True)
+ buildreport.Add(bi)
raise PushWarning, 'WARNING: %s published before' % pkg_fn
for package in br.filedict['rpm'] + br.filedict['debuginfo']:
@@ -231,10 +189,8 @@
# Mark successfully signed packages as PUSHED.
br.MarkPushed()
- rollback = []
- if buildreport:
- rundirfile.write(buildreportinfo)
- rundirfile.close()
+ del rollback[:]
+ buildreport.Add(buildreportinfo)
def copy_sign_move(dist,whitelist=['.*']):
@@ -319,13 +275,13 @@
clogdiff = WhatsNew.getclogdiff(dist,name,br.GetSourcePkg(),ts)
newclog = WhatsNew.readclog(br.GetSourcePkg(),ts)
if name in cfg.diversion_dict: # install this elsewhere?
- buildreport = False
+ buildreport = NoBuildReportManager()
targetroot = os.path.join(cfg.diversion_dict[name],dist)
if os.path.exists(targetroot):
shutil.rmtree(targetroot)
Utils.make_std_repodirs(cfg,dist,targetroot)
else:
- buildreport = True
+ buildreport = BuildReportManager(cfg.rundir,dist)
targetroot = destroot
try:
push(br,dist,targetroot,buildreport)
@@ -335,9 +291,8 @@
except rpmUtils.RpmUtilsError, e:
print e
WhatsNew.putname(dist,name)
- if dist == 'development':
- WhatsNew.putclog(dist,name,newclog)
- WhatsNew.putclogdiff(dist,br.__str__(),clogdiff)
+ WhatsNew.putclog(dist,name,newclog)
+ WhatsNew.putclogdiff(dist,br.__str__(),clogdiff)
WhatsNew.save(cfg.rundir)
except PushFatal:
@@ -380,28 +335,22 @@
for dist in cfg.alldists: # we do this for sorting the dists
if not dist in distlist:
continue
- uniqued = rpmUtils.miscutils.unique( getlinesfromrunfile(dist) )
- uniqued.sort()
+ brm = BuildReportManager(cfg.rundir,dist)
- body += "\nPackages built and released for %s %s: %s \n\n" % (cfg.project_hr, dist, len(uniqued))
- for p in uniqued:
- if p.endswith(' NEW'):
- p = 'NEW '+p[:-4]
- elif p.endswith(' INV'):
- p = '(!) '+p[:-4]
- else:
- p = ' '+p
- body += p+'\n'
- body += '\n'
-
- if not body:
- return
+ body += "\nPackages built and released for %s %s: %s\n\n" % (cfg.project_hr, dist, brm.GetCount())
+ print brm.GetReport()
+ body += brm.GetReport()
+ body += '\n\n'
- try:
- WhatsNew.load(cfg.rundir)
- body += '\n'+WhatsNew.getallclogdiffs('development')
- except:
- pass
+ for dist in cfg.alldists: # we do this for sorting the dists
+ if not dist in distlist:
+ continue
+ body += "\nChanges in %s %s: \n\n" % (cfg.project_hr, dist)
+ try:
+ WhatsNew.load(cfg.rundir)
+ body += '\n'+WhatsNew.getallclogdiffs(dist)
+ except:
+ pass
body += cfg.mail_footer
@@ -423,7 +372,8 @@
# Build report has been mailed, we can delete the run-files.
for dist in distlist:
- emptyrunfile(dist)
+ b = BuildReportManager(cfg.rundir,dist)
+ b.Clear()
# ====================================================================
@@ -498,9 +448,8 @@
sys.exit(result)
if repochanged:
changed.append(dist)
- # len(getlinesfromrunfile(dist)) is the number of build jobs
- # per dist which have been pushed.
- buildjobs = len( getlinesfromrunfile(dist) )
+ brm = BuildReportManager(cfg.rundir,dist)
+ buildjobs = brm.GetCount()
totalchanges += buildjobs
if buildjobs:
mustfinish.append(dist)
More information about the fedora-extras-commits
mailing list