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.

296 lines
6.4 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM raisesp.cmd
  5. REM This script raises the xpsp builds in the dfs
  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 Logmsg;
  19. use ParseTable;
  20. #
  21. # Global vars
  22. #
  23. # Command line parameters
  24. my ($qfenum, $quality, $arch, $debug);
  25. # dfslinks hash
  26. my @ah_dfs;
  27. # Error return
  28. my $errorcode;
  29. sub Usage { print<<USAGE; exit(1) }
  30. raisesp.cmd -n:qfenum -q:quality -a:arch -d:debug [-l:lang] [-?]
  31. -n:qfenum Service pack number ie. 1000
  32. -q:quality bvt, tst, del
  33. -a:arch x86, ia64
  34. -d:debug fre, chk
  35. -l:lang Language
  36. USAGE
  37. parseargs('?' => \&Usage,
  38. 'n:' => \$qfenum,
  39. 'q:' => \$quality,
  40. 'a:' => \$arch,
  41. 'd:' => \$debug
  42. );
  43. #
  44. # Main
  45. #
  46. &main();
  47. #
  48. # Main entry point. Runs all functions.
  49. #
  50. sub main
  51. {
  52. #Validate command line
  53. unless ( $errorcode = &ValidateCmdLine() )
  54. {
  55. logmsg ( "Bad command line arguments" );
  56. logmsg ( "Exiting..." );
  57. return;
  58. }
  59. #Only run if offical build machine
  60. unless ( $errorcode = &IsOfficial() )
  61. {
  62. logmsg ( "This script only runs on OFFICIAL_BUILD_MACHINE's." );
  63. logmsg ( "Exiting..." );
  64. return;
  65. }
  66. #Load and parse dfs data file
  67. unless ( @ah_dfs = &ParseDfsData( ($ENV{"RazzleToolPath"} . "\\sp\\spdfs.txt"), \@ah_dfs) )
  68. {
  69. logmsg ( "Could not parse spdfs.txt." );
  70. logmsg ( "Exiting..." );
  71. return;
  72. }
  73. # Sub variables in hash
  74. unless ( @ah_dfs = &FilterHash( $qfenum, $arch, $debug, $ENV{LANG}, \@ah_dfs ) )
  75. {
  76. logmsg ( "Could not filter Dfs hash." );
  77. logmsg ( "Exiting..." );
  78. return;
  79. }
  80. # Edit the dfs server
  81. unless ( &EditDfs( $quality, \@ah_dfs ) )
  82. {
  83. logmsg ( "Could not create dfs links." );
  84. logmsg ( "Exiting..." );
  85. return;
  86. }
  87. }
  88. #
  89. # Function: Validate the command line
  90. #
  91. # return: 1 if true; undef if false
  92. #
  93. sub ValidateCmdLine
  94. {
  95. if ( $qfenum !~ /^\d{4}$/ )
  96. {
  97. logmsg ("Bad qfe number");
  98. return;
  99. }
  100. if ( $quality !~ /^(tst|bvt|idw|del)$/i )
  101. {
  102. logmsg ("Bad quality value");
  103. return;
  104. }
  105. if ( $arch !~ /^(x86|ia64|amd64)$/i )
  106. {
  107. logmsg ("Bad arch value");
  108. return;
  109. }
  110. if ( $debug !~ /^(fre|chk)$/i )
  111. {
  112. logmsg ("Bad debug value");
  113. return;
  114. }
  115. return 1;
  116. }
  117. #
  118. # Function: Check if local machine is OFFICIAL
  119. #
  120. # return: 1 if true; undef if false
  121. #
  122. sub IsOfficial
  123. {
  124. if ( exists ($ENV{OFFICIAL_BUILD_MACHINE}) )
  125. {
  126. return 1;
  127. }
  128. return;
  129. }
  130. #
  131. # Function: Read spdfs.txt and return a hash
  132. #
  133. # return: %
  134. #
  135. sub ParseDfsData
  136. {
  137. my ($input_file, $ah_dfs) = @_;
  138. my (@ah_dfs);
  139. logmsg ("#### Parsing $input_file ####");
  140. ParseTable::parse_table_file($input_file, \@ah_dfs);
  141. return @ah_dfs;
  142. }
  143. #
  144. # Function: Sub variables in hash for real values.
  145. #
  146. # return: %
  147. #
  148. sub FilterHash
  149. {
  150. my ($qfenum, $arch, $debug, $lang, $ah_dfs) = @_;
  151. logmsg ("#### Parse dfs hash w/variables ####");
  152. # Log filter values
  153. logmsg ("Qfenum: $qfenum");
  154. logmsg ("Architecure: $arch");
  155. logmsg ("Debug: $debug");
  156. logmsg ("Lang: $lang");
  157. my $dfslink;
  158. my @ah_dfs = @$ah_dfs;
  159. for $dfslink (@ah_dfs)
  160. {
  161. # Make DfsRoot name variable substitutions
  162. $dfslink->{DfsRoot} =~ s/<qfenum>/$qfenum/ig;
  163. $dfslink->{DfsRoot} =~ s/<arch>/$arch/ig;
  164. $dfslink->{DfsRoot} =~ s/<debug>/$debug/ig;
  165. $dfslink->{DfsRoot} =~ s/<lang>/$lang/ig;
  166. # Make FileShare name variable substitutions
  167. $dfslink->{FileShare} =~ s/<computername>/$ENV{COMPUTERNAME}/ig;
  168. $dfslink->{FileShare} =~ s/<qfenum>/$qfenum/ig;
  169. $dfslink->{FileShare} =~ s/<arch>/$arch/ig;
  170. $dfslink->{FileShare} =~ s/<debug>/$debug/ig;
  171. $dfslink->{FileShare} =~ s/<lang>/$lang/ig;
  172. # Make Comment variable substitutions
  173. $dfslink->{Comment} =~ s/<qfenum>/$qfenum/ig;
  174. $dfslink->{Comment} =~ s/<arch>/$arch/ig;
  175. $dfslink->{Comment} =~ s/<debug>/$debug/ig;
  176. $dfslink->{Comment} =~ s/<lang>/$lang/ig;
  177. }
  178. return @ah_dfs = @$ah_dfs;
  179. }
  180. #
  181. # Function: Edit dfs using dfscmd.exe
  182. #
  183. # return:
  184. #
  185. sub EditDfs
  186. {
  187. my ($quality, $ah_dfs) = @_;
  188. # Exit if quality is undefined
  189. if ($quality !~ m/(tst|bvt|idw|del)/i )
  190. {
  191. return;
  192. }
  193. # Local vars
  194. my $dfslink;
  195. my @ah_dfs = @$ah_dfs;
  196. my $cmdLine;
  197. my @cmdOutput;
  198. my @dfsViewOutput;
  199. logmsg ("#### Viewing current dfslinks ####");
  200. #View dfs links
  201. logmsg ("View the dfslinks...");
  202. $cmdLine = "dfscmd /view";
  203. $cmdLine .= " \\\\ntdev\\release";
  204. logmsg ("Running: $cmdLine");
  205. # @dfsViewOutput = `$cmdLine`;
  206. # logmsg ("@dfsViewOutput");
  207. logmsg ("#### Creating the dfslinks ####");
  208. for $dfslink ( @ah_dfs )
  209. {
  210. if ( $dfslink->{Condition} =~ $quality )
  211. {
  212. #Remove dfs links
  213. logmsg ("Delete the dfslinks...");
  214. $cmdLine = "dfscmd /unmap";
  215. $cmdLine .= " $dfslink->{DfsRoot}";
  216. logmsg ("Running: $cmdLine");
  217. @cmdOutput = `$cmdLine`;
  218. logmsg ("@cmdOutput");
  219. }
  220. if ( $dfslink->{Condition} =~ $quality )
  221. {
  222. # Create dfs links
  223. logmsg ("Create the dfslinks...");
  224. $cmdLine = "dfscmd /map";
  225. $cmdLine .= " $dfslink->{DfsRoot}";
  226. $cmdLine .= " $dfslink->{FileShare}";
  227. $cmdLine .= " \"$dfslink->{Comment}\"";
  228. logmsg ("Running: $cmdLine");
  229. @cmdOutput = `$cmdLine`;
  230. logmsg ("@cmdOutput");
  231. }
  232. }
  233. return 1;
  234. }
  235. sub DumpHash
  236. {
  237. my ($ah_dfs) = @_;
  238. my $dfslink;
  239. my @ah_dfs = @$ah_dfs;
  240. logmsg ("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
  241. for $dfslink (@ah_dfs)
  242. {
  243. logmsg ("***************************************");
  244. logmsg ("DfsLink: $dfslink->{DfsRoot}");
  245. logmsg ("FileShare: $dfslink->{FileShare}");
  246. logmsg ("Comment: $dfslink->{Comment}");
  247. logmsg ("Condition: $dfslink->{Condition}");
  248. }
  249. logmsg ("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
  250. return 1;
  251. }