]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: translate /private/var to /var on darwin builders
authorRuss Cox <rsc@golang.org>
Fri, 27 Oct 2017 20:48:02 +0000 (16:48 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 27 Oct 2017 23:50:21 +0000 (23:50 +0000)
This is ugly but needed on the builders, because they do not set
PWD/GOROOT consistently, and the new content-based staleness
understands that the setting of GOROOT influences the content in
the linker outputs.

Change-Id: I0606f2c70b719619b188864ad3ae1b34432140cb
Reviewed-on: https://go-review.googlesource.com/74070
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
src/cmd/dist/build.go

index 2d4b575a834495e8bf474d8a3c25c88e7dc94284..cc0c9af6439d6184768997478c96c7a187d035a7 100644 (file)
@@ -12,6 +12,7 @@ import (
        "os"
        "os/exec"
        "path/filepath"
+       "runtime"
        "sort"
        "strings"
        "sync"
@@ -100,6 +101,22 @@ func xinit() {
        }
        goroot = filepath.Clean(b)
 
+       if runtime.GOOS == "darwin" && strings.HasPrefix(goroot, "/private/") {
+               // The builders don't set $PWD correctly during make.bash
+               // but then they apparently do set it or perhaps $GOROOT
+               // during run.bash. During make.bash we infer that
+               // GOROOT=/private/var/blah/blah but then during run.bash
+               // apparently GOROOT=/var/blah/blah. This makes all commands
+               // seem out of date, which breaks some tests.
+               // Instead of finding the problem in the builders, fix it here.
+               // This is not great but is the best we can do today.
+               f1, err1 := os.Stat(goroot)
+               f2, err2 := os.Stat(strings.TrimPrefix(goroot, "/private"))
+               if err1 == nil && err2 == nil && os.SameFile(f1, f2) {
+                       goroot = strings.TrimPrefix(goroot, "/private")
+               }
+       }
+
        b = os.Getenv("GOROOT_FINAL")
        if b == "" {
                b = goroot