-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Clark Williams wrote:
> Michael E Brown wrote:
>> On Fri, Feb 29, 2008 at 09:58:35AM -0600, Clark Williams wrote:
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> Michael,
>>>
>>> I was looking at BZ  233529 on mock and was wondering if the requested 
>>> behavior seems
>>> valid (it does to me, just wanted a sanity check).
>>>
>>> As far as I can tell, the only time the root cache is invalidated is when 
>>> it ages out
>>> (was looking at the plugin). 
>> This is correct.
> 
>>> Does it make sense to also invalidate the cache when the
>>> .cfg that defines it has a newer modification time?
>> Makes perfect sense. May be somewhat difficult to implement, I'm not
>> sure we store the config file name anywhere that the plugin can get to
>> it. 
>> --
>> Michael
> 
> Here's a way to do it.
> 
> One thing that wasn't immediately apparent to me, but became clear when I 
> started
> installing/debugging was that everytime you install a new mock rpm, the cfg 
> file will
> have a timestamp newer than any existing root-cache file, which means with 
> this patch
> each root-cache will be rebuilt. This seems like a reasonable thing to do 
> (rebuild
> the caches after installing a new mock), but I wonder if it will break 
> anything?
> 
> Clark
> 

Michael,

Following our IRC conversation, where you expressed admiration and unreserved 
joy at
the ability to update the cache after an install (maybe I overstate a bit), I
modified the patch to check the timestamp of both the config file and the
site-default.cfg file. I think this does the job in that after an install, the 
cache
is rebuilt because of an updated site-defaults.cfg and if you touch the config 
file
it's also detected.

Clark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkfIdWYACgkQHyuj/+TTEp1mFQCg2Ckelz5scAG73j+nSBJxxzS2
2cAAoN60hJOAcBF0x1UlFxWVtQM9M1pt
=Vutc
-----END PGP SIGNATURE-----
diff --git a/py/mock.py b/py/mock.py
index d5afbbe..a48ffe2 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -425,9 +425,13 @@ def main(ret):
     if options.configdir:
         config_path = options.configdir
 
+    # save for use in Root object
+    config_opts['config_paths'] = []
+
     # Read in the config files: default, and then user specified
     for cfg in ( os.path.join(config_path, 'site-defaults.cfg'), '%s/%s.cfg' % 
(config_path, options.chroot)):
         if os.path.exists(cfg):
+            config_opts['config_paths'].append(cfg)
             execfile(cfg)
         else:
             log.error("Could not find required config file: %s" % cfg)
diff --git a/py/mock/backend.py b/py/mock/backend.py
index 7d11532..6726deb 100644
--- a/py/mock/backend.py
+++ b/py/mock/backend.py
@@ -50,6 +50,7 @@ class Root(object):
         self._state_log = getLog("mock.Root.state")
 
         # config options
+        self.configs = config['config_paths']
         self.chrootuid = config['chrootuid']
         self.chrootuser = 'mockbuild'
         self.chrootgid = config['chrootgid']
diff --git a/py/mock/plugins/root_cache.py b/py/mock/plugins/root_cache.py
index 9cb0a13..5382912 100644
--- a/py/mock/plugins/root_cache.py
+++ b/py/mock/plugins/root_cache.py
@@ -61,12 +61,21 @@ class RootCache(object):
         if self.rootCacheLock is None:
             self.rootCacheLock = open(os.path.join(self.rootSharedCachePath, 
"rootcache.lock"), "a+")
 
-        # check cache age:
+        # check cache status
         try:
+            # see if it aged out
             statinfo = os.stat(self.rootCacheFile)
             file_age_days = (time.time() - statinfo.st_ctime) / (60 * 60 * 24)
             if file_age_days > self.root_cache_opts['max_age_days']:
+                getLog().info("root cache aged out! cache will be rebuilt")
                 os.unlink(self.rootCacheFile)
+            else:
+                # make sure no config file is newer than the cache file
+                for cfg in self.rootObj.configs:
+                    if os.stat(cfg).st_mtime > statinfo.st_mtime:
+                        getLog().info("%s newer than root cache; cache will be 
rebuilt" % cfg)
+                        os.unlink(self.rootCacheFile)
+                        break
         except OSError:
             pass
 
--
Fedora-buildsys-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/fedora-buildsys-list

Reply via email to