Allow wrapper to build with cros sdk.

Cros sdk uses go version 1.11.

BUG=chromium:773875
TEST=unit test

Change-Id: Ib76cb21b47f24263e3c0f9fad6321192ad4cf801
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1752535
Tested-by: Tobias Bosch <tbosch@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
diff --git a/compiler_wrapper/goldenutil_test.go b/compiler_wrapper/goldenutil_test.go
index 2b6463d..99d45bb 100644
--- a/compiler_wrapper/goldenutil_test.go
+++ b/compiler_wrapper/goldenutil_test.go
@@ -194,6 +194,7 @@
 }
 
 func (writer *replacingWriter) Write(p []byte) (n int, err error) {
-	p = bytes.ReplaceAll(p, writer.old, writer.new)
+	// TODO: Use bytes.ReplaceAll once cros sdk uses golang >= 1.12
+	p = bytes.Replace(p, writer.old, writer.new, -1)
 	return writer.Writer.Write(p)
 }
diff --git a/compiler_wrapper/oldwrapper.go b/compiler_wrapper/oldwrapper.go
index 6c4ee0e..5db4725 100644
--- a/compiler_wrapper/oldwrapper.go
+++ b/compiler_wrapper/oldwrapper.go
@@ -203,7 +203,8 @@
 	oldWrapperContent := cfg.OldWrapperContent
 	oldWrapperContent = regexp.MustCompile(`(?m)^exec\b`).ReplaceAllString(oldWrapperContent, "exec_mock")
 	oldWrapperContent = regexp.MustCompile(`\$EXEC`).ReplaceAllString(oldWrapperContent, "exec_mock")
-	oldWrapperContent = strings.ReplaceAll(oldWrapperContent, "$0", cfg.CmdPath)
+	// TODO: Use strings.ReplaceAll once cros sdk uses golang >= 1.12
+	oldWrapperContent = strings.Replace(oldWrapperContent, "$0", cfg.CmdPath, -1)
 	cfg.OldWrapperContent = oldWrapperContent
 	mockFile, err := ioutil.TempFile("", filepattern)
 	if err != nil {
@@ -241,7 +242,7 @@
 	// Note: Using a self executable wrapper does not work due to a race condition
 	// on unix systems. See https://github.com/golang/go/issues/22315
 	oldWrapperCmd := &command{
-		Path:       "/usr/bin/sh",
+		Path:       "/bin/sh",
 		Args:       append([]string{mockFile.Name()}, inputCmd.Args...),
 		EnvUpdates: inputCmd.EnvUpdates,
 	}
@@ -250,11 +251,12 @@
 
 func callOldPythonWrapper(env env, cfg *oldWrapperConfig, inputCmd *command, filepattern string, stdout io.Writer, stderr io.Writer) (exitCode int, err error) {
 	oldWrapperContent := cfg.OldWrapperContent
-	oldWrapperContent = strings.ReplaceAll(oldWrapperContent, "from __future__ import print_function", "")
+	// TODO: Use strings.ReplaceAll once cros sdk uses golang >= 1.12
+	oldWrapperContent = strings.Replace(oldWrapperContent, "from __future__ import print_function", "", -1)
 	// Replace sets with lists to make our comparisons deterministic
-	oldWrapperContent = strings.ReplaceAll(oldWrapperContent, "set(", "ListSet(")
-	oldWrapperContent = strings.ReplaceAll(oldWrapperContent, "if __name__ == '__main__':", "def runMain():")
-	oldWrapperContent = strings.ReplaceAll(oldWrapperContent, "__file__", "'"+cfg.WrapperPath+"'")
+	oldWrapperContent = strings.Replace(oldWrapperContent, "set(", "ListSet(", -1)
+	oldWrapperContent = strings.Replace(oldWrapperContent, "if __name__ == '__main__':", "def runMain():", -1)
+	oldWrapperContent = strings.Replace(oldWrapperContent, "__file__", "'"+cfg.WrapperPath+"'", -1)
 	cfg.OldWrapperContent = oldWrapperContent
 
 	mockFile, err := ioutil.TempFile("", filepattern)
diff --git a/compiler_wrapper/testutil_test.go b/compiler_wrapper/testutil_test.go
index da014ac..fa321a0 100644
--- a/compiler_wrapper/testutil_test.go
+++ b/compiler_wrapper/testutil_test.go
@@ -288,7 +288,7 @@
 func newExitCodeError(exitCode int) error {
 	// It's actually hard to create an error that represents a command
 	// with exit code. Using a real command instead.
-	tmpCmd := exec.Command("/usr/bin/sh", "-c", fmt.Sprintf("exit %d", exitCode))
+	tmpCmd := exec.Command("/bin/sh", "-c", fmt.Sprintf("exit %d", exitCode))
 	return tmpCmd.Run()
 }