Skip to content
This repository was archived by the owner on Dec 28, 2017. It is now read-only.

Commit 82170d0

Browse files
author
Victor Hurdugaci
committed
Update the build scripts to the latest version
1 parent 27ed807 commit 82170d0

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

build.ps1

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries)
4+
{
5+
while($true)
6+
{
7+
try
8+
{
9+
Invoke-WebRequest $url -OutFile $downloadLocation
10+
break
11+
}
12+
catch
13+
{
14+
$exceptionMessage = $_.Exception.Message
15+
Write-Host "Failed to download '$url': $exceptionMessage"
16+
if ($retries -gt 0) {
17+
$retries--
18+
Write-Host "Waiting 10 seconds before retrying. Retries left: $retries"
19+
Start-Sleep -Seconds 10
20+
21+
}
22+
else
23+
{
24+
$exception = $_.Exception
25+
throw $exception
26+
}
27+
}
28+
}
29+
}
30+
131
cd $PSScriptRoot
232

333
$repoFolder = $PSScriptRoot
@@ -20,7 +50,8 @@ if (!(Test-Path $buildFolder)) {
2050

2151
$localZipFile="$tempFolder\korebuild.zip"
2252

23-
Invoke-WebRequest $koreBuildZip -OutFile $localZipFile
53+
DownloadWithRetry -url $koreBuildZip -downloadLocation $localZipFile -retries 6
54+
2455
Add-Type -AssemblyName System.IO.Compression.FileSystem
2556
[System.IO.Compression.ZipFile]::ExtractToDirectory($localZipFile, $tempFolder)
2657

build.sh

+13-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,18 @@ if test ! -d $buildFolder; then
1818

1919
localZipFile="$tempFolder/korebuild.zip"
2020

21-
wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip /dev/null
21+
retries=6
22+
until (wget -O $localZipFile $koreBuildZip 2>/dev/null || curl -o $localZipFile --location $koreBuildZip 2>/dev/null)
23+
do
24+
echo "Failed to download '$koreBuildZip'"
25+
if [ "$retries" -le 0 ]; then
26+
exit 1
27+
fi
28+
retries=$((retries - 1))
29+
echo "Waiting 10 seconds before retrying. Retries left: $retries"
30+
sleep 10s
31+
done
32+
2233
unzip -q -d $tempFolder $localZipFile
2334

2435
mkdir $buildFolder
@@ -32,4 +43,4 @@ if test ! -d $buildFolder; then
3243
fi
3344
fi
3445

35-
$buildFile -r $repoFolder "$@"
46+
$buildFile -r $repoFolder "$@"

0 commit comments

Comments
 (0)