Skip to content

Commit b4c1a67

Browse files
committed
Update PS1 to auto update esptool
- Fix access to system temp folder. - Rename esptools packages (again) to match repo release. ***NO_CI***
1 parent 716b217 commit b4c1a67

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

update-esptool.ps1

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,38 +23,43 @@ else {
2323
# make sure security doesn't block our request
2424
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11"
2525

26+
$tempPath = (Get-Item -LiteralPath ([System.IO.Path]::GetTempPath())).FullName
27+
2628
#############
2729
# WIN version
28-
$urlWin = "https://github.com/espressif/esptool/releases/download/$version/esptool-$version-win64.zip"
29-
$outputWin = "$env:TEMP\esptool-$version-win64.zip"
30+
$urlWin = "https://github.com/espressif/esptool/releases/download/$version/esptool-$version-windows-amd64.zip"
31+
$outputWin = (Join-Path -Path $tempPath -ChildPath "esptool-$version-windows-amd64.zip")
3032

3133
"Downloading esptool $version for Windows..." | Write-Host -ForegroundColor White -NoNewline
3234
(New-Object Net.WebClient).DownloadFile($urlWin, $outputWin)
3335
"OK" | Write-Host -ForegroundColor Green
3436

3537
#############
3638
# MAC version
37-
$urlMac = "https://github.com/espressif/esptool/releases/download/$version/esptool-$version-macos.zip"
38-
$outputMac = "$env:TEMP\esptool-$version-macos.zip"
39+
$urlMac = "https://github.com/espressif/esptool/releases/download/$version/esptool-$version-macos-amd64.tar.gz"
40+
$outputMac = (Join-Path -Path $tempPath -ChildPath "esptool-$version-macos-amd64.tar.gz")
3941

4042
"Downloading esptool $version for MAC..." | Write-Host -ForegroundColor White -NoNewline
4143
(New-Object Net.WebClient).DownloadFile($urlMac, $outputMac)
4244
"OK" | Write-Host -ForegroundColor Green
4345

4446
###############
4547
# Linux version
46-
$urlLinux = "https://github.com/espressif/esptool/releases/download/$version/esptool-$version-linux-amd64.zip"
47-
$outputLinux = "$env:TEMP\esptool-$version-linux-amd64.zip"
48+
$urlLinux = "https://github.com/espressif/esptool/releases/download/$version/esptool-$version-linux-amd64.tar.gz"
49+
$outputLinux = (Join-Path -Path $tempPath -ChildPath "esptool-$version-linux-amd64.tar.gz")
4850

4951
"Downloading esptool for $version Linux..." | Write-Host -ForegroundColor White -NoNewline
5052
(New-Object Net.WebClient).DownloadFile($urlLinux, $outputLinux)
5153
"OK" | Write-Host -ForegroundColor Green
5254

5355
# unzip files
5456
"Unzip files..." | Write-Host -ForegroundColor White -NoNewline
55-
Expand-Archive $outputWin -DestinationPath $env:TEMP -Force > $null
56-
Expand-Archive $outputMac -DestinationPath $env:TEMP -Force > $null
57-
Expand-Archive $outputLinux -DestinationPath $env:TEMP -Force > $null
57+
Expand-Archive $outputWin -DestinationPath $tempPath -Force > $null
58+
59+
# tarballs need an extra extraction pass because Expand-Archive only supports zip
60+
& tar -xf $outputMac -C $tempPath
61+
& tar -xf $outputLinux -C $tempPath
62+
5863
"OK" | Write-Host -ForegroundColor Green
5964

6065
# clean destination folders
@@ -64,9 +69,9 @@ Remove-Item -Path (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptool
6469

6570
# copy files to the correct locations
6671
"Copying files to tools folders..." | Write-Host -ForegroundColor White -NoNewline
67-
Move-Item -Path (Join-Path -Path $env:TEMP -ChildPath "esptool-win64\**" -Resolve) -Destination (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolWin" -Resolve) -Force
68-
Move-Item -Path (Join-Path -Path $env:TEMP -ChildPath "esptool-macos\**" -Resolve) -Destination (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolMac" -Resolve) -Force
69-
Move-Item -Path (Join-Path -Path $env:TEMP -ChildPath "esptool-linux-amd64\**" -Resolve) -Destination (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolLinux" -Resolve) -Force
72+
Move-Item -Path (Join-Path -Path $tempPath -ChildPath "esptool-windows-amd64\**" -Resolve) -Destination (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolWin" -Resolve) -Force
73+
Move-Item -Path (Join-Path -Path $tempPath -ChildPath "esptool-macos-amd64\**" -Resolve) -Destination (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolMac" -Resolve) -Force
74+
Move-Item -Path (Join-Path -Path $tempPath -ChildPath "esptool-linux-amd64\**" -Resolve) -Destination (Join-Path -Path $PSScriptRoot -ChildPath "lib\esptool\esptoolLinux" -Resolve) -Force
7075
"OK" | Write-Host -ForegroundColor Green
7176

7277
# cleanup files

0 commit comments

Comments
 (0)