From d258c708b1186869f0605f84da12f99fe746df50 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Nahan <814683+macintoshplus@users.noreply.github.com> Date: Wed, 20 Dec 2023 17:35:57 +0100 Subject: [PATCH 1/2] Use local cache directory --- run.ps1 | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/run.ps1 b/run.ps1 index 6463d8d..b6f49b5 100644 --- a/run.ps1 +++ b/run.ps1 @@ -44,11 +44,20 @@ if (-not $toolset) { throw "toolset not available" } +$cachePath="../cache" +if (!(Test-Path -Path $cachePath -PathType Container)) { + mkdir $cachePath +} + Write-Output "Install PHP SDK ..." -$temp = New-TemporaryFile | Rename-Item -NewName {$_.Name + ".zip"} -PassThru -$url = "https://github.com/php/php-sdk-binary-tools/archive/refs/heads/master.zip" -Invoke-WebRequest $url -OutFile $temp +#$temp = New-TemporaryFile | Rename-Item -NewName {$_.Name + ".zip"} -PassThru +$temp="$cachePath\php-sdk.zip" +if (!(Test-Path -Path $temp -PathType Leaf)) { + $url = "https://github.com/php/php-sdk-binary-tools/archive/refs/heads/master.zip" + Invoke-WebRequest $url -OutFile $temp +} + Expand-Archive $temp -DestinationPath "." Rename-Item "php-sdk-binary-tools-master" "php-sdk" @@ -80,18 +89,26 @@ $tspart = if ($ts -eq "nts") {"nts-Win32"} else {"Win32"} Write-Output "Install PHP $phpversion ..." -$temp = New-TemporaryFile | Rename-Item -NewName {$_.Name + ".zip"} -PassThru +#$temp = New-TemporaryFile | Rename-Item -NewName {$_.Name + ".zip"} -PassThru $fname = "php-$phpversion-$tspart-$vs-$arch.zip" -$url = "$baseurl/$fname" -Invoke-WebRequest $url -OutFile $temp +$temp="$cachePath\$fname" +if (!(Test-Path -Path $temp -PathType Leaf)) { + $url = "$baseurl/$fname" + Invoke-WebRequest $url -OutFile $temp +} + Expand-Archive $temp "php-bin" Write-Output "Install development pack ..." -$temp = New-TemporaryFile | Rename-Item -NewName {$_.Name + ".zip"} -PassThru +#$temp = New-TemporaryFile | Rename-Item -NewName {$_.Name + ".zip"} -PassThru $fname = "php-devel-pack-$phpversion-$tspart-$vs-$arch.zip" -$url = "$baseurl/$fname" -Invoke-WebRequest $url -OutFile $temp +$temp="$cachePath\$fname" +if (!(Test-Path -Path $temp -PathType Leaf)) { + $url = "$baseurl/$fname" + Invoke-WebRequest $url -OutFile $temp +} + Expand-Archive $temp "." Rename-Item "php-$phpversion-devel-$vs-$arch" "php-dev" @@ -105,7 +122,10 @@ if ($deps.Count -gt 0) { if ($line -match "^$dep") { Write-Output "Install $line" $temp = New-TemporaryFile | Rename-Item -NewName {$_.Name + ".zip"} -PassThru + $temp="$cachePath\$vs\$arch\$line" + if (!(Test-Path -Path $temp -PathType Leaf)) { Invoke-WebRequest "$baseurl/$vs/$arch/$line" -OutFile $temp + } Expand-Archive $temp "../deps" $installed = $true break From dc80ed3763a693b468e992aac944d9563a6178e8 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Nahan <814683+macintoshplus@users.noreply.github.com> Date: Wed, 20 Dec 2023 17:46:42 +0100 Subject: [PATCH 2/2] Make directory before download deps --- run.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run.ps1 b/run.ps1 index b6f49b5..6cf6d3b 100644 --- a/run.ps1 +++ b/run.ps1 @@ -123,6 +123,9 @@ if ($deps.Count -gt 0) { Write-Output "Install $line" $temp = New-TemporaryFile | Rename-Item -NewName {$_.Name + ".zip"} -PassThru $temp="$cachePath\$vs\$arch\$line" + if (!(Test-Path -Path "$cachePath\$vs\$arch" -PathType Container)) { + mkdir "$cachePath\$vs\$arch" + } if (!(Test-Path -Path $temp -PathType Leaf)) { Invoke-WebRequest "$baseurl/$vs/$arch/$line" -OutFile $temp }