Skip to content

Commit 1b1b0e8

Browse files
committed
add progression for downloading rune, use tag for installing
and display telemetry info
1 parent 0ee61aa commit 1b1b0e8

File tree

2 files changed

+58
-8
lines changed

2 files changed

+58
-8
lines changed

metadata/scripts/install.ps1

+54-6
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,57 @@ if (([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]:
44
Write-Host "You cannot install vein-sdk from under the administrator." -ForegroundColor Red
55
exit 1
66
}
7+
$env:RUNE_NOVID = "1";
8+
$env:VEINC_NOVID = "1";
79

810
$apiUrl = "https://releases.vein-lang.org/api/get-release"
911

1012
$outputDir = "$HOME\.vein"
1113

12-
function DownloadFile($url, $outputFile) {
13-
$webClient = New-Object System.Net.WebClient
14-
$webClient.DownloadFile($url, $outputFile)
14+
function DownloadFile {
15+
param (
16+
[string]$url,
17+
[string]$outputFile
18+
)
19+
20+
$fileStream = $null
21+
$stream = $null
22+
23+
try {
24+
$request = [System.Net.HttpWebRequest]::Create($url)
25+
$request.Method = "GET"
26+
$response = $request.GetResponse()
27+
$totalBytes = $response.ContentLength
28+
$stream = $response.GetResponseStream()
29+
$fileStream = [System.IO.File]::Create($outputFile)
30+
$buffer = New-Object byte[] 8192
31+
$totalReadBytes = 0
32+
while ($true) {
33+
$readBytes = $stream.Read($buffer, 0, $buffer.Length)
34+
if ($readBytes -le 0) { break }
35+
$fileStream.Write($buffer, 0, $readBytes)
36+
$totalReadBytes += $readBytes
37+
$percentComplete = [math]::Round(($totalReadBytes / $totalBytes) * 100, 2)
38+
Write-Progress -Activity "Downloading $url" -Status "$percentComplete% Complete" -PercentComplete $percentComplete
39+
}
40+
} finally {
41+
if ($fileStream) {
42+
$fileStream.Close()
43+
}
44+
if ($stream) {
45+
$stream.Close()
46+
}
47+
Write-Progress -Activity "Downloading $url" -Status "Download Complete" -Completed
48+
}
1549
}
1650

51+
1752
try {
1853
$releaseInfo = Invoke-RestMethod -Uri $apiUrl
1954
$asset = $releaseInfo.assets | Where-Object { $_.name -eq "rune.$arch.zip" }
2055
$downloadUrl = $asset.browser_download_url
21-
Write-Output $downloadUrl
56+
$tagVersion = $releaseInfo.tag_name.Replace("v", "")
57+
Write-Host $tagVersion
2258
New-Item -ItemType Directory -Force -Path $outputDir > $null
2359
$zipFile = "$outputDir\rune.$arch.zip"
2460
DownloadFile $downloadUrl $zipFile
@@ -30,10 +66,22 @@ try {
3066
[Environment]::SetEnvironmentVariable("Path", $env:Path, [EnvironmentVariableTarget]::User)
3167
}
3268

69+
Invoke-Expression "$outputDir\rune.exe telemetry"
70+
71+
if ($LASTEXITCODE -ne 0) {
72+
exit $LASTEXITCODE
73+
}
74+
3375
$installWorkloads = Read-Host "Do you want to install vein.runtime and vein.compiler workloads? (y/n)"
3476
if ($installWorkloads -eq 'y') {
35-
Invoke-Expression "$outputDir\rune.exe workload install [email protected]"
36-
Invoke-Expression "$outputDir\rune.exe workload install [email protected]"
77+
Invoke-Expression "$outputDir\rune.exe workload install vein.runtime@$tagVersion"
78+
if ($LASTEXITCODE -ne 0) {
79+
exit $LASTEXITCODE
80+
}
81+
Invoke-Expression "$outputDir\rune.exe workload install vein.compiler@$tagVersion"
82+
if ($LASTEXITCODE -ne 0) {
83+
exit $LASTEXITCODE
84+
}
3785
Write-Output "Workloads installed."
3886
} else {
3987
Write-Output "Workloads installation skipped."

metadata/scripts/install.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ fi
7070
chmod +x "$OUTPUT_DIR/rune"
7171
chmod +x "$OUTPUT_DIR/bin/rune.sh"
7272

73+
RUNE_NOVID=1 "$OUTPUT_DIR/rune" telemetry
74+
7375
read -p "Do you want to install vein.runtime and vein.compiler workloads? (y/n): " install_workloads
7476
if [[ "$install_workloads" == "y" ]]; then
75-
"$OUTPUT_DIR/rune" workload install [email protected]
76-
"$OUTPUT_DIR/rune" workload install [email protected]
77+
RUNE_NOVID=1 "$OUTPUT_DIR/rune" workload install [email protected]
78+
RUNE_NOVID=1 "$OUTPUT_DIR/rune" workload install [email protected]
7779
echo "Workloads installed."
7880
else
7981
echo "Workloads installation skipped."

0 commit comments

Comments
 (0)