|
| 1 | +function Save-ChocoPackage { |
| 2 | + param ( |
| 3 | + $PackageName |
| 4 | + ) |
| 5 | + Rename-Item -Path "$env:ChocolateyInstall\lib\$PackageName\$PackageName.nupkg" -NewName "$PackageName.nupkg.zip" -ErrorAction:SilentlyContinue |
| 6 | + Expand-Archive -LiteralPath "$env:ChocolateyInstall\lib\$PackageName\$PackageName.nupkg.zip" -DestinationPath "$env:ChocolateyInstall\lib\$PackageName" -Force |
| 7 | + Remove-Item "$env:ChocolateyInstall\lib\$PackageName\_rels" -Recurse |
| 8 | + Remove-Item "$env:ChocolateyInstall\lib\$PackageName\package" -Recurse |
| 9 | + Remove-Item "$env:ChocolateyInstall\lib\$PackageName\[Content_Types].xml" |
| 10 | + New-Item -Path "${PSScriptRoot}\..\tmp\chocolatey\$PackageName" -ItemType "directory" -ErrorAction:SilentlyContinue |
| 11 | + choco pack "$env:ChocolateyInstall\lib\$PackageName\$PackageName.nuspec" --outdir "${PSScriptRoot}\..\tmp\chocolatey\$PackageName" --no-progress |
| 12 | +} |
| 13 | + |
| 14 | +# Check for existence of required environment variables |
| 15 | +if ( $null -eq $env:ChocolateyInstall ) { |
| 16 | + [Console]::Error.WriteLine('Missing $env:ChocolateyInstall environment variable') |
| 17 | + exit 1 |
| 18 | +} |
| 19 | + |
| 20 | +# Add the cached packages with source priority 1 (Chocolatey community is 0) |
| 21 | +New-Item -Path "${PSScriptRoot}\..\tmp\chocolatey" -ItemType "directory" -ErrorAction:SilentlyContinue |
| 22 | +choco source add --name="cache" --source="${PSScriptRoot}\..\tmp\chocolatey" --priority=1 --no-progress |
| 23 | + |
| 24 | +# Install nodejs v20.5.1 (will use cache if exists) |
| 25 | +$nodejs = "nodejs" |
| 26 | +choco install "$nodejs" --version="20.5.1" --require-checksums -y --no-progress |
| 27 | +# Internalise nodejs to cache if doesn't exist |
| 28 | +if ( -not (Test-Path -Path "${PSScriptRoot}\..\tmp\chocolatey\$nodejs\$nodejs.20.5.1.nupkg" -PathType Leaf) ) { |
| 29 | + Save-ChocoPackage -PackageName $nodejs |
| 30 | +} |
| 31 | + |
| 32 | +# Install rust v1.68.0 (will use cache if exists) |
| 33 | +$rust = "rust-ms" |
| 34 | +choco install "$rust" --version="1.83.0" --require-checksums -y --no-progress |
| 35 | +# Internalise rust to cache if doesn't exist |
| 36 | +if ( -not (Test-Path -Path "${PSScriptRoot}\..\tmp\chocolatey\$rust\$rust.1.83.0.nupkg" -PathType Leaf) ) { |
| 37 | + Save-ChocoPackage -PackageName $rust |
| 38 | +} |
| 39 | + |
| 40 | +# Install llvm v16.0.3 (will use cache if exists) |
| 41 | +$llvm = "llvm" |
| 42 | +choco install "$llvm" --version="16.0.3" --require-checksums -y --no-progress |
| 43 | +# Internalise rust to cache if doesn't exist |
| 44 | +if ( -not (Test-Path -Path "${PSScriptRoot}\..\tmp\chocolatey\$llvm\$llvm.16.0.3.nupkg" -PathType Leaf) ) { |
| 45 | + Save-ChocoPackage -PackageName $llvm |
| 46 | +} |
| 47 | + |
| 48 | +# Install nasm v2.16.01.20221231 (will use cache if exists) |
| 49 | +$nasm = "nasm" |
| 50 | +choco install "$nasm" --version="2.16.01.20221231" --require-checksums -y --no-progress |
| 51 | +# Internalise rust to cache if doesn't exist |
| 52 | +if ( -not (Test-Path -Path "${PSScriptRoot}\..\tmp\chocolatey\$nasm\$nasm.2.16.01.20221231.nupkg" -PathType Leaf) ) { |
| 53 | + Save-ChocoPackage -PackageName $nasm |
| 54 | +} |
| 55 | + |
| 56 | +# Install Windows SDK v10.0.22621.2 (will use cache if exists) |
| 57 | +$windowsSdk = "windows-sdk-11-version-22h2-all" |
| 58 | +choco install $windowsSdk --version="10.0.22621.2" --require-checksums -y --no-progress |
| 59 | +# Internalise rust to cache if doesn't exist |
| 60 | +if ( -not (Test-Path -Path "${PSScriptRoot}\..\tmp\chocolatey\$windowsSdk\$windowsSdk.10.0.22621.2.nupkg" -PathType Leaf) ) { |
| 61 | + Save-ChocoPackage -PackageName $windowsSdk |
| 62 | +} |
0 commit comments