summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/mock/site-defaults.cfg2
-rwxr-xr-xpy/mock.py10
-rw-r--r--py/mock/backend.py18
-rw-r--r--py/mock/plugins/root_cache.py12
4 files changed, 31 insertions, 11 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
diff --git a/py/mock.py b/py/mock.py
index 408b421..c5f057b 100755
--- a/py/mock.py
+++ b/py/mock.py
@@ -40,6 +40,7 @@ import pwd
import sys
import time
from optparse import OptionParser
+from socket import gethostname
# all of the variables below are substituted by the build system
__VERSION__ = "unreleased_version"
@@ -247,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:
@@ -268,7 +271,6 @@ def setup_default_config_opts(config_opts, unprivUid):
config_opts['yum.conf'] = ''
config_opts['more_buildreqs'] = {}
config_opts['files'] = {}
- config_opts['files']['etc/hosts'] = "127.0.0.1 localhost localhost.localdomain\n"
config_opts['macros'] = {
'%_topdir': '%s/build' % config_opts['chroothome'],
'%_rpmfilename': '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm',
@@ -519,6 +521,10 @@ def main(ret):
# cmdline options override config options
set_config_opts_per_cmdline(config_opts, options, args)
+ # default /etc/hosts contents
+ if not config_opts['use_host_resolv'] and not config_opts['files'].has_key('etc/hosts'):
+ config_opts['files']['etc/hosts'] = "127.0.0.1 localhost localhost.localdomain %s\n" % gethostname();
+
# elevate privs
uidManager._becomeUser(0, 0)
diff --git a/py/mock/backend.py b/py/mock/backend.py
index 86b3fb7..78358c7 100644
--- a/py/mock/backend.py
+++ b/py/mock/backend.py
@@ -227,13 +227,19 @@ class Root(object):
pass
os.symlink('yum/yum.conf', self.makeChrootPath("etc", "yum.conf"))
- # set up resolv.conf
+ # set up resolver configuration
if self.use_host_resolv:
- resolvdir = self.makeChrootPath('etc')
- resolvpath = self.makeChrootPath('etc', 'resolv.conf')
- if os.path.exists(resolvpath):
- os.remove(resolvpath)
- shutil.copy2('/etc/resolv.conf', resolvdir)
+ etcdir = self.makeChrootPath('etc')
+
+ resolvconfpath = self.makeChrootPath('etc', 'resolv.conf')
+ if os.path.exists(resolvconfpath):
+ os.remove(resolvconfpath)
+ shutil.copy2('/etc/resolv.conf', etcdir)
+
+ hostspath = self.makeChrootPath('etc', 'hosts')
+ if os.path.exists(hostspath):
+ os.remove(hostspath)
+ shutil.copy2('/etc/hosts', etcdir)
# files in /etc that need doing
for key in self.chroot_file_contents:
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
)