]> Cypherpunks repositories - gostls13.git/commit
cmd/dist: add -distpack flag to build distribution archives
authorRuss Cox <rsc@golang.org>
Thu, 19 Jan 2023 22:04:07 +0000 (17:04 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 11 Apr 2023 21:29:13 +0000 (21:29 +0000)
commit1635205a72d26721af54f01ccbab8e0b51ded3a9
tree86d7a24dc8f7ebc543106e6b99a7566ffc458203
parent2fcca5d52dd3d23ec2ca3a81e588e0f9d877ca69
cmd/dist: add -distpack flag to build distribution archives

We want to enable others to reproduce the exact distribution archives
we are serving on go.dev/dl. Today the code for building those
archives lives in golang.org/x/build, which is fundamentally tied to
running on the Go team build infrastructure and not easy for others to
run. This CL adds a new flag -distpack to cmd/dist, usually invoked as
make.bash -distpack, to build the distribution archives using code in
the main repository that anyone can run. Starting in Go 1.21,
the Go team build infrastructure will run this instead of its current
custom code to build those archives.

The current builds are not reproducible even given identical
infrastructure, because the archives are stamped with the current
time. It is helpful to have a timestamp in the archives indicating
when the code is from, but that time needs to be reproducible.
To ensure this, the new -distpack flag extends the VERSION file to
include a time stamp, which it uses as the modification time for all
files in the archive.

The new -distpack flag is implemented by a separate program,
cmd/distpack, instead of being in cmd/dist, so that it can be compiled
by the toolchain being distributed and not the bootstrap toolchain.
Otherwise details like the exact compression algorithms might vary
from one bootstrap toolchain to another and produce non-reproducible
builds. So there is a new 'go tool distpack', but it's omitted from
the distributions themselves, just as 'go tool dist' is.

make.bash already accepts any flags for cmd/dist, including -distpack.
make.bat is less sophisticated and looks for each known flag, so this
CL adds an update to look for -distpack. The CL also changes make.bat
to accept the idiomatic Go -flagname in addition to the non-idiomatic
(for Go) --flagname. Previously it insisted on the --flag form.

I have confirmed that using make.bash -distpack produces the
identical distribution archives for windows/amd64, linux/amd64,
darwin/amd64, and darwin/arm64 whether it is run on
windows/amd64, linux/amd64, or darwin/amd64 hosts.

For #24904.

Change-Id: Ie6d69365ee3d7294d05b4f96ffb9159b41918074
Reviewed-on: https://go-review.googlesource.com/c/go/+/470676
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Carlos Amedee <amedee@google.com>
src/cmd/dist/build.go
src/cmd/distpack/archive.go [new file with mode: 0644]
src/cmd/distpack/archive_test.go [new file with mode: 0644]
src/cmd/distpack/pack.go [new file with mode: 0644]
src/cmd/distpack/test.go [new file with mode: 0644]
src/make.bat