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.

179 lines
4.4 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM submitloc.cmd
  4. REM Submit Localized files.
  5. REM
  6. REM Copyright (c) Microsoft Corporation. All rights reserved.
  7. REM Version: < 1.0 > 07/10/2002 Suemiao Rossignol
  8. REM ------------------------------------------------------------------
  9. perl -x "%~f0" %*
  10. goto :EOF
  11. #!perl
  12. use strict;
  13. use lib "$ENV{RAZZLETOOLPATH}\\PostBuildScripts";
  14. use lib $ENV{RAZZLETOOLPATH};
  15. use filestat;
  16. use Logmsg;
  17. use ParseArgs;
  18. use File::Basename;
  19. use comlib;
  20. use GetIniSetting;
  21. $ENV{script_name} = basename( $0 );
  22. sub Usage {
  23. print<<USAGE;
  24. Submit the localized files.
  25. Usage:
  26. $ENV{script_name} [-p]
  27. -p Powerless.
  28. -? Display Usage.
  29. USAGE
  30. exit(1)
  31. }
  32. my ( $powerLess );
  33. if( !&GetParams()) { exit(1); }
  34. timemsg( "Start $ENV{script_name}" );
  35. if( !&SubmitLocFiles() ) { exit(1); }
  36. timemsg( "Complete $ENV{script_name}" );
  37. exit(0);
  38. #-----------------------------------------------------------------------------
  39. sub GetParams
  40. {
  41. parseargs('?' => \&Usage, 'p' =>\$powerLess);
  42. # Reset logfile and errfile
  43. $ENV{LOGFILE} = "$ENV{temp}\\SubmitLoc.log";
  44. $ENV{ERRFILE} = "$ENV{temp}\\SubmitLoc.err";
  45. if(-e $ENV{LOGFILE} )
  46. {
  47. system( "copy $ENV{LOGFILE} $ENV{LOGFILE}.old");
  48. system( "del $ENV{LOGFILE}" );
  49. }
  50. if(-e $ENV{ERRFILE} )
  51. {
  52. system( "copy $ENV{ERRFILE} $ENV{ERRFILE}.old") ;
  53. system( "del $ENV{ERRFILE}" );
  54. }
  55. return 1;
  56. }
  57. #-----------------------------------------------------------------------------
  58. sub SubmitLocFiles
  59. {
  60. my @sdMap = &comlib::ReadFile( "$ENV{sdxroot}\\sd.map" );
  61. my @sdProject;
  62. my $validLine = 0;
  63. for my $curLine ( @sdMap )
  64. {
  65. chomp $curLine;
  66. my @tmpLine = split( /\s+/, $curLine );
  67. if( $tmpLine[1] !~ "---" )
  68. {
  69. next if ( !$validLine );
  70. last if( $tmpLine[0] =~ "#" );
  71. }
  72. else
  73. {
  74. $validLine = 1;
  75. next;
  76. }
  77. next if( !$tmpLine[1] || $tmpLine[1] =~ "(.*)_(.*)" );
  78. next if( $tmpLine[1] eq "root" );
  79. push ( @sdProject, $tmpLine[3] );
  80. }
  81. push ( @sdProject,"Mergedcomponents" );
  82. for my $theDir( @sdProject )
  83. {
  84. &VryFieZs("zerosize", "$ENV{sdxroot}\\$theDir");
  85. &SDSubmit("test", "$ENV{sdxroot}\\$theDir" );
  86. }
  87. return 1;
  88. }
  89. #----------------------------------------------------------------------------
  90. # SDSubmit($) - Automates Submittals w/ arg:comment
  91. #----------------------------------------------------------------------------
  92. sub SDSubmit($$)
  93. {
  94. my($comment, $dir) = @_;
  95. my @revertList;
  96. my @noDiff = `cd $dir & sd diff -sr`;
  97. for (@noDiff)
  98. {
  99. push( @revertList, `cd $dir &sd have $_` );
  100. }
  101. chomp @revertList;
  102. my @chgList = `cd $dir &sd change -o`;
  103. my $res = 0;
  104. my $l = 0;
  105. while( $l < @chgList && $chgList[$l++] !~ /^Files:/ ){}
  106. while( $l < @chgList && $chgList[$l++] =~ /\/\/depot.*/ )
  107. {
  108. $res = 1;
  109. last;
  110. }
  111. if ($res == 0){
  112. logmsg("No files to submit.\n");
  113. return 1;
  114. }
  115. my $submitFile = "$ENV{TEMP}\\sdchglst.tmp";
  116. open OUTFILE, ">$submitFile" || return 0;
  117. for my $line (@chgList)
  118. {
  119. $line =~ s/\<enter description here\>/$comment/ && next;
  120. my $continue;
  121. for ( @revertList )
  122. {
  123. $_ =~ /^(.+)\#.*$/;
  124. my $cmp = $1;
  125. next if( $line !~ /$cmp/i );
  126. &comlib::ExecuteSystem( "cd $dir &sd revert $cmp");
  127. $continue = 1;
  128. last;
  129. }
  130. next if( $continue );
  131. print OUTFILE $line;
  132. }
  133. close OUTFILE;
  134. if( $powerLess )
  135. {
  136. `start list $submitFile`;
  137. }
  138. else
  139. {
  140. print `cd $dir &type $submitFile | sd submit `;
  141. }
  142. return 1;
  143. }
  144. #----------------------------------------------------------------------------
  145. # VryFieZs - verify files in directories
  146. # usage VryFieZs(test, dirname,dirname,...)
  147. # currently as "test" the "writeable" or "zerosize" may be used.
  148. #----------------------------------------------------------------------------
  149. sub VryFieZs()
  150. {
  151. my ( $test, $path ) = @_;
  152. my $GOOD = 1;
  153. chdir $path;
  154. my @res = (qx(cd $path &dir /s/b/a-d .) =~ /.+\n/mig);
  155. map {chomp} @res;
  156. my @bad = &filestat($test, @res);
  157. map { errmsg("ZeroSize[$_]")} @bad ;
  158. return 0 if scalar(@bad);
  159. return 1;
  160. }
  161. #----------------------------------------------------------------------------
  162. 1;