summaryrefslogtreecommitdiff
path: root/solenv/bin/modules/installer.pm
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2017-01-21 11:44:33 +0100
committerDavid Ostrovsky <david@ostrovsky.org>2017-02-01 18:07:38 +0000
commit30473907a565764eb35a19051dc0d52704cf7bb7 (patch)
tree438cb94e9bc3a61fba8dcbee57fe107802dca732 /solenv/bin/modules/installer.pm
parent56a8a76e9e001dc5274815c3893bf48c9e7b7298 (diff)
tdf#105311 VC++ Runtime installed in wrong directory
Starting from MSVC 14.0, the directory table layout of VC++ Runtime merge module changed. As consequence, all MSI produced with newer compilers, including MSVC 15.0 (aka VS 2017) are broken in term that the VC++ Runtime DLLs are installed in the wrong directory, e.g.: C:\System64. According to the specification for merging merge module (msm), see: "Authoring Merge Module Directory Tables": [1], custom action 51 (set property) must be emitted for every directory name in the merge module directory table if the directory name is starting with the standard directory name. Quoting it here: " When a predefined directory is included in a merge module, the merge tool automatically adds a Custom Action Type 51 to the target database. The merge module author must ensure that a CustomAction table is also included. The CustomAction table may be empty, but this table is required to exist in the target database and ensures that the modified predefined directories are written to the correct locations. For example, when a system directory is included in a merge module, the merge module author must ensure that a Custom Action table exists. Note that the matching algorithm for the generation of these type 51 custom actions only checks that the directory name begins with one of the predefined SystemFolder properties. It does not verify that the directory name exactly equals the directory property. Any directory beginning with one of these standard folder names gets a type 51 custom action, even if the rest of the name is not a GUID. Authors need to take care that this does not generate false positive matches, and unintended custom action generation, on derivative primary keys that begin with one of the SystemFolder properties." Rectify the problem by analyzing the directory table from the merge module, checking whether the directory name starts with the standard prefix name and if it is the case, emitting custom action 51 to set this variable to the standard directory name. Implementation details: We use the existing facility for emitting the custom action table events including referencing them in the corresponding sequence tables. Given that the specification above doesn't mention what sequence table should be referencing this emitted custom action, we reversed engineer this information from WiX toolkit. Merging the VC++ CRT module with WiX toolkit and investigating the resulting MSI with Orca MSI reader, reveals that these sequence tables were referencing from these sequence tables: * AdminExecuteSequence * AdminUISequence * AdvtExecuteSequence * InstallExecuteSequence * InstallUISequence Replicate this behaviour here as well. Note, though, that custom actions are generally not referenced in AdminUISequence and AdvtExecuteSequence tables in LibreOffice MSI building tool chain. Rendering of the custom action is achieved by programmatic emulation of custom action in SCP module. Consider this similar SCP module based action: Name = "MigrateInstallPath"; Typ = "321"; Source = "shlxtmsi.dll"; Target = "MigrateInstallPath"; Inbinarytable = 1; Assignment1 = ("InstallExecuteSequence", "", "CostInitialize"); Assignment2 = ("InstallUISequence", "", "CostInitialize"); We instantiate the following data structure to emit custom action System64Folder.3CFBED52_9B44_3A4D_953C_90E456671BA1: Name = "System64Folder.3CFBED52_9B44_3A4D_953C_90E456671BA1" Typ = "51" Source = "System64Folder.3CFBED52_9B44_3A4D_953C_90E456671BA1" Target = "[System64Folder]" Styles = "NO_FILES" Assignment1 = ("AdminExecuteSequence", "", "CostInitialize") Assignment2 = ("InstallExecuteSequence", "", "CostInitialize") Assignment3 = ("InstallUISequence", "", "CostInitialize") [1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa367787%28v=vs.85%29.aspx Change-Id: I2fbd37ff63298d99b2ba1b6afe6e875f56d8e378 Reviewed-on: https://gerrit.libreoffice.org/33366 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: David Ostrovsky <david@ostrovsky.org>
Diffstat (limited to 'solenv/bin/modules/installer.pm')
-rw-r--r--solenv/bin/modules/installer.pm26
1 files changed, 25 insertions, 1 deletions
diff --git a/solenv/bin/modules/installer.pm b/solenv/bin/modules/installer.pm
index 485a508ccccf..1acac03e43c6 100644
--- a/solenv/bin/modules/installer.pm
+++ b/solenv/bin/modules/installer.pm
@@ -518,9 +518,15 @@ sub run {
if ( $installer::globals::updatedatabase )
{
($uniquefilename, $revuniquefilename, $revshortfilename, $allupdatesequences, $allupdatecomponents, $allupdatefileorder, $allupdatecomponentorder, $shortdirname, $componentid, $componentidkeypath, $alloldproperties, $allupdatelastsequences, $allupdatediskids) = installer::windows::update::create_database_hashes($refdatabase);
- if ( $mergemodulesarrayref > -1 ) { installer::windows::update::readmergedatabase($mergemodulesarrayref, $languagestringref, $includepatharrayref); }
}
}
+
+ # Always analyze the merge module.
+ # We need to investigate the directory table in merge module to emit
+ # custom action for directory names that start with standard prefix
+ if ( $mergemodulesarrayref > -1 ) {
+ installer::windows::update::readmergedatabase($mergemodulesarrayref, $languagestringref, $includepatharrayref);
+ }
}
##############################################
@@ -1499,6 +1505,24 @@ sub run {
installer::windows::idtglobal::addcustomactions($languageidtdir, $windowscustomactionsarrayref, $filesinproductlanguageresolvedarrayref);
+ installer::logger::print_message( "... Analyze if custom action table must be patched with merge module directory names ...\n" );
+
+ my @customactions = ();
+ for my $e (keys %installer::globals::merge_directory_hash) {
+ my $var;
+ installer::logger::print_message( "... analyzing directory from merge module: $e\n");
+ if (installer::windows::directory::has_standard_directory_prefix($e, \$var)) {
+ installer::logger::print_message( "... emitting custom action to set the var $e to directory: $var\n");
+ push(@customactions, installer::windows::idtglobal::emit_custom_action_for_standard_directory($e, $var));
+ }
+ }
+
+ if (@customactions) {
+ installer::logger::print_message( "... Patching custom action table with merge module directory names ...\n" );
+ #print Dumper(@customactions);
+ installer::windows::idtglobal::addcustomactions($languageidtdir, \@customactions, $filesinproductlanguageresolvedarrayref);
+ }
+
# Then the language specific msi database can be created
if ( $installer::globals::iswin || $installer::globals::packageformat eq 'msi' )