Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / bin / modules / installer / windows / assembly.pm
blob38c04a799627da46a38aaa97d8249deb822c27a9
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;
21 use installer::files;
22 use installer::globals;
23 use installer::worker;
24 use installer::windows::idtglobal;
26 ##############################################################
27 # Returning the first module of a file from the
28 # comma separated list of modules.
29 ##############################################################
31 sub get_msiassembly_feature
33 my ( $onefile ) = @_;
35 my $module = "";
37 if ( $onefile->{'modules'} ) { $module = $onefile->{'modules'}; }
39 # If modules contains a list of modules, only taking the first one.
41 if ( $module =~ /^\s*(.*?)\,/ ) { $module = $1; }
43 # Attention: Maximum feature length is 38!
44 installer::windows::idtglobal::shorten_feature_gid(\$module);
46 return $module;
49 ##############################################################
50 # Returning the component of a file.
51 ##############################################################
53 sub get_msiassembly_component
55 my ( $onefile ) = @_;
57 my $component = "";
59 $component = $onefile->{'componentname'};
61 return $component;
64 ##############################################################
65 # Returning the file name as manifest file
66 ##############################################################
68 sub get_msiassembly_filemanifest
70 my ( $onefile ) = @_;
72 my $filemanifest = "";
74 $filemanifest = $onefile->{'uniquename'};
76 return $filemanifest;
79 ##############################################################
80 # Returning the file application
81 ##############################################################
83 sub get_msiassembly_fileapplication
85 my ( $onefile ) = @_;
87 my $fileapplication = "";
89 return $fileapplication;
92 ##############################################################
93 # Returning the file attributes
94 ##############################################################
96 sub get_msiassembly_attributes
98 my ( $onefile ) = @_;
100 my $fileattributes = "";
102 if ( $onefile->{'Attributes'} ne "" ) { $fileattributes = $onefile->{'Attributes'}; }
104 return $fileattributes;
107 ####################################################################################
108 # Creating the file MsiAssembly.idt dynamically
109 # Content:
110 # Component_ Feature_ File_Manifest File_Application Attributes
111 # s72 s38 S72 S72 I2
112 # MsiAssembly Component_
113 ####################################################################################
115 sub create_msiassembly_table
117 my ($filesref, $basedir) = @_;
119 $installer::globals::msiassemblyfiles = installer::worker::collect_all_items_with_special_flag($filesref, "ASSEMBLY");
121 my @msiassemblytable = ();
123 installer::windows::idtglobal::write_idt_header(\@msiassemblytable, "msiassembly");
125 # Registering all libraries listed in $installer::globals::msiassemblyfiles
127 for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ )
129 my $onefile = ${$installer::globals::msiassemblyfiles}[$i];
131 my %msiassembly = ();
133 $msiassembly{'Component_'} = get_msiassembly_component($onefile);
134 $msiassembly{'Feature_'} = get_msiassembly_feature($onefile);
135 $msiassembly{'File_Manifest'} = get_msiassembly_filemanifest($onefile);
136 $msiassembly{'File_Application'} = get_msiassembly_fileapplication($onefile);
137 $msiassembly{'Attributes'} = get_msiassembly_attributes($onefile);
139 my $oneline = $msiassembly{'Component_'} . "\t" . $msiassembly{'Feature_'} . "\t" .
140 $msiassembly{'File_Manifest'} . "\t" . $msiassembly{'File_Application'} . "\t" .
141 $msiassembly{'Attributes'} . "\n";
143 push(@msiassemblytable, $oneline);
146 # Saving the file
148 my $msiassemblytablename = $basedir . $installer::globals::separator . "MsiAssem.idt";
149 installer::files::save_file($msiassemblytablename ,\@msiassemblytable);
150 my $infoline = "Created idt file: $msiassemblytablename\n";
151 push(@installer::globals::logfileinfo, $infoline);
154 ####################################################################################
155 # Creating the file MsiAssemblyName.idt dynamically
156 # Content:
157 # Component_ Name Value
158 # s72 s255 s255
159 # MsiAssemblyName Component_ Name
160 ####################################################################################
162 sub create_msiassemblyname_table
164 my ($filesref, $basedir) = @_;
166 my @msiassemblynametable = ();
168 installer::windows::idtglobal::write_idt_header(\@msiassemblynametable, "msiassemblyname");
170 for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ )
172 my $onefile = ${$installer::globals::msiassemblyfiles}[$i];
174 my $component = get_msiassembly_component($onefile);
175 my $oneline = "";
177 # Order: (Assembly)name, publicKeyToken, version, culture.
179 if ( $onefile->{'Assemblyname'} )
181 $oneline = $component . "\t" . "name" . "\t" . $onefile->{'Assemblyname'} . "\n";
182 push(@msiassemblynametable, $oneline);
185 if ( $onefile->{'PublicKeyToken'} )
187 $oneline = $component . "\t" . "publicKeyToken" . "\t" . $onefile->{'PublicKeyToken'} . "\n";
188 push(@msiassemblynametable, $oneline);
191 if ( $onefile->{'Version'} )
193 $oneline = $component . "\t" . "version" . "\t" . $onefile->{'Version'} . "\n";
194 push(@msiassemblynametable, $oneline);
197 if ( $onefile->{'Culture'} )
199 $oneline = $component . "\t" . "culture" . "\t" . $onefile->{'Culture'} . "\n";
200 push(@msiassemblynametable, $oneline);
203 if ( $onefile->{'ProcessorArchitecture'} )
205 $oneline = $component . "\t" . "processorArchitecture" . "\t" . $onefile->{'ProcessorArchitecture'} . "\n";
206 push(@msiassemblynametable, $oneline);
210 # Saving the file
212 my $msiassemblynametablename = $basedir . $installer::globals::separator . "MsiAsseN.idt";
213 installer::files::save_file($msiassemblynametablename ,\@msiassemblynametable);
214 my $infoline = "Created idt file: $msiassemblynametablename\n";
215 push(@installer::globals::logfileinfo, $infoline);
219 ####################################################################################
220 # setting an installation condition for the assembly libraries saved in
221 # @installer::globals::msiassemblynamecontent
222 ####################################################################################
224 sub add_assembly_condition_into_component_table
226 my ($filesref, $basedir) = @_;
228 my $componenttablename = $basedir . $installer::globals::separator . "Componen.idt";
229 my $componenttable = installer::files::read_file($componenttablename);
230 my $changed = 0;
231 my $infoline = "";
233 for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ )
235 my $onefile = ${$installer::globals::msiassemblyfiles}[$i];
237 my $filecomponent = get_msiassembly_component($onefile);
239 for ( my $j = 0; $j <= $#{$componenttable}; $j++ )
241 my $oneline = ${$componenttable}[$j];
243 if ( $oneline =~ /(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)/ )
245 my $component = $1;
246 my $componentid = $2;
247 my $directory = $3;
248 my $attributes = $4;
249 my $condition = $5;
250 my $keypath = $6;
252 if ( $component eq $filecomponent )
254 # setting the condition
256 $condition = "MsiNetAssemblySupport >= \"4.0.0.0\"";
257 $oneline = $component . "\t" . $componentid . "\t" . $directory . "\t" . $attributes . "\t" . $condition . "\t" . $keypath . "\n";
258 ${$componenttable}[$j] = $oneline;
259 $changed = 1;
260 $infoline = "Changing $componenttablename :\n";
261 push(@installer::globals::logfileinfo, $infoline);
262 $infoline = $oneline;
263 push(@installer::globals::logfileinfo, $infoline);
264 last;
270 if ( $changed )
272 # Saving the file
273 installer::files::save_file($componenttablename ,$componenttable);
274 $infoline = "Saved idt file: $componenttablename\n";
275 push(@installer::globals::logfileinfo, $infoline);