installer: auto-install git if missing

This commit is contained in:
thePR0M3TH3AN
2025-07-04 21:56:49 -04:00
parent cd7654ac97
commit 22a4370dd3
3 changed files with 29 additions and 2 deletions

View File

@@ -78,6 +78,7 @@ bash -c "$(curl -sSL https://raw.githubusercontent.com/PR0M3TH3AN/SeedPass/main/
```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; $scriptContent = (New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/PR0M3TH3AN/SeedPass/main/scripts/install.ps1'); & ([scriptblock]::create($scriptContent))
```
The Windows installer will attempt to install Git automatically if it is not already available.
*Install the beta branch:*
```powershell
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; $scriptContent = (New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/PR0M3TH3AN/SeedPass/main/scripts/install.ps1'); & ([scriptblock]::create($scriptContent)) -Branch beta

View File

@@ -32,7 +32,19 @@ function Write-Error {
# 1. Check for prerequisites
Write-Info "Installing SeedPass from branch: '$Branch'"
Write-Info "Checking for prerequisites..."
if (-not (Get-Command git -ErrorAction SilentlyContinue)) { Write-Error "Git is not installed. Please install it from https://git-scm.com/ and ensure it's in your PATH." }
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
Write-Warning "Git is not installed. Attempting to install..."
if (Get-Command winget -ErrorAction SilentlyContinue) {
try { winget install --id Git.Git -e --source winget -h } catch { Write-Error "Failed to install Git via winget. Error: $_" }
} elseif (Get-Command choco -ErrorAction SilentlyContinue) {
try { choco install git -y } catch { Write-Error "Failed to install Git via Chocolatey. Error: $_" }
} elseif (Get-Command scoop -ErrorAction SilentlyContinue) {
try { scoop install git } catch { Write-Error "Failed to install Git via Scoop. Error: $_" }
} else {
Write-Error "Git is not installed. Please install it from https://git-scm.com/ and ensure it's in your PATH."
}
if (-not (Get-Command git -ErrorAction SilentlyContinue)) { Write-Error "Git installation failed or git not found in PATH after installation." }
}
$pythonExe = Get-Command python -ErrorAction SilentlyContinue
if (-not $pythonExe) { Write-Error "Python 3 is not installed or not in your PATH. Please install it from https://www.python.org/" }

View File

@@ -57,7 +57,21 @@ main() {
# 2. Check for prerequisites
print_info "Checking for prerequisites (git, python3, pip)..."
if ! command -v git &> /dev/null; then print_error "Git is not installed. Please install it."; fi
if ! command -v git &> /dev/null; then
print_warning "Git is not installed. Attempting to install..."
if [ "$OS_NAME" = "Linux" ]; then
if command -v apt-get &> /dev/null; then sudo apt-get update && sudo apt-get install -y git;
elif command -v dnf &> /dev/null; then sudo dnf install -y git;
elif command -v pacman &> /dev/null; then sudo pacman -Syu --noconfirm git;
else print_error "Git is not installed and automatic installation is not supported on this system."; fi
elif [ "$OS_NAME" = "Darwin" ]; then
if command -v brew &> /dev/null; then brew install git;
else print_error "Git is not installed and Homebrew was not found. Please install Git manually."; fi
else
print_error "Git is not installed. Please install it."
fi
if ! command -v git &> /dev/null; then print_error "Git installation failed or git not found in PATH."; fi
fi
if ! command -v python3 &> /dev/null; then print_error "Python 3 is not installed. Please install it."; fi
if ! python3 -m ensurepip --default-pip &> /dev/null && ! command -v pip3 &> /dev/null; then print_error "pip for Python 3 is not available. Please install it."; fi
if ! python3 -c "import venv" &> /dev/null; then