-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathBootstrap.ps1
47 lines (38 loc) · 1.72 KB
/
Bootstrap.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
#
# Twili Driver Bootstrap Script
#
# This script downloads support tooling and libusbK, to set up the
# on-disk hierarchy to support driver installation via twili.inf
#
$LibusbkUrl = "https://sourceforge.net/projects/libusbk/files/libusbK-release/3.0.7.0/libusbK-3.0.7.0-bin.7z/download"
$LibusbkPrefix = "libusbK-3.0.7.0"
$7zipUrl = "https://www.7-zip.org/a/7z1805.msi"
New-Item -ItemType Directory tools -ErrorAction Stop | Out-Null
$env:Path += ";.\tools"
# # #
Write-Output "• Staging 7-Zip"
$WorkingFilename = [IO.Path]::GetRandomFileName()
$WorkingDirectory = [IO.Path]::GetRandomFileName()
Invoke-WebRequest $7zipUrl -OutFile $WorkingFilename
Start-Process msiexec.exe -Wait -NoNewWindow -ArgumentList @(
"/q","/a",$WorkingFilename,"TARGETDIR=$((Get-Item -Path '.\' -Verbose).FullName)\$WorkingDirectory")
Move-Item .\$WorkingDirectory\Files\7-Zip\7z.??? .\tools
Remove-Item .\$WorkingFilename
Remove-Item .\$WorkingDirectory -Recurse
# # #
Write-Output "• Staging libusbk"
New-Item -ItemType Directory @("amd64", "x86") -ErrorAction Stop | Out-Null
$WorkingFilename = [IO.Path]::GetRandomFileName()
$WorkingDirectory = [IO.Path]::GetRandomFileName()
Invoke-WebRequest $LibusbkUrl -OutFile $WorkingFilename -MaximumRedirection 3 -UserAgent "PowerShell/Windows"
Start-Process 7z.exe -Wait -ArgumentList @("x", $WorkingFilename, "-i!*\bin\dll", "-i!*\bin\sys", "-o$WorkingDirectory")
# # #
Write-Output "• Creating driver directory hierarchy"
Move-Item .\$WorkingDirectory\$LibusbkPrefix-bin\bin\*\x86\* .\x86
Move-Item .\$WorkingDirectory\$LibusbkPrefix-bin\bin\*\amd64\* .\amd64
# # #
Write-Output "• Cleaning up"
Remove-Item .\$WorkingFilename
Remove-Item .\$WorkingDirectory -Recurse
# # #
Write-Output "✓ Done"