extras-buildsys/utils/pushscript BuildSys.py, NONE, 1.1 BlackList.py, 1.2, 1.3 List.py, 1.2, 1.3 Utils.py, 1.11, 1.12 Push.py, 1.33, 1.34

Michael Schwendt (mschwendt) fedora-extras-commits at redhat.com
Tue Feb 27 23:11:05 UTC 2007


Author: mschwendt

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

Modified Files:
	BlackList.py List.py Utils.py Push.py 
Added Files:
	BuildSys.py 
Log Message:
Commit the changes I've used during the past days in a private
directory that make it possible to run extras-repoclosure on
temporary repositories created from the needsign tree.

- Access to the build results (get_build_results, prune_build_results,
and friends) move to a BuildSys class and are implemented for the
local plague-results tree.

- Individual build-job results information moves into BuildResults
objects. Build results, when copied to a tempdir, still know about
their original location in the needsign tree (unless this
connection is deleted deliberately).




--- NEW FILE BuildSys.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

## Build job results interface
## implemented for local plague-results needsign tree.

import errno, os, sys
import fnmatch, shutil, time

import Utils

DEBUG = False
Utils.setdebug(DEBUG)


class BuildSys:
    
    def GetBuildResults(self):
        pass
    
    def PruneBuildResults(self):
        pass


class LocalPlague(BuildSys):
    
    def __init__(self,needsignroot):
        self.needsignroot = needsignroot

    def GetBuildResults(self):
        rv = []
        for (name,jobroots) in self._ListPlagueResults(True):
            for path in jobroots:
                br = BuildResults(name,path)
                rv.append(br)

        def sortbyname(a,b):
            return cmp(a.__str__(),b.__str__())
        rv.sort(sortbyname)
        return rv

    def _ListPlagueResults(self,droppushed=False):
        """returns list of (name,[jobroots]) tuples for available build-results, where every "jobroot" is the path to a build-job results directory"""
        # The needsign repository root contains a directory "name" for
        # every built src.rpm package %{name}.
        d = os.listdir(self.needsignroot)
        try:
            d.remove('repodata')
        except ValueError:
            pass

        rv = []  # return value: list of (name,[jobroots]) tuples
        for name in d:
            pkgroot = os.path.join(self.needsignroot,name)
            if not os.path.isdir(pkgroot):
                continue
            jobroots = []
            # Every built version-release is stored in an own sub-dir of "name".
            # e.g.  ./foo/1.0-1  ./foo/1.0-2
            for pkgrelroot in map(lambda f: os.path.join(pkgroot,f), os.listdir(pkgroot)):
                if os.path.isdir(pkgrelroot):
                    if droppushed and os.path.isfile(os.path.join(pkgrelroot,'PUSHED')):
                        continue
                    jobroots.append(pkgrelroot)
            if jobroots or not droppushed:
                rv.append( (name,jobroots) )
        return rv

    def PruneBuildResults(self):
        for (name,pkgrelroots) in self._ListPlagueResults():
            validbuilds = pkgrelroots
        
            # Delete those builds which are marked as PUSHED and old enough.
            for pkgrelroot in pkgrelroots:
                flagname = os.path.join(pkgrelroot,'PUSHED')
                if not os.path.isfile(flagname):
                    continue
                mtime = os.path.getmtime(flagname)
                # Check if there are *.rpm newer than the flag
                # (When exactly is that possible? old-style kernel mods?)
                changed = False
                for root, dirs, files in os.walk(pkgrelroot):
                    if changed:
                        break
                    for f in fnmatch.filter(files, '*.rpm'):
                        if os.path.getmtime(os.path.join(root, f)) > mtime:
                            changed = True
                            break
                if changed:
                    print 'New packages in PUSHED %s, clearing flag' % pkgrelroot
                    Utils.unmark_pkg_pushed(pkgrelroot)
                    continue
                if ( time.time()-mtime > 3600*48 ):
                    print 'Removing old %s' % pkgrelroot
                    if not DEBUG:
                        shutil.rmtree(pkgrelroot)
                    validbuilds.remove(pkgrelroot)

            # Now re-examine the remaining builds and mark unneeded ones as PUSHED.
            # TODO: white-list some packages, such as "kmod-*"?
            pkgrelroots = validbuilds
            pkgroot = os.path.join(self.needsignroot,name)
            if len(pkgrelroots) < 2: # only one release or empty dir
                # Clean up empty package name directories.
                if not len(pkgrelroots):
                    try:
                        Utils.debugprint('Removing empty directory %s' % pkgroot)
                        if not DEBUG:
                            os.rmdir(pkgroot)
                    except OSError, e:
                        print e
                        pass
                continue  # with next name
            Utils.debugprint( '%s release(s) for %s: %s' % (len(pkgrelroots),name,' '.join(map(lambda f: os.path.basename(f),pkgrelroots))) )
            # We assume this release to be the newest.
            relroot = pkgrelroots[0]
            # There can be only one src.rpm in this dir, since relroot
            # and src.rpm filename are unique (due to NVR).
            srcrpms = Utils.find_files(relroot,'*.src.rpm')
            srcrpms.extend(Utils.find_files(relroot,'*.nosrc.rpm'))
            # Currently, directories can be empty though, unless we clean up
            # the repodir regularly.
            if not len(srcrpms):
                continue
            srcrpm = srcrpms[0]
            (n,a,e,v,r) = Utils.naevr(srcrpm)
            # Now compare with the other releases.
            for nextrelroot in pkgrelroots[1:]:
                nextsrcrpms = Utils.find_files(nextrelroot,'*.src.rpm')
                nextsrcrpms.extend(Utils.find_files(nextrelroot,'*.nosrc.rpm'))
                if not len(nextsrcrpms):
                    continue
                nextsrcrpm = nextsrcrpms[0]
                (nextn,nexta,nexte,nextv,nextr) = Utils.naevr(nextsrcrpm)
                # 1 means: e,v,r is higher than nexte,nextv,nextr
                if Utils.compareEVR((e,v,r),(nexte,nextv,nextr)) == 1:
                    Utils.debugprint('Ignoring: %s' % nextrelroot)
                    Utils.mark_pkg_pushed(nextrelroot)
                else:
                    Utils.debugprint('Ignoring: %s' % 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)


class BuildResults:

    def __init__(self,name,home):
        self.name = name  # src.rpm %{name}
        self.home = home
        self.origin = home  # original home
        self.pkgid = self.name+'-'+os.path.basename(self.home)  # plague-results style

    def __str__(self):
        return self.pkgid

    def GetName(self):
        return self.name
    
    def GetHome(self):
        return self.home

    def SetHome(self,home):
        self.home = home
    
#    def GetSourcePkg(self):
#        pass

#    def IsPushed(self):
#        return False

    def MarkPushed(self):
        if self.origin:
            Utils.mark_pkg(self.origin,'PUSHED')
            Utils.unmark_pkg(self.origin,'EXCLUDED')

    def MarkExcluded(self):
        if self.origin:
            Utils.mark_pkg(self.origin,'EXCLUDED')




Index: BlackList.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/BlackList.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BlackList.py	9 Feb 2007 19:33:36 -0000	1.2
+++ BlackList.py	27 Feb 2007 23:11:02 -0000	1.3
@@ -31,10 +31,9 @@
         pass
     
     newresults = []
-    for (name,pkgrelroots) in results:
-        if name in blacklist:
-            for pkgrelroot in pkgrelroots:
-                Utils.mark_pkg_excluded(pkgrelroot)
+    for br in results:
+        if br.GetName() in blacklist:
+            br.MarkExcluded()
             continue
-        newresults.append((name,pkgrelroots))
+        newresults.append(br)
     return newresults


Index: List.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/List.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- List.py	8 Feb 2007 17:25:15 -0000	1.2
+++ List.py	27 Feb 2007 23:11:02 -0000	1.3
@@ -17,7 +17,8 @@
 
 import errno, os, sys
 
-import Utils, Push
+import Utils
+from BuildSys import LocalPlague
 
 
 def main(cfg,dists):
@@ -28,10 +29,10 @@
         distdir = '%s-%s-%s' % (cfg.distro, dist, cfg.project)
         print distdir+':'
         needsignroot = os.path.join(cfg.stagesdir, distdir)
-        results = Push.get_build_results(needsignroot,droppushed=True)
-        for (name,pkgrelroots) in results:
-            for pkgrelroot in pkgrelroots:
-                print '    '+name+'-'+os.path.basename(pkgrelroot)
+        bs = LocalPlague(needsignroot)
+        results = bs.GetBuildResults()
+        for br in results:
+            print '   ', br
         print
 
 


Index: Utils.py
===================================================================
RCS file: /cvs/fedora/extras-buildsys/utils/pushscript/Utils.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Utils.py	21 Feb 2007 20:47:53 -0000	1.11
+++ Utils.py	27 Feb 2007 23:11:02 -0000	1.12
@@ -20,8 +20,10 @@
 import os, sys
 import shutil
 import stat, tempfile
+import rpmUtils
 
 compsname = 'comps.xml'
+ts = rpmUtils.transaction.initReadOnlyTransaction()
 
 DEBUG = False
 
@@ -280,6 +282,38 @@
         shutil.rmtree(tmpdir)
 
 
+def naevr(pkg):
+    """return nevra from the package srpm"""
+    try:
+        hdr = rpmUtils.miscutils.hdrFromPackage(ts, pkg)
+    except rpmUtils.RpmUtilsError:
+        print 'WARNING: %s is BAD' % pkg
+        raise
+    name = hdr['name']
+    ver = hdr['version']
+    rel = hdr['release']
+    arch = hdr['arch']
+    epoch = hdr['epoch']
+    if epoch is None:
+        epoch = 0
+    return (name, arch, epoch, ver, rel)
+
+
+def compareEVR(tup1,tup2):
+    return rpmUtils.miscutils.compareEVR(tup1,tup2)
+
+
+def find_files(rootpath,pattern='*'):
+    """returns list of paths in given tree which point to a file matching the fnmatch pattern"""
+    rv = []
+    if not os.path.isdir(rootpath):
+        return rv
+    for root, dirs, files in os.walk(rootpath):
+        for f in fnmatch.filter(files,pattern):
+            rv.append(os.path.join(root,f))
+    return rv
+
+
 def mark_pkg(pkgrelroot,flag):
     fname = os.path.join(pkgrelroot,flag)
     if os.path.isfile(fname):
@@ -305,24 +339,3 @@
     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.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- Push.py	26 Feb 2007 11:57:45 -0000	1.33
+++ Push.py	27 Feb 2007 23:11:02 -0000	1.34
@@ -28,6 +28,7 @@
 import Utils, MultiLib, Comps, WhatsNew, BlackList
 import RepoBuild, RepoPrune, RepoView
 from LockFile import LockFile, LockFileLocked
+from BuildSys import LocalPlague
 
 DEBUG = False
 Utils.setdebug(DEBUG)
@@ -75,142 +76,6 @@
 
 # ====================================================================
 
-def get_build_results(path,droppushed=False):
-    """returns list of (name,[jobroots]) tuples for available build-results, where every "jobroot" is the path to a build-job results directory"""
-    # The needsign repository root contains a directory "name" for
-    # every built src.rpm package %{name}.
-    d = os.listdir(path)
-    try:
-        d.remove('repodata')
-    except ValueError:
-        pass
-
-    rv = []  # return value: list of (name,[jobroots]) tuples
-    for name in d:
-        pkgroot = os.path.join(path,name)
-        if not os.path.isdir(pkgroot):
-            continue
-        jobroots = []
-        # Every built version-release is stored in an own sub-dir of "name".
-        # e.g.  ./foo/1.0-1  ./foo/1.0-2
-        for pkgrelroot in map(lambda f: os.path.join(pkgroot,f), os.listdir(pkgroot)):
-            if os.path.isdir(pkgrelroot):
-                if droppushed and os.path.isfile(os.path.join(pkgrelroot,'PUSHED')):
-                    continue
-                jobroots.append(pkgrelroot)
-        if jobroots or not droppushed:
-            rv.append( (name,jobroots) )
-    return rv
-
-
-def find_files(rootpath,pattern='*'):
-    """returns list of paths in given tree which point to a file matching the fnmatch pattern"""
-    rv = []
-    if not os.path.isdir(rootpath):
-        return rv
-    for root, dirs, files in os.walk(rootpath):
-        for f in fnmatch.filter(files,pattern):
-            rv.append(os.path.join(root,f))
-    return rv
-
-
-def prune_needsign_tree(needsignroot):
-    for (name,pkgrelroots) in get_build_results(needsignroot):
-        validbuilds = pkgrelroots
-        
-        # Delete those builds which are marked as PUSHED and old enough.
-        for pkgrelroot in pkgrelroots:
-            flagname = os.path.join(pkgrelroot,'PUSHED')
-            if not os.path.isfile(flagname):
-                continue
-            mtime = os.path.getmtime(flagname)
-            # Check if there are *.rpm newer than the flag
-            # (When exactly is that possible? old-style kernel mods?)
-            changed = False
-            for root, dirs, files in os.walk(pkgrelroot):
-                if changed:
-                    break
-                for f in fnmatch.filter(files, '*.rpm'):
-                    if os.path.getmtime(os.path.join(root, f)) > mtime:
-                        changed = True
-                        break
-            if changed:
-                print 'New packages in PUSHED %s, clearing flag' % pkgrelroot
-                Utils.unmark_pkg_pushed(pkgrelroot)
-                continue
-            if ( time.time()-mtime > 3600*48 ):
-                print 'Removing old %s' % pkgrelroot
-                if not DEBUG:
-                    shutil.rmtree(pkgrelroot)
-                validbuilds.remove(pkgrelroot)
-
-        # Now re-examine the remaining builds and mark unneeded ones as PUSHED.
-        # TODO: white-list some packages, such as "kmod-*"?
-        pkgrelroots = validbuilds
-        pkgroot = os.path.join(needsignroot,name)
-        if len(pkgrelroots) < 2: # only one release or empty dir
-            # Clean up empty package name directories.
-            if not len(pkgrelroots):
-                try:
-                    Utils.debugprint('Removing empty directory %s' % pkgroot)
-                    if not DEBUG:
-                        os.rmdir(pkgroot)
-                except OSError, e:
-                    print e
-                    pass
-            continue  # with next name
-        Utils.debugprint( '%s release(s) for %s: %s' % (len(pkgrelroots),name,' '.join(map(lambda f: os.path.basename(f),pkgrelroots))) )
-        # We assume this release to be the newest.
-        relroot = pkgrelroots[0]
-        # There can be only one src.rpm in this dir, since relroot
-        # and src.rpm filename are unique (due to NVR).
-        srcrpms = find_files(relroot,'*.src.rpm')
-        srcrpms.extend(find_files(relroot,'*.nosrc.rpm'))
-        # Currently, directories can be empty though, unless we clean up
-        # the repodir regularly.
-        if not len(srcrpms):
-            continue
-        srcrpm = srcrpms[0]
-        (n,a,e,v,r) = naevr(srcrpm)
-        # Now compare with the other releases.
-        for nextrelroot in pkgrelroots[1:]:
-            nextsrcrpms = find_files(nextrelroot,'*.src.rpm')
-            nextsrcrpms.extend(find_files(nextrelroot,'*.nosrc.rpm'))
-            if not len(nextsrcrpms):
-                continue
-            nextsrcrpm = nextsrcrpms[0]
-            (nextn,nexta,nexte,nextv,nextr) = naevr(nextsrcrpm)
-            # 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)
-                Utils.mark_pkg_pushed(nextrelroot)
-            else:
-                Utils.debugprint('Ignoring: %s' % 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)
-
-
-def naevr(pkg):
-    """return nevra from the package srpm"""
-
-    try:
-        hdr = rpmUtils.miscutils.hdrFromPackage(ts, pkg)
-    except rpmUtils.RpmUtilsError:
-        print 'WARNING: %s is BAD' % pkg
-        raise
-    name = hdr['name']
-    ver = hdr['version']
-    rel = hdr['release']
-    arch = hdr['arch']
-    epoch = hdr['epoch']
-    if epoch is None:
-        epoch = 0
-    
-    return (name, arch, epoch, ver, rel)
-
-
 def getexcludearch(pkgpath,reporoot):
     """Returns list of excluded archs for a binary rpm.
     Needs access to the repository root directory where it
@@ -256,12 +121,15 @@
 class PushWarning(Exception):
     pass
 
+class PushFatal(Exception):
+    pass
+
 
-def push(dist,needsignroot,destroot,name,pkgrelroot,buildreport=True):
+def push(br,dist,destroot,buildreport=True):
     """push the files found within a single package build-results directory"""
     rollback = []
     try:
-        push_with_rollback(rollback,dist,needsignroot,destroot,name,pkgrelroot,buildreport)
+        push_with_rollback(rollback,br,dist,destroot,buildreport)
     except:
         print 'Rollback:', rollback
         for f in rollback:
@@ -274,16 +142,17 @@
         raise
 
 
-def push_with_rollback(rollback,dist,needsignroot,destroot,name,pkgrelroot,buildreport):
-    print '  %s-%s' % (name,os.path.basename(pkgrelroot))
-    
+def push_with_rollback(rollback,br,dist,destroot,buildreport):
+    print ' ', br
+
+    ## TODO: create and validate in BuildResults class
     filedict = {}
     filedict['srpm'] = []
     filedict['rpm'] = []
     filedict['debuginfo'] = []
     filedict['other'] = []
     # Match the build-results files to what list they should be in.
-    for file in find_files(pkgrelroot):
+    for file in Utils.find_files( br.GetHome() ):
         if file.endswith('.rpm'):
             if file.find('debuginfo') != -1:
                 which = 'debuginfo' 
@@ -310,15 +179,15 @@
     # if it is a debuginfo package, move it into the 'debug' dir for that arch
 
     if len(filedict['srpm']) != 1:
-        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))
+        br.MarkPushed()
+        buildreportinfo = '%s : INVALID build results, not published! INV\n' % br
         if buildreport:
             rundirfile.write(buildreportinfo)
         rundirfile.close()
-        raise PushWarning, 'WARNING: %d source rpms in %s' % (len(filedict['srpm']),pkgrelroot)
+        raise PushWarning, 'WARNING: %d source rpms in %s' % (len(filedict['srpm']),br.GetHome())
     
     package = filedict['srpm'][0]
-    (n,a,e,v,r) = naevr(package)
+    (n,a,e,v,r) = Utils.naevr(package)
     pkg_fn = os.path.basename(package)
     global srpmlocdict  # debug only
     srpmlocdict[pkg_fn] = package  # debug only
@@ -326,13 +195,13 @@
     if not os.path.exists(destloc):
         rollback.append(destloc)
         Utils.install_move(package,destloc)
-        if WhatsNew.get(dist,name):
+        if WhatsNew.get(dist,n):
             buildreportinfo = '%s-%s-%s\n' % (n,v,r)
         else:
             buildreportinfo = '%s-%s-%s NEW\n' % (n,v,r)
     else:  # src.rpm published before, exclude entire build job
-        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))
+        br.MarkPushed()
+        buildreportinfo = '%s : INVALID rebuild, not published! INV\n' % br
         if buildreport:
             rundirfile.write(buildreportinfo)
         rundirfile.close()
@@ -342,7 +211,7 @@
         pkg_fn = pkg_destfn = os.path.basename(package)
         if package in filedict['debuginfo']:
             pkg_destfn = 'debug/' + pkg_fn
-        (n,a,e,v,r) = naevr(package)
+        (n,a,e,v,r) = Utils.naevr(package)
 
         if a == 'noarch':
             excludearch = getexcludearch(package,destroot)
@@ -379,7 +248,7 @@
         Utils.install_move(package,destloc)
 
     # Mark successfully signed packages as PUSHED.
-    Utils.mark_pkg_pushed( os.path.join(needsignroot,name,os.path.basename(pkgrelroot)) )
+    br.MarkPushed()
     rollback = []
     if buildreport:
         rundirfile.write(buildreportinfo)
@@ -421,8 +290,9 @@
         print "ERROR: lockfile %s failure: %s (error %d)" % (repolockname, strerr, err)
         sys.exit(err)
         
-    prune_needsign_tree(needsignroot)
-    results = get_build_results(needsignroot,droppushed=True)
+    bs = LocalPlague(needsignroot)
+    bs.PruneBuildResults()
+    results = bs.GetBuildResults()
     results = BlackList.get_filtered_build_results(cfg,dist,results)
     results = apply_whitelist(results,whitelist)
     print 'Package directories found: %d' % len(results)
@@ -434,21 +304,18 @@
     if signtmpdir == cfg.treedir: # paranoid, should never happen
         sys.exit(errno.EPERM)
     try:
-        for (name,pkgrelroots) in results:
-            destpkgroot = os.path.join(signtmpdir,name)
-            if not os.path.exists(destpkgroot):
-                os.makedirs(destpkgroot)
-            for pkgrelroot in pkgrelroots:
-                vr = os.path.basename(pkgrelroot)
-                print '  %s-%s' % (name,vr)
-                shutil.copytree(pkgrelroot,os.path.join(destpkgroot,vr))
+        for br in results:
+            print ' ', br
+            newhome = os.path.join(signtmpdir,br.__str__())
+            shutil.copytree(br.GetHome(),newhome)
+            br.SetHome(newhome)
     except: # everything is fatal
         print 'ERROR: Creating temporary working copy failed.'
         shutil.rmtree(signtmpdir)
         raise
 
     # Now we have a temporary copy of everything from the needsign repository
-    # we want. Build results as  ./foo/1.0-1/  directories in signtmpdir.
+    # we want.
     repolock.unlock()
 
     try:
@@ -456,44 +323,42 @@
         
         print "Signing Packages:"
         while (True):
-            rv = sign_pkgs( find_files(signtmpdir,'*.rpm') )
+            rv = sign_pkgs( Utils.find_files(signtmpdir,'*.rpm') )
             if not rv:
                 break
             while (True):
                 print 'Retry? (y/n)',
                 a = raw_input().lower()
                 if a=='n':
-                    raise Exception
+                    raise PushFatal
                 if a=='y':
                     break
 
-
         print "Copying packages into repositories:"
         global srpmlocdict
         srpmlocdict = {} # debug only
-        results = get_build_results(signtmpdir)
-        for (name,pkgrelroots) in results:
-            for pkgrelroot in pkgrelroots:
-                if name in cfg.diversion_dict:  # install this elsewhere?
-                    buildreport = False
-                    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
-                    targetroot = destroot
-                try:
-                    push(dist,needsignroot,targetroot,name,pkgrelroot,buildreport)
-                # TODO: report these via mail (or so)
-                except PushWarning, e:
-                    print e
-                except rpmUtils.RpmUtilsError, e:
-                    print e
+        for br in results:
+            name = br.GetName()
+            if name in cfg.diversion_dict:  # install this elsewhere?
+                buildreport = False
+                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
+                targetroot = destroot
+            try:
+                push(br,dist,targetroot,buildreport)
+            # TODO: report these via mail (or so)
+            except PushWarning, e:
+                print e
+            except rpmUtils.RpmUtilsError, e:
+                print e
             WhatsNew.set(dist,name)
         
         WhatsNew.save(cfg.rundir)
-    except Exception:
+    except PushFatal:
         shutil.rmtree(signtmpdir)
         sys.exit(1)
     except:
@@ -516,10 +381,10 @@
 
 def apply_whitelist(results, whitelist):
     newresults = []
-    for (name,pkgrelroots) in results:
+    for br in results:
         for r in whitelist:
-            if re.compile('^'+r+'$').search(name):
-                newresults.append((name,pkgrelroots))
+            if re.compile('^'+r+'$').search(br.GetName()):
+                newresults.append(br)
                 continue
     return newresults
 




More information about the fedora-extras-commits mailing list