This repository was archived by the owner on Apr 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetImageMagick.ps1
More file actions
42 lines (31 loc) · 1.63 KB
/
getImageMagick.ps1
File metadata and controls
42 lines (31 loc) · 1.63 KB
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
<#
Script to install the most current version of ImageMagick on agent
#>
$ErrorActionPreference = "Stop"
Write-Host "Getting latest version of ImageMagick"
Add-Type -Assembly System.IO.Compression.FileSystem
$archiveContentFile = "$env:TEMP_DIR\content.html"
$dependenciesDir = "$env:DEPENDENCIES_DIR\ImageMagick"
# Create the dependencies directory if it does not exist
if(!(Test-Path -Path $dependenciesDir))
{
New-Item -ItemType directory -Path $dependenciesDir | Out-Null
}
# Fetch the download page from imagemagick.org
wget -OutFile $archiveContentFile http://www.imagemagick.org/script/binary-releases.php
# Parse out the current version of the ImageMagick
$regex = "http://www.imagemagick.org/download/binaries/ImageMagick-[0-9]+\.[0-9]+\.[0-9]+-[0-9]+-portable-Q16-x86\.zip"
$currentDownloadLink = Select-String -Path $archiveContentFile -Pattern $regex -AllMatches | Select-Object -First 1 | %{$_.Matches} | %{$_.Value}
$regex = "ImageMagick-[0-9]+\.[0-9]+\.[0-9]+-[0-9]+-portable-Q16-x86"
$currentVersion = $currentDownloadLink | Select-String -Pattern $regex -AllMatches | Select-Object -First 1 | %{$_.Matches} | %{$_.Value}
Remove-Item -Path $archiveContentFile
if(!($currentVersion))
{
Add-AppveyorMessage -Category Error -Message "Cannot obtain the most current version of ImageMagick."
$host.SetShouldExit(1)
}
# Download ImageMagick
wget -OutFile "$env:TEMP_DIR\$currentVersion.zip" $currentDownloadLink
# Install ImageMagick
[System.IO.Compression.ZipFile]::ExtractToDirectory("$env:TEMP_DIR\$currentVersion.zip", "$dependenciesDir")
Add-AppveyorMessage -Category Information -Message "Installed: $currentVersion"