Source code of Windows XP (NT5)
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.

236 lines
6.1 KiB

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