From b6e4971caf2fc7b1568c3ef6ef8ea0d8b21a963f Mon Sep 17 00:00:00 2001 From: Nose Date: Sat, 28 Feb 2026 02:45:14 -0800 Subject: [PATCH] fix updater --- scripts/bootstrap.py | 123 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 104 insertions(+), 19 deletions(-) diff --git a/scripts/bootstrap.py b/scripts/bootstrap.py index e42614e..0775f32 100644 --- a/scripts/bootstrap.py +++ b/scripts/bootstrap.py @@ -1604,29 +1604,61 @@ if (Test-Path (Join-Path $repo ".git")) { $conf = Join-Path $repo "config.conf" $skip = $false 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 } } if (-not $skip) { Write-Host "Checking for updates..." -ForegroundColor Gray + Write-Host "[mm] Checking repository updates..." -ForegroundColor DarkGray $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)) { - Write-Host "Checking Python module updates..." -ForegroundColor Gray - & $py -m pip install --disable-pip-version-check --upgrade -r $requirements *> $null - if ($LASTEXITCODE -ne 0) { - Write-Host "Warning: dependency update failed; continuing startup." -ForegroundColor Yellow + Write-Host "[mm] Checking Python module updates..." -ForegroundColor DarkGray + $depOutput = & $py -m pip install --disable-pip-version-check --upgrade -r $requirements 2>&1 + $depExit = $LASTEXITCODE + 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) { - Clear-Host Write-Host "Medeia-Macina has been updated. Please restart the application to apply changes." -ForegroundColor Cyan exit 0 } - Clear-Host } } } catch {} @@ -1694,21 +1726,50 @@ if (Test-Path (Join-Path $repo 'CLI.py')) { " )\n" " if \"!AUTO_UPDATE!\" == \"true\" (\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" - " 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 exist \"!PY!\" if exist \"!REQ!\" (\n" - " echo Checking Python module updates...\n" - " \"!PY!\" -m pip install --disable-pip-version-check --upgrade -r \"!REQ!\" >nul 2>&1\n" + " echo [mm] Checking Python module updates...\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" + " ) else (\n" + " echo [mm] Python module update skipped: MM_NO_DEP_UPDATE=1.\n" " )\n" " if \"!REPO_UPDATED!\" == \"true\" (\n" - " cls\n" " echo Medeia-Macina has been updated. Please restart the application to apply changes.\n" " exit /b 0\n" " )\n" - " cls\n" " )\n" " )\n" ")\n" @@ -1888,10 +1949,20 @@ if (Test-Path (Join-Path $repo 'CLI.py')) { ' fi\n' ' if [ "$AUTO_UPDATE" = "true" ]; then\n' ' echo "Checking for updates..."\n' + ' echo "[mm] Checking repository updates..."\n' ' UPDATE_OUT=$(git -C "$REPO" pull --ff-only 2>&1)\n' + ' UPDATE_EXIT=$?\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' + ' 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' ' MM_PY=""\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' ' fi\n' ' if [ -z "${MM_NO_DEP_UPDATE:-}" ] && [ -n "$MM_PY" ] && [ -f "$REPO/scripts/requirements.txt" ]; then\n' - ' echo "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' + ' echo "[mm] Checking Python module updates..."\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' ' if [ "$REPO_UPDATED" = "true" ]; then\n' - ' clear\n' ' echo "Medeia-Macina has been updated. Please restart the application to apply changes."\n' ' exit 0\n' ' fi\n' - ' clear\n' ' fi\n' "fi\n" "\n"