[Libreoffice-commits] core.git: Branch 'feature/cib_contract57b' - 2 commits - scp2/source solenv/bin

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Thu May 23 16:23:15 UTC 2019


 scp2/source/winexplorerext/file_winexplorerext.scp   |   11 +++
 scp2/source/winexplorerext/module_winexplorerext.scp |    5 -
 solenv/bin/modules/installer.pm                      |   26 +++++++
 solenv/bin/modules/installer/globals.pm              |    1 
 solenv/bin/modules/installer/windows/directory.pm    |   62 +++++++++++++++++++
 solenv/bin/modules/installer/windows/idtglobal.pm    |   25 +++++++
 solenv/bin/modules/installer/windows/update.pm       |   28 ++++++++
 7 files changed, 153 insertions(+), 5 deletions(-)

New commits:
commit ec8d4dbe31f2f5bc58100b701121d872982367e7
Author:     Michael Stahl <mstahl at redhat.com>
AuthorDate: Fri Jun 2 22:38:06 2017 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Thu May 23 18:21:59 2019 +0200

    scp2: package 64-bit MSVC runtimes for explorer extensions
    
    Not a backport because master is a bit too refactored now.
    
    Reviewed-on: https://gerrit.libreoffice.org/38365
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit ab4344c34ddf048adf9a3fad0dd1fa2970935550)
    
    Conflicts:
            scp2/source/winexplorerext/file_winexplorerext.scp
    
    Change-Id: I1eccb99252fb66dc1fcc9cb5af978c61717ff629

diff --git a/scp2/source/winexplorerext/file_winexplorerext.scp b/scp2/source/winexplorerext/file_winexplorerext.scp
index 7567896b4b9f..7ca1f9c6a63d 100644
--- a/scp2/source/winexplorerext/file_winexplorerext.scp
+++ b/scp2/source/winexplorerext/file_winexplorerext.scp
@@ -85,4 +85,15 @@ End
 
 #endif
 
+#if defined(WITH_VC140_REDIST) || defined(WITH_VC150_REDIST)
+
+File gid_File_X64_Redist
+    Styles = (FILELIST, USE_INTERNAL_RIGHTS, PACKED);
+    Dir = FILELIST_DIR;
+    Name = "msvc_dlls.filelist";
+    ComponentCondition = "VersionNT64";
+End
+
+#endif
+
 #endif
diff --git a/scp2/source/winexplorerext/module_winexplorerext.scp b/scp2/source/winexplorerext/module_winexplorerext.scp
index 440945e89096..b71153cd0052 100644
--- a/scp2/source/winexplorerext/module_winexplorerext.scp
+++ b/scp2/source/winexplorerext/module_winexplorerext.scp
@@ -49,9 +49,6 @@ Module gid_Module_Optional_Winexplorerext_x64
     Dirs = (gid_Dir_Shlxthdl);
     Files = (auto_winexplorerextwin64_ALL,
              auto_winexplorerextwin64nt6_ALL,
-             gid_File_Lib_Msvcp100,
-             gid_File_Lib_Msvcr100,
-             gid_File_Lib_Msvcp110,
-             gid_File_Lib_Msvcr110);
+             gid_File_X64_Redist);
 End
 #endif
commit afa1ef04fc9428cb367c060033a2edcb4ac6b16b
Author:     David Ostrovsky <david at ostrovsky.org>
AuthorDate: Sat Jan 21 11:44:33 2017 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Thu May 23 18:21:59 2019 +0200

    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 at libreoffice.org>
    Reviewed-by: David Ostrovsky <david at ostrovsky.org>
    (cherry picked from commit 30473907a565764eb35a19051dc0d52704cf7bb7)

diff --git a/solenv/bin/modules/installer.pm b/solenv/bin/modules/installer.pm
index 605aec25e663..eb6ec70aafb9 100644
--- a/solenv/bin/modules/installer.pm
+++ b/solenv/bin/modules/installer.pm
@@ -519,9 +519,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);
+            }
         }
 
         ##############################################
@@ -1510,6 +1516,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' )
diff --git a/solenv/bin/modules/installer/globals.pm b/solenv/bin/modules/installer/globals.pm
index 5a7423aa48f8..c09b696c766c 100644
--- a/solenv/bin/modules/installer/globals.pm
+++ b/solenv/bin/modules/installer/globals.pm
@@ -159,6 +159,7 @@ BEGIN
     %merge_media_line = ();
     %merge_allfeature_hash = ();
     %merge_alldirectory_hash = ();
+    %merge_directory_hash = ();
     %copy_msm_files = ();
     $mergefeaturecollected = 0;
     $mergedirectoriescollected = 0;
diff --git a/solenv/bin/modules/installer/windows/directory.pm b/solenv/bin/modules/installer/windows/directory.pm
index a1d677393334..b29fa13c045a 100644
--- a/solenv/bin/modules/installer/windows/directory.pm
+++ b/solenv/bin/modules/installer/windows/directory.pm
@@ -29,6 +29,36 @@ use installer::windows::msiglobal;
 # Collecting all directory trees in global hash
 ##############################################################
 
+my @msistandarddirectorynames = qw(
+   AdminToolsFolder
+   AppDataFolder
+   CommonAppDataFolder
+   CommonFiles64Folder
+   CommonFilesFolder
+   DesktopFolder
+   FavoritesFolder
+   FontsFolder
+   LocalAppDataFolder
+   MyPicturesFolder
+   NetHoodFolder
+   PersonalFolder
+   PrintHoodFolder
+   ProgramFiles64Folder
+   ProgramFilesFolder
+   ProgramMenuFolder
+   RecentFolder
+   SendToFolder
+   StartMenuFolder
+   StartupFolder
+   System16Folder
+   System64Folder
+   SystemFolder
+   TempFolder
+   TemplateFolder
+   WindowsFolder
+   WindowsVolume
+);
+
 sub collectdirectorytrees
 {
     my ( $directoryref ) = @_;
@@ -569,4 +599,36 @@ sub create_directory_table
     }
 }
 
+################################################
+# Check if the string starts with another string
+################################################
+
+sub starts_with
+{
+    my ($first, $second) = @_;
+
+    return substr($first, 0, length($second)) eq $second;
+}
+
+###############################################
+# Check if the directory prefix is a standard
+# directory name. If it is the case, then the
+# standard directory name is returned in $var.
+###############################################
+
+sub has_standard_directory_prefix
+{
+    my ($dir, $var) = @_;
+
+    for my $d (@msistandarddirectorynames) {
+        if (starts_with($dir, $d) && $dir ne $d) {
+            installer::logger::print_message("... match found: [$d]\n");
+            ${$var} = $d;
+            return 1;
+        }
+    }
+
+    return 0;
+}
+
 1;
diff --git a/solenv/bin/modules/installer/windows/idtglobal.pm b/solenv/bin/modules/installer/windows/idtglobal.pm
index d9d2f9e2c238..2fa46fbbdb6a 100644
--- a/solenv/bin/modules/installer/windows/idtglobal.pm
+++ b/solenv/bin/modules/installer/windows/idtglobal.pm
@@ -1834,4 +1834,29 @@ sub setbidiattributes
     push(@installer::globals::logfileinfo, $infoline);
 }
 
+###############################################
+# Emit custom action 51 for setting standard
+# directory variable. Reference to a hash is
+# returned, represented the custom action.
+# This can be passed in to addcustomaction
+# method.
+###############################################
+
+sub emit_custom_action_for_standard_directory
+{
+    my ($dir, $var) = @_;
+    my %action = ();
+
+    $action{'Name'} = $dir;
+    $action{'Typ'} = "51";
+    $action{'Source'} = $dir;
+    $action{'Target'} = "[$var]";
+    $action{'Styles'} = "NO_FILE";
+    $action{'Assignment1'} = '("AdminExecuteSequence", "", "CostInitialize")';
+    $action{'Assignment2'} = '("InstallExecuteSequence", "", "CostInitialize")';
+    $action{'Assignment3'} = '("InstallUISequence", "", "CostInitialize")';
+
+    return \%action;
+}
+
 1;
diff --git a/solenv/bin/modules/installer/windows/update.pm b/solenv/bin/modules/installer/windows/update.pm
index 0edaaf2d8d91..45c47ed7ab0d 100644
--- a/solenv/bin/modules/installer/windows/update.pm
+++ b/solenv/bin/modules/installer/windows/update.pm
@@ -183,6 +183,9 @@ sub read_all_tables_from_msidatabase
         if ( ! -f $longonefilename ) { installer::exiter::exit_program("ERROR: Could not find idt file: $longonefilename!", "read_all_tables_from_msidatabase"); }
         my $filecontent = installer::files::read_file($longonefilename);
         my $idtcontent = analyze_idt_file($filecontent);
+        if ($onefilename eq "Directory.idt") {
+            collect_directories($filecontent);
+        }
         my $key = $onefilename;
         $key =~ s/\.idt\s*$//;
         $database{$key} = $idtcontent;
@@ -406,6 +409,31 @@ sub readdatabase
     return $database;
 }
 
+#########################################################################
+# Reading the file "Directory.idt".
+#########################################################################
+
+sub collect_directories
+{
+    my ($filecontent) = @_;
+
+    for ( my $i = 0; $i <= $#{$filecontent}; $i++ )
+    {
+        if ( $i <= 2 ) { next; }                        # ignoring first three lines
+        if ( ${$filecontent}[$i] =~ /^\s*$/ ) { next; } # ignoring empty lines
+        # Format: Directory Directory_Parent    DefaultDir
+        if ( ${$filecontent}[$i] =~ /^\s*(.+?)\t(.*?)\t(.*?)\s*$/ )
+        {
+            $installer::globals::merge_directory_hash{$1} = 1;
+        }
+        else
+        {
+            my $linecount = $i + 1;
+            installer::exiter::exit_program("ERROR: Unknown line format in table \"$idtfilename\" (line $linecount) !", "collect_directories");
+        }
+    }
+}
+
 #################################################################################
 # Files can be included in merge modules. This is also important for update.
 #################################################################################


More information about the Libreoffice-commits mailing list