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.

243 lines
7.6 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM release.cmd - SuemiaoR
  4. @REM Move the build to the shared release directory locally.
  5. @REM
  6. @REM Copyright (c) Microsoft Corporation. All rights reserved.
  7. @REM Version: < 1.0 > 02/02/2001 Suemiao Rossignol
  8. @REM -----------------------------------------------------------------
  9. @perl -x "%~f0" %*
  10. @goto :EOF
  11. #!perl
  12. use strict;
  13. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  14. use lib $ENV{RAZZLETOOLPATH};
  15. use PbuildEnv;
  16. use Logmsg;
  17. use ParseArgs;
  18. use File::Basename;
  19. use BuildName;
  20. use GetIniSetting;
  21. use comlib;
  22. my $scriptname = basename( $0 );
  23. sub Usage {
  24. print<<USAGE;
  25. A wrapper starting release processes which are srvrel, miscrel and startsymcopy.
  26. Usage:
  27. $scriptname: -l:<language> [-b:<BuildName>] [-p]
  28. -l Language.
  29. Default is "usa".
  30. -b Build Name.
  31. Default is defined in
  32. <ReleaseShare>\\<buildName>\\build_logs\\buildname.txt for language usa.
  33. <ReleaseShare>\\<lang>\\<buildName>\\build_logs\\buildname.txt for language none usa.
  34. -o Executing options of release processes.
  35. Use ',' to separate options.
  36. Default to all options when undefined.
  37. -? Display Usage.
  38. Example:
  39. $scriptname -l:ger -b:2415.x86fre.main.001222-1745 -p
  40. $scriptname -o:srvrel,miscrel
  41. USAGE
  42. exit(1)
  43. }
  44. my ( $lang, $buildName, $execOpt, $powerLess );
  45. my ( $buildBranch, $buildArch, $buildType, $iniFile );
  46. my ( $computerName, $releaseShareRootDir, $releaseResDir, @releaseServers );
  47. my ( $localReleaseDrive, $iniConglomerator, $iniSymfarm );
  48. my @defaultOpts = ( "srvrel", "miscrel", "startsymcopy" );
  49. my %releaseOpts;
  50. &GetParams();
  51. if( !&InitVars() ) { exit(1); }
  52. system("$ENV{RAZZLETOOLPATH}\\setbuildstatus.cmd -s:release");
  53. if( !&StartPostBootRelease ){ exit(1); }
  54. exit(0);
  55. #-----------------------------------------------------------------------------
  56. sub GetParams
  57. {
  58. parseargs('?' => \&Usage, 'b:' => \$buildName, 'o:' => \$execOpt );
  59. $lang = $ENV{lang};
  60. $computerName = $ENV{computername};
  61. my @tmpOpts = split( /\,/, $execOpt );
  62. @tmpOpts = @defaultOpts if( !@tmpOpts );
  63. for my $theOpt( @tmpOpts )
  64. {
  65. $releaseOpts{$theOpt} = 1;
  66. }
  67. }
  68. #-----------------------------------------------------------------------------
  69. sub InitVars
  70. {
  71. my ( @iniRequest );
  72. #####Set build name, buildbranch, buildArch, buildType and ini file
  73. if( !$buildName )
  74. {
  75. if( -e $ENV{_NtPostbld} )
  76. {
  77. errmsg( "Found $ENV{_NtPostbld} exists." );
  78. return 0;
  79. }
  80. my ($cmdLine ) = "$ENV{RazzleToolPath}\\postbuildscripts\\getlatestrelease.cmd -l:$lang";
  81. return 0 if( !chomp($buildName= `$cmdLine`) );
  82. }
  83. $buildBranch = build_branch($buildName);
  84. $buildArch = build_arch($buildName);
  85. $buildType = build_type($buildName);
  86. if( !$buildBranch || !$buildArch || !$buildType )
  87. {
  88. errmsg( "Unable to parse [$buildName]");
  89. return 0;
  90. }
  91. $iniFile = "$buildBranch.$lang.ini";
  92. #####Set release Share Drive
  93. @iniRequest = ("LocalReleaseDrive::$ENV{computerName}");
  94. $localReleaseDrive = &GetIniSetting::GetSettingEx( $buildBranch,$lang,@iniRequest );
  95. if ( !$localReleaseDrive )
  96. {
  97. $ENV{_ntdrive} =~ /(.*)\:/;
  98. $localReleaseDrive = $1;
  99. }
  100. #####Set <ReleaseShareName> & <ReleaseShareRootDir> & <ReleaseDir>
  101. my ( $releaseShareName ) = &comlib::GetReleaseShareName( $ENV{_BuildBranch}, $lang );
  102. $releaseShareRootDir = "$localReleaseDrive:\\$releaseShareName";
  103. if( lc($lang) eq "usa" )
  104. {
  105. $releaseResDir = "$releaseShareRootDir\\$buildName";
  106. }
  107. else
  108. {
  109. $releaseResDir = "$releaseShareRootDir\\$lang\\$buildName";
  110. }
  111. if( !( -e $releaseResDir ) )
  112. {
  113. errmsg( "[$releaseResDir] not exists, exit." );
  114. return 0;
  115. }
  116. #####Set release servers
  117. @iniRequest = ( "ReleaseServers::$buildArch$buildType" );
  118. my( $iniRelServers ) = &GetIniSetting::GetSetting( @iniRequest );
  119. @releaseServers = split( /\s+/, $iniRelServers );
  120. #####Set Symbol Servers
  121. $iniSymfarm = &GetIniSetting::GetSettingEx( $buildBranch,$lang,"SymFarm" );
  122. #####Set Conglomerate Servers
  123. $iniConglomerator = &GetIniSetting::GetSettingEx( $buildBranch,$lang,"ConglomerationServers" );
  124. logmsg( "Lauguage ..............[$lang]" );
  125. logmsg( "Executing Options......[$execOpt]" );
  126. logmsg( "This computer..........[$computerName]" );
  127. logmsg( "Build name ............[$buildName]" );
  128. logmsg( "Ini file ..............[$iniFile]" );
  129. logmsg( "Release share name ....[$releaseShareName]" );
  130. logmsg( "Release share resource [$releaseResDir]" );
  131. logmsg( "Release Servers .......[@releaseServers]");
  132. logmsg( "Conglomerate Servers...[$iniConglomerator]");
  133. logmsg( "Symbol Servers.........[$iniSymfarm]");
  134. logmsg( "Temp Log file .........[$ENV{LOGFILE}]" );
  135. logmsg( "Temp Error file .......[$ENV{ERRFILE}]" );
  136. return 1;
  137. }
  138. #-----------------------------------------------------------------------------
  139. sub StartPostBootRelease
  140. {
  141. my ( $cmdLine, $dash);
  142. $dash = '-' x 60;
  143. logmsg ( $dash );
  144. #####SrvRel
  145. if( exists $releaseOpts{ srvrel } )
  146. {
  147. &StartRemoteRelease;
  148. }
  149. logmsg ( $dash );
  150. #####MiscRel
  151. if( exists $releaseOpts{ miscrel } && $ENV{ OFFICIAL_BUILD_MACHINE } && $iniConglomerator )
  152. {
  153. $cmdLine = "$ENV{RazzleToolPath}\\PostBuildScripts\\miscrel.cmd -l:$lang -b:$buildName";
  154. &comlib::ExecuteSystem( $cmdLine );
  155. }
  156. logmsg ( $dash );
  157. ####StartsymCopy
  158. if( exists $releaseOpts{ startsymcopy } && $ENV{ OFFICIAL_BUILD_MACHINE } && $iniSymfarm )
  159. {
  160. $cmdLine = "perl $ENV{RazzleToolPath}\\PostBuildScripts\\startsymcopy.pl -l:$lang";
  161. &comlib::ExecuteSystem( $cmdLine );
  162. }
  163. logmsg ( $dash );
  164. return 1;
  165. }
  166. #-----------------------------------------------------------------------------
  167. sub StartRemoteRelease
  168. {
  169. my ( $cmdLine );
  170. #####set remote name
  171. my( @iniRequest ) = ( "AlternateReleaseRemote" );
  172. my( $remoteName ) = &GetIniSetting::GetSettingEx( $buildBranch, $lang, @iniRequest );
  173. $remoteName = "release" if( !$remoteName );
  174. #####Start remote srvrel
  175. my $status=1;
  176. for my $relServer ( @releaseServers )
  177. {
  178. #####Check the remote connection
  179. if( !&comlib::ExecuteSystem( "net view $relServer >nul 2>nul" ) )
  180. {
  181. errmsg( "Cannot see remote server [$relServer], skipping" );
  182. next;
  183. }
  184. #####Remote is not required when Build machine is a Release server also
  185. if( lc($computerName) eq lc( $relServer) )
  186. {
  187. &comlib::ExecuteSystem("$ENV{RazzleToolPath}\\PostBuildScripts\\srvrel.cmd -l:$lang -b:$buildName" );
  188. next;
  189. }
  190. #####Remote connection
  191. $cmdLine = "echo pushd ^^%RazzleToolPath^^% ^& echo del /q /a-r * ^& echo popd ^&";
  192. $cmdLine .= "echo pushd ^^%RazzleToolPath^^%\\PostBuildScripts ^& echo del /q /a-r * ^& echo popd ^&";
  193. $cmdLine .= "echo pushd ^^%RazzleToolPath^^% ^& echo sd sync ... ^& echo popd ^&";
  194. $cmdLine .= " echo start /min cmd /c SrvRel.cmd \-l:$lang \-b:$buildName";
  195. $cmdLine .= " \| \@remote.exe /c $relServer $remoteName /L 1";
  196. #####Remote.exe always return 6, ignore the return value
  197. if( !&comlib::ExecuteSystem( $cmdLine ) )
  198. {
  199. errmsg( "Failed to start remote release on [$relServer], please investigate." );
  200. $status=0;
  201. }
  202. }
  203. return $status;
  204. }
  205. #-----------------------------------------------------------------------------
  206. 1;