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.

173 lines
4.1 KiB

  1. use strict;
  2. use File::Basename;
  3. use File::Copy;
  4. use File::Path;
  5. use lib $ENV{RAZZLETOOLPATH} . "\\sp";
  6. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  7. use lib $ENV{RAZZLETOOLPATH};
  8. use PbuildEnv;
  9. use ParseArgs;
  10. use Logmsg;
  11. use Data::Dumper;
  12. use File::Basename;
  13. sub Usage { print<<USAGE; exit(1) }
  14. perl planpackage.pl [-qfe <QFEnum>] [-prs]
  15. -qfe Make a QFE with a given QFE number;
  16. if omitted, make a service pack.
  17. -prs Need to prs sign during during package.
  18. Generate a complete list of files for filter, etc., then
  19. detemine which package scripts need to be run.
  20. USAGE
  21. my ($qfenum, $prs);
  22. parseargs('?' => \&Usage,
  23. 'qfe:' => \$qfenum,
  24. 'prs' => \$prs);
  25. my $listFile = "$ENV{RAZZLETOOLPATH}\\" . ($qfenum ? "qfelists\\Q$qfenum\.txt":"spfiles.txt");
  26. my $dir = "$ENV{_NTPOSTBLD}\\..\\build_logs";
  27. my $dbFile = "$dir\\dependencies.txt";
  28. my $qfearg = $qfenum ? "-qfe $qfenum":"";
  29. my $prsarg = $prs ? "-prs":"";
  30. my %qfe = ("..." => "\;");
  31. my %data;
  32. my @allcmds = ();
  33. my @skip = ();
  34. # Generate dependency file.
  35. sys("$ENV{RAZZLETOOLPATH}\\sp\\package.cmd -plan $qfearg $prsarg");
  36. # Read in the initial file list.
  37. if ( !open LIST, $listFile ) {
  38. errmsg "Unable to open $listFile $?";
  39. die;
  40. }
  41. while ( <LIST> ) {
  42. s/(\;.*)?\s*$//;
  43. next if !/^(?:(\S*)\s+)?(\S+)$/;
  44. addFile($1, lc$2);
  45. }
  46. close LIST;
  47. # Read in the dependency information.
  48. if ( !open DB, $dbFile ) {
  49. errmsg "Unable to open $dbFile: $?";
  50. die;
  51. }
  52. my $cont = "";
  53. my $cmd = "";
  54. foreach ( <DB> ) {
  55. s/(\#.*)?\s*$//;
  56. $_ = "$cont$_\n";
  57. if ( /^\s*\[([^\]]*)\]$/) {
  58. $cmd=lc$1;
  59. push @allcmds, $cmd;
  60. $cont = "";
  61. next;
  62. }
  63. if ( /\[\S*\]/ ) {
  64. wrnmsg "DB Parse failed:\n$_\n";
  65. $cont = "";
  66. next;
  67. }
  68. if ( !/IF\s*\{\s*([^\}]*\S)?\s*\}\s*ADD\s*\{\s*([^\}]*\S)?\s*\}/ ) {
  69. $cont = $_;
  70. next;
  71. }
  72. my ($op, $ip) = ($1, $2);
  73. $op = [ split /\s+/, lc$op ];
  74. $ip = [ split /\s+/, lc$ip ];
  75. push @{ $data{$cmd} }, [ ($op, $ip) ];
  76. $cont = "";
  77. }
  78. close DB;
  79. # Add files and scripts to the lists.
  80. foreach my $cmd (reverse @allcmds) {
  81. my $test = 0;
  82. my $pairs = $data{$cmd};
  83. foreach my $list (@$pairs) {
  84. my $op = $list->[0];
  85. my $ip = $list->[1];
  86. foreach my $file ( @$op ) {
  87. if ( exists $qfe{$file} and $qfe{$file} !~ /d/ ) {
  88. $test = 1;
  89. foreach my $add ( @$ip ) {
  90. next if $add =~ /^\\?\.\.\.$/;
  91. addFile("c", $add);
  92. }
  93. last;
  94. }
  95. }
  96. }
  97. push @skip, $cmd if !$test;
  98. }
  99. # Output the results.
  100. writeToFiles(\%qfe,\@skip);
  101. # Cleanup any messes from previous runs of timebuild.
  102. system("del /q $ENV{_NTPOSTBLD}\\..\\build_logs\\startprs.txt >nul 2>nul");
  103. system("del /q $ENV{_NTPOSTBLD}\\..\\build_logs\\langlist.txt >nul 2>nul");
  104. #Subroutines
  105. sub addFile {
  106. my ($flag, $file) = @_;
  107. if ( $flag =~ /c/ ) {
  108. (my $temp = $file) =~ s/\.\.\.$//;
  109. while ( $temp ne "" and $temp=~s/[^\\]*\\?$// ) {
  110. return if exists $qfe{"$temp\..."} and $qfe{"$temp\..."} !~ /\;/;
  111. }
  112. }
  113. $qfe{$file} = $flag if !exists $qfe{$file} or $qfe{$file} =~ /\;/;
  114. return if $flag =~ /d/;
  115. (my $temp = $file) =~ s/[^\\]*$/\*/ ;
  116. $qfe{$temp} = "\;" if !exists $qfe{$temp};
  117. while ( $file ne "" and $file=~s/[^\\]*\\?$// ) {
  118. $qfe{"$file\..."} = "\;" if !exists $qfe{"$file\..."};
  119. }
  120. }
  121. sub sys {
  122. my $cmd = shift;
  123. logmsg($cmd);
  124. my $err = system($cmd);
  125. $err = $err >> 8;
  126. if ($err) {
  127. errmsg("$cmd ($err)");
  128. die;
  129. }
  130. return $err;
  131. }
  132. sub writeToFiles {
  133. my $spfiles = shift;
  134. my $skiplist = shift;
  135. if ( !open FILES,">$dir\\files.txt" ) {
  136. errmsg "Unable to open $dir\\files.txt for write $?";
  137. die;
  138. }
  139. if ( !open SKIP,">$dir\\skip.txt" ) {
  140. errmsg "Unable to open $dir\\skip.txt for write $?";
  141. die;
  142. }
  143. foreach my $file (sort keys %$spfiles) {
  144. my $flag = $spfiles->{$file};
  145. next if $flag =~ /\;/;
  146. print FILES "$flag\t$file\n";
  147. }
  148. foreach (@$skiplist){
  149. print SKIP "$_\n";
  150. }
  151. close SKIP;
  152. close FILES;
  153. }