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.

145 lines
3.3 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM spcab.cmd - JeremyD
  5. REM Create SP driver cab file.
  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};
  16. use PbuildEnv;
  17. use ParseArgs;
  18. use File::Basename;
  19. use Logmsg;
  20. sub Usage { print<<USAGE; exit(1) }
  21. spcab [-l <language>]
  22. Create SP driver cab file. Uses data from spfiles.txt and 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 { sp1.cab }
  32. ADD {
  33. drvindex.inf
  34. idw\\srvpack\\spmap.txt
  35. }
  36. DEPENDENCIES
  37. close DEPEND;
  38. exit;
  39. }
  40. my $qfe;
  41. parseargs('?' => \&Usage,
  42. 'plan' => \&Dependencies,
  43. 'qfe:' => \$qfe);
  44. if ( -f "$ENV{_NTPOSTBLD}\\..\\build_logs\\skip.txt" ) {
  45. if ( !open SKIP, "$ENV{_NTPOSTBLD}\\..\\build_logs\\skip.txt" ) {
  46. errmsg("Unable to open skip list file.");
  47. die;
  48. }
  49. while (<SKIP>) {
  50. chomp;
  51. exit if lc$_ eq lc$0;
  52. }
  53. close SKIP;
  54. }
  55. my $sp = 'SP1';
  56. my $sp_file = "$ENV{RAZZLETOOLPATH}\\spfiles.txt";
  57. my $map_file = "$ENV{_NTPOSTBLD}\\idw\\srvpack\\spmap.txt";
  58. my $drv_pfile = "$ENV{_NTPOSTBLD}\\drvindex.inf";
  59. my $drv_cfile = "$ENV{_NTPOSTBLD}\\perinf\\drvindex.inf";
  60. my $ddf_file = "$ENV{_NTPOSTBLD}\\$sp.ddf";
  61. my %sp;
  62. open SP, $sp_file or die "sp file list open failed: $!";
  63. while (<SP>) {
  64. if (/^([^\;\s]*\s+)?([^\;\s]*\\)?([^\;\\\s]+)/) {
  65. my ($tag, $file) = ($1, $3);
  66. next if $tag =~ /d/i;
  67. $sp{lc $file}++;
  68. }
  69. }
  70. close SP;
  71. logmsg("creating ddf file $ddf_file");
  72. open DDF, ">$ddf_file" or die "ddf file open failed: $!";
  73. print DDF <<HEADER;
  74. .option explicit
  75. .set DiskDirectoryTemplate=$ENV{_NTPOSTBLD}
  76. .set CabinetName1=$sp.cab
  77. .set SourceDir=$ENV{_NTPOSTBLD}
  78. .set RptFileName=nul
  79. .set InfFileName=nul
  80. .set MaxDiskSize=999948288
  81. .set Compress=on
  82. .set Cabinet=on
  83. .set CompressionType=LZX
  84. .set CompressionMemory=21
  85. HEADER
  86. my %spmap;
  87. open MAP, $map_file or die "map file open failed: $!";
  88. while (<MAP>) {
  89. my ($bin, $upd) = /(\S+)\s+(\S+)/;
  90. my $key = lc basename($bin);
  91. $spmap{$key} = "" if !exists $spmap{$key};
  92. $spmap{$key} = $bin if $upd eq '--DRIVER--';
  93. }
  94. close MAP;
  95. my %drv;
  96. sub readDrvIndex {
  97. my ($file) = @_;
  98. open DRV, $file or die "drvindex file open failed: $!";
  99. while (<DRV>) { last if /\[sp1\]/i; }
  100. while (<DRV>) {
  101. last if /\[.*\]/i;
  102. $drv{lc$1}++ if /(\S+)/;
  103. }
  104. close DRV;
  105. }
  106. readDrvIndex($drv_pfile);
  107. readDrvIndex($drv_cfile) if -f $drv_cfile;
  108. foreach my $key ( keys %sp ) {
  109. next if exists $spmap{$key} and $spmap{$key} eq "";
  110. next if !exists $drv{$key};
  111. my $bin = $key;
  112. $bin = $spmap{$key} if defined $spmap{$key};
  113. if (!-e "$ENV{_NTPOSTBLD}\\$bin") {
  114. wrnmsg( "$ENV{_NTPOSTBLD}\\$bin missing" );
  115. next;
  116. }
  117. print DDF "$bin\n";
  118. }
  119. close DDF;
  120. my $cmd = "makecab /f $ddf_file";
  121. logmsg("creating cab file using: $cmd");
  122. system("makecab /f $ddf_file");
  123. if ($?) {
  124. errmsg("makecab failed: $?");
  125. }
  126. else {
  127. logmsg("makecab succeeded");
  128. }