extras-repoclosure rc-modified,1.18,1.19

Michael Schwendt (mschwendt) fedora-extras-commits at redhat.com
Tue Feb 19 12:13:12 UTC 2008


Author: mschwendt

Update of /cvs/fedora/extras-repoclosure
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22700

Modified Files:
	rc-modified 
Log Message:
Merge portability changes for yum/rpmUtils API changes.
It now runs on F8 down to EL4. On EL4 it warns if checkForObsolete()
is missing.




Index: rc-modified
===================================================================
RCS file: /cvs/fedora/extras-repoclosure/rc-modified,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- rc-modified	23 Oct 2007 11:22:22 -0000	1.18
+++ rc-modified	19 Feb 2008 12:13:11 -0000	1.19
@@ -15,7 +15,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 # seth vidal 2005 (c) etc etc
-
+# mschwendt: modified for Fedora Extras buildsys
 
 #Read in the metadata of a series of repositories and check all the
 #   dependencies in all packages for resolution. Print out the list of
@@ -26,7 +26,7 @@
 
 # For patched "yum" and "rpmUtils" (post 2.6.1 checkForObsolete support).
 # Comment this to use system yum.
-sys.path.insert(0,'/srv/extras-push/work/buildsys-utils/pushscript')
+#sys.path.insert(0,'/srv/extras-push/work/buildsys-utils/pushscript')
 
 import yum
 import yum.Errors
@@ -34,7 +34,10 @@
 from optparse import OptionParser
 import rpmUtils.arch
 from yum.constants import *
-from repomd.packageSack import ListPackageSack
+if yum.__version__ < '3.0':  # TODO: check
+    from repomd.packageSack import ListPackageSack
+else:
+    from yum.packageSack import ListPackageSack
 
 
 def parseArgs():
@@ -62,7 +65,10 @@
         yum.YumBase.__init__(self)
 
         self.arch = arch
-        self.doConfigSetup(fn = config)
+        if yum.__version__ < '3.0':  # TODO: check
+            self.doConfigSetup(fn = config)
+        else:
+            self.doConfigSetup(fn = config, init_plugins = False)
         if hasattr(self.repos, 'sqlite'):
             self.repos.sqlite = False
             self.repos._selectSackType()
@@ -89,16 +95,22 @@
         self.doRepoSetup()
         self.doSackSetup(rpmUtils.arch.getArchList(self.arch))
         for repo in self.repos.listEnabled():
-            self.repos.populateSack(which=[repo.id], with='filelists')
+            try:  # TODO: when exactly did this change to "mdtype"?
+                self.repos.populateSack(which=[repo.id], mdtype='filelists')
+            except TypeError:
+                self.repos.populateSack(which=[repo.id], with='filelists')
 
     def getBrokenDeps(self, newest=False):
         unresolved = {}
         resolved = {}
         newpkgtuplist = []
         if newest:
-            pkgs = []
-            for l in self.pkgSack.returnNewestByName():
-                pkgs.extend(l)
+            if yum.__version__ >= '2.9':  # TODO: check
+                pkgs = self.pkgSack.returnNewestByName()
+            else:
+                pkgs = []
+                for l in self.pkgSack.returnNewestByName():
+                    pkgs.extend(l)
             newestpkgtuplist = ListPackageSack(pkgs).simplePkgList()
 
             pkgs = self.pkgSack.returnNewestByNameArch()
@@ -116,14 +128,19 @@
         self.up = rpmUtils.updates.Updates([],pkgtuplist)
         self.up.rawobsoletes = mypkgSack.returnObsoletes()
 
+        haveCheckForObsolete = hasattr(rpmUtils.updates.Updates,'checkForObsolete')
+        if not haveCheckForObsolete:
+            print 'WARNING: rpmUtils.updates.checkForObsolete missing!'
+
         for pkg in pkgs:
             thispkgobsdict = {}
-            try:
-                thispkgobsdict = self.up.checkForObsolete([pkg.pkgtup])
-                if thispkgobsdict.has_key(pkg.pkgtup):
-                    continue
-            except:
-                pass
+            if haveCheckForObsolete:
+                try:
+                    thispkgobsdict = self.up.checkForObsolete([pkg.pkgtup])
+                    if thispkgobsdict.has_key(pkg.pkgtup):
+                        continue
+                except AttributeError:
+                    pass
 
             def isnotnewest(pkg):
                 # Handle noarch<->arch switches in package updates, so any
@@ -170,12 +187,13 @@
                         # which are not obsolete. If no provider is left, the
                         # dep is unresolved.
                         thispkgobsdict = {}
-                        try:
-                            thispkgobsdict = self.up.checkForObsolete([po.pkgtup])
-                            if thispkgobsdict.has_key(po.pkgtup):
-                                continue
-                        except:
-                            pass
+                        if haveCheckForObsolete:
+                            try:
+                                thispkgobsdict = self.up.checkForObsolete([po.pkgtup])
+                                if thispkgobsdict.has_key(po.pkgtup):
+                                    continue
+                            except AttributeError:
+                                pass
                         
                         if po.pkgtup in pkgtuplist:
                             resolved_by_newest = True




More information about the fedora-extras-commits mailing list