Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

226 lines
6.7 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM createtokens.cmd - aesquiv
  4. @REM a batch files that performs tokenization
  5. @REM
  6. @REM Copyright (c) Microsoft Corporation. All rights reserved.
  7. @REM
  8. @REM -----------------------------------------------------------------
  9. @if defined _CPCMAGIC goto CPCBegin
  10. @perl -x "%~f0" %*
  11. @goto :EOF
  12. #!perl
  13. use strict;
  14. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  15. use lib $ENV{RAZZLETOOLPATH};
  16. use PbuildEnv;
  17. use ParseArgs;
  18. sub Usage { print<<USAGE; exit(1) }
  19. createtokens.cmd -b:buildname -f:filelist -l:lang
  20. -b: BuildName
  21. build name of build to tokenized
  22. -f: Filelist
  23. list of binaries to tokenize
  24. -l: Lang
  25. lang of build
  26. Example:
  27. createtokens.cmd -b:3663.main.x86fre.020805-1420 -f:\\nt\\tools\\ploc\\whistler.bat -l:psu
  28. USAGE
  29. parseargs('?' => \&Usage,
  30. '-b:' => \$ENV{BLDNAME},
  31. '-f:' => \$ENV{FLIST});
  32. # *** TEMPLATE CODE ***
  33. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  34. __END__
  35. @:CPCBegin
  36. @set _CPCMAGIC=
  37. @setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  38. @if not defined DEBUG echo off
  39. @REM *** CMD SCRIPT BELOW ***
  40. IF NOT DEFINED LANG goto Use
  41. if /i "%LANG%" == "usa" goto Done
  42. if defined BLDName (
  43. set BuildName=%BLDNAME%
  44. ) else (
  45. call logmsg "-b flag must be define in order to perform tokenization on a build."
  46. goto Use
  47. )
  48. if defined FLIST (
  49. set FileList=%FLIST%
  50. ) else (
  51. call logmsg "-f flag must be define in order to perform tokenization on a binaries."
  52. goto Use
  53. )
  54. REM ********************************************************************************
  55. REM Get and set parameters from %_BuildBranch%.%LANG%.ini file
  56. REM ********************************************************************************
  57. set PlocPath=%SDXROOT%\tools\ploc
  58. set CmdIni=perl %RazzleToolPath%\PostBuildScripts\CmdIniSetting.pl
  59. set ThisCommandLine=%CmdIni% -l:%LANG% -f:ReleaseDir
  60. %ThisCommandLine% >nul 2>nul
  61. if %ERRORLEVEL% NEQ 0 (
  62. call errmsg.cmd "ReleaseDir is not defined in the %_BuildBranch%.%LANG%.ini file, exiting"
  63. set ReleaseDir=release
  64. goto :Done
  65. ) else (
  66. for /f %%a in ('%ThisCommandLine%') do (
  67. set ReleaseDir=%%a
  68. set ReleasePath=%_NTDRIVE%\!ReleaseDir!
  69. )
  70. )
  71. set ThisCommandLine=%CmdIni% -l:%LANG% -f:TokenShare
  72. %ThisCommandLine% >nul 2>nul
  73. if %ERRORLEVEL% NEQ 0 (
  74. call errmsg.cmd "TokenShare is not defined in the %_BuildBranch%.%LANG%.ini file, exciting"
  75. goto :Done
  76. ) else (
  77. for /f %%a in ('%ThisCommandLine%') do (
  78. set TokenShare=%%a
  79. )
  80. net share !TokenShare! >nul 2>nul
  81. if %ERRORLEVEL% NEQ 0 (
  82. call errmsg.cmd "No token share found on release server, exciting"
  83. goto :Done
  84. )
  85. set TokenPath=
  86. for /f "tokens=1,2" %%a in ('net share !TokenShare!') do (
  87. if /i "%%a" == "Path" (
  88. REM at this point, %%b is the local path to the default release directory
  89. set TokenPath=%%b
  90. )
  91. )
  92. )
  93. set ThisCommandLine=%CmdIni% -l:%LANG% -f:CodePage
  94. %ThisCommandLine% >nul 2>nul
  95. if %ERRORLEVEL% NEQ 0 (
  96. call errmsg.cmd "CodePage is not defined in the %_BuildBranch%.%LANG%.ini file, exiting"
  97. goto :Done
  98. ) else (
  99. for /f %%a in ('%ThisCommandLine%') do (
  100. set CodePage=%%a
  101. )
  102. )
  103. set ThisCommandLine=%CmdIni% -l:%LANG% -f:AlternateReleaseRemote
  104. %ThisCommandLine% >nul 2>nul
  105. if %ERRORLEVEL% NEQ 0 (
  106. call errmsg.cmd "AlternateReleaseRemote is not defined in the %_BuildBranch%.%LANG%.ini file, exiting"
  107. goto :Done
  108. ) else (
  109. for /f %%a in ('%ThisCommandLine%') do (
  110. set ReleaseRemote=%%a
  111. )
  112. )
  113. REM +-------------------------------------------------------------------------------------------------+
  114. REM Find the build at the release share
  115. set ReleaseShare=!ReleasePath!\!LANG!
  116. if not exist !ReleaseShare! (
  117. call errmsg.cmd "No !ReleaseShare! dir on !COMPUTERNAME!, exiting ..."
  118. goto :DONE
  119. )
  120. set BuildShare=!ReleaseShare!\!BuildName!
  121. if not exist !BuildShare! (
  122. call errmsg.cmd "No !BuildShare! found on !COMPUTERNAME!, exiting tokenization..."
  123. goto :DONE
  124. )
  125. set path=%PlocPath%;%path%
  126. REM Do Tokenization
  127. set TmpBinPath=%TokenPath%\%LANG%\%BuildName%
  128. set TmpResPath=%TokenPath%\%LANG%\%BuildName%\resources
  129. set TokLogFile=%TokenPath%\%LANG%\%BuildName%\resources\TokLogFile.log
  130. set LocMapPath=\\sysloc\sourcedepot\winloc\loc\res\%LANG%\windows\misc\dump
  131. if NOT EXIST !TmpBinPath! md !TmpBinPath!
  132. if NOT EXIST !TmpResPath! md !TmpResPath!
  133. REM create semaphores
  134. set sem1=%PlocPath%\run\sem1
  135. set sem2=%PlocPath%\run\sem2
  136. REM create the poor man's semaphore
  137. echo running > %sem1%
  138. echo running > %sem2%
  139. REM call tokenization scripts, wait for both to complete
  140. Start "Whistler1 tokenization" cmd /c !PlocPath!\run\scriptwrap1.bat %sem1% !PlocPath!\tokwrap.bat !TokLogFile! !_NTTREE! !PlocPath! !SDXROOT!\tools\ploc\whistler1.bat !LANG! !TmpBinPath! !BuildShare!
  141. Start "Whistler1 tokenization" cmd /c !PlocPath!\run\scriptwrap1.bat %sem2% !PlocPath!\tokwrap.bat !TokLogFile! !_NTTREE! !PlocPath! !SDXROOT!\tools\ploc\whistler2.bat !LANG! !TmpBinPath! !BuildShare!
  142. popd
  143. REM wait for first pseudoloc process to complete
  144. call logmsg /t "PSEUDOLOC SEM 1................[Running]"
  145. REM wait for first pseudoloc process to complete
  146. call logmsg /t "PSEUDOLOC SEM 2................[Running]"
  147. :psuloop1
  148. if exist %sem1% goto psuloop1
  149. call logmsg /t "PSEUDOLOC SEM 1................[Finished]"
  150. :psuloop2
  151. if exist %sem1% goto psuloop2
  152. call logmsg /t "PSEUDOLOC SEM 2................[Finished]"
  153. if /I "!LANG!" == "psu" (
  154. copy /y /v !PlocPath!\!CodePage!map.inf !TmpResPath!\map.inf
  155. ) else if /I "!LANG!" == "fe" (
  156. copy /y /v !PlocPath!\!CodePage!map.inf !TmpResPath!\map.inf
  157. ) else (
  158. copy /y /v !LocMapPath!\map.inf !TmpResPath!\map.inf
  159. )
  160. REM copy Tokens on token share to release server
  161. REM First, we need to find the release servers and then send the copy command to the remotes
  162. set ThisCommandLine=%CmdIni% -l:%LANG% -f:ReleaseServers::%_BuildArch%%_BuildType%
  163. %ThisCommandLine% >nul 2>nul
  164. if !ERRORLEVEL! NEQ 0 (
  165. call errmsg.cmd "ReleaseServers is not defined in the %_BuildBranch%.%LANG%.ini file, exiting"
  166. goto :Done
  167. ) else (
  168. for /f %%a in ('!ThisCommandLine!') do (
  169. echo pushd ^^%%RazzleToolPath^^%%\ploc\run ^& echo start /min cmd /c copytokens.cmd -b:%BuildName% -l:%LANG% -m:%ComputerName% ^& echo popd | %RazzleToolPath%\x86\remote.exe /c %%a %ReleaseRemote% /L 1>nul
  170. )
  171. )
  172. goto :Done
  173. :USE
  174. call logmsg "createtokens.cmd -b:buildname -f:filelist -l:lang"
  175. :Done