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.

243 lines
6.4 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM makeupdatemap.cmd - jtolman
  5. REM Maps out the update directory structure, and generates update.inf
  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} . "\\sp";
  16. use lib $ENV{RAZZLETOOLPATH};
  17. use PbuildEnv;
  18. use ParseArgs;
  19. use File::Basename;
  20. use File::Copy;
  21. use File::Path;
  22. use Logmsg;
  23. use ParseTable;
  24. sub Usage { print<<USAGE; exit(1) }
  25. makeupdatemap [-l <language>] [-qfe <QFE_number>]
  26. Creates the update directory structure.
  27. USAGE
  28. sub Dependencies {
  29. if ( !open DEPEND, ">>$ENV{_NTPOSTBLD}\\..\\build_logs\\dependencies.txt" ) {
  30. errmsg("Unable to open dependency list file.");
  31. die;
  32. }
  33. print DEPEND<<DEPENDENCIES;
  34. \[$0\]
  35. IF {
  36. update.inf
  37. idw\\srvpack\\newinf.tbl
  38. idw\\srvpack\\filelist.txt
  39. } ADD {
  40. idw\\srvpack\\spmap.txt
  41. idw\\srvpack\\infsect.tbl
  42. idw\\srvpack\\infdiff.tbl
  43. idw\\srvpack\\update.inf
  44. idw\\srvpack\\hotfix.inf
  45. }
  46. IF { sfcfiles.dll }
  47. ADD {
  48. congeal_scripts\\autogen\\ia64_wks.h
  49. congeal_scripts\\autogen\\x86_wks.h
  50. congeal_scripts\\autogen\\x86_per.h
  51. }
  52. DEPENDENCIES
  53. close DEPEND;
  54. exit;
  55. }
  56. my $qfe;
  57. parseargs('?' => \&Usage,
  58. 'plan' => \&Dependencies,
  59. 'qfe:' => \$qfe);
  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 %skudirs = (
  72. "perinf\\"=>""
  73. );
  74. my $listname = "$ENV{_NTPOSTBLD}\\..\\build_logs\\files.txt";
  75. sub sys {
  76. my $cmd = shift;
  77. print "$cmd\n";
  78. system($cmd);
  79. if ($?) {
  80. die "ERROR: $cmd ($?)\n";
  81. }
  82. }
  83. sub unique {
  84. my ($list) = @_;
  85. my %temp = ();
  86. foreach my $ent ( @$list ) {
  87. $temp{$ent}++;
  88. }
  89. return keys %temp;
  90. }
  91. sub testf {
  92. my ($file) = @_;
  93. return 1 if -e "$ENV{_NTPOSTBLD}\\$file";
  94. wrnmsg "File not found, omitted: $file";
  95. return 0;
  96. }
  97. # Setting up the flag so that Copying the wow files can start on ia64 m/c
  98. sys "echo Q$qfe\> $ENV{_NTPostBld}\\build_logs\\CopyWowCanStart.txt" if $qfe;
  99. # First, need to generate the complete list of files that go into update.inf
  100. sys "touch /c $ENV{_NTPOSTBLD}\\nt5.cat";
  101. sys "touch /c $ENV{_NTPOSTBLD}\\nt5inf.cat";
  102. sys "touch /c $ENV{_NTPOSTBLD}\\perinf\\nt5inf.cat" if $ENV{386};
  103. # Figure out which ones go in lang\
  104. my %lang;
  105. my $langdir = "$ENV{_NTPOSTBLD}\\lang";
  106. foreach my $file ( `dir /a-d /b $langdir` ) {
  107. $file =~ s/\s*$//;
  108. $file = lc $file;
  109. next if $file =~ /\\/;
  110. $lang{$file}++;
  111. }
  112. # See what directories are handed to us.
  113. my %spmap;
  114. open MAP, "$ENV{_NTPOSTBLD}\\idw\\srvpack\\spmap.txt" or die "spmap open failed: $!";
  115. while (<MAP>) {
  116. $_ = lc$_;
  117. my ($src, $dst) = /(\S+)\s+(\S+)/;
  118. my ($spath, $sfile) = $src =~ /^(.*\\)?([^\\]*)$/;
  119. my ($dpath, $dfile) = $dst =~ /^(.*\\)?([^\\]*)$/;
  120. my $key = $spath;
  121. $key =~ s/^(lang|...inf)\\//;
  122. $key .= $sfile;
  123. if ($dfile =~ /\_$/) {
  124. $dfile =~ s/\_$/substr $sfile, -1/e;
  125. }
  126. $dpath = "\\" if $dpath !~ /\\/;
  127. $dst = "$dpath$dfile";
  128. $spmap{$key} = [ () ] if !exists $spmap{$key};
  129. push @{ $spmap{$key} }, $dst;
  130. }
  131. # Add the main files.
  132. my $templist = "$ENV{TEMP}\\templist\.$ENV{_BUILDARCH}$ENV{_BUILDTYPE}.txt";
  133. open OUT, ">$templist" or die "temp file open failed: $!";
  134. open LIST, ">$ENV{_NTPOSTBLD}\\idw\\srvpack\\filelist.txt" or die "list file open failed: $!";
  135. open SP, "$listname" or die "file list open failed: $!";
  136. while (<SP>) {
  137. my ($tag, $file) = /^([^\;\s]*\s+)?([^\;\s]+)/;
  138. next if $file eq "";
  139. $file = lc $file;
  140. next if $tag =~ /c/i;
  141. if ( $tag =~ /s/i ) {
  142. if ( exists $spmap{$file} ) {
  143. foreach my $file ( unique($spmap{$file}) ) {
  144. $file =~ s/^\\//;
  145. print LIST "$file\n";
  146. }
  147. }
  148. }
  149. elsif ( exists $spmap{$file} ) {
  150. foreach my $file ( unique($spmap{$file}) ) {
  151. $file =~ /^(.*\\)?([^\\]*)$/;
  152. if ( !defined $1 or $1 =~ /^(new|lang|[im].)?\\$/ or $tag =~ /m/ ) {
  153. print OUT "$tag\E$file\n";
  154. } else {
  155. $file =~ s/^\\//;
  156. print LIST "$file\n";
  157. }
  158. }
  159. }
  160. elsif ( exists $lang{$file} ) {
  161. print OUT "$tag\Elang\\$file\n";
  162. } else {
  163. my $del = $tag =~ /d/i;
  164. print OUT "$tag\E$file\n" if $del or testf $file;
  165. if ( $del and lc$ENV{_BUILDARCH} eq "ia64" and $tag !~ /w/i ) {
  166. print OUT "$tag\Ewow\\w$file\n";
  167. print OUT "$tag\Ewow\\lang\\w$file\n";
  168. }
  169. }
  170. }
  171. close SP;
  172. close LIST;
  173. # Add wow files.
  174. if ( lc$ENV{_BUILDARCH} eq "ia64" ) {
  175. my $wowdir = "$ENV{_NTPOSTBLD}\\wowbins";
  176. foreach my $file ( `dir /a-d /b $wowdir` ) {
  177. $file =~ s/\s*$//;
  178. $file = lc $file;
  179. next if $file =~ /\\/;
  180. print OUT "\twow\\$file\n";
  181. }
  182. foreach my $file ( `dir /a-d /b $wowdir\\lang` ) {
  183. $file =~ s/\s*$//;
  184. $file = lc $file;
  185. next if $file =~ /\\/;
  186. print OUT "\twow\\lang\\$file\n";
  187. }
  188. }
  189. close OUT;
  190. # Substitute in the qfe number.
  191. my $spdir = "$ENV{_NTPOSTBLD}\\idw\\srvpack";
  192. if ( $qfe ) {
  193. if ( !open HOT, "$spdir\\hotfix.inf" ) {
  194. errmsg "Unable to open hotfix.inf: $!";
  195. die;
  196. }
  197. if ( !open HOT2, ">$spdir\\hotfix1.inf" ) {
  198. errmsg "Unable to open hotfix1.inf: $!";
  199. die;
  200. }
  201. while (<HOT>) {
  202. s/\%QNUM\%/Q$qfe/g;
  203. print HOT2;
  204. }
  205. close HOT;
  206. close HOT2;
  207. }
  208. # Make the output files.
  209. my $basedir = "$ENV{RAZZLETOOLPATH}\\sp\\data\\changes";
  210. my $change = "/c:$basedir\\all.txt" if -f "$basedir\\all.txt";
  211. if ( opendir CHANGE, $basedir ) {
  212. my @files = readdir CHANGE;
  213. foreach (@files) {
  214. my $cfile = "";
  215. $cfile = "$basedir\\$_" if /^(new\.)?($ENV{_BUILDARCH}\.)?($ENV{LANG}\.)?txt$/i;
  216. next if $cfile eq "";
  217. $change .= " /c:$cfile";
  218. }
  219. }
  220. my $_q = $qfe ? "-qfe":"";
  221. system("del $ENV{_NTPOSTBLD}\\update.inf >nul 2>&1");
  222. sys("$ENV{RAZZLETOOLPATH}\\sp\\findinfdata.cmd $ENV{_NTPOSTBLD} /f:$spdir\\newinf.tbl $change /xs /i /b /l $ENV{LANG}");
  223. sys("$ENV{RAZZLETOOLPATH}\\sp\\updater.cmd -trim -entries:$templist /c $ENV{RAZZLETOOLPATH}\\sp\\data\\changes\\inf.txt $_q");