Setup TPM2-Plugin build environment
[aaf/sshsm.git] / SoftHSMv2 / testing / appveyor / appveyor_download_requirements.ps1
1 Add-Type -AssemblyName System.IO.Compression.FileSystem
2 function Unzip
3 {
4     param([string]$zipfile, [string]$outpath)
5
6     [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
7 }
8
9 $CURRENT_DIR_PATH = (Get-Item -Path ".\" -Verbose).FullName
10 $BUILD_DIR = Join-Path $CURRENT_DIR_PATH build
11
12 #prepare directories
13 Write-Host "Preparing directories"
14
15 $exists = Test-Path build
16 if ($exists -eq $false) {
17     mkdir build
18 }
19 cd build
20
21 $exists = Test-Path $env:RELEASE_DIR
22 if ($exists -eq $false) {
23     mkdir $env:RELEASE_DIR
24 }
25
26 $exists = Test-Path python
27 if ($exists -eq $true) {
28     Remove-Item python -recurse
29 }
30
31 $exists = Test-Path "$env:CPPUNIT_PATH"
32 if ($exists -eq $true) {
33     Remove-Item "$env:CPPUNIT_PATH" -recurse
34 }
35
36 $exists = Test-Path "$env:CRYPTO_PACKAGE_PATH"
37 if ($exists -eq $true) {
38     Remove-Item "$env:CRYPTO_PACKAGE_PATH" -recurse
39 }
40
41 mkdir python
42
43 Write-Host "Preparing directories - OK"
44
45 Write-Host "Downloading needed tools and dependencies"
46
47 $exists = Test-Path "$env:CRYPTO_PACKAGE_NAME"
48 if ($exists -eq $false) {
49     $source = "https://github.com/disig/SoftHSM2-AppVeyor/raw/master/$env:PACKAGE_VERSION_NAME/$env:CRYPTO_PACKAGE"
50     Invoke-WebRequest $source -OutFile $env:CRYPTO_PACKAGE
51 }
52
53 $exists = Test-Path "$env:CPPUNIT_PACKAGE"
54 if ($exists -eq $false) {
55     $source = "https://github.com/disig/SoftHSM2-AppVeyor/raw/master/$env:CPPUNIT_VERSION_NAME/$env:CPPUNIT_PACKAGE"
56     Invoke-WebRequest $source -OutFile $env:CPPUNIT_PACKAGE
57 }
58
59 $exists = Test-Path python-3.5.2-embed-win32.zip
60 if ($exists -eq $false) {
61     $source = "https://www.python.org/ftp/python/3.5.2/python-3.5.2-embed-win32.zip"
62     Invoke-WebRequest $source -OutFile python-3.5.2-embed-win32.zip
63 }
64
65 Write-Host "Downloading needed tools and dependencies - OK"
66
67 Write-Host "Extracting ..."  
68 Unzip "$BUILD_DIR/python-3.5.2-embed-win32.zip" "$env:PYTHON_PATH"
69
70 Unzip "$BUILD_DIR/$env:CRYPTO_PACKAGE" "$BUILD_DIR"
71
72 Unzip "$BUILD_DIR/$env:CPPUNIT_PACKAGE" "$BUILD_DIR"
73
74 dir 
75
76 dir "$env:PYTHON_PATH"
77 dir "$env:CRYPTO_PACKAGE_PATH"
78 dir "$env:CPPUNIT_PATH"
79
80 cd $CURRENT_DIR_PATH