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.

212 lines
6.0 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM release.cmd
  5. REM Move the build to the release directory locally and remotely.
  6. REM
  7. REM Copyright (c) Microsoft Corporation. All rights reserved.
  8. REM Version: < 1.0 > 04/26/2002 Suemiao Rossignol
  9. REM ------------------------------------------------------------------
  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 Logmsg;
  17. use ParseArgs;
  18. use File::Basename;
  19. use comlib;
  20. use GetIniSetting;
  21. $ENV{script_name} = basename( $0 );
  22. sub Usage {
  23. print<<USAGE;
  24. A wrapper starting XPSP1 local and remote release processes.
  25. Usage:
  26. $ENV{script_name}
  27. -l: Language.
  28. Default is "usa".
  29. -n: Build Number.
  30. -d: Release Target Server.
  31. Default is defined in xpsp1.ini.
  32. -s: Release Source Server.
  33. Default is %computername%.
  34. -a: Build Architecture. x86 or ia64.
  35. Default is $ENV{_BuildArch}.
  36. -t: Build Debug Type. fre or chk.
  37. Default is $ENV{_BuildType}.
  38. -release
  39. Propagate builds only, do not perform movebuild.
  40. -p Powerless.
  41. -qfe: qfe number
  42. -? Display Usage.
  43. USAGE
  44. exit(1)
  45. }
  46. my ( $buildNo, @releaseServers, $srcServer, $relOnly, $powerLess );
  47. my ( $buildArch, $buildType );
  48. my ( $qfe );
  49. if( !&GetParams() ) { &ExitWithError(); }
  50. if( !&InitVars() ) { &ExitWithError(); }
  51. if( !&StartRelease ){ &ExitWithError(); }
  52. timemsg( "Complete $ENV{script_name} - NO ERRORS ENCOUNTERED" );
  53. exit(0);
  54. #-----------------------------------------------------------------------------
  55. sub ExitWithError
  56. {
  57. timemsg( "Complete $ENV{script_name} - ERRORS ENCOUNTERED" );
  58. exit(1);
  59. }
  60. #-----------------------------------------------------------------------------
  61. sub GetParams
  62. {
  63. parseargs('?' => \&Usage, 'l:' => \$ENV{lang}, '\n:' => \$buildNo,
  64. 's:' =>\$srcServer, 'd:' => \@releaseServers, 'p' =>\$powerLess,
  65. 'a:' =>\$buildArch, 't:' =>\$buildType, 'release' =>\$relOnly , 'qfe:' => \$qfe);
  66. $ENV{lang}="usa" if( !$ENV{lang} );
  67. $srcServer = $ENV{computername} if( !$srcServer );
  68. if( $relOnly )
  69. {
  70. if( !$buildNo && !$qfe)
  71. {
  72. errmsg( "Please enter build number or qfe number" );
  73. return 0;
  74. }
  75. }
  76. if( !$buildArch ) { $buildArch = $ENV{_BuildArch}; }
  77. elsif( lc $buildArch ne "x86" && lc $buildArch ne "ia64" )
  78. {
  79. errmsg( "Invalid Build Architecture." );
  80. return 0;
  81. }
  82. if( !$buildType ) { $buildType = $ENV{_BuildType}; }
  83. elsif( lc $buildType ne "fre" && lc $buildType ne "chk" )
  84. {
  85. errmsg( "Invalid Build Debug Type." );
  86. return 0;
  87. }
  88. return 1;
  89. }
  90. #-----------------------------------------------------------------------------
  91. sub InitVars
  92. {
  93. if( !$ENV{ OFFICIAL_BUILD_MACHINE })
  94. {
  95. logmsg( "[$ENV{computername}] is not an official build machine, skip release." );
  96. return 1;
  97. }
  98. # set %_ntpostbld% for any circumstances
  99. my $ntpostbld = $ENV{_ntpostbld};
  100. $ntpostbld =~ /^(.*)\\([^\\]+)$/;
  101. $ntpostbld = "$ENV{_ntpostbld}\\$ENV{lang}" if( lc $ENV{lang} ne lc $2 );
  102. #Set build Number
  103. if( !$buildNo && !$qfe )
  104. {
  105. my $buildNoFile = "$ntpostbld\\congeal_scripts\\__qfenum__";
  106. my $buildRevFile = "$ntpostbld\\build_logs\\BuildRev.txt";
  107. if( !(-e $buildNoFile ) )
  108. {
  109. errmsg( "Cannot find [$buildNoFile] to determine the build number" );
  110. return 0;
  111. }
  112. my @qfeNum;
  113. return 0 if( !( @qfeNum = &comlib::ReadFile( $buildNoFile ) ) );
  114. @qfeNum = split( /\=/, $qfeNum[0] );
  115. $buildNo = $qfeNum[1];
  116. if( -e $buildRevFile )
  117. {
  118. my @revision = `cat $buildRevFile`;
  119. chomp @revision;
  120. $revision[0] =~ s/^\s*(.*?)\s*$/$1/;
  121. $buildNo .= "-$revision[0]" if( $revision[0] );
  122. }
  123. }
  124. # Set release target servers
  125. if( !@releaseServers )
  126. {
  127. my @iniRequest ;
  128. @iniRequest = $qfe ? ("ReleaseServers::QFE::$buildArch$buildType" ) : ("ReleaseServers::$ENV{lang}::$buildArch$buildType" );
  129. my( $iniRelServers ) = &GetIniSetting::GetSetting( @iniRequest );
  130. @releaseServers = split( /\s+/, $iniRelServers );
  131. }
  132. # Set release Source Server
  133. $srcServer = $ENV{computername} if( !$srcServer );
  134. &comlib::ResetLogErrFile("release.$buildNo.$buildArch$buildType");
  135. timemsg( "Start $ENV{script_name}" );
  136. logmsg( "Lauguage ..............[$ENV{lang}]" );
  137. logmsg( "Build No ..............[$buildNo]" );
  138. logmsg( "Release Target Server .[@releaseServers]" );
  139. logmsg( "Release Source Server .[$srcServer]" );
  140. logmsg( "Temp Log file .........[$ENV{LOGFILE}]" );
  141. logmsg( "Temp Error file .......[$ENV{ERRFILE}]" );
  142. return 1;
  143. }
  144. #-----------------------------------------------------------------------------
  145. sub StartRelease
  146. {
  147. if( !$ENV{ OFFICIAL_BUILD_MACHINE })
  148. {
  149. logmsg( "[$ENV{computername}] is not an official build machine, skip release." );
  150. return 1;
  151. }
  152. my ( $cmdLine, $dash);
  153. $dash = '-' x 60;
  154. logmsg ( $dash );
  155. # Move build locally
  156. my $_QFE = $qfe ? "-qfe:$qfe" : "-n:$buildNo" ;
  157. if( !$relOnly && lc $srcServer eq lc $ENV{computername} )
  158. {
  159. $cmdLine = "$ENV{RazzleToolPath}\\sp\\movebuild.cmd -d:forward $_QFE";
  160. return 0 if( !&comlib::ExecuteSystemX( $cmdLine, $powerLess ));
  161. }
  162. # Start remote to pull the build
  163. my $pLess= "-p" if( $powerLess );
  164. for my $theServer ( @releaseServers )
  165. {
  166. logmsg ( $dash );
  167. $cmdLine = "start /min cmd /c $ENV{RazzleToolPath}\\sp\\propbuild.cmd -l:$ENV{lang} $_QFE";
  168. $cmdLine .= " -a:$buildArch -t:$buildType -s:$srcServer -d:$theServer -mail $pLess";
  169. &comlib::ExecuteSystemX( $cmdLine, $powerLess );
  170. }
  171. # Create request to index symbol
  172. logmsg ( $dash );
  173. $cmdLine = "$ENV{RazzleToolPath}\\sp\\indexsym.cmd -n:$buildNo -l:$ENV{lang} -x:$buildArch$buildType";
  174. return 0 if( !$relOnly && !$qfe &&!&comlib::ExecuteSystemX( $cmdLine, $powerLess ));
  175. return 1;
  176. }
  177. #-----------------------------------------------------------------------------
  178. 1;