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.

136 lines
3.8 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM dbgeula.cmd - BarbKess
  4. @REM script for putting localized eulas into dbg*.msi
  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. use strict;
  13. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  14. use lib $ENV{RAZZLETOOLPATH};
  15. use File::Basename;
  16. use PbuildEnv;
  17. use ParseArgs;
  18. use Logmsg;
  19. use A2U;
  20. BEGIN {
  21. # A2u is setting itself as the script_name
  22. $ENV{SCRIPT_NAME} = 'dbgeula.cmd';
  23. }
  24. sub Usage { print<<USAGE; exit(1) }
  25. dbgeula -m <MsiFile> -e <EulaFile> -b <Lg>
  26. -m <MsiFile> MSI File
  27. -e <EulaFile> Eula to insert in RTF format
  28. -b <Lg> Language - necessary for BiDi
  29. Updates the msi file with the localized eula
  30. USAGE
  31. # global switches/values set on the command line
  32. my ( $MsiFile, $EulaFile, $Lg );
  33. parseargs('?' => \&Usage,
  34. 'm:' => \$MsiFile,
  35. 'e:' => \$EulaFile,
  36. 'b:' => \$Lg
  37. );
  38. # Global Variables
  39. my( $LogFileName );
  40. my( $TempDir );
  41. my( $RazPath );
  42. # call into the Main sub, too much indentation to make this
  43. # toplevel right now
  44. &Main();
  45. sub Main {
  46. # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  47. # Begin Main code section
  48. # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  49. # Return when you want to exit on error
  50. # <Implement your code here>
  51. $Logmsg::DEBUG = 0; # set to 1 to activate logging of dbgmsg's
  52. $LogFileName = $ENV{ "LOGFILE" };
  53. $TempDir = $ENV{ "TMP" };
  54. if ( ! defined( $LogFileName ) ) {
  55. $LogFileName = "$TempDir\\$0.log";
  56. }
  57. $RazPath= $ENV{ "RazzleToolPath" };
  58. timemsg( "Beginning ...", $LogFileName );
  59. logmsg( "Updating eula in $MsiFile" );
  60. # Copy the msi file over to the destination directory
  61. if ( not -e $MsiFile ) {
  62. errmsg( "$MsiFile does not exist" );
  63. }
  64. # Replace all of the \r\n's in the eula.rtf with nothing
  65. system( qq(rep.exe "\\r\\n" "" $EulaFile ) );
  66. # Export the control table to the temporary directory
  67. system( "cscript $RazPath\\wiexport.vbs \/\/nologo $MsiFile $TempDir Control" );
  68. # Copy the Control table to Control.idt.old
  69. system( "copy $TempDir\\Control.idt $TempDir\\Control.idt.old" );
  70. system( "del \/f \/q $TempDir\\Control.idt" );
  71. # Fix the control table
  72. my ( $Line );
  73. my ( $fh_in );
  74. unless ( $fh_in = new IO::File $TempDir . "\\Control.idt.old", "r" ) {
  75. errmsg( "Failed to open $TempDir\\Control.idt.old for read" );
  76. return;
  77. }
  78. my( $fh_out );
  79. unless ( $fh_out = new IO::File $TempDir . "\\Control.idt", "w" ) {
  80. errmsg( "Failed to open $TempDir\\Control.idt for write" );
  81. return;
  82. }
  83. my ( $eula_in );
  84. unless ( $eula_in = new IO::File $EulaFile, "r" ) {
  85. errmsg( "Failed to open $EulaFile for read" );
  86. return;
  87. }
  88. my( $ReplaceLine );
  89. $ReplaceLine = <$eula_in>;
  90. my( $IdentifyLine );
  91. $IdentifyLine = "LicenseDialog\\sLicense\\sScrollableText";
  92. while ( $Line = <$fh_in> ) {
  93. chomp( $Line );
  94. if ( $Line =~ /$IdentifyLine/) {
  95. my( @myData );
  96. my @myData = split(/\t/, $Line);
  97. $myData[7] |= 224 if $Lg =~ /(ara?)|(heb?)/i;
  98. $Line = join("\t", @myData[0..8],
  99. $ReplaceLine,
  100. @myData[10..$#myData], undef);
  101. }
  102. print( $fh_out "$Line\n" );
  103. }
  104. undef( $fh_in );
  105. undef( $fh_out );
  106. # Import the control table to the msi file
  107. system( "cscript $RazPath\\wiimport.vbs \/\/nologo $MsiFile $TempDir Control.idt" );
  108. }