mirror of
https://github.com/golang/go
synced 2024-11-27 00:01:23 -07:00
cmd/distpack: rename go.mod to _go.mod in toolchain modules
Modules cannot contain go.mod files except at the root (and we don't keep one at the root). Rename the other go.mod files to _go.mod. dl2mod, which we used to convert all the old releases, did this renaming, but it was missed when porting that code to distpack. For #57001. Fixes #60847. Change-Id: I4d646b96b5be15df3b79193e254ddc9b11cc8734 Reviewed-on: https://go-review.googlesource.com/c/go/+/503979 Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
6459494014
commit
3b4b7b84de
@ -92,7 +92,7 @@ func (a *Archive) Add(name, src string, info fs.FileInfo) {
|
||||
}
|
||||
|
||||
// Sort sorts the files in the archive.
|
||||
// It is only necessary to call Sort after calling Add.
|
||||
// It is only necessary to call Sort after calling Add or RenameGoMod.
|
||||
// ArchiveDir returns a sorted archive, and the other methods
|
||||
// preserve the sorting of the archive.
|
||||
func (a *Archive) Sort() {
|
||||
@ -164,6 +164,16 @@ func (a *Archive) SetTime(t time.Time) {
|
||||
}
|
||||
}
|
||||
|
||||
// RenameGoMod renames the go.mod files in the archive to _go.mod,
|
||||
// for use with the module form, which cannot contain other go.mod files.
|
||||
func (a *Archive) RenameGoMod() {
|
||||
for i, f := range a.Files {
|
||||
if strings.HasSuffix(f.Name, "/go.mod") {
|
||||
a.Files[i].Name = strings.TrimSuffix(f.Name, "go.mod") + "_go.mod"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func amatch(pattern, name string) (bool, error) {
|
||||
// firstN returns the prefix of name corresponding to the first n path elements.
|
||||
// If n <= 0, firstN returns the entire name.
|
||||
|
@ -14,6 +14,17 @@
|
||||
// A cross-compiled distribution for goos/goarch can be built using:
|
||||
//
|
||||
// GOOS=goos GOARCH=goarch ./make.bash -distpack
|
||||
//
|
||||
// To test that the module downloads are usable with the go command:
|
||||
//
|
||||
// ./make.bash -distpack
|
||||
// mkdir -p /tmp/goproxy/golang.org/toolchain/
|
||||
// ln -sf $(pwd)/../pkg/distpack /tmp/goproxy/golang.org/toolchain/@v
|
||||
// GOPROXY=file:///tmp/goproxy GOTOOLCHAIN=$(sed 1q ../VERSION) gotip version
|
||||
//
|
||||
// gotip can be replaced with an older released Go version once there is one.
|
||||
// It just can't be the one make.bash built, because it knows it is already that
|
||||
// version and will skip the download.
|
||||
package main
|
||||
|
||||
import (
|
||||
@ -199,6 +210,8 @@ func main() {
|
||||
)
|
||||
modVers := modVersionPrefix + "-" + version + "." + goosDashGoarch
|
||||
modArch.AddPrefix(modPath + "@" + modVers)
|
||||
modArch.RenameGoMod()
|
||||
modArch.Sort()
|
||||
testMod(modArch)
|
||||
|
||||
// distpack returns the full path to name in the distpack directory.
|
||||
|
@ -95,6 +95,10 @@ var modRules = []testRule{
|
||||
{name: "golang.org/toolchain@*/pkg/tool/*/compile", goos: "darwin"},
|
||||
{name: "golang.org/toolchain@*/pkg/tool/*/compile", goos: "windows", exclude: true},
|
||||
{name: "golang.org/toolchain@*/pkg/tool/*/compile.exe", goos: "windows"},
|
||||
|
||||
// go.mod are renamed to _go.mod.
|
||||
{name: "**/go.mod", exclude: true},
|
||||
{name: "**/_go.mod"},
|
||||
}
|
||||
|
||||
func testSrc(a *Archive) {
|
||||
|
Loading…
Reference in New Issue
Block a user