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.

202 lines
6.0 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM Tokrel.cmd - JorgeBa
  4. @REM Move the build resources to the release servers
  5. @REM
  6. @REM Copyright (c) Microsoft Corporation. All rights reserved.
  7. @REM
  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. Propogate miscellaneous build components such as symbols and DDKS to conglomeration servers.
  26. Usage:
  27. $scriptname: -l:<language> [-b:<BuildName>][-misc] [-p]
  28. -l Language.
  29. Default is "usa".
  30. -b Build Name.
  31. Default is defined in
  32. <ReleaseShare>\\build_logs\\buildname.txt for language usa.
  33. <ReleaseShare>\\<lang>\\build_logs\\buildname.txt for language none usa.
  34. -p Powerless.
  35. Display key variables only.
  36. -? Display Usage.
  37. Example:
  38. $scriptname -b:2415.x86fre.main.001222-1745
  39. $scriptname -l:ger -p
  40. USAGE
  41. exit(1)
  42. }
  43. my ( $buildName, $buildNo, $powerLess, $buildBranch, $buildArch, $buildType, $iniFile );
  44. my ( $buildTime, %groupShareName, %groupShareRootDir, @group, $releaseDrive );
  45. my ( $lang, $computerName, $releaseResDir);
  46. my ( @conglomerators, @releaseServers, @releaseAccess );
  47. my ( @hashTable, $miscOnly );
  48. &GetParams();
  49. if(lc($ENV{"lang"}) ne "usa" && lc($ENV{"lang"}) ne "cov")
  50. {
  51. timemsg( "Start [$scriptname]" );
  52. if( !&InitVars() ) { exit(1); }
  53. if( !$powerLess && !&CopyTokens ){ exit(1); }
  54. timemsg( "Complete [$scriptname]" );
  55. exit(0);
  56. }
  57. #-----------------------------------------------------------------------------
  58. sub GetParams
  59. {
  60. parseargs('?' => \&Usage, 'b:' => \$buildName, 'p' =>\$powerLess );
  61. $lang = lc( $ENV{lang} );
  62. $computerName = lc( $ENV{computername} );
  63. }
  64. #-----------------------------------------------------------------------------
  65. sub InitVars
  66. {
  67. my( @iniRequest );
  68. #####Set build name, buildbranch, buildArch, buildType and ini file
  69. if( !$buildName )
  70. {
  71. my ($cmdLine ) = "$ENV{RazzleToolPath}\\postbuildscripts\\getlatestrelease.cmd -l:$lang";
  72. return 0 if( !chomp($buildName= `$cmdLine`) );
  73. }
  74. $buildNo = build_number($buildName);
  75. $buildBranch = lc ( build_branch($buildName) );
  76. $buildArch = lc ( build_arch($buildName) );
  77. $buildType = lc ( build_type($buildName) );
  78. $buildTime = build_date($buildName);
  79. if( !$buildBranch || !$buildArch || !$buildType )
  80. {
  81. errmsg( "Unable to parse [$buildName]");
  82. return 0;
  83. }
  84. $iniFile = "$buildBranch.$lang.ini";
  85. #####Set <ReleaseShareName> & <ReleaseShareRootDir> & <ReleaseDir>
  86. my $lookUpName = "release";
  87. if( $ENV{_BuildBranch} =~ /idx\d{2}/i )
  88. {
  89. $lookUpName = "$ENV{_buildBranch}$lookUpName";
  90. }
  91. my $releaseShareRootDir = &comlib::ParseNetShare( $lookUpName, "Path" );
  92. if( lc($lang) eq "usa" )
  93. {
  94. $releaseResDir = "$releaseShareRootDir\\$buildName";
  95. }
  96. else
  97. {
  98. $releaseResDir = "$releaseShareRootDir\\$lang\\$buildName";
  99. }
  100. if( !( -e $releaseResDir ) )
  101. {
  102. errmsg( "[$releaseResDir] not exists, exit." );
  103. return 0;
  104. }
  105. $releaseShareRootDir =~ /^([^\:]+)\:(\\.+)$/;
  106. my $localReleaseDrive= $1;
  107. $releaseShareRootDir = $2;
  108. #####Set release servers
  109. @iniRequest = ( "ReleaseServers::$buildArch$buildType" );
  110. my( $iniRelServers ) = &GetIniSetting::GetSetting( @iniRequest );
  111. if( !$iniRelServers )
  112. {
  113. logmsg( "no [Release Servers] defined in $iniFile, exit." );
  114. }
  115. @releaseServers = split( /\s+/, $iniRelServers );
  116. #####Set public share access
  117. @iniRequest = ( "ReleaseAccess");
  118. my $iniAccess = &GetIniSetting::GetSetting( @iniRequest );
  119. @releaseAccess = split ( /\s+/, $iniAccess );
  120. @releaseAccess = "$ENV{userDomain}\\$ENV{UserName}" if( !@releaseAccess );
  121. logmsg( "Lauguage .................[$lang]" );
  122. logmsg( "This computer.............[$computerName]");
  123. logmsg( "Release Servers ..........[$iniRelServers]");
  124. logmsg( "Build name ...............[$buildName]" );
  125. logmsg( "Ini file .................[$iniFile]" );
  126. logmsg( "Local release Drive.......[$localReleaseDrive]" );
  127. logmsg( "Share Access is ..........[@releaseAccess]" );
  128. logmsg( "Temp Log file ............[$ENV{LOGFILE}]" );
  129. logmsg( "Temp Error file ..........[$ENV{ERRFILE}]" );
  130. return 1;
  131. }
  132. #-----------------------------------------------------------------------------
  133. sub CopyTokens
  134. {
  135. my ( $destRootDir, $copyFlag );
  136. for my $sReleaseServer ( @releaseServers )
  137. {
  138. if( $sReleaseServer =~ /burn/)
  139. {
  140. next;
  141. }
  142. #####Set Remote Misc Share Drive
  143. my $tmpReleasePath = &comlib::ParseNetShare( "\\\\$sReleaseServer\\release", "Path" );
  144. $tmpReleasePath =~ /^([^\:]+)\:(\\.+)$/;
  145. $releaseDrive = $1;
  146. if ( !$releaseDrive )
  147. {
  148. my( @iniRequest ) = ("ReleaseDrive::$sReleaseServer");
  149. $releaseDrive = &GetIniSetting::GetSettingEx( $buildBranch,$lang,@iniRequest );
  150. if ( !$releaseDrive )
  151. {
  152. $ENV{_ntdrive} =~ /(.*)\:/;
  153. $releaseDrive = $1;
  154. }
  155. }
  156. $destRootDir = "\\\\$sReleaseServer\\$releaseDrive\$\\Release\\$lang\\$buildName\\Resources";
  157. $copyFlag = "/ydei";
  158. comlib::ExecuteSystem("xcopy $copyFlag $releaseResDir\\Resources $destRootDir");
  159. }
  160. #####Check error logs
  161. if( -e $ENV{errfile} && !(-z $ENV{errfile}) )
  162. {
  163. $ENV{errfile} =~ /(.*)\.tmp$/;
  164. logmsg("Please check error at $1");
  165. return 0;
  166. }
  167. logmsg("tokrel Copy Successfully");
  168. return 1;
  169. }
  170. #-----------------------------------------------------------------------------
  171. 1;