xenserver/xenserver-core — pull request #349 by euanh (2014-01-07 11:30:28+00:00)
Title: Mock: Store mock's cache and chroot in the workspace

By default mock creates chroots in /var/lib/mock and keeps a cache of the
chroot in /var/cache/mock. Two mock jobs with the same name can't run
simultaneously because the chroot directory in /var/lib/mock is locked.
Even if the chroots have different names, they may still share the same
cache, which can lead to conflicts.

The conflict shows up as one build complaining that 'repomd.xml' from
the chroot (installed from the cache) is newer than repomd.xml from the
repository being built. This seems to be because one of the builds
writes its repomd.xml back into the cache before the other.

This change stores chroots and caches in the mock subdirectory of
the local workspace. This means that the chroots and caches can't
conflict, so multiple different builds (from different workspaces)
can run simultaneously. It does not make it possible to run multiple
simultaneous builds in the same workspace.

There are a few other practical effects of this change:

* A workspace will be about 300MB larger permanently (the size of the
cache) and will grow by another 300MB or so transiently during the build
(the size of the temporary chroot).

* Builds on NFS-mounted filesystems with 'root squash' enabled will not work.
The cache and chroot directories created by mock are owned by root.

* A non-root user cannot delete the contents of the mock/cache and
mock/root directories directly using 'rm'. The directories have
'mock' group ownership and so can be deleted, but the files inside
them are owned by root. To delete mock's files, use mock --scrub as follows:

mock --configdir mock -r xenserver --scrub=all

Signed-off-by: Euan Harris