merge the formfield patch from ooo-build
[ooovba.git] / solenv / bin / modules / installer / windows / assembly.pm
blobb643c9bf1ca134301d5713f44cc7f9696f371577
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: assembly.pm,v $
11 # $Revision: 1.11 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 package installer::windows::assembly;
34 use installer::files;
35 use installer::globals;
36 use installer::worker;
37 use installer::windows::idtglobal;
39 ##############################################################
40 # Returning the first module of a file from the
41 # comma separated list of modules.
42 ##############################################################
44 sub get_msiassembly_feature
46 my ( $onefile ) = @_;
48 my $module = "";
50 if ( $onefile->{'modules'} ) { $module = $onefile->{'modules'}; }
52 # If modules contains a list of modules, only taking the first one.
54 if ( $module =~ /^\s*(.*?)\,/ ) { $module = $1; }
56 # Attention: Maximum feature length is 38!
57 installer::windows::idtglobal::shorten_feature_gid(\$module);
59 return $module;
62 ##############################################################
63 # Returning the component of a file.
64 ##############################################################
66 sub get_msiassembly_component
68 my ( $onefile ) = @_;
70 my $component = "";
72 $component = $onefile->{'componentname'};
74 return $component;
77 ##############################################################
78 # Returning the file name as manifest file
79 ##############################################################
81 sub get_msiassembly_filemanifest
83 my ( $onefile ) = @_;
85 my $filemanifest = "";
87 $filemanifest = $onefile->{'uniquename'};
88 # $filemanifest = $onefile->{'Name'};
90 return $filemanifest;
94 ##############################################################
95 # Returning the file application
96 ##############################################################
98 sub get_msiassembly_fileapplication
100 my ( $onefile ) = @_;
102 my $fileapplication = "";
104 return $fileapplication;
107 ##############################################################
108 # Returning the file attributes
109 ##############################################################
111 sub get_msiassembly_attributes
113 my ( $onefile ) = @_;
115 my $fileattributes = "";
117 if ( $onefile->{'Attributes'} ne "" ) { $fileattributes = $onefile->{'Attributes'}; }
119 return $fileattributes;
122 ##############################################################
123 # Returning the file object for the msiassembly table.
124 ##############################################################
126 sub get_msiassembly_file
128 my ( $filesref, $filename ) = @_;
130 my $foundfile = 0;
131 my $onefile;
133 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
135 $onefile = ${$filesref}[$i];
136 my $name = $onefile->{'Name'};
138 if ( $name eq $filename )
140 $foundfile = 1;
141 last;
145 # It does not need to exist. For example products that do not contain the libraries.
146 # if (! $foundfile ) { installer::exiter::exit_program("ERROR: No unique file name found for $filename !", "get_selfreg_file"); }
148 if (! $foundfile ) { $onefile = ""; }
150 return $onefile;
153 ##############################################################
154 # Returning the file object for the msiassembly table.
155 ##############################################################
157 sub get_msiassembly_file_by_gid
159 my ( $filesref, $gid ) = @_;
161 my $foundfile = 0;
162 my $onefile;
164 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
166 $onefile = ${$filesref}[$i];
167 my $filegid = $onefile->{'gid'};
169 if ( $filegid eq $gid )
171 $foundfile = 1;
172 last;
176 # It does not need to exist. For example products that do not contain the libraries.
177 # if (! $foundfile ) { installer::exiter::exit_program("ERROR: No unique file name found for $filename !", "get_selfreg_file"); }
179 if (! $foundfile ) { $onefile = ""; }
181 return $onefile;
184 ####################################################################################
185 # Creating the file MsiAssembly.idt dynamically
186 # Content:
187 # Component_ Feature_ File_Manifest File_Application Attributes
188 # s72 s38 S72 S72 I2
189 # MsiAssembly Component_
190 ####################################################################################
192 sub create_msiassembly_table
194 my ($filesref, $basedir) = @_;
196 $installer::globals::msiassemblyfiles = installer::worker::collect_all_items_with_special_flag($filesref, "ASSEMBLY");
198 my @msiassemblytable = ();
200 installer::windows::idtglobal::write_idt_header(\@msiassemblytable, "msiassembly");
202 # Registering all libraries listed in $installer::globals::msiassemblyfiles
204 for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ )
206 my $onefile = ${$installer::globals::msiassemblyfiles}[$i];
208 my %msiassembly = ();
210 $msiassembly{'Component_'} = get_msiassembly_component($onefile);
211 $msiassembly{'Feature_'} = get_msiassembly_feature($onefile);
212 $msiassembly{'File_Manifest'} = get_msiassembly_filemanifest($onefile);
213 $msiassembly{'File_Application'} = get_msiassembly_fileapplication($onefile);
214 $msiassembly{'Attributes'} = get_msiassembly_attributes($onefile);
216 my $oneline = $msiassembly{'Component_'} . "\t" . $msiassembly{'Feature_'} . "\t" .
217 $msiassembly{'File_Manifest'} . "\t" . $msiassembly{'File_Application'} . "\t" .
218 $msiassembly{'Attributes'} . "\n";
220 push(@msiassemblytable, $oneline);
223 # Saving the file
225 my $msiassemblytablename = $basedir . $installer::globals::separator . "MsiAssem.idt";
226 installer::files::save_file($msiassemblytablename ,\@msiassemblytable);
227 my $infoline = "Created idt file: $msiassemblytablename\n";
228 push(@installer::globals::logfileinfo, $infoline);
231 ####################################################################################
232 # Returning the name for the table MsiAssemblyName
233 ####################################################################################
235 sub get_msiassemblyname_name
237 ( $number ) = @_;
239 my $name = "";
241 if ( $number == 1 ) { $name = "name"; }
242 elsif ( $number == 2 ) { $name = "publicKeyToken"; }
243 elsif ( $number == 3 ) { $name = "version"; }
244 elsif ( $number == 4 ) { $name = "culture"; }
246 return $name;
249 ####################################################################################
250 # Creating the file MsiAssemblyName.idt dynamically
251 # Content:
252 # Component_ Name Value
253 # s72 s255 s255
254 # MsiAssemblyName Component_ Name
255 ####################################################################################
257 sub create_msiassemblyname_table
259 my ($filesref, $basedir) = @_;
261 my @msiassemblynametable = ();
263 installer::windows::idtglobal::write_idt_header(\@msiassemblynametable, "msiassemblyname");
265 for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ )
267 my $onefile = ${$installer::globals::msiassemblyfiles}[$i];
269 my $component = get_msiassembly_component($onefile);
270 my $oneline = "";
272 # Order: (Assembly)name, publicKeyToken, version, culture.
274 if ( $onefile->{'Assemblyname'} )
276 $oneline = $component . "\t" . "name" . "\t" . $onefile->{'Assemblyname'} . "\n";
277 push(@msiassemblynametable, $oneline);
280 if ( $onefile->{'PublicKeyToken'} )
282 $oneline = $component . "\t" . "publicKeyToken" . "\t" . $onefile->{'PublicKeyToken'} . "\n";
283 push(@msiassemblynametable, $oneline);
286 if ( $onefile->{'Version'} )
288 $oneline = $component . "\t" . "version" . "\t" . $onefile->{'Version'} . "\n";
289 push(@msiassemblynametable, $oneline);
292 if ( $onefile->{'Culture'} )
294 $oneline = $component . "\t" . "culture" . "\t" . $onefile->{'Culture'} . "\n";
295 push(@msiassemblynametable, $oneline);
298 if ( $onefile->{'ProcessorArchitecture'} )
300 $oneline = $component . "\t" . "processorArchitecture" . "\t" . $onefile->{'ProcessorArchitecture'} . "\n";
301 push(@msiassemblynametable, $oneline);
305 # Saving the file
307 my $msiassemblynametablename = $basedir . $installer::globals::separator . "MsiAsseN.idt";
308 installer::files::save_file($msiassemblynametablename ,\@msiassemblynametable);
309 my $infoline = "Created idt file: $msiassemblynametablename\n";
310 push(@installer::globals::logfileinfo, $infoline);
314 ####################################################################################
315 # setting an installation condition for the assembly libraries saved in
316 # @installer::globals::msiassemblynamecontent
317 ####################################################################################
319 sub add_assembly_condition_into_component_table
321 my ($filesref, $basedir) = @_;
323 my $componenttablename = $basedir . $installer::globals::separator . "Componen.idt";
324 my $componenttable = installer::files::read_file($componenttablename);
325 my $changed = 0;
326 my $infoline = "";
328 for ( my $i = 0; $i <= $#{$installer::globals::msiassemblyfiles}; $i++ )
330 my $onefile = ${$installer::globals::msiassemblyfiles}[$i];
332 my $filecomponent = get_msiassembly_component($onefile);
334 for ( my $j = 0; $j <= $#{$componenttable}; $j++ )
336 my $oneline = ${$componenttable}[$j];
338 if ( $oneline =~ /(.*)\t(.*)\t(.*)\t(.*)\t(.*)\t(.*)/ )
340 my $component = $1;
341 my $componentid = $2;
342 my $directory = $3;
343 my $attributes = $4;
344 my $condition = $5;
345 my $keypath = $6;
347 if ( $component eq $filecomponent )
349 # setting the condition
351 # $condition = "MsiNetAssemblySupport";
352 $condition = "DOTNET_SUFFICIENT=1";
353 $oneline = $component . "\t" . $componentid . "\t" . $directory . "\t" . $attributes . "\t" . $condition . "\t" . $keypath . "\n";
354 ${$componenttable}[$j] = $oneline;
355 $changed = 1;
356 $infoline = "Changing $componenttablename :\n";
357 push(@installer::globals::logfileinfo, $infoline);
358 $infoline = $oneline;
359 push(@installer::globals::logfileinfo, $infoline);
360 last;
366 if ( $changed )
368 # Saving the file
369 installer::files::save_file($componenttablename ,$componenttable);
370 $infoline = "Saved idt file: $componenttablename\n";
371 push(@installer::globals::logfileinfo, $infoline);