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: scriptitems.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
::scriptitems
;
34 use installer
::converter
;
35 use installer
::existence
;
36 use installer
::exiter
;
37 use installer
::globals
;
38 use installer
::languages
;
39 use installer
::logger
;
40 use installer
::pathanalyzer
;
41 use installer
::remover
;
42 use installer
::systemactions
;
44 ################################################################
45 # Resolving the GID for the directories defined in setup script
46 ################################################################
48 sub resolve_all_directory_names
50 my ($directoryarrayref) = @_;
52 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::resolve_all_directory_names : $#{$directoryarrayref}"); }
54 # After this procedure the hash shall contain the complete language
55 # dependent path, not only the language dependent HostName.
57 my ($key, $value, $parentvalue, $parentgid, $parentdirectoryhashref);
59 for ( my $i = 0; $i <= $#{$directoryarrayref}; $i++ )
61 my $directoryhashref = ${$directoryarrayref}[$i];
62 my $gid = $directoryhashref-> {'gid'};
63 my $parentid = $directoryhashref-> {'ParentID'};
65 if ( $parentid ne "PREDEFINED_PROGDIR" )
67 # find the array of the parentid, which has to be defined before in setup script
68 # and is therefore listed before in this array
70 for ( my $j = 0; $j <= $i; $j++ )
72 $parentdirectoryhashref = ${$directoryarrayref}[$j];
73 $parentgid = $parentdirectoryhashref->{'gid'};
75 if ( $parentid eq $parentgid)
81 # and now we can put the path together
82 # But take care of the languages!
84 my $dirismultilingual = $directoryhashref->{'ismultilingual'};
85 my $parentismultilingual = $parentdirectoryhashref->{'ismultilingual'};
87 # First: Both directories are language independent or both directories are language dependent
89 if ((( ! $dirismultilingual ) && ( ! $parentismultilingual )) ||
90 (( $dirismultilingual ) && ( $parentismultilingual )))
92 foreach $key (keys %{$directoryhashref})
94 # the key ("HostName (en-US)") must be usable for both hashes
96 if ( $key =~ /\bHostName\b/ )
99 $value = $directoryhashref->{$key};
100 if ( $parentdirectoryhashref->{$key} ) { $parentvalue = $parentdirectoryhashref->{$key}; }
102 # It is possible, that in scp project, a directory is defined in more languages than
103 # the directory parent (happened after automatic generation of macros.inc).
104 # Therefore this is checked now and written with a warning into the logfile.
105 # This is no error, because (in most cases) the concerned language is not build.
107 if ($parentvalue eq "")
109 $directoryhashref->{$key} = "FAILURE";
110 my $infoline = "WARNING: No hostname for $parentid with \"$key\". Needed by child directory $gid !\n";
111 push( @installer::globals
::globallogfileinfo
, $infoline);
115 $directoryhashref->{$key} = $parentvalue . $installer::globals
::separator
. $value;
121 # Second: The directory is language dependent, the parent not
123 if (( $dirismultilingual ) && ( ! $parentismultilingual ))
125 $parentvalue = $parentdirectoryhashref->{'HostName'}; # there is only one
127 foreach $key (keys %{$directoryhashref}) # the current directory
129 if ( $key =~ /\bHostName\b/ )
131 $value = $directoryhashref->{$key};
132 $directoryhashref->{$key} = $parentvalue . $installer::globals
::separator
. $value;
137 # Third: The directory is not language dependent, the parent is language dependent
139 if (( ! $dirismultilingual ) && ( $parentismultilingual ))
141 $value = $directoryhashref->{'HostName'}; # there is only one
142 delete($directoryhashref->{'HostName'});
144 foreach $key (keys %{$parentdirectoryhashref}) # the parent directory
146 if ( $key =~ /\bHostName\b/ )
148 $parentvalue = $parentdirectoryhashref->{$key}; # there is only one
149 $directoryhashref->{$key} = $parentvalue . $installer::globals
::separator
. $value;
153 $directoryhashref->{'ismultilingual'} = 1; # now this directory is also language dependent
159 #############################################################################
160 # Files with flag DELETE_ONLY do not need to be packed into installation set
161 #############################################################################
163 sub remove_delete_only_files_from_productlists
165 my ($productarrayref) = @_;
167 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::remove_delete_only_files_from_productlists : $#{$productarrayref}"); }
171 for ( my $i = 0; $i <= $#{$productarrayref}; $i++ )
173 my $oneitem = ${$productarrayref}[$i];
176 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
178 if (!($styles =~ /\bDELETE_ONLY\b/))
180 push(@newitems, $oneitem);
187 #############################################################################
188 # Files with flag NOT_IN_SUITE do not need to be packed into
189 # Suite installation sets
190 #############################################################################
192 sub remove_notinsuite_files_from_productlists
194 my ($productarrayref) = @_;
196 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::remove_notinsuite_files_from_productlists : $#{$productarrayref}"); }
200 for ( my $i = 0; $i <= $#{$productarrayref}; $i++ )
202 my $oneitem = ${$productarrayref}[$i];
205 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
207 if (!($styles =~ /\bNOT_IN_SUITE\b/))
209 push(@newitems, $oneitem);
213 my $infoline = "INFO: Flag NOT_IN_SUITE \-\> Removing $oneitem->{'gid'} from file list.\n";
214 push( @installer::globals
::globallogfileinfo
, $infoline);
221 #############################################################################
222 # Files with flag NOT_IN_SUITE do not need to be packed into
223 # Suite installation sets
224 #############################################################################
226 sub remove_office_start_language_files
228 my ($productarrayref) = @_;
230 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::remove_notinsuite_files_from_productlists : $#{$productarrayref}"); }
234 for ( my $i = 0; $i <= $#{$productarrayref}; $i++ )
236 my $oneitem = ${$productarrayref}[$i];
239 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
241 if (!($styles =~ /\bSET_OFFICE_LANGUAGE\b/))
243 push(@newitems, $oneitem);
247 my $infoline = "INFO: Flag SET_OFFICE_LANGUAGE \-\> Removing $oneitem->{'gid'} from file list.\n";
248 push( @installer::globals
::globallogfileinfo
, $infoline);
255 #############################################################################
256 # Registryitems for Uninstall have to be removed
257 #############################################################################
259 sub remove_uninstall_regitems_from_script
261 my ($registryarrayref) = @_;
263 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::remove_uninstall_regitems_from_script : $#{$registryarrayref}"); }
267 for ( my $i = 0; $i <= $#{$registryarrayref}; $i++ )
269 my $oneitem = ${$registryarrayref}[$i];
272 if ( $oneitem->{'Subkey'} ) { $subkey = $oneitem->{'Subkey'}; }
274 if ( $subkey =~ /Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall/ ) { next; }
276 push(@newitems, $oneitem);
282 ##############################################################################
283 # Searching the language module for a specified language
284 ##############################################################################
286 sub get_languagespecific_module
288 my ( $lang, $modulestring ) = @_;
290 my $langmodulestring = "";
293 foreach $module ( keys %installer::globals
::alllangmodules
)
295 if (( $installer::globals
::alllangmodules
{$module} eq $lang ) && ( $modulestring =~ /\b$module\b/ ))
297 $langmodulestring = "$langmodulestring,$module";
301 $langmodulestring =~ s/^\s*,//;
303 if ( $langmodulestring eq "" ) { installer
::exiter
::exit_program
("ERROR: No language pack module found for language $lang in string \"$modulestring\"!", "get_languagespecific_module"); }
305 return $langmodulestring;
308 ##############################################################################
309 # Removing all items in product lists which do not have the correct languages
310 ##############################################################################
312 sub resolving_all_languages_in_productlists
314 my ($productarrayref, $languagesarrayref) = @_;
316 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::resolving_all_languages_in_productlists : $#{$productarrayref} : $#{$languagesarrayref}"); }
318 my @itemsinalllanguages = ();
322 for ( my $i = 0; $i <= $#{$productarrayref}; $i++ )
324 my $oneitem = ${$productarrayref}[$i];
326 my $ismultilingual = $oneitem->{'ismultilingual'};
328 if (!($ismultilingual)) # nothing to do with single language items
330 $oneitem->{'specificlanguage'} = "";
331 push(@itemsinalllanguages, $oneitem);
333 else #all language dependent files
335 for ( my $j = 0; $j <= $#{$languagesarrayref}; $j++ ) # iterating over all languages
337 my $onelanguage = ${$languagesarrayref}[$j];
339 my %oneitemhash = ();
341 foreach $key (keys %{$oneitem})
343 if ( $key =~ /\(\S+\)/ ) # this are the language dependent keys
345 if ( $key =~ /\(\Q$onelanguage\E\)/ )
347 $value = $oneitem->{$key};
348 $oneitemhash{$key} = $value;
353 $value = $oneitem->{$key};
354 $oneitemhash{$key} = $value;
358 $oneitemhash{'specificlanguage'} = $onelanguage;
360 if ( $oneitemhash{'haslanguagemodule'} )
362 my $langmodulestring = get_languagespecific_module
($onelanguage, $oneitemhash{'modules'});
363 $oneitemhash{'modules'} = $langmodulestring;
366 push(@itemsinalllanguages, \
%oneitemhash);
371 return \
@itemsinalllanguages;
374 ################################################################################
375 # Removing all modules, that have the flag LANGUAGEMODULE, but do not
376 # have the correct language
377 ################################################################################
379 sub remove_not_required_language_modules
381 my ($modulesarrayref, $languagesarrayref) = @_;
385 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
387 my $module = ${$modulesarrayref}[$i];
389 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
391 if ( $styles =~ /\bLANGUAGEMODULE\b/ )
393 if ( ! exists($module->{'Language'}) ) { installer
::exiter
::exit_program
("ERROR: \"$module->{'gid'}\" has flag LANGUAGEMODULE, but does not know its language!", "remove_not_required_language_modules"); }
394 my $modulelanguage = $module->{'Language'};
395 # checking, if language is required
397 for ( my $j = 0; $j <= $#{$languagesarrayref}; $j++ )
399 my $onelanguage = ${$languagesarrayref}[$j];
400 if ( $onelanguage eq $modulelanguage )
407 if ( $doinclude ) { push(@allmodules, $module); }
411 push(@allmodules, $module);
418 ################################################################################
419 # Removing all modules, that have a spellchecker language that is not
420 # required for this product (spellchecker selection).
421 # All required spellchecker languages are stored in
422 # %installer::globals::spellcheckerlanguagehash
423 ################################################################################
425 sub remove_not_required_spellcheckerlanguage_modules
427 my ($modulesarrayref) = @_;
432 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
434 my $module = ${$modulesarrayref}[$i];
435 if ( $module->{'Spellcheckerlanguage'} ) # selecting modules with Spellcheckerlanguage
437 if ( exists($installer::globals
::spellcheckerlanguagehash
{$module->{'Spellcheckerlanguage'}}) )
439 push(@allmodules, $module);
443 $infoline = "Spellchecker selection: Removing module $module->{'gid'}\n";
444 push( @installer::globals
::logfileinfo
, $infoline);
446 # Collecting all files at modules that are removed
448 if ( $module->{'Files'} )
450 if ( $module->{'Files'} =~ /^\s*\((.*?)\)\s*$/ )
454 my $filelisthash = installer
::converter
::convert_stringlist_into_hash
(\
$filelist, ",");
455 foreach my $onefile ( keys %{$filelisthash} ) { $installer::globals
::spellcheckerfilehash
{$onefile} = 1; }
462 push(@allmodules, $module);
469 ################################################################################
470 # Removing all modules, that belong to a module that was removed
471 # in "remove_not_required_spellcheckerlanguage_modules" because of the
472 # spellchecker language. The files belonging to the modules are collected
473 # in %installer::globals::spellcheckerfilehash.
474 ################################################################################
476 sub remove_not_required_spellcheckerlanguage_files
478 my ($filesarrayref) = @_;
483 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
485 my $onefile = ${$filesarrayref}[$i];
486 if ( exists($installer::globals
::spellcheckerfilehash
{$onefile->{'gid'}}) )
488 $infoline = "Spellchecker selection: Removing file $onefile->{'gid'}\n";
489 push( @installer::globals
::logfileinfo
, $infoline);
492 push(@filesarray, $onefile);
498 ################################################################################
499 # Looking for directories without correct HostName
500 ################################################################################
502 sub checking_directories_with_corrupt_hostname
504 my ($dirsref, $languagesarrayref) = @_;
506 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
508 my $onedir = ${$dirsref}[$i];
512 if ( $onedir->{'HostName'} ) { $hostname = $onedir->{'HostName'}; }
514 if ( $hostname eq "" )
517 for ( my $j = 0; $j <= $#{$languagesarrayref}; $j++ ) { $langstring .= ${$languagesarrayref}[$j] . " "; }
518 installer
::exiter
::exit_program
("ERROR: HostName not defined for $onedir->{'gid'} for specified language. Probably you wanted to create an installation set, in a language not defined in scp2 project. You selected the following language(s): $langstring", "checking_directories_with_corrupt_hostname");
521 if ( $hostname eq "FAILURE" )
523 installer
::exiter
::exit_program
("ERROR: Could not create HostName for $onedir->{'gid'} (missing language at parent). See logfile warning for more info!", "checking_directories_with_corrupt_hostname");
528 ################################################################################
529 # Setting global properties
530 ################################################################################
532 sub set_global_directory_hostnames
534 my ($dirsref, $allvariables) = @_;
536 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
538 my $onedir = ${$dirsref}[$i];
540 if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
542 if ( $styles =~ /\bOFFICEDIRECTORY\b/ )
544 $installer::globals
::officedirhostname
= $onedir->{'HostName'};
545 $installer::globals
::officedirgid
= $onedir->{'gid'};
546 $allvariables->{'OFFICEDIRECTORYHOSTNAME'} = $installer::globals
::officedirhostname
;
548 if ( $styles =~ /\bBASISDIRECTORY\b/ )
550 $installer::globals
::basisdirhostname
= $onedir->{'HostName'};
551 $installer::globals
::basisdirgid
= $onedir->{'gid'};
552 $allvariables->{'BASISDIRECTORYHOSTNAME'} = $installer::globals
::basisdirhostname
;
554 if ( $styles =~ /\bUREDIRECTORY\b/ )
556 $installer::globals
::uredirhostname
= $onedir->{'HostName'};
557 $installer::globals
::uredirgid
= $onedir->{'gid'};
558 $allvariables->{'UREDIRECTORYHOSTNAME'} = $installer::globals
::uredirhostname
;
560 if ( $styles =~ /\bSUNDIRECTORY\b/ )
562 $installer::globals
::sundirhostname
= $onedir->{'HostName'};
563 $installer::globals
::sundirgid
= $onedir->{'gid'};
564 $allvariables->{'SUNDIRECTORYHOSTNAME'} = $installer::globals
::sundirhostname
;
569 ########################################################
570 # Recursively defined procedure to order
571 # modules and directories
572 ########################################################
576 my ($allitems, $startparent, $newitemorder) = @_;
578 for ( my $i = 0; $i <= $#{$allitems}; $i++ )
580 my $gid = ${$allitems}[$i]->{'gid'};
582 if ( ${$allitems}[$i]->{'ParentID'} ) { $parent = ${$allitems}[$i]->{'ParentID'}; }
584 if ( $parent eq $startparent )
586 push(@
{$newitemorder}, ${$allitems}[$i]);
588 get_children
($allitems, $parent, $newitemorder); # recursive!
593 ################################################################################
594 # Using different HostName for language packs
595 ################################################################################
597 sub use_langpack_hostname
601 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
603 my $onedir = ${$dirsref}[$i];
604 if (( $onedir->{'LangPackHostName'} ) && ( $onedir->{'LangPackHostName'} ne "" )) { $onedir->{'HostName'} = $onedir->{'LangPackHostName'}; }
608 ################################################################################
609 # Using different HostName for language packs
610 ################################################################################
612 sub use_patch_hostname
616 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
618 my $onedir = ${$dirsref}[$i];
619 if (( $onedir->{'PatchHostName'} ) && ( $onedir->{'PatchHostName'} ne "" )) { $onedir->{'HostName'} = $onedir->{'PatchHostName'}; }
623 ################################################################################
624 # Using different HostName for language packs
625 ################################################################################
627 sub use_langpack_copy_scpaction
629 my ($scpactionsref) = @_;
631 for ( my $i = 0; $i <= $#{$scpactionsref}; $i++ )
633 my $onescpaction = ${$scpactionsref}[$i];
634 if (( $onescpaction->{'LangPackCopy'} ) && ( $onescpaction->{'LangPackCopy'} ne "" )) { $onescpaction->{'Copy'} = $onescpaction->{'LangPackCopy'}; }
638 ################################################################################
639 # Using different HostName for language packs
640 ################################################################################
642 sub use_patch_copy_scpaction
644 my ($scpactionsref) = @_;
646 for ( my $i = 0; $i <= $#{$scpactionsref}; $i++ )
648 my $onescpaction = ${$scpactionsref}[$i];
649 if (( $onescpaction->{'PatchCopy'} ) && ( $onescpaction->{'PatchCopy'} ne "" )) { $onescpaction->{'Copy'} = $onescpaction->{'PatchCopy'}; }
653 ################################################################################
654 # Shifting parent directories of URE and Basis layer, so that
655 # these directories are located below the Brand layer.
656 # Style: SHIFT_BASIS_INTO_BRAND_LAYER
657 ################################################################################
659 sub shift_basis_directory_parents
665 my @shifteddirs = ();
667 my $officedirgid = "";
669 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
671 my $onedir = ${$dirsref}[$i];
673 if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
675 if ( $styles =~ /\bOFFICEDIRECTORY\b/ ) { $officedirgid = $onedir->{'gid'}; }
678 if ( $officedirgid ne "" )
680 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
682 my $onedir = ${$dirsref}[$i];
684 if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
686 if (( $styles =~ /\bBASISDIRECTORY\b/ ) || ( $styles =~ /\bUREDIRECTORY\b/ ))
688 $onedir->{'ParentID'} = $officedirgid;
692 # Sorting directories
693 my $startgid = "PREDEFINED_PROGDIR";
694 get_children
($dirsref, $startgid, \
@alldirs);
700 ################################################################################
701 # Setting the name of the directory with style OFFICEDIRECTORY.
702 # The name can be defined in property OFFICEDIRECTORYNAME.
703 ################################################################################
705 sub set_officedirectory_name
707 my ($dirsref, $officedirname) = @_;
709 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
711 my $onedir = ${$dirsref}[$i];
713 if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
714 if ( $styles =~ /\bOFFICEDIRECTORY\b/ )
716 $onedir->{'HostName'} = $officedirname;
722 ################################################################################
723 # Simplifying the name for language dependent items from "Name (xy)" to "Name"
724 ################################################################################
726 sub changing_name_of_language_dependent_keys
728 my ($itemsarrayref) = @_;
730 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::changing_name_of_language_dependent_keys : $#{$itemsarrayref}"); }
732 # Changing key for multilingual items from "Name ( )" to "Name" or "HostName ( )" to "HostName"
734 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
736 my $oneitem = ${$itemsarrayref}[$i];
737 my $onelanguage = $oneitem->{'specificlanguage'};
739 if (!($onelanguage eq "" )) # language dependent item
743 foreach $itemkey (keys %{$oneitem})
745 if ( $itemkey =~ /^\s*(\S+?)\s+\(\S+\)\s*$/ )
748 my $itemvalue = $oneitem->{$itemkey};
749 $oneitem->{$newitemkey} = $itemvalue;
750 delete($oneitem->{$itemkey});
757 ################################################################################
758 # Collecting language specific names for language packs
759 ################################################################################
761 sub collect_language_specific_names
763 my ($itemsarrayref) = @_;
765 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
767 my $oneitem = ${$itemsarrayref}[$i];
769 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
771 if ( $styles =~ /\bUSELANGUAGENAME\b/ )
774 if ( $oneitem->{'Language'} ) { $language = $oneitem->{'Language'}; }
775 my $specificlanguage = "";
776 if ( $oneitem->{'specificlanguage'} ) { $specificlanguage = $oneitem->{'specificlanguage'}; }
778 if (( $language ne "" ) && ( $language eq $specificlanguage ))
780 if (! installer
::existence
::exists_in_array
($oneitem->{'Name'}, \
@installer::globals
::languagenames
))
782 push(@installer::globals
::languagenames
, $oneitem->{'Name'});
789 ################################################################################
790 # Replacement of setup variables in ConfigurationItems and ProfileItems
791 # <productkey>, <buildid>, <sequence_languages>, <productcode>, <upgradecode>, <productupdate>
792 ################################################################################
794 sub replace_setup_variables
796 my ($itemsarrayref, $languagestringref, $hashref) = @_;
798 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::replace_setup_variables : $#{$itemsarrayref} : $$languagestringref : $hashref->{'PRODUCTNAME'}"); }
800 my $languagesstring = $$languagestringref;
801 $languagesstring =~ s/\_/ /g; # replacing underscore with whitespace
802 # $languagesstring is "01 49" instead of "en-US de"
803 installer
::languages
::fake_languagesstring
(\
$languagesstring);
805 my $productname = $hashref->{'PRODUCTNAME'};
806 my $productversion = $hashref->{'PRODUCTVERSION'};
807 my $userdirproductversion = "";
808 if ( $hashref->{'USERDIRPRODUCTVERSION'} ) { $userdirproductversion = $hashref->{'USERDIRPRODUCTVERSION'}; }
809 my $productkey = $productname . " " . $productversion;
811 # string $buildid, which is used to replace the setup variable <buildid>
813 my $localminor = "flat";
814 if ( $installer::globals
::minor
ne "" ) { $localminor = $installer::globals
::minor
; }
815 else { $localminor = $installer::globals
::lastminor
; }
817 my $localbuild = $installer::globals
::build
;
819 if ( $localbuild =~ /^\s*(\w+?)(\d+)\s*$/ ) { $localbuild = $2; } # using "680" instead of "src680"
821 my $buildidstring = $localbuild . $localminor . "(Build:" . $installer::globals
::buildid
. ")";
823 # the environment variable CWS_WORK_STAMP is set only in CWS
824 if ( $ENV{'CWS_WORK_STAMP'} ) { $buildidstring = $buildidstring . "\[CWS\:" . $ENV{'CWS_WORK_STAMP'} . "\]"; }
826 if ( $localminor =~ /^\s*\w(\d+)\w*\s*$/ ) { $localminor = $1; }
829 my $updateid = $productname . "_" . $userdirproductversion . "_" . $$languagestringref;
830 $updateid =~ s/ /_/g;
832 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
834 my $oneitem = ${$itemsarrayref}[$i];
835 my $value = $oneitem->{'Value'};
837 $value =~ s/\<buildid\>/$buildidstring/;
838 $value =~ s/\<sequence_languages\>/$languagesstring/;
839 $value =~ s/\<productkey\>/$productkey/;
840 $value =~ s/\<productcode\>/$installer::globals::productcode/;
841 $value =~ s/\<upgradecode\>/$installer::globals::upgradecode/;
842 $value =~ s/\<alllanguages\>/$languagesstring/;
843 $value =~ s/\<productmajor\>/$localbuild/;
844 $value =~ s/\<productminor\>/$localminor/;
845 $value =~ s/\<productbuildid\>/$installer::globals::buildid/;
846 $value =~ s/\<sourceid\>/$installer::globals::build/;
847 $value =~ s/\<updateid\>/$updateid/;
848 $value =~ s/\<pkgformat\>/$installer::globals::packageformat/;
849 $value =~ s/\<vendor\>/$ENV{'OOO_VENDOR'}/;
850 $value =~ s/\<buildversion\>/$ENV{'BUILD_VER_STRING'}/;
852 $oneitem->{'Value'} = $value;
856 ################################################################################
857 # By defining variable LOCALUSERDIR in *.lst it is possible to change
858 # the standard destination of user directory defined in scp2 ($SYSUSERCONFIG).
859 ################################################################################
861 sub replace_userdir_variable
863 my ($itemsarrayref) = @_;
866 if ( $allvariableshashref->{'LOCALUSERDIR'} ) { $userdir = $allvariableshashref->{'LOCALUSERDIR'}; }
867 else { $userdir = $installer::globals
::simpledefaultuserdir
; }
869 if ( $userdir ne "" )
871 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
873 my $oneitem = ${$itemsarrayref}[$i];
874 $oneitem->{'Value'} =~ s/\$SYSUSERCONFIG/$userdir/;
879 #####################################################################################
880 # Files and ConfigurationItems are not included for all languages.
881 # For instance asian fonts. These can be removed, if no "Name" is found.
882 # ConfigurationItems are not always defined in the linguistic configuration file.
883 # The "Key" cannot be found for them.
884 #####################################################################################
886 sub remove_non_existent_languages_in_productlists
888 my ($itemsarrayref, $languagestringref, $searchkey, $itemtype) = @_;
890 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::remove_non_existent_languages_in_productlists : $#{$itemsarrayref} : $$languagestringref : $searchkey : $itemtype"); }
892 # Removing of all non existent files, for instance asian fonts
894 installer
::logger
::include_header_into_logfile
("Removing for this language $$languagestringref:");
896 my @allexistentitems = ();
900 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
902 my $oneitem = ${$itemsarrayref}[$i];
903 my $oneitemname = ""; # $searchkey is "Name" for files and "Key" for ConfigurationItems
905 if ( $oneitem->{$searchkey} ) { $oneitemname = $oneitem->{$searchkey} }
907 my $itemtoberemoved = 0;
909 if ($oneitemname eq "") # for instance asian font in english installation set
911 $itemtoberemoved = 1;
914 if ($itemtoberemoved)
916 $infoline = "WARNING: Language $$languagestringref: No $itemtype packed for $oneitem->{'gid'}!\n";
917 push( @installer::globals
::logfileinfo
, $infoline);
921 push(@allexistentitems, $oneitem);
926 push( @installer::globals
::logfileinfo
, $infoline);
928 return \
@allexistentitems;
931 ########################################################################
932 # Input is the directory gid, output the "HostName" of the directory
933 ########################################################################
935 sub get_Directoryname_From_Directorygid
937 my ($dirsarrayref ,$searchgid, $onelanguage, $oneitemgid) = @_;
939 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::get_Directoryname_From_Directorygid : $#{$dirsarrayref} : $searchgid : $onelanguage"); }
941 my $directoryname = "";
945 for ( my $i = 0; $i <= $#{$dirsarrayref}; $i++ )
947 $onedirectory = ${$dirsarrayref}[$i];
948 my $directorygid = $onedirectory->{'gid'};
950 if ($directorygid eq $searchgid)
959 installer
::exiter
::exit_program
("ERROR: Gid $searchgid not defined in $installer::globals::setupscriptname", "get_Directoryname_From_Directorygid");
962 if ( ! ( $onedirectory->{'ismultilingual'} )) # the directory is not language dependent
964 $directoryname = $onedirectory->{'HostName'};
968 $directoryname = $onedirectory->{"HostName ($onelanguage)"};
971 # gid_Dir_Template_Wizard_Letter is defined as language dependent directory, but the file gid_Dir_Template_Wizard_Letter
972 # is not language dependent. Therefore $onelanguage is not defined. But which language is the correct language for the
974 # Perhaps better solution: In scp it must be forbidden to have a language independent file in a language dependent directory.
976 if (( ! $directoryname ) && ( $onelanguage eq "" ))
978 installer
::exiter
::exit_program
("ERROR (in scp): Directory $searchgid is language dependent, but not $oneitemgid inside this directory", "get_Directoryname_From_Directorygid");
981 return \
$directoryname;
984 ##################################################################
985 # Getting destination direcotory for links, files and profiles
986 ##################################################################
988 sub get_Destination_Directory_For_Item_From_Directorylist
# this is used for Files, Profiles and Links
990 my ($itemarrayref, $dirsarrayref) = @_;
992 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::get_Destination_Directory_For_Item_From_Directorylist : $#{$itemarrayref} : $#{$dirsarrayref}"); }
994 for ( my $i = 0; $i <= $#{$itemarrayref}; $i++ )
996 my $oneitem = ${$itemarrayref}[$i];
997 my $oneitemgid = $oneitem->{'gid'};
998 my $directorygid = $oneitem->{'Dir'}; # for instance gid_Dir_Program
999 my $netdirectorygid = "";
1000 my $onelanguage = $oneitem->{'specificlanguage'};
1001 my $ispredefinedprogdir = 0;
1002 my $ispredefinedconfigdir = 0;
1004 my $oneitemname = $oneitem->{'Name'};
1006 if ( $oneitem->{'NetDir'} ) { $netdirectorygid = $oneitem->{'NetDir'}; }
1008 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$oneitemname); # making /registry/schema/org/openoffice/VCL.xcs to VCL.xcs
1012 if ( $netdirectorygid eq "" ) # if NetDir is defined, it is privileged
1014 $searchdirgid = $directorygid
1018 $searchdirgid = $netdirectorygid
1021 if ($searchdirgid =~ /PREDEFINED_PROGDIR/) # the root directory is not defined in setup script
1023 $ispredefinedprogdir = 1;
1026 if ($searchdirgid =~ /PREDEFINED_CONFIGDIR/) # the root directory is not defined in setup script
1028 $ispredefinedconfigdir = 1;
1033 if ((!( $ispredefinedprogdir )) && (!( $ispredefinedconfigdir )))
1035 my $directorynameref = get_Directoryname_From_Directorygid
($dirsarrayref, $searchdirgid, $onelanguage, $oneitemgid);
1036 $destfilename = $$directorynameref . $installer::globals
::separator
. $oneitemname;
1040 $destfilename = $oneitemname;
1043 $oneitem->{'destination'} = $destfilename;
1047 ##########################################################################
1048 # Searching a file in a list of pathes
1049 ##########################################################################
1051 sub get_sourcepath_from_filename_and_includepath_classic
1053 my ($searchfilenameref, $includepatharrayref, $write_logfile) = @_;
1055 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic : $$searchfilenameref : $#{$includepatharrayref} : $write_logfile"); }
1057 my ($onefile, $includepath, $infoline);
1059 my $foundsourcefile = 0;
1061 for ( my $j = 0; $j <= $#{$includepatharrayref}; $j++ )
1063 $includepath = ${$includepatharrayref}[$j];
1064 installer
::remover
::remove_leading_and_ending_whitespaces
(\
$includepath);
1066 $onefile = $includepath . $installer::globals
::separator
. $$searchfilenameref;
1070 $foundsourcefile = 1;
1075 if (!($foundsourcefile))
1077 $onefile = ""; # the sourcepath has to be empty
1078 if ( $write_logfile)
1080 if ( $ENV{'DEFAULT_TO_ENGLISH_FOR_PACKING'} )
1082 $infoline = "WARNING: Source for $$searchfilenameref not found!\n"; # Important message in log file
1086 $infoline = "ERROR: Source for $$searchfilenameref not found!\n"; # Important message in log file
1089 push( @installer::globals
::logfileinfo
, $infoline);
1094 if ( $write_logfile)
1096 $infoline = "SUCCESS: Source for $$searchfilenameref: $onefile\n";
1097 push( @installer::globals
::logfileinfo
, $infoline);
1104 ##########################################################################
1105 # Input is one file name, output the complete absolute path of this file
1106 ##########################################################################
1108 sub get_sourcepath_from_filename_and_includepath
1110 my ($searchfilenameref, $unused, $write_logfile) = @_;
1112 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::get_sourcepath_from_filename_and_includepath : $$searchfilenameref : $#{$includepatharrayref} : $write_logfile"); }
1114 my ($onefile, $includepath, $infoline);
1116 my $foundsourcefile = 0;
1117 my $foundnewname = 0;
1119 for ( my $j = 0; $j <= $#installer::globals
::allincludepathes
; $j++ )
1121 my $allfiles = $installer::globals
::allincludepathes
[$j];
1123 if ( exists( $allfiles->{$$searchfilenameref} ))
1125 $onefile = $allfiles->{'includepath'} . $installer::globals
::separator
. $$searchfilenameref;
1126 $foundsourcefile = 1;
1131 if (!($foundsourcefile)) # testing with lowercase filename
1133 # Attention: README01.html is copied for Windows to readme01.html, not case sensitive
1135 for ( my $j = 0; $j <= $#installer::globals
::allincludepathes
; $j++ )
1137 my $allfiles = $installer::globals
::allincludepathes
[$j];
1139 my $newfilename = $$searchfilenameref;
1140 $newfilename =~ s/readme/README/; # special handling for readme files
1141 $newfilename =~ s/license/LICENSE/; # special handling for license files
1143 if ( exists( $allfiles->{$newfilename} ))
1145 $onefile = $allfiles->{'includepath'} . $installer::globals
::separator
. $newfilename;
1146 $foundsourcefile = 1;
1153 if (!($foundsourcefile))
1155 $onefile = ""; # the sourcepath has to be empty
1156 if ( $write_logfile)
1158 if ( $ENV{'DEFAULT_TO_ENGLISH_FOR_PACKING'} )
1160 $infoline = "WARNING: Source for $$searchfilenameref not found!\n"; # Important message in log file
1164 $infoline = "ERROR: Source for $$searchfilenameref not found!\n"; # Important message in log file
1167 push( @installer::globals
::logfileinfo
, $infoline);
1172 if ( $write_logfile)
1174 if (!($foundnewname))
1176 $infoline = "SUCCESS: Source for $$searchfilenameref: $onefile\n";
1180 $infoline = "SUCCESS/WARNING: Special handling for $$searchfilenameref: $onefile\n";
1182 push( @installer::globals
::logfileinfo
, $infoline);
1189 ##############################################################
1190 # Determining, whether a specified directory is language
1192 ##############################################################
1194 sub determine_directory_language_dependency
1196 my($directorygid, $dirsref) = @_;
1198 my $is_multilingual = 0;
1200 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
1202 my $onedir = ${$dirsref}[$i];
1203 my $gid = $onedir->{'gid'};
1205 if ( $gid eq $directorygid )
1207 $is_multilingual = $onedir->{'ismultilingual'};
1212 return $is_multilingual;
1215 ##############################################################
1216 # Getting all source pathes for all files to be packed
1217 # $item can be "Files" or "ScpActions"
1218 ##############################################################
1220 sub get_Source_Directory_For_Files_From_Includepathlist
1222 my ($filesarrayref, $includepatharrayref, $dirsref, $item) = @_;
1224 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::get_Source_Directory_For_Files_From_Includepathlist : $#{$filesarrayref} : $#{$includepatharrayref} : $item"); }
1226 installer
::logger
::include_header_into_logfile
("$item:");
1230 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1232 my $onefile = ${$filesarrayref}[$i];
1233 my $onelanguage = $onefile->{'specificlanguage'};
1235 if ( ! $onefile->{'Name'} ) { installer
::exiter
::exit_program
("ERROR: $item without name ! GID: $onefile->{'gid'} ! Language: $onelanguage", "get_Source_Directory_For_Files_From_Includepathlist"); }
1237 my $onefilename = $onefile->{'Name'};
1238 if ( $item eq "ScpActions" ) { $onefilename =~ s/\//$installer::globals
::separator
/g
; }
1239 $onefilename =~ s/^\s*\Q$installer::globals::separator\E//; # filename begins with a slash, for instance /registry/schema/org/openoffice/VCL.xcs
1242 my $file_can_miss = 0;
1243 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1244 if (( $styles =~ /\bSTARREGISTRY\b/ ) || ( $styles =~ /\bFILE_CAN_MISS\b/ )) { $file_can_miss = 1; }
1246 my $sourcepathref = "";
1248 if ( $file_can_miss ) { $sourcepathref = get_sourcepath_from_filename_and_includepath
(\
$onefilename, $includepatharrayref, 0); }
1249 else { $sourcepathref = get_sourcepath_from_filename_and_includepath
(\
$onefilename, $includepatharrayref, 1); }
1251 $onefile->{'sourcepath'} = $$sourcepathref; # This $$sourcepathref is empty, if no source was found
1253 # defaulting to english for multilingual files if DEFAULT_TO_ENGLISH_FOR_PACKING is set
1255 if ( $ENV{'DEFAULT_TO_ENGLISH_FOR_PACKING'} )
1257 if (( ! $onefile->{'sourcepath'} ) && ( $onefile->{'ismultilingual'} ))
1259 my $oldname = $onefile->{'Name'};
1260 my $oldlanguage = $onefile->{'specificlanguage'};
1261 my $newlanguage = "en-US";
1262 # $onefile->{'Name'} =~ s/$oldlanguage\./$newlanguage\./; # Example: tplwizfax_it.zip -> tplwizfax_en-US.zip
1263 $onefilename = $onefile->{'Name'};
1264 $onefilename =~ s/$oldlanguage\./$newlanguage\./; # Example: tplwizfax_it.zip -> tplwizfax_en-US.zip
1265 $onefilename =~ s/^\s*\Q$installer::globals::separator\E//; # filename begins with a slash, for instance /registry/schema/org/openoffice/VCL.xcs
1266 $sourcepathref = get_sourcepath_from_filename_and_includepath
(\
$onefilename, $includepatharrayref, 1);
1267 $onefile->{'sourcepath'} = $$sourcepathref; # This $$sourcepathref is empty, if no source was found
1269 if ($onefile->{'sourcepath'}) # defaulting to english was successful
1271 $infoline = "WARNING: Using $onefilename instead of $oldname\n";
1272 push( @installer::globals
::logfileinfo
, $infoline);
1274 # if ( $onefile->{'destination'} ) { $onefile->{'destination'} =~ s/\Q$oldname\E/$onefile->{'Name'}/; }
1276 # If the directory, in which the new file is installed, is not language dependent,
1277 # the filename has to be changed to avoid installation conflicts
1278 # No mechanism for resource files!
1279 # -> implementing for the content of ARCHIVE files
1281 if ( $onefile->{'Styles'} =~ /\bARCHIVE\b/ )
1283 my $directorygid = $onefile->{'Dir'};
1284 my $islanguagedependent = determine_directory_language_dependency
($directorygid, $dirsref);
1286 if ( ! $islanguagedependent )
1288 $onefile->{'Styles'} =~ s/\bARCHIVE\b/ARCHIVE, RENAME_TO_LANGUAGE/; # Setting new flag RENAME_TO_LANGUAGE
1289 $infoline = "Setting flag RENAME_TO_LANGUAGE: File $onefile->{'Name'} in directory: $directorygid\n";
1290 push( @installer::globals
::logfileinfo
, $infoline);
1296 $infoline = "WARNING: Using $onefile->{'Name'} instead of $oldname was not successful\n";
1297 push( @installer::globals
::logfileinfo
, $infoline);
1298 $onefile->{'Name'} = $oldname; # Switching back to old file name
1304 $infoline = "\n"; # empty line after listing of all files
1305 push( @installer::globals
::logfileinfo
, $infoline);
1308 #################################################################################
1309 # Removing files, that shall not be included into languagepacks
1310 # (because of rpm conflicts)
1311 #################################################################################
1313 sub remove_Files_For_Languagepacks
1315 my ($itemsarrayref) = @_;
1317 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::remove_Files_For_Languagepacks : $#{$filesarrayref}"); }
1321 my @newitemsarray = ();
1323 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1325 my $oneitem = ${$itemsarrayref}[$i];
1326 my $gid = $oneitem->{'gid'};
1328 # scp Todo: Remove asap after removal of old setup
1330 if (( $gid eq "gid_File_Extra_Fontunxpsprint" ) ||
1331 ( $gid eq "gid_File_Extra_Migration_Lang" ))
1333 $infoline = "ATTENTION: Removing item $oneitem->{'gid'} from the installation set.\n";
1334 push( @installer::globals
::logfileinfo
, $infoline);
1339 push(@newitemsarray, $oneitem);
1342 return \
@newitemsarray;
1345 #################################################################################
1346 # Files, whose source directory is not found, are removed now (this is an ERROR)
1347 #################################################################################
1349 sub remove_Files_Without_Sourcedirectory
1351 my ($filesarrayref) = @_;
1353 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::remove_Files_Without_Sourcedirectory : $#{$filesarrayref}"); }
1357 my $error_occured = 0;
1358 my @missingfiles = ();
1359 push(@missingfiles, "ERROR: The following files could not be found: \n");
1361 my @newfilesarray = ();
1363 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1365 my $onefile = ${$filesarrayref}[$i];
1366 my $sourcepath = $onefile->{'sourcepath'};
1368 if ($sourcepath eq "")
1370 my $styles = $onefile->{'Styles'};
1372 if ( ! ( $styles =~ /\bSTARREGISTRY\b/ )) # StarRegistry files will be created later
1374 my $filename = $onefile->{'Name'};
1375 $infoline = "ERROR: Removing file $filename from file list.\n";
1376 push( @installer::globals
::logfileinfo
, $infoline);
1378 push(@missingfiles, "ERROR: File not found: $filename\n");
1381 next; # removing this file from list, if sourcepath is empty
1385 push(@newfilesarray, $onefile);
1389 push( @installer::globals
::logfileinfo
, $infoline);
1391 if ( $error_occured )
1393 for ( my $i = 0; $i <= $#missingfiles; $i++ ) { print "$missingfiles[$i]"; }
1394 installer
::exiter
::exit_program
("ERROR: Missing files", "remove_Files_Without_Sourcedirectory");
1397 return \
@newfilesarray;
1400 ############################################################################
1401 # License and Readme files in the default language have to be installed
1402 # in the directory with flag OFFICEDIRECTORY. If this is not defined
1403 # they have to be installed in the installation root.
1404 ############################################################################
1406 sub get_office_directory_gid_and_hostname
1408 my ($dirsarrayref) = @_;
1410 my $foundofficedir = 0;
1414 for ( my $i = 0; $i <= $#{$dirsarrayref}; $i++ )
1416 my $onedir = ${$dirsarrayref}[$i];
1417 if ( $onedir->{'Styles'} )
1419 my $styles = $onedir->{'Styles'};
1421 if ( $styles =~ /\bOFFICEDIRECTORY\b/ )
1423 $foundofficedir = 1;
1424 $gid = $onedir->{'gid'};
1425 $hostname = $onedir->{'HostName'};
1431 return ($foundofficedir, $gid, $hostname);
1434 ############################################################################
1435 # License and Readme files in the default language have to be installed
1436 # in the installation root (next to the program dir). This is in scp
1437 # project done by a post install basic script
1438 ############################################################################
1440 sub add_License_Files_into_Installdir
1442 my ($filesarrayref, $dirsarrayref, $languagesarrayref) = @_;
1444 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::add_License_Files_into_Installdir : $#{$filesarrayref} : $#{$languagesarrayref}"); }
1448 my @newfilesarray = ();
1450 my $defaultlanguage = installer
::languages
::get_default_language
($languagesarrayref);
1452 my ($foundofficedir, $officedirectorygid, $officedirectoryhostname) = get_office_directory_gid_and_hostname
($dirsarrayref);
1454 # copy all files from directory share/readme, that contain the default language in their name
1455 # without default language into the installation root. This makes the settings of the correct
1456 # file names superfluous. On the other hand this requires a dependency to the directory
1459 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1461 my $onefile = ${$filesarrayref}[$i];
1462 my $destination = $onefile->{'destination'};
1464 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1466 if ( ( $destination =~ /share\Q$installer::globals::separator\Ereadme\Q$installer::globals::separator\E(\w+?)_?$defaultlanguage\.?(\w*)\s*/ )
1467 || (( $styles =~ /\bROOTLICENSEFILE\b/ ) && ( $destination =~ /\Q$installer::globals::separator\E?(\w+?)_?$defaultlanguage\.?(\w*?)\s*$/ )) )
1474 if ( $extension eq "" ) { $newfilename = $filename; }
1475 else { $newfilename = $filename . "\." . $extension; }
1478 my $newfile = \
%newfile;
1480 installer
::converter
::copy_item_object
($onefile, $newfile);
1482 $newfile->{'gid'} = $onefile->{'gid'} . "_Copy";
1483 $newfile->{'Name'} = $newfilename;
1484 $newfile->{'ismultilingual'} = "0";
1485 $newfile->{'specificlanguage'} = "";
1486 $newfile->{'haslanguagemodule'} = "0";
1488 if ( $foundofficedir )
1490 $newfile->{'Dir'} = $officedirectorygid;
1491 $newfile->{'destination'} = $officedirectoryhostname . $installer::globals
::separator
. $newfilename;
1495 $newfile->{'Dir'} = "PREDEFINED_PROGDIR";
1496 $newfile->{'destination'} = $newfilename;
1499 # Also setting "modules=gid_Module_Root_Brand" (module with style: ROOT_BRAND_PACKAGE)
1500 if ( $installer::globals
::rootbrandpackageset
)
1502 $newfile->{'modules'} = $installer::globals
::rootbrandpackage
;
1505 push(@newfilesarray, $newfile);
1507 $infoline = "New files: Adding file $newfilename for the installation root to the file list. Language: $defaultlanguage\n";
1508 push( @installer::globals
::logfileinfo
, $infoline);
1510 # Collecting license and readme file for the installation set
1512 push(@installer::globals
::installsetfiles
, $newfile);
1513 $infoline = "New files: Adding file $newfilename to the file collector for the installation set. Language: $defaultlanguage\n";
1514 push( @installer::globals
::logfileinfo
, $infoline);
1517 push(@newfilesarray, $onefile);
1520 return \
@newfilesarray;
1523 ############################################################################
1524 # Removing files with flag ONLY_ASIA_LANGUAGE, only if no asian
1525 # language is part of the product.
1526 # This special files are connected to the root module and are not
1527 # included into a language pack (would lead to conflicts!).
1528 # But this files shall only be included into the product, if the
1529 # product contains at least one asian language.
1530 ############################################################################
1532 sub remove_onlyasialanguage_files_from_productlists
1534 my ($filesarrayref) = @_;
1538 my @newfilesarray = ();
1539 my $returnfilesarrayref;
1541 my $containsasianlanguage = installer
::languages
::detect_asian_language
($installer::globals
::alllanguagesinproductarrayref
);
1543 my $alllangstring = installer
::converter
::convert_array_to_comma_separated_string
($installer::globals
::alllanguagesinproductarrayref
);
1544 $infoline = "\nLanguages in complete product: $alllangstring\n";
1545 push( @installer::globals
::logfileinfo
, $infoline);
1547 if ( ! $containsasianlanguage )
1549 $infoline = "Product does not contain asian language -> removing files\n";
1550 push( @installer::globals
::logfileinfo
, $infoline);
1552 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1554 my $onefile = ${$filesarrayref}[$i];
1556 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1557 if ( $styles =~ /\bONLY_ASIA_LANGUAGE\b/ )
1559 $infoline = "Flag ONLY_ASIA_LANGUAGE: Removing file $onefile->{'Name'} from files collector!\n";
1560 push( @installer::globals
::logfileinfo
, $infoline);
1564 push(@newfilesarray, $onefile);
1567 $returnfilesarrayref = \
@newfilesarray;
1571 $returnfilesarrayref = $filesarrayref;
1573 $infoline = "Product contains asian language -> Nothing to do\n";
1574 push( @installer::globals
::logfileinfo
, $infoline);
1578 return $returnfilesarrayref;
1581 ############################################################################
1582 # Removing files with flag ONLY_WESTERN_LANGUAGE, only if no western
1583 # language is part of the product.
1584 # This special files are connected to the root module and are not
1585 # included into a language pack (would lead to conflicts!).
1586 # But this files shall only be included into the product, if the
1587 # product contains at least one western language.
1588 ############################################################################
1590 sub remove_onlywesternlanguage_files_from_productlists
1592 my ($filesarrayref) = @_;
1596 my @newfilesarray = ();
1597 my $returnfilesarrayref;
1599 my $containswesternlanguage = installer
::languages
::detect_western_language
($installer::globals
::alllanguagesinproductarrayref
);
1601 my $alllangstring = installer
::converter
::convert_array_to_comma_separated_string
($installer::globals
::alllanguagesinproductarrayref
);
1602 $infoline = "\nLanguages in complete product: $alllangstring\n";
1603 push( @installer::globals
::logfileinfo
, $infoline);
1605 if ( ! $containswesternlanguage )
1607 $infoline = "Product does not contain western language -> removing files\n";
1608 push( @installer::globals
::logfileinfo
, $infoline);
1610 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1612 my $onefile = ${$filesarrayref}[$i];
1614 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1615 if ( $styles =~ /\bONLY_WESTERN_LANGUAGE\b/ )
1617 $infoline = "Flag ONLY_WESTERN_LANGUAGE: Removing file $onefile->{'Name'} from files collector!\n";
1618 push( @installer::globals
::logfileinfo
, $infoline);
1622 push(@newfilesarray, $onefile);
1625 $returnfilesarrayref = \
@newfilesarray;
1629 $returnfilesarrayref = $filesarrayref;
1631 $infoline = "Product contains western language -> Nothing to do\n";
1632 push( @installer::globals
::logfileinfo
, $infoline);
1636 return $returnfilesarrayref;
1639 ############################################################################
1640 # Some files are included for more than one language and have the same
1641 # name and the same destination directory for all languages. This would
1642 # lead to conflicts, if the filenames are not changed.
1643 # In scp project this files must have the flag MAKE_LANG_SPECIFIC
1644 # For this files, the language is included into the filename.
1645 ############################################################################
1647 sub make_filename_language_specific
1649 my ($filesarrayref) = @_;
1653 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1655 my $onefile = ${$filesarrayref}[$i];
1657 if ( $onefile->{'ismultilingual'} )
1660 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1661 if ( $styles =~ /\bMAKE_LANG_SPECIFIC\b/ )
1663 my $language = $onefile->{'specificlanguage'};
1664 my $olddestination = $onefile->{'destination'};
1665 my $oldname = $onefile->{'Name'};
1667 # Including the language into the file name.
1668 # But be sure, to include the language before the file extension.
1670 my $fileextension = "";
1672 if ( $onefile->{'Name'} =~ /(\.\w+?)\s*$/ ) { $fileextension = $1; }
1673 if ( $fileextension ne "" )
1675 $onefile->{'Name'} =~ s/\Q$fileextension\E\s*$/_$language$fileextension/;
1676 $onefile->{'destination'} =~ s/\Q$fileextension\E\s*$/_$language$fileextension/;
1679 $infoline = "Flag MAKE_LANG_SPECIFIC:\n";
1680 push( @installer::globals
::logfileinfo
, $infoline);
1681 $infoline = "Changing name from $oldname to $onefile->{'Name'} !\n";
1682 push( @installer::globals
::logfileinfo
, $infoline);
1683 $infoline = "Changing destination from $olddestination to $onefile->{'destination'} !\n";
1684 push( @installer::globals
::logfileinfo
, $infoline);
1690 ############################################################################
1691 # Removing all scpactions, that have no name.
1692 # See: FlatLoaderZip
1693 ############################################################################
1695 sub remove_scpactions_without_name
1697 my ($itemsarrayref) = @_;
1699 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::remove_scpactions_without_name : $#{$itemsarrayref}"); }
1703 my @newitemsarray = ();
1705 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1707 my $oneitem = ${$itemsarrayref}[$i];
1710 if ( $oneitem->{'Name'} ) { $name = $oneitem->{'Name'}; }
1714 $infoline = "ATTENTION: Removing scpaction $oneitem->{'gid'} from the installation set.\n";
1715 push( @installer::globals
::logfileinfo
, $infoline);
1719 push(@newitemsarray, $oneitem);
1722 return \
@newitemsarray;
1725 ############################################################################
1726 # Because of the item "File" the source name must be "Name". Therefore
1727 # "Copy" is changed to "Name" and "Name" is changed to "DestinationName".
1728 ############################################################################
1730 sub change_keys_of_scpactions
1732 my ($itemsarrayref) = @_;
1734 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::change_keys_of_scpactions : $#{$itemsarrayref}"); }
1736 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1738 my $oneitem = ${$itemsarrayref}[$i];
1742 # First Name to DestinationName, then deleting Name
1743 foreach $key (keys %{$oneitem})
1745 if ( $key =~ /\bName\b/ )
1747 my $value = $oneitem->{$key};
1749 $key =~ s/Name/DestinationName/;
1750 $oneitem->{$key} = $value;
1751 delete($oneitem->{$oldkey});
1755 # Second Copy to Name, then deleting Copy
1756 foreach $key (keys %{$oneitem})
1758 if ( $key =~ /\bCopy\b/ )
1760 my $value = $oneitem->{$key};
1762 $key =~ s/Copy/Name/;
1763 $oneitem->{$key} = $value;
1764 delete($oneitem->{$oldkey});
1770 ############################################################################
1771 # Removing all xpd only items from installation set (scpactions with
1772 # the style XPD_ONLY), except an xpd installation set is created
1773 ############################################################################
1775 sub remove_Xpdonly_Items
1777 my ($itemsarrayref) = @_;
1779 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::remove_Xpdonly_Items : $#{$itemsarrayref}"); }
1783 my @newitemsarray = ();
1785 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1787 my $oneitem = ${$itemsarrayref}[$i];
1789 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
1791 if ( $styles =~ /\bXPD_ONLY\b/ )
1793 $infoline = "Removing \"xpd only\" item $oneitem->{'gid'} from the installation set.\n";
1794 push( @installer::globals
::globallogfileinfo
, $infoline);
1799 push(@newitemsarray, $oneitem);
1803 push( @installer::globals
::globallogfileinfo
, $infoline);
1805 return \
@newitemsarray;
1808 ############################################################################
1809 # Removing all language pack files from installation set (files with
1810 # the style LANGUAGEPACK), except this is a language pack.
1811 ############################################################################
1813 sub remove_Languagepacklibraries_from_Installset
1815 my ($itemsarrayref) = @_;
1817 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::remove_Languagepacklibraries_from_Installset : $#{$itemsarrayref}"); }
1821 my @newitemsarray = ();
1823 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1825 my $oneitem = ${$itemsarrayref}[$i];
1827 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
1829 if ( $styles =~ /\bLANGUAGEPACK\b/ )
1831 $infoline = "Removing language pack file $oneitem->{'gid'} from the installation set.\n";
1832 push( @installer::globals
::globallogfileinfo
, $infoline);
1837 push(@newitemsarray, $oneitem);
1841 push( @installer::globals
::globallogfileinfo
, $infoline);
1843 return \
@newitemsarray;
1846 ############################################################################
1847 # Removing all files with flag PATCH_ONLY from installation set.
1848 # This function is not called during patch creation.
1849 ############################################################################
1851 sub remove_patchonlyfiles_from_Installset
1853 my ($itemsarrayref) = @_;
1855 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::remove_patchonlyfiles_from_Installset : $#{$itemsarrayref}"); }
1859 my @newitemsarray = ();
1861 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1863 my $oneitem = ${$itemsarrayref}[$i];
1865 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
1867 if ( $styles =~ /\bPATCH_ONLY\b/ )
1869 $infoline = "Removing file with flag PATCH_ONLY $oneitem->{'gid'} from the installation set.\n";
1870 push( @installer::globals
::globallogfileinfo
, $infoline);
1875 push(@newitemsarray, $oneitem);
1879 push( @installer::globals
::globallogfileinfo
, $infoline);
1881 return \
@newitemsarray;
1884 ############################################################################
1885 # Removing all files with flag TAB_ONLY from installation set.
1886 # This function is not called during tab creation.
1887 ############################################################################
1889 sub remove_tabonlyfiles_from_Installset
1891 my ($itemsarrayref) = @_;
1893 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::remove_tabonlyfiles_from_Installset : $#{$itemsarrayref}"); }
1897 my @newitemsarray = ();
1899 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1901 my $oneitem = ${$itemsarrayref}[$i];
1903 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
1905 if ( $styles =~ /\bTAB_ONLY\b/ )
1907 $infoline = "Removing tab only file $oneitem->{'gid'} from the installation set.\n";
1908 push( @installer::globals
::globallogfileinfo
, $infoline);
1913 push(@newitemsarray, $oneitem);
1917 push( @installer::globals
::globallogfileinfo
, $infoline);
1919 return \
@newitemsarray;
1922 ###############################################################################
1923 # Removing all files with flag ONLY_INSTALLED_PRODUCT from installation set.
1924 # This function is not called for PKGFORMAT installed and archive.
1925 ###############################################################################
1927 sub remove_installedproductonlyfiles_from_Installset
1929 my ($itemsarrayref) = @_;
1931 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::remove_installedproductonlyfiles_from_Installset : $#{$itemsarrayref}"); }
1935 my @newitemsarray = ();
1937 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1939 my $oneitem = ${$itemsarrayref}[$i];
1941 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
1943 if ( $styles =~ /\bONLY_INSTALLED_PRODUCT\b/ )
1945 $infoline = "Removing file $oneitem->{'gid'} from the installation set. This file is only required for PKGFORMAT archive or installed).\n";
1946 push( @installer::globals
::globallogfileinfo
, $infoline);
1950 push(@newitemsarray, $oneitem);
1954 push( @installer::globals
::globallogfileinfo
, $infoline);
1956 return \
@newitemsarray;
1959 ############################################################################
1960 # Some files cotain a $ in their name. epm conflicts with such files.
1961 # Solution: Renaming this files, converting "$" to "$$"
1962 ############################################################################
1964 sub quoting_illegal_filenames
1966 my ($filesarrayref) = @_;
1968 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::rename_illegal_filenames : $#{$filesarrayref}"); }
1970 # This function has to be removed as soon as possible!
1972 installer
::logger
::include_header_into_logfile
("Renaming illegal filenames:");
1974 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1976 my $onefile = ${$filesarrayref}[$i];
1977 my $filename = $onefile->{'Name'};
1979 if ( $filename =~ /\$/ )
1981 my $sourcepath = $onefile->{'sourcepath'};
1982 my $destpath = $onefile->{'destination'};
1984 # sourcepath and destination have to be quoted for epm list file
1986 # $filename =~ s/\$/\$\$/g;
1987 $destpath =~ s/\$/\$\$/g;
1988 $sourcepath =~ s/\$/\$\$/g;
1990 # my $infoline = "ATTENTION: Files: Renaming $onefile->{'Name'} to $filename\n";
1991 # push( @installer::globals::logfileinfo, $infoline);
1992 my $infoline = "ATTENTION: Files: Quoting sourcepath $onefile->{'sourcepath'} to $sourcepath\n";
1993 push( @installer::globals
::logfileinfo
, $infoline);
1994 $infoline = "ATTENTION: Files: Quoting destination path $onefile->{'destination'} to $destpath\n";
1995 push( @installer::globals
::logfileinfo
, $infoline);
1997 # $onefile->{'Name'} = $filename;
1998 $onefile->{'sourcepath'} = $sourcepath;
1999 $onefile->{'destination'} = $destpath;
2004 ############################################################################
2005 # Removing multiple occurences of same module.
2006 ############################################################################
2010 my ( $longlist ) = @_;
2013 my $hashref = installer
::converter
::convert_stringlist_into_hash
(\
$longlist, ",");
2014 foreach my $key (sort keys %{$hashref} ) { $shortlist = "$shortlist,$key"; }
2015 $shortlist =~ s/^\s*\,//;
2020 #######################################################################
2021 # Collecting all directories needed for the epm list
2022 # 1. Looking for all destination paths in the files array
2023 # 2. Looking for directories with CREATE flag in the directory array
2024 #######################################################################
2026 ##################################
2027 # Collecting directories: Part 1
2028 ##################################
2030 sub collect_directories_from_filesarray
2032 my ($filesarrayref) = @_;
2034 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::collect_directories_from_filesarray : $#{$filesarrayref}"); }
2036 my @alldirectories = ();
2037 my %alldirectoryhash = ();
2039 my $predefinedprogdir_added = 0;
2040 my $alreadyincluded = 0;
2042 # Preparing this already as hash, although the only needed value at the moment is the HostName
2043 # But also adding: "specificlanguage" and "Dir" (for instance gid_Dir_Program)
2045 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
2047 my $onefile = ${$filesarrayref}[$i];
2048 my $destinationpath = $onefile->{'destination'};
2049 installer
::pathanalyzer
::get_path_from_fullqualifiedname
(\
$destinationpath);
2050 $destinationpath =~ s/\Q$installer::globals::separator\E\s*$//; # removing ending slashes or backslashes
2052 $alreadyincluded = 0;
2053 if ( exists($alldirectoryhash{$destinationpath}) ) { $alreadyincluded = 1; }
2055 if (!($alreadyincluded))
2057 my %directoryhash = ();
2058 $directoryhash{'HostName'} = $destinationpath;
2059 $directoryhash{'specificlanguage'} = $onefile->{'specificlanguage'};
2060 $directoryhash{'Dir'} = $onefile->{'Dir'};
2061 $directoryhash{'modules'} = $onefile->{'modules'}; # NEW, saving modules
2062 # NEVER!!! if ( ! $installer::globals::iswindowsbuild ) { $directoryhash{'Styles'} = "(CREATE)"; } # this directories must be created
2064 if ( $onefile->{'Dir'} eq "PREDEFINED_PROGDIR" ) { $predefinedprogdir_added = 1; }
2066 $alldirectoryhash{$destinationpath} = \
%directoryhash;
2068 # Problem: The $destinationpath can be share/registry/schema/org/openoffice
2069 # but not all directories contain files and will be added to this list.
2070 # Therefore the path has to be analyzed.
2072 while ( $destinationpath =~ /(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/ ) # as long as the path contains slashes
2074 $destinationpath = $1;
2076 $alreadyincluded = 0;
2077 if ( exists($alldirectoryhash{$destinationpath}) ) { $alreadyincluded = 1; }
2079 if (!($alreadyincluded))
2081 my %directoryhash = ();
2083 $directoryhash{'HostName'} = $destinationpath;
2084 $directoryhash{'specificlanguage'} = $onefile->{'specificlanguage'};
2085 $directoryhash{'Dir'} = $onefile->{'Dir'};
2086 $directoryhash{'modules'} = $onefile->{'modules'}; # NEW, saving modules
2087 # NEVER!!! if ( ! $installer::globals::iswindowsbuild ) { $directoryhash{'Styles'} = "(CREATE)"; } # this directories must be created
2089 $alldirectoryhash{$destinationpath} = \
%directoryhash;
2093 # Adding the modules to the module list!
2094 $alldirectoryhash{$destinationpath}->{'modules'} = $alldirectoryhash{$destinationpath}->{'modules'} . "," . $onefile->{'modules'};
2100 # Adding the modules to the module list!
2101 $alldirectoryhash{$destinationpath}->{'modules'} = $alldirectoryhash{$destinationpath}->{'modules'} . "," . $onefile->{'modules'};
2103 # Also adding the module to all parents
2104 while ( $destinationpath =~ /(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/ ) # as long as the path contains slashes
2106 $destinationpath = $1;
2107 $alldirectoryhash{$destinationpath}->{'modules'} = $alldirectoryhash{$destinationpath}->{'modules'} . "," . $onefile->{'modules'};
2112 # if there is no file in the root directory PREDEFINED_PROGDIR, it has to be included into the directory array now
2113 # HostName= specificlanguage= Dir=PREDEFINED_PROGDIR
2115 if (! $predefinedprogdir_added )
2117 my %directoryhash = ();
2118 $directoryhash{'HostName'} = "";
2119 $directoryhash{'specificlanguage'} = "";
2120 $directoryhash{'modules'} = ""; # ToDo?
2121 $directoryhash{'Dir'} = "PREDEFINED_PROGDIR";
2123 push(@alldirectories, \
%directoryhash);
2126 # Creating directory array
2127 foreach my $destdir ( sort keys %alldirectoryhash )
2129 $alldirectoryhash{$destdir}->{'modules'} = optimize_list
($alldirectoryhash{$destdir}->{'modules'});
2130 push(@alldirectories, $alldirectoryhash{$destdir});
2133 return (\
@alldirectories, \
%alldirectoryhash);
2136 ##################################
2137 # Collecting directories: Part 2
2138 ##################################
2140 sub collect_directories_with_create_flag_from_directoryarray
2142 my ($directoryarrayref, $alldirectoryhash) = @_;
2144 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::collect_directories_with_create_flag_from_directoryarray : $#{$directoryarrayref}"); }
2146 my $alreadyincluded = 0;
2147 my @alldirectories = ();
2149 for ( my $i = 0; $i <= $#{$directoryarrayref}; $i++ )
2151 my $onedir = ${$directoryarrayref}[$i];
2153 $newdirincluded = 0;
2155 if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
2157 if ( $styles =~ /\bCREATE\b/ )
2159 my $directoryname = "";
2161 if ( $onedir->{'HostName'} ) { $directoryname = $onedir->{'HostName'}; }
2162 else { installer
::exiter
::exit_program
("ERROR: No directory name (HostName) set for specified language in gid $onedir->{'gid'}", "collect_directories_with_create_flag_from_directoryarray"); }
2164 $alreadyincluded = 0;
2165 if ( exists($alldirectoryhash->{$directoryname}) ) { $alreadyincluded = 1; }
2167 if (!($alreadyincluded))
2169 my %directoryhash = ();
2170 $directoryhash{'HostName'} = $directoryname;
2171 $directoryhash{'specificlanguage'} = $onedir->{'specificlanguage'};
2172 # $directoryhash{'gid'} = $onedir->{'gid'};
2173 $directoryhash{'Dir'} = $onedir->{'gid'};
2174 $directoryhash{'Styles'} = $onedir->{'Styles'};
2176 # saving also the modules
2177 if ( ! $onedir->{'modules'} ) { installer
::exiter
::exit_program
("ERROR: No assigned modules found for directory $onedir->{'gid'}", "collect_directories_with_create_flag_from_directoryarray"); }
2178 $directoryhash{'modules'} = $onedir->{'modules'};
2180 $alldirectoryhash->{$directoryname} = \
%directoryhash;
2181 $newdirincluded = 1;
2183 # Problem: The $destinationpath can be share/registry/schema/org/openoffice
2184 # but not all directories contain files and will be added to this list.
2185 # Therefore the path has to be analyzed.
2187 while ( $directoryname =~ /(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/ ) # as long as the path contains slashes
2189 $directoryname = $1;
2191 $alreadyincluded = 0;
2192 if ( exists($alldirectoryhash->{$directoryname}) ) { $alreadyincluded = 1; }
2194 if (!($alreadyincluded))
2196 my %directoryhash = ();
2198 $directoryhash{'HostName'} = $directoryname;
2199 $directoryhash{'specificlanguage'} = $onedir->{'specificlanguage'};
2200 $directoryhash{'Dir'} = $onedir->{'gid'};
2201 if ( ! $installer::globals
::iswindowsbuild
) { $directoryhash{'Styles'} = "(CREATE)"; } # Exeception for Windows?
2203 # saving also the modules
2204 $directoryhash{'modules'} = $onedir->{'modules'};
2206 $alldirectoryhash->{$directoryname} = \
%directoryhash;
2207 $newdirincluded = 1;
2211 # Adding the modules to the module list!
2212 $alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $onedir->{'modules'};
2218 # Adding the modules to the module list!
2219 $alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $onedir->{'modules'};
2221 while ( $directoryname =~ /(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/ ) # as long as the path contains slashes
2223 $directoryname = $1;
2224 # Adding the modules to the module list!
2225 $alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $onedir->{'modules'};
2230 # Saving the styles for already added directories in function collect_directories_from_filesarray
2232 if (( ! $newdirincluded ) && ( $styles ne "" ))
2234 $styles =~ s/\bWORKSTATION\b//;
2235 $styles =~ s/\bCREATE\b//;
2237 if (( ! ( $styles =~ /^\s*\(\s*\)\s*$/ )) && ( ! ( $styles =~ /^\s*\(\s*\,\s*\)\s*$/ )) && ( ! ( $styles =~ /^\s*$/ ))) # checking, if there are styles left
2239 my $directoryname = "";
2240 if ( $onedir->{'HostName'} ) { $directoryname = $onedir->{'HostName'}; }
2241 else { installer
::exiter
::exit_program
("ERROR: No directory name (HostName) set for specified language in gid $onedir->{'gid'}", "collect_directories_with_create_flag_from_directoryarray"); }
2243 if ( exists($alldirectoryhash->{$directoryname}) )
2245 $alldirectoryhash->{$directoryname}->{'Styles'} = $styles;
2251 # Creating directory array
2252 foreach my $destdir ( sort keys %{$alldirectoryhash} )
2254 $alldirectoryhash->{$destdir}->{'modules'} = optimize_list
($alldirectoryhash->{$destdir}->{'modules'});
2255 push(@alldirectories, $alldirectoryhash->{$destdir});
2258 return (\
@alldirectories, \
%alldirectoryhash);
2261 #################################################
2262 # Determining the destination file of a link
2263 #################################################
2265 sub get_destination_file_path_for_links
2267 my ($linksarrayref, $filesarrayref) = @_;
2269 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::get_destination_file_path_for_links : $#{$linksarrayref} : $#{$filesarrayref}"); }
2273 for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ )
2276 my $onelink = ${$linksarrayref}[$i];
2277 if ( $onelink->{'FileID'} ) { $fileid = $onelink->{'FileID'}; }
2279 if (!( $fileid eq "" ))
2283 for ( my $j = 0; $j <= $#{$filesarrayref}; $j++ )
2285 my $onefile = ${$filesarrayref}[$j];
2286 my $filegid = $onefile->{'gid'};
2288 if ( $filegid eq $fileid )
2291 $onelink->{'destinationfile'} = $onefile->{'destination'};
2298 $infoline = "Warning: FileID $fileid for Link $onelink->{'gid'} not found!\n";
2299 push( @installer::globals
::logfileinfo
, $infoline);
2305 push( @installer::globals
::logfileinfo
, $infoline);
2308 #################################################
2309 # Determining the destination link of a link
2310 #################################################
2312 sub get_destination_link_path_for_links
2314 my ($linksarrayref) = @_;
2316 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::get_destination_link_path_for_links : $#{$linksarrayref}"); }
2320 for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ )
2322 my $shortcutid = "";
2323 my $onelink = ${$linksarrayref}[$i];
2324 if ( $onelink->{'ShortcutID'} ) { $shortcutid = $onelink->{'ShortcutID'}; }
2326 if (!( $shortcutid eq "" ))
2330 for ( my $j = 0; $j <= $#{$linksarrayref}; $j++ )
2332 my $destlink = ${$linksarrayref}[$j];
2333 $shortcutgid = $destlink->{'gid'};
2335 if ( $shortcutgid eq $shortcutid )
2338 $onelink->{'destinationfile'} = $destlink->{'destination'}; # making key 'destinationfile'
2345 $infoline = "Warning: ShortcutID $shortcutid for Link $onelink->{'gid'} not found!\n";
2346 push( @installer::globals
::logfileinfo
, $infoline);
2352 push( @installer::globals
::logfileinfo
, $infoline);
2355 ###################################################################################
2356 # Items with flag WORKSTATION are not needed (here: links and configurationitems)
2357 ###################################################################################
2359 sub remove_workstation_only_items
2361 my ($itemarrayref) = @_;
2363 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::remove_workstation_only_items : $#{$itemarrayref}"); }
2365 my @newitemarray = ();
2367 for ( my $i = 0; $i <= $#{$itemarrayref}; $i++ )
2369 my $oneitem = ${$itemarrayref}[$i];
2370 my $styles = $oneitem->{'Styles'};
2372 if (( $styles =~ /\bWORKSTATION\b/ ) &&
2373 (!( $styles =~ /\bNETWORK\b/ )) &&
2374 (!( $styles =~ /\bSTANDALONE\b/ )))
2376 next; # removing this link, it is only needed for a workstation installation
2379 push(@newitemarray, $oneitem);
2382 return \
@newitemarray;
2385 ################################################
2386 # Resolving relative path in links
2387 ################################################
2389 sub resolve_links_with_flag_relative
2391 my ($linksarrayref) = @_;
2393 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::resolve_links_with_flag_relative : $#{$linksarrayref}"); }
2395 # Before this step is:
2396 # destination=program/libsalhelperC52.so.3, this will be the name of the link
2397 # destinationfile=program/libsalhelperC52.so.3, this will be the linked file or name
2398 # If the flag RELATIVE is set, the pathes have to be analyzed. If the flag is not set
2399 # (this will not occur in the future?) destinationfile has to be an absolute path name
2401 for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ )
2403 my $onelink = ${$linksarrayref}[$i];
2404 my $styles = $onelink->{'Styles'};
2406 if ( $styles =~ /\bRELATIVE\b/ )
2408 # ToDo: This is only a simple not sufficient mechanism
2410 my $destination = $onelink->{'destination'};
2411 my $destinationfile = $onelink->{'destinationfile'};
2413 my $destinationpath = $destination;
2415 installer
::pathanalyzer
::get_path_from_fullqualifiedname
(\
$destinationpath);
2417 my $destinationfilepath = $destinationfile;
2419 # it is possible, that the destinationfile is no longer part of the files collector
2420 if ($destinationfilepath) { installer
::pathanalyzer
::get_path_from_fullqualifiedname
(\
$destinationfilepath); }
2421 else { $destinationfilepath = ""; }
2423 if ( $destinationpath eq $destinationfilepath )
2425 # link and file are in the same directory
2426 # Therefore the path of the file can be removed
2428 my $newdestinationfile = $destinationfile;
2429 installer
::pathanalyzer
::make_absolute_filename_to_relative_filename
(\
$newdestinationfile);
2431 $onelink->{'destinationfile'} = $newdestinationfile;
2437 ########################################################################
2438 # This function is a helper of function "assigning_modules_to_items"
2439 ########################################################################
2441 sub insert_for_item
($$$)
2443 my ($hash, $item, $id) = @_;
2445 # print STDERR "insert '$id' for '$item'\n";
2446 if (!defined $hash->{$item})
2449 $hash->{$item} = \
@gids;
2451 my $gid_list = $hash->{$item};
2452 push @
{$gid_list}, $id;
2453 $hash->{$item} = $gid_list;
2456 sub build_modulegids_table
2458 my ($modulesref, $itemname) = @_;
2460 my %module_lookup_table = ();
2462 # build map of item names to list of respective module gids
2463 # containing these items
2464 for my $onemodule (@
{$modulesref})
2466 next if ( ! defined $onemodule->{$itemname} );
2467 # these are the items contained in this module
2468 # eg. Files = (gid_a_b_c,gid_d_e_f)
2469 my $module_gids = $onemodule->{$itemname};
2471 # prune outer brackets
2472 $module_gids =~ s
|^\s
*\
(||g
;
2473 $module_gids =~ s
|\
)\s
*$||g
;
2474 for my $id (split (/,/, $module_gids))
2477 insert_for_item
(\
%module_lookup_table, lc ($id), $onemodule->{'gid'});
2481 return \
%module_lookup_table;
2484 ########################################################################
2485 # Items like files do not know their modules
2486 # This function is a helper of function "assigning_modules_to_items"
2487 ########################################################################
2489 sub get_string_of_modulegids_for_itemgid
2491 my ($module_lookup_table, $modulesref, $itemgid, $itemname) = @_;
2493 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::get_string_of_modulegids_for_itemgid : $#{$modulesref} : $itemgid : $itemname"); }
2495 my $allmodules = "";
2496 my $haslanguagemodule = 0;
2497 my %foundmodules = ();
2499 # print STDERR "lookup '" . lc($itemgid) . "'\n";
2500 my $gid_list = $module_lookup_table->{lc($itemgid)};
2502 for my $gid (@
{$gid_list})
2504 $foundmodules{$gid} = 1;
2505 $allmodules = $allmodules . "," . $gid;
2506 # Is this module a language module? This info should be stored at the file.
2507 if ( exists($installer::globals
::alllangmodules
{$gid}) ) { $haslanguagemodule = 1; }
2510 $allmodules =~ s/^\s*\,//; # removing leading comma
2512 # Check: All modules or no module must have flag LANGUAGEMODULE
2513 if ( $haslanguagemodule )
2515 my $isreallylanguagemodule = installer
::worker
::key_in_a_is_also_key_in_b
(\
%foundmodules, \
%installer::globals
::alllangmodules
);
2516 if ( ! $isreallylanguagemodule ) { installer
::exiter
::exit_program
("ERROR: \"$itemgid\" is assigned to modules with flag \"LANGUAGEMODULE\" and also to modules without this flag! Modules: $allmodules", "get_string_of_modulegids_for_itemgid"); }
2519 # print STDERR "get_string_for_itemgid ($itemgid, $itemname) => $allmodules, $haslanguagemodule\n";
2521 return ($allmodules, $haslanguagemodule);
2524 ########################################################
2525 # Items like files do not know their modules
2526 # This function add the {'modules'} to these items
2527 ########################################################
2529 sub assigning_modules_to_items
2531 my ($modulesref, $itemsref, $itemname) = @_;
2533 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::assigning_modules_to_items : $#{$modulesref} : $#{$itemsref} : $itemname"); }
2536 my $languageassignmenterror = 0;
2537 my @languageassignmenterrors = ();
2539 my $module_lookup_table = build_modulegids_table
($modulesref, $itemname);
2541 for my $oneitem (@
{$itemsref})
2543 my $itemgid = $oneitem->{'gid'};
2546 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
2547 if (( $itemname eq "Dirs" ) && ( ! ( $styles =~ /\bCREATE\b/ ))) { next; }
2549 if ( $itemgid eq "" )
2551 installer
::exiter
::exit_program
("ERROR in item collection: No gid for item $oneitem->{'Name'}", "assigning_modules_to_items");
2554 # every item can belong to many modules
2556 my ($modulegids, $haslanguagemodule) = get_string_of_modulegids_for_itemgid
($module_lookup_table, $modulesref, $itemgid, $itemname);
2558 if ($modulegids eq "")
2560 installer
::exiter
::exit_program
("ERROR in file collection: No module found for $itemname $itemgid", "assigning_modules_to_items");
2563 $oneitem->{'modules'} = $modulegids;
2564 $oneitem->{'haslanguagemodule'} = $haslanguagemodule;
2566 # Important check: "ismultilingual" and "haslanguagemodule" must have the same value !
2567 if (( $oneitem->{'ismultilingual'} ) && ( ! $oneitem->{'haslanguagemodule'} ))
2569 $infoline = "Error: \"$oneitem->{'gid'}\" is multi lingual, but not in language pack (Assigned module: $modulegids)!\n";
2570 push( @installer::globals
::globallogfileinfo
, $infoline);
2571 push( @languageassignmenterrors, $infoline );
2572 $languageassignmenterror = 1;
2574 if (( $oneitem->{'haslanguagemodule'} ) && ( ! $oneitem->{'ismultilingual'} ))
2576 $infoline = "Error: \"$oneitem->{'gid'}\" is in language pack, but not multi lingual (Assigned module: $modulegids)!\n";
2577 push( @installer::globals
::globallogfileinfo
, $infoline);
2578 push( @languageassignmenterrors, $infoline );
2579 $languageassignmenterror = 1;
2583 if ($languageassignmenterror)
2585 for ( my $i = 0; $i <= $#languageassignmenterrors; $i++ ) { print "$languageassignmenterrors[$i]"; }
2586 installer
::exiter
::exit_program
("ERROR: Incorrect assignments for language packs.", "assigning_modules_to_items");
2591 #################################################################################################
2592 # Root path (for instance /opt/openofficeorg20) needs to be added to directories, files and links
2593 #################################################################################################
2595 sub add_rootpath_to_directories
2597 my ($dirsref, $rootpath) = @_;
2599 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::add_rootpath_to_directories : $#{$dirsref} : $rootpath"); }
2601 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
2603 my $onedir = ${$dirsref}[$i];
2606 if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; }
2608 if (!($dir =~ /\bPREDEFINED_/ ))
2610 my $hostname = $onedir->{'HostName'};
2611 $hostname = $rootpath . $installer::globals
::separator
. $hostname;
2612 $onedir->{'HostName'} = $hostname;
2617 if ( $dir =~ /\bPREDEFINED_PROGDIR\b/ )
2619 my $hostname = $onedir->{'HostName'};
2620 if ( $hostname eq "" ) { $onedir->{'HostName'} = $rootpath; }
2621 else { $onedir->{'HostName'} = $rootpath . $installer::globals
::separator
. $hostname; }
2626 sub add_rootpath_to_files
2628 my ($filesref, $rootpath) = @_;
2630 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::add_rootpath_to_files : $#{$filesref} : $rootpath"); }
2632 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
2634 my $onefile = ${$filesref}[$i];
2635 my $destination = $onefile->{'destination'};
2636 $destination = $rootpath . $installer::globals
::separator
. $destination;
2637 $onefile->{'destination'} = $destination;
2641 sub add_rootpath_to_links
2643 my ($linksref, $rootpath) = @_;
2645 if ( $installer::globals
::debug
) { installer
::logger
::debuginfo
("installer::scriptitems::add_rootpath_to_links : $#{$linksref} : $rootpath"); }
2647 for ( my $i = 0; $i <= $#{$linksref}; $i++ )
2649 my $onelink = ${$linksref}[$i];
2650 my $styles = $onelink->{'Styles'};
2652 my $destination = $onelink->{'destination'};
2653 $destination = $rootpath . $installer::globals
::separator
. $destination;
2654 $onelink->{'destination'} = $destination;
2656 if (!($styles =~ /\bRELATIVE\b/ )) # for absolute links
2658 my $destinationfile = $onelink->{'destinationfile'};
2659 $destinationfile = $rootpath . $installer::globals
::separator
. $destinationfile;
2660 $onelink->{'destinationfile'} = $destinationfile;
2665 #################################################################################
2666 # Collecting all parent gids
2667 #################################################################################
2669 sub collect_all_parent_feature
2671 my ($modulesref) = @_;
2673 my @allparents = ();
2675 my $found_root_module = 0;
2677 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2679 my $onefeature = ${$modulesref}[$i];
2682 if ( $onefeature->{'ParentID'} )
2684 $parentgid = $onefeature->{'ParentID'};
2687 if ( $parentgid ne "" )
2689 if (! installer
::existence
::exists_in_array
($parentgid, \
@allparents))
2691 push(@allparents, $parentgid);
2695 # Setting the global root module
2697 if ( $parentgid eq "" )
2699 if ( $found_root_module ) { installer
::exiter
::exit_program
("ERROR: Only one module without ParentID or with empty ParentID allowed ($installer::globals::rootmodulegid, $onefeature->{'gid'}).", "collect_all_parent_feature"); }
2700 $installer::globals
::rootmodulegid
= $onefeature->{'gid'};
2701 $found_root_module = 1;
2702 $infoline = "Setting Root Module: $installer::globals::rootmodulegid\n";
2703 push( @installer::globals
::globallogfileinfo
, $infoline);
2706 if ( ! $found_root_module ) { installer
::exiter
::exit_program
("ERROR: Could not define root module. No module without ParentID or with empty ParentID exists.", "collect_all_parent_feature"); }
2710 return \
@allparents;
2713 #################################################################################
2714 # Checking for every feature, whether it has children
2715 #################################################################################
2717 sub set_children_flag
2719 my ($modulesref) = @_;
2721 my $allparents = collect_all_parent_feature
($modulesref);
2723 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2725 my $onefeature = ${$modulesref}[$i];
2726 my $gid = $onefeature->{'gid'};
2728 # is this gid a parent?
2730 if ( installer
::existence
::exists_in_array
($gid, $allparents) )
2732 $onefeature->{'has_children'} = 1;
2736 $onefeature->{'has_children'} = 0;
2741 #################################################################################
2742 # All modules, that use a template module, do now get the assignments of
2743 # the template module.
2744 #################################################################################
2746 sub resolve_assigned_modules
2748 my ($modulesref) = @_;
2750 # collecting all template modules
2752 my %directaccess = ();
2754 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2756 my $onefeature = ${$modulesref}[$i];
2758 if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
2759 if ( $styles =~ /\bTEMPLATEMODULE\b/ ) { $directaccess{$onefeature->{'gid'}} = $onefeature; }
2761 # also looking for module with flag ROOT_BRAND_PACKAGE, to save is for further usage
2762 if ( $styles =~ /\bROOT_BRAND_PACKAGE\b/ )
2764 $installer::globals
::rootbrandpackage
= $onefeature->{'gid'};
2765 $installer::globals
::rootbrandpackageset
= 1;
2769 # looking, where template modules are assigned
2771 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2773 my $onefeature = ${$modulesref}[$i];
2774 if ( $onefeature->{'Assigns'} )
2776 my $templategid = $onefeature->{'Assigns'};
2778 if ( ! exists($directaccess{$templategid}) )
2780 installer
::exiter
::exit_program
("ERROR: Did not find definition of assigned template module \"$templategid\"", "resolve_assigned_modules");
2783 # Currently no merging of Files, Dirs, ...
2784 # This has to be included here, if it is required
2786 foreach $item (@installer::globals
::items_at_modules
)
2788 if ( exists($directaccess{$templategid}->{$item}) ) { $onefeature->{$item} = $directaccess{$templategid}->{$item}; }
2794 #################################################################################
2795 # Removing the template modules from the list, after all
2796 # assignments are transferred to the "real" modules.
2797 #################################################################################
2799 sub remove_template_modules
2801 my ($modulesref) = @_;
2805 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2807 my $onefeature = ${$modulesref}[$i];
2809 if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
2810 if ( $styles =~ /\bTEMPLATEMODULE\b/ ) { next; }
2812 push(@modules, $onefeature);
2818 #################################################################################
2819 # Collecting all modules with flag LANGUAGEMODULE in a global
2821 #################################################################################
2823 sub collect_all_languagemodules
2825 my ($modulesref) = @_;
2827 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2829 my $onefeature = ${$modulesref}[$i];
2831 if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
2832 if ( $styles =~ /\bLANGUAGEMODULE\b/ )
2834 if ( ! exists($onefeature->{'Language'}) ) { installer
::exiter
::exit_program
("ERROR: \"$onefeature->{'gid'}\" has flag LANGUAGEMODULE, but does not know its language!", "collect_all_languagemodules"); }
2835 $installer::globals
::alllangmodules
{$onefeature->{'gid'}} = $onefeature->{'Language'};
2836 # Collecting also the english names, that are used for nsis unpack directory for language packs
2837 my $lang = $onefeature->{'Language'};
2839 foreach my $localkey ( keys %{$onefeature} )
2841 if ( $localkey =~ /^\s*Name\s*\(\s*en-US\s*\)\s*$/ )
2843 $installer::globals
::all_english_languagestrings
{$lang} = $onefeature->{$localkey};
2850 #################################################################################
2851 # Selecting from all collected english language strings those, that are really
2852 # required in this installation set.
2853 #################################################################################
2855 sub select_required_language_strings
2857 my ($modulesref) = @_;
2859 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2861 my $onefeature = ${$modulesref}[$i];
2863 if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
2864 if ( $styles =~ /\bLANGUAGEMODULE\b/ )
2866 if ( ! exists($onefeature->{'Language'}) ) { installer
::exiter
::exit_program
("ERROR: \"$onefeature->{'gid'}\" has flag LANGUAGEMODULE, but does not know its language!", "select_required_language_strings"); }
2867 my $lang = $onefeature->{'Language'};
2869 if (( exists($installer::globals
::all_english_languagestrings
{$lang}) ) && ( ! exists($installer::globals
::all_required_english_languagestrings
{$lang}) ))
2871 $installer::globals
::all_required_english_languagestrings
{$lang} = $installer::globals
::all_english_languagestrings
{$lang};
2877 #####################################################################################
2878 # Unixlinks are not always required. For Linux RPMs and Solaris Packages they are
2879 # created dynamically. Exception: For package formats "installed" or "archive".
2880 # In scp2 this unixlinks have the flag LAYERLINK.
2881 #####################################################################################
2883 sub filter_layerlinks_from_unixlinks
2885 my ( $unixlinksref ) = @_;
2889 for ( my $i = 0; $i <= $#{$unixlinksref}; $i++ )
2893 my $onelink = ${$unixlinksref}[$i];
2895 if ( $onelink->{'Styles'} ) { $styles = $onelink->{'Styles'}; }
2897 if ( $styles =~ /\bLAYERLINK\b/ )
2899 # Platforms, that do not need the layer links
2900 if (( $installer::globals
::islinuxrpmbuild
) || ( $installer::globals
::issolarispkgbuild
))
2905 # Package formats, that need the layer link (platform independent)
2906 if (( $installer::globals
::packageformat
eq "installed" ) || ( $installer::globals
::packageformat
eq "archive" ))
2912 if ( $isrequired ) { push(@alllinks, $onelink); }