Description of problem: mock doesn't play along with $HOME on a NFS share ($HOME is on a "root_squash" mount). Version-Release number of selected component (if applicable): 1.1.6 (i've used the git version from yesterday: abd9d4c8b5b72aef58e4d5cebc3f3259226832a0) How reproducible: You need a non-root user with a $HOME on an NFS share ("root_squash" must be set so all root mappings are changed to nobody:nobody). Steps to Reproduce: 1. Login to the mock-machine 2. Try to build a RPM from a .src.rpm. Any SRPM is good for this job. Here we go: % mock -r centos-5-x86_64 --resultdir=$HOME/mock/results --uniqueext=$USER $HOME/rpms/SRPMS/gitosis-0.2-6.20080825git.src.rpm INFO: mock.py version 1.1.6 starting... State Changed: init plugins INFO: selinux disabled State Changed: start ERROR: Cannot find/open srpm: /home/foobar/rpms/SRPMS/gitosis-0.2-6.20080825git.src.rpm. Error: Unable to open file Actual results: The above error message because the read will be done as root (and mapped to nobody on the NFS mount) and that will fail with a "chmod 700 $HOME". And - of course - no build. Expected results: A perfect build. B-) Additional info: 1) The concept of handling builds in mock where changed. (Our recently used version of mock-0.7.4 doesn't have this problem at all. And non of the problem I will describe later.) 2) Copying the file to the /tmp file doesn't change the problem. We only got an error message further: % cp -p $HOME/rpms/SRPMS/gitosis-0.2-6.20080825git.src.rpm /tmp % mock -r centos-5-x86_64 --resultdir=$HOME/mock/results --uniqueext=$USER /tmp/gitosis-0.2-6.20080825git.src.rpm INFO: mock.py version 1.1.6 starting... State Changed: init plugins INFO: selinux disabled State Changed: start INFO: Start(/tmp/gitosis-0.2-6.20080825git.src.rpm) Config(centos-5-x86_64) State Changed: lock buildroot State Changed: clean State Changed: init State Changed: lock buildroot Mock Version: 1.1.6 INFO: Mock Version: 1.1.6 INFO: enabled root cache State Changed: unpacking root cache INFO: /vols/smb0/home/foobar ERROR: Exception(/tmp/gitosis-0.2-6.20080825git.src.rpm) Config(centos-5-x86_64) 0 minutes 0 seconds INFO: Results and/or logs in: /home/foobar/mock/results INFO: Cleaning up build root ('clean_on_failure=True') State Changed: lock buildroot State Changed: clean INFO: chroot (/var/lib/mock/centos-5-x86_64-foobar) unlocked and deleted ERROR: Command failed. See logs for output. # ['tar', '--use-compress-program', 'pigz', '-xf', '/var/cache/mock/centos-5-x86_64/root_cache/cache.tar.gz', '-C', '/var/lib/mock/centos-5-x86_64-foobar/root/'] The relevant lines from ~/mock/results/root.log: DEBUG util.py:301: Executing command: ['tar', '--use-compress-program', 'pigz', '-xf', '/var/cache/mock/centos-5-x86_64/root_cache/cache.tar.gz', '-C', '/var/lib/mock/centos-5-x86_64-foobar/root/'] DEBUG util.py:267: tar: Cannot save working directory DEBUG util.py:267: tar: Error is not recoverable: exiting now DEBUG util.py:340: Child returncode was: 2 The problem here is that tar is called with an invalid initial working directory. The program is started as root, the working directory is the $HOME share on the NFS machine and inaccessible for 'tar' (okay this is a tar problem) but it can be solved with a little patch (a os.chdir("/") before the tar call do it). Other things are brocken too: The "--copyin" mode of mock is can't read from NFS homes (same problem). To make a long story short: NFS and mock is a little problematic (read: non working). I've found the following solution(s): 1) copy the files to /tmp before the mock call 2) use a little patch (should I post the patch here?) to satify tar 3) don't use --copyin and --copyout Any comments?
This package has changed ownership in the Fedora Package Database. Reassigning to the new owner of this component.
I've just hit the same problem.
Created attachment 489975 [details] Patch to avoid the error message (tested with 1.1.6 and 1.1.9) After the update to mock 1.1.9 the bug is still their. So I'm sending in this small little patch. The patch will just do a 'os.chdir("/")' before the tar call. I'm using mock very often and havn't detected any side effects so I think it's safe to use.
Thanks Erik, I'm slowly working on 1.1.10, so I'll add it to the queue.
I modified this logic a bit to conditionally do the chdir: ommit e04b7d8a52a2bb88496545593898c744d2e8c8af Author: Clark Williams <williams> Date: Thu Aug 23 14:12:13 2012 -0500 deal with NFS home directories and root_cache issues [BZ# 649192] Detect if we're running on an NFS home and if so chdir to a non-NFS directory so tar doesn't freak out when unpacking the chroot cache. Signed-off-by: Clark Williams <williams> diff --git a/py/mockbuild/plugins/root_cache.py b/py/mockbuild/plugins/root_cache.py index da17162..bcbd6b3 100644 --- a/py/mockbuild/plugins/root_cache.py +++ b/py/mockbuild/plugins/root_cache.py @@ -95,6 +95,11 @@ class RootCache(object): 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 diff --git a/py/mockbuild/util.py b/py/mockbuild/util.py index 62da296..07c52d0 100644 --- a/py/mockbuild/util.py +++ b/py/mockbuild/util.py @@ -411,3 +411,16 @@ def clean_env(): } env['LANG'] = os.environ.setdefault('LANG', 'en_US.UTF-8') return env + +def get_fs_type(path): + cmd = '/usr/bin/stat -f -L -c %%T %s' % path + p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) + p.wait() + return p.stdout.readline().strip() + +def find_non_nfs_dir(): + dirs = ('/tmp', '/usr/tmp', '/') + for d in dirs: + if not get_fs_type(d).startswith('nfs'): + return d + raise mockbuild.exception.Error('Cannot find non-NFS directory in: %s' % dirs) will be in the next build.
I've modified the patch a bit to be conditional: Author: Clark Williams <williams> Date: Thu Aug 23 14:12:13 2012 -0500 deal with NFS home directories and root_cache issues [BZ# 649192] Detect if we're running on an NFS home and if so chdir to a non-NFS directory so tar doesn't freak out when unpacking the chroot cache. Signed-off-by: Clark Williams <williams> diff --git a/py/mockbuild/plugins/root_cache.py b/py/mockbuild/plugins/root_cache.py index da17162..bcbd6b3 100644 --- a/py/mockbuild/plugins/root_cache.py +++ b/py/mockbuild/plugins/root_cache.py @@ -95,6 +95,11 @@ class RootCache(object): 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.makeCh shell=False diff --git a/py/mockbuild/util.py b/py/mockbuild/util.py index 62da296..07c52d0 100644 --- a/py/mockbuild/util.py +++ b/py/mockbuild/util.py @@ -411,3 +411,16 @@ def clean_env(): } env['LANG'] = os.environ.setdefault('LANG', 'en_US.UTF-8') return env + +def get_fs_type(path): + cmd = '/usr/bin/stat -f -L -c %%T %s' % path + p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) + p.wait() + return p.stdout.readline().strip() + +def find_non_nfs_dir(): + dirs = ('/tmp', '/usr/tmp', '/') + for d in dirs: + if not get_fs_type(d).startswith('nfs'): + return d + raise mockbuild.exception.Error('Cannot find non-NFS directory in: %s' % dirs) Should go into the next build
mock-1.1.27-2.el6 has been submitted as an update for Fedora EPEL 6. https://admin.fedoraproject.org/updates/mock-1.1.27-2.el6
mock-1.1.27-2.fc16 has been submitted as an update for Fedora 16. https://admin.fedoraproject.org/updates/mock-1.1.27-2.fc16
mock-1.0.35-1.el5 has been submitted as an update for Fedora EPEL 5. https://admin.fedoraproject.org/updates/mock-1.0.35-1.el5
mock-1.1.27-2.fc17 has been submitted as an update for Fedora 17. https://admin.fedoraproject.org/updates/mock-1.1.27-2.fc17
Package mock-1.1.27-2.el6: * should fix your issue, * was pushed to the Fedora EPEL 6 testing repository, * should be available at your local mirror within two days. Update it with: # su -c 'yum update --enablerepo=epel-testing mock-1.1.27-2.el6' as soon as you are able to. Please go to the following url: https://admin.fedoraproject.org/updates/FEDORA-EPEL-2012-12915/mock-1.1.27-2.el6 then log in and leave karma (feedback).
mock-1.1.28-1.el6 has been submitted as an update for Fedora EPEL 6. https://admin.fedoraproject.org/updates/mock-1.1.28-1.el6
mock-1.1.28-1.fc18 has been submitted as an update for Fedora 18. https://admin.fedoraproject.org/updates/mock-1.1.28-1.fc18
mock-1.0.36-1.el5 has been submitted as an update for Fedora EPEL 5. https://admin.fedoraproject.org/updates/mock-1.0.36-1.el5
mock-1.1.28-1.fc17 has been submitted as an update for Fedora 17. https://admin.fedoraproject.org/updates/mock-1.1.28-1.fc17
mock-1.1.28-1.fc16 has been submitted as an update for Fedora 16. https://admin.fedoraproject.org/updates/mock-1.1.28-1.fc16
mock-1.1.28-1.fc17 has been pushed to the Fedora 17 stable repository. If problems still persist, please make note of it in this bug report.
mock-1.1.28-1.fc16 has been pushed to the Fedora 16 stable repository. If problems still persist, please make note of it in this bug report.
mock-1.0.36-1.el5 has been pushed to the Fedora EPEL 5 stable repository. If problems still persist, please make note of it in this bug report.
I'm seeing what seems to be an odd-side effect from this change, mock ... ./foo.src.rpm now fails for me (when issued on an nfs dir), Finish: clean chroot Finish: lock buildroot ERROR: [Errno 2] No such file or directory: './kdelibs-4.9.90-1.fc19.src.rpm' Traceback (most recent call last): File "/usr/sbin/mock", line 920, in <module> main(retParams) File "/usr/sbin/mock", line 856, in main do_rebuild(config_opts, chroot, args) File "<peak.util.decorators.rewrap wrapping __main__.do_rebuild at 0x01E71CF8>", line 3, in do_rebuild but mock ... /full/path/to/foo.src.rpm works.
$ rpm -q mock mock-1.1.28-1.el6.noarch by the way