feat: modified install to install dependencies when target PC lacks them
This commit is contained in:
parent
c1dd4f7e8c
commit
b8776a9c3e
76
install.ps1
76
install.ps1
|
|
@ -87,30 +87,86 @@ if ($List) {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- Check deps ---
|
# --- Check deps function ---
|
||||||
if ($CheckDeps) {
|
function Invoke-DependencyCheck {
|
||||||
Write-Host '=== Running Dependency Checks ===' -ForegroundColor Cyan
|
Write-Host '=== Running Dependency Checks ===' -ForegroundColor Cyan
|
||||||
Write-Host ''
|
Write-Host ''
|
||||||
|
|
||||||
|
$missingDeps = @()
|
||||||
|
|
||||||
Write-Host '--- Windows Dependencies ---' -ForegroundColor Yellow
|
Write-Host '--- Windows Dependencies ---' -ForegroundColor Yellow
|
||||||
$winScript = Join-Path $ScriptDir 'plugins\windows-reverse-engineering\skills\windows-reverse-engineering\scripts\check-deps.ps1'
|
$winCheck = Join-Path $ScriptDir 'plugins\windows-reverse-engineering\skills\windows-reverse-engineering\scripts\check-deps.ps1'
|
||||||
if (Test-Path $winScript) {
|
$winInstall = Join-Path $ScriptDir 'plugins\windows-reverse-engineering\skills\windows-reverse-engineering\scripts\install-dep.ps1'
|
||||||
& powershell -ExecutionPolicy Bypass -File $winScript
|
if (Test-Path $winCheck) {
|
||||||
|
$winOut = & powershell -ExecutionPolicy Bypass -File $winCheck
|
||||||
|
foreach ($line in $winOut) {
|
||||||
|
$lineStr = [string]$line
|
||||||
|
if ($lineStr -match '^INSTALL_') {
|
||||||
|
$depInfo = @{
|
||||||
|
OS = 'Windows'
|
||||||
|
Name = ($lineStr -split ':')[1]
|
||||||
|
InstallScript = $winInstall
|
||||||
|
}
|
||||||
|
$missingDeps += $depInfo
|
||||||
|
} else {
|
||||||
|
Write-Host $lineStr
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host ('Windows check-deps.ps1 not found at: ' + $winScript) -ForegroundColor Red
|
Write-Host ('Windows check-deps.ps1 not found at: ' + $winCheck) -ForegroundColor Red
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host ''
|
Write-Host ''
|
||||||
Write-Host '--- Android Dependencies ---' -ForegroundColor Yellow
|
Write-Host '--- Android Dependencies ---' -ForegroundColor Yellow
|
||||||
$androidScript = Join-Path $ScriptDir 'plugins\android-reverse-engineering\skills\android-reverse-engineering\scripts\check-deps.sh'
|
$androidCheck = Join-Path $ScriptDir 'plugins\android-reverse-engineering\skills\android-reverse-engineering\scripts\check-deps.sh'
|
||||||
if (Test-Path $androidScript) {
|
$androidInstall = Join-Path $ScriptDir 'plugins\android-reverse-engineering\skills\android-reverse-engineering\scripts\install-dep.sh'
|
||||||
|
if (Test-Path $androidCheck) {
|
||||||
$bashCmd = Get-Command bash -ErrorAction SilentlyContinue
|
$bashCmd = Get-Command bash -ErrorAction SilentlyContinue
|
||||||
if ($bashCmd) {
|
if ($bashCmd) {
|
||||||
& bash $androidScript
|
$andOut = & bash $androidCheck
|
||||||
|
foreach ($line in $andOut) {
|
||||||
|
$lineStr = [string]$line
|
||||||
|
if ($lineStr -match '^INSTALL_') {
|
||||||
|
$depInfo = @{
|
||||||
|
OS = 'Android'
|
||||||
|
Name = ($lineStr -split ':')[1]
|
||||||
|
InstallScript = $androidInstall
|
||||||
|
}
|
||||||
|
$missingDeps += $depInfo
|
||||||
|
} else {
|
||||||
|
Write-Host $lineStr
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host 'bash not found. Android dependency check requires WSL or Git Bash.' -ForegroundColor Yellow
|
Write-Host 'bash not found. Android dependency check requires WSL or Git Bash.' -ForegroundColor Yellow
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Write-Host ('Android check-deps.sh not found at: ' + $androidScript) -ForegroundColor Red
|
Write-Host ('Android check-deps.sh not found at: ' + $androidCheck) -ForegroundColor Red
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($missingDeps.Count -gt 0) {
|
||||||
|
Write-Host ''
|
||||||
|
$totalMissing = $missingDeps.Count
|
||||||
|
$ans = Read-Host ('Detected {0} missing dependencies (optional/required). Would you like to install them now? (y/N)' -f $totalMissing)
|
||||||
|
if ($ans -match '^y') {
|
||||||
|
Write-Host ''
|
||||||
|
foreach ($depInfo in $missingDeps) {
|
||||||
|
Write-Host ('--- Installing ' + $depInfo.OS + ' dependency: ' + $depInfo.Name + ' ---') -ForegroundColor Cyan
|
||||||
|
if ($depInfo.OS -eq 'Windows') {
|
||||||
|
& powershell -ExecutionPolicy Bypass -File $depInfo.InstallScript $depInfo.Name
|
||||||
|
} else {
|
||||||
|
& bash $depInfo.InstallScript $depInfo.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write-Host ''
|
||||||
|
Write-Host 'Done installing dependencies.' -ForegroundColor Green
|
||||||
|
Write-Host 'Restart your terminal if any PATH variables were updated.' -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($CheckDeps) {
|
||||||
|
Invoke-DependencyCheck
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
75
install.sh
75
install.sh
|
|
@ -81,27 +81,82 @@ if $LIST; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- Check deps ---
|
# --- Check deps function ---
|
||||||
if $CHECK_DEPS; then
|
invoke_dependency_check() {
|
||||||
echo "=== Running Dependency Checks ==="
|
echo "=== Running Dependency Checks ==="
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
local missing_win=()
|
||||||
|
local missing_android=()
|
||||||
|
|
||||||
echo "--- Windows Dependencies ---"
|
echo "--- Windows Dependencies ---"
|
||||||
WIN_SCRIPT="$SCRIPT_DIR/plugins/windows-reverse-engineering/skills/windows-reverse-engineering/scripts/check-deps.ps1"
|
local win_check="$SCRIPT_DIR/plugins/windows-reverse-engineering/skills/windows-reverse-engineering/scripts/check-deps.ps1"
|
||||||
if command -v powershell &>/dev/null && [ -f "$WIN_SCRIPT" ]; then
|
local win_install="$SCRIPT_DIR/plugins/windows-reverse-engineering/skills/windows-reverse-engineering/scripts/install-dep.ps1"
|
||||||
powershell -ExecutionPolicy Bypass -File "$WIN_SCRIPT" || true
|
if command -v powershell &>/dev/null && [ -f "$win_check" ]; then
|
||||||
elif command -v pwsh &>/dev/null && [ -f "$WIN_SCRIPT" ]; then
|
while IFS= read -r line; do
|
||||||
pwsh -ExecutionPolicy Bypass -File "$WIN_SCRIPT" || true
|
if [[ "$line" =~ ^INSTALL_(REQUIRED|OPTIONAL):(.+)$ ]]; then
|
||||||
|
missing_win+=("${BASH_REMATCH[2]}")
|
||||||
|
else
|
||||||
|
echo "$line"
|
||||||
|
fi
|
||||||
|
done < <(powershell -ExecutionPolicy Bypass -File "$win_check" 2>&1 || true)
|
||||||
|
elif command -v pwsh &>/dev/null && [ -f "$win_check" ]; then
|
||||||
|
while IFS= read -r line; do
|
||||||
|
if [[ "$line" =~ ^INSTALL_(REQUIRED|OPTIONAL):(.+)$ ]]; then
|
||||||
|
missing_win+=("${BASH_REMATCH[2]}")
|
||||||
|
else
|
||||||
|
echo "$line"
|
||||||
|
fi
|
||||||
|
done < <(pwsh -ExecutionPolicy Bypass -File "$win_check" 2>&1 || true)
|
||||||
else
|
else
|
||||||
echo "PowerShell not available. Skipping Windows dependency check."
|
echo "PowerShell not available. Skipping Windows dependency check."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "--- Android Dependencies ---"
|
echo "--- Android Dependencies ---"
|
||||||
ANDROID_SCRIPT="$SCRIPT_DIR/plugins/android-reverse-engineering/skills/android-reverse-engineering/scripts/check-deps.sh"
|
local android_check="$SCRIPT_DIR/plugins/android-reverse-engineering/skills/android-reverse-engineering/scripts/check-deps.sh"
|
||||||
if [ -f "$ANDROID_SCRIPT" ]; then
|
local android_install="$SCRIPT_DIR/plugins/android-reverse-engineering/skills/android-reverse-engineering/scripts/install-dep.sh"
|
||||||
bash "$ANDROID_SCRIPT" || true
|
if [ -f "$android_check" ]; then
|
||||||
|
while IFS= read -r line; do
|
||||||
|
# Filter out powershell warnings matching CRLF if needed, bash doesn't have it generally but check-deps might
|
||||||
|
line="${line%$'\r'}"
|
||||||
|
if [[ "$line" =~ ^INSTALL_(REQUIRED|OPTIONAL):(.+)$ ]]; then
|
||||||
|
missing_android+=("${BASH_REMATCH[2]}")
|
||||||
|
else
|
||||||
|
echo "$line"
|
||||||
|
fi
|
||||||
|
done < <(bash "$android_check" 2>&1 || true)
|
||||||
else
|
else
|
||||||
echo "Android check-deps.sh not found."
|
echo "Android check-deps.sh not found."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local total_missing=$((${#missing_win[@]} + ${#missing_android[@]}))
|
||||||
|
if [ "$total_missing" -gt 0 ]; then
|
||||||
|
echo ""
|
||||||
|
read -rp "Detected $total_missing missing dependencies (optional/required). Would you like to install them now? (y/N) " ans
|
||||||
|
if [[ "$ans" =~ ^[Yy] ]]; then
|
||||||
|
echo ""
|
||||||
|
for dep in "${missing_win[@]}"; do
|
||||||
|
echo "--- Installing Windows dependency: $dep ---"
|
||||||
|
if command -v powershell &>/dev/null; then
|
||||||
|
powershell -ExecutionPolicy Bypass -File "$win_install" "$dep"
|
||||||
|
else
|
||||||
|
pwsh -ExecutionPolicy Bypass -File "$win_install" "$dep"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
for dep in "${missing_android[@]}"; do
|
||||||
|
echo "--- Installing Android dependency: $dep ---"
|
||||||
|
bash "$android_install" "$dep"
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
|
echo "Done installing dependencies."
|
||||||
|
echo "Restart your terminal if any PATH variables were updated."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if $CHECK_DEPS; then
|
||||||
|
invoke_dependency_check
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue