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.

721 lines
24 KiB

  1. @echo off
  2. if defined _echo echo on
  3. if defined verbose echo on
  4. if defined __MTSCRIPT_ENV_ID set BUILD_CONSOLE=1 else set BUILD_CONSOLE=
  5. set __MTSCRIPT_ENV_ID=
  6. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  7. REM -------------------------------------------------------------------------------------------
  8. REM Template for the postbuild scripts:
  9. REM SD Location: %sdxroot%\tools\postbuildscripts
  10. REM
  11. REM (1) Code section description:
  12. REM PreMain - Developer adaptable code. Use this model and add your script params
  13. REM Main - Developer code section. This is where your work gets done.
  14. REM PostMain - Logging support code. No changes should be made here.
  15. REM
  16. REM (2) GetParams.pm - Usage
  17. REM run perl.exe GetParams.pm /? for complete usage
  18. REM
  19. REM (3) Reserved Variables -
  20. REM lang - The specified language. Defaults to USA.
  21. REM logfile - The path and filename of the logs file.
  22. REM logfile_bak - The path and filename of the logfile.
  23. REM errfile - The path and filename of the error file.
  24. REM tmpfile - The path and filename of the temp file.
  25. REM errors - The scripts errorlevel.
  26. REM script_name - The script name.
  27. REM script_args - The arguments passed to the script.
  28. REM CMD_LINE - The script name plus arguments passed to the script.
  29. REM _NTPostBld - Abstracts the language from the files path that
  30. REM postbuild operates on.
  31. REM
  32. REM (4) Reserved Subs -
  33. REM Usage - Use this sub to discribe the scripts usage.
  34. REM ValidateParams - Use this sub to verify the parameters passed to the script.
  35. REM
  36. REM
  37. REM (8) Do not turn echo off, copy the 3 lines from the beginning of the template
  38. REM instead.
  39. REM
  40. REM (9) Use setlocal/endlocal as in this template.
  41. REM
  42. REM (10)Have your changes reviewed by a member of the US build team (ntbusa) and
  43. REM by a member of the international build team (ntbintl).
  44. REM
  45. REM -------------------------------------------------------------------------------------------
  46. REM PreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMain
  47. REM Begin PreProcessing Section - Adapt this section but do not remove support
  48. REM scripts or reorder section.
  49. REM PreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMainPreMain
  50. :PreMain
  51. REM
  52. REM Define SCRIPT_NAME. Used by the logging scripts.
  53. REM Define CMD_LINE. Used by the logging scripts.
  54. REM Define SCRIPT_ARGS. Used by the logging scripts.
  55. REM
  56. set SCRIPT_NAME=%~nx0
  57. set CMD_LINE=%script_name% %*
  58. set SCRIPT_ARGS=%*
  59. REM
  60. REM Parse the command line arguments - Add your scripts command line arguments
  61. REM as indicated by brackets.
  62. REM For complete usage run: perl.exe GetParams.pm /?
  63. REM
  64. REM special case command line parser here
  65. set Lang=usa
  66. set Full=
  67. set Safe=
  68. set Reuse=
  69. set PrivateDatFile=
  70. set optreldatafile=
  71. :SwitchLoop
  72. for %%a in (./ .- .) do if ".%1." == "%%a?." goto :Usage
  73. if "%1" == "" goto :EndSwitchLoop
  74. for /f "tokens=1* delims=:" %%a in ('echo %1') do (
  75. set Switch=%%a
  76. set Arg=%%b
  77. for %%c in (./ .-) do (
  78. if ".!Switch!." == "%%cl." (set Lang=!Arg!&&goto :ShiftArg)
  79. if ".!Switch!." == "%%csku." (set _BuildSku=!Arg!&& goto :ShiftArg)
  80. if ".!Switch!." == "%%creldat." (set optreldatafile=!Arg!&& goto :ShiftArg)
  81. if ".!Switch!." == "%%cfull." (set Full=TRUE&&goto :ShiftArg)
  82. if ".!Switch!." == "%%csafe." (set Safe=TRUE&&goto :ShiftArg)
  83. if ".!Switch!." == "%%cr." (set Reuse=TRUE&&goto :ShiftArg)
  84. if ".!Switch!." == "%%cd." (set PrivateDatFile=!Arg!&&goto :ShiftArg)
  85. )
  86. REM if we're here, we didn't encounter any switches and thus we have
  87. REM an unrecognized argument
  88. goto :Usage
  89. )
  90. :ShiftArg
  91. shift
  92. goto :SwitchLoop
  93. :EndSwitchLoop
  94. REM not using the template so we can still use postbuild -full
  95. REM for %%h in (./ .- .) do if ".%SCRIPT_ARGS%." == "%%h?." goto Usage
  96. REM REM call :GetParams -n <add required prams> -o l:<add optional params> -p "lang <add variable names>" %SCRIPT_ARGS%
  97. REM call :GetParams -o fsl: -p "full safe lang" %SCRIPT_ARGS%
  98. REM if errorlevel 1 goto :End
  99. REM
  100. REM Special postbuild cleanup step
  101. REM
  102. REM NOTE: %TEMP% and %TMP% might be pointing at different physical locations
  103. REM if the user has configured things that way either by design or accident
  104. REM more likely the latter). At worst we'll flush twice, at best we prevent
  105. REM weird random breaks.
  106. if defined lang (
  107. rd /s/q %tmp%\%lang% 2>Nul
  108. if exist "%tmp%\%lang%\." (
  109. call logmsg "%tmp%\%lang% delete failed"
  110. )
  111. md %tmp%\%lang%
  112. rd /s/q %temp%\%lang% 2>Nul
  113. if exist "%temp%\%lang%\." (
  114. call logmsg "%temp%\%lang% delete failed"
  115. )
  116. md %temp%\%lang%
  117. ) else (
  118. rd /s/q %tmp%\usa 2>Nul
  119. if exist "%tmp%\%lang%\." (
  120. call logmsg "%tmp%\usa delete failed"
  121. )
  122. md %tmp%\usa
  123. rd /s/q %temp%\usa 2>Nul
  124. if exist "%temp%\%lang%\." (
  125. call logmsg "%temp%\usa delete failed"
  126. )
  127. md %temp%\usa
  128. )
  129. if defined _COVERAGE_BUILD (
  130. rd /s/q %tmp%\cov 2>Nul
  131. if exist "%tmp%\cov\." (
  132. call logmsg "%tmp%\cov delete failed"
  133. )
  134. md %tmp%\cov
  135. rd /s/q %temp%\cov 2>Nul
  136. if exist "%temp%\cov\." (
  137. call logmsg "%temp%\cov delete failed"
  138. )
  139. md %temp%\cov
  140. )
  141. REM
  142. REM Set up the local enviroment extensions.
  143. REM
  144. call :LocalEnvEx -i
  145. if errorlevel 1 goto :End
  146. REM
  147. REM Validate the command line parameters.
  148. REM
  149. call :ValidateParams
  150. if errorlevel 1 goto :End
  151. REM
  152. REM Execute Main
  153. REM
  154. call :Main
  155. :End_PreMain
  156. goto PostMain
  157. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  158. REM Begin Main code section
  159. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  160. REM (5) Call other executables or command scripts by using:
  161. REM call ExecuteCmd.cmd "<command>"
  162. REM Check for errors by using:
  163. REM if errorlevel 1 ...
  164. REM Note that the executable/script you're calling with ExecuteCmd must return a
  165. REM non-zero value on errors to make the error checking mechanism work.
  166. REM
  167. REM Example
  168. REM call ExecuteCmd.cmd "xcopy /f foo1 foo2"
  169. REM if errorlevel 1 (
  170. REM set errors=%errorlevel%
  171. REM goto end
  172. REM )
  173. REM
  174. REM (6) Log non-error information by using:
  175. REM call logmsg.cmd "<log message>"
  176. REM and log error information by using:
  177. REM call errmsg.cmd "<error message>"
  178. REM
  179. REM (7) Exit from the option routines with
  180. REM set errors=%errorlevel%
  181. REM goto end
  182. REM if errors found during execution and with
  183. REM goto end
  184. REM otherwise.
  185. :Main
  186. REM Main code section
  187. REM <Start your script's code here>
  188. REM before anything else, yell to octopus
  189. if /i "%COMPUTERNAME%" == "X86FRE00" (
  190. echo start ^^%%RazzleToolPath^^%%\PostBuildScripts\octowrap.cmd | remote /c mlekas-x octopus /L 1
  191. )
  192. REM delete the FoundLatest file so copywow64 and copyremoteboot work correctly
  193. set FoundLatestFile=%_NTPOSTBLD%\build_logs\FoundLatest.txt
  194. if exist %FoundLatestFile% del /f /q %FoundLatestFile%
  195. REM globally defined the interleave log as a special case for postbuild
  196. for %%a in (%LOGFILE%) do set INTBASELOGNAME=%%~na
  197. if exist %LOGFILE% del /f %LOGFILE% >nul 2>nul
  198. set INTLOGNAME=!INTBASELOGNAME!.int.log
  199. set INTERRNAME=!INTBASELOGNAME!.int.err
  200. set INTERLEAVE_LOG=%TEMP%\!INTLOGNAME!
  201. set INTERLEAVE_ERRLOG=%TEMP%\!INTERRNAME!
  202. if exist %INTERLEAVE_LOG% del /f %INTERLEAVE_LOG% >nul 2>nul
  203. if exist %INTERLEAVE_ERRLOG% del /f %INTERLEAVE_ERRLOG% >nul 2>nul
  204. REM data driven postbuild, uses pbuild.dat
  205. REM set test vars here
  206. set Waiter=perl %RazzleToolPath%\PostBuildScripts\cmdevt.pl
  207. set PbsPath=%RazzleToolPath%\PostBuildScripts
  208. set /a ExitCode=0
  209. set FullPass=
  210. set SafePass=
  211. REM Set local command line parameters
  212. if defined full (set FullPass=TRUE)
  213. if defined safe (set SafePass=TRUE)
  214. REM first things first, put in a flag marker saying that postbuild is
  215. REM currently running ...
  216. set MarkerFile=%SDXROOT%\postbuild.run.%_BuildArch%%_BuildType%
  217. if exist %MarkerFile% (
  218. REM we may want to add this code at some point ...
  219. REM call logmsg.cmd "There was a marker file already at %MarkerFile%"
  220. REM call logmsg.cmd "Please ensure no other postbuild instances are running"
  221. REM call logmsg.cmd "then re-run postbuild."
  222. REM goto :End
  223. del /f %MarkerFile%
  224. )
  225. echotime /t> %MarkerFile%
  226. REM set build status to say we're in postbuild
  227. call setbuildstatus.cmd -s:postbuild -l:%lang%
  228. if /i "%lang%" NEQ "usa" (
  229. if /i "%lang%" NEQ "psu" (
  230. if /i "%lang%" NEQ "FE" (
  231. if /i "%lang%" NEQ "mir" (
  232. if /i "!FullPass!" == "TRUE" (
  233. if /i "%REUSE%" NEQ "TRUE" (
  234. if exist %_NTPOSTBLD% (
  235. call ExecuteCmd "ren %_NTPOSTBLD% %lang%_TEMP"
  236. if not errorlevel 1 (
  237. call logmsg.cmd "Raise another window to remove the old _NTPOSTBLD %_NTPOSTBLD%_TEMP tree"
  238. start "CLEAN - %_NTPOSTBLD%" /min cmd /c "rd %_NTPOSTBLD%_TEMP /s /q"
  239. )
  240. )
  241. )
  242. )
  243. )
  244. )
  245. )
  246. )
  247. set REUSE=
  248. REM handle the full switch, meaning they want to do everything over in
  249. REM postbuild
  250. REM delete the full pass flag if necessary
  251. set FullPassFlag=%_NTPOSTBLD%\build_logs\FullPass.txt
  252. if exist %FullPassFlag% del %FullPassFlag%
  253. if /i "!FullPass!" == "TRUE" (
  254. set DelFileList=%_NTPOSTBLD%\build_logs\bindiff.txt
  255. set DelFileList=!DelFileList! %_NTPOSTBLD%\build_logs\BinSnapShot.txt
  256. set DelFileList=!DelFileList! %_NTPOSTBLD%\build_logs\postbuild.*
  257. set DelFileList=!DelFileList! %_NTPostBLD%\build_logs\buildname.txt
  258. set DelFileList=!DelFileList! %_NTPostBld%\iis51.cab
  259. set DelFileList=!DelFileList! %_NTPostBld%\iis6.cab
  260. set DelFileList=!DelFileList! %_NTPostBld%\nt5.ca*
  261. set DelFileList=!DelFileList! %_NTPostBld%\nt5inf.ca*
  262. set DelFileList=!DelFileList! %_NTPostBld%\perinf\nt5inf.ca*
  263. set DelFileList=!DelFileList! %_NTPostBld%\blainf\nt5inf.ca*
  264. set DelFileList=!DelFileList! %_NTPostBld%\sbsinf\nt5inf.ca*
  265. set DelFileList=!DelFileList! %_NTPostBld%\srvinf\nt5inf.ca*
  266. set DelFileList=!DelFileList! %_NTPostBld%\entinf\nt5inf.ca*
  267. set DelFileList=!DelFileList! %_NTPostBld%\dtcinf\nt5inf.ca*
  268. set DelFileList=!DelFileList! %_NTPostBld%\ntprint.ca*
  269. set DelFileList=!DelFileList! %_NTPostBld%\congeal_scripts\setupw95.txt
  270. set DelFileList=!DelFileList! %_NTPostBld%\congeal_scripts\sfcgen*.txt
  271. for %%a in (!DelFileList!) do if exist %%a del /f %%a
  272. set DelDirList=%_NTPostBld%\uniproc
  273. set DelDirList=!DelDirList! %_NTPostBld%\comp
  274. set DelDirList=!DelDirList! %_NTPostBld%\per
  275. set DelDirList=!DelDirList! %_NTPostBld%\pro
  276. set DelDirList=!DelDirList! %_NTPostBld%\bla
  277. set DelDirList=!DelDirList! %_NTPostBld%\sbs
  278. set DelDirList=!DelDirList! %_NTPostBld%\srv
  279. set DelDirList=!DelDirList! %_NTPostBld%\ads
  280. set DelDirList=!DelDirList! %_NTPostBld%\dtc
  281. set DelDirList=!DelDirList! %_NTPostBld%\build_logs\bindiff_backups
  282. set DelDirList=!DelDirList! %_NTPostBld%\cabs\driver
  283. set DelDirList=!DelDirList! %_NTPostBld%\congeal_scripts\drvgen
  284. for %%a in (!DelDirList!) do if exist %%a rd /s /q %%a
  285. REM put a flag saying we're a full pass
  286. if not exist %_NTPOSTBLD%\build_logs md %_NTPOSTBLD%\build_logs
  287. echo Running full postbuild>%FullPassFlag%
  288. )
  289. REM backup and clear log files at the beginning of every run
  290. for %%a in (postbuild.err postbuild.log postbuild.ord.log) do (
  291. if exist %_NTPostBld%\build_logs\%%a.old (
  292. del /f %_NTPostBld%\build_logs\%%a.old
  293. )
  294. if exist %_NTPostBld%\build_logs\%%a (
  295. ren %_NTPostBld%\build_logs\%%a %%a.old
  296. if "%errorlevel%" neq "0" (
  297. call logmsg "ren %_NTPostBld%\build_logs\%%a %%a.old failed"
  298. )
  299. if exist %_NTPostBld%\build_logs\%%a (
  300. del /f %_NTPostBld%\build_logs\%%a
  301. )
  302. )
  303. )
  304. REM clear CPLocation.txt so copy* scripts don't try to copy early
  305. if exist %_NTPostBld%\build_logs\cplocation.txt (
  306. del /f %_NTPostBld%\build_logs\cplocation.txt
  307. )
  308. REM Remove this once setupw95 works
  309. set notfirst=
  310. if exist %_NTPostBld%\build_logs\binsnapshot.txt set notfirst=1
  311. if exist %_NTPostBld%\build_logs\bindiff.txt set notfirst=1
  312. if not defined notfirst (
  313. if not exist %_NTPostBld%\congeal_scripts md %_NTPostBld%\congeal_scripts
  314. echo first pass>%_NTPostBld%\congeal_scripts\firstpass.txt
  315. ) else (
  316. if exist %_NTPostBld%\congeal_scripts\firstpass.txt del /f %_NTPostBld%\congeal_scripts\firstpass.txt
  317. )
  318. REM the following code is to ensure we don't lose changed-file history if
  319. REM somebody Ctrl-C's postbuild
  320. set BinBak=%_NTPostBld%\build_logs\bindiff_backups
  321. if exist %BinBak% (
  322. REM if this dir exists already, that means someone hit Ctrl-C in the
  323. REM last postbuild run, so let's copy over the old bindiff files
  324. for %%a in (%BinBak%\bindiff.txt %BinBak%\BinSnapShot.txt) do (
  325. if exist %%a copy %%a %_NTPostBld%\build_logs
  326. )
  327. ) else (
  328. REM if the %BinBak% dir doesn't exist, it means we're either doing a fresh
  329. REM postbuild run or a run after a complete postbuild run.
  330. if not exist %BinBak% md %BinBak%
  331. for %%a in (%_NTPostBld%\build_logs\bindiff.txt %_NTPostBld%\build_logs\BinSnapShot.txt) do (
  332. if exist %%a copy %%a %BinBak%
  333. )
  334. )
  335. REM note that there is a corresponding code section at the end of postbuild
  336. REM which deletes this directory
  337. echo. > %_NTPostBld%\disk1
  338. rem hack to make ddkcabs.bat work
  339. pushd %PbsPath%
  340. REM Decide if we want to do compression
  341. set Comp=No
  342. if /i "!PB_COMP!" == "TRUE" (
  343. set Comp=Yes
  344. ) else (
  345. if "!PB_COMP!" == "FALSE" (
  346. set Comp=No
  347. ) else (
  348. if defined OFFICIAL_BUILD_MACHINE set Comp=Yes
  349. if !NUMBER_OF_PROCESSORS! GEQ 4 set Comp=Yes
  350. )
  351. )
  352. REM At this point the binaries have not been moved to \release so it'll
  353. REM be safe to assume the directory for the build logs is %_NTPostBld%\build_logs
  354. set MyCopyDir=%_NTPostBld%\build_logs
  355. REM Save off compile time and postbuild logs exept for postbuild's own logs
  356. echo Copying build logs to: %MyCopyDir%
  357. if NOT exist %MyCopyDir% mkdir %MyCopyDir%
  358. REM timebuild also copies build.changes, but not in build labs, so do it again here
  359. if exist %_NTBINDIR%\build.changes copy /Y %_NTBINDIR%\build.changes %MyCopyDir%
  360. if exist %_NTBINDIR%\build.changedfiles copy /Y %_NTBINDIR%\build.changedfiles %MyCopyDir%
  361. if exist %_NTBINDIR%\build.scorch copy %_NTBINDIR%\build.scorch %MyCopyDir%
  362. if exist %_NTBINDIR%\build.goldfiles copy %_NTBINDIR%\build.goldfiles %MyCopyDir%
  363. if exist %_NTBINDIR%\build.log copy %_NTBINDIR%\build.log %MyCopyDir%
  364. if exist %_NTBINDIR%\build.wrn copy %_NTBINDIR%\build.wrn %MyCopyDir%
  365. REM do the actual dirty work in pbuild.cmd
  366. set PbuildOptions=
  367. if defined PrivateDatFile set PbuildOptions=-d:%PrivateDatFile%
  368. call %RazzleToolpath%\PostBuildScripts\pbuild.cmd -l %lang% %PbuildOptions%
  369. REM cough out the time-date stamp before starting release.cmd.
  370. REM this could probably be done during SubmitPublic, but i'll do it here
  371. REM
  372. REM let's also put this time into a nice SD format
  373. REM
  374. REM echotime /t>!MyCopyDir!\BuildFinishTime.txt 2>nul
  375. for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do (
  376. set ThisMonth=%%a
  377. set ThisDate=%%b
  378. set ThisYear=%%c
  379. )
  380. for /f "tokens=4" %%a in ('echotime /t') do set ThisTimeStamp=%%a
  381. set SDTimeStamp=%ThisYear%/%ThisMonth%/%ThisDate%:%ThisTimeStamp%
  382. REM
  383. REM note we have to use the funny syntax for the redirect here because
  384. REM the date time stamp ends in a number -- if that number is one or two,
  385. REM we'd accidentally redirect the wrong way and lose a digit from our string.
  386. REM
  387. echo %SDTimeStamp% 1>%MyCopyDir%\BuildFinishTime.txt 2>nul
  388. REM Take a snapshot of the postbuild logs and save them to %_NTPostBld%\build_logs
  389. if exist %INTERLEAVE_LOG% copy %INTERLEAVE_LOG% %MyCopyDir%\postbuild.log >nul
  390. if exist %LOGFILE% copy %LOGFILE% %MyCopyDir%\postbuild.ord.log >nul
  391. REM If we're building coverage builds then set lang=cov to treat coverage
  392. REM as a lang during execution of all files in pbuildrelease.dat
  393. if "%_COVERAGE_BUILD%" == "1" (
  394. if /i "%lang%" == "usa" set lang=cov
  395. )
  396. REM Now, we can run the last part of postbuild, everything after checkfatal
  397. REM If the -reldat switch is set on the commandline then for the release
  398. REM portion of postbuild, the commands in the optreldatafile will be used to
  399. REM execute the release steps. If it is not, then use pbuildrelease.dat
  400. set PbuildOptions=
  401. if defined optreldatafile (
  402. set PbuildOptions=-d:!optreldatafile!
  403. ) else (
  404. set PbuildOptions=-d:pbuildrelease.dat
  405. )
  406. call %RazzleToolpath%\PostBuildScripts\pbuild.cmd -l %lang% %PbuildOptions%
  407. REM Get directory for logs
  408. set DRIVE=%_NTPostBld:~0,2%
  409. REM determine the name of the release directory for this branch
  410. set MyReleaseDirName=
  411. set IniCmd=perl %RazzleToolPath%\PostBuildScripts\CmdIniSetting.pl
  412. set IniCmd=!IniCmd! -l:%lang%
  413. set IniCmd=!IniCmd! -b:%_BuildBranch%
  414. set IniCmd=!IniCmd! -f:AlternateReleaseDir
  415. for /f %%a in ('!IniCmd!') do (
  416. set MyReleaseDirName=%%a
  417. )
  418. if not defined MyReleaseDirName set MyReleaseDirName=release
  419. if NOT exist %_NTPostBld% (
  420. for /f %%a in ('!RazzleToolPath!\PostBuildScripts\GetLatestRelease.cmd -l:%lang%') do (
  421. if /i "%%a" == "none" (
  422. set MyCopyDir=%DRIVE%\.
  423. call errmsg.cmd "No latest release found, copying logs to !MyCopyDir!"
  424. ) else (
  425. set LatestBuild=%%a
  426. if /i "%lang%" NEQ "usa" (
  427. set MyCopyDir=%DRIVE%\%MyReleaseDirName%\%lang%\!LatestBuild!\build_logs
  428. ) else (
  429. set MyCopyDir=%DRIVE%\%MyReleaseDirName%\!LatestBuild!\build_logs
  430. )
  431. )
  432. )
  433. )
  434. REM delete the backup bindiff directory as we have fully completed our
  435. REM current postbuild run.
  436. if exist %BinBak% rd /s /q %BinBak%
  437. REM We need to delete the bindiff backups dir after release finishes.
  438. if exist %MyCopyDir%\bindiff_backups rd /s/q %MyCopyDir%\bindiff_backups
  439. if exist %MyCopyDir%\build.err (
  440. copy %MyCopyDir%\build.err %MyCopyDir%\build.err.old
  441. del %MyCopyDir%\build.err
  442. )
  443. if exist %_NTBINDIR%\build.err (
  444. copy %_NTBINDIR%\build.err %MyCopyDir%
  445. copy %_NTBINDIR%\build.err %_NTBINDIR%\build.err.old
  446. del %_NTBINDIR%\build.err
  447. )
  448. if exist %_NTBINDIR%\build.fixed-err (
  449. copy %_NTBINDIR%\build.fixed-err %MyCopyDir%
  450. copy %_NTBINDIR%\build.fixed-err %_NTBINDIR%\build.fixed-err.old
  451. del %_NTBINDIR%\build.fixed-err
  452. )
  453. if exist %TMP%\CdData.txt copy %TMP%\CdData.txt %MyCopyDir%
  454. if exist %TMP%\CdData.txt.full copy %TMP%\CdData.txt.full %MyCopyDir%
  455. popd
  456. REM remove the marker file
  457. if exist %MarkerFile% del /f %MarkerFile%
  458. goto end
  459. :ValidateParams
  460. REM
  461. REM Validate the option given as parameter.
  462. REM
  463. goto end
  464. :Usage
  465. REM Usage of the script
  466. REM If errors, goto end
  467. echo Usage: %script_name% [-f -s -r -l:^<lang^> -d:^<path^>] [-?]
  468. echo -l:lang run for given language (see %%RAZZLETOOLPATH%%\codes.txt)
  469. echo -d:path specify pbuild.* file (e.g. postbuildscripts\pbuild.mui)
  470. echo -full run in forced non-incremental mode, i.e. run everything
  471. echo from scratch
  472. echo -sku:sku Must be one of PRO, PER, SRV, BLA, SBS, ADS, DTC
  473. echo You can specify multiple SKU as -sku:BLA;ADS;DTC
  474. echo -reldat:path specify an alternate release data file. Default is pbuildrelease.dat
  475. echo make sure it is in the same format as pbuildrelease.dat
  476. echo -safe run in incremental mode with extra sanity checks, e.g.
  477. echo force rebase and bind to run
  478. echo -r run incremental aggregation.
  479. echo Applicable to international builds only.
  480. echo -? Displays usage
  481. echo.
  482. echo %script_name% is the general process to take a binaries tree and generate a
  483. echo bootable image from it. it is incremental in the sense that it will
  484. echo not run more than is needed on a second pass, and it is configurably
  485. echo multithreaded. the user has two non-command line options for setting
  486. echo preferences for compression and multithreading:
  487. echo.
  488. echo HORSE_POWER if this env var is set, the maximum number of threads
  489. echo spawned by %0 will be HORSE_POWER multiplied
  490. echo by NUMBER_OF_PROCESSORS. default is HORSE_POWER=2
  491. echo PB_COMP if this env var is set to TRUE, compressed bootable
  492. echo images will be generated regardless of the machine
  493. echo %0 is running on. if this env var is set to FALSE,
  494. echo uncompressed images will be generated. the default is
  495. echo to generate compressed images on quad-proc machines
  496. echo or higher.
  497. echo.
  498. echo note that %0 must be run from an NT razzle window with ^%_NTPostBld^%
  499. echo defined and existing.
  500. set ERRORS=1
  501. goto end
  502. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  503. REM End Main code section
  504. REM /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  505. :End_Main
  506. goto PostMain
  507. REM SupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubs
  508. REM Support Subs - Do not touch this section!
  509. REM SupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubsSupportSubs
  510. :GetParams
  511. REM
  512. REM Parse the command line arguments
  513. REM
  514. set ERRORS=0
  515. for %%h in (./ .- .) do if ".%SCRIPT_ARGS%." == "%%h?." goto Usage
  516. pushd %RazzleToolPath%\PostBuildScripts
  517. set ERRORS=0
  518. for /f "tokens=1 delims=;" %%c in ('perl.exe GetParams.pm %*') do (
  519. set commandline=%%c
  520. set commandtest=!commandline:~0,3!
  521. if /i "!commandtest!" neq "set" (
  522. if /i "!commandtest!" neq "ech" (
  523. echo %%c
  524. ) else (
  525. %%c
  526. )
  527. ) else (
  528. %%c
  529. )
  530. )
  531. if "%errorlevel%" neq "0" (
  532. set ERRORS=%errorlevel%
  533. goto end
  534. )
  535. popd
  536. goto end
  537. REM Given a set of files/directories, rename them
  538. REM to <current_name>.v#, where # is the first number
  539. REM unique to all passed in files/directories starting
  540. REM at one and counting upward
  541. :BackupRelatedItems
  542. setlocal EnableDelayedExpansion
  543. set /a count=0
  544. :GetNextItem
  545. set /a count=%count%+1
  546. set Item%Count%=%1 & shift
  547. if "" NEQ "%1" GOTO :GetNextItem
  548. set /a BackupNumber=1
  549. :TryNextNumber
  550. for /l %%a in (1,1,%count%) do (
  551. for %%b in (!Item%%a!) do if exist %%b.v!BackupNumber! (
  552. set /a BackupNumber=!BackupNumber! + 1
  553. GOTO :TryNextNumber
  554. )
  555. )
  556. for /l %%a in (1,1,%count%) do (
  557. for %%b in (!Item%%a!) do ren %%b %%~nxb.v%BackupNumber%
  558. )
  559. endlocal
  560. GOTO :EOF
  561. :LocalEnvEx
  562. REM
  563. REM Manage local script environment extensions
  564. REM
  565. pushd %RazzleToolPath%\PostBuildScripts
  566. for /f "tokens=1 delims=;" %%c in ('perl.exe LocalEnvEx.pm %1') do (
  567. set commandline=%%c
  568. set commandtest=!commandline:~0,3!
  569. if /i "!commandtest!" neq "set" (
  570. if /i "!commandtest!" neq "ech" (
  571. echo %%c
  572. ) else (
  573. %%c
  574. )
  575. ) else (
  576. %%c
  577. )
  578. )
  579. if "%errorlevel%" neq "0" (
  580. set errors=%errorlevel%
  581. goto end
  582. )
  583. popd
  584. goto end
  585. :end
  586. seterror.exe "%errors%"& goto :EOF
  587. REM PostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMain
  588. REM Begin PostProcessing - Do not touch this section!
  589. REM PostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMainPostMain
  590. :PostMain
  591. REM
  592. REM End the local environment extensions.
  593. REM
  594. call :LocalEnvEx -e
  595. REM
  596. REM Create the interleave errfile
  597. REM
  598. findstr /ilc:"error:" %INTERLEAVE_LOG% | findstr /v /il filelist.dat >>%INTERLEAVE_ERRLOG%
  599. for %%a in (%INTERLEAVE_ERRLOG%) do (
  600. if "%%~za" == "0" del %%a
  601. )
  602. REM
  603. REM Check for errors and copy logs in place
  604. REM
  605. if defined MyCopyDir if exist !MyCopyDir! (
  606. if exist %INTERLEAVE_ERRLOG% copy %INTERLEAVE_ERRLOG% %MyCopyDir%\postbuild.err >nul
  607. if exist %INTERLEAVE_LOG% copy %INTERLEAVE_LOG% %MyCopyDir%\postbuild.log >nul
  608. if exist %LOGFILE% copy %LOGFILE% %MyCopyDir%\postbuild.ord.log >nul
  609. if exist %MyCopyDir%\postbuild.err (
  610. echo.
  611. echo Postbuild failed, errors logged in: %MyCopyDir%\postbuild.err
  612. echo.
  613. set /a errors=%errors%+1
  614. ) else (
  615. echo.
  616. echo Postbuild completed successfully
  617. echo.
  618. if exist %SDXROOT%\developer\%_NTUSER%\custom_build_actions.cmd (
  619. echo ...calling %SDXROOT%\developer\%_NTUSER%\custom_build_actions.cmd
  620. echo.
  621. call %SDXROOT%\developer\%_NTUSER%\custom_build_actions.cmd
  622. )
  623. )
  624. )
  625. endlocal& seterror.exe "%errors%"