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.

original Change-Id: I99afe644c8ee0e0b881c1643fef0cb31b83bcd17

Change-Id: I38524f4693899348d6bad3b1c38d95b847722012
diff --git a/ui/build/sandbox_linux.go b/ui/build/sandbox_linux.go
index 95b71a7..1edbe21 100644
--- a/ui/build/sandbox_linux.go
+++ b/ui/build/sandbox_linux.go
@@ -307,6 +307,13 @@
 		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, "--")