diff options
-rw-r--r-- | etc/mock/site-defaults.cfg | 2 | ||||
-rwxr-xr-x | py/mock.py | 4 | ||||
-rw-r--r-- | py/mock/plugins/root_cache.py | 12 |
3 files changed, 14 insertions, 4 deletions
diff --git a/etc/mock/site-defaults.cfg b/etc/mock/site-defaults.cfg index 92f5562..0ee2082 100644 --- a/etc/mock/site-defaults.cfg +++ b/etc/mock/site-defaults.cfg @@ -62,6 +62,8 @@ # config_opts['plugin_conf']['root_cache_enable'] = True # config_opts['plugin_conf']['root_cache_opts']['max_age_days'] = 15 # config_opts['plugin_conf']['root_cache_opts']['dir'] = "%(cache_topdir)s/%(root)s/root_cache/" +# config_opts['plugin_conf']['root_cache_opts']['compress_program'] = "gzip" +# config_opts['plugin_conf']['root_cache_opts']['extension'] = ".gz" # # bind mount plugin is enabled by default but has no configured directories to mount # config_opts['plugin_conf']['bind_mount_enable'] = True @@ -248,7 +248,9 @@ def setup_default_config_opts(config_opts, unprivUid): 'root_cache_enable': True, 'root_cache_opts': { 'max_age_days': 15, - 'dir': "%(cache_topdir)s/%(root)s/root_cache/"}, + 'dir': "%(cache_topdir)s/%(root)s/root_cache/", + 'compress_program': 'gzip', + 'extension': '.gz'}, 'bind_mount_enable': True, 'bind_mount_opts': {'dirs': [ # specify like this: diff --git a/py/mock/plugins/root_cache.py b/py/mock/plugins/root_cache.py index f69f28f..8756c01 100644 --- a/py/mock/plugins/root_cache.py +++ b/py/mock/plugins/root_cache.py @@ -28,8 +28,14 @@ class RootCache(object): self.rootObj = rootObj self.root_cache_opts = conf self.rootSharedCachePath = self.root_cache_opts['dir'] % self.root_cache_opts - self.rootCacheFile = os.path.join(self.rootSharedCachePath, "cache.tar.gz") + self.rootCacheFile = os.path.join(self.rootSharedCachePath, "cache.tar") self.rootCacheLock = None + self.compressProgram = self.root_cache_opts['compress_program'] + if self.compressProgram: + self.compressArgs = ['--use-compress-program', self.compressProgram] + self.rootCacheFile = self.rootCacheFile + self.root_cache_opts['extension'] + else: + self.compressArgs = [] self.state = rootObj.state rootObj.rootCacheObj = self rootObj.addHook("preinit", self._rootCachePreInitHook) @@ -85,7 +91,7 @@ class RootCache(object): self.state("unpacking root cache") self._rootCacheLock() mock.util.do( - ["tar", "xzf", self.rootCacheFile, "-C", self.rootObj.makeChrootPath()], + ["tar"] + self.compressArgs + ["-xf", self.rootCacheFile, "-C", self.rootObj.makeChrootPath()], shell=False ) self._rootCacheUnlock() @@ -105,7 +111,7 @@ class RootCache(object): if self.rootObj.chrootWasCleaned: self.state("creating cache") mock.util.do( - ["tar", "czf", self.rootCacheFile, + ["tar"] + self.compressArgs + ["-cf", self.rootCacheFile, "-C", self.rootObj.makeChrootPath(), "."], shell=False ) |