Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
38d21cc
Fork 1.17 from main branch
dagood Jan 26, 2022
50ba7c0
Switch to 1ES servicing pools on microsoft/release-branch.go1.17 (#238)
jonfortescue Oct 20, 2021
a0895e3
[microsoft/release-branch.go1.17] Add "make" retry capability, with 5…
dagood Dec 6, 2021
1566253
Update submodule to dev.boringcrypto.go1.17; patch
dagood Jan 27, 2022
1ab9abc
Fork 1.16 from 1.17 branch
dagood Jan 27, 2022
5ef23a6
Update submodule to latest release-branch.go1.17 (539d430e): [release…
Jan 28, 2022
a35e8f7
Merge pull request #389 from microsoft/dev/auto-sync/microsoft/releas…
Jan 28, 2022
b06f38c
Add FIPS OpenSSL documentation
qmuntal Jan 28, 2022
cdf3574
Find submodule VERSION file for build asset json (#391)
dagood Jan 31, 2022
ea9cc8e
Merge pull request #392 from microsoft/dev/dagood/fips-readme
dagood Jan 31, 2022
04d9343
Update submodule to latest release-branch.go1.17 (1b867ce3): [release…
Feb 4, 2022
86be7f0
Merge pull request #405 from microsoft/dev/auto-sync/microsoft/releas…
Feb 4, 2022
7f876da
Update submodule to latest release-branch.go1.17 (1952c65f): [release…
Feb 9, 2022
12e9183
Merge pull request #411 from microsoft/dev/auto-sync/microsoft/releas…
Feb 9, 2022
d52c9c6
Create source archive during CI (#408) (#413)
dagood Feb 9, 2022
0a17315
Merge 'microsoft/release-branch.go1.16' into microsoft/release-branch…
dagood Feb 9, 2022
4a14e62
Fix up patch with 3-way resolution
dagood Feb 9, 2022
b1e24c4
Merge pull request #414 from dagood/dev/dagood/merge-1.17-from-1.16
dagood Feb 9, 2022
6e4168f
Merge 'microsoft/release-branch.go1.17' into microsoft/dev.boringcryp…
dagood Feb 9, 2022
6a9a55a
Merge pull request #417 from dagood/dev/dagood/merge-b1.17-from-1.17
dagood Feb 9, 2022
13c3cef
Update submodule to latest release-branch.go1.16 (0a6cf870): [release…
Feb 9, 2022
73d4cc3
Merge pull request #420 from microsoft/dev/auto-sync/microsoft/releas…
Feb 10, 2022
d240ef9
Update submodule to latest tag, go1.17.7 (#422)
dagood Feb 10, 2022
e368833
Update submodule to latest release-branch.go1.17 (cd6e0d7c): [release…
Feb 11, 2022
20c7363
Update submodule to latest dev.boringcrypto.go1.17 (172559d2): [dev.b…
Feb 11, 2022
b602aec
Merge pull request #425 from microsoft/dev/auto-sync/microsoft/releas…
Feb 11, 2022
50a0608
Merge pull request #426 from microsoft/dev/auto-sync/microsoft/dev.bo…
Feb 11, 2022
6a38a08
Update go-infra: detect VERSION or go/VERSION (#429) (#433)
dagood Feb 15, 2022
6e23ec4
Merge 'microsoft/release-branch.go1.16' into dev/dagood/merge-1.17-fr…
dagood Feb 15, 2022
29d325a
Merge pull request #436 from dagood/dev/dagood/merge-1.17-from-1.16
dagood Feb 15, 2022
ba9fb97
Merge 'microsoft/release-branch.go1.17' into dev/dagood/merge-b1.17-f…
dagood Feb 15, 2022
001ce31
Add VERSION file: 1.17.7
dagood Feb 15, 2022
e27e251
Update submodule to latest dev.boringcrypto.go1.17 (6666adc1): [dev.b…
Feb 16, 2022
ddd2ddc
Merge pull request #439 from microsoft/dev/auto-sync/microsoft/dev.bo…
Feb 16, 2022
d0cc051
Merge pull request #437 from dagood/dev/dagood/merge-b1.17-from-1.17
dagood Feb 16, 2022
96ce61a
Update submodule to latest release-branch.go1.17 (7d8fa657): [release…
Feb 18, 2022
8546ef6
Merge pull request #443 from microsoft/dev/auto-sync/microsoft/releas…
Feb 18, 2022
690c325
Update submodule to latest release-branch.go1.17 (7dd10d4c): [release…
Mar 3, 2022
50b5a3a
Merge pull request #460 from microsoft/dev/auto-sync/microsoft/releas…
Mar 3, 2022
c4f89b7
Add pointer in FIPS docs to new location (#457)
dagood Mar 7, 2022
9645f3c
Update submodule to latest dev.boringcrypto.go1.17 (4ea866a9): [dev.b…
Mar 7, 2022
c32828c
Merge pull request #467 from microsoft/dev/auto-sync/microsoft/dev.bo…
Mar 7, 2022
396389c
Update submodule to latest release-branch.go1.17 (88be85f1): [release…
Mar 15, 2022
ab0c6ab
Merge pull request #480 from microsoft/dev/auto-sync/microsoft/releas…
Mar 15, 2022
4b02077
[microsoft/release-branch.go1.17] Add linux-arm64 builders (#495)
dagood Mar 25, 2022
8c1418a
gate openssl backend behind cgo build constraint (#503)
qmuntal Mar 29, 2022
0018dc9
Fix version; increment Microsoft revision (#507)
dagood Mar 29, 2022
dfb9361
Update submodule to latest release-branch.go1.17 (4e69fddc): [release…
Mar 30, 2022
43cc740
Merge pull request #509 from microsoft/dev/auto-sync/microsoft/releas…
Mar 30, 2022
924c64b
Rearrange FIPS patches, start at 0100 (#514)
dagood Mar 31, 2022
34faa82
Merge 'microsoft/release-branch.go1.17' into dev/dagood/merge-b1.17-f…
dagood Mar 31, 2022
f971b14
Use FIPS-enabled Mariner image when running CI tests
qmuntal Apr 1, 2022
b81ff1e
Merge pull request #517 from dagood/dev/dagood/merge-b1.17-from-1.17
dagood Apr 1, 2022
cc3355e
Merge branch 'microsoft/dev.boringcrypto.go1.17' into dev/qmuntal/fix…
qmuntal Apr 4, 2022
e258137
Update run-job.yml
qmuntal Apr 4, 2022
1bc6820
Merge pull request #521 from microsoft/dev/qmuntal/fix-url-go1.17
qmuntal Apr 7, 2022
d2b3c0a
Update submodule to latest release-branch.go1.17 (346b18ee): [release…
Apr 12, 2022
2f62271
Merge pull request #526 from microsoft/dev/auto-sync/microsoft/releas…
Apr 12, 2022
2eb964a
Update submodule to latest dev.boringcrypto.go1.17 (ed86dfc4): [dev.b…
Apr 14, 2022
4eef17c
Merge pull request #528 from microsoft/dev/auto-sync/microsoft/dev.bo…
Apr 14, 2022
111b830
Update version to 1.17.9-1 (#529)
dagood Apr 14, 2022
a3dfe91
Add test retries on Windows CI (#475)
dagood Apr 7, 2022
3b1a957
Add arm/v6 cross-compiled build (#523)
dagood Apr 20, 2022
d2c7206
Merge pull request #534 from dagood/dev/dagood/port-1.17
dagood Apr 20, 2022
31f1d43
Merge 'microsoft/release-branch.go1.17' into dev/dagood/merge-b1.17-f…
dagood Apr 20, 2022
78da40e
Merge pull request #536 from dagood/dev/dagood/merge-b1.17-from-1.17
dagood Apr 20, 2022
8db55fd
Update submodule to latest release-branch.go1.17 (2150be1a): [release…
May 6, 2022
bd68f71
Merge pull request #544 from microsoft/dev/auto-sync/microsoft/releas…
May 6, 2022
67f2af9
Update submodule to latest release-branch.go1.17 (78992411): [release…
May 9, 2022
91e335b
Merge pull request #551 from microsoft/dev/auto-sync/microsoft/releas…
May 9, 2022
989e3ed
Update submodule to latest release-branch.go1.17 (085c61ae): [release…
May 10, 2022
69ec492
Resolve patch conflicts: neighboring line changes
dagood May 10, 2022
c59dd44
Merge pull request #554 from microsoft/dev/auto-sync/microsoft/releas…
May 10, 2022
82bc6f9
Update submodule to latest dev.boringcrypto.go1.17 (6b07de79): [dev.b…
May 10, 2022
6736ef4
Merge branch 'microsoft/release-branch.go1.17' into dev/auto-sync/mic…
dagood May 10, 2022
be67047
Update VERSION to 1.17.10
dagood May 10, 2022
bf7c9fd
Merge pull request #557 from microsoft/dev/auto-sync/microsoft/dev.bo…
May 10, 2022
a2cff57
upgrade go-crypto-openssl
qmuntal May 12, 2022
b6b4365
Merge pull request #563 from microsoft/dev/qmuntal/go1.17-bump-openssl
qmuntal May 14, 2022
bcaa2ae
Update submodule to latest dev.boringcrypto.go1.17 (4658e6e3): [dev.b…
Jun 2, 2022
ec654e8
Merge pull request #592 from microsoft/dev/auto-sync/microsoft/dev.bo…
Jun 2, 2022
e8d3dac
Update submodule to latest dev.boringcrypto.go1.17 (7d5078e3): [dev.b…
Jul 13, 2022
37bb4ef
Merge pull request #634 from microsoft/dev/auto-sync/microsoft/dev.bo…
Jul 13, 2022
a57a91c
Update submodule to latest dev.boringcrypto.go1.17 (7d5078e3): [dev.b…
Jul 13, 2022
d234ade
Merge pull request #637 from microsoft/dev/auto-sync/microsoft/dev.bo…
Jul 13, 2022
c0efbba
Update submodule to latest dev.boringcrypto.go1.17 (349da2d4): [dev.b…
Aug 1, 2022
cdb5479
Merge pull request #676 from microsoft/dev/auto-sync/microsoft/dev.bo…
Aug 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go1.17.13
190 changes: 163 additions & 27 deletions eng/_core/archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,49 @@ import (
"io"
"io/fs"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"time"
)

// CreateFromSource runs a Git command to generate an archive file from the Go source code at
// "source". If output is "", the archive is produced in the build directory inside the
// "eng/artifacts/bin" directory. A checksum file is also produced.
func CreateFromSource(source string, output string) error {
fmt.Printf("---- Creating Go source archive (tarball) from '%v'...\n", source)

if output == "" {
output = filepath.Join(getBinDir(source), fmt.Sprintf("go.%v.src.tar.gz", getBuildID()))
}

// Ensure the target directory exists.
archiveDir := filepath.Dir(output)
if err := os.MkdirAll(archiveDir, os.ModeDir|os.ModePerm); err != nil {
return err
}

// Use "^{tree}" to avoid Git including a global extended pax header. The commit it would list
// is a temporary commit, and would only be confusing. See https://git-scm.com/docs/git-archive.
cmd := exec.Command("git", "archive", "-o", output, "--prefix=go/", "HEAD^{tree}")
cmd.Dir = source
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
fmt.Printf("---- Running command: %v\n", cmd.Args)
if err := cmd.Run(); err != nil {
return err
}

fmt.Printf("---- Creating checksum file...\n")
if err := writeSHA256ChecksumFile(output); err != nil {
return err
}

fmt.Printf("---- Pack complete.\n")
return nil
}

// CreateFromBuild walks the Go build directory at "source" and produces an archive with the path
// "output". If output is "", CreateFromBuild produces a file in the build directory inside the
// "eng/artifacts/bin" directory. The output directory is created if it doesn't exist. This function
Expand All @@ -30,25 +67,14 @@ import (
// The inclusion of some files depends on the OS/ARCH. If output is specified, its filename must
// follow the pattern "*{GOOS}-{GOARCH}{extension}" so OS and ARCH can be detected. If output is not
// specified, the current Go runtime's OS and ARCH are used.
func CreateFromBuild(source string, output string) error {
//
// If runtime.GOOS and runtime.GOARCH don't match the OS/ARCH of the output file name, the build
// directory is treated as a cross-compiled build of Go.
func CreateFromBuild(source, output string) error {
fmt.Printf("---- Creating Go archive (zip/tarball) from '%v'...\n", source)

if output == "" {
// If BUILD_BUILDNUMBER is defined (e.g. a CI build), use it. For local builds, use "dev".
archiveVersion := os.Getenv("BUILD_BUILDNUMBER")
if archiveVersion == "" {
archiveVersion = "dev"
}

archiveExtension := ".tar.gz"
if runtime.GOOS == "windows" {
archiveExtension = ".zip"
}

archiveName := fmt.Sprintf("go.%v.%v-%v%v", archiveVersion, runtime.GOOS, runtime.GOARCH, archiveExtension)
binDir := filepath.Join(source, "..", "eng", "artifacts", "bin")

output = filepath.Join(binDir, archiveName)
output = DefaultBuildOutputPath(source, "", "")
}

// Ensure the target directory exists.
Expand Down Expand Up @@ -81,6 +107,22 @@ func CreateFromBuild(source string, output string) error {
filepath.Join("pkg", "tool", os+"_"+arch, "api.exe"),
}

hostOS := runtime.GOOS
hostArch := runtime.GOARCH
if hostOS != os || hostArch != arch {
fmt.Printf("Handling cross-compile: %v-%v host to %v-%v target\n", hostOS, hostArch, os, arch)
skipPaths = append(skipPaths, []string{
// Don't include binaries that were built for the host toolchain.
filepath.Join("pkg", hostOS+"_"+hostArch),
filepath.Join("pkg", "tool", hostOS+"_"+hostArch),
// Don't include the host binaries: the target binaries are in a subdir.
filepath.Join("bin", "go"),
filepath.Join("bin", "go.exe"),
filepath.Join("bin", "gofmt"),
filepath.Join("bin", "gofmt.exe"),
}...)
}

// Figure out what the race detection syso (precompiled binary) is named for the current
// os/arch. We want to exclude all race syso files other than this one.
targetRuntimeRaceSyso := fmt.Sprintf("race_%v_%v.syso", os, arch)
Expand All @@ -89,17 +131,26 @@ func CreateFromBuild(source string, output string) error {
// data the script has processed to avoid appearing unresponsive.
lastProgressUpdate := time.Now()

filepath.WalkDir(source, func(path string, info fs.DirEntry, err error) error {
// Keep track of target paths added to the archive (key) and the source path that it comes from
// (value). This map ensures no target files are double-added.
addedPaths := make(map[string]string)
// Keep track of dir entries that have been added.
addedDirs := make(map[string]struct{})

err := filepath.WalkDir(source, func(path string, info fs.DirEntry, err error) error {
if err != nil {
fmt.Printf("Failure accessing a path %q: %v\n", path, err)
return err
}

relPath, err := filepath.Rel(source, path)
if err != nil {
panic(err)
return err
}

// targetPath is where relPath should be placed in the output archive, if it belongs inside.
targetPath := relPath

// Walk every dir/file in the root of the repository.
if relPath == "." {
// Ignore the rest of the logic in this func by returning nil early.
Expand Down Expand Up @@ -138,6 +189,11 @@ func CreateFromBuild(source string, output string) error {
}
}

// Include "bin/{OS}_{ARCH}/go" as "bin/go" if this is a cross-compilation build.
if filepath.Dir(relPath) == filepath.Join("bin", os+"_"+arch) {
targetPath = filepath.Join("bin", filepath.Base(relPath))
}

// Skip race detection syso file if it doesn't match the target runtime.
//
// Ignore error: the only possible error is one that says the pattern is invalid (see
Expand All @@ -151,16 +207,52 @@ func CreateFromBuild(source string, output string) error {

if info.IsDir() {
// We want to continue the recursive search in this directory for more files, but we
// don't need to add it to the archive. Return nil to continue.
// don't necessarily want to add this dir to the archive. Return nil to continue.
return nil
}

// At this point, we know "path" is a file that should be included. Add it.
archiver.AddFile(
path,
// Store everything in a root "go" directory to match upstream Go archives.
filepath.Join("go", relPath),
)
if relPath != targetPath {
fmt.Printf("Archiving %#q as %#q\n", relPath, targetPath)
}

if otherSource, ok := addedPaths[targetPath]; ok {
return fmt.Errorf(
"adding archive file %#q from %#q, but target already added from %#q",
targetPath, relPath, otherSource)
}
addedPaths[targetPath] = relPath

// At this point, we know "path" is a file that should be included. Add it. Store everything
// in a root "go" directory to match upstream Go archives.
goTargetPath := filepath.Join("go", targetPath)
if err := archiver.AddFile(path, goTargetPath); err != nil {
return err
}

// Add all dirs that are ancestors of this target file. Even though explicitly added dirs
// aren't necessary to create a valid archive file, upstream does this, so we do too. This
// reduces the diff, e.g. when comparing results with tools like "tar -tf".
dir := goTargetPath
for {
dir = filepath.Dir(dir)
if dir == "." {
break
}
if dir == "/" {
return fmt.Errorf("unexpected rooted target path: %#q", goTargetPath)
}

if _, ok := addedDirs[dir]; ok {
break
}
// Use root repository dir as a stand-in for any filesystem information. This is simpler
// than reproducing the actual dir's path based on the target path, especially
// considering the target path may not match up with a directory that actually exists.
if err := archiver.AddFile(source, dir); err != nil {
return err
}
addedDirs[dir] = struct{}{}
}

// If it's been long enough, log an update on our progress.
now := time.Now()
Expand All @@ -174,6 +266,9 @@ func CreateFromBuild(source string, output string) error {

return nil
})
if err != nil {
return err
}

fmt.Printf(
"Complete! %v (%v kB uncompressed data archived)\n",
Expand All @@ -186,20 +281,61 @@ func CreateFromBuild(source string, output string) error {
}

fmt.Printf("---- Creating checksum file...\n")
writeSHA256ChecksumFile(output)
if err := writeSHA256ChecksumFile(output); err != nil {
return err
}

fmt.Printf("---- Pack complete.\n")
return nil
}

// DefaultBuildOutputPath returns the default path to place the output archive given a built Go
// directory. Optionally takes os and arch, or detects their values from the environment and runtime
// if empty string.
func DefaultBuildOutputPath(source, os, arch string) string {
if os == "" {
os = runtime.GOOS
}
if arch == "" {
arch = runtime.GOARCH
}
// Add "v6l" suffix to "arm" arch. More robust handling would be necessary if there were
// multiple "arm" builds with GOARM=6 and GOARM=7, but there are not, and "arm64" obsoletes it.
if arch == "arm" {
arch += "v6l"
}

ext := ".tar.gz"
if runtime.GOOS == "windows" {
ext = ".zip"
}

archiveName := fmt.Sprintf("go.%v.%v-%v%v", getBuildID(), os, arch, ext)
return filepath.Join(getBinDir(source), archiveName)
}

// getBuildID returns BUILD_BUILDNUMBER if defined (e.g. a CI build). Otherwise, "dev".
func getBuildID() string {
archiveVersion := os.Getenv("BUILD_BUILDNUMBER")
if archiveVersion == "" {
return "dev"
}
return archiveVersion
}

func getBinDir(source string) string {
return filepath.Join(source, "..", "eng", "artifacts", "bin")
}

// getArchivePathRuntime takes a path like "go1.7.linux-amd64.tar.gz" and extension like ".tar.gz",
// and returns the os (linux) and arch (amd64). The "path" extension may have multiple '.'
// characters in it, so "ext" must be passed in explicitly or else the match would be ambiguous.
func getArchivePathRuntime(path string, ext string) (os string, arch string) {
pathNoExt := path[0 : len(path)-len(ext)]
firstRuntimeIndex := strings.LastIndex(pathNoExt, ".") + 1
osArch := strings.Split(pathNoExt[firstRuntimeIndex:], "-")
return osArch[0], osArch[1]
// "v6l" is added to the end of the "arm" arch filename, but is not part of the arch. Remove it.
return osArch[0], strings.TrimSuffix(osArch[1], "v6l")
}

// writeSHA256ChecksumFile reads the content of the file at the given path into a SHA256 hasher, and
Expand Down
40 changes: 31 additions & 9 deletions eng/_core/archive/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,20 @@ func (a *tarGzArchiver) AddFile(filePath string, archivePath string) error {

// tar.FileInfoHeader only takes base name, so set full path here. See FileInfoHeader doc.
header.Name = archivePath
if stat.IsDir() {
header.Name += "/"
}

if err := a.tarWriter.WriteHeader(header); err != nil {
return err
}

n, err := io.Copy(a.tarWriter, fileReader)
a.processedBytes += n
return err
if !stat.IsDir() {
n, err := io.Copy(a.tarWriter, fileReader)
a.processedBytes += n
return err
}
return nil
}

func (a *tarGzArchiver) Close() error {
Expand Down Expand Up @@ -129,20 +135,36 @@ func newZipArchiver(path string) *zipArchiver {
}

func (a *zipArchiver) AddFile(filePath string, archivePath string) error {
archiveFileWriter, err := a.writer.Create(archivePath)
fileReader, err := os.Open(filePath)
if err != nil {
return err
}
defer fileReader.Close()

fileReader, err := os.Open(filePath)
stat, err := fileReader.Stat()
if err != nil {
return err
}
defer fileReader.Close()

n, err := io.Copy(archiveFileWriter, fileReader)
a.processedBytes += n
return err
// Upstream Go uses "/" for archive dir separators, even on Windows.
archivePath = filepath.ToSlash(archivePath)

// Give dirs a trailing forward slash to indicate to the zip writer that it's a dir.
if stat.IsDir() {
archivePath += "/"
}

archiveFileWriter, err := a.writer.Create(archivePath)
if err != nil {
return err
}

if !stat.IsDir() {
n, err := io.Copy(archiveFileWriter, fileReader)
a.processedBytes += n
return err
}
return nil
}

func (a *zipArchiver) Close() error {
Expand Down
Loading