cmd/go: remove TestScript/version_buildvcs_git_gpg

This was a regression test added for a 'git' command line
used for build stamping. Unfortunately, 'gpg' has proved to
be extremely fragile:

* In recent versions, it appears to always require 'gpg-agent' to be
  installed for anything involving secret keys, but for some reason is
  not normally marked as requiring gpg-agent in Debian's package
  manager.

* It tries to create a Unix domain socket in a subdirectory of $TMPDIR
  without checking the path length, which fails when $TMPDIR is too
  long to fit in the 'sun_path' field of a sockaddr_un struct (which
  typically tops out somewhere between 92 and 108 bytes).

We could theoretically address those by artificially reducing the
script's TMPDIR length and checking for gpg-agent in addition to gpg,
but arguably those should both be fixed upstream instead. On balance,
the incremental value that this test provides does not seem worth the
complexity of dealing with such a fragile third-party tool.

Updates #50675.
Updates #48802.
Fixes #57034.

Change-Id: Ia3288c2f84f8db86ddfa139b4d1c0112d67079ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/454502
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
Bryan C. Mills 2022-12-02 14:11:00 -05:00 committed by Gopher Robot
parent 5efa4dab91
commit 45f5ef4ed7
1 changed files with 0 additions and 107 deletions

View File

@ -1,107 +0,0 @@
# This test checks that VCS information is stamped into Go binaries even when
# the current commit is signed and the use has configured git to display commit
# signatures.
[!git] skip
[!exec:gpg] skip
[short] skip
env GOBIN=$GOPATH/bin
env GNUPGHOME=$WORK/.gpupg
mkdir $GNUPGHOME
chmod 0700 $GNUPGHOME
# Create GPG key
exec gpg --batch --passphrase '' --quick-generate-key --verbose gopher@golang.org
exec gpg --list-secret-keys --with-colons gopher@golang.org
cp stdout keyinfo.txt
go run extract_key_id.go keyinfo.txt
cp stdout keyid.txt
# Initialize repo
cd repo/
exec git init
exec git config user.email gopher@golang.org
exec git config user.name 'J.R. Gopher'
exec git config --add log.showSignature true
go run ../configure_signing_key.go ../keyid.txt
# Create signed commit
cd a
exec git add -A
exec git commit -m 'initial commit' --gpg-sign
exec git log
# Verify commit signature does not interfere with versioning
go install
go version -m $GOBIN/a
stdout '^\tbuild\tvcs\.revision='
stdout '^\tbuild\tvcs\.time='
stdout '^\tbuild\tvcs\.modified=false$'
-- repo/README --
Far out in the uncharted backwaters of the unfashionable end of the western
spiral arm of the Galaxy lies a small, unregarded yellow sun.
-- repo/a/go.mod --
module example.com/a
go 1.18
-- repo/a/a.go --
package main
func main() {}
-- extract_key_id.go --
package main
import (
"fmt"
"os"
"strings"
)
func main() {
err := run(os.Args[1])
if err != nil {
panic(err)
}
}
func run(keyInfoFilePath string) error {
contents, err := os.ReadFile(keyInfoFilePath)
if err != nil {
return err
}
lines := strings.Split(string(contents), "\n")
for _, line := range lines {
fields := strings.Split(line, ":")
if fields[0] == "sec" {
fmt.Print(fields[4])
return nil
}
}
return fmt.Errorf("key ID not found in: %s", keyInfoFilePath)
}
-- configure_signing_key.go --
package main
import (
"os"
"os/exec"
)
func main() {
err := run(os.Args[1])
if err != nil {
panic(err)
}
}
func run(keyIdFilePath string) error {
keyId, err := os.ReadFile(keyIdFilePath)
if err != nil {
return err
}
gitCmd := exec.Command("git", "config", "user.signingKey", string(keyId))
return gitCmd.Run()
}