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.

289 lines
9.3 KiB

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