summaryrefslogtreecommitdiff
path: root/Master/bin/win32/tlmgr.bat
blob: efb1f4b2c6966eea644fd7319d37ccc1fffee053 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@echo off
rem Advanced launcher for tlmgr with auto-update
rem
rem Copyright 2009 by Tomasz M. Trzeciak <t.m.trzeciak@googlemail.com>
rem This file is licensed under the GNU General Public License version 2
rem or any later version.
rem

rem Check if we are running under NT based system
rem (works for Vista too, extra check needed to exclude winNT4)
if not [%OS%]==[Windows_NT] goto err_OS

rem Make environment changes local & enable delayed expansion
setlocal enabledelayedexpansion
(set errorlevel=)

rem Get TL installation root (it should be two levels up)
for %%I in ("%~dp0..\..") do (set tlroot=%%~fI)

rem Remove remains of previous update if any
(set tlupdatername=run-updater-w32)
(set tlupdater=%tlroot%\temp\%tlupdatername%)
if exist "%tlupdater%*" del "%tlupdater%*"
if exist "%tlupdater%*" goto :err_updater_exists

rem Start tlmgr
(set PERL5LIB=%tlroot%\tlpkg\tlperl\lib)
"%tlroot%\tlpkg\tlperl\bin\perl.exe" "%tlroot%\texmf\scripts\texlive\tlmgr.pl" %*

rem Exit here if there are no updates to do
if not exist "%tlupdater%" exit /b %errorlevel%
rem Rename updater script before it is run
ren "%tlupdater%" "%tlupdatername%.bat"
if errorlevel 1 goto :err_rename_updater
rem Run updater explicitly with cmd.exe, in case we are launched from 4NT
rem Use delayed expansion for errorlevel, 4NT doesn't like: call exit /b %%errorlevel%%
echo Starting update ...
endlocal & call "%tlupdater%.bat" & exit /b !errorlevel!

:err_updater_exists
echo %~n0: cannot remove update script, infrastructure update might be in progress>&2
exit /b 1

:err_rename_updater
echo %~n0: cannot rename "%tlupdater%">&2
exit /b 1

:err_OS
echo Unsupported operating system. Windows 2000 or later required.
pause