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.

125 lines
3.3 KiB

  1. #----------------------------------------------------------------//
  2. # Script: checkdepots.pl
  3. #
  4. # (c) 2001 Microsoft Corporation. All rights reserved.
  5. #
  6. # Purpose: This script validates if all depots have a mapping
  7. # consistent with the root depot in a particular drive
  8. # enlistment. This tool should be run from the root of the
  9. # enlistment drive of interest and is. Currently it is
  10. # invoked as part of razzle with an optional argument i.e.:
  11. # razzle.cmd checkdepots
  12. #
  13. #
  14. # Version: <1.00> 03/22/2001 : VishnuP
  15. #----------------------------------------------------------------//
  16. $VERSION = '1.00';
  17. if ($#ARGV != -1) {
  18. die "usage: perl.exe checkdepots.pl\n";
  19. }
  20. $sdxroot = $ENV{'SDXROOT'} || die "SDXROOT not defined\n";
  21. chdir($sdxroot);
  22. print "\nChecking for consistent mappings...\n";
  23. $SdRootMapping = `sd client -o`;
  24. if ($SdRootMapping =~ m/depot\/([^\/]+)\/root\/... /){
  25. $SdRootDepotMapping = lc($1);
  26. }
  27. else {
  28. die "Warning: Either there are Source Depot problems or some client specification(s) might be corrupt in $sdxroot.\n";
  29. }
  30. @dirs = `dir /ad /b $sdxroot`;
  31. chomp(@dirs);
  32. @serverarray = ();
  33. foreach $dir (@dirs) {
  34. $dir = "$sdxroot\\$dir";
  35. if (-e "$dir\\sd.ini"){
  36. chdir($dir);
  37. $server = `sd info | findstr /c:"Server address:"`;
  38. if ($server = ~ m/Server/){
  39. push(@serverarray, $server);
  40. }
  41. else {
  42. die "Warning: Either there are Source Depot problems or some client specification(s) might be corrupt in $dir\n";
  43. }
  44. }
  45. }
  46. chdir($sdxroot);
  47. %seen = ();
  48. @uniqeservers = ();
  49. foreach $server (@serverarray) {
  50. push(@uniqeservers, $server) unless $seen{$server}++;
  51. }
  52. for (@cleanservers = @uniqeservers) { s/Server address: //, s/.ntdev.microsoft.com// };
  53. chomp(@cleanservers);
  54. $bIsInconsistent = 0;
  55. print "root -> $SdRootDepotMapping, ";
  56. $depotprintcount = 1;
  57. $depotcount = 1;
  58. @inconsistencies = ();
  59. foreach $server (@cleanservers){
  60. $sdcmd = "sd -p $server client -o | findstr /i /c:\"//depot/\" | findstr /i /v /c:\"//depot/$ARGV[0]/\"";
  61. $output = `$sdcmd`;
  62. if ($output =~ m/depot\/([^\/]+)\/([^\/]+)\/... /){
  63. $depotmatch = lc($1);
  64. if (!($depotmatch eq $SdRootDepotMapping)){
  65. $inconsistency = "$2 -> $depotmatch";
  66. push(@inconsistencies, $inconsistency);
  67. $bIsInconsistent = 1;
  68. }
  69. else {
  70. if (($depotprintcount) % 3 == 0 || $depotcount == $#cleanservers+1 ){
  71. $separator = "\n";
  72. }
  73. else {
  74. $separator = ", ";
  75. }
  76. print "$2 -> ",$depotmatch, $separator;
  77. ++$depotprintcount;
  78. }
  79. ++$depotcount;
  80. }
  81. else {
  82. die "Warning: Either there are Source Depot problems or some client specification(s) might be corrupt when querying server $server.\n";
  83. }
  84. }
  85. if (!$bIsInconsistent){
  86. print "\nInformation: All depots are consistent with the root depot's mapping\n";
  87. }
  88. else {
  89. print "\nInconsistent mapping(s): ";
  90. $inconsistencyCnt = 0;
  91. foreach $inconsistency (@inconsistencies){
  92. if ($inconsistencyCnt == $#inconsistencies) {
  93. $separator = "\n";
  94. }
  95. else {
  96. $separator = ", ";
  97. }
  98. print $inconsistency, $separator;
  99. $inconsistencyCnt++;
  100. }
  101. print "\nWarning: At least one depot does not map to the same depot that the root\n";
  102. print "depot maps to as reported above. If this is not the intention, please edit\n";
  103. print "the client specification for the inconsistent depots.\n";
  104. }