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.

104 lines
2.0 KiB

  1. #----------------------------------------------------------------//
  2. # Script: changelab.pl
  3. #
  4. # (c) 2001 Microsoft Corporation. All rights reserved.
  5. #
  6. # Purpose: This script maps the client views of all
  7. # depots to the view specified as an argument.
  8. # usage: perl.exe changelab.pl <lab_name>
  9. #
  10. # Maintenance: Update @labarray to reflect the list of valid labs
  11. #
  12. # Version: <1.00> 03/22/2001 : VishnuP
  13. #----------------------------------------------------------------//
  14. $VERSION = '1.00';
  15. if ($#ARGV != 0) {
  16. die "usage: perl.exe changelab.pl <lab_name>\n";
  17. }
  18. $changeto = lc($ARGV[$#ARGV]);
  19. if (validateLab() == 0)
  20. {
  21. die "$changeto is not a valid <lab_name>\n";
  22. }
  23. $sdxroot = $ENV{'SDXROOT'} || die "SDXROOT not defined\n";
  24. chdir($sdxroot);
  25. @SdMapping = `sd client -o`;
  26. foreach $line (@SdMapping) {
  27. if ($line =~ m/depot\/([^\/]+)\//) {
  28. $line =~ s/$1/$changeto/;
  29. }
  30. $SdNewMapping .= $line;
  31. }
  32. $tmpdir = $ENV{'tmp'} || die "tmp not defined\n";
  33. $dirOnly = "root";
  34. MapIt();
  35. $SdNewMapping = "";
  36. @dirs = `dir /ad /b $sdxroot`;
  37. chomp(@dirs);
  38. foreach $dir (@dirs) {
  39. $dirOnly = $dir;
  40. $dir = "$sdxroot\\$dir";
  41. if (-e "$dir\\sd.ini"){
  42. chdir($dir);
  43. @SdMapping = `sd client -o`;
  44. foreach $line (@SdMapping) {
  45. if ($line =~ m/depot\/([^\/]+)\//) {
  46. $line =~ s/$1/$changeto/;
  47. }
  48. $SdNewMapping .= $line;
  49. }
  50. MapIt();
  51. $SdNewMapping = "";
  52. }
  53. }
  54. chdir($sdxroot);
  55. sub validateLab{
  56. @labarray = ("lab01_n", "lab02_n", "lab03_n", "lab03_client", "lab04_n", "lab05_n",
  57. "lab06_n", "lab07_n", "lab08_n", "lab09_n", "lab10_n",
  58. "lab11_n", "lab12_n", "lab13_n", "lab14_n", "lab15_n",
  59. "main");
  60. foreach $lab (@labarray){
  61. if ($changeto eq $lab){
  62. return 1;
  63. }
  64. }
  65. return 0;
  66. }
  67. sub MapIt{
  68. $random = int (1000 * rand(7));
  69. $clientSpecFile = "$tmpdir\\$random";
  70. if ( !open(MAPFILE, ">$clientSpecFile"))
  71. {
  72. die "cannot create file $clientSpecFile\n";
  73. }
  74. print MAPFILE $SdNewMapping;
  75. close(MAPFILE);
  76. print "Changing $dirOnly depot...\n";
  77. print `sd client -i < $clientSpecFile`;
  78. unlink($clientSpecFile);
  79. }