12345678910111213141516171819202122232425262728293031323334 |
- From 958f724b1b434702c3d44ceaca646791674d07b1 Mon Sep 17 00:00:00 2001
- From: Georg Koppen <gk@torproject.org>
- Date: Fri, 17 Apr 2020 10:24:23 +0000
- Subject: [PATCH] Use fixed go-build tmp directory
- Use fixed go-build tmp directory, when the directory does not exist, in
- order to avoid some reproducibility issues where build directory gets
- embedded in generated binaries.
- diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go
- index 33b7818fb2..5e369d0f53 100644
- --- a/src/cmd/go/internal/work/action.go
- +++ b/src/cmd/go/internal/work/action.go
- @@ -249,9 +249,13 @@ func (b *Builder) Init() {
- if cfg.BuildN {
- b.WorkDir = "$WORK"
- } else {
- - tmp, err := ioutil.TempDir(cfg.Getenv("GOTMPDIR"), "go-build")
- - if err != nil {
- - base.Fatalf("go: creating work dir: %v", err)
- + tmp := filepath.Join(cfg.Getenv("GOTMPDIR"), "go-build-workdir")
- + _, err := os.Stat(tmp)
- + if !os.IsNotExist(err) {
- + tmp, err = ioutil.TempDir(cfg.Getenv("GOTMPDIR"), "go-build")
- + if err != nil {
- + base.Fatalf("go: creating work dir: %v", err)
- + }
- }
- if !filepath.IsAbs(tmp) {
- abs, err := filepath.Abs(tmp)
- --
- 2.26.1
|