From 22a4370dd346d305af0956d7ca876ffd27c55fea Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Fri, 4 Jul 2025 21:56:49 -0400 Subject: [PATCH] installer: auto-install git if missing --- README.md | 1 + scripts/install.ps1 | 14 +++++++++++++- scripts/install.sh | 16 +++++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2f652c7..392e423 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/scripts/install.ps1 b/scripts/install.ps1 index 9c2c4a8..f2f3f1d 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -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/" } diff --git a/scripts/install.sh b/scripts/install.sh index 48a72fd..5cea79c 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -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