build.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env bash
  2. repoFolder="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  3. cd $repoFolder
  4. koreBuildZip="https://github.com/aspnet/KoreBuild/archive/1.0.0.zip"
  5. if [ ! -z $KOREBUILD_ZIP ]; then
  6. koreBuildZip=$KOREBUILD_ZIP
  7. fi
  8. buildFolder=".build"
  9. buildFile="$buildFolder/KoreBuild.sh"
  10. if test ! -d $buildFolder; then
  11. echo "Downloading KoreBuild from $koreBuildZip"
  12. tempFolder="/tmp/KoreBuild-$(uuidgen)"
  13. mkdir $tempFolder
  14. localZipFile="$tempFolder/korebuild.zip"
  15. retries=6
  16. until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null)
  17. do
  18. echo "Failed to download '$koreBuildZip'"
  19. if [ "$retries" -le 0 ]; then
  20. exit 1
  21. fi
  22. retries=$((retries - 1))
  23. echo "Waiting 10 seconds before retrying. Retries left: $retries"
  24. sleep 10s
  25. done
  26. unzip -q -d $tempFolder $localZipFile
  27. mkdir $buildFolder
  28. cp -r $tempFolder/**/build/** $buildFolder
  29. chmod +x $buildFile
  30. # Cleanup
  31. if test ! -d $tempFolder; then
  32. rm -rf $tempFolder
  33. fi
  34. fi
  35. $buildFile -r $repoFolder "$@"