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.

97 lines
2.5 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM sample.cmd
  5. REM Sample script for updating a hotfix/sp INF using infgen.dll
  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 Logmsg;
  19. use Win32::OLE qw(in);
  20. sub die_ole_errmsg($);
  21. sub Usage { print<<USAGE; exit(1) }
  22. sample.cmd -inf:<template_inf_file> -out:<output_inf_file> [<files> ...]
  23. template_inf_file - starting INF file to add entries to
  24. output_inf_file - file to save with changes
  25. files - one or more files to add to the INF
  26. USAGE
  27. my ($inf_start, $inf_end, @files);
  28. parseargs('?' => \&Usage,
  29. 'inf:' => \$inf_start,
  30. 'out:' => \$inf_end,
  31. \@files);
  32. if ( !$inf_start || !$inf_end || !@files )
  33. {
  34. errmsg( "Invalid parameters" );
  35. Usage();
  36. }
  37. my $inf_generator = Win32::OLE->new('InfGenerator');
  38. die_ole_errmsg "Could not instatiate InfGenerator" if ( !defined $inf_generator );
  39. logmsg( "Setting up DB connection info ..." );
  40. # DB connection info
  41. $inf_generator->SetDB( "ntbldwebdev", "SPBuilds", "buildlab", "perky" );
  42. if ( Win32::OLE->LastError() )
  43. {
  44. my $errstr = $inf_generator->{InfGenError};
  45. die_ole_errmsg "Error setting DB info (". ($errstr?$errstr:""). ")";
  46. }
  47. logmsg( "initializing generator ..." );
  48. # Initialization
  49. $inf_generator->InitGen( $inf_start, $inf_end );
  50. if ( Win32::OLE->LastError() )
  51. {
  52. my $errstr = $inf_generator->{InfGenError};
  53. die_ole_errmsg "Error starting up InfGenerator (". ($errstr?$errstr:""). ")";
  54. }
  55. logmsg( "inserting files ..." );
  56. # Insert files
  57. foreach my $new_file ( @files )
  58. {
  59. logmsg( "inserting $new_file" );
  60. $inf_generator->InsertFile( $new_file );
  61. if ( Win32::OLE->LastError() )
  62. {
  63. my $errstr = $inf_generator->{InfGenError};
  64. errmsg( "Failed adding file '$new_file': ". ($errstr?$errstr:"<unknown error>") );
  65. }
  66. }
  67. logmsg( "Creating/storing INF ..." );
  68. # Trim and save new INF file
  69. $inf_generator->CloseGen();
  70. if ( Win32::OLE->LastError() )
  71. {
  72. my $errstr = $inf_generator->{InfGenError};
  73. errmsg( "Failed trimming/saving file (". ($errstr?$errstr:"unknown error"). ")" )
  74. }
  75. logmsg( "Successful" );
  76. exit 0;
  77. sub die_ole_errmsg($)
  78. {
  79. my $text = shift;
  80. errmsg( "$text (". Win32::OLE->LastError(). ")" );
  81. exit 1;
  82. }