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.

137 lines
3.6 KiB

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