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.

229 lines
4.8 KiB

  1. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  2. use lib $ENV{RAZZLETOOLPATH};
  3. use IO::File;
  4. use Logmsg;
  5. $uncomppath=shift;
  6. $comppath=shift;
  7. my ($dircomp,$diruncomp,$diruncompPrune,$dircompPrune);
  8. open SP , "SpecialAddedFiles.txt" or die $?;
  9. foreach (<SP>){
  10. if ( /(.*)\t(.*$)/ ){
  11. sys(" copy $ENV{_NTPOSTBLD}\\$1 $comppath\\..\\$2");
  12. sys(" copy $ENV{_NTPOSTBLD}\\$1 $uncomppath\\..\\$2");
  13. }
  14. }
  15. close SP;
  16. createNewFile($uncomppath);
  17. sys("move $uncomppath\\tagfile.1 $comppath\\tagfile.1");
  18. sys("copy $uncomppath\\new\\update2.inf $comppath\\new\\update2.inf");
  19. $diruncompPrune=makeList($uncomppath,1);
  20. print "paths $uncomppath :::$comppath\n";
  21. open UNCOMP_IMAGE,"+>","$ENV{tmp}\\sp-image";
  22. foreach (@$diruncompPrune)
  23. {
  24. print UNCOMP_IMAGE "$_ \n";
  25. }
  26. $cmd = "updater.cmd -db:InfSections.tbl -entries:$ENV{tmp}\\sp-image -inf:$ENV{_NTPOSTBLD}\\idw\\srvpack\\update.inf -out:$uncomppath\\update\\update.inf"; # -trim";
  27. sys($cmd);
  28. $cmd = "vertool.exe $uncomppath\\update\\update.inf \/out:$uncomppath\\update\\update.ver \/files:$uncomppath";
  29. sys($cmd);
  30. sys("copy $uncomppath\\update\\update.inf $comppath\\update\\update.inf");
  31. sys("copy $uncomppath\\update\\update.ver $comppath\\update\\update.ver");
  32. ########making sp1.cat
  33. $diruncomp=makeList($uncomppath,0);
  34. makecdf($diruncomp,$uncomppath);
  35. my $cmd="makecat $ENV{tmp}\\sp.cdf";
  36. sys($cmd);
  37. $cmd="ntsign $uncomppath\\update\\SP1.CAT";
  38. sys("$cmd");
  39. sys("copy $uncomppath\\update\\SP1.CAT $comppath\\update\\SP1.CAT");
  40. #signing done
  41. ##################makinf cab file###############################
  42. $diruncompPrune = makeList($comppath,0);
  43. makeddf($diruncompPrune ,$comppath);
  44. $cmd ="makecab /f $ENV{tmp}\\sp.ddf";
  45. sys($cmd);
  46. #######MAKING THE FINAL EXE###############
  47. sys("makesfx $ENV{_NTPOSTBLD}\update\xpsp1.cab $ENV{_NTPOSTBLD}\update\xpsp1.exe /RUN");
  48. #############END##########################
  49. exit (0);
  50. sub makeList
  51. {
  52. my $path = shift;
  53. my $prune = shift;
  54. print "$path \n";
  55. system("dir /b /s /a-d $path >$ENV{tmp}\\recursiveDir.txt");
  56. open recur_file,"$ENV{tmp}\\recursiveDir.txt";
  57. my @line;
  58. foreach ( <recur_file> )
  59. {
  60. chomp;
  61. if( /.*?\\i386\\(.*)$/ )
  62. {
  63. push @line,$1;
  64. }
  65. }
  66. close(recur_file);
  67. my $file_name="spimageprune.txt";
  68. if ($prune)
  69. {return pruner(\@line,$file_name);}
  70. else
  71. {
  72. return \@line ;}
  73. }
  74. sub pruner
  75. {
  76. my $input = shift;
  77. my $filter_file = shift;
  78. my $outputfile = shift;
  79. my @lines;
  80. open FILE, $filter_file or die $!;
  81. my @exclude_strs = <FILE>;
  82. chomp(@exclude_strs);
  83. close FILE;
  84. my $exclude_re = join '|', map { quotemeta($_) } @exclude_strs;
  85. foreach (@$input){
  86. if (!(/$exclude_re/o)) {
  87. # print SP_IMAGE "$_ \n";
  88. push @lines,$_;
  89. }
  90. else {
  91. #print "excluded $_ \n";
  92. }
  93. }
  94. close FILE;
  95. return \@lines;
  96. }
  97. sub sys {
  98. my $cmd = shift;
  99. print "$cmd\n";
  100. system($cmd);
  101. if ($?) {
  102. die "ERROR: $cmd ($?)\n";
  103. }
  104. # if ($?) {
  105. # my $errorcode=$?>>8;
  106. # die "ERROR: $cmd (". $errorcode . ")\n";
  107. # }
  108. }
  109. sub makecdf {
  110. my $file=shift;
  111. my $path=shift;
  112. open CDF ,"+>" , "$ENV{tmp}\\sp.cdf" or die $!;
  113. #open FILE,$file or die $!;
  114. print CDF "[CatalogHeader] \n";
  115. print CDF "Name=$uncomppath\\update\\SP1.cat\n";
  116. print CDF "PublicVersion=0x0000001 \n";
  117. print CDF "EncodingType=0x00010001 \n";
  118. print CDF "CATATTR1=0x10010001:OSAttr:2:5.1 \n";
  119. print CDF "[CatalogFiles] \n";
  120. foreach (@$file)
  121. {
  122. chomp;
  123. if (!(/\.cat/i)){
  124. print CDF "<hash>$path\\$_=$path\\$_ \n";
  125. }
  126. }
  127. close CDF;
  128. #close FILE;
  129. }
  130. sub makeddf
  131. {
  132. my $file=shift;
  133. my $path=shift;
  134. my ($line,@update);
  135. open DDF,"+>", "$ENV{tmp}\\sp.ddf";
  136. #open FILE, $file;
  137. print DDF ".option explicit \n";
  138. print DDF ".set DiskDirectoryTemplate=$ENV{_NTPOSTBLD}\update \n";
  139. print DDF ".set CabinetName1=xpsp1.cab \n";
  140. print DDF ".set SourceDir=$path \n";
  141. print DDF ".set RptFileName=nul \n";
  142. print DDF ".set InfFileName=nul \n";
  143. print DDF ".set MaxDiskSize=999948288 \n";
  144. print DDF ".set Compress=on \n";
  145. print DDF ".set Cabinet=on\n";
  146. print DDF ".set CompressionType=LZX\n";
  147. print DDF ".set CompressionMemory=21\n";
  148. foreach (@$file)
  149. {
  150. chomp;
  151. if (!(/^update\\/i))
  152. {
  153. print DDF "$_ $_ \n"
  154. }
  155. else {push @update ,$_;}
  156. }
  157. print DDF ".set DestinationDir=\"update\" \n";
  158. print DDF ".New Folder \n";
  159. foreach (@update)
  160. {
  161. if (/\\update\.exe$/i)
  162. { print DDF "\"$_\" /RUN \n"; }
  163. else
  164. {print DDF "\"$_\" \n";}
  165. }
  166. close DDF;
  167. }
  168. sub createNewFile
  169. {
  170. $PATH1=shift;
  171. open TAG ,"+>","$PATH1\\tagfile.1";
  172. print TAG " ";
  173. close TAG;
  174. open TAG ,"+>","$PATH1\\new\\update2.inf";
  175. print TAG "[Version]\n";
  176. print TAG " Signature=$Windows NT$\n";
  177. print TAG "[Data]\n";
  178. print TAG " Pid=P8PBW-XQHQX-YQV2J-2BY3V-CB2J8\n";
  179. close TAG;
  180. }