Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 691597 Details for
Bug 905362
Problems using mock as sandbox with tmpfs
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Second patch proposal
0001-Second-proposed-patch-for-bug-905362.patch (text/plain), 10.23 KB, created by
Justin Lewis Salmon
on 2013-02-01 14:15:40 UTC
(
hide
)
Description:
Second patch proposal
Filename:
MIME Type:
Creator:
Justin Lewis Salmon
Created:
2013-02-01 14:15:40 UTC
Size:
10.23 KB
patch
obsolete
>From dd0f008cf7541257b4e74fe8642d43880919aa5c Mon Sep 17 00:00:00 2001 >From: Justin Salmon <jsalmon@cern.ch> >Date: Fri, 1 Feb 2013 15:14:59 +0100 >Subject: [PATCH] Second proposed patch for bug #905362 > >--- > docs/mock.1 | 3 + > py/mock.py | 6 ++ > py/mockbuild/backend.py | 3 +- > py/mockbuild/plugins/root_cache.py | 104 ++++++++++++++++++++++++------------ > 4 files changed, 81 insertions(+), 35 deletions(-) > >diff --git a/docs/mock.1 b/docs/mock.1 >index 4d9177c..be05f47 100644 >--- a/docs/mock.1 >+++ b/docs/mock.1 >@@ -130,6 +130,9 @@ Clean chroot after building. Use with \-\-resultdir. Only active for '\-\-rebuil > \fB\-\-no\-cleanup\-after\fR > Don't clean chroot after building. If automatic cleanup is enabled, use this to disable. > .TP >+\fB\-\-cache\-alterations\fR >+Rebuild the root cache after making alterations to the chroot (i.e. --install). Only useful when using tmpfs plugin. >+.TP > \fB\-\-target=\fR\fIARCH\fP > This argument is passed to rpmbuild to specify the target arch to build. It defaults to whatever is specified for --arch, or whatever is specified in the config file as config_opts['target_arch']. > .TP >diff --git a/py/mock.py b/py/mock.py >index 4efd086..3f496ad 100755 >--- a/py/mock.py >+++ b/py/mock.py >@@ -144,6 +144,10 @@ def command_parse(config_opts): > dest="cleanup_after", default=None, > help="Dont clean chroot after building. If automatic" > " cleanup is enabled, use this to disable.", ) >+ parser.add_option("--cache-alterations", action="store_true", >+ dest="cache_alterations", default=False, >+ help="Rebuild the root cache after making alterations to the chroot" >+ " (i.e. --install). Only useful when using tmpfs plugin.") > parser.add_option("--arch", action ="store", dest="arch", > default=None, help="Sets kernel personality().") > parser.add_option("--target", action ="store", dest="rpmbuild_arch", >@@ -464,6 +468,8 @@ def set_config_opts_per_cmdline(config_opts, options, args): > config_opts['cleanup_on_success'] = False > config_opts['cleanup_on_failure'] = False > >+ config_opts['cache_alterations'] = options.cache_alterations >+ > config_opts['online'] = options.online > > if options.scm: >diff --git a/py/mockbuild/backend.py b/py/mockbuild/backend.py >index 46069a4..3f6b3eb 100644 >--- a/py/mockbuild/backend.py >+++ b/py/mockbuild/backend.py >@@ -96,6 +96,7 @@ class Root(object): > self.more_buildreqs = config['more_buildreqs'] > self.cache_topdir = config['cache_topdir'] > self.cachedir = os.path.join(self.cache_topdir, self.sharedRootName) >+ self.cache_alterations = config['cache_alterations'] > self.useradd = config['useradd'] > self.online = config['online'] > self.internal_dev_setup = config['internal_dev_setup'] >@@ -901,7 +902,7 @@ class Root(object): > if cmd[0] == "builddep": > yumcmd[0] = self.yum_builddep_path > cmdix = 1 >- if self.yum_builddep_opts: >+ if self.yum_builddep_opts: > for eachopt in self.yum_builddep_opts.split(): > yumcmd.insert(1, '%s' % eachopt) > yumcmd.extend(('--installroot', self.makeChrootPath())) >diff --git a/py/mockbuild/plugins/root_cache.py b/py/mockbuild/plugins/root_cache.py >index 03d1fb5..739b681 100644 >--- a/py/mockbuild/plugins/root_cache.py >+++ b/py/mockbuild/plugins/root_cache.py >@@ -24,8 +24,6 @@ def init(rootObj, conf): > class RootCache(object): > """caches root environment in a tarball""" > decorate(traceLog()) >- >- > def __init__(self, rootObj, conf): > self.rootObj = rootObj > self.root_cache_opts = conf >@@ -43,7 +41,13 @@ class RootCache(object): > self.compressArgs = [] > rootObj.rootCacheObj = self > rootObj.addHook("preinit", self._rootCachePreInitHook) >+ rootObj.addHook("preshell", self._rootCachePreShellHook) >+ rootObj.addHook("prechroot", self._rootCachePreShellHook) >+ rootObj.addHook("preyum", self._rootCachePreYumHook) > rootObj.addHook("postinit", self._rootCachePostInitHook) >+ rootObj.addHook("postshell", self._rootCachePostShellHook) >+ rootObj.addHook("postchroot", self._rootCachePostShellHook) >+ rootObj.addHook("postyum", self._rootCachePostShellHook) > self.exclude_dirs = self.root_cache_opts['exclude_dirs'] > self.exclude_tar_cmds = [ "--exclude=" + dir for dir in self.exclude_dirs] > >@@ -68,11 +72,10 @@ class RootCache(object): > decorate(traceLog()) > def _rootCachePreInitHook(self): > getLog().info("enabled root cache") >- mockbuild.util.mkdirIfAbsent(self.rootSharedCachePath) >- # lock so others dont accidentally use root cache while we operate on it. >- if self.rootCacheLock is None: >- self.rootCacheLock = open(os.path.join(self.rootSharedCachePath, "rootcache.lock"), "a+") >+ self._unpack_root_cache() > >+ decorate(traceLog()) >+ def _unpack_root_cache(self): > # check cache status > try: > if self.root_cache_opts['age_check']: >@@ -94,25 +97,42 @@ class RootCache(object): > except OSError: > pass > >- # optimization: don't unpack root cache if chroot was not cleaned >- if os.path.exists(self.rootCacheFile) and self.rootObj.chrootWasCleaned: >- self.rootObj.start("unpacking root cache") >- self._rootCacheLock() >- # >- # deal with NFS homedir and root_squash >- # >- if mockbuild.util.get_fs_type(os.getcwd()).startswith('nfs'): >- os.chdir(mockbuild.util.find_non_nfs_dir()) >- mockbuild.util.do( >- ["tar"] + self.compressArgs + ["-xf", self.rootCacheFile, "-C", self.rootObj.makeChrootPath()], >- shell=False >- ) >- for dir in self.exclude_dirs: >- mockbuild.util.mkdirIfAbsent(self.rootObj.makeChrootPath(dir)) >- self._rootCacheUnlock() >- self.rootObj.chrootWasCleaned = False >- self.rootObj.chrootWasCached = True >- self.rootObj.finish("unpacking root cache") >+ mockbuild.util.mkdirIfAbsent(self.rootSharedCachePath) >+ # lock so others dont accidentally use root cache while we operate on it. >+ if self.rootCacheLock is None: >+ self.rootCacheLock = open(os.path.join(self.rootSharedCachePath, "rootcache.lock"), "a+") >+ >+ # optimization: don't unpack root cache if chroot was not cleaned (unless we are using tmpfs) >+ if os.path.exists(self.rootCacheFile): >+ if self.rootObj.chrootWasCleaned or self.rootObj.pluginConf['tmpfs_enable']: >+ self.rootObj.start("unpacking root cache") >+ self._rootCacheLock() >+ # >+ # deal with NFS homedir and root_squash >+ # >+ if mockbuild.util.get_fs_type(os.getcwd()).startswith('nfs'): >+ os.chdir(mockbuild.util.find_non_nfs_dir()) >+ mockbuild.util.do( >+ ["tar"] + self.compressArgs + ["-xf", self.rootCacheFile, "-C", self.rootObj.makeChrootPath()], >+ shell=False >+ ) >+ for dir in self.exclude_dirs: >+ mockbuild.util.mkdirIfAbsent(self.rootObj.makeChrootPath(dir)) >+ self._rootCacheUnlock() >+ self.rootObj.chrootWasCleaned = False >+ self.rootObj.chrootWasCached = True >+ self.rootObj.finish("unpacking root cache") >+ >+ decorate(traceLog()) >+ def _rootCachePreShellHook(self): >+ if self.rootObj.pluginConf['tmpfs_enable']: >+ self._unpack_root_cache() >+ >+ decorate(traceLog()) >+ def _rootCachePreYumHook(self): >+ if self.rootObj.pluginConf['tmpfs_enable']: >+ if not os.listdir(self.rootObj.makeChrootPath()) or self.rootObj.cache_alterations: >+ self._unpack_root_cache() > > decorate(traceLog()) > def _root_cache_handle_mounts(self): >@@ -124,6 +144,10 @@ class RootCache(object): > > decorate(traceLog()) > def _rootCachePostInitHook(self): >+ self._rebuild_root_cache() >+ >+ decorate(traceLog()) >+ def _rebuild_root_cache(self): > try: > self._rootCacheLock(shared=0) > # nuke any rpmdb tmp files >@@ -132,12 +156,15 @@ class RootCache(object): > > # truncate the sparse files in /var/log > for logfile in ('/var/log/lastlog', '/var/log/faillog'): >- f = open(self.rootObj.makeChrootPath(logfile), "w") >- f.truncate(0) >- f.close() >- >- # never rebuild cache unless it was a clean build. >- if self.rootObj.chrootWasCleaned: >+ try: >+ f = open(self.rootObj.makeChrootPath(logfile), "w") >+ f.truncate(0) >+ f.close() >+ except: >+ pass >+ >+ # never rebuild cache unless it was a clean build, or we are explicitly caching alterations >+ if self.rootObj.chrootWasCleaned or self.rootObj.cache_alterations: > mockbuild.util.do(["sync"], shell=False) > self._root_cache_handle_mounts() > self.rootObj.start("creating cache") >@@ -153,9 +180,18 @@ class RootCache(object): > os.remove(self.rootCacheFile) > raise > # now create the cache log file >- l = open(os.path.join(self.rootSharedCachePath, "cache.log"), "w") >- l.write(self.rootObj.yum_init_install_output) >- l.close() >+ try: >+ l = open(os.path.join(self.rootSharedCachePath, "cache.log"), "w") >+ l.write(self.rootObj.yum_init_install_output) >+ l.close() >+ except: >+ pass > self.rootObj.finish("creating cache") > finally: > self._rootCacheUnlock() >+ >+ decorate(traceLog()) >+ def _rootCachePostShellHook(self): >+ if self.rootObj.pluginConf['tmpfs_enable'] and self.rootObj.cache_alterations: >+ self._rebuild_root_cache() >+ >-- >1.7.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 905362
:
689849
| 691597