forked from datastax/csharp-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appveyor_install.ps1
103 lines (85 loc) · 3.73 KB
/
appveyor_install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
$env:JAVA_HOME="C:\Program Files\Java\jdk1.8.0"
$env:PYTHON="C:\Python27-x64"
$env:PATH="$($env:PYTHON);$($env:PYTHON)\Scripts;$($env:JAVA_HOME)\bin;$($env:PATH)"
$dep_dir="C:\Users\appveyor\deps"
Write-Host "Install..."
If (!(Test-Path $dep_dir)) {
Write-Host "Creating $($dep_dir)"
New-Item -Path $dep_dir -ItemType Directory -Force
}
# Install Ant
$ant_base = "$($dep_dir)\ant"
$ant_path = "$($ant_base)\apache-ant-1.9.7"
If (!(Test-Path $ant_path)) {
Write-Host "Installing Ant"
$ant_url = "https://www.dropbox.com/s/lgx95x1jr6s787l/apache-ant-1.9.7-bin.zip?dl=1"
$ant_zip = "C:\Users\appveyor\apache-ant-1.9.7-bin.zip"
(new-object System.Net.WebClient).DownloadFile($ant_url, $ant_zip)
[System.IO.Compression.ZipFile]::ExtractToDirectory($ant_zip, $ant_base)
}
$env:PATH="$($ant_path)\bin;$($env:PATH)"
Write-Host "Installing java Cryptographic Extensions, needed for SSL..."
# Install Java Cryptographic Extensions, needed for SSL.
$target = "$($env:JAVA_HOME)\jre\lib\security"
# If this file doesn't exist we know JCE hasn't been installed.
$jce_indicator = "$target\README.txt"
$zip = "C:\Users\appveyor\jce_policy-8.zip"
If (!(Test-Path $jce_indicator)) {
# Download zip to staging area if it doesn't exist, we do this because
# we extract it to the directory based on the platform and we want to cache
# this file so it can apply to all platforms.
if(!(Test-Path $zip)) {
$url = "https://www.dropbox.com/s/al1e6e92cjdv7m7/jce_policy-8.zip?dl=1"
Write-Host "Downloading file..."
(new-object System.Net.WebClient).DownloadFile($url, $zip)
Write-Host "Download completed."
}
Add-Type -AssemblyName System.IO.Compression.FileSystem
Write-Host "Extracting zip file..."
[System.IO.Compression.ZipFile]::ExtractToDirectory($zip, $target)
Write-Host "Extraction completed."
$jcePolicyDir = "$target\UnlimitedJCEPolicyJDK8"
Move-Item $jcePolicyDir\* $target\ -force
Remove-Item $jcePolicyDir
}
$env:CCM_PATH="$($dep_dir)\ccm"
# Clone ccm from git and use master.
If (!(Test-Path $env:CCM_PATH)) {
Write-Host "Cloning git ccm... $($env:CCM_PATH)"
Start-Process git -ArgumentList "clone https://github.com/pcmanus/ccm.git $($env:CCM_PATH)" -Wait -NoNewWindow
Write-Host "git ccm cloned"
}
# Install Python Dependencies for CCM.
Write-Host "Installing CCM and its dependencies"
Start-Process python -ArgumentList "-m pip install psutil pyYaml six ccm" -Wait -NoNewWindow
Write-Host "Set execution Policy"
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
#removing any existing ccm cluster
Write-Host "Removing any existing ccm clusters"
$params = "/c ccm list"
& "cmd.exe" $params | Tee-Object -Variable scriptOutput | Out-Null
If ($scriptOutput)
{
$list = $scriptOutput.Split(" ")
Write-Host "[ccm] list $($list)"
Foreach ($cluster in $list)
{
If (-Not $cluster.equals(""))
{
$name = $cluster.Replace("*", "")
& "cmd.exe" "/c ccm remove $($name)" | Tee-Object -Variable result | Out-Null
Write-Host "[ccm] remove $($name) $($result)"
}
}
& "cmd.exe" $params | Tee-Object -Variable scriptOutputEnd | Out-Null
Write-Host "[ccm] list $($scriptOutputEnd)"
}
Write-Host "[Install] Check installed cassandra version $($env:cassandra_version)"
# Predownload cassandra version for CCM if it isn't already downloaded.
If (!(Test-Path C:\Users\appveyor\.ccm\repository\$env:cassandra_version)) {
Write-Host "[Install] Install cassandra version $($env:cassandra_version)"
Start-Process python -ArgumentList "$($env:CCM_PATH)\ccm.py create -v $($env:cassandra_version) -n 1 predownload" -Wait -NoNewWindow
Start-Process python -ArgumentList "$($env:CCM_PATH)\ccm.py remove predownload" -Wait -NoNewWindow
} else {
Write-Host "Cassandra $env:cassandra_version was already preloaded"
}