aboutsummaryrefslogtreecommitdiffstats
path: root/coin/provisioning/common/helpers.ps1
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2016-04-27 14:52:15 +0200
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2016-04-28 07:54:48 +0000
commit54f1bfd10c5149271531d40f1a3056dace5f420b (patch)
tree1f2484af6ee9ac9c5cd6abc3476edc3a8dbec321 /coin/provisioning/common/helpers.ps1
parent2aff3114237294c08dee8a90d403c1b98c64b079 (diff)
Add script to install jom through powershell
Change-Id: I3f12aa0dd54f99fafdffb53796e54e7b127c3c8c Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Diffstat (limited to 'coin/provisioning/common/helpers.ps1')
-rw-r--r--coin/provisioning/common/helpers.ps131
1 files changed, 31 insertions, 0 deletions
diff --git a/coin/provisioning/common/helpers.ps1 b/coin/provisioning/common/helpers.ps1
new file mode 100644
index 00000000..f517e94d
--- /dev/null
+++ b/coin/provisioning/common/helpers.ps1
@@ -0,0 +1,31 @@
+function Verify-Checksum
+{
+ Param (
+ [string]$File=$(throw("You must specify a filename to get the checksum of.")),
+ [string]$Expected=$(throw("Checksum required")),
+ [ValidateSet("sha1","md5")][string]$Algorithm="sha1"
+ )
+ $fs = new-object System.IO.FileStream $File, "Open"
+ $algo = [type]"System.Security.Cryptography.$Algorithm"
+ $crypto = $algo::Create()
+ $hash = [BitConverter]::ToString($crypto.ComputeHash($fs)).Replace("-", "")
+ $fs.Close()
+ if ($hash -ne $Expected) {
+ Write-Error "Checksum verification failed, got: '$hash' expected: '$Expected'"
+ }
+}
+
+function Extract-Zip
+{
+ Param (
+ [string]$Source,
+ [string]$Destination
+ )
+ echo "Extracting '$Source' to '$Destination'..."
+
+ New-Item -ItemType Directory -Force -Path $Destination
+ $shell = new-object -com shell.application
+ $zipfile = $shell.Namespace($Source)
+ $destinationFolder = $shell.Namespace($Destination)
+ $destinationFolder.CopyHere($zipfile.Items())
+}