From 08436e407b18df915e3ea94b263a737ee65b9905 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 12 Feb 2009 12:08:37 +0000 Subject: commit Tomek's changes plus renaming the updater to updater-w32 git-svn-id: svn://tug.org/texlive/trunk@12152 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf/scripts/texlive/tlmgr.pl | 8 +- Master/texmf/scripts/texlive/updater-w32.bat | 144 +++++++++++++++++++++++++++ Master/texmf/scripts/texlive/w32_updater.bat | 144 --------------------------- 3 files changed, 149 insertions(+), 147 deletions(-) create mode 100644 Master/texmf/scripts/texlive/updater-w32.bat delete mode 100644 Master/texmf/scripts/texlive/w32_updater.bat (limited to 'Master/texmf/scripts') diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index 0e7d4a4d633..4c7253fe2c6 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -1198,13 +1198,15 @@ sub write_w32_updater { } return 0 if ($opts{"dry-run"}); # nothing else to do # write the updater script file - open UPDATER, ">$root/texmf/scripts/texlive/updater" + open UPDATER, ">$root/temp/run-updater-w32" or die "Cannot create updater: $!"; print UPDATER '@echo off setlocal enableextensions (set errorlevel=) -call "%~dp0w32_updater" ' . join(' ',@updater_args) . ' -start /b cmd /c del "%~f0" & exit /b %errorlevel%'; +>nul copy /y "%~dp0..\texmf\scripts\texlive\updater-w32.bat" "%~dp0updater-w32.bat" +call "%~dp0updater-w32" ' . join(' ',@updater_args) . ' +if errorlevel 1 call exit /b %%errorlevel%% +start /b cmd /c del "%~f0" "%~dp0updater-w32.bat"'; close UPDATER; return 0; } diff --git a/Master/texmf/scripts/texlive/updater-w32.bat b/Master/texmf/scripts/texlive/updater-w32.bat new file mode 100644 index 00000000000..0482f1d2d84 --- /dev/null +++ b/Master/texmf/scripts/texlive/updater-w32.bat @@ -0,0 +1,144 @@ +@echo off +rem Update script for TeX Live infrastructure +rem called automatically if there are any infrastructure updates +rem +rem Copyright 2009 by Tomasz M. Trzeciak +rem This file is licensed under the GNU General Public License version 2 +rem or any later version. +rem + +rem This script makes some very specific assumptions. +rem Arguments are expected to be a package list passed in triples: +rem package-name old-revision-number new-revision-number +rem For each package-name a tar archive package-name.tar is +rem expected as well (also for .source and .doc pseudo packages - +rem - those are for distribution only and don't appear as separate +rem entries in tlpdb) and a corresponding backup archive +rem __BACKUP_package-name.rXXX.tar, where XXX is (old) +rem revision number (.source and .doc are included in them) + +rem The update logic is follows: +rem (1) untar all package archives +rem (2) include .tlpobj files into tlpdb +rem (3) print update info +rem Any error during (1) or (2) trigers a rollback action: +rem (1) print failed update info +rem (2) untar all package backups +rem (3) include .tlpobj files (from backup) into tlpdb +rem (4) print restore info and popup an error dialog +rem Any error during (1) or (2) and we go into panic mode. +rem At this point there is no guarantee that the installation is still +rem working. There is not much we can do but to print failed restore info +rem and popup a fatal error dialog with instructions to download and run +rem 'update-tlmgr-latest.exe' when everything else failed. + +rem make environment changes local & enable cmd extensions +setlocal enableextensions +rem get installation root +for /f "delims=" %%D in ('kpsewhich -var-value=SELFAUTOPARENT') do (set tlroot=%%~fD) +if exist "%tlroot%\" goto :foundtlroot +>&2 echo Could not locate installation root. +exit /b 1 + +:foundtlroot +rem get location of the log file +for /f "delims=" %%D in ('kpsewhich -var-value=TEXMFSYSVAR') do (set logdir=%%~fD\web2c) +if not exist "%logdir%\" (set logdir=temp) +rem cd to root +cd /d "%tlroot%" +rem create tar.exe backup +>nul copy /y tlpkg\installer\tar.exe temp\w32_tar.exe +rem set up perl environment +set "PERL5LIB=%tlroot%\tlpkg\tlperl\lib" +rem let's make sure that we can use dynamic variables +(set errorlevel=) +(set date=) +(set time=) + +rem get package list from arguments +(set pkgpartslist=%*) +if not defined pkgpartslist exit /b 0 +rem construct package list without .source and .doc packages +rem count the total number of packages while doing that +set pkgcount=0 +(set pkglist=) +call :foreachpkg :remove_src_doc pkglist %pkgpartslist% + +echo DO NOT CLOSE THIS WINDOW! +echo TeX Live infrastructure update in progress... +call :foreachpkg :untar "temp\" %pkgpartslist% || goto :rollback +call :foreachpkg :incltlpobj "tlpkg\tlpobj\" %pkgpartslist% || goto :rollback +call :foreachpkg :update_info "" %pkglist% +echo Update complete. +set exitcode=0 +goto :finish + +:rollback +call :foreachpkg :update_info ">&2" %pkglist% +>&2 echo Update failed! Rolling back to previous version... +call :foreachpkg :untar "temp\__BACKUP_" %pkglist% || goto :panic +call :foreachpkg :incltlpobj "tlpkg\tlpobj\" %pkglist% || goto :panic +call :foreachpkg :restore_info "" %pkglist% +echo Recovery from backup successful. +call :errorpopup "ERROR: TeX Live" "TeX Live infrastructure update failed." +set exitcode=1 +goto :finish + +:panic +call :foreachpkg :restore_info ">&2" %pkglist% +>&2 echo FATAL ERROR: recovery from backup failed! +echo Your TeX Live installation may be broken, to repair it download and run: +echo http://mirror.ctan.org/systems/texlive/tlnet/2008/update-tlmgr-latest.exe +call :errorpopup "FATAL ERROR: TeX Live" "TeX Live infrastructure update failed and so did recovery from backup.\nYour TeX Live installation may be broken, to repair it download and run:\nhttp://mirror.ctan.org/systems/texlive/tlnet/2008/update-tlmgr-latest.exe" +rem Evil has taken over - emit adequate exit code +exit /b 666 + +:finish +2>nul del temp\w32_tar.exe temp\__BACKUP_* +exit /b %exitcode% + +REM SUBROUTINES + +:foreachpkg cmd prefix [pkg_name oldrev newrev [...]] +set pkgcurr=0 +:pkgloop +if [%3]==[] exit /b 0 +set /a pkgcurr+=1 +call %~1 %2 %3 %4 %5 +if errorlevel 1 exit /b %errorlevel% +shift /3 & shift /3 & shift /3 +goto :pkgloop + +:untar temp\[__BACKUP_] pkg_name +set "ext=tar" +if %~n1_==__BACKUP__ set "ext=r%~3.tar" +temp\w32_tar.exe -x -f "%~1%~2.%ext%" && del "%~1%~2.%ext%" +exit /b %errorlevel% + +:incltlpobj tlpkg\tlpobj\ pkg_name +tlpkg\tlperl\bin\perl.exe texmf\scripts\texlive\tlmgr.pl _include_tlpobj "%~1%~2.tlpobj" +exit /b %errorlevel% + +:remove_src_doc +if /i %~x2.==.source. exit /b 0 +if /i %~x2.==.doc. exit /b 0 +set %1=%pkglist% %2 %3 %4 +set /a pkgcount+=1 +exit /b 0 + +:update_info redir pkg_name oldrev newrev +set "infomsg=update: %~2 (%~3 -^> %~4)" +goto :continue_info +:restore_info redir pkg_name oldrev newrev +set "infomsg=restore: %~2 (%~3)" +:continue_info +if "%~1"==">&2" set "infomsg=failed %infomsg%" +>>"%logdir%\tlmgr.log" echo [%date% %time%] %infomsg% +%~1 echo [%pkgcurr%/%pkgcount%] %infomsg% +exit /b 0 + +:errorpopup "title string" "message text" +>temp\errorpopup.vbs echo CreateObject("Scripting.FileSystemObject").DeleteFile(WScript.ScriptFullName) : MsgBox Replace("%~2","\n",Chr(10)), 16, "%~1" +wscript temp\errorpopup.vbs +rem del temp\errorpopup.vbs +exit /b 0 diff --git a/Master/texmf/scripts/texlive/w32_updater.bat b/Master/texmf/scripts/texlive/w32_updater.bat deleted file mode 100644 index cbd8982c6f3..00000000000 --- a/Master/texmf/scripts/texlive/w32_updater.bat +++ /dev/null @@ -1,144 +0,0 @@ -@echo off -rem Update script for TeX Live infrastructure -rem called automatically if there are any infrastructure updates -rem -rem Copyright 2009 by Tomasz M. Trzeciak -rem This file is licensed under the GNU General Public License version 2 -rem or any later version. -rem - -rem This script makes some very specific assumptions. -rem Arguments are expected to be a package list passed in triples: -rem package-name old-revision-number new-revision-number -rem For each package-name a tar archive package-name.tar is -rem expected as well (also for .source and .doc pseudo packages - -rem - those are for distribution only and don't appear as separate -rem entries in tlpdb) and a corresponding backup archive -rem __BACKUP_package-name.rXXX.tar, where XXX is (old) -rem revision number (.source and .doc are included in them) - -rem The update logic is follows: -rem (1) untar all package archives -rem (2) include .tlpobj files into tlpdb -rem (3) print update info -rem Any error during (1) or (2) trigers a rollback action: -rem (1) print failed update info -rem (2) untar all package backups -rem (3) include .tlpobj files (from backup) into tlpdb -rem (4) print restore info and popup an error dialog -rem Any error during (1) or (2) and we go into panic mode. -rem At this point there is no guarantee that the installation is still -rem working. There is not much we can do but to print failed restore info -rem and popup a fatal error dialog with instructions to download and run -rem 'update-tlmgr-latest.exe' when everything else failed. - -rem make environment changes local & enable cmd extensions -setlocal enableextensions -rem get installation root -for /f "delims=" %%D in ('kpsewhich -var-value=SELFAUTOPARENT') do (set tlroot=%%~fD) -if exist "%tlroot%\" goto :foundtlroot ->&2 echo Could not locate installation root. -exit /b 1 - -:foundtlroot -rem get location of the log file -for /f "delims=" %%D in ('kpsewhich -var-value=TEXMFSYSVAR') do (set logdir=%%~fD\web2c) -if not exist "%logdir%\" (set logdir=temp) -rem cd to root -cd /d "%tlroot%" -rem create tar.exe backup ->nul copy /y "tlpkg\installer\tar.exe" "tlpkg\installer\tarsave.exe" -rem set up perl environment -set "PERL5LIB=%tlroot%\tlpkg\tlperl\lib" -rem let's make sure that we can use dynamic variables -(set errorlevel=) -(set date=) -(set time=) - -rem get package list from arguments -(set pkgpartslist=%*) -if not defined pkgpartslist exit /b 0 -rem construct package list without .source and .doc packages -rem count the total number of packages while doing that -set pkgcount=0 -(set pkglist=) -call :foreachpkg :remove_src_doc pkglist %pkgpartslist% - -echo DO NOT CLOSE THIS WINDOW! -echo TeX Live infrastructure update in progress... -call :foreachpkg :untar "temp\" %pkgpartslist% || goto :rollback -call :foreachpkg :incltlpobj "tlpkg\tlpobj\" %pkgpartslist% || goto :rollback -call :foreachpkg :update_info "" %pkglist% -echo Update complete. -set exitcode=0 -goto :finish - -:rollback -call :foreachpkg :update_info ">&2" %pkglist% ->&2 echo Update failed! Rolling back to previous version... -call :foreachpkg :untar "temp\__BACKUP_" %pkglist% || goto :panic -call :foreachpkg :incltlpobj "tlpkg\tlpobj\" %pkglist% || goto :panic -call :foreachpkg :restore_info "" %pkglist% -echo Recovery from backup successful. -call :errorpopup "ERROR: TeX Live" "TeX Live infrastructure update failed." -set exitcode=1 -goto :finish - -:panic -call :foreachpkg :restore_info ">&2" %pkglist% ->&2 echo FATAL ERROR: recovery from backup failed! -echo Your TeX Live installation may be broken, to repair it download and run: -echo http://mirror.ctan.org/systems/texlive/tlnet/2008/update-tlmgr-latest.exe -call :errorpopup "FATAL ERROR: TeX Live" "TeX Live infrastructure update failed and so did recovery from backup.\nYour TeX Live installation may be broken, to repair it download and run:\nhttp://mirror.ctan.org/systems/texlive/tlnet/2008/update-tlmgr-latest.exe" -rem Evil has taken over - emit adequate exit code -exit /b 666 - -:finish -2>nul del tlpkg\installer\tarsave.exe temp\__BACKUP_* -exit /b %exitcode% - -REM SUBROUTINES - -:foreachpkg cmd prefix [pkg_name oldrev newrev [...]] -set pkgcurr=0 -:pkgloop -if [%3]==[] exit /b 0 -set /a pkgcurr+=1 -call %~1 %2 %3 %4 %5 -if errorlevel 1 exit /b %errorlevel% -shift /3 & shift /3 & shift /3 -goto :pkgloop - -:untar temp\[__BACKUP_] pkg_name -set "ext=tar" -if %~n1_==__BACKUP__ set "ext=r%~3.tar" -tlpkg\installer\tarsave.exe -x -f "%~1%~2.%ext%" && del "%~1%~2.%ext%" -exit /b %errorlevel% - -:incltlpobj tlpkg\tlpobj\ pkg_name -tlpkg\tlperl\bin\perl.exe texmf\scripts\texlive\tlmgr.pl _include_tlpobj "%~1%~2.tlpobj" -exit /b %errorlevel% - -:remove_src_doc -if /i %~x2.==.source. exit /b 0 -if /i %~x2.==.doc. exit /b 0 -set %1=%pkglist% %2 %3 %4 -set /a pkgcount+=1 -exit /b 0 - -:update_info redir pkg_name oldrev newrev -set "infomsg=update: %~2 (%~3 -^> %~4)" -goto :continue_info -:restore_info redir pkg_name oldrev newrev -set "infomsg=restore: %~2 (%~3)" -:continue_info -if "%~1"==">&2" set "infomsg=failed %infomsg%" ->>"%logdir%\tlmgr.log" echo [%date% %time%] %infomsg% -%~1 echo [%pkgcurr%/%pkgcount%] %infomsg% -exit /b 0 - -:errorpopup "title string" "message text" ->temp\errorpopup.vbs echo CreateObject("Scripting.FileSystemObject").DeleteFile(WScript.ScriptFullName) : MsgBox Replace("%~2","\n",Chr(10)), 16, "%~1" -wscript temp\errorpopup.vbs -rem del temp\errorpopup.vbs -exit /b 0 \ No newline at end of file -- cgit v1.2.3