mirror of
https://github.com/PR0M3TH3AN/VoxVera.git
synced 2025-09-08 06:58:42 +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 }
|
||||
}
|
||||
|
||||
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) {
|
||||
try {
|
||||
pipx install voxvera --force
|
||||
@@ -31,13 +57,19 @@ if (Get-Command pipx -ErrorAction SilentlyContinue) {
|
||||
$dest = "$HOME/.local/bin"
|
||||
New-Item -ItemType Directory -Path $dest -Force | Out-Null
|
||||
$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 {
|
||||
$dest = "$HOME/.local/bin"
|
||||
New-Item -ItemType Directory -Path $dest -Force | Out-Null
|
||||
$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.'
|
||||
|
50
install.sh
50
install.sh
@@ -61,6 +61,34 @@ require_pkg jq jq
|
||||
require_pkg qrencode qrencode
|
||||
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 ! pipx install --force voxvera; then
|
||||
echo "pipx install failed, downloading binary"
|
||||
@@ -68,30 +96,20 @@ if command_exists pipx; then
|
||||
mkdir -p "$install_dir"
|
||||
url="https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera"
|
||||
dest="$install_dir/voxvera"
|
||||
if command_exists curl; then
|
||||
curl -fsSL "$url" -o "$dest"
|
||||
elif command_exists wget; then
|
||||
wget -q "$url" -O "$dest"
|
||||
else
|
||||
echo "Install curl or wget to download voxvera" >&2
|
||||
exit 1
|
||||
if ! download_binary "$url" "$dest"; then
|
||||
echo "Binary download failed, falling back to pip." >&2
|
||||
pip_fallback
|
||||
fi
|
||||
chmod +x "$dest"
|
||||
fi
|
||||
else
|
||||
install_dir="$HOME/.local/bin"
|
||||
mkdir -p "$install_dir"
|
||||
url="https://github.com/PR0M3TH3AN/VoxVera/releases/latest/download/voxvera"
|
||||
dest="$install_dir/voxvera"
|
||||
if command_exists curl; then
|
||||
curl -fsSL "$url" -o "$dest"
|
||||
elif command_exists wget; then
|
||||
wget -q "$url" -O "$dest"
|
||||
else
|
||||
echo "Install curl or wget to download voxvera" >&2
|
||||
exit 1
|
||||
if ! download_binary "$url" "$dest"; then
|
||||
echo "Binary download failed, falling back to pip." >&2
|
||||
pip_fallback
|
||||
fi
|
||||
chmod +x "$dest"
|
||||
fi
|
||||
|
||||
echo "VoxVera installed successfully."
|
||||
|
Reference in New Issue
Block a user