[yum-cvs] yum/yum __init__.py,1.248,1.249 packages.py,1.67,1.68

Seth Vidal skvidal at linux.duke.edu
Fri Sep 8 21:05:18 UTC 2006


Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv24445/yum

Modified Files:
	__init__.py packages.py 
Log Message:

partial check in just to get it off my laptop:

1. do check for space in cache dir for downloading packages
2. start changing around the way packages are checked


Index: __init__.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/__init__.py,v
retrieving revision 1.248
retrieving revision 1.249
diff -u -r1.248 -r1.249
--- __init__.py	8 Sep 2006 17:06:26 -0000	1.248
+++ __init__.py	8 Sep 2006 21:05:16 -0000	1.249
@@ -575,23 +575,21 @@
 
         if type(fo) is types.InstanceType:
             fo = fo.filename
-        (csum_type, csum) = po.returnIdSum()
-        try:
-            self.verifyChecksum(fo, checksumType, checksum)
-        except URLGrabError, e:
+            
+        if not po.verifyLocalPkg():
             if raiseError:
-                raise
+                raise 
             else:
-                return 0
+                return False
 
         ylp = YumLocalPackage(self.rpmdb.readOnlyTS(), fo)
         if ylp.pkgtup != po.pkgtup:
             if raiseError:
                 raise URLGrabError(-1, 'Package does not match intended download')
             else:
-                return 0
+                return False
         
-        return 1
+        return True
         
         
     def verifyChecksum(self, fo, checksumType, csum):
@@ -625,26 +623,16 @@
             if os.path.exists(local):
                 cursize = os.stat(local)[6]
                 totsize = int(po.size)
-                try:
-                    result = self.verifyPkg(local, po, raiseError=1)
-                except URLGrabError, e: # fails the check
-                    
-                    repo = self.repos.getRepo(po.repoid)
-                    if repo.cache:
+                if not po.verifyLocalPkg():
+                    if po.repo.cache:
                         repo_cached = True
-                        msg = 'package fails checksum but caching is enabled for %s' % repo.id
+                        msg = 'package fails checksum but caching is enabled for %s' % po.repo.id
                         if not errors.has_key(po): errors[po] = []
                         errors[po].append(msg)
                         
-                    if cursize >= totsize: # keep it around for regetting
+                    if cursize >= totsize: # otherwise keep it around for regetting
                         os.unlink(local)
                         
-                else:
-                    if result:
-                        continue
-                    else:
-                        if cursize >= totsize: # keep it around for regetting
-                            os.unlink(local)
             remote_pkgs.append(po)
             
             # caching is enabled and the package 
@@ -657,21 +645,20 @@
         i = 0
         for po in remote_pkgs:
             i += 1
-            repo = self.repos.getRepo(po.repoid)
             checkfunc = (self.verifyPkg, (po, 1), {})
-
-
-            # FIXME - add check here to make sure we have the disk space
-            # available to download the package. If we don't then politely
-            # bail out with an informative message.
-            # os.statvfs(repo's local path)[4]*[2] >= po.size
+            stvfs = os.statvfs(po.repo.pkgdir)
+            if stvfs[4] * stvfs[0] <= po.size:
+                msg = "Insufficient space in download directory %s to download" % po.repo.pkgdir
+                errors[po].append(msg)
+                continue
+            
             try:
                 text = '(%s/%s): %s' % (i, len(remote_pkgs),
                                         os.path.basename(po.returnSimple('relativepath')))
-                mylocal = repo.getPackage(po,
+                mylocal = po.repo.getPackage(po,
                                    checkfunc=checkfunc,
                                    text=text,
-                                   cache=repo.http_caching != 'none',
+                                   cache=po.repo.http_caching != 'none',
                                    )
             except Errors.RepoError, e:
                 if not errors.has_key(po):

Index: packages.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/packages.py,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- packages.py	8 Sep 2006 17:06:26 -0000	1.67
+++ packages.py	8 Sep 2006 21:05:16 -0000	1.68
@@ -419,7 +419,6 @@
     def localPkg(self):
         """return path to local package (whether it is present there, or not)"""
         if not hasattr(self, 'localpath'):
-            #repo = base.repos.getRepo(self.repoid)
             remote = self.returnSimple('relativepath')
             rpmfn = os.path.basename(remote)
             self.localpath = self.repo.pkgdir + '/' + rpmfn
@@ -430,7 +429,6 @@
            byte ranges"""
            
         if not hasattr(self, 'hdrpath'):
-            #repo = base.repos.getRepo(self.repoid)
             pkgpath = self.returnSimple('relativepath')
             pkgname = os.path.basename(pkgpath)
             hdrname = pkgname[:-4] + '.hdr'
@@ -438,6 +436,22 @@
 
         return self.hdrpath
     
+    def verifyLocalPkg(self):
+        """check the package checksum vs the localPkg
+           return True if pkg is good, False if not"""
+           
+        (csum_type, csum) = self.returnIdSum()
+        
+        try:
+            filesum = misc.checksum(csum_type, self.localPkg())
+        except Errors.MiscError, e:
+            return False
+        
+        if filesum != csum:
+            return False
+        
+        return True
+        
     def prcoPrintable(self, prcoTuple):
         """convert the prco tuples into a nicer human string"""
         warnings.warn('prcoPrintable() will go away in a future version of Yum.\n',




More information about the Yum-cvs-commits mailing list