[yum-cvs] yum/yum __init__.py,1.337,1.338 yumRepo.py,1.51,1.52

Seth Vidal skvidal at linux.duke.edu
Tue Jul 3 19:24:32 UTC 2007


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

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

check if the .repo file or config files are newer than our mirrorlist or
cachecookie files. If so, then invalidate these files.
idea from florian laroche.


Index: __init__.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/__init__.py,v
retrieving revision 1.337
retrieving revision 1.338
diff -u -r1.337 -r1.338
--- __init__.py	2 Jul 2007 19:40:25 -0000	1.337
+++ __init__.py	3 Jul 2007 19:24:30 -0000	1.338
@@ -140,6 +140,7 @@
 
         startupconf = config.readStartupConfig(fn, root)
 
+        
         if debuglevel != None:
             startupconf.debuglevel = debuglevel
         if errorlevel != None:
@@ -155,11 +156,13 @@
         # run the postconfig plugin hook
         self.plugins.run('postconfig')
         self.yumvar = self.conf.yumvar
+        self.conf.config_file_age = os.stat(fn)[8]
         self.getReposFromConfig()
 
         # who are we:
         self.conf.uid = os.geteuid()
-            
+        
+        
         self.doFileLogSetup(self.conf.uid, self.conf.logfile)
 
         self.plugins.run('init')
@@ -195,10 +198,13 @@
             except (Errors.RepoError, Errors.ConfigError), e:
                 self.logger.warning(e)
             else:
+                thisrepo.repo_config_age = self.conf.config_file_age
                 reposlist.append(thisrepo)
 
         # Read .repo files from directories specified by the reposdir option
         # (typically /etc/yum/repos.d)
+        repo_config_age = self.conf.config_file_age
+        
         parser = ConfigParser()
         for reposdir in self.conf.reposdir:
             if os.path.exists(self.conf.installroot+'/'+reposdir):
@@ -206,6 +212,10 @@
 
             if os.path.isdir(reposdir):
                 for repofn in glob.glob('%s/*.repo' % reposdir):
+                    thisrepo_age = os.stat(repofn)[8]
+                    if thisrepo_age > repo_config_age:
+                        repo_config_age = thisrepo_age
+                        
                     confpp_obj = ConfigPreProcessor(repofn, vars=self.yumvar)
                     try:
                         parser.readfp(confpp_obj)
@@ -220,6 +230,7 @@
             except (Errors.RepoError, Errors.ConfigError), e:
                 self.logger.warning(e)
             else:
+                thisrepo.repo_config_age = repo_config_age
                 reposlist.append(thisrepo)
 
         # Got our list of repo objects, add them to the repos collection
@@ -386,8 +397,10 @@
             return self._up
 
         self.verbose_logger.debug('Building updates object')
-        self._up = rpmUtils.updates.Updates(self.rpmdb.simplePkgList(),
-                                           self.pkgSack.simplePkgList())
+        rpmdb_pkglist = self.rpmdb.simplePkgList()
+        self.rpmdb = None
+        sack_pkglist = self.pkgSack.simplePkgList()
+        self._up = rpmUtils.updates.Updates(rpmdb_pkglist, sack_pkglist)
         if self.conf.debuglevel >= 6:
             self._up.debug = 1
             
@@ -402,7 +415,7 @@
             self._up.doObsoletes()
 
         self._up.condenseUpdates()
-        
+        self.closeRpmDB()
         return self._up
     
     def doGroupSetup(self):
@@ -1023,7 +1036,8 @@
             for po in self.rpmdb:
                 dinst[po.pkgtup] = po;
             installed = dinst.values()
-
+            self.closeRpmDB()
+            
             if self.conf.showdupesfromrepos:
                 avail = self.pkgSack.returnPackages()
             else:

Index: yumRepo.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/yumRepo.py,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- yumRepo.py	2 Jul 2007 19:40:25 -0000	1.51
+++ yumRepo.py	3 Jul 2007 19:24:30 -0000	1.52
@@ -224,7 +224,8 @@
         self.metadata_cookie_fn = 'cachecookie'
         self.groups_added = False
         self.http_headers = {}
-        
+        self.repo_config_age = 0 # if we're a repo not from a file then the 
+                                 # config is very, very old
         # throw in some stubs for things that will be set by the config class
         self.basecachedir = ""
         self.cachedir = ""
@@ -628,6 +629,9 @@
            the cachecookie and the mirrorlist
            return True if w/i the expiration time limit
            false if the time limit has expired
+           
+           Additionally compare the file to age of the newest .repo or yum.conf 
+           file. If any of them are newer then invalidate the cache
            """
 
         val = False
@@ -638,8 +642,14 @@
             # WE ARE FROM THE FUTURE!!!!
             elif cookie_info[8] > time.time():
                 val = False
+            
+            # make sure none of our config files for this repo are newer than
+            # us
+            if cookie_info[8] < int(self.repo_config_age):
+                val = False
+
         return val
-           
+    
     def setMetadataCookie(self):
         """if possible, set touch the metadata_cookie file"""
 




More information about the Yum-cvs-commits mailing list