0001-Use-fixed-go-build-tmp-directory.patch 1.1 KB

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