cid#1607171 Data race condition
[LibreOffice.git] / solenv / bin / modules / installer / windows / assembly.pm
blobd7014144ce9ad8e628c993c0ce24d4653d2d62a6
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 strict;
22 use warnings;
24 use installer::files;
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
36 my ( $onefile ) = @_;
38 my $module = "";
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);
49 return $module;
52 ##############################################################
53 # Returning the component of a file.
54 ##############################################################
56 sub get_msiassembly_component
58 my ( $onefile ) = @_;
60 my $component = "";
62 $component = $onefile->{'componentname'};
64 return $component;
67 ##############################################################
68 # Returning the file name as manifest file
69 ##############################################################
71 sub get_msiassembly_filemanifest
73 my ( $onefile ) = @_;
75 my $filemanifest = "";
77 $filemanifest = $onefile->{'uniquename'};
79 return $filemanifest;
82 ##############################################################
83 # Returning the file application
84 ##############################################################
86 sub get_msiassembly_fileapplication
88 my ( $onefile ) = @_;
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
112 # Content:
113 # Component_ Feature_ File_Manifest File_Application Attributes
114 # s72 s38 S72 S72 I2
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);
149 # Saving the file
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
159 # Content:
160 # Component_ Name Value
161 # s72 s255 s255
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);
178 my $oneline = "";
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);
213 # Saving the file
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);
233 my $changed = 0;
234 my $infoline = "";
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(.*)/ )
248 my $component = $1;
249 my $componentid = $2;
250 my $directory = $3;
251 my $attributes = $4;
252 my $condition = $5;
253 my $keypath = $6;
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;
262 $changed = 1;
263 $infoline = "Changing $componenttablename :\n";
264 push(@installer::globals::logfileinfo, $infoline);
265 $infoline = $oneline;
266 push(@installer::globals::logfileinfo, $infoline);
267 last;
273 if ( $changed )
275 # Saving the file
276 installer::files::save_file($componenttablename ,$componenttable);
277 $infoline = "Saved idt file: $componenttablename\n";
278 push(@installer::globals::logfileinfo, $infoline);