cmd/coordinator: fix trybots for the "dl" repo, part 2

This continues the work started in CL 170417,
and hopefully finishes it.

Fixes golang/go#35581
Updates golang/go#30852

Change-Id: Ie666ead86dccb4de7dfc2ca94c79f4592b2da47a
Reviewed-on: https://go-review.googlesource.com/c/build/+/212023
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
diff --git a/cmd/coordinator/coordinator.go b/cmd/coordinator/coordinator.go
index 7365bb7..310b93a 100644
--- a/cmd/coordinator/coordinator.go
+++ b/cmd/coordinator/coordinator.go
@@ -2566,7 +2566,7 @@
 
 	// Check out the provided sub-repo to the buildlet's workspace.
 	// Need to do this first, so we can run go env GOMOD in it.
-	err = buildgo.FetchSubrepo(st.ctx, st, st.bc, st.SubName, st.SubRev)
+	err = buildgo.FetchSubrepo(st.ctx, st, st.bc, st.SubName, st.SubRev, importPathOfRepo(st.SubName))
 	if err != nil {
 		return nil, err
 	}
@@ -2760,7 +2760,7 @@
 	// fetch checks out the provided sub-repo to the buildlet's workspace.
 	fetch := func(repo, rev string) error {
 		fetched[repo] = true
-		return buildgo.FetchSubrepo(st.ctx, st, st.bc, repo, rev)
+		return buildgo.FetchSubrepo(st.ctx, st, st.bc, repo, rev, importPathOfRepo(repo))
 	}
 
 	// findDeps uses 'go list' on the checked out repo to find its
diff --git a/internal/buildgo/benchmarks.go b/internal/buildgo/benchmarks.go
index bc89223..a14453e 100644
--- a/internal/buildgo/benchmarks.go
+++ b/internal/buildgo/benchmarks.go
@@ -86,7 +86,7 @@
 		return nil, err
 	}
 	if err := bc.ListDir(ctx, "gopath/src/golang.org/x/benchmarks", buildlet.ListDirOpts{}, func(buildlet.DirEntry) {}); err != nil {
-		if err := FetchSubrepo(ctx, sl, bc, "benchmarks", rev); err != nil {
+		if err := FetchSubrepo(ctx, sl, bc, "benchmarks", rev, "golang.org/x/benchmarks"); err != nil {
 			return nil, err
 		}
 	}
@@ -112,7 +112,7 @@
 
 	// Fetch x/benchmarks
 	if benchmarksRev != "" {
-		if err := FetchSubrepo(ctx, gb.Logger, bc, "benchmarks", benchmarksRev); err != nil {
+		if err := FetchSubrepo(ctx, gb.Logger, bc, "benchmarks", benchmarksRev, "golang.org/x/benchmarks"); err != nil {
 			return nil, err
 		}
 	}
diff --git a/internal/buildgo/buildgo.go b/internal/buildgo/buildgo.go
index 951da1e..dce01fd 100644
--- a/internal/buildgo/buildgo.go
+++ b/internal/buildgo/buildgo.go
@@ -25,8 +25,6 @@
 	"golang.org/x/build/internal/sourcecache"
 )
 
-const subrepoPrefix = "golang.org/x/"
-
 // BuilderRev is a build configuration type and a revision.
 type BuilderRev struct {
 	Name string // e.g. "linux-amd64-race"
@@ -177,16 +175,17 @@
 
 // FetchSubrepo checks out the go.googlesource.com repository
 // repo (for example, "net" or "oauth2") at git revision rev,
-// and places it into the buildlet's GOPATH workspace.
+// and places it into the buildlet's GOPATH workspace at
+// $GOPATH/src/<importPath>.
 //
 // The GOPATH workspace is assumed to be the "gopath" directory
 // in the buildlet's work directory.
-func FetchSubrepo(ctx context.Context, sl spanlog.Logger, bc *buildlet.Client, repo, rev string) error {
+func FetchSubrepo(ctx context.Context, sl spanlog.Logger, bc *buildlet.Client, repo, rev, importPath string) error {
 	tgz, err := sourcecache.GetSourceTgz(sl, repo, rev)
 	if err != nil {
 		return err
 	}
-	return bc.PutTar(ctx, tgz, "gopath/src/"+subrepoPrefix+repo)
+	return bc.PutTar(ctx, tgz, "gopath/src/"+importPath)
 }
 
 // VersionTgz returns an io.Reader of a *.tar.gz file containing only