diff options
author | Piotr Strzelczyk <piotr@eps.gda.pl> | 2009-08-05 23:37:31 +0000 |
---|---|---|
committer | Piotr Strzelczyk <piotr@eps.gda.pl> | 2009-08-05 23:37:31 +0000 |
commit | a109be8215ec1d0accec5e1905f2d79b5a318058 (patch) | |
tree | 7d6b00b347e9e99b3c601b1c3a2f4d9be99e09d1 /Master/texmf | |
parent | 7a9e53b7e5ebb0d14a14c3562cd5c3521754722a (diff) |
more debug in updater, removed locking
git-svn-id: svn://tug.org/texlive/trunk@14546 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf')
-rw-r--r-- | Master/texmf/scripts/texlive/updater-w32 | 132 |
1 files changed, 69 insertions, 63 deletions
diff --git a/Master/texmf/scripts/texlive/updater-w32 b/Master/texmf/scripts/texlive/updater-w32 index f2a831f6726..187206e856b 100644 --- a/Master/texmf/scripts/texlive/updater-w32 +++ b/Master/texmf/scripts/texlive/updater-w32 @@ -22,7 +22,10 @@ rem :: a trigger script that is to be executed. If trigger script exists :: before tlmgr.pl is launched, it will be removed or tlmgr.bat will :: abort if it fails to do so. This means that the trigger script -:: has to be created by the current invocation of tlmgr.pl +:: has to be created by the current invocation of tlmgr.pl. +:: Futhermore, the trigger script is renamed from updater-w32 to +:: updater-w32.bat just before it is run, and thus it can trigger only +:: once. :: * write_w32_updater subroutine in tlmgr.pl prepares the update :: and writes the trigger script. Packages in .xz archives are :: dowloaded/copied and uncompressed to .tar files. Also .tar @@ -30,11 +33,9 @@ rem :: successful, the trigger script is created from the template :: appended with evironment settings needed for the update. :: Otherwise the update is aborted. -:: * updater-w32.bat, which is this script, triggers and executes -:: the actual update. During the execution of an update it locks -:: itself up write open to prevent tlmgr.bat from starting another -:: instance of tlmgr and/or update. The list of packages to update -:: and any additional information is passed through evironment, +:: * updater-w32[.bat], which is this script, triggers and executes +:: the actual update. The list of packages to update and any +:: additional information is passed through evironment, :: including agrmuments for tlmgr restart needed to complete the :: update of remaining packages. :: The list of infrastructure packages consists of triples: @@ -67,40 +68,27 @@ rem rem Make environment changes local & enable cmd extensions rem (we don't want delayed expansion becasue it's hard to echo bang !) setlocal enableextensions disabledelayedexpansion -rem Make sure that the environment is clean and that we can use dynamic variables -for %%I in (errorlevel date time w32upd_args) do (set %%I=) + +rem Make sure that dynamic variables are not overshadowed +for %%I in (errorlevel date time) do (set %%I=) rem Set up the evironment for update call :setupenv -if not defined w32upd_args ( - echo updater-w32: update arguments not defined, please report this to: tex-live@tug.org>&2 - exit /b 1 -) -set dbg=rem -if /i %w32upd_debug%0 GTR 0 ( - set dbg=echo D:updater-w32: - echo D:updater-w32: updater data: - set w32upd_ -) +if /i %w32upd_debug%0 GEQ 20 (echo on) if "%~1"=="main" goto :main -rem Restart in cmd.exe to avoid problems if 4NT is used -set respawn=cmd.exe /c call +set respawn= rem For gui mode console window might be hidden, so open a new one -if /i %w32upd_gui_mode%0==10 set respawn=start /wait %respawn% -set exitcode=0 -rem Lock this file write-open during execution to signal running state -call %dbg% respawning in cmd.exe ... -%respawn% "%~f0" main 9^>^>"%~f0" -if errorlevel 1 goto :sefldel -if not defined w32upd_rerun_args goto :selfdel - -echo Restarting tlmgr to complete update ... -call %dbg% tlmgr.bat %w32upd_rerun_args% -call tlmgr.bat %w32upd_rerun_args% - -:selfdel +if "%w32upd_gui_mode%"=="1" set respawn=start /wait +rem Restart in cmd.exe to avoid problems if 4NT is used +call :debug "respawning in cmd.exe ..." +%respawn% cmd.exe /c call "%~f0" main +if errorlevel 1 exit /b %errorlevel% +if defined w32upd_rerun_args ( + call :info "Restarting tlmgr to complete update ..." + call tlmgr.bat %w32upd_rerun_args% +) set exitcode=%errorlevel% rem Self-delete without error message about missing file start /b cmd.exe /c del "%~f0" & exit /b %exitcode% @@ -108,27 +96,32 @@ start /b cmd.exe /c del "%~f0" & exit /b %exitcode% :main title %w32upd_title% +if not defined w32upd_args ( + call :error "Update arguments not defined, please report this to: tex-live@tug.org" + goto :abort +) +call :debug "update package list: %w32upd_args%" + rem Get TL installation root and log file location for /f "tokens=1-2 delims=;" %%I in ( - 'kpsewhich -expand-var=$SELFAUTOLOC/:;$TEXMFSYSVAR/web2c' + 'kpsewhich -expand-var="$SELFAUTOLOC/:;$TEXMFSYSVAR/web2c/tlmgr.log"' ) do ( set tlroot=%%~fI - set logdir=%%~fJ + set tlmgrlog=%%~fJ ) set "tlroot=%tlroot:\bin\win32\:=%" if not exist "%tlroot%\texmf\scripts\texlive\tlmgr.pl" ( - echo updater-w32: cannot locate installation root.>&2 - exit /b 1 + call :error "Could not locate installation root." + goto :abort ) -call %dbg% TL root: %tlroot% -if not exist "%logdir%\" (set logdir=%tlroot%\temp) -call %dbg% log dir: %logdir% +call :debug "TL root: %tlroot%" +if not exist "%tlmgrlog%" (set tlmgrlog=%~dpn0.log) rem Make a private copy of tar.exe copy /y "%tlroot%\tlpkg\installer\tar.exe" "%tlroot%\temp\tar-w32.exe" >nul if errorlevel 1 ( - echo updater-w32: cannot copy tar.exe>&2 - exit /b 1 + call :error "Could not copy tar.exe." + goto :abort ) rem Set up perl environment @@ -143,38 +136,37 @@ set pkgcount=0 call :foreachpkg remove_src_doc pkglist %pkgpartslist% rem Begin update -set exitcode=0 echo DO NOT CLOSE THIS WINDOW! -echo TeX Live infrastructure update in progress... +call :info "TeX Live infrastructure update [%date% %time%]" call :foreachpkg untar "%tlroot%\temp\" %pkgpartslist% if errorlevel 1 goto :rollback call :foreachpkg incltlpobj "%tlroot%\tlpkg\tlpobj\" %pkgpartslist% if errorlevel 1 goto :rollback call :foreachpkg updateinfo "update" %pkglist% -call :printmsg%w32upd_gui_mode% "TeX Live infrastructure update complete." 0 "%w32upd_title%" -goto :finish +call :printmsg "TeX Live infrastructure update complete." 0 "%w32upd_title%" +del "%tlroot%\temp\tar-w32.exe" "%tlroot%\temp\*.tar" 1>nul +exit /b 0 :rollback call :foreachpkg updateinfo "failed update" %pkglist% >&2 -echo Rolling back to previous version... +call :info "Rolling back to previous version ..." call :foreachpkg untar "%tlroot%\temp\__BACKUP_" %pkglist% if errorlevel 1 goto :panic call :foreachpkg incltlpobj "%tlroot%\tlpkg\tlpobj\" %pkglist% if errorlevel 1 goto :panic call :foreachpkg restoreinfo "restore" %pkglist% -call :printmsg%w32upd_gui_mode% "TeX Live infrastructure update failed.\nPrevious version has been restored." 16 "ERROR: %w32upd_title%" >&2 -set exitcode=1 -goto :finish +call :printmsg "TeX Live infrastructure update failed.\nPrevious version has been restored." 16 "ERROR: %w32upd_title%" >&2 +exit /b 1 :panic call :foreachpkg restoreinfo "failed restore" %pkglist% >&2 -call :printmsg%w32upd_gui_mode% "TeX Live infrastructure update failed and backup recovery failed as well.\nYour TeX Live installation may be broken, to repair it download and run:\nhttp://mirror.ctan.org/systems/texlive/tlnet/update-tlmgr-latest.exe" 16 "FATAL ERROR: %w32upd_title%" >&2 +call :printmsg "TeX Live infrastructure update failed and backup recovery failed as well.\nYour TeX Live installation may be broken, to repair it download and run:\nhttp://mirror.ctan.org/systems/texlive/tlnet/update-tlmgr-latest.exe" 16 "FATAL ERROR: %w32upd_title%" >&2 rem Evil has taken over - emit adequate exit code exit /b 666 -:finish -del "%tlroot%\temp\tar-w32.exe" "%tlroot%\temp\__BACKUP_*" 1>nul 2>nul -exit /b %exitcode% +:abort +call :info "Aborting infrastructure update, no changes have been made." +exit /b 1 REM SUBROUTINES @@ -197,15 +189,30 @@ exit /b 0 :untar %tlroot%\temp\[__BACKUP_] pkgname set "suffix=tar" if %~n1_==__BACKUP__ set "suffix=r%~3.tar" -call %dbg% untar: "%tlroot%\temp\tar-w32.exe" -C "%tlroot%" -f "%~1%~2.%suffix%" -x -"%tlroot%\temp\tar-w32.exe" -C "%tlroot%" -f "%~1%~2.%suffix%" -x && del "%~1%~2.%suffix%" +call :debug "untar: %~1%~2.%suffix%" +"%tlroot%\temp\tar-w32.exe" -C "%tlroot%" -f "%~1%~2.%suffix%" -x exit /b %errorlevel% :incltlpobj %tlroot%\tlpkg\tlpobj\ pkgname -call %dbg% merge into tlpdb: "%~1%~2.tlpobj" +call :debug "include into tlpdb: %~1%~2.tlpobj" "%tlroot%\tlpkg\tlperl\bin\perl.exe" "%tlroot%\texmf\scripts\texlive\tlmgr.pl" _include_tlpobj "%~1%~2.tlpobj" exit /b %errorlevel% +:info "message text" +echo.%~1>>"%~dpn0.log" +echo.%~1 +exit /b 0 + +:debug "message text" +echo.%~1>>"%~dpn0.log" +if /i %w32upd_debug%0 GTR 0 (>&2 echo D: %~1) +exit /b 0 + +:error "message text" +echo.%~1>>"%~dpn0.log" +>&2 echo.%~1 +exit /b 1 + :updateinfo header pkgname oldrev newrev set "infomsg= -> %~4" :restoreinfo header pkgname oldrev newrev @@ -213,16 +220,15 @@ set "infomsg=%~1: %~2 (%~3%infomsg%)" set "infomsg=%infomsg:>=^>%" set /a pkgnr+=1 echo [%pkgnr%/%pkgcount%] %infomsg% -echo [%date% %time%] %infomsg%>>"%logdir%\tlmgr.log" +echo [%pkgnr%/%pkgcount%] %infomsg%>>"%~dpn0.log" +echo [%date% %time%] %infomsg%>>"%tlmgrlog%" set "infomsg=" exit /b 0 -:printmsg0 "message text" +:printmsg "message text" set infomsg=%~1 -for %%I in ("%infomsg:\n=" "%") do echo.%%~I -exit /b 0 - -:printmsg1 "message text" icon "title string" +for %%I in ("%infomsg:\n=" "%") do call :info "%%~I" +if not "%w32upd_gui_mode%"=="1" exit /b 0 echo MsgBox Replace("%~1", "\n", Chr(10)), %2, "%~3" >"%tlroot%\temp\dialogpopup.vbs" cscript -nologo "%tlroot%\temp\dialogpopup.vbs" del "%tlroot%\temp\dialogpopup.vbs" |