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.

269 lines
8.5 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM miscrel.cmd
  5. REM Move the build components such as symbolcd, ddk to the conglomeration servers.
  6. REM
  7. REM Copyright (c) Microsoft Corporation. All rights reserved.
  8. REM Version: < 1.0 > 02/02/2001 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 PbuildEnv;
  17. use Logmsg;
  18. use ParseArgs;
  19. use File::Basename;
  20. use BuildName;
  21. use GetIniSetting;
  22. use comlib;
  23. my $scriptname = basename( $0 );
  24. sub Usage {
  25. print<<USAGE;
  26. Propogate miscellaneous build components such as symbols and DDKS to conglomeration servers.
  27. Usage:
  28. $scriptname: -l:<language> [-b:<BuildName>] [-p]
  29. -l Language.
  30. Default is "usa".
  31. -b Build Name.
  32. Default is defined in
  33. <ReleaseShare>\\build_logs\\buildname.txt for language usa.
  34. <ReleaseShare>\\<lang>\\build_logs\\buildname.txt for language none usa.
  35. -p Powerless.
  36. Display key variables only.
  37. -? Display Usage.
  38. Example:
  39. $scriptname -b:2415.x86fre.main.001222-1745
  40. $scriptname -l:ger -p
  41. USAGE
  42. exit(1)
  43. }
  44. my ( $buildName, $buildNo, $powerLess, $buildBranch, $buildArch, $buildType, $iniFile );
  45. my ( $buildTime, %groupShareName, %groupShareRootDir, @group, $releaseDrive );
  46. my ( $lang, $computerName, $releaseResDir);
  47. my ( @conglomerators, @releaseServers, @releaseAccess );
  48. my ( @hashTable );
  49. &GetParams();
  50. timemsg( "Start [$scriptname]" );
  51. if( !&InitVars() ) { exit(1); }
  52. if( !$powerLess && !&CopyMiscBuild ){ exit(1); }
  53. timemsg( "Complete [$scriptname]" );
  54. exit(0);
  55. #-----------------------------------------------------------------------------
  56. sub GetParams
  57. {
  58. parseargs('?' => \&Usage, 'b:' => \$buildName, 'p' =>\$powerLess );
  59. $lang = lc( $ENV{lang} );
  60. $computerName = lc( $ENV{computername} );
  61. }
  62. #-----------------------------------------------------------------------------
  63. sub InitVars
  64. {
  65. my( @iniRequest );
  66. #####Set build name, buildbranch, buildArch, buildType and ini file
  67. if( !$buildName )
  68. {
  69. my ($cmdLine ) = "$ENV{RazzleToolPath}\\postbuildscripts\\getlatestrelease.cmd -l:$lang";
  70. return 0 if( !chomp($buildName= `$cmdLine`) );
  71. }
  72. $buildNo = build_number($buildName);
  73. $buildBranch = lc ( build_branch($buildName) );
  74. $buildArch = lc ( build_arch($buildName) );
  75. $buildType = lc ( build_type($buildName) );
  76. $buildTime = build_date($buildName);
  77. if( !$buildBranch || !$buildArch || !$buildType )
  78. {
  79. errmsg( "Unable to parse [$buildName]");
  80. return 0;
  81. }
  82. $iniFile = "$buildBranch.$lang.ini";
  83. #####Set <ReleaseShareName> & <ReleaseShareRootDir> & <ReleaseDir>
  84. my ( $releaseShareName ) = &comlib::GetReleaseShareName( $ENV{_BuildBranch}, $lang );
  85. my $releaseShareRootDir = "\\$releaseShareName";
  86. if( lc($lang) eq "usa" )
  87. {
  88. $releaseResDir = "$releaseShareRootDir\\$buildName";
  89. }
  90. else
  91. {
  92. $releaseResDir = "$releaseShareRootDir\\$lang\\$buildName";
  93. }
  94. if( !( -e $releaseResDir ) )
  95. {
  96. errmsg( "[$releaseResDir] not exists, exit." );
  97. return 0;
  98. }
  99. #####Set aggregation servers
  100. @iniRequest = ( "ConglomerationServers" );
  101. my( $iniConglomerator ) = &GetIniSetting::GetSetting( @iniRequest );
  102. if( !$iniConglomerator )
  103. {
  104. logmsg( "no [ConglomerationServers] defined in [$iniFile]." );
  105. }
  106. @conglomerators = split( /\s+/, $iniConglomerator );
  107. #####Set release servers
  108. @iniRequest = ( "ReleaseServers::$buildArch$buildType" );
  109. my( $iniRelServers ) = &GetIniSetting::GetSetting( @iniRequest );
  110. if( !$iniRelServers )
  111. {
  112. logmsg( "no [Release Servers] defined in $iniFile, exit." );
  113. }
  114. @releaseServers = split( /\s+/, $iniRelServers );
  115. #####Set public share access
  116. @iniRequest = ( "ReleaseAccess");
  117. my $iniAccess = &GetIniSetting::GetSetting( @iniRequest );
  118. @releaseAccess = split ( /\s+/, $iniAccess );
  119. @releaseAccess = "$ENV{userDomain}\\$ENV{UserName}" if( !@releaseAccess );
  120. #####Array as group in miscrel.txt
  121. @group = ( "lang", "build" );
  122. #####Share name and Share root dir for each group item
  123. %groupShareRootDir = ( "lang" => "$releaseShareRootDir\\$lang\\$buildNo.$buildBranch",
  124. "build" => "$releaseShareRootDir\\misc\\$buildNo.$buildBranch" );
  125. %groupShareName = ( "lang" => "$buildNo.$buildBranch.$lang",
  126. "build" => "$buildNo.$buildBranch.misc" );
  127. logmsg( "Lauguage .................[$lang]" );
  128. logmsg( "This computer.............[$computerName]");
  129. logmsg( "Release Servers ..........[$iniRelServers]");
  130. logmsg( "Conglomerate Servers......[$iniConglomerator]");
  131. logmsg( "Build name ...............[$buildName]" );
  132. logmsg( "Ini file .................[$iniFile]" );
  133. logmsg( "Resource Share name.......[$buildName.$lang]" );
  134. logmsg( "Resource Share Path.......[\\\\$computerName\\$ENV{_ntdrive}$releaseResDir]" );
  135. for my $key ( sort keys %groupShareName )
  136. {
  137. logmsg( "Conglomeration share name:Path [$groupShareName{$key}:$groupShareRootDir{$key}]" );
  138. }
  139. logmsg( "Share Access is ..........[@releaseAccess]" );
  140. logmsg( "Temp Log file ............[$ENV{LOGFILE}]" );
  141. logmsg( "Temp Error file ..........[$ENV{ERRFILE}]" );
  142. return 1;
  143. }
  144. #-----------------------------------------------------------------------------
  145. sub CopyMiscBuild
  146. {
  147. my ( $destRootDir, $copyFlag );
  148. for my $theConglomerator( @conglomerators )
  149. {
  150. if( grep { $theConglomerator eq $_} @releaseServers )
  151. {
  152. logmsg( "[$theConglomerator] is also a release server, skip copying.");
  153. next;
  154. }
  155. #####Set Remote Misc Share Drive
  156. my( @iniRequest ) = ("ReleaseDrive::$theConglomerator");
  157. $releaseDrive = &GetIniSetting::GetSettingEx( $buildBranch,$lang,@iniRequest );
  158. if ( !$releaseDrive )
  159. {
  160. $ENV{_ntdrive} =~ /(.*)\:/;
  161. $releaseDrive = $1;
  162. }
  163. for my $theGroup ( @group )
  164. {
  165. next if( !&CreateMiscShare( $theConglomerator, $releaseDrive, $groupShareName{$theGroup}, $groupShareRootDir{ $theGroup} ) );
  166. $destRootDir = "\\\\$theConglomerator\\$releaseDrive\$$groupShareRootDir{$theGroup}";
  167. #####Parse miscrel.txt table for copying
  168. @hashTable = &comlib::ParseTable( $theGroup, $lang, $buildArch, $buildType );
  169. for my $line( @hashTable )
  170. {
  171. my $from = "$releaseResDir\\$line->{SourceDir}";
  172. my $to = "$destRootDir\\$line->{DestDir}";
  173. my $tmpfile = &comlib::CreateExcludeFile( $line->{ExcludeDir} );
  174. if( uc($line->{DestDir}) eq "IFS" || uc($line->{DestDir}) eq "HAL" )
  175. {
  176. $copyFlag = "/yei";
  177. }
  178. else
  179. {
  180. $copyFlag = "/ydei";
  181. }
  182. &comlib::ExecuteSystem( "xcopy $copyFlag /EXCLUDE:$tmpfile $from $to" );
  183. if ($line->{DestDir} =~ /IA64/i)
  184. {
  185. &comlib::ExecuteSystem( "echo BUGBUG#336842" );
  186. &comlib::ExecuteSystem( "echo foo > $to\\efinvr.exe");
  187. }
  188. }
  189. }
  190. }
  191. #####Check error logs
  192. if( -e $ENV{errfile} && !(-z $ENV{errfile}) )
  193. {
  194. $ENV{errfile} =~ /(.*)\.tmp$/;
  195. logmsg("Please check error at $1");
  196. return 0;
  197. }
  198. logmsg("miscrel Copy Successfully");
  199. return 1;
  200. }
  201. #-----------------------------------------------------------------------------
  202. sub CreateMiscShare
  203. {
  204. my ( $pConglomerator, $pReleaseDrive, $pShareName, $pShareRootDir ) = @_;
  205. my ( $cmdLine );
  206. #####Create the conglomeration root dir if it does not exist.
  207. if( !( -e "\\\\$pConglomerator\\$releaseDrive\$$pShareRootDir" ) )
  208. {
  209. $cmdLine = "md \\\\$pConglomerator\\$releaseDrive\$$pShareRootDir";
  210. return 0 if( !&comlib::ExecuteSystem( $cmdLine ) );
  211. }
  212. #####create the public conglomeration share
  213. #####use system for not logging the error message if the share does not exist.
  214. if( system( "rmtshare \\\\$pConglomerator\\$pShareName >nul 2>nul") )
  215. {
  216. $cmdLine = "rmtshare \\\\$pConglomerator\\$pShareName=$pReleaseDrive:$pShareRootDir";
  217. $cmdLine .= " /grant $ENV{USERDOMAIN}\\$ENV{USERNAME}:read";
  218. #####Raiseall.pl should grant access to these shares in the main build lab
  219. if ( !$ENV{MAIN_BUILD_LAB_MACHINE} )
  220. {
  221. for my $ID ( @releaseAccess )
  222. {
  223. $cmdLine .= " /grant $ID:read";
  224. }
  225. }
  226. return 0 if( !&comlib::ExecuteSystem( $cmdLine ) );
  227. }
  228. return 1;
  229. }
  230. #-----------------------------------------------------------------------------
  231. 1;