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

12345678910111213141516171819202122232425262728293031323334
  1. From 44e3391a5a3d9a2c4b57f78e43414465ab84681e Mon Sep 17 00:00:00 2001
  2. From: Nicolas Vigier <boklm@torproject.org>
  3. Date: Thu, 27 Jun 2019 19:21:05 +0200
  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. ---
  9. src/cmd/go/internal/work/action.go | 10 +++++++---
  10. 1 file changed, 7 insertions(+), 3 deletions(-)
  11. diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go
  12. index 1f91046eb1..ba74b26a38 100644
  13. --- a/src/cmd/go/internal/work/action.go
  14. +++ b/src/cmd/go/internal/work/action.go
  15. @@ -224,9 +224,13 @@ func (b *Builder) Init() {
  16. if cfg.BuildN {
  17. b.WorkDir = "$WORK"
  18. } else {
  19. - tmp, err := ioutil.TempDir(os.Getenv("GOTMPDIR"), "go-build")
  20. - if err != nil {
  21. - base.Fatalf("go: creating work dir: %v", err)
  22. + tmp := filepath.Join(os.Getenv("GOTMPDIR"), "go-build-workdir")
  23. + _, err := os.Stat(tmp)
  24. + if !os.IsNotExist(err) {
  25. + tmp, err = ioutil.TempDir(os.Getenv("GOTMPDIR"), "go-build")
  26. + if err != nil {
  27. + base.Fatalf("go: creating work dir: %v", err)
  28. + }
  29. }
  30. if !filepath.IsAbs(tmp) {
  31. abs, err := filepath.Abs(tmp)