1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: file.pm,v $
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
::file
;
35 use installer
::existence
;
36 use installer
::exiter
;
38 use installer
::globals
;
39 use installer
::logger
;
40 use installer
::pathanalyzer
;
41 use installer
::worker
;
42 use installer
::windows
::font
;
43 use installer
::windows
::idtglobal
;
44 use installer
::windows
::language
;
46 ##########################################################################
47 # Assigning one cabinet file to each file. This is requrired,
48 # if cabinet files shall be equivalent to packages.
49 ##########################################################################
51 sub assign_cab_to_files
53 my ( $filesref ) = @_;
57 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
59 if ( ! exists(${$filesref}[$i]->{'modules'}) ) { installer
::exiter
::exit_program
("ERROR: No module assignment found for ${$filesref}[$i]->{'gid'} !", "assign_cab_to_files"); }
60 my $module = ${$filesref}[$i]->{'modules'};
61 # If modules contains a list of modules, only taking the first one.
62 if ( $module =~ /^\s*(.*?)\,/ ) { $module = $1; }
64 if ( ! exists($installer::globals
::allcabinetassigns
{$module}) ) { installer
::exiter
::exit_program
("ERROR: No cabinet file assigned to module \"$module\" (${$filesref}[$i]->{'gid'}) !", "assign_cab_to_files"); }
65 ${$filesref}[$i]->{'assignedcabinetfile'} = $installer::globals
::allcabinetassigns
{$module};
67 # Counting the files in each cabinet file
68 if ( ! exists($installer::globals
::cabfilecounter
{${$filesref}[$i]->{'assignedcabinetfile'}}) )
70 $installer::globals
::cabfilecounter
{${$filesref}[$i]->{'assignedcabinetfile'}} = 1;
74 $installer::globals
::cabfilecounter
{${$filesref}[$i]->{'assignedcabinetfile'}}++;
78 # logging the number of files in each cabinet file
80 $infoline = "\nCabinet file content:\n";
81 push(@installer::globals
::logfileinfo
, $infoline);
83 foreach $cabfile ( sort keys %installer::globals
::cabfilecounter
)
85 $infoline = "$cabfile : $installer::globals::cabfilecounter{$cabfile} files\n";
86 push(@installer::globals
::logfileinfo
, $infoline);
89 # assigning startsequencenumbers for each cab file
92 foreach $cabfile ( sort keys %installer::globals
::cabfilecounter
)
94 my $filecount = $installer::globals
::cabfilecounter
{$cabfile};
95 $installer::globals
::cabfilecounter
{$cabfile} = $offset;
96 $offset = $offset + $filecount;
98 $installer::globals
::lastsequence
{$cabfile} = $offset - 1;
101 # logging the start sequence numbers
103 $infoline = "\nCabinet file start sequences:\n";
104 push(@installer::globals
::logfileinfo
, $infoline);
105 foreach $cabfile ( sort keys %installer::globals
::cabfilecounter
)
107 $infoline = "$cabfile : $installer::globals::cabfilecounter{$cabfile}\n";
108 push(@installer::globals
::logfileinfo
, $infoline);
111 # logging the last sequence numbers
113 $infoline = "\nCabinet file last sequences:\n";
114 push(@installer::globals
::logfileinfo
, $infoline);
115 foreach $cabfile ( sort keys %installer::globals
::lastsequence
)
117 $infoline = "$cabfile : $installer::globals::lastsequence{$cabfile}\n";
118 push(@installer::globals
::logfileinfo
, $infoline);
122 ##########################################################################
123 # Assigning sequencenumbers to files. This is requrired,
124 # if cabinet files shall be equivalent to packages.
125 ##########################################################################
127 sub assign_sequencenumbers_to_files
129 my ( $filesref ) = @_;
131 my %directaccess = ();
134 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
136 my $onefile = ${$filesref}[$i];
138 # Keeping order in cabinet files
139 # -> collecting all files in one cabinet file
140 # -> sorting files and assigning numbers
142 # Saving counter $i for direct access into files array
143 # "destination" of the file is a unique identifier ('Name' is not unique!)
144 if ( exists($directaccess{$onefile->{'destination'}}) ) { installer
::exiter
::exit_program
("ERROR: 'destination' at file not unique: $onefile->{'destination'}", "assign_sequencenumbers_to_files"); }
145 $directaccess{$onefile->{'destination'}} = $i;
147 my $cabfilename = $onefile->{'assignedcabinetfile'};
148 # collecting files in cabinet files
149 if ( ! exists($allassigns{$cabfilename}) )
152 $onecabfile{$onefile->{'destination'}} = 1;
153 $allassigns{$cabfilename} = \
%onecabfile;
157 $allassigns{$cabfilename}->{$onefile->{'destination'}} = 1;
161 # Sorting each hash and assigning numbers
162 # The destination of the file determines the sort order, not the filename!
164 foreach $cabfile ( sort keys %allassigns )
166 my $counter = $installer::globals
::cabfilecounter
{$cabfile};
168 foreach $dest ( sort keys %{$allassigns{$cabfile}} ) # <- sorting the destination!
170 my $directaccessnumber = $directaccess{$dest};
171 ${$filesref}[$directaccessnumber]->{'assignedsequencenumber'} = $counter;
177 ###############################################
178 # Generating the component name from a file
179 ###############################################
181 sub get_file_component_name
183 my ($fileref, $filesref) = @_;
185 # In this function exists the rule to create components from files
187 # Two files get the same componentid, if:
188 # both have the same destination directory.
189 # both have the same "gid" -> both were packed in the same zip file
190 # All other files are included into different components!
192 # my $componentname = $fileref->{'gid'} . "_" . $fileref->{'Dir'};
194 # $fileref->{'Dir'} is not sufficient! All files in a zip file have the same $fileref->{'Dir'},
195 # but can be in different subdirectories.
196 # Solution: destination=share\Scripts\beanshell\Capitalise\capitalise.bsh
197 # in which the filename (capitalise.bsh) has to be removed and all backslashes (slashes) are
198 # converted into underline.
200 my $destination = $fileref->{'destination'};
201 installer
::pathanalyzer
::get_path_from_fullqualifiedname
(\
$destination);
202 $destination =~ s/\s//g;
203 $destination =~ s/\\/\_/g;
204 $destination =~ s/\//\_
/g
;
205 $destination =~ s/\_\s*$//g; # removing ending underline
207 my $componentname = $fileref->{'gid'} . "__" . $destination;
209 # Files with different languages, need to be packed into different components.
210 # Then the installation of the language specific component is determined by a language condition.
212 if ( $fileref->{'ismultilingual'} )
214 my $officelanguage = $fileref->{'specificlanguage'};
215 $componentname = $componentname . "_" . $officelanguage;
218 $componentname = lc($componentname); # componentnames always lowercase
220 $componentname =~ s/\-/\_/g; # converting "-" to "_"
221 $componentname =~ s/\./\_/g; # converting "-" to "_"
223 # Attention: Maximum length for the componentname is 72
225 $componentname =~ s/gid_file_/g_f_/g;
226 $componentname =~ s/_extra_/_e_/g;
227 $componentname =~ s/_config_/_c_/g;
228 $componentname =~ s/_org_openoffice_/_o_o_/g;
229 $componentname =~ s/_program_/_p_/g;
230 $componentname =~ s/_typedetection_/_td_/g;
231 $componentname =~ s/_linguistic_/_l_/g;
232 $componentname =~ s/_module_/_m_/g;
233 $componentname =~ s/_optional_/_opt_/g;
234 $componentname =~ s/_packages/_pack/g;
235 $componentname =~ s/_menubar/_mb/g;
236 $componentname =~ s/_common_/_cm_/g;
237 $componentname =~ s/_export_/_exp_/g;
238 $componentname =~ s/_table_/_tb_/g;
239 $componentname =~ s/_sofficecfg_/_sc_/g;
240 $componentname =~ s/_startmodulecommands_/_smc_/g;
241 $componentname =~ s/_drawimpresscommands_/_dic_/g;
242 $componentname =~ s/_basiccommands_/_bac_/g;
243 $componentname =~ s/_basicidecommands_/_baic_/g;
244 $componentname =~ s/_genericcommands_/_genc_/g;
245 $componentname =~ s/_bibliographycommands_/_bibc_/g;
246 $componentname =~ s/_share_/_s_/g;
247 $componentname =~ s/_modules_/_ms_/g;
248 $componentname =~ s/_uiconfig_zip_/_ucz_/g;
249 $componentname =~ s/_soffice_cfg_/_sc_/g;
251 # All this is not necessary for files, which have the flag ASSIGNCOMPOMENT
254 if ( $fileref->{'Styles'} ) { $styles = $fileref->{'Styles'}; }
255 if ( $styles =~ /\bASSIGNCOMPOMENT\b/ ) { $componentname = get_component_from_assigned_file
($fileref->{'AssignComponent'}, $filesref); }
257 return $componentname;
260 ####################################################################
261 # Returning the component name for a defined file gid.
262 # This is necessary for files with flag ASSIGNCOMPOMENT
263 ####################################################################
265 sub get_component_from_assigned_file
267 my ($gid, $filesref) = @_;
269 my $onefile = installer
::existence
::get_specified_file
($filesref, $gid);
270 my $componentname = "";
271 if ( $onefile->{'componentname'} ) { $componentname = $onefile->{'componentname'}; }
272 else { installer
::exiter
::exit_program
("ERROR: No component defined for file: $gid", "get_component_from_assigned_file"); }
274 return $componentname;
277 ####################################################################
278 # Generating the special filename for the database file File.idt
279 # Sample: CONTEXTS, CONTEXTS1
280 # This name has to be unique.
281 # In most cases this is simply the filename.
282 ####################################################################
284 sub generate_unique_filename_for_filetable
286 my ($fileref, $component, $uniquefilenamehashref) = @_;
288 # This new filename has to be saved into $fileref, because this is needed to find the source.
289 # The filename sbasic.idx/OFFSETS is changed to OFFSETS, but OFFSETS is not unique.
290 # In this procedure names like OFFSETS5 are produced. And exactly this string has to be added to
291 # the array of all files.
293 my $uniquefilename = "";
296 if ( $fileref->{'Name'} ) { $uniquefilename = $fileref->{'Name'}; }
298 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$uniquefilename); # making /registry/schema/org/openoffice/VCL.xcs to VCL.xcs
300 # Reading unique filename with help of "Component_" in File table from old database
301 if (( $installer::globals
::updatedatabase
) && ( exists($uniquefilenamehashref->{"$component/$uniquefilename"}) ))
303 $uniquefilename = $uniquefilenamehashref->{"$component/$uniquefilename"}; # syntax of $value: ($uniquename;$shortname)
304 if ( $uniquefilename =~ /^\s*(.*?)\;\s*(.*?)\s*$/ ) { $uniquefilename = $1; }
305 $lcuniquefilename = lc($uniquefilename);
306 $installer::globals
::alluniquefilenames
{$uniquefilename} = 1;
307 $installer::globals
::alllcuniquefilenames
{$lcuniquefilename} = 1;
308 return $uniquefilename;
310 elsif (( $installer::globals
::prepare_winpatch
) && ( exists($installer::globals
::savedmapping
{"$component/$uniquefilename"}) ))
312 # If we have a FTK mapping for this component/file, use it.
313 $installer::globals
::savedmapping
{"$component/$uniquefilename"} =~ m
/^(.*);/;
314 $uniquefilename = $1;
315 $lcuniquefilename = lc($uniquefilename);
316 $installer::globals
::alluniquefilenames
{$uniquefilename} = 1;
317 $installer::globals
::alllcuniquefilenames
{$lcuniquefilename} = 1;
318 return $uniquefilename;
321 $uniquefilename =~ s/\-/\_/g; # no "-" allowed
322 $uniquefilename =~ s/\@/\_/g; # no "@" allowed
323 $uniquefilename =~ s/\$/\_/g; # no "$" allowed
324 $uniquefilename =~ s/^\s*\./\_/g; # no "." at the beginning allowed allowed
325 $uniquefilename =~ s/^\s*\d/\_d/g; # no number at the beginning allowed allowed (even file "0.gif", replacing to "_d.gif")
326 $uniquefilename =~ s/org_openoffice_/ooo_/g; # shorten the unique file name
328 my $lcuniquefilename = lc($uniquefilename); # only lowercase names
332 if ( ! exists($installer::globals
::alllcuniquefilenames
{$lcuniquefilename}) &&
333 ! exists($installer::globals
::savedrevmapping
{$lcuniquefilename}) )
335 $installer::globals
::alluniquefilenames
{$uniquefilename} = 1;
336 $installer::globals
::alllcuniquefilenames
{$lcuniquefilename} = 1;
342 # adding a number until the name is really unique: OFFSETS, OFFSETS1, OFFSETS2, ...
343 # But attention: Making "abc.xcu" to "abc1.xcu"
345 my $uniquefilenamebase = $uniquefilename;
351 if ( $uniquefilenamebase =~ /\./ )
353 $uniquefilename = $uniquefilenamebase;
354 $uniquefilename =~ s/\./$counter\./;
358 $uniquefilename = $uniquefilenamebase . $counter;
362 $lcuniquefilename = lc($uniquefilename); # only lowercase names
364 if ( ! exists($installer::globals
::alllcuniquefilenames
{$lcuniquefilename}) &&
365 ! exists($installer::globals
::savedrevmapping
{$lcuniquefilename}) )
367 $installer::globals
::alluniquefilenames
{$uniquefilename} = 1;
368 $installer::globals
::alllcuniquefilenames
{$lcuniquefilename} = 1;
375 return $uniquefilename;
378 ####################################################################
379 # Generating the special file column for the database file File.idt
380 # Sample: NAMETR~1.TAB|.nametranslation.table
381 # The first part has to be 8.3 conform.
382 ####################################################################
384 sub generate_filename_for_filetable
386 my ($fileref, $shortnamesref, $uniquefilenamehashref) = @_;
388 my $returnstring = "";
390 my $filename = $fileref->{'Name'};
392 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$filename); # making /registry/schema/org/openoffice/VCL.xcs to VCL.xcs
396 # Reading short string with help of "FileName" in File table from old database
397 if (( $installer::globals
::updatedatabase
) && ( exists($uniquefilenamehashref->{"$fileref->{'componentname'}/$filename"}) ))
399 my $value = $uniquefilenamehashref->{"$fileref->{'componentname'}/$filename"}; # syntax of $value: ($uniquename;$shortname)
400 if ( $value =~ /^\s*(.*?)\;\s*(.*?)\s*$/ ) { $shortstring = $2; } # already collected in function "collect_shortnames_from_old_database"
401 else { $shortstring = $filename; }
403 elsif (( $installer::globals
::prepare_winpatch
) && ( exists($installer::globals
::savedmapping
{"$fileref->{'componentname'}/$filename"}) ))
405 $installer::globals
::savedmapping
{"$fileref->{'componentname'}/$filename"} =~ m
/.*;(.*)/;
412 $shortstring = installer
::windows
::idtglobal
::make_eight_three_conform_with_hash
($filename, "file", $shortnamesref);
417 $shortstring = installer
::windows
::idtglobal
::make_eight_three_conform_with_hash
($filename, "file", $shortnamesref);
420 if ( $shortstring eq $filename ) { $returnstring = $filename; } # nothing changed
421 else {$returnstring = $shortstring . "\|" . $filename; }
423 return $returnstring;
426 #########################################
427 # Returning the filesize of a file
428 #########################################
434 my $file = $fileref->{'sourcepath'};
438 if ( -f
$file ) # test of existence. For instance services.rdb does not always exist
440 $filesize = ( -s
$file ); # file size can be "0"
450 #############################################
451 # Returning the file version, if required
452 # Sample: "8.0.1.8976";
453 #############################################
457 my ($onefile, $allvariables, $styles) = @_;
459 my $fileversion = "";
461 if ( $allvariables->{'USE_FILEVERSION'} )
463 if ( ! $allvariables->{'LIBRARYVERSION'} ) { installer
::exiter
::exit_program
("ERROR: USE_FILEVERSION is set, but not LIBRARYVERSION", "get_fileversion"); }
464 my $libraryversion = $allvariables->{'LIBRARYVERSION'};
465 if ( $libraryversion =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ )
470 my $concat = 100 * $minor + $micro;
471 $libraryversion = $major . "\." . $concat;
473 my $vendornumber = 0;
474 if ( $allvariables->{'VENDORPATCHVERSION'} ) { $vendornumber = $allvariables->{'VENDORPATCHVERSION'}; }
475 $fileversion = $libraryversion . "\." . $installer::globals
::buildid
. "\." . $vendornumber;
476 if ( $onefile->{'FileVersion'} ) { $fileversion = $onefile->{'FileVersion'}; } # overriding FileVersion in scp
478 # if ( $styles =~ /\bFONT\b/ )
480 # my $newfileversion = installer::windows::font::get_font_version($onefile->{'sourcepath'});
481 # if ( $newfileversion != 0 ) { $fileversion = $newfileversion; }
485 if ( $installer::globals
::prepare_winpatch
) { $fileversion = ""; } # Windows patches do not allow this version # -> who says so?
490 #############################################
491 # Returning the sequence for a file
492 #############################################
494 sub get_sequence_for_file
496 my ($number, $onefile, $fileentry, $allupdatesequenceshashref, $allupdatecomponentshashref, $allupdatefileorderhashref, $allfilecomponents) = @_;
500 my $pffcomponentname = $onefile->{'componentname'} . "_pff";
502 if ( $installer::globals
::updatedatabase
)
504 if (( exists($allupdatesequenceshashref->{$onefile->{'uniquename'}}) ) &&
505 (( $onefile->{'componentname'} eq $allupdatecomponentshashref->{$onefile->{'uniquename'}} ) ||
506 ( $pffcomponentname eq $allupdatecomponentshashref->{$onefile->{'uniquename'}} )))
508 # The second condition is necessary to find shifted files, that have same "uniquename", but are now
509 # located in another directory. This can be seen at the component name.
510 $sequence = $allupdatesequenceshashref->{$onefile->{'uniquename'}};
511 $onefile->{'assignedsequencenumber'} = $sequence;
512 # Collecting all used sequences, to guarantee, that no number is unused
513 $installer::globals
::allusedupdatesequences
{$sequence} = 1;
514 # Special help for files, that already have a "pff" component name (for example after ServicePack 1)
515 if ( $pffcomponentname eq $allupdatecomponentshashref->{$onefile->{'uniquename'}} )
517 $infoline = "Warning: Special handling for component \"$pffcomponentname\". This file was added after the final, but before this ServicePack.\n";
518 push(@installer::globals
::logfileinfo
, $infoline);
519 $onefile->{'componentname'} = $pffcomponentname; # pff for "post final file"
520 $fileentry->{'Component_'} = $onefile->{'componentname'};
521 if ( ! exists($allfilecomponents->{$fileentry->{'Component_'}}) ) { $allfilecomponents->{$fileentry->{'Component_'}} = 1; }
526 $installer::globals
::updatesequencecounter
++;
527 $sequence = $installer::globals
::updatesequencecounter
;
528 $onefile->{'assignedsequencenumber'} = $sequence;
529 # $onefile->{'assignedcabinetfile'} = $installer::globals::pffcabfilename; # assigning to cabinet file for "post final files"
530 # Collecting all new files
531 $installer::globals
::newupdatefiles
{$sequence} = $onefile;
532 # Saving in sequence hash
533 $allupdatefileorderhashref->{$sequence} = $onefile->{'uniquename'};
535 # If the new file is part of an existing component, this must be changed now. All files
536 # of one component have to be included in one cabinet file. But because the order must
537 # not change, all new files have to be added to new components.
538 # $onefile->{'componentname'} = $file{'Component_'};
540 $onefile->{'componentname'} = $onefile->{'componentname'} . "_pff"; # pff for "post final file"
541 $fileentry->{'Component_'} = $onefile->{'componentname'};
542 if ( ! exists($allfilecomponents->{$fileentry->{'Component_'}}) ) { $allfilecomponents->{$fileentry->{'Component_'}} = 1; }
543 $onefile->{'PostFinalFile'} = 1;
544 # $installer::globals::pfffileexists = 1;
545 # The sequence for this file has changed. It has to be inserted at the end of the files collector.
546 $installer::globals
::insert_file_at_end
= 1;
547 $installer::globals
::newfilescollector
{$sequence} = $onefile; # Adding new files to the end of the filescollector
548 $installer::globals
::newfilesexist
= 1;
551 elsif (( $onefile->{'assignedsequencenumber'} ) && ( $installer::globals
::use_packages_for_cabs
))
553 $sequence = $onefile->{'assignedsequencenumber'};
558 # my $sequence = $number + 1;
560 # Idea: Each component is packed into a cab file.
561 # This requires that all files in one cab file have sequences directly follwing each other,
562 # for instance from 1456 to 1466. Then in the media table the LastSequence for this cab file
564 # Because all files belonging to one component are directly behind each other in the file
565 # collector, it is possible to use simply an increasing number as sequence value.
566 # If files belonging to one component are not directly behind each other in the files collector
567 # this mechanism will no longer work.
573 #############################################
574 # Returning the Windows language of a file
575 #############################################
577 sub get_language_for_file
583 if ( $fileref->{'specificlanguage'} ) { $language = $fileref->{'specificlanguage'}; }
585 if (!($language eq ""))
587 $language = installer
::windows
::language
::get_windows_language
($language);
593 ####################################################################
594 # Creating a new KeyPath for components in TemplatesFolder.
595 ####################################################################
597 sub generate_registry_keypath
601 my $keypath = $onefile->{'Name'};
603 $keypath = lc($keypath);
604 $keypath = "userreg_" . $keypath;
609 ####################################################################
610 # Check, if in an update process files are missing. No removal
611 # of files allowed for Windows Patch creation.
612 # Also logging all new files, that have to be included in extra
613 # components and cab files.
614 ####################################################################
616 sub check_file_sequences
618 my ($allupdatefileorderhashref, $allupdatecomponentorderhashref) = @_;
620 # All used sequences stored in %installer::globals::allusedupdatesequences
621 # Maximum sequence number of old database stored in $installer::globals::updatelastsequence
622 # All new files stored in %installer::globals::newupdatefiles
626 my @missing_sequences = ();
627 my @really_missing_sequences = ();
629 for ( my $i = 1; $i <= $installer::globals
::updatelastsequence
; $i++ )
631 if ( ! exists($installer::globals
::allusedupdatesequences
{$i}) ) { push(@missing_sequences, $i); }
634 if ( $#missing_sequences > -1 )
636 # Missing sequences can also be caused by files included in merge modules. This files are added later into the file table.
637 # Therefore now it is time to check the content of the merge modules.
639 for ( my $j = 0; $j <= $#missing_sequences; $j++ )
641 my $filename = $allupdatefileorderhashref->{$missing_sequences[$j]};
643 # Is this a file from a merge module? Then this is no error.
644 if ( ! exists($installer::globals
::mergemodulefiles
{$filename}) )
646 push(@really_missing_sequences, $missing_sequences[$j]);
651 if ( $#really_missing_sequences > -1 )
653 my $errorstring = "";
654 for ( my $j = 0; $j <= $#really_missing_sequences; $j++ )
656 my $filename = $allupdatefileorderhashref->{$really_missing_sequences[$j]};
657 my $comp = $allupdatecomponentorderhashref->{$really_missing_sequences[$j]};
658 $errorstring = "$errorstring$filename (Sequence: $really_missing_sequences[$j], Component: \"$comp\")\n";
661 $infoline = "ERROR: Files are removed compared with update database.\nThe following files are missing:\n$errorstring";
662 push(@installer::globals
::logfileinfo
, $infoline);
663 installer
::exiter
::exit_program
($infoline, "check_file_sequences");
666 # Searching for new files
670 foreach my $key ( keys %installer::globals
::newupdatefiles
)
672 my $onefile = $installer::globals
::newupdatefiles
{$key};
676 $infoline = "\nNew files compared to the update database:\n";
677 push(@installer::globals
::logfileinfo
, $infoline);
680 $infoline = "$onefile->{'Name'} ($onefile->{'gid'}) Sequence: $onefile->{'assignedsequencenumber'}\n";
681 push(@installer::globals
::logfileinfo
, $infoline);
686 $infoline = "Info: No new file compared with update database!\n";
687 push(@installer::globals
::logfileinfo
, $infoline);
692 ###################################################################
693 # Collecting further conditions for the component table.
694 # This is used by multilayer products, to enable installation
695 # of separate layers.
696 ###################################################################
698 sub get_tree_condition_for_component
700 my ($onefile, $componentname) = @_;
702 if ( $onefile->{'destination'} )
704 my $dest = $onefile->{'destination'};
706 # Comparing the destination path with
707 # $installer::globals::hostnametreestyles{$hostname} = $treestyle;
708 # (-> hostname is the key, the style the value!)
710 foreach my $hostname ( keys %installer::globals
::hostnametreestyles
)
712 if (( $dest eq $hostname ) || ( $dest =~ /^\s*\Q$hostname\E\\/ ))
714 # the value is the style
715 my $style = $installer::globals
::hostnametreestyles
{$hostname};
716 # the condition is saved in %installer::globals::treestyles
717 my $condition = $installer::globals
::treestyles
{$style};
718 # Saving condition to be added in table Property
719 $installer::globals
::usedtreeconditions
{$condition} = 1;
720 $condition = $condition . "=1";
721 # saving this condition
722 $installer::globals
::treeconditions
{$componentname} = $condition;
724 # saving also at the file, for usage in fileinfo
725 $onefile->{'layer'} = $installer::globals
::treelayername
{$style};
731 ############################################
732 # Collecting all short names, that are
733 # already used by the old database
734 ############################################
736 sub collect_shortnames_from_old_database
738 my ($uniquefilenamehashref, $shortnameshashref) = @_;
740 foreach my $key ( keys %{$uniquefilenamehashref} )
742 my $value = $uniquefilenamehashref->{$key}; # syntax of $value: ($uniquename;$shortname)
744 if ( $value =~ /^\s*(.*?)\;\s*(.*?)\s*$/ )
746 my $shortstring = $2;
747 $shortnameshashref->{$shortstring} = 1; # adding the shortname to the array of all shortnames
752 ############################################
753 # Creating the file File.idt dynamically
754 ############################################
756 sub create_files_table
758 my ($filesref, $allfilecomponentsref, $basedir, $allvariables, $uniquefilenamehashref, $allupdatesequenceshashref, $allupdatecomponentshashref, $allupdatefileorderhashref) = @_;
760 installer
::logger
::include_timestamp_into_logfile
("Performance Info: File Table start");
762 # Structure of the files table:
763 # File Component_ FileName FileSize Version Language Attributes Sequence
764 # In this function, all components are created.
766 # $allfilecomponentsref is empty at the beginning
772 my @filehashtable = ();
773 my %allfilecomponents = ();
776 if ( $^O
=~ /cygwin/i ) { installer
::worker
::generate_cygwin_pathes
($filesref); }
778 # The filenames must be collected because of uniqueness
779 # 01-44-~1.DAT, 01-44-~2.DAT, ...
780 # my @shortnames = ();
783 if ( $installer::globals
::updatedatabase
) { collect_shortnames_from_old_database
($uniquefilenamehashref, \
%shortnames); }
785 installer
::windows
::idtglobal
::write_idt_header
(\
@filetable, "file");
786 installer
::windows
::idtglobal
::write_idt_header
(\
@filehashtable, "filehash");
788 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
792 my $onefile = ${$filesref}[$i];
795 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
796 if (( $styles =~ /\bJAVAFILE\b/ ) && ( ! ($allvariables->{'JAVAPRODUCT'} ))) { next; }
798 $file{'Component_'} = get_file_component_name
($onefile, $filesref);
799 $file{'File'} = generate_unique_filename_for_filetable
($onefile, $file{'Component_'}, $uniquefilenamehashref);
801 $onefile->{'uniquename'} = $file{'File'};
802 $onefile->{'componentname'} = $file{'Component_'};
804 # Collecting all components
805 # if (!(installer::existence::exists_in_array($file{'Component_'}, $allfilecomponentsref))) { push(@{$allfilecomponentsref}, $file{'Component_'}); }
807 if ( ! exists($allfilecomponents{$file{'Component_'}}) ) { $allfilecomponents{$file{'Component_'}} = 1; }
809 $file{'FileName'} = generate_filename_for_filetable
($onefile, \
%shortnames, $uniquefilenamehashref);
811 $file{'FileSize'} = get_filesize
($onefile);
813 $file{'Version'} = get_fileversion
($onefile, $allvariables, $styles);
815 $file{'Language'} = get_language_for_file
($onefile);
817 if ( $styles =~ /\bDONT_PACK\b/ ) { $file{'Attributes'} = "8192"; }
818 else { $file{'Attributes'} = "16384"; }
820 # $file{'Attributes'} = "16384"; # Sourcefile is packed
821 # $file{'Attributes'} = "8192"; # Sourcefile is unpacked
823 $installer::globals
::insert_file_at_end
= 0;
825 $file{'Sequence'} = get_sequence_for_file
($counter, $onefile, \
%file, $allupdatesequenceshashref, $allupdatecomponentshashref, $allupdatefileorderhashref, \
%allfilecomponents);
827 $onefile->{'sequencenumber'} = $file{'Sequence'};
829 my $oneline = $file{'File'} . "\t" . $file{'Component_'} . "\t" . $file{'FileName'} . "\t"
830 . $file{'FileSize'} . "\t" . $file{'Version'} . "\t" . $file{'Language'} . "\t"
831 . $file{'Attributes'} . "\t" . $file{'Sequence'} . "\n";
833 push(@filetable, $oneline);
835 if ( ! $installer::globals
::insert_file_at_end
) { push(@allfiles, $onefile); }
837 # Collecting all component conditions
838 if ( $onefile->{'ComponentCondition'} )
840 if ( ! exists($installer::globals
::componentcondition
{$file{'Component_'}}))
842 $installer::globals
::componentcondition
{$file{'Component_'}} = $onefile->{'ComponentCondition'};
846 # Collecting also all tree conditions for multilayer products
847 get_tree_condition_for_component
($onefile, $file{'Component_'});
849 # Collecting all component names, that have flag VERSION_INDEPENDENT_COMP_ID
850 # This should be all components with constant API, for example URE
851 if ( $styles =~ /\bVERSION_INDEPENDENT_COMP_ID\b/ )
853 $installer::globals
::base_independent_components
{$onefile->{'componentname'}} = 1;
856 # Collecting all component ids, that are defined at files in scp project (should not be used anymore)
857 if ( $onefile->{'CompID'} )
859 if ( ! exists($installer::globals
::componentid
{$onefile->{'componentname'}}))
861 $installer::globals
::componentid
{$onefile->{'componentname'}} = $onefile->{'CompID'};
865 if ( $installer::globals
::componentid
{$onefile->{'componentname'}} ne $onefile->{'CompID'} )
867 installer
::exiter
::exit_program
("ERROR: There is already a ComponentID for component \"$onefile->{'componentname'}\" : \"$installer::globals::componentid{$onefile->{'componentname'}}\" . File \"$onefile->{'gid'}\" uses \"$onefile->{'CompID'}\" !", "create_files_table");
871 # Also checking vice versa. Is this ComponentID already used? If yes, is the componentname the same?
873 if ( ! exists($installer::globals
::comparecomponentname
{$onefile->{'CompID'}}))
875 $installer::globals
::comparecomponentname
{$onefile->{'CompID'}} = $onefile->{'componentname'};
879 if ( $installer::globals
::comparecomponentname
{$onefile->{'CompID'}} ne $onefile->{'componentname'} )
881 installer
::exiter
::exit_program
("ERROR: There is already a component for ComponentID \"$onefile->{'CompID'}\" : \"$installer::globals::comparecomponentname{$onefile->{'CompID'}}\" . File \"$onefile->{'gid'}\" has same component id but is included in component \"$onefile->{'componentname'}\" !", "create_files_table");
886 # Collecting all language specific conditions
887 # if ( $onefile->{'haslanguagemodule'} )
888 if ( $onefile->{'ismultilingual'} )
890 if ( $onefile->{'ComponentCondition'} ) { installer
::exiter
::exit_program
("ERROR: Cannot set language condition. There is already another component condition for file $onefile->{'gid'}: \"$onefile->{'ComponentCondition'}\" !", "create_files_table"); }
892 if ( $onefile->{'specificlanguage'} eq "" ) { installer
::exiter
::exit_program
("ERROR: There is no specific language for file at language module: $onefile->{'gid'} !", "create_files_table"); }
893 my $locallanguage = $onefile->{'specificlanguage'};
894 my $property = "IS" . $file{'Language'};
896 my $condition = $property . "=" . $value;
898 $onefile->{'ComponentCondition'} = $condition;
900 if ( exists($installer::globals
::componentcondition
{$file{'Component_'}}))
902 if ( $installer::globals
::componentcondition
{$file{'Component_'}} ne $condition ) { installer
::exiter
::exit_program
("ERROR: There is already another component condition for file $onefile->{'gid'}: \"$installer::globals::componentcondition{$file{'Component_'}}\" and \"$condition\" !", "create_files_table"); }
906 $installer::globals
::componentcondition
{$file{'Component_'}} = $condition;
909 # collecting all properties for table Property
910 if ( ! exists($installer::globals
::languageproperties
{$property}) ) { $installer::globals
::languageproperties
{$property} = $value; }
913 if ( $installer::globals
::prepare_winpatch
)
915 my $path = $onefile->{'sourcepath'};
916 if ( $^O
=~ /cygwin/i ) { $path = $onefile->{'cyg_sourcepath'}; }
918 open(FILE
, $path) or die "ERROR: Can't open $path for creating file hash";
920 my $hashinfo = pack("l", 20);
921 $hashinfo .= Digest
::MD5
->new->addfile(*FILE
)->digest;
923 my @i = unpack ('x[l]l4', $hashinfo);
924 $oneline = $file{'File'} . "\t" .
930 push (@filehashtable, $oneline);
933 # Saving the sequence number in a hash with uniquefilename as key.
934 # This is used for better performance in "save_packorder"
935 $installer::globals
::uniquefilenamesequence
{$onefile->{'uniquename'}} = $onefile->{'sequencenumber'};
937 # Special handling for files in PREDEFINED_OSSHELLNEWDIR. These components
938 # need as KeyPath a RegistryItem in HKCU
940 if ( $onefile->{'Dir'} ) { $destdir = $onefile->{'Dir'}; }
942 if (( $destdir =~ /\bPREDEFINED_OSSHELLNEWDIR\b/ ) || ( $onefile->{'needs_user_registry_key'} ))
944 my $keypath = generate_registry_keypath
($onefile);
945 $onefile->{'userregkeypath'} = $keypath;
946 push(@installer::globals
::userregistrycollector
, $onefile);
947 $installer::globals
::addeduserregitrykeys
= 1;
951 # putting content from %allfilecomponents to $allfilecomponentsref for later usage
952 foreach $localkey (keys %allfilecomponents ) { push( @
{$allfilecomponentsref}, $localkey); }
954 my $filetablename = $basedir . $installer::globals
::separator
. "File.idt";
955 installer
::files
::save_file
($filetablename ,\
@filetable);
956 $infoline = "\nCreated idt file: $filetablename\n";
957 push(@installer::globals
::logfileinfo
, $infoline);
959 installer
::logger
::include_timestamp_into_logfile
("Performance Info: File Table end");
961 my $filehashtablename = $basedir . $installer::globals
::separator
. "MsiFileHash.idt";
962 installer
::files
::save_file
($filehashtablename ,\
@filehashtable);
963 $infoline = "\nCreated idt file: $filehashtablename\n";
964 push(@installer::globals
::logfileinfo
, $infoline);
966 # Now the new files can be added to the files collector (only in update packaging processes)
967 if ( $installer::globals
::newfilesexist
)
969 foreach my $seq (sort keys %installer::globals
::newfilescollector
) { push(@allfiles, $installer::globals
::newfilescollector
{$seq}) }