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.

305 lines
9.2 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM incCatSign.cmd - surajp
  4. @REM
  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 Logmsg;
  16. use PbuildEnv;
  17. use ParseArgs;
  18. use File::Basename;
  19. use Updcat;
  20. use Data::Dumper;
  21. sub Usage { print<<USAGE; exit(1) }
  22. incCatSign -list:picklist.txt -mapfile:spmap.txt
  23. USAGE
  24. sub Dependencies {
  25. if ( !open DEPEND, ">>$ENV{_NTPOSTBLD}\\..\\build_logs\\dependencies.txt" ) {
  26. errmsg("Unable to open dependency list file.");
  27. die;
  28. }
  29. print DEPEND<<DEPENDENCIES;
  30. \[$0\]
  31. IF { nt5.cat nt5inf.cat }
  32. ADD {
  33. idw\\srvpack\\spmap.txt
  34. idw\\srvpack\\filelist.txt
  35. }
  36. DEPENDENCIES
  37. close DEPEND;
  38. exit;
  39. }
  40. my ($picklist,$path,$mapfile);
  41. my (%goldhash,%map);
  42. my (@line);
  43. my $qfe;
  44. parseargs('?' => \&Usage,
  45. 'plan' => \&Dependencies,
  46. 'qfe:' => \$qfe);
  47. my $sp = 'SP1';
  48. my $sp_file = "$ENV{_NTPOSTBLD}\\..\\build_logs\\files.txt";
  49. my $map_file = "$ENV{_NTPOSTBLD}\\idw\\srvpack\\spmap.txt";
  50. my $list_file = "$ENV{_NTPOSTBLD}\\idw\\srvpack\\filelist.txt";
  51. my $drm_list = "$ENV{RAZZLETOOLPATH}\\sp\\data\\drmlist.txt";
  52. my %sku;
  53. if ($ENV{_BuildArch} =~/x86/i ){ %sku=(PRO=>1,PER=>1);}
  54. else {%sku=(PRO=>1);}
  55. system("del $ENV{_NTPOSTBLD}\\nt5.cat >nul 2>nul");
  56. system("del $ENV{_NTPOSTBLD}\\nt5inf.cat >nul 2>nul");
  57. if (defined $sku{PER}) {
  58. system("del $ENV{_NTPOSTBLD}\\perinf\\nt5inf.cat >nul 2>nul");
  59. }
  60. if ( -f "$ENV{_NTPOSTBLD}\\..\\build_logs\\skip.txt" ) {
  61. if ( !open SKIP, "$ENV{_NTPOSTBLD}\\..\\build_logs\\skip.txt" ) {
  62. errmsg("Unable to open skip list file.");
  63. die;
  64. }
  65. while (<SKIP>) {
  66. chomp;
  67. exit if lc$_ eq lc$0;
  68. }
  69. close SKIP;
  70. }
  71. my %infdirs = (
  72. "ip\\" => "",
  73. "ic\\" => "perinf\\",
  74. "is\\" => "srvinf\\",
  75. "ia\\" => "entinf\\",
  76. "id\\" => "dtsinf\\",
  77. "il\\" => "sbsinf\\",
  78. "ib\\" => "blainf\\",
  79. "lang\\"=> "lang\\"
  80. );
  81. my( $IsCoverageBuild ) = $ENV{ "_COVERAGE_BUILD" };
  82. if(!$IsCoverageBuild) {
  83. $path = "$ENV{RazzleToolPath}\\sp\\data\\catalog\\$ENV{lang}\\$ENV{_BuildArch}$ENV{_BUildType}";
  84. }
  85. else{
  86. $path = "$ENV{RazzleToolPath}\\sp\\data\\catalog\\cov\\$ENV{_BuildArch}$ENV{_BUildType}";
  87. }
  88. logmsg("Catalog Path is $path");
  89. sys("copy $path\\nt5.cat $ENV{_NTPOSTBLD}");
  90. sys("copy $path\\nt5inf.cat $ENV{_NTPOSTBLD}");
  91. if (defined $sku{PER}) {
  92. sys("copy $path\\perinf\\nt5inf.cat $ENV{_NTPOSTBLD}\\perinf");
  93. }
  94. #######Add when required for other SKUs############
  95. # Get a list of source paths from spmap.
  96. my %spmap = ();
  97. open MAP, $map_file or die "unable to open map file: $!";
  98. while (<MAP>) {
  99. $_ = lc$_;
  100. my ($src, $dst) = /(\S+)\s+(\S+)/;
  101. if ($dst =~ /\_$/) {
  102. $dst =~ s/\_$/substr $src, -1/e;
  103. }
  104. $spmap{$dst} = $src;
  105. }
  106. close MAP;
  107. # Find the skus for each source file.
  108. my %map = ();
  109. open LIST, $list_file or die "unable to open list file: $!";
  110. foreach ( <LIST> ){
  111. chomp;
  112. $_ = lc$_;
  113. my ($path, $file) = /^(.*\\)?([^\\]*)$/;
  114. next if $path =~ /^wow\\/i;
  115. my $src;
  116. if ( !exists $spmap{$_} ) {
  117. $src = $infdirs{$path} . $file;
  118. $src = $file if !-e "$ENV{_NTPOSTBLD}\\$src";
  119. } else {
  120. $src = $spmap{$_};
  121. }
  122. my $file_base = basename($src);
  123. $map{$file_base} = {$src => ""} if !defined $map{$file_base};
  124. if ($path =~ /new\\ip/i){
  125. ${$map{$file_base}}{$src} = ["PRO",1];
  126. }
  127. elsif($path =~ /new\\ic/i){
  128. ${$map{$file_base}}{$src} = ["PER",1];
  129. }
  130. elsif($path =~ /new\\/i){
  131. ${$map{$file_base}}{$src} = ["ALL",1];
  132. }
  133. elsif($path =~ /ip\\/i){
  134. ${$map{$file_base}}{$src} = ["PRO",0];
  135. }
  136. elsif($path =~ /ic\\/i){
  137. ${$map{$file_base}}{$src} = ["PER",0];
  138. }
  139. else{
  140. ${$map{$file_base}}{$src} = ["ALL",0];
  141. }
  142. }
  143. close LIST;
  144. open NT5, "$path\\nt5.hash" or die $!;
  145. open NT5INF_PRO , "$path\\nt5inf.hash" or die $!;
  146. if (defined $sku{PER}) {
  147. open NT5INF_PER , "$path\\perinf\\nt5inf.hash" or die $!;
  148. }
  149. foreach ( <NT5> ) {
  150. my ($fullname, $hash) = /(\S+) - (\S+)/;
  151. my $name = basename($fullname);
  152. $goldhash{$name}{HASH} = $hash;
  153. push @{$goldhash{$name}{CATS}}, 'nt5.cat';
  154. }
  155. foreach ( <NT5INF_PRO> ) {
  156. my ($fullname, $hash) = /(\S+) - (\S+)/;
  157. my $name = basename($fullname);
  158. $goldhash{$name}{HASH} = $hash;
  159. push @{$goldhash{$name}{CATS}}, 'nt5inf.cat';
  160. }
  161. if (defined $sku{PER}) {
  162. foreach ( <NT5INF_PER> ) {
  163. my ($fullname, $hash) = /(\S+) - (\S+)/;
  164. my $name = basename($fullname);
  165. $goldhash{$name}{HASH} = $hash;
  166. push @{$goldhash{$name}{CATS}}, 'perinf\\nt5inf.cat';
  167. }
  168. }
  169. close NT5;
  170. close NT5INF_PRO;
  171. if (defined $sku{PER}) {
  172. close NT5INF_PER;
  173. }
  174. open DRM, $drm_list or die "unable to open DRM file list $drm_list: $!";
  175. my %drm_list = map { /(.*):(.*)/ ? (lc $1 => $2) : () } <DRM>;
  176. close DRM;
  177. open F, $sp_file or die "unable to open file list: $!";
  178. my %remove_hashes = ( 'nt5.cat' => [],
  179. 'nt5inf.cat' => [],
  180. 'perinf\\nt5inf.cat' => [] );
  181. my %add_file_sigs = ( 'nt5.cat' => [],
  182. 'nt5inf.cat' => [],
  183. 'perinf\\nt5inf.cat' => [] );
  184. my %add_drm_list = ( 'nt5.cat' => [],
  185. 'nt5inf.cat' => [],
  186. 'perinf\\nt5inf.cat' => [] );
  187. foreach ( <F> ){
  188. chomp;
  189. my $flag;
  190. ($flag, $_) = /^([^\;\s]*\s+)?([^\;\s]+)/;
  191. next if $_ eq "";
  192. next if /\.ca[bt]$/i;
  193. my $basename_file = lc basename($_);
  194. (my $name = $_) =~ s/^lang\\//i;
  195. if ( $flag =~ /d/i ) {
  196. next if $flag =~ /m/i;
  197. if (exists $goldhash{$name}){
  198. for my $cat (@{$goldhash{$name}{CATS}}) {
  199. if ( !exists $remove_hashes{lc$cat} ) {
  200. die "Unrecognized catalog $cat";
  201. }
  202. push @{$remove_hashes{lc$cat}}, $goldhash{$name}{HASH};
  203. #system("updcat.exe $ENV{_NTPostBld}\\$cat -d $goldhash{$name}{HASH}");
  204. }
  205. }
  206. }
  207. if ( defined($map{$basename_file}) ){
  208. foreach ( keys( %{$map{$basename_file}} ) ) {
  209. if (!-e "$ENV{_NTPostBld}\\$_") { next }
  210. if (exists $goldhash{$name}){
  211. for my $cat (@{$goldhash{$name}{CATS}}) {
  212. if ( !exists $remove_hashes{lc$cat} ) {
  213. die "Unrecognized catalog $cat";
  214. }
  215. push @{$remove_hashes{lc$cat}}, $goldhash{$name}{HASH};
  216. #system("updcat.exe $ENV{_NTPostBld}\\$cat -d $goldhash{$name}{HASH}");
  217. }
  218. }
  219. if (${ $map{$basename_file} }{$_}[0] eq "ALL" ){
  220. push @{$add_file_sigs{'nt5.cat'}}, "$ENV{_NTPostBld}\\$_";
  221. push @{$add_file_sigs{'nt5inf.cat'}}, "$ENV{_NTPostBld}\\$_" if !defined $sku{PER};
  222. if ( defined $drm_list{$basename_file} ) {
  223. push @{$add_drm_list{'nt5.cat'}}, ["$ENV{_NTPostBld}\\$_"=>$drm_list{$basename_file}];
  224. push @{$add_drm_list{'nt5inf.cat'}},["$ENV{_NTPostBld}\\$_"=> $drm_list{$basename_file}] if (!defined $sku{PER}) ;
  225. }
  226. #system("updcat.exe $ENV{_NTPostBld}\\nt5.cat -a $ENV{_NTPostBld}\\$_");
  227. }
  228. elsif (${ $map{$basename_file} }{$_}[0] eq "PRO" ){
  229. push @{$add_file_sigs{'nt5inf.cat'}}, "$ENV{_NTPostBld}\\$_";
  230. if ( defined $drm_list{$basename_file} ) {
  231. push @{$add_drm_list{'nt5inf.cat'}},["$ENV{_NTPostBld}\\$_"=>$drm_list{$basename_file}];
  232. }
  233. #system("updcat.exe $ENV{_NTPostBld}\\nt5inf.cat -a $ENV{_NTPostBld}\\$_");
  234. }
  235. else {
  236. if (defined $sku{PER}) {
  237. push @{$add_file_sigs{'perinf\\nt5inf.cat'}}, "$ENV{_NTPostBld}\\$_";
  238. if ( defined $drm_list{$basename_file} ) {
  239. push @{$add_drm_list{'perinf\\nt5inf.cat'}}, ["$ENV{_NTPostBld}\\$_"=>$drm_list{$basename_file}];
  240. }
  241. #system("updcat.exe $ENV{_NTPostBld}\\perinf\\nt5inf.cat -a $ENV{_NTPostBld}\\$_");
  242. }
  243. }
  244. }
  245. }
  246. }
  247. close F;
  248. if ( @{$remove_hashes{'nt5.cat'}} ||
  249. @{$add_file_sigs{'nt5.cat'}} ) {
  250. Updcat::Update( "$ENV{_NTPostBld}\\nt5.cat", $remove_hashes{'nt5.cat'}, $add_file_sigs{'nt5.cat'}, $add_drm_list{'nt5.cat'} ) || die Updcat::GetLastError();
  251. }
  252. sys("ntsign $ENV{_NTPostBld}\\nt5.cat");
  253. if ( @{$remove_hashes{'nt5inf.cat'}} ||
  254. @{$add_file_sigs{'nt5inf.cat'}} ) {
  255. Updcat::Update( "$ENV{_NTPostBld}\\nt5inf.cat", $remove_hashes{'nt5inf.cat'}, $add_file_sigs{'nt5inf.cat'} , $add_drm_list{'nt5inf.cat'}) || die Updcat::GetLastError();
  256. }
  257. sys("ntsign $ENV{_NTPostBld}\\nt5inf.cat");
  258. if (defined $sku{PER}) {
  259. if ( @{$remove_hashes{'perinf\\nt5inf.cat'}} ||
  260. @{$add_file_sigs{'perinf\\nt5inf.cat'}} ) {
  261. Updcat::Update( "$ENV{_NTPostBld}\\perinf\\nt5inf.cat", $remove_hashes{'perinf\\nt5inf.cat'}, $add_file_sigs{'perinf\\nt5inf.cat'} , $add_drm_list{'perinf\nt5inf.cat'}) || die Updcat::GetLastError();
  262. }
  263. sys("ntsign $ENV{_NTPostBld}\\perinf\\nt5inf.cat");
  264. }
  265. sub sys {
  266. my $cmd = shift;
  267. print "$cmd\n";
  268. system($cmd);
  269. if ($?) {
  270. die "ERROR: $cmd ($?)\n";
  271. }
  272. }