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.

213 lines
5.2 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM spinfs.cmd - JeremyD
  4. @REM Update layout.inf and drvindex.inf for SP skus
  5. @REM
  6. @REM Copyright (c) Microsoft Corporation. All rights reserved.
  7. @REM
  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 lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts\\svcpack";
  16. use PbuildEnv;
  17. use ParseArgs;
  18. use SP;
  19. use Utils;
  20. sub Usage { print<<USAGE; exit(1) }
  21. <<Insert your usage message here>>
  22. USAGE
  23. parseargs('?' => \&Usage);
  24. my $sp_cab_tag = 'SP1';
  25. my $sp_cab_file = 'SP1.cab';
  26. my $cache;
  27. sub is_sp {
  28. my $file = shift;
  29. if (!$cache->{files}) {
  30. my $fh = IO::File->new("$ENV{_NTPOSTBLD}\\SP\\data\\files.txt", 'r');
  31. while (!$fh->eof) {
  32. my $line = $fh->getline;
  33. chomp($line);
  34. my ($cdpath, $filename) = split /\t/, $line;
  35. $cache->{files}{lc $filename} = $cdpath;
  36. }
  37. }
  38. return $cache->{files}{lc $file};
  39. }
  40. sub is_sp_driver {
  41. my $file = shift;
  42. if (!$cache->{drivers}) {
  43. my $fh = IO::File->new("$ENV{_NTPOSTBLD}\\SP\\data\\drivers.txt", 'r');
  44. while (!$fh->eof) {
  45. my $line = $fh->getline;
  46. chomp($line);
  47. $cache->{drivers}{lc $line} = $line;
  48. }
  49. }
  50. return $cache->{drivers}{lc $file};
  51. }
  52. sub update_drvindex {
  53. my $sku = shift;
  54. my @files;
  55. my $drvindex = Utils::inf_file($sku, 'drvindex.inf');
  56. my $spdrvindex = "$ENV{_NTPOSTBLD}\\SP\\$sku\\drvindex.inf";
  57. open FILE, "$drvindex" or die "unable to open $drvindex: $!";
  58. my @input = <FILE>;
  59. close FILE;
  60. open FILE, ">$spdrvindex" or die "unable to open $spdrvindex: $!";
  61. my $read_flag = 0;
  62. for (@input) {
  63. chomp;
  64. if (/^\[driver\]$/i) {
  65. $read_flag = 1;
  66. }
  67. elsif (/^\[cabs\]$/i) {
  68. print FILE "[$sp_cab_tag]\n";
  69. print FILE "$_\n" for @files;
  70. print FILE "\n";
  71. }
  72. elsif (/^\[/) {
  73. $read_flag = 0;
  74. }
  75. else {
  76. if ($read_flag) {
  77. if (is_sp_driver($_)) {
  78. push @files, $_;
  79. next;
  80. }
  81. }
  82. }
  83. s/(CabFiles=)(.*)/$1$sp_cab_tag,$2/i;
  84. print FILE $_, "\n";
  85. }
  86. print FILE "$sp_cab_tag=$sp_cab_file\n";
  87. close FILE;
  88. }
  89. sub update_layout {
  90. my $sku = shift;
  91. my @files;
  92. my $layout = Utils::inf_file($sku, 'layout.inf');
  93. my $splayout = "$ENV{_NTPOSTBLD}\\SP\\$sku\\layout.inf";
  94. open FILE, "$layout" or die "unable to open $layout: $!";
  95. my @input = <FILE>;
  96. close FILE;
  97. open FILE, ">$splayout" or die "unable to open $splayout: $!";
  98. my $read_flag = 0;
  99. for (@input) {
  100. if (/^\[sourcedisksfiles(.*)\]$/i) {
  101. $read_flag = 1;
  102. }
  103. elsif (/^\[/) {
  104. $read_flag = 0;
  105. }
  106. else {
  107. if ($read_flag) {
  108. my ($file) = /^([^\s=]+)/;
  109. if (is_sp($file) or is_sp_driver($file)) {
  110. s/(=\s*)[12],/${1}100,/;
  111. }
  112. }
  113. }
  114. print FILE $_;
  115. }
  116. print FILE "\n[SourceDisksFiles]\nSP1.cab = 100,,22222,,,,_x,39,0,0\n";
  117. close FILE;
  118. }
  119. sub update_dosnet {
  120. my $sku = shift;
  121. my @files;
  122. my $dosnet = Utils::inf_file($sku, 'dosnet.inf');
  123. my $spdosnet = "$ENV{_NTPOSTBLD}\\SP\\$sku\\dosnet.inf";
  124. open FILE, "$dosnet" or die "unable to open $dosnet: $!";
  125. my @input = <FILE>;
  126. close FILE;
  127. open FILE, ">$spdosnet" or die "unable to open $spdosnet: $!";
  128. my $read_flag = 0;
  129. my $spcab_flag = 0;
  130. for (@input) {
  131. print FILE $_;
  132. }
  133. print FILE "\n[Files]\nd1,SP1.cab\n";
  134. close FILE;
  135. }
  136. sub update_txtsetup {
  137. my $sku = shift;
  138. my @files;
  139. my $txtsetup = Utils::inf_file($sku, 'txtsetup.sif');
  140. my $sptxtsetup = "$ENV{_NTPOSTBLD}\\SP\\$sku\\txtsetup.sif";
  141. open FILE, "$txtsetup" or die "unable to open $txtsetup: $!";
  142. my @input = <FILE>;
  143. close FILE;
  144. open FILE, ">$sptxtsetup" or die "unable to open $sptxtsetup: $!";
  145. my $read_flag = 0;
  146. for (@input) {
  147. if (/^\[sourcedisksfiles(.*)\]$/i) {
  148. $read_flag = 1;
  149. }
  150. elsif (/^\[/) {
  151. $read_flag = 0;
  152. }
  153. else {
  154. if ($read_flag) {
  155. my ($file) = /^([^\s=]+)/;
  156. if (is_sp($file) or is_sp_driver($file)) {
  157. s/(=\s*)[12],/${1}100,/;
  158. }
  159. }
  160. }
  161. s/(DriverCabName=.*)/$1,$sp_cab_file/i;
  162. print FILE $_;
  163. if (/driver.cab = 16/) {
  164. print FILE "$sp_cab_file = 16\n";
  165. }
  166. }
  167. print FILE "\n[SourceDisksFiles]\n$sp_cab_file = 100,,22222,,,,_x,39,0,0\n";
  168. close FILE;
  169. }
  170. for my $sku (SP::sp_skus()) {
  171. Utils::mkdir("$ENV{_NTPOSTBLD}\\SP\\$sku");
  172. update_layout($sku);
  173. update_drvindex($sku);
  174. update_dosnet($sku);
  175. update_txtsetup($sku);
  176. }