extras-buildsys/utils/pushscript BlackList.py, NONE, 1.1 Utils.py, 1.9, 1.10 Push.py, 1.28, 1.29

Michael Schwendt (mschwendt) fedora-extras-commits at redhat.com
Fri Feb 9 19:23:45 UTC 2007


Author: mschwendt

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

Modified Files:
	Utils.py Push.py 
Added Files:
	BlackList.py 
Log Message:
- Push.py : move mark_pkg_pushed() to Utils.py for reuse
- Utils.py : add mark_pkg* and unmark_pkg* functions
- BlackList.py : add rudimentary blacklist support



--- NEW FILE BlackList.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 Utils

def get_filtered_build_results(cfg,dist,results):
    # Blacklist file contains one src.rpm %{name} per line.
    blacklist = []
    blname = cfg.project+'-'+dist+'-blacklist.txt'  # e.g. extras-6-blacklist.txt
    try:
        f = open(blname,'r')
        blacklist = f.read().splitlines()
        f.close()
    except IOError, (err, strerr):
        print 'WARNING: %s: %s' % (strerr,blname)
        pass
    
    newresults = []
    for (name,pkgrelroots) in results:
        if name in blacklist:
            for pkgrelroot in pkgrelroots:
                Utils.mark_pkg_excluded(pkgrelroot)
            continue
        newresults.append((name,pkgrelroots))
    return newresults


Index: Utils.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/Utils.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Utils.py	12 Dec 2006 10:58:24 -0000	1.9
+++ Utils.py	9 Feb 2007 19:23:42 -0000	1.10
@@ -274,3 +274,49 @@
         shutil.rmtree(tmpdir)
 
 
+def mark_pkg(pkgrelroot,flag):
+    fname = os.path.join(pkgrelroot,flag)
+    if os.path.isfile(fname):
+        return
+    if DEBUG:
+        print 'Creating %s' % fname
+        return
+    try:
+        f = open(fname,'w')
+        f.close()
+    except IOError, (err, strerr):
+        print 'ERROR: %s: %s' % (strerr,fname)
+        raise IOError, (err, strerr)
+
+
+def unmark_pkg(pkgrelroot,flag):
+    fname = os.path.join(pkgrelroot,flag)
+    if not os.path.isfile(fname):
+        return
+    if DEBUG:
+        print 'Deleting %s' % fname
+        return
+    os.remove(fname)
+
+
+def mark_pkg_pushed(pkgrelroot):
+    """create a file named PUSHED in a package build-results root directory"""
+    mark_pkg(pkgrelroot,'PUSHED')
+    unmark_pkg_excluded(pkgrelroot)
+
+
+def unmark_pkg_pushed(pkgrelroot):
+    """delete a file named PUSHED in a package build-results root directory"""
+    unmark_pkg(pkgrelroot,'PUSHED')
+
+
+def mark_pkg_excluded(pkgrelroot):
+    """create a file named EXCLUDED in a package build-results root directory"""
+    mark_pkg(pkgrelroot,'EXCLUDED')
+
+
+def unmark_pkg_excluded(pkgrelroot):
+    """delete a file named EXCLUDED in a package build-results root directory"""
+    unmark_pkg(pkgrelroot,'EXCLUDED')
+
+


Index: Push.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/Push.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Push.py	8 Feb 2007 18:45:36 -0000	1.28
+++ Push.py	9 Feb 2007 19:23:42 -0000	1.29
@@ -24,7 +24,7 @@
 import tempfile
 import time
 
-import Utils, MultiLib, Comps, WhatsNew
+import Utils, MultiLib, Comps, WhatsNew, BlackList
 import RepoBuild, RepoPrune, RepoView
 from LockFile import LockFile, LockFileLocked
 
@@ -113,22 +113,6 @@
     return rv
 
 
-def mark_pkg_pushed(pkgrelroot):
-    """create a file named PUSHED in a package build-results root directory"""
-    fname = os.path.join(pkgrelroot,'PUSHED')
-    if os.path.isfile(fname):
-        return
-    if DEBUG:
-        print 'Creating %s' % fname
-        return
-    try:
-        f = open(fname,'w')
-        f.close()
-    except IOError, (err, strerr):
-        print 'ERROR: %s: %s' % (strerr,fname)
-        raise IOError, (err, strerr)
-
-
 def prune_needsign_tree(needsignroot):
     for (name,pkgrelroots) in get_build_results(needsignroot):
         validbuilds = pkgrelroots
@@ -151,8 +135,7 @@
                         break
             if changed:
                 print 'New packages in PUSHED %s, clearing flag' % pkgrelroot
-                if not DEBUG:
-                    os.remove(flagname)
+                Utils.unmark_pkg_pushed(pkrelroot)
                 continue
             if ( time.time()-mtime > 3600*48 ):
                 print 'Removing old %s' % pkgrelroot
@@ -199,10 +182,10 @@
             # 1 means: e,v,r is higher than nexte,nextv,nextr
             if rpmUtils.miscutils.compareEVR((e,v,r),(nexte,nextv,nextr)) == 1:
                 Utils.debugprint('Ignoring: %s' % nextrelroot)
-                mark_pkg_pushed(nextrelroot)
+                Utils.mark_pkg_pushed(nextrelroot)
             else:
                 Utils.debugprint('Ignoring: %s' % relroot)
-                mark_pkg_pushed(relroot)
+                Utils.mark_pkg_pushed(relroot)
                 # Make this the next newest package for ongoing comparison.
                 relroot = nextrelroot
                 (n,a,e,v,r) = (nextn,nexta,nexte,nextv,nextr)
@@ -326,7 +309,7 @@
     # if it is a debuginfo package, move it into the 'debug' dir for that arch
 
     if len(filedict['srpm']) != 1:
-        mark_pkg_pushed( os.path.join(needsignroot,name,os.path.basename(pkgrelroot)) )
+        Utils.mark_pkg_pushed( os.path.join(needsignroot,name,os.path.basename(pkgrelroot)) )
         buildreportinfo = '%s-%s : INVALID build results, not published! INV\n' % (name,os.path.basename(pkgrelroot))
         if buildreport:
             rundirfile.write(buildreportinfo)
@@ -347,7 +330,7 @@
         else:
             buildreportinfo = '%s-%s-%s NEW\n' % (n,v,r)
     else:  # src.rpm published before, exclude entire build job
-        mark_pkg_pushed( os.path.join(needsignroot,name,os.path.basename(pkgrelroot)) )
+        Utils.mark_pkg_pushed( os.path.join(needsignroot,name,os.path.basename(pkgrelroot)) )
         buildreportinfo = '%s-%s : INVALID rebuild, not published! INV\n' % (name,os.path.basename(pkgrelroot))
         if buildreport:
             rundirfile.write(buildreportinfo)
@@ -395,7 +378,7 @@
         Utils.install_move(package,destloc)
 
     # Mark successfully signed packages as PUSHED.
-    mark_pkg_pushed( os.path.join(needsignroot,name,os.path.basename(pkgrelroot)) )
+    Utils.mark_pkg_pushed( os.path.join(needsignroot,name,os.path.basename(pkgrelroot)) )
     rollback = []
     if buildreport:
         rundirfile.write(buildreportinfo)
@@ -439,7 +422,7 @@
         
     prune_needsign_tree(needsignroot)
     results = get_build_results(needsignroot,droppushed=True)
-    # TODO: room for black-list checks.
+    results = BlackList.get_filtered_build_results(cfg,dist,results)
     print 'Package directories found: %d' % len(results)
     if len(results) == 0:
         return 0, changed
@@ -658,7 +641,6 @@
             RepoPrune.main(cfg,dist)
         RepoBuild.main(cfg,dist)
 
-    # TODO: multilib resolver hook
     MultiLib.main(cfg,changed)
 
     if changed:




More information about the scm-commits mailing list