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.

244 lines
6.5 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM submit_public.cmd - DavePr
  4. @REM submit public files on official builds
  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. submit_public
  20. Submit public files on official builds.
  21. USAGE
  22. parseargs('?' => \&Usage);
  23. # *** TEMPLATE CODE ***
  24. $ENV{"_CPCMAGIC"}++;exit(system($0)>>8);
  25. __END__
  26. @:CPCBegin
  27. @set _CPCMAGIC=
  28. @setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  29. @if not defined DEBUG echo off
  30. @REM *** CMD SCRIPT BELOW ***
  31. if NOT defined OFFICIAL_BUILD_MACHINE (
  32. call logmsg.cmd "Skipping submit_public"
  33. goto end
  34. )
  35. if /i "%__BUILDMACHINE__%" == "LB6RI" (
  36. call logmsg.cmd "Skipping submit_public"
  37. goto end
  38. )
  39. if NOT "%lang%"=="usa" (
  40. call logmsg.cmd "No submit_public for %lang%"
  41. goto end
  42. )
  43. if defined _COVERAGE_BUILD (
  44. call logmsg.cmd "Skipping submit_public for Coverage builds"
  45. goto end
  46. )
  47. @rem
  48. @rem Build up the list of files we should checkin.
  49. @rem
  50. set _Arch_Submit_Rules=%temp%\SubmitRules%RANDOM%
  51. set _Arch_Submit_Files=%temp%\SubmitFiles%RANDOM%
  52. set _Arch_Submit_Reopen=%temp%\SubmitReopen%RANDOM%
  53. set _sdresults=%TEMP%\sdresults_%RANDOM%
  54. set _Arch_Submit_ChangeNum_Name=SubmitChangeOrder%RANDOM%
  55. set _Arch_Submit_ChangeNum=%_NTDRIVE%%_NTROOT%\public\%_Arch_Submit_ChangeNum_Name%
  56. if NOT defined _BUILDARCH echo Error: Unknown Build architecture&&goto end
  57. if NOT defined _BUILDTYPE echo Error: Unknown Build type&&goto end
  58. if "%_BUILDARCH%" == "x86" set _LIBARCH=i386&& goto LibArchSet
  59. set _LIBARCH=%_BUILDARCH%
  60. :LibArchSet
  61. set ConvertMacro=
  62. @rem First eliminate comments
  63. set ConvertMacro=s/\;.*//g
  64. @rem Then build architecture rules
  65. set ConvertMacro=%ConvertMacro%;s/_BUILDARCH/%_BUILDARCH%/;s/_LIBARCH/%_LIBARCH%/
  66. @rem If this is the primary machine, whack the primary tag
  67. if "%OFFICIAL_BUILD_MACHINE%" == "PRIMARY" set ConvertMacro=%ConvertMacro%;s/PRIMARY/%_BUILDARCH%%_BUILDTYPE%/
  68. @rem and print out the results.
  69. set ConvertMacro=%ConvertMacro%;print $_;
  70. @rem run the results over the rules file to get the rules for this architecture.
  71. perl -n -e "%ConvertMacro%" < %RazzleToolPath%\PostBuildScripts\submit_rules.txt > %_Arch_Submit_rules%
  72. @rem
  73. @rem Now, based on the submit rules for this architecture, let's see what files
  74. @rem we have checked out that need to be updated.
  75. @rem
  76. pushd %_NTDRIVE%%_NTROOT%\public
  77. @rem
  78. @rem Check for old edit_public turds. Make sure they're handled first.
  79. @rem
  80. if exist publish.log_* do (
  81. for %%x in (publish.log_*) do (
  82. type %%x >> publish.log
  83. del %%x
  84. )
  85. call edit_public.cmd
  86. )
  87. if not exist %_NTDRIVE%%_NTROOT%\public\PUBLIC_CHANGENUM.SD (
  88. call errmsg.cmd "%_NTDRIVE%%_NTROOT%\public\PUBLIC_CHANGENUM.SD is missing."
  89. call errmsg.cmd "Open a new razzle window and redo your build."
  90. goto TheEnd
  91. )
  92. set sderror=FALSE
  93. for /f "tokens=2" %%i in (PUBLIC_CHANGENUM.SD) do (
  94. @for /f "tokens=2 delims=," %%j in ('findstr %_BUILDARCH%%_BUILDTYPE% %_Arch_Submit_Rules%') do (
  95. sd opened -l -c %%i %%j >> %_Arch_Submit_Files%
  96. if %errorlevel% GEQ 1 set sderror=TRUE
  97. )
  98. )
  99. if not exist %_Arch_Submit_Files% goto RevertLeftovers
  100. for /f %%x in ('findstr /c:"error:" %_Arch_Submit_Files%') do (
  101. set sderror=TRUE
  102. )
  103. if NOT "%sderror%" == "FALSE" (
  104. call errmsg.cmd "Error talking to SD depot - Try again later"
  105. goto TheEnd
  106. )
  107. @rem
  108. @rem We have a list of files that this machine s/b checking in.
  109. @rem See if it's non-zero. While we're at it, create a stripped flavor
  110. @rem of the file list that has the #ver goo removed from each line.
  111. @rem
  112. set FilesToSubmit=
  113. for /f "delims=#" %%i in (%_Arch_Submit_Files%) do (
  114. set FilesToSubmit=1
  115. echo %%i>> %_Arch_Submit_Reopen%
  116. )
  117. if not defined FilesToSubmit goto RevertLeftovers
  118. @rem
  119. @rem Fetch the build date info.
  120. @rem
  121. if not exist %_NTBINDIR%\__blddate__ goto TheEnd
  122. for /f "tokens=2 delims==" %%i in (%_NTBINDIR%\__blddate__) do (
  123. set __BuildDate=%%i
  124. )
  125. if not defined __BuildDate (
  126. call errmsg.cmd "Unable to get build date for the public changes."
  127. goto TheEnd
  128. )
  129. @rem
  130. @rem Get a new changenum for the checkin.
  131. @rem
  132. call get_change_num.cmd PUBLIC %_Arch_Submit_ChangeNum_Name% "Public Changes for %__BuildDate%/%_BUILDARCH%%_BUILDTYPE%"
  133. if not exist %_Arch_Submit_ChangeNum% (
  134. call errmsg.cmd "Unable to get a changenum for the public changes."
  135. goto TheEnd
  136. )
  137. set ReopenChangenum=
  138. for /f "tokens=2" %%i in (%_Arch_Submit_ChangeNum%) do (
  139. set ReopenChangenum=%%i
  140. )
  141. @rem
  142. @rem Reopen the public files with the new changenum
  143. @rem
  144. set sderror=FALSE
  145. sd -x %_Arch_Submit_Reopen% reopen -c %ReopenChangenum% > %_sdresults%
  146. if %errorlevel% GEQ 1 set sderror=TRUE
  147. for /f %%x in ('findstr /c:"error:" %_sdresults%') do (
  148. set sderror=TRUE
  149. )
  150. if NOT "%sderror%" == "FALSE" (
  151. call errmsg.cmd "Error talking to SD depot - Try again later"
  152. goto TheEnd
  153. )
  154. @rem
  155. @rem And submit the changes.
  156. @rem
  157. set sderror=FALSE
  158. set _RetrySubmit_=
  159. :RetrySubmit
  160. sd submit -c %ReopenChangenum% > %_sdresults%
  161. @rem If there's a resolve conflict - force it to accept this one and retry.
  162. if NOT "%_RetrySubmit_%" == "" goto CheckSdSubmitErrors
  163. for /f %%x in ('findstr /c:"resolve" %_sdresults%') do (
  164. set _RetrySubmit_=1
  165. sd resolve -ay
  166. )
  167. if NOT "%_RetrySubmit_%" == "" goto RetrySubmit
  168. :CheckSdSubmitErrors
  169. if %errorlevel% GEQ 1 set sderror=TRUE
  170. for /f %%x in ('findstr /c:"error:" %_sdresults%') do (
  171. set sderror=TRUE
  172. )
  173. if NOT "%sderror%" == "FALSE" (
  174. call errmsg.cmd "Unable to access SD depot - Submit change %ReopenChangenum% manually"
  175. goto TheEnd
  176. )
  177. @echo Files submitted for this build
  178. @echo ==============================
  179. @type %_Arch_Submit_Reopen%
  180. :TheEnd
  181. if exist %_Arch_Submit_Rules% del %_Arch_Submit_Rules%
  182. if exist %_Arch_Submit_Files% del %_Arch_Submit_Files%
  183. if exist %_Arch_Submit_Reopen% del %_Arch_Submit_Reopen%
  184. if exist %_Arch_Submit_ChangeNum% del %_Arch_Submit_ChangeNum%
  185. if exist %_sdresults% del %_sdresults%
  186. popd
  187. goto end
  188. :RevertLeftovers
  189. echo Nothing to submit
  190. goto TheEnd
  191. goto end
  192. :end
  193. seterror.exe "%errors%"& goto :EOF