Debian Codegraph @

solenv/bin/modules/installer/windows/assembly.pm

raw
1 #
2 # This file is part of the LibreOffice project.
3 #
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/.
7 #
8 # This file incorporates work covered by the following license notice:
9 #
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 .
17 #
18
19 package installer::windows::assembly;
20
21 use strict;
22 use warnings;
23
24 use installer::files;
25 use installer::globals;
26 use installer::worker;
27 use installer::windows::idtglobal;
28
29 ##############################################################
30 # Returning the first module of a file from the
31 # comma separated list of modules.
32 ##############################################################
33
34 sub get_msiassembly_feature
35 {
36 my ( $onefile ) = @_;
37
38 my $module = "";
39
40 if ( $onefile->{'modules'} ) { $module = $onefile->{'modules'}; }
41
42 # If modules contains a list of modules, only taking the first one.
43
44 if ( $module =~ /^\s*(.*?)\,/ ) { $module = $1; }
45
46 # Attention: Maximum feature length is 38!
47 installer::windows::idtglobal::shorten_feature_gid(\$module);
48
49 return $module;
50 }
51
52 ##############################################################
53 # Returning the component of a file.
54 ##############################################################
55
56 sub get_msiassembly_component
57 {
58 my ( $onefile ) = @_;
59
60 my $component = "";
61
62 $component = $onefile->{'componentname'};
63
64 return $component;
65 }
66
67 ##############################################################
68 # Returning the file name as manifest file
69 ##############################################################
70
71 sub get_msiassembly_filemanifest
72 {
73 my ( $onefile ) = @_;
74
75 my $filemanifest = "";
76
77 $filemanifest = $onefile->{'uniquename'};
78
79 return $filemanifest;
80 }
81
82 ##############################################################
83 # Returning the file application
84 ##############################################################
85
86 sub get_msiassembly_fileapplication
87 {
88 my ( $onefile ) = @_;
89
90 my $fileapplication = "";
91
92 return $fileapplication;
93 }
94
95 ##############################################################
96 # Returning the file attributes
97 ##############################################################
98
99 sub get_msiassembly_attributes
100 {
101 my ( $onefile ) = @_;
102
103 my $fileattributes = "";
104
105 if ( $onefile->{'Attributes'} ne "" ) { $fileattributes = $onefile->{'Attributes'}; }
106
107 return $fileattributes;
108 }
109
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 ####################################################################################
117
118 sub create_msiassembly_table
119 {
120 my ($filesref, $basedir) = @_;
121
122 $installer::globals::msiassemblyfiles = installer::worker::collect_all_items_with_special_flag($filesref, "ASSEMBLY");
123
124 my @msiassemblytable = ();
125
126 installer::windows::idtglobal::write_idt_header(\@msiassemblytable, "msiassembly");
127
128 # Registering all libraries listed in $installer::globals::msiassemblyfiles
129
130 for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ )
131 {
132 my $onefile = ${$installer::globals::msiassemblyfiles}[$i];
133
134 my %msiassembly = ();
135
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);
141
142 my $oneline = $msiassembly{'Component_'} . "\t" . $msiassembly{'Feature_'} . "\t" .
143 $msiassembly{'File_Manifest'} . "\t" . $msiassembly{'File_Application'} . "\t" .
144 $msiassembly{'Attributes'} . "\n";
145
146 push(@msiassemblytable, $oneline);
147 }
148
149 # Saving the file
150
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);
155 }
156
157 ####################################################################################
158 # Creating the file MsiAssemblyName.idt dynamically
159 # Content:
160 # Component_ Name Value
161 # s72 s255 s255
162 # MsiAssemblyName Component_ Name
163 ####################################################################################
164
165 sub create_msiassemblyname_table
166 {
167 my ($filesref, $basedir) = @_;
168
169 my @msiassemblynametable = ();
170
171 installer::windows::idtglobal::write_idt_header(\@msiassemblynametable, "msiassemblyname");
172
173 for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ )
174 {
175 my $onefile = ${$installer::globals::msiassemblyfiles}[$i];
176
177 my $component = get_msiassembly_component($onefile);
178 my $oneline = "";
179
180 # Order: (Assembly)name, publicKeyToken, version, culture.
181
182 if ( $onefile->{'Assemblyname'} )
183 {
184 $oneline = $component . "\t" . "name" . "\t" . $onefile->{'Assemblyname'} . "\n";
185 push(@msiassemblynametable, $oneline);
186 }
187
188 if ( $onefile->{'PublicKeyToken'} )
189 {
190 $oneline = $component . "\t" . "publicKeyToken" . "\t" . $onefile->{'PublicKeyToken'} . "\n";
191 push(@msiassemblynametable, $oneline);
192 }
193
194 if ( $onefile->{'Version'} )
195 {
196 $oneline = $component . "\t" . "version" . "\t" . $onefile->{'Version'} . "\n";
197 push(@msiassemblynametable, $oneline);
198 }
199
200 if ( $onefile->{'Culture'} )
201 {
202 $oneline = $component . "\t" . "culture" . "\t" . $onefile->{'Culture'} . "\n";
203 push(@msiassemblynametable, $oneline);
204 }
205
206 if ( $onefile->{'ProcessorArchitecture'} )
207 {
208 $oneline = $component . "\t" . "processorArchitecture" . "\t" . $onefile->{'ProcessorArchitecture'} . "\n";
209 push(@msiassemblynametable, $oneline);
210 }
211 }
212
213 # Saving the file
214
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);
219
220 }
221
222 ####################################################################################
223 # setting an installation condition for the assembly libraries saved in
224 # @installer::globals::msiassemblynamecontent
225 ####################################################################################
226
227 sub add_assembly_condition_into_component_table
228 {
229 my ($filesref, $basedir) = @_;
230
231 my $componenttablename = $basedir . $installer::globals::separator . "Componen.idt";
232 my $componenttable = installer::files::read_file($componenttablename);
233 my $changed = 0;
234 my $infoline = "";
235
236 for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ )
237 {
238 my $onefile = ${$installer::globals::msiassemblyfiles}[$i];
239
240 my $filecomponent = get_msiassembly_component($onefile);
241
242 for ( my $j = 0; $j <= $#{$componenttable}; $j++ )
243 {
244 my $oneline = ${$componenttable}[$j];
245
246 if ( $oneline =~ /(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)/ )
247 {
248 my $component = $1;
249 my $componentid = $2;
250 my $directory = $3;
251 my $attributes = $4;
252 my $condition = $5;
253 my $keypath = $6;
254
255 if ( $component eq $filecomponent )
256 {
257 # setting the condition
258
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;
268 }
269 }
270 }
271 }
272
273 if ( $changed )
274 {
275 # Saving the file
276 installer::files::save_file($componenttablename ,$componenttable);
277 $infoline = "Saved idt file: $componenttablename\n";
278 push(@installer::globals::logfileinfo, $infoline);
279 }
280 }
281
282 1;