2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package installer
::windows
::assembly
;
25 use installer
::globals
;
26 use installer
::worker
;
27 use installer
::windows
::idtglobal
;
29 ##############################################################
30 # Returning the first module of a file from the
31 # comma separated list of modules.
32 ##############################################################
34 sub get_msiassembly_feature
40 if ( $onefile->{'modules'} ) { $module = $onefile->{'modules'}; }
42 # If modules contains a list of modules, only taking the first one.
44 if ( $module =~ /^\s*(.*?)\,/ ) { $module = $1; }
46 # Attention: Maximum feature length is 38!
47 installer
::windows
::idtglobal
::shorten_feature_gid
(\
$module);
52 ##############################################################
53 # Returning the component of a file.
54 ##############################################################
56 sub get_msiassembly_component
62 $component = $onefile->{'componentname'};
67 ##############################################################
68 # Returning the file name as manifest file
69 ##############################################################
71 sub get_msiassembly_filemanifest
75 my $filemanifest = "";
77 $filemanifest = $onefile->{'uniquename'};
82 ##############################################################
83 # Returning the file application
84 ##############################################################
86 sub get_msiassembly_fileapplication
90 my $fileapplication = "";
92 return $fileapplication;
95 ##############################################################
96 # Returning the file attributes
97 ##############################################################
99 sub get_msiassembly_attributes
101 my ( $onefile ) = @_;
103 my $fileattributes = "";
105 if ( $onefile->{'Attributes'} ne "" ) { $fileattributes = $onefile->{'Attributes'}; }
107 return $fileattributes;
110 ####################################################################################
111 # Creating the file MsiAssembly.idt dynamically
113 # Component_ Feature_ File_Manifest File_Application Attributes
115 # MsiAssembly Component_
116 ####################################################################################
118 sub create_msiassembly_table
120 my ($filesref, $basedir) = @_;
122 $installer::globals
::msiassemblyfiles
= installer
::worker
::collect_all_items_with_special_flag
($filesref, "ASSEMBLY");
124 my @msiassemblytable = ();
126 installer
::windows
::idtglobal
::write_idt_header
(\
@msiassemblytable, "msiassembly");
128 # Registering all libraries listed in $installer::globals::msiassemblyfiles
130 for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ )
132 my $onefile = ${$installer::globals
::msiassemblyfiles
}[$i];
134 my %msiassembly = ();
136 $msiassembly{'Component_'} = get_msiassembly_component
($onefile);
137 $msiassembly{'Feature_'} = get_msiassembly_feature
($onefile);
138 $msiassembly{'File_Manifest'} = get_msiassembly_filemanifest
($onefile);
139 $msiassembly{'File_Application'} = get_msiassembly_fileapplication
($onefile);
140 $msiassembly{'Attributes'} = get_msiassembly_attributes
($onefile);
142 my $oneline = $msiassembly{'Component_'} . "\t" . $msiassembly{'Feature_'} . "\t" .
143 $msiassembly{'File_Manifest'} . "\t" . $msiassembly{'File_Application'} . "\t" .
144 $msiassembly{'Attributes'} . "\n";
146 push(@msiassemblytable, $oneline);
151 my $msiassemblytablename = $basedir . $installer::globals
::separator
. "MsiAssem.idt";
152 installer
::files
::save_file
($msiassemblytablename ,\
@msiassemblytable);
153 my $infoline = "Created idt file: $msiassemblytablename\n";
154 push(@installer::globals
::logfileinfo
, $infoline);
157 ####################################################################################
158 # Creating the file MsiAssemblyName.idt dynamically
160 # Component_ Name Value
162 # MsiAssemblyName Component_ Name
163 ####################################################################################
165 sub create_msiassemblyname_table
167 my ($filesref, $basedir) = @_;
169 my @msiassemblynametable = ();
171 installer
::windows
::idtglobal
::write_idt_header
(\
@msiassemblynametable, "msiassemblyname");
173 for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ )
175 my $onefile = ${$installer::globals
::msiassemblyfiles
}[$i];
177 my $component = get_msiassembly_component
($onefile);
180 # Order: (Assembly)name, publicKeyToken, version, culture.
182 if ( $onefile->{'Assemblyname'} )
184 $oneline = $component . "\t" . "name" . "\t" . $onefile->{'Assemblyname'} . "\n";
185 push(@msiassemblynametable, $oneline);
188 if ( $onefile->{'PublicKeyToken'} )
190 $oneline = $component . "\t" . "publicKeyToken" . "\t" . $onefile->{'PublicKeyToken'} . "\n";
191 push(@msiassemblynametable, $oneline);
194 if ( $onefile->{'Version'} )
196 $oneline = $component . "\t" . "version" . "\t" . $onefile->{'Version'} . "\n";
197 push(@msiassemblynametable, $oneline);
200 if ( $onefile->{'Culture'} )
202 $oneline = $component . "\t" . "culture" . "\t" . $onefile->{'Culture'} . "\n";
203 push(@msiassemblynametable, $oneline);
206 if ( $onefile->{'ProcessorArchitecture'} )
208 $oneline = $component . "\t" . "processorArchitecture" . "\t" . $onefile->{'ProcessorArchitecture'} . "\n";
209 push(@msiassemblynametable, $oneline);
215 my $msiassemblynametablename = $basedir . $installer::globals
::separator
. "MsiAsseN.idt";
216 installer
::files
::save_file
($msiassemblynametablename ,\
@msiassemblynametable);
217 my $infoline = "Created idt file: $msiassemblynametablename\n";
218 push(@installer::globals
::logfileinfo
, $infoline);
222 ####################################################################################
223 # setting an installation condition for the assembly libraries saved in
224 # @installer::globals::msiassemblynamecontent
225 ####################################################################################
227 sub add_assembly_condition_into_component_table
229 my ($filesref, $basedir) = @_;
231 my $componenttablename = $basedir . $installer::globals
::separator
. "Componen.idt";
232 my $componenttable = installer
::files
::read_file
($componenttablename);
236 for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ )
238 my $onefile = ${$installer::globals
::msiassemblyfiles
}[$i];
240 my $filecomponent = get_msiassembly_component
($onefile);
242 for ( my $j = 0; $j <= $#{$componenttable}; $j++ )
244 my $oneline = ${$componenttable}[$j];
246 if ( $oneline =~ /(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)/ )
249 my $componentid = $2;
255 if ( $component eq $filecomponent )
257 # setting the condition
259 $condition = "MsiNetAssemblySupport >= \"4.0.0.0\"";
260 $oneline = $component . "\t" . $componentid . "\t" . $directory . "\t" . $attributes . "\t" . $condition . "\t" . $keypath . "\n";
261 ${$componenttable}[$j] = $oneline;
263 $infoline = "Changing $componenttablename :\n";
264 push(@installer::globals
::logfileinfo
, $infoline);
265 $infoline = $oneline;
266 push(@installer::globals
::logfileinfo
, $infoline);
276 installer
::files
::save_file
($componenttablename ,$componenttable);
277 $infoline = "Saved idt file: $componenttablename\n";
278 push(@installer::globals
::logfileinfo
, $infoline);