setup_go_for_windows7.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. VERSION="1.25.8"
  4. PATCH_COMMITS=(
  5. "466f6c7a29bc098b0d4c987b803c779222894a11"
  6. "1bdabae205052afe1dadb2ad6f1ba612cdbc532a"
  7. "a90777dcf692dd2168577853ba743b4338721b06"
  8. "f6bddda4e8ff58a957462a1a09562924d5f3d05c"
  9. "bed309eff415bcb3c77dd4bc3277b682b89a388d"
  10. "34b899c2fb39b092db4fa67c4417e41dc046be4b"
  11. )
  12. CURL_ARGS=(
  13. -fL
  14. --silent
  15. --show-error
  16. )
  17. if [[ -n "${GITHUB_TOKEN:-}" ]]; then
  18. CURL_ARGS+=(-H "Authorization: Bearer ${GITHUB_TOKEN}")
  19. fi
  20. mkdir -p "$HOME/go"
  21. cd "$HOME/go"
  22. wget "https://dl.google.com/go/go${VERSION}.linux-amd64.tar.gz"
  23. tar -xzf "go${VERSION}.linux-amd64.tar.gz"
  24. mv go go_win7
  25. cd go_win7
  26. # modify from https://github.com/restic/restic/issues/4636#issuecomment-1896455557
  27. # these patch URLs only work on golang1.25.x
  28. # that means after golang1.26 release it must be changed
  29. # see: https://github.com/MetaCubeX/go/commits/release-branch.go1.25/
  30. # revert:
  31. # 693def151adff1af707d82d28f55dba81ceb08e1: "crypto/rand,runtime: switch RtlGenRandom for ProcessPrng"
  32. # 7c1157f9544922e96945196b47b95664b1e39108: "net: remove sysSocket fallback for Windows 7"
  33. # 48042aa09c2f878c4faa576948b07fe625c4707a: "syscall: remove Windows 7 console handle workaround"
  34. # a17d959debdb04cd550016a3501dd09d50cd62e7: "runtime: always use LoadLibraryEx to load system libraries"
  35. # fixes:
  36. # bed309eff415bcb3c77dd4bc3277b682b89a388d: "Fix os.RemoveAll not working on Windows7"
  37. # 34b899c2fb39b092db4fa67c4417e41dc046be4b: "Revert \"os: remove 5ms sleep on Windows in (*Process).Wait\""
  38. for patch_commit in "${PATCH_COMMITS[@]}"; do
  39. curl "${CURL_ARGS[@]}" "https://github.com/MetaCubeX/go/commit/${patch_commit}.diff" | patch --verbose -p 1
  40. done