Work around for permissions problems when different users share a ccache.
authorCarl Hetherington <cth@carlh.net>
Thu, 11 Jun 2020 18:20:57 +0000 (20:20 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 11 Jun 2020 18:20:57 +0000 (20:20 +0200)
cdist
make-ccache-volume

diff --git a/cdist b/cdist
index 84814ac1751b8b09f0ab23074a59c3eda657a9cc..01e016cacff8ce80d917b5e6ec32c084834e1b8d 100755 (executable)
--- a/cdist
+++ b/cdist
@@ -554,7 +554,7 @@ class DockerTarget(Target):
         if self.privileged:
             opts += '--privileged=true '
         if self.ccache:
-            opts += "-e CCACHE_DIR=/ccache/%s --mount source=ccache,target=/ccache" % self.image
+            opts += "-e CCACHE_DIR=/ccache/%s-%d --mount source=ccache,target=/ccache" % (self.image, os.getuid())
 
         tag = self.image
         if config.has('docker_hub_repository'):
index 60a2e42425d09c6bbcd0c3b65a6086932a1d4244..aa284d2752041e663dd2cda3b028978f1580734c 100755 (executable)
@@ -2,8 +2,10 @@
 
 docker volume create ccache
 id=$(docker run --mount source=ccache,target=/ccache -itd ubuntu-18.04-64 bash)
-for t in ubuntu-18.04-64 windows windows_2.15.x; do
-  docker exec $id mkdir /ccache/$t
-  docker exec $id chown carl /ccache/$t
+for u in 127 1000; do
+  for t in ubuntu-18.04-64 windows windows_2.15.x; do
+    docker exec $id mkdir /ccache/$t-$u
+    docker exec $id chmod 777 /ccache/$t-$u
+  done
 done
 docker kill $id