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.

95 lines
2.4 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM spdriverdelta.cmd - JeremyD
  4. @REM Create lists of files used by SP scripts.
  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. #line 12
  13. use strict;
  14. use warnings;
  15. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  16. use lib $ENV{RAZZLETOOLPATH};
  17. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts\\svcpack";
  18. use PbuildEnv;
  19. use ParseArgs;
  20. use Digest;
  21. use IO::Dir;
  22. use IO::File;
  23. use File::Basename;
  24. use SP;
  25. use Utils;
  26. sub Usage { print<<USAGE; exit(1) }
  27. USAGE
  28. parseargs('?' => \&Usage);
  29. my @skus = SP::sp_skus();
  30. exit if !@skus;
  31. my %drivers;
  32. for my $sku (@skus) {
  33. my $gold = read_gold_info($sku);
  34. my $current = read_sku_info($sku);
  35. my ($added, $changed) = diff($gold, $current);
  36. for my $file (keys %$added, keys %$changed) {
  37. $drivers{$file}++;
  38. }
  39. }
  40. my $fh = IO::File->new("$ENV{_NTPOSTBLD}\\SP\\data\\drivers.txt", 'w');
  41. for my $driver (sort keys %drivers) {
  42. print $fh "$driver\n";
  43. }
  44. sub diff {
  45. my ($gold, $current) = @_;
  46. my (%added, %changed, %removed);
  47. for my $file (keys %$gold) {
  48. if (!exists $current->{$file}) {
  49. $removed{$file} = {file => $gold->{$file}{file}, hash => '--deleted--'};
  50. }
  51. else {
  52. #print "G: $gold->{$file}{hash} C: $current->{$file}{hash}\n";
  53. if ($gold->{$file}{hash} ne $current->{$file}{hash}) {
  54. $changed{$file} = $current->{$file};
  55. }
  56. }
  57. }
  58. for my $file (keys %$current) {
  59. if (!exists $gold->{$file}) {
  60. $added{$file} = $current->{$file};
  61. }
  62. }
  63. return (\%added, \%changed, \%removed);
  64. }
  65. sub read_sku_info {
  66. my $sku = shift;
  67. return read_info("$ENV{_NTPOSTBLD}\\SP\\data\\$sku\\driver_info.txt");
  68. }
  69. sub read_gold_info {
  70. my $sku = shift;
  71. return read_info("$ENV{RAZZLETOOLPATH}\\postbuildscripts\\svcpack\\gold\\${sku}-drivers-$ENV{LANG}.txt");
  72. }
  73. sub read_info {
  74. my $file = shift;
  75. my %data;
  76. my $fh = IO::File->new($file, 'r') or die "$file $!";
  77. while (my $line = $fh->getline) {
  78. chomp($line);
  79. my ($relative, $file, $size, $mtime, $hash) = split /\t/, $line;
  80. $data{$relative} = {file => $file, hash => $hash};
  81. }
  82. return \%data;
  83. }