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.

375 lines
12 KiB

  1. @REM normal cmd header stuff ...
  2. @echo off
  3. if defined _echo echo on
  4. if defined verbose echo on
  5. setlocal EnableDelayedExpansion EnableExtensions
  6. set SCRIPT_NAME=%~nx0
  7. set Language=%1
  8. set BuildName=%2
  9. for /f "tokens=1 delims=." %%a in ('echo %BuildName%') do set /a BuildNumber=%%a
  10. if not exist %TMP% md %TMP%
  11. set LOGFILE=%TMP%\%SCRIPT_NAME%.log
  12. if exist %LOGFILE% del %LOGFILE%
  13. REM if binaries directory still exists then release did not run properly
  14. if exist %_NTPOSTBLD% (
  15. REM give an error only if %_NTPOSTBLD% is the same build
  16. findstr /ilc:%BuildName% "%_NTPOSTBLD%\build_logs\buildname.txt"
  17. if not errorlevel 1 (
  18. call errmsg.cmd "Binaries tree %_NTPOSTBLD% still exists, not copying symbols!"
  19. goto :ErrEnd
  20. )
  21. )
  22. REM if running on idx branch then paths below will change
  23. set OfficialIDXBranch1=idx01
  24. set OfficialIDXBranch2=idx02
  25. call logmsg.cmd "Beginning ..."
  26. time /t
  27. REM figure out symbol farm we are copying symbols to
  28. REM Read it out of this lab's ini file
  29. set SymbolsMachineShare=
  30. set CmdIni=perl %RazzleToolPath%\PostBuildScripts\CmdIniSetting.pl
  31. set ThisCommandLine=%CmdIni% -l:%Language% -f:SymFarm
  32. %ThisCommandLine% >nul 2>nul
  33. if %ERRORLEVEL% NEQ 0 (
  34. call errmsg.cmd "SymFarm is not defined in the ini file, not copying symbols"
  35. goto :ErrEnd
  36. ) else (
  37. for /f %%a in ('%ThisCommandLine%') do (
  38. set SymbolsMachineShare=%%a
  39. )
  40. call logmsg "Symbol farm location is !SymbolsMachineShare!"
  41. )
  42. if not defined SymbolsMachineShare (
  43. call errmsg.cmd "SymFarm is not defined in the ini file, not copying symbols"
  44. goto :ErrEnd
  45. )
  46. set SymbolsMachineShareWritable=%SymbolsMachineShare%$
  47. REM set paths to where symbols, etc are copied (pushed)
  48. set PushPriShare=%SymbolsMachineShareWritable%\%Language%\%BuildName%\symbols.pri
  49. set PushPubShare=%SymbolsMachineShareWritable%\%Language%\%BuildName%\symbols
  50. set PushBinShare=%SymbolsMachineShareWritable%\%Language%\%BuildName%
  51. set PushSymsrvShare=%SymbolsMachineShareWritable%\%Language%\%BuildName%\symsrv\%Language%\add_finished
  52. set PushTraceFormatShare=%SymbolsMachineShareWritable%\%Language%\%BuildName%\symbols.pri\TraceFormat
  53. if not exist %PushPriShare% md %PushPriShare%
  54. if not exist %PushPubShare% md %PushPubShare%
  55. if not exist %PushBinShare% md %PushBinShare%
  56. if not exist %PushSymsrvShare% md %PushSymsrvShare%
  57. if not exist %PushTraceFormatShare% md %PushTraceFormatShare%
  58. REM set paths from which symbols, etc. are copied from (pulled)
  59. REM IDX branch release directory is named differently
  60. set ReleaseDir=release
  61. set ThisRelDir=
  62. set IniCmd=perl %RazzleToolPath%\PostBuildScripts\CmdIniSetting.pl
  63. set IniCmd=!IniCmd! -l:%Language%
  64. set IniCmd=!IniCmd! -b:%_BuildBranch%
  65. set IniCmd=!IniCmd! -f:AlternateReleaseDir
  66. for /f %%a in ('!IniCmd!') do (
  67. set ThisRelDir=%%a
  68. )
  69. if defined ThisRelDir set ReleaseDir=%ThisRelDir%
  70. REM get the local path so we can do file ops on them
  71. set ReleaseLocalPath=
  72. for /f "tokens=1,2" %%a in ('net share %ReleaseDir%') do (
  73. if /i "%%a" == "path" set ReleaseLocalPath=%%b
  74. )
  75. if not defined ReleaseLocalPath (
  76. call errmsg.cmd "Can't find local path for %ReleaseDir%"
  77. goto :ErrEnd
  78. )
  79. set PullRelPath=%ReleaseLocalPath%
  80. if /i "%Language%" neq "usa" set PullRelPath=!PullRelPath!\%Language%
  81. set PullRelPath=%PullRelPath%\%BuildName%
  82. set PullPriShare=%PullRelPath%\symbols.pri
  83. set PullPubShare=%PullRelPath%\symbols
  84. set PullBinShare=%PullRelPath%
  85. set altLang=
  86. set altLang=%Language%
  87. if /i "%Language%" EQU "cov" set altLang=usa
  88. set PullSymsrvShare=%PullRelPath%\symsrv\%altLang%\add_finished
  89. set PullTraceFormatShare=%PullRelPath%\symbols.pri\TraceFormat
  90. REM We need only copy the files required by the symfarm, as defined in the
  91. REM .pri .pub and .bin files:
  92. REM we need to find the latest
  93. REM :FindLatestSymFile sets the env var %NewestFile% to the greatest numbered file
  94. set SymFiles=%PullSymsrvShare%\%BuildName%.*.pri
  95. call :FindLatestSymFile %SymFiles%
  96. set SymPriFile=%NewestFile%
  97. set SymPriFilePath=%PullSymsrvShare%\%NewestFile%
  98. set SymFiles=%PullSymsrvShare%\%BuildName%.*.pub
  99. call :FindLatestSymFile %SymFiles%
  100. set SymPubFile=%NewestFile%
  101. set SymPubFilePath=%PullSymsrvShare%\%NewestFile%
  102. set SymFiles=%PullSymsrvShare%\%BuildName%.*.bin
  103. call :FindLatestSymFile %SymFiles%
  104. set SymBinFile=%NewestFile%
  105. set SymBinFilePath=%PullSymsrvShare%\%NewestFile%
  106. time /t
  107. call logmsg.cmd /t "Beginning %SymPriFile% split"
  108. REM delete old split files
  109. for /l %%a in (1,1,%NUMBER_OF_PROCESSORS%) do (
  110. if exist %SymPriFilePath%.%%a del %SymPriFilePath%.%%a
  111. )
  112. if not defined SymPriFile (
  113. call logmsg "No pri symbol file -- OK"
  114. goto EndSymPriFile
  115. )
  116. REM split up list of private symbols to copy
  117. perl %RazzleToolPath%\PostBuildScripts\SplitList.pl -n %NUMBER_OF_PROCESSORS% -f %SymPriFilePath% -l %Language%
  118. set EventNames=
  119. for /l %%a in (1,1,%NUMBER_OF_PROCESSORS%) do (
  120. if exist %SymPriFilePath%.%%a (
  121. start "copy symbols.pri #%%a" /min /high cmd /c %RazzleToolPath%\PostBuildScripts\symcopythread.cmd %PullPriShare% %PushPriShare% %SymPriFilePath%.%%a %SymPriFile%.%%a
  122. set EventNames=!EventNames! %SymPriFile%.%%a
  123. ) else (
  124. call errmsg.cmd "SplitList.pl did not create %SymPriFilePath%.%%a as expected!"
  125. )
  126. )
  127. call logmsg.cmd /t "WAITING ON COPYING PRIVATE SYMBOLS"
  128. perl %RazzleToolPath%\PostBuildScripts\cmdevt.pl -wv !EventNames!
  129. REM
  130. REM Publish whole private symbols for testing coverage builds
  131. REM
  132. start /min cmd /c xcopy /seqcdhkr "%PullPriShare%" "%PushPriShare%"
  133. call logmsg.cmd /t "FINISHED COPYING PRIVATE SYMBOLS"
  134. :EndSymPriFile
  135. call logmsg.cmd /t "Beginning %SymPubFile% split"
  136. REM delete old split files
  137. for /l %%a in (1,1,%NUMBER_OF_PROCESSORS%) do (
  138. if exist %SymPubFilePath%.%%a del %SymPubFilePath%.%%a
  139. )
  140. if not defined SymPubFile (
  141. call logmsg "No pub symbol file -- OK"
  142. goto EndSymPubFile
  143. )
  144. REM split up list of public symbols to copy
  145. perl %RazzleToolPath%\PostBuildScripts\SplitList.pl -n %NUMBER_OF_PROCESSORS% -f %SymPubFilePath% -l %Language%
  146. set EventNames=
  147. for /l %%a in (1,1,%NUMBER_OF_PROCESSORS%) do (
  148. if exist %SymPubFilePath%.%%a (
  149. start "copy symbols.pub #%%a" /min /high cmd /c %RazzleToolPath%\PostBuildScripts\symcopythread.cmd %PullPubShare% %PushPubShare% %SymPubFilePath%.%%a %SymPubFile%.%%a
  150. set EventNames=!EventNames! %SymPubFile%.%%a
  151. ) else (
  152. call errmsg.cmd "SplitList.pl did not create %SymPubFilePath%.%%a as expected!"
  153. )
  154. )
  155. call logmsg.cmd /t "WAITING ON COPYING PUBLIC SYMBOLS"
  156. perl %RazzleToolPath%\PostBuildScripts\cmdevt.pl -wv !EventNames!
  157. call logmsg.cmd /t "FINISHED COPYING PUBLIC SYMBOLS"
  158. :EndSymPubFile
  159. call logmsg.cmd /t "Beginning %SymBinFile% split"
  160. REM delete old split files
  161. for /l %%a in (1,1,%NUMBER_OF_PROCESSORS%) do (
  162. if exist %SymBinFilePath%.%%a del %SymBinFilePath%.%%a
  163. )
  164. if not defined SymBinFile (
  165. call logmsg "No bin symbol file -- OK"
  166. goto EndSymBinFile
  167. )
  168. REM split up list of binaries to copy
  169. perl %RazzleToolPath%\PostBuildScripts\SplitList.pl -n %NUMBER_OF_PROCESSORS% -f %SymBinFilePath% -l %Language%
  170. set EventNames=
  171. for /l %%a in (1,1,%NUMBER_OF_PROCESSORS%) do (
  172. if exist %SymBinFilePath%.%%a (
  173. start "copy symbols.bin #%%a" /min /high cmd /c %RazzleToolPath%\PostBuildScripts\symcopythread.cmd %PullBinShare% %PushBinShare% %SymBinFilePath%.%%a %SymBinFile%.%%a
  174. set EventNames=!EventNames! %SymBinFile%.%%a
  175. ) else (
  176. call errmsg.cmd "SplitList.pl did not create %SymBinFilePath%.%%a as expected!"
  177. )
  178. )
  179. call logmsg.cmd /t "WAITING ON COPYING BINARIES"
  180. perl %RazzleToolPath%\PostBuildScripts\cmdevt.pl -wv !EventNames!
  181. call logmsg.cmd /t "FINISHED COPYING BINARIES"
  182. :EndSymBinFile
  183. if defined SymPriFile (
  184. call logmsg.cmd "copying %SymPriFilePath% ..."
  185. xcopy /dhkr %SymPriFilePath% %PushPriShare%
  186. if "!ErrorLevel!" neq "0" (
  187. call errmsg.cmd "copy failed: xcopy /dhkr %SymPriFilePath% %PushPriShare%"
  188. )
  189. )
  190. if defined SymPubFile (
  191. call logmsg.cmd "copying %SymPubFilePath% ..."
  192. xcopy /dhkr %SymPubFilePath% %PushPubShare%
  193. if "!ErrorLevel!" neq "0" (
  194. call errmsg.cmd "copy failed: xcopy /dhkr %SymPubFilePath% %PushPubShare%"
  195. )
  196. )
  197. if defined SymBinFile (
  198. call logmsg.cmd "copying %SymBinFilePath% ..."
  199. xcopy /dhkr %SymBinFilePath% %PushBinShare%
  200. if "!ErrorLevel!" neq "0" (
  201. call errmsg.cmd "copy failed: xcopy /dhkr %SymBinFilePath% %PushBinShare%"
  202. )
  203. )
  204. call logmsg.cmd "copying %PullSymsrvShare% ..."
  205. xcopy /dehikr %PullSymsrvShare% %PushSymsrvShare% >nul 2>nul
  206. if "!ErrorLevel!" neq "0" (
  207. call errmsg.cmd "copy failed: xcopy /dehikr %PullSymsrvShare% %PushSymsrvShare%"
  208. )
  209. REM International might not have TraceFormat folder
  210. if exist "%PullTraceFormatShare%" (
  211. call logmsg.cmd "copying %PullTraceFormatShare% ..."
  212. xcopy /dehikr %PullTraceFormatShare% %PushTraceFormatShare% >nul 2>nul
  213. if "!ErrorLevel!" neq "0" (
  214. call errmsg.cmd "copy failed: xcopy /dehikr %PullTraceFormatShare% %PushTraceFormatShare%"
  215. )
  216. )
  217. REM Copy sfcfiles out there
  218. if exist %PullPriShare%\retail\dll\sfcfiles*.pdb (
  219. call logmsg.cmd "copying %PullPriShare%\retail\dll\sfcfiles*.pdb ... "
  220. if not exist %PushPriShare%\retail\dll mkdir %PushPriShare%\retail\dll
  221. xcopy /dehikr %PullPriShare%\retail\dll\sfcfiles*.pdb %PushPriShare%\retail\dll
  222. if "!ErrorLevel!" neq "0" (
  223. call errmsg.cmd "copy failed:xcopy /dehikr %PullPriShare%\retail\dll\sfcfiles*.pdb %PushPriShare%\retail\dll\sfcfiles*.pdb"
  224. )
  225. )
  226. findstr /il error: %LOGFILE%
  227. if "!ErrorLevel!" equ "0" (
  228. findstr /il error: %LOGFILE% > %LOGFILE%.err
  229. call logmsg.cmd /t "Errors in Symbol Copy, see %LOGFILE%.err"
  230. goto :ErrEnd
  231. )
  232. goto :End
  233. REM :FindLatestSymFile sets the env var %NewestFile% to the greatest numbered file
  234. :FindLatestSymFile
  235. set FileSpec=%1
  236. set NewestFile=
  237. set SysCommand=dir /a-d /b %FileSpec%
  238. %SysCommand% >nul 2>nul
  239. if "!ErrorLevel!" neq "0" (
  240. REM no files with this spec found, return nothing
  241. set NewestFile=
  242. goto :EOF
  243. )
  244. set LargestNumber=0
  245. set ThisFileName=
  246. for /f "tokens=1,2,3,4,5,6,7 delims=." %%a in ('%SysCommand%') do (
  247. if "%%e" gtr "!LargestNumber!" (
  248. set LargestNumber=%%e
  249. set ThisFileName=%%a.%%b.%%c.%%d.%%e.%%f.%%g
  250. )
  251. )
  252. set NewestFile=!ThisFileName!
  253. goto :EOF
  254. :End
  255. call logmsg.cmd "FINISHED with all Symbol copies, no errors!!!"
  256. endlocal
  257. goto :EOF
  258. :ErrEnd
  259. REM Send mail about symcopy error
  260. set Sender=%COMPUTERNAME%
  261. set Title=Symbol copy error on %COMPUTERNAME% build %BUILDNAME%
  262. set Message=A symbol copy error was detected on machine %COMPUTERNAME%. See %LOGFILE%.err
  263. REM Read the Symbol Copy Error Message Receiver from the .ini file
  264. set Receiver=
  265. set CmdIni=perl %RazzleToolPath%\PostBuildScripts\CmdIniSetting.pl
  266. set ThisCommandLine=%CmdIni% -l:%Language% -f:SymCopyErrReceiver
  267. %ThisCommandLine% >nul 2>nul
  268. if %ERRORLEVEL% NEQ 0 (
  269. call errmsg.cmd "SymCopyErrReceiver is not defined in the .ini file, can't send error message email"
  270. goto :SkipSendMsg
  271. ) else (
  272. for /f %%a in ('%ThisCommandLine%') do (
  273. set Receiver=%%a
  274. )
  275. call logmsg "Symbol Copy Error Message Receiver is !Receiver!"
  276. )
  277. if not defined Receiver (
  278. call errmsg.cmd "SymCopyErrReceiver is not defined in the .ini file, can't send error message email"
  279. goto :SkipSendMsg
  280. )
  281. perl -e "require '%RazzleToolPath%\sendmsg.pl';sendmsg('-v','%Sender%','%Title%','%Message%','%Receiver%');"
  282. :SkipSendMsg
  283. REM type logfile so it is seen in the window
  284. type %LOGFILE%.err
  285. endlocal
  286. seterror.exe 1