fix updater
This commit is contained in:
@@ -1604,29 +1604,61 @@ if (Test-Path (Join-Path $repo ".git")) {
|
|||||||
$conf = Join-Path $repo "config.conf"
|
$conf = Join-Path $repo "config.conf"
|
||||||
$skip = $false
|
$skip = $false
|
||||||
if (Test-Path $conf) {
|
if (Test-Path $conf) {
|
||||||
if ((Get-Content $conf | Select-String "auto_update\s*=\s*(false|no|off|0)") -ne $null) {
|
if ($null -ne (Get-Content $conf | Select-String "auto_update\s*=\s*(false|no|off|0)")) {
|
||||||
$skip = $true
|
$skip = $true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (-not $skip) {
|
if (-not $skip) {
|
||||||
Write-Host "Checking for updates..." -ForegroundColor Gray
|
Write-Host "Checking for updates..." -ForegroundColor Gray
|
||||||
|
Write-Host "[mm] Checking repository updates..." -ForegroundColor DarkGray
|
||||||
$update = git -C "$repo" pull --ff-only 2>&1
|
$update = git -C "$repo" pull --ff-only 2>&1
|
||||||
$repoUpdated = ($update -like "*Updating*" -or $update -like "*Fast-forward*")
|
$gitExit = $LASTEXITCODE
|
||||||
|
$updateText = ($update | Out-String)
|
||||||
|
$repoUpdated = ($updateText -match "Updating|Fast-forward")
|
||||||
|
$repoUpToDate = ($updateText -match "Already up[\s-]+to[\s-]+date")
|
||||||
|
|
||||||
|
if ($gitExit -ne 0) {
|
||||||
|
Write-Host "[mm] Warning: git update check failed; continuing startup." -ForegroundColor Yellow
|
||||||
|
$gitTail = @($update | Select-Object -Last 3)
|
||||||
|
foreach ($line in $gitTail) {
|
||||||
|
if ($line) { Write-Host "[git] $line" -ForegroundColor DarkYellow }
|
||||||
|
}
|
||||||
|
} elseif ($repoUpdated) {
|
||||||
|
Write-Host "[mm] Repository update found (fast-forward/applied)." -ForegroundColor Green
|
||||||
|
} elseif ($repoUpToDate) {
|
||||||
|
Write-Host "[mm] Repository already up to date." -ForegroundColor DarkGray
|
||||||
|
} else {
|
||||||
|
Write-Host "[mm] Repository update check completed." -ForegroundColor DarkGray
|
||||||
|
}
|
||||||
|
|
||||||
if (-not $env:MM_NO_DEP_UPDATE -and (Test-Path $py) -and (Test-Path $requirements)) {
|
if (-not $env:MM_NO_DEP_UPDATE -and (Test-Path $py) -and (Test-Path $requirements)) {
|
||||||
Write-Host "Checking Python module updates..." -ForegroundColor Gray
|
Write-Host "[mm] Checking Python module updates..." -ForegroundColor DarkGray
|
||||||
& $py -m pip install --disable-pip-version-check --upgrade -r $requirements *> $null
|
$depOutput = & $py -m pip install --disable-pip-version-check --upgrade -r $requirements 2>&1
|
||||||
if ($LASTEXITCODE -ne 0) {
|
$depExit = $LASTEXITCODE
|
||||||
Write-Host "Warning: dependency update failed; continuing startup." -ForegroundColor Yellow
|
if ($depExit -ne 0) {
|
||||||
|
Write-Host "[mm] Warning: dependency update failed; continuing startup." -ForegroundColor Yellow
|
||||||
|
$depTail = @($depOutput | Select-Object -Last 5)
|
||||||
|
foreach ($line in $depTail) {
|
||||||
|
if ($line) { Write-Host "[pip] $line" -ForegroundColor DarkYellow }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$depSummary = @($depOutput | Select-String -Pattern "Successfully installed" | Select-Object -Last 1)
|
||||||
|
if ($depSummary.Count -gt 0) {
|
||||||
|
Write-Host "[mm] $($depSummary[0].Line)" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host "[mm] Python modules are already up to date." -ForegroundColor DarkGray
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} elseif ($env:MM_NO_DEP_UPDATE) {
|
||||||
|
Write-Host "[mm] Python module update skipped (MM_NO_DEP_UPDATE=1)." -ForegroundColor DarkGray
|
||||||
|
} else {
|
||||||
|
Write-Host "[mm] Python module update skipped (venv python or requirements file missing)." -ForegroundColor DarkGray
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($repoUpdated) {
|
if ($repoUpdated) {
|
||||||
Clear-Host
|
|
||||||
Write-Host "Medeia-Macina has been updated. Please restart the application to apply changes." -ForegroundColor Cyan
|
Write-Host "Medeia-Macina has been updated. Please restart the application to apply changes." -ForegroundColor Cyan
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
Clear-Host
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
@@ -1694,21 +1726,50 @@ if (Test-Path (Join-Path $repo 'CLI.py')) {
|
|||||||
" )\n"
|
" )\n"
|
||||||
" if \"!AUTO_UPDATE!\" == \"true\" (\n"
|
" if \"!AUTO_UPDATE!\" == \"true\" (\n"
|
||||||
" echo Checking for updates...\n"
|
" echo Checking for updates...\n"
|
||||||
" git -C \"!REPO!\" pull --ff-only | findstr /i /c:\"Updating\" /c:\"Fast-forward\" >nul 2>&1\n"
|
" echo [mm] Checking repository updates...\n"
|
||||||
|
" set \"GIT_OUT=%TEMP%\\mm_git_update_!RANDOM!_!RANDOM!.log\"\n"
|
||||||
|
" git -C \"!REPO!\" pull --ff-only >\"!GIT_OUT!\" 2>&1\n"
|
||||||
|
" set \"GIT_EXIT=!errorlevel!\"\n"
|
||||||
" set \"REPO_UPDATED=false\"\n"
|
" set \"REPO_UPDATED=false\"\n"
|
||||||
" if !errorlevel! == 0 set \"REPO_UPDATED=true\"\n"
|
" if \"!GIT_EXIT!\" == \"0\" (\n"
|
||||||
|
" findstr /i /c:\"Updating\" /c:\"Fast-forward\" \"!GIT_OUT!\" >nul 2>&1\n"
|
||||||
|
" if !errorlevel! == 0 (\n"
|
||||||
|
" set \"REPO_UPDATED=true\"\n"
|
||||||
|
" echo [mm] Repository update found - fast-forward applied.\n"
|
||||||
|
" ) else (\n"
|
||||||
|
" echo [mm] Repository already up to date.\n"
|
||||||
|
" )\n"
|
||||||
|
" ) else (\n"
|
||||||
|
" echo [mm] Warning: git update check failed; continuing startup.\n"
|
||||||
|
" type \"!GIT_OUT!\"\n"
|
||||||
|
" )\n"
|
||||||
|
" del /q \"!GIT_OUT!\" >nul 2>&1\n"
|
||||||
" if not defined MM_NO_DEP_UPDATE (\n"
|
" if not defined MM_NO_DEP_UPDATE (\n"
|
||||||
" if exist \"!PY!\" if exist \"!REQ!\" (\n"
|
" if exist \"!PY!\" if exist \"!REQ!\" (\n"
|
||||||
" echo Checking Python module updates...\n"
|
" echo [mm] Checking Python module updates...\n"
|
||||||
" \"!PY!\" -m pip install --disable-pip-version-check --upgrade -r \"!REQ!\" >nul 2>&1\n"
|
" set \"PIP_OUT=%TEMP%\\mm_pip_update_!RANDOM!_!RANDOM!.log\"\n"
|
||||||
|
" \"!PY!\" -m pip install --disable-pip-version-check --upgrade -r \"!REQ!\" >\"!PIP_OUT!\" 2>&1\n"
|
||||||
|
" if !errorlevel! == 0 (\n"
|
||||||
|
" findstr /i /c:\"Successfully installed\" \"!PIP_OUT!\" >nul 2>&1\n"
|
||||||
|
" if !errorlevel! == 0 (\n"
|
||||||
|
" for /f \"delims=\" %%L in ('findstr /i /c:\"Successfully installed\" \"!PIP_OUT!\"') do set \"PIP_SUM=%%L\"\n"
|
||||||
|
" if defined PIP_SUM echo [mm] !PIP_SUM!\n"
|
||||||
|
" ) else (\n"
|
||||||
|
" echo [mm] Python modules are already up to date.\n"
|
||||||
|
" )\n"
|
||||||
|
" ) else (\n"
|
||||||
|
" echo [mm] Warning: dependency update failed; continuing startup.\n"
|
||||||
|
" type \"!PIP_OUT!\"\n"
|
||||||
|
" )\n"
|
||||||
|
" del /q \"!PIP_OUT!\" >nul 2>&1\n"
|
||||||
" )\n"
|
" )\n"
|
||||||
|
" ) else (\n"
|
||||||
|
" echo [mm] Python module update skipped: MM_NO_DEP_UPDATE=1.\n"
|
||||||
" )\n"
|
" )\n"
|
||||||
" if \"!REPO_UPDATED!\" == \"true\" (\n"
|
" if \"!REPO_UPDATED!\" == \"true\" (\n"
|
||||||
" cls\n"
|
|
||||||
" echo Medeia-Macina has been updated. Please restart the application to apply changes.\n"
|
" echo Medeia-Macina has been updated. Please restart the application to apply changes.\n"
|
||||||
" exit /b 0\n"
|
" exit /b 0\n"
|
||||||
" )\n"
|
" )\n"
|
||||||
" cls\n"
|
|
||||||
" )\n"
|
" )\n"
|
||||||
" )\n"
|
" )\n"
|
||||||
")\n"
|
")\n"
|
||||||
@@ -1888,10 +1949,20 @@ if (Test-Path (Join-Path $repo 'CLI.py')) {
|
|||||||
' fi\n'
|
' fi\n'
|
||||||
' if [ "$AUTO_UPDATE" = "true" ]; then\n'
|
' if [ "$AUTO_UPDATE" = "true" ]; then\n'
|
||||||
' echo "Checking for updates..."\n'
|
' echo "Checking for updates..."\n'
|
||||||
|
' echo "[mm] Checking repository updates..."\n'
|
||||||
' UPDATE_OUT=$(git -C "$REPO" pull --ff-only 2>&1)\n'
|
' UPDATE_OUT=$(git -C "$REPO" pull --ff-only 2>&1)\n'
|
||||||
|
' UPDATE_EXIT=$?\n'
|
||||||
' REPO_UPDATED="false"\n'
|
' REPO_UPDATED="false"\n'
|
||||||
' if echo "$UPDATE_OUT" | grep -qiE \'Updating|Fast-forward\'; then\n'
|
' if [ $UPDATE_EXIT -ne 0 ]; then\n'
|
||||||
|
' echo "[mm] Warning: git update check failed; continuing startup."\n'
|
||||||
|
' printf "%s\n" "$UPDATE_OUT" | tail -n 3\n'
|
||||||
|
' elif echo "$UPDATE_OUT" | grep -qiE \'Updating|Fast-forward\'; then\n'
|
||||||
' REPO_UPDATED="true"\n'
|
' REPO_UPDATED="true"\n'
|
||||||
|
' echo "[mm] Repository update found (fast-forward/applied)."\n'
|
||||||
|
' elif echo "$UPDATE_OUT" | grep -qiE \'Already up[ -]to[ -]date\'; then\n'
|
||||||
|
' echo "[mm] Repository already up to date."\n'
|
||||||
|
' else\n'
|
||||||
|
' echo "[mm] Repository update check completed."\n'
|
||||||
' fi\n'
|
' fi\n'
|
||||||
' MM_PY=""\n'
|
' MM_PY=""\n'
|
||||||
' if [ -x "$VENV/bin/python3" ]; then\n'
|
' if [ -x "$VENV/bin/python3" ]; then\n'
|
||||||
@@ -1900,15 +1971,29 @@ if (Test-Path (Join-Path $repo 'CLI.py')) {
|
|||||||
' MM_PY="$VENV/bin/python"\n'
|
' MM_PY="$VENV/bin/python"\n'
|
||||||
' fi\n'
|
' fi\n'
|
||||||
' if [ -z "${MM_NO_DEP_UPDATE:-}" ] && [ -n "$MM_PY" ] && [ -f "$REPO/scripts/requirements.txt" ]; then\n'
|
' if [ -z "${MM_NO_DEP_UPDATE:-}" ] && [ -n "$MM_PY" ] && [ -f "$REPO/scripts/requirements.txt" ]; then\n'
|
||||||
' echo "Checking Python module updates..."\n'
|
' echo "[mm] Checking Python module updates..."\n'
|
||||||
' "$MM_PY" -m pip install --disable-pip-version-check --upgrade -r "$REPO/scripts/requirements.txt" >/dev/null 2>&1 || true\n'
|
' DEP_OUT=$("$MM_PY" -m pip install --disable-pip-version-check --upgrade -r "$REPO/scripts/requirements.txt" 2>&1)\n'
|
||||||
|
' DEP_EXIT=$?\n'
|
||||||
|
' if [ $DEP_EXIT -ne 0 ]; then\n'
|
||||||
|
' echo "[mm] Warning: dependency update failed; continuing startup."\n'
|
||||||
|
' printf "%s\n" "$DEP_OUT" | tail -n 5\n'
|
||||||
|
' else\n'
|
||||||
|
' DEP_SUM=$(printf "%s\n" "$DEP_OUT" | grep -i "Successfully installed" | tail -n 1 || true)\n'
|
||||||
|
' if [ -n "$DEP_SUM" ]; then\n'
|
||||||
|
' echo "[mm] $DEP_SUM"\n'
|
||||||
|
' else\n'
|
||||||
|
' echo "[mm] Python modules are already up to date."\n'
|
||||||
|
' fi\n'
|
||||||
|
' fi\n'
|
||||||
|
' elif [ -n "${MM_NO_DEP_UPDATE:-}" ]; then\n'
|
||||||
|
' echo "[mm] Python module update skipped (MM_NO_DEP_UPDATE=1)."\n'
|
||||||
|
' else\n'
|
||||||
|
' echo "[mm] Python module update skipped (venv python or requirements file missing)."\n'
|
||||||
' fi\n'
|
' fi\n'
|
||||||
' if [ "$REPO_UPDATED" = "true" ]; then\n'
|
' if [ "$REPO_UPDATED" = "true" ]; then\n'
|
||||||
' clear\n'
|
|
||||||
' echo "Medeia-Macina has been updated. Please restart the application to apply changes."\n'
|
' echo "Medeia-Macina has been updated. Please restart the application to apply changes."\n'
|
||||||
' exit 0\n'
|
' exit 0\n'
|
||||||
' fi\n'
|
' fi\n'
|
||||||
' clear\n'
|
|
||||||
' fi\n'
|
' fi\n'
|
||||||
"fi\n"
|
"fi\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user