[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

extras-buildsys/utils/pushscript WhatsNew.py,1.6,1.7



Author: mschwendt

Update of /cvs/fedora/extras-buildsys/utils/pushscript
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv4646

Modified Files:
	WhatsNew.py 
Log Message:
Everyone perhaps has noticed that the Extras build report changelog summary for FE6 and FE5 is based on an incorrectly initialised history. The trivial fix is to read only the latest package.


Index: WhatsNew.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/WhatsNew.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- WhatsNew.py	6 May 2007 15:52:32 -0000	1.6
+++ WhatsNew.py	10 May 2007 14:18:52 -0000	1.7
@@ -32,18 +32,66 @@
 # The 'clogdiffs' dict is filled when new packages are published
 # and is cleared after sending a build report.
 
+def stripold(rpmfiles):
+    ts = rpmUtils.transaction.initReadOnlyTransaction()
+    
+    newestrpms = {}
+    for f in rpmfiles:
+        try:
+           hdr = rpmUtils.miscutils.hdrFromPackage(ts,f)
+        except:
+           print "Unable to open %s" % f
+        else:
+            n = hdr['name']
+            v = hdr['version']
+            r = hdr['release']
+            e = hdr['epoch']
+            a = hdr['arch']
+            if e is None:
+                e = 0
+            newestrpms.setdefault("%s.%s" % (n,a),[])
+            newestrpms["%s.%s" % (n,a)].append((f,n,e,v,r,a))
+
+    for l in newestrpms.values():
+        x = len(l)
+        if x > 1:
+            def sortByEVR(fnevr1, fnevr2):
+                (f1,n1,e1,v1,r1,a1) = fnevr1
+                (f2,n2,e2,v2,r2,a2) = fnevr2
+                rc = rpmUtils.miscutils.compareEVR((e1,v1,r1),(e2,v2,r2))
+                if rc == 0:
+                    return 0
+                if rc > 0:
+                    return -1
+                if rc < 0:
+                    return 1
+            l.sort(sortByEVR)  # highest first in list
+        
+        oldies = []
+        if len(l) > 1:
+            oldies = l[1:]
+        for (f,n,e,v,r,a) in oldies:
+            #print '  Ignoring', os.path.basename(f)
+            rpmfiles.remove(f)
+
+
 def rebuild(dist,srcdir):
     """initialise the pickle files"""
     ts = rpmUtils.transaction.initReadOnlyTransaction()
 
+    rpmfiles = []
     for root, dirs, files in os.walk(srcdir):
         srpms = []
         srpms.extend(fnmatch.filter(files,'*.src.rpm'))
         srpms.extend(fnmatch.filter(files,'*.nosrc.rpm'))
         for f in srpms:
             srcfile = os.path.join(root,f)
-            hdr = rpmUtils.miscutils.hdrFromPackage(ts,srcfile)
-            put(dist,srcfile,ts)
+            rpmfiles.append(srcfile)
+
+    stripold(rpmfiles)
+    for srcfile in rpmfiles:
+        hdr = rpmUtils.miscutils.hdrFromPackage(ts,srcfile)
+        put(dist,srcfile,ts)
 
 
 def putname(dist,name):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]