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.

265 lines
8.4 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM AllRel.cmd
  5. REM Check the status of release across release 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 ParseArgs;
  18. use GetIniSetting;
  19. sub Usage { print<<USAGE; exit(1) }
  20. allrel [-n <build number>] [-b <branch>] [-a <arch>] [-t <type>]
  21. [-l <language>]
  22. Check the release servers specified in the .ini file for the state of
  23. the matching release.
  24. build number Build number for which to examine the relase logs.
  25. Default is latest build for each server / flavor.
  26. branch Branch for which to examine the release logs. Default is
  27. %_BuildBranch%.
  28. arch Build architecture for which to examine the release logs.
  29. Default is %_BuildArch%.
  30. type Build architecture for which to examine the release logs.
  31. Default is %_BuildType%.
  32. lang Language for which to examine the release logs. Default
  33. is 'usa'.
  34. USAGE
  35. my ($build, $branch, @arches, @types);
  36. parseargs('?' => \&Usage,
  37. 'n:'=> \$build,
  38. 'b:'=> \$branch,
  39. 'a:'=> \@arches,
  40. 't:'=> \@types);
  41. *GetSettingQuietEx = \&GetIniSetting::GetSettingQuietEx;
  42. my $back = 1;
  43. $build ||= '*';
  44. $branch ||= $ENV{_BUILDBRANCH};
  45. if (!@arches) { @arches = ('x86', 'ia64', 'amd64') }
  46. if (!@types) { @types = ('fre', 'chk') }
  47. for my $arch (@arches)
  48. {
  49. for my $type (@types)
  50. {
  51. print "$arch$type\n";
  52. my @servers = split / /, GetSettingQuietEx($branch, $ENV{LANG}, 'ReleaseServers', "$arch$type");
  53. my $bldMachine = GetSettingQuietEx($branch, $ENV{LANG}, 'BuildMachines', "$arch$type");
  54. for my $server (@servers)
  55. {
  56. my $NoLogFound = 0;
  57. my $FailedToOpenLog = 0;
  58. my $FailedToParseLog = 0;
  59. my $IsReleaseRunning = 0;
  60. my $IsReleaseDone = 0;
  61. my $IsThereAnError = 0;
  62. my $LogFileTime = "[UNKNOWN]";
  63. my $ReleaseLogDir = "[UNKNOWN]";
  64. my $ReleaseLogFile = "[UNKNOWN]";
  65. my $ReleaseErrFile = "[UNKNOWN]";
  66. my $sServerHash = "";
  67. my $sBldMachineHash = "";
  68. # Tell the user what server we're examining
  69. print " $server\n";
  70. # Find the log files...
  71. my $temp = '\\temp$';
  72. my $alt_temp = 'c$\\temp';
  73. my $log_base = "\\\\$server";
  74. if ( -e "$log_base\\$temp" )
  75. {
  76. $log_base .= "\\$temp";
  77. }
  78. elsif ( -e "$log_base\\$alt_temp" )
  79. {
  80. $log_base .= "\\$alt_temp";
  81. }
  82. else
  83. {
  84. # Add error reporting here.
  85. $log_base .= "\\$temp";
  86. }
  87. $log_base .= "\\$ENV{LANG}";
  88. # Switch to using release share instead of d$ share.
  89. my $release_spec = "//$server/release/$ENV{LANG}/$build.$arch$type.$branch.*";
  90. my $hash_loc;
  91. my $sServer_loc;
  92. my @releases = glob $release_spec;
  93. if(lc($ENV{LANG}) ne "usa")
  94. {
  95. $hash_loc = "\\\\$bldMachine\\release\\$ENV{LANG}\\";
  96. }
  97. else
  98. {
  99. $hash_loc = "\\\\$bldMachine\\release\\";
  100. }
  101. $sServer_loc = "\\\\$server\\release\\$ENV{LANG}\\";
  102. # Handy debugging code...
  103. #print " LOG BASE DIR: \"$log_base\"\n";
  104. #print " RELEASE SPEC: \"$release_spec\"\n";
  105. #print @releases;
  106. for (my $i=0; $i < $back and $i <= $#releases; $i++)
  107. {
  108. my ($build_name) = $releases[$#releases-$i] =~ /([^\/]+)$/;
  109. my $sBMHAsh;
  110. my $sRelHash;
  111. $build_name =~ s/_TEMP$//;
  112. if(open(BLDHASH,"$hash_loc\\$build_name\\build_logs\\bldhash.txt"))
  113. {
  114. $sBMHAsh = readline(BLDHASH);
  115. close(BLDHASH);
  116. }
  117. if(open(BLDHASH,"$sServer_loc\\$build_name\\build_logs\\srvrelhash.txt"))
  118. {
  119. $sRelHash = readline(BLDHASH);
  120. close(BLDHASH);
  121. }
  122. my $log_dir = "$log_base\\$build_name";
  123. print " $build_name: ";
  124. my $log_file = "$log_dir\\srvrel.log";
  125. my $err_file = "$log_dir\\srvrel.err";
  126. # Save this off for later...
  127. $ReleaseLogDir = $log_dir;
  128. $ReleaseLogFile = $log_file;
  129. $ReleaseErrFile = $err_file;
  130. if (-e $err_file and !-z $err_file)
  131. {
  132. # We found an error. Save that info off.
  133. $IsThereAnError = 1;
  134. $ReleaseErrFile = $err_file;
  135. }
  136. if (!-e $log_file)
  137. {
  138. $NoLogFound = 1;
  139. }
  140. else
  141. {
  142. if( !open FILE, $log_file)
  143. {
  144. $FailedToOpenLog = 1;
  145. }
  146. else
  147. {
  148. $LogFileTime = localtime((stat FILE)[9]);
  149. if (<FILE> =~ /Start \[srvrel.cmd\]/)
  150. {
  151. seek(FILE,-100,2);
  152. local $/ = undef;
  153. if (<FILE> =~ /Complete \[srvrel\.cmd\]/)
  154. {
  155. $IsReleaseDone = 1;
  156. }
  157. if ( !$IsReleaseDone )
  158. {
  159. seek(FILE,-100,2);
  160. if (<FILE> =~ /\(srvrel.cmd\) Please check error at/)
  161. {
  162. $IsReleaseDone = 1;
  163. }
  164. }
  165. if ( !$IsReleaseDone )
  166. {
  167. $IsReleaseRunning = 1;
  168. }
  169. }
  170. else
  171. {
  172. $FailedToParseLog = 1;
  173. }
  174. close FILE;
  175. }
  176. }
  177. # Done gathering info for this server. Print it.
  178. if ( $NoLogFound )
  179. {
  180. print "NO LOG FOUND\n";
  181. print " $ReleaseLogDir\n";
  182. }
  183. elsif ( $FailedToOpenLog )
  184. {
  185. print " : FAILED TO OPEN LOG\n";
  186. print " $ReleaseLogFile\n";
  187. }
  188. elsif ( $FailedToParseLog )
  189. {
  190. print "FAILED TO PARSE LOG\n";
  191. print " $ReleaseLogFile\n";
  192. }
  193. else
  194. {
  195. if ( $IsThereAnError )
  196. {
  197. print "ERROR. ";
  198. }
  199. if ( $IsReleaseRunning )
  200. {
  201. print "RUNNING (@ $LogFileTime)\n";
  202. }
  203. elsif ( $IsReleaseDone )
  204. {
  205. print "DONE AT $LogFileTime - ";
  206. if($sBMHAsh)
  207. {
  208. if($sBMHAsh eq $sRelHash)
  209. {
  210. print "CHKSUM OK\n";
  211. }
  212. else
  213. {
  214. print "CHKSUM ERROR\n";
  215. }
  216. }
  217. else
  218. {
  219. print "CHKSUM NOT FOUND\n";
  220. }
  221. }
  222. if ( $IsThereAnError )
  223. {
  224. print " $ReleaseErrFile\n";
  225. }
  226. }
  227. }
  228. }
  229. # Done with this archtype entirely - move on
  230. print "\n";
  231. }
  232. }