mirror of
https://github.com/PR0M3TH3AN/VoxVera.git
synced 2025-09-09 07:28:43 +00:00
Merge pull request #46 from PR0M3TH3AN/codex/update-install-scripts-for-download-failure-handling
Improve installer failure handling
This commit is contained in:
36
install.ps1
36
install.ps1
@@ -23,6 +23,32 @@ if ($choco) {
|
|||||||
foreach ($p in $packages) { Install-Pkg $p }
|
foreach ($p in $packages) { Install-Pkg $p }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Install-PipFallback {
|
||||||
|
if (Get-Command pip -ErrorAction SilentlyContinue) {
|
||||||
|
try {
|
||||||
|
pip install --user voxvera
|
||||||
|
Write-Host 'VoxVera installed successfully via pip.'
|
||||||
|
exit 0
|
||||||
|
} catch {
|
||||||
|
Write-Error 'pip installation failed.'
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Error 'pip not found for fallback installation.'
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Download-Binary {
|
||||||
|
param([string]$Url, [string]$Dest)
|
||||||
|
try {
|
||||||
|
Invoke-WebRequest -Uri $Url -OutFile $Dest -ErrorAction Stop
|
||||||
|
return $true
|
||||||
|
} catch {
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Get-Command pipx -ErrorAction SilentlyContinue) {
|
if (Get-Command pipx -ErrorAction SilentlyContinue) {
|
||||||
try {
|
try {
|
||||||
pipx install voxvera --force
|
pipx install voxvera --force
|
||||||
@@ -31,13 +57,19 @@ if (Get-Command pipx -ErrorAction SilentlyContinue) {
|
|||||||
$dest = "$HOME/.local/bin"
|
$dest = "$HOME/.local/bin"
|
||||||
New-Item -ItemType Directory -Path $dest -Force | Out-Null
|
New-Item -ItemType Directory -Path $dest -Force | Out-Null
|
||||||
$url = 'https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera.exe'
|
$url = 'https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera.exe'
|
||||||
Invoke-WebRequest -Uri $url -OutFile "$dest/voxvera.exe"
|
if (-not (Download-Binary $url "$dest/voxvera.exe")) {
|
||||||
|
Write-Host 'Binary download failed, falling back to pip'
|
||||||
|
Install-PipFallback
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$dest = "$HOME/.local/bin"
|
$dest = "$HOME/.local/bin"
|
||||||
New-Item -ItemType Directory -Path $dest -Force | Out-Null
|
New-Item -ItemType Directory -Path $dest -Force | Out-Null
|
||||||
$url = 'https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera.exe'
|
$url = 'https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera.exe'
|
||||||
Invoke-WebRequest -Uri $url -OutFile "$dest/voxvera.exe"
|
if (-not (Download-Binary $url "$dest/voxvera.exe")) {
|
||||||
|
Write-Host 'Binary download failed, falling back to pip'
|
||||||
|
Install-PipFallback
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host 'VoxVera installed successfully.'
|
Write-Host 'VoxVera installed successfully.'
|
||||||
|
50
install.sh
50
install.sh
@@ -61,6 +61,34 @@ require_pkg jq jq
|
|||||||
require_pkg qrencode qrencode
|
require_pkg qrencode qrencode
|
||||||
require_pkg convert imagemagick
|
require_pkg convert imagemagick
|
||||||
|
|
||||||
|
download_binary() {
|
||||||
|
local url=$1
|
||||||
|
local dest=$2
|
||||||
|
if command_exists curl; then
|
||||||
|
curl -fsSL "$url" -o "$dest" || return 1
|
||||||
|
elif command_exists wget; then
|
||||||
|
wget -q "$url" -O "$dest" || return 1
|
||||||
|
else
|
||||||
|
echo "Install curl or wget to download voxvera" >&2
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
chmod +x "$dest"
|
||||||
|
}
|
||||||
|
|
||||||
|
pip_fallback() {
|
||||||
|
if command_exists pip; then
|
||||||
|
echo "Attempting pip install as fallback..."
|
||||||
|
if pip install --user voxvera; then
|
||||||
|
echo "VoxVera installed successfully via pip."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "pip installation failed." >&2
|
||||||
|
else
|
||||||
|
echo "pip not found for fallback installation" >&2
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
if command_exists pipx; then
|
if command_exists pipx; then
|
||||||
if ! pipx install --force voxvera; then
|
if ! pipx install --force voxvera; then
|
||||||
echo "pipx install failed, downloading binary"
|
echo "pipx install failed, downloading binary"
|
||||||
@@ -68,30 +96,20 @@ if command_exists pipx; then
|
|||||||
mkdir -p "$install_dir"
|
mkdir -p "$install_dir"
|
||||||
url="https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera"
|
url="https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera"
|
||||||
dest="$install_dir/voxvera"
|
dest="$install_dir/voxvera"
|
||||||
if command_exists curl; then
|
if ! download_binary "$url" "$dest"; then
|
||||||
curl -fsSL "$url" -o "$dest"
|
echo "Binary download failed, falling back to pip." >&2
|
||||||
elif command_exists wget; then
|
pip_fallback
|
||||||
wget -q "$url" -O "$dest"
|
|
||||||
else
|
|
||||||
echo "Install curl or wget to download voxvera" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
chmod +x "$dest"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
install_dir="$HOME/.local/bin"
|
install_dir="$HOME/.local/bin"
|
||||||
mkdir -p "$install_dir"
|
mkdir -p "$install_dir"
|
||||||
url="https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera"
|
url="https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera"
|
||||||
dest="$install_dir/voxvera"
|
dest="$install_dir/voxvera"
|
||||||
if command_exists curl; then
|
if ! download_binary "$url" "$dest"; then
|
||||||
curl -fsSL "$url" -o "$dest"
|
echo "Binary download failed, falling back to pip." >&2
|
||||||
elif command_exists wget; then
|
pip_fallback
|
||||||
wget -q "$url" -O "$dest"
|
|
||||||
else
|
|
||||||
echo "Install curl or wget to download voxvera" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
chmod +x "$dest"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "VoxVera installed successfully."
|
echo "VoxVera installed successfully."
|
||||||
|
Reference in New Issue
Block a user