From d44bc5b281a980ba81bad8b0512b0b4d0e0ea60f Mon Sep 17 00:00:00 2001 From: daniml3 Date: Mon, 11 Oct 2021 14:12:34 +0200 Subject: [PATCH] sandbox_linux: set CCACHE_DIR as a writable path Fixes "Read-only file system" error when using ccache. NOTE: This is only required when both ccache exec and dir are on the same partition. Change-Id: I99afe644c8ee0e0b881c1643fef0cb31b83bcd17 --- ui/build/sandbox_linux.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/build/sandbox_linux.go b/ui/build/sandbox_linux.go index edb3b66d4..ce0d174b9 100644 --- a/ui/build/sandbox_linux.go +++ b/ui/build/sandbox_linux.go @@ -228,6 +228,13 @@ func (c *Cmd) wrapSandbox() { sandboxArgs = append(sandboxArgs, "-N") } + if ccacheExec := os.Getenv("CCACHE_EXEC"); ccacheExec != "" { + bytes, err := exec.Command(ccacheExec, "-k", "cache_dir").Output() + if err == nil { + sandboxArgs = append(sandboxArgs, "-B", strings.TrimSpace(string(bytes))) + } + } + // Stop nsjail from parsing arguments sandboxArgs = append(sandboxArgs, "--")