Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / bin / modules / installer / scriptitems.pm
blob7fdb6540c34b87b46e48a51e1d21f7ac4e12ccaa
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package installer::scriptitems;
21 use installer::converter;
22 use installer::exiter;
23 use installer::globals;
24 use installer::languages;
25 use installer::logger;
26 use installer::pathanalyzer;
27 use installer::remover;
28 use installer::systemactions;
30 ################################################################
31 # Resolving the GID for the directories defined in setup script
32 ################################################################
34 sub resolve_all_directory_names
36 my ($directoryarrayref) = @_;
38 # After this procedure the hash shall contain the complete language
39 # dependent path, not only the language dependent HostName.
41 my ($key, $value, $parentvalue, $parentgid, $parentdirectoryhashref);
43 for ( my $i = 0; $i <= $#{$directoryarrayref}; $i++ )
45 my $directoryhashref = ${$directoryarrayref}[$i];
46 my $gid = $directoryhashref-> {'gid'};
47 my $parentid = $directoryhashref-> {'ParentID'};
49 if ( $parentid ne "PREDEFINED_PROGDIR" )
51 # find the array of the parentid, which has to be defined before in setup script
52 # and is therefore listed before in this array
54 for ( my $j = 0; $j <= $i; $j++ )
56 $parentdirectoryhashref = ${$directoryarrayref}[$j];
57 $parentgid = $parentdirectoryhashref->{'gid'};
59 if ( $parentid eq $parentgid)
61 last;
65 # and now we can put the path together
66 # But take care of the languages!
68 my $dirismultilingual = $directoryhashref->{'ismultilingual'};
69 my $parentismultilingual = $parentdirectoryhashref->{'ismultilingual'};
71 # First: Both directories are language independent or both directories are language dependent
73 if ((( ! $dirismultilingual ) && ( ! $parentismultilingual )) ||
74 (( $dirismultilingual ) && ( $parentismultilingual )))
76 foreach $key (keys %{$directoryhashref})
78 # the key ("HostName (en-US)") must be usable for both hashes
80 if ( $key =~ /\bHostName\b/ )
82 $parentvalue = "";
83 $value = $directoryhashref->{$key};
84 if ( $parentdirectoryhashref->{$key} ) { $parentvalue = $parentdirectoryhashref->{$key}; }
86 # It is possible, that in scp project, a directory is defined in more languages than
87 # the directory parent (happened after automatic generation of macros.inc).
88 # Therefore this is checked now and written with a warning into the logfile.
89 # This is no error, because (in most cases) the concerned language is not build.
91 if ($parentvalue eq "")
93 $directoryhashref->{$key} = "FAILURE";
94 my $infoline = "WARNING: No hostname for $parentid with \"$key\". Needed by child directory $gid !\n";
95 push( @installer::globals::globallogfileinfo, $infoline);
97 else
99 $directoryhashref->{$key} = $parentvalue . $installer::globals::separator . $value;
105 # Second: The directory is language dependent, the parent not
107 if (( $dirismultilingual ) && ( ! $parentismultilingual ))
109 $parentvalue = $parentdirectoryhashref->{'HostName'}; # there is only one
111 foreach $key (keys %{$directoryhashref}) # the current directory
113 if ( $key =~ /\bHostName\b/ )
115 $value = $directoryhashref->{$key};
116 $directoryhashref->{$key} = $parentvalue . $installer::globals::separator . $value;
121 # Third: The directory is not language dependent, the parent is language dependent
123 if (( ! $dirismultilingual ) && ( $parentismultilingual ))
125 $value = $directoryhashref->{'HostName'}; # there is only one
126 delete($directoryhashref->{'HostName'});
128 foreach $key (keys %{$parentdirectoryhashref}) # the parent directory
130 if ( $key =~ /\bHostName\b/ )
132 $parentvalue = $parentdirectoryhashref->{$key}; # there is only one
133 $directoryhashref->{$key} = $parentvalue . $installer::globals::separator . $value;
137 $directoryhashref->{'ismultilingual'} = 1; # now this directory is also language dependent
143 #############################################################################
144 # Files with flag NOT_IN_SUITE do not need to be packed into
145 # Suite installation sets
146 #############################################################################
148 sub remove_office_start_language_files
150 my ($productarrayref) = @_;
152 my @newitems = ();
154 for ( my $i = 0; $i <= $#{$productarrayref}; $i++ )
156 my $oneitem = ${$productarrayref}[$i];
157 my $styles = "";
159 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
161 if (!($styles =~ /\bSET_OFFICE_LANGUAGE\b/))
163 push(@newitems, $oneitem);
165 else
167 my $infoline = "INFO: Flag SET_OFFICE_LANGUAGE \-\> Removing $oneitem->{'gid'} from file list.\n";
168 push( @installer::globals::logfileinfo, $infoline);
172 return \@newitems;
175 #############################################################################
176 # Registryitems for Uninstall have to be removed
177 #############################################################################
179 sub remove_uninstall_regitems_from_script
181 my ($registryarrayref) = @_;
183 my @newitems = ();
185 for ( my $i = 0; $i <= $#{$registryarrayref}; $i++ )
187 my $oneitem = ${$registryarrayref}[$i];
188 my $subkey = "";
190 if ( $oneitem->{'Subkey'} ) { $subkey = $oneitem->{'Subkey'}; }
192 if ( $subkey =~ /Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall/ ) { next; }
194 push(@newitems, $oneitem);
197 return \@newitems;
200 ##############################################################################
201 # Searching the language module for a specified language
202 ##############################################################################
204 sub get_languagespecific_module
206 my ( $lang, $modulestring ) = @_;
208 my $langmodulestring = "";
210 my $module;
211 foreach $module ( keys %installer::globals::alllangmodules )
213 if (( $installer::globals::alllangmodules{$module} eq $lang ) && ( $modulestring =~ /\b$module\b/ ))
215 $langmodulestring = "$langmodulestring,$module";
219 $langmodulestring =~ s/^\s*,//;
221 if ( $langmodulestring eq "" ) { installer::exiter::exit_program("ERROR: No language pack module found for language $lang in string \"$modulestring\"!", "get_languagespecific_module"); }
223 return $langmodulestring;
226 ##############################################################################
227 # Removing all items in product lists which do not have the correct languages
228 ##############################################################################
230 sub resolving_all_languages_in_productlists
232 my ($productarrayref, $languagesarrayref) = @_;
234 my @itemsinalllanguages = ();
236 my ($key, $value);
238 for ( my $i = 0; $i <= $#{$productarrayref}; $i++ )
240 my $oneitem = ${$productarrayref}[$i];
242 my $ismultilingual = $oneitem->{'ismultilingual'};
244 if (!($ismultilingual)) # nothing to do with single language items
246 $oneitem->{'specificlanguage'} = "";
247 push(@itemsinalllanguages, $oneitem);
249 else #all language dependent files
251 for ( my $j = 0; $j <= $#{$languagesarrayref}; $j++ ) # iterating over all languages
253 my $onelanguage = ${$languagesarrayref}[$j];
255 my %oneitemhash = ();
257 foreach $key (keys %{$oneitem})
259 if ( $key =~ /\(\S+\)/ ) # this are the language dependent keys
261 if ( $key =~ /\(\Q$onelanguage\E\)/ )
263 $value = $oneitem->{$key};
264 $oneitemhash{$key} = $value;
267 else
269 $value = $oneitem->{$key};
270 $oneitemhash{$key} = $value;
274 $oneitemhash{'specificlanguage'} = $onelanguage;
276 if ( $oneitemhash{'haslanguagemodule'} )
278 my $langmodulestring = get_languagespecific_module($onelanguage, $oneitemhash{'modules'});
279 $oneitemhash{'modules'} = $langmodulestring;
282 push(@itemsinalllanguages, \%oneitemhash);
287 return \@itemsinalllanguages;
290 ################################################################################
291 # Removing all modules, that have the flag LANGUAGEMODULE, but do not
292 # have the correct language
293 ################################################################################
295 sub remove_not_required_language_modules
297 my ($modulesarrayref, $languagesarrayref) = @_;
299 my @allmodules = ();
301 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
303 my $module = ${$modulesarrayref}[$i];
304 my $styles = "";
305 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
307 if ( $styles =~ /\bLANGUAGEMODULE\b/ )
309 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"); }
310 my $modulelanguage = $module->{'Language'};
311 # checking, if language is required
312 my $doinclude = 0;
313 for ( my $j = 0; $j <= $#{$languagesarrayref}; $j++ )
315 my $onelanguage = ${$languagesarrayref}[$j];
316 if ( $onelanguage eq $modulelanguage )
318 $doinclude = 1;
319 last;
323 if ( $doinclude ) { push(@allmodules, $module); }
325 else
327 push(@allmodules, $module);
331 return \@allmodules;
334 ################################################################################
335 # Removing all modules, that have a spellchecker language that is not
336 # required for this product (spellchecker selection).
337 # All required spellchecker languages are stored in
338 # %installer::globals::spellcheckerlanguagehash
339 ################################################################################
341 sub remove_not_required_spellcheckerlanguage_modules
343 my ($modulesarrayref) = @_;
345 my $infoline = "";
346 my @allmodules = ();
348 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
350 my $module = ${$modulesarrayref}[$i];
351 if ( $module->{'Spellcheckerlanguage'} ) # selecting modules with Spellcheckerlanguage
353 if ( exists($installer::globals::spellcheckerlanguagehash{$module->{'Spellcheckerlanguage'}}) )
355 push(@allmodules, $module);
357 else
359 $infoline = "Spellchecker selection: Removing module $module->{'gid'}\n";
360 push( @installer::globals::logfileinfo, $infoline);
362 # Collecting all files at modules that are removed
364 if ( $module->{'Files'} )
366 if ( $module->{'Files'} =~ /^\s*\((.*?)\)\s*$/ )
368 my $filelist = $1;
370 my $filelisthash = installer::converter::convert_stringlist_into_hash(\$filelist, ",");
371 foreach my $onefile ( keys %{$filelisthash} ) { $installer::globals::spellcheckerfilehash{$onefile} = 1; }
376 else
378 push(@allmodules, $module);
382 return \@allmodules;
385 ################################################################################
386 # Removing all modules, that belong to a module that was removed
387 # in "remove_not_required_spellcheckerlanguage_modules" because of the
388 # spellchecker language. The files belonging to the modules are collected
389 # in %installer::globals::spellcheckerfilehash.
390 ################################################################################
392 sub remove_not_required_spellcheckerlanguage_files
394 my ($filesarrayref) = @_;
396 my @filesarray = ();
397 my $infoline = "";
399 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
401 my $onefile = ${$filesarrayref}[$i];
402 if ( exists($installer::globals::spellcheckerfilehash{$onefile->{'gid'}}) )
404 $infoline = "Spellchecker selection: Removing file $onefile->{'gid'}\n";
405 push( @installer::globals::logfileinfo, $infoline);
406 next;
408 push(@filesarray, $onefile);
411 return \@filesarray;
414 ################################################################################
415 # Looking for directories without correct HostName
416 ################################################################################
418 sub checking_directories_with_corrupt_hostname
420 my ($dirsref, $languagesarrayref) = @_;
422 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
424 my $onedir = ${$dirsref}[$i];
426 my $hostname = "";
428 if ( $onedir->{'HostName'} ) { $hostname = $onedir->{'HostName'}; }
430 if ( $hostname eq "" )
432 my $langstring = "";
433 for ( my $j = 0; $j <= $#{$languagesarrayref}; $j++ ) { $langstring .= ${$languagesarrayref}[$j] . " "; }
434 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");
437 if ( $hostname eq "FAILURE" )
439 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");
444 ################################################################################
445 # Setting global properties
446 ################################################################################
448 sub set_global_directory_hostnames
450 my ($dirsref, $allvariables) = @_;
452 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
454 my $onedir = ${$dirsref}[$i];
455 my $styles = "";
456 if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
458 if ( $styles =~ /\bOFFICEDIRECTORY\b/ )
460 $installer::globals::officedirhostname = $onedir->{'HostName'};
461 $installer::globals::officedirgid = $onedir->{'gid'};
462 $allvariables->{'OFFICEDIRECTORYHOSTNAME'} = $installer::globals::officedirhostname;
467 ########################################################
468 # Recursively defined procedure to order
469 # modules and directories
470 ########################################################
472 sub get_children
474 my ($allitems, $startparent, $newitemorder) = @_;
476 for ( my $i = 0; $i <= $#{$allitems}; $i++ )
478 my $gid = ${$allitems}[$i]->{'gid'};
479 my $parent = "";
480 if ( ${$allitems}[$i]->{'ParentID'} ) { $parent = ${$allitems}[$i]->{'ParentID'}; }
482 if ( $parent eq $startparent )
484 push(@{$newitemorder}, ${$allitems}[$i]);
485 my $parent = $gid;
486 get_children($allitems, $parent, $newitemorder); # recursive!
491 ################################################################################
492 # Using langpack copy action for language packs
493 ################################################################################
495 sub use_langpack_copy_scpaction
497 my ($scpactionsref) = @_;
499 for ( my $i = 0; $i <= $#{$scpactionsref}; $i++ )
501 my $onescpaction = ${$scpactionsref}[$i];
502 if (( $onescpaction->{'LangPackCopy'} ) && ( $onescpaction->{'LangPackCopy'} ne "" )) { $onescpaction->{'Copy'} = $onescpaction->{'LangPackCopy'}; }
506 ################################################################################
507 # Using dev copy patch action for developer snapshot builds
508 ################################################################################
510 sub use_devversion_copy_scpaction
512 my ($scpactionsref) = @_;
514 for ( my $i = 0; $i <= $#{$scpactionsref}; $i++ )
516 my $onescpaction = ${$scpactionsref}[$i];
517 if (( $onescpaction->{'DevVersionCopy'} ) && ( $onescpaction->{'DevVersionCopy'} ne "" )) { $onescpaction->{'Copy'} = $onescpaction->{'DevVersionCopy'}; }
521 ################################################################################
522 # Shifting parent directories of URE and Basis layer, so that
523 # these directories are located below the Brand layer.
524 # Style: SHIFT_BASIS_INTO_BRAND_LAYER
525 ################################################################################
527 sub shift_basis_directory_parents
529 my ($dirsref) = @_;
531 my @alldirs = ();
533 my $officedirgid = "";
535 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
537 my $onedir = ${$dirsref}[$i];
538 my $styles = "";
539 if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
541 if ( $styles =~ /\bOFFICEDIRECTORY\b/ ) { $officedirgid = $onedir->{'gid'}; }
544 if ( $officedirgid ne "" )
546 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
548 my $onedir = ${$dirsref}[$i];
549 my $styles = "";
550 if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
552 if (( $styles =~ /\bBASISDIRECTORY\b/ ) || ( $styles =~ /\bUREDIRECTORY\b/ ))
554 $onedir->{'ParentID'} = $officedirgid;
558 # Sorting directories
559 my $startgid = "PREDEFINED_PROGDIR";
560 get_children($dirsref, $startgid, \@alldirs);
563 return \@alldirs;
566 ################################################################################
567 # Setting the name of the directory with style OFFICEDIRECTORY.
568 # The name can be defined in property OFFICEDIRECTORYNAME.
569 ################################################################################
571 sub set_officedirectory_name
573 my ($dirsref, $officedirname) = @_;
575 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
577 my $onedir = ${$dirsref}[$i];
578 my $styles = "";
579 if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
580 if ( $styles =~ /\bOFFICEDIRECTORY\b/ )
582 $onedir->{'HostName'} = $officedirname;
583 last;
588 ################################################################################
589 # Simplifying the name for language dependent items from "Name (xy)" to "Name"
590 ################################################################################
592 sub changing_name_of_language_dependent_keys
594 my ($itemsarrayref) = @_;
596 # Changing key for multilingual items from "Name ( )" to "Name" or "HostName ( )" to "HostName"
598 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
600 my $oneitem = ${$itemsarrayref}[$i];
601 my $onelanguage = $oneitem->{'specificlanguage'};
603 if (!($onelanguage eq "" )) # language dependent item
605 my $itemkey;
607 foreach $itemkey (keys %{$oneitem})
609 if ( $itemkey =~ /^\s*(\S+?)\s+\(\S+\)\s*$/ )
611 my $newitemkey = $1;
612 my $itemvalue = $oneitem->{$itemkey};
613 $oneitem->{$newitemkey} = $itemvalue;
614 delete($oneitem->{$itemkey});
621 ################################################################################
622 # Replacement of setup variables in ConfigurationItems and ProfileItems
623 # <productkey>, <buildid>, <sequence_languages>, <productcode>, <upgradecode>, <productupdate>
624 ################################################################################
626 sub replace_setup_variables
628 my ($itemsarrayref, $languagestringref, $hashref) = @_;
630 my $languagesstring = $$languagestringref;
631 $languagesstring =~ s/\_/ /g; # replacing underscore with whitespace
633 my $productname = $hashref->{'PRODUCTNAME'};
634 my $productversion = $hashref->{'PRODUCTVERSION'};
635 my $userdirproductversion = "";
636 if ( $hashref->{'USERDIRPRODUCTVERSION'} ) { $userdirproductversion = $hashref->{'USERDIRPRODUCTVERSION'}; }
637 my $productkey = $productname . " " . $productversion;
639 # string $buildid, which is used to replace the setup variable <buildid>
641 my $localminor = "flat";
642 if ( $installer::globals::minor ne "" ) { $localminor = $installer::globals::minor; }
643 else { $localminor = $installer::globals::lastminor; }
645 my $localbuild = $installer::globals::build;
647 if ( $localbuild =~ /^\s*(\w+?)(\d+)\s*$/ ) { $localbuild = $2; } # using "680" instead of "src680"
649 my $buildidstring = `cd $ENV{'SRCDIR'} 2>&1 >/dev/null && git log -n 1 --pretty=format:"%H"`;
650 if ($? || !$buildidstring) {
651 $buildidstring = $localbuild . $localminor . "(Build:" . $installer::globals::buildid . ")";
654 if ( $localminor =~ /^\s*\w(\d+)\w*\s*$/ ) { $localminor = $1; }
656 my $updateid = $productname . "_" . $userdirproductversion . "_" . $$languagestringref;
657 $updateid =~ s/ /_/g;
659 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
661 my $oneitem = ${$itemsarrayref}[$i];
662 my $value = $oneitem->{'Value'};
664 $value =~ s/\<buildid\>/$buildidstring/;
665 $value =~ s/\<sequence_languages\>/$languagesstring/;
666 $value =~ s/\<productkey\>/$productkey/;
667 $value =~ s/\<productcode\>/$installer::globals::productcode/;
668 $value =~ s/\<upgradecode\>/$installer::globals::upgradecode/;
669 $value =~ s/\<alllanguages\>/$languagesstring/;
670 $value =~ s/\<sourceid\>/$installer::globals::build/;
671 $value =~ s/\<updateid\>/$updateid/;
672 $value =~ s/\<pkgformat\>/$installer::globals::packageformat/;
673 $ENV{'OOO_VENDOR'} = "" if !defined $ENV{'OOO_VENDOR'};
674 $value =~ s/\<vendor\>/$ENV{'OOO_VENDOR'}/;
675 $ENV{'BUILD_VER_STRING'} = "" if !defined $ENV{'BUILD_VER_STRING'};
676 $value =~ s/\<buildversion\>/$ENV{'BUILD_VER_STRING'}/;
678 $oneitem->{'Value'} = $value;
682 ################################################################################
683 # By defining variable LOCALUSERDIR in *.lst it is possible to change
684 # the standard destination of user directory defined in scp2 ($SYSUSERCONFIG).
685 ################################################################################
687 sub replace_userdir_variable
689 my ($itemsarrayref) = @_;
691 my $userdir = "";
692 if ( $allvariableshashref->{'LOCALUSERDIR'} ) { $userdir = $allvariableshashref->{'LOCALUSERDIR'}; }
693 else { $userdir = $installer::globals::simpledefaultuserdir; }
695 if ( $userdir ne "" )
697 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
699 my $oneitem = ${$itemsarrayref}[$i];
700 $oneitem->{'Value'} =~ s/\$SYSUSERCONFIG/$userdir/;
705 #####################################################################################
706 # Files and ConfigurationItems are not included for all languages.
707 # For instance asian fonts. These can be removed, if no "Name" is found.
708 # ConfigurationItems are not always defined in the linguistic configuration file.
709 # The "Key" cannot be found for them.
710 #####################################################################################
712 sub remove_non_existent_languages_in_productlists
714 my ($itemsarrayref, $languagestringref, $searchkey, $itemtype) = @_;
716 # Removing of all non existent files, for instance asian fonts
718 installer::logger::include_header_into_logfile("Removing for this language $$languagestringref:");
720 my @allexistentitems = ();
722 my $infoline;
724 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
726 my $oneitem = ${$itemsarrayref}[$i];
727 my $oneitemname = ""; # $searchkey is "Name" for files and "Key" for ConfigurationItems
729 if ( $oneitem->{$searchkey} ) { $oneitemname = $oneitem->{$searchkey} }
731 my $itemtoberemoved = 0;
733 if ($oneitemname eq "") # for instance asian font in english installation set
735 $itemtoberemoved = 1;
738 if ($itemtoberemoved)
740 $infoline = "WARNING: Language $$languagestringref: No $itemtype packed for $oneitem->{'gid'}!\n";
741 push( @installer::globals::logfileinfo, $infoline);
743 else
745 push(@allexistentitems, $oneitem);
749 $infoline = "\n";
750 push( @installer::globals::logfileinfo, $infoline);
752 return \@allexistentitems;
755 ########################################################################
756 # Input is the directory gid, output the "HostName" of the directory
757 ########################################################################
759 sub get_Directoryname_From_Directorygid
761 my ($dirsarrayref ,$searchgid, $onelanguage, $oneitemgid) = @_;
763 my $directoryname = "";
764 my $onedirectory;
765 my $foundgid = 0;
767 for ( my $i = 0; $i <= $#{$dirsarrayref}; $i++ )
769 $onedirectory = ${$dirsarrayref}[$i];
770 my $directorygid = $onedirectory->{'gid'};
772 if ($directorygid eq $searchgid)
774 $foundgid = 1;
775 last;
779 if (!($foundgid))
781 installer::exiter::exit_program("ERROR: Gid $searchgid not defined in $installer::globals::setupscriptname", "get_Directoryname_From_Directorygid");
784 if ( ! ( $onedirectory->{'ismultilingual'} )) # the directory is not language dependent
786 $directoryname = $onedirectory->{'HostName'};
788 else
790 $directoryname = $onedirectory->{"HostName ($onelanguage)"};
793 # gid_Dir_Template_Wizard_Letter is defined as language dependent directory, but the file gid_Dir_Template_Wizard_Letter
794 # is not language dependent. Therefore $onelanguage is not defined. But which language is the correct language for the
795 # directory?
796 # Perhaps better solution: In scp it must be forbidden to have a language independent file in a language dependent directory.
798 if (( ! $directoryname ) && ( $onelanguage eq "" ))
800 installer::exiter::exit_program("ERROR (in scp): Directory $searchgid is language dependent, but not $oneitemgid inside this directory", "get_Directoryname_From_Directorygid");
803 return \$directoryname;
806 ##################################################################
807 # Getting destination direcotory for links, files and profiles
808 ##################################################################
810 sub get_Destination_Directory_For_Item_From_Directorylist # this is used for Files, Profiles and Links
812 my ($itemarrayref, $dirsarrayref) = @_;
814 for ( my $i = 0; $i <= $#{$itemarrayref}; $i++ )
816 my $oneitem = ${$itemarrayref}[$i];
817 my $oneitemgid = $oneitem->{'gid'};
818 my $directorygid = $oneitem->{'Dir'}; # for instance gid_Dir_Program
819 my $netdirectorygid = "";
820 my $onelanguage = $oneitem->{'specificlanguage'};
821 my $ispredefinedprogdir = 0;
822 my $ispredefinedconfigdir = 0;
824 my $oneitemname = $oneitem->{'Name'};
826 if ( $oneitem->{'NetDir'} ) { $netdirectorygid = $oneitem->{'NetDir'}; }
828 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$oneitemname); # making /registry/schema/org/openoffice/VCL.xcs to VCL.xcs
830 my $searchdirgid;
832 if ( $netdirectorygid eq "" ) # if NetDir is defined, it is privileged
834 $searchdirgid = $directorygid
836 else
838 $searchdirgid = $netdirectorygid
841 if ($searchdirgid =~ /PREDEFINED_PROGDIR/) # the root directory is not defined in setup script
843 $ispredefinedprogdir = 1;
846 if ($searchdirgid =~ /PREDEFINED_CONFIGDIR/) # the root directory is not defined in setup script
848 $ispredefinedconfigdir = 1;
851 my $destfilename;
853 if ($oneitem->{'DoNotMessWithSymlinks'})
855 $destfilename = $oneitem->{'Name'};
857 elsif ((!( $ispredefinedprogdir )) && (!( $ispredefinedconfigdir )))
859 my $directorynameref = get_Directoryname_From_Directorygid($dirsarrayref, $searchdirgid, $onelanguage, $oneitemgid);
860 my $styles = "";
861 if ($oneitem->{'Styles'}) { $styles = $oneitem->{'Styles'}; }
862 if ($styles =~ /\bFILELIST\b/)
864 $destfilename = $$directorynameref . $installer::globals::separator . $oneitemname;
866 else
868 $destfilename = $$directorynameref . $installer::globals::separator . $oneitem->{'Name'};
871 else
873 $destfilename = $oneitemname;
876 $oneitem->{'destination'} = $destfilename;
880 ##########################################################################
881 # Searching a file in a list of paths
882 ##########################################################################
884 sub get_sourcepath_from_filename_and_includepath_classic
886 my ($searchfilenameref, $includepatharrayref, $write_logfile) = @_;
888 my ($onefile, $includepath, $infoline);
890 my $foundsourcefile = 0;
892 for ( my $j = 0; $j <= $#{$includepatharrayref}; $j++ )
894 $includepath = ${$includepatharrayref}[$j];
895 installer::remover::remove_leading_and_ending_whitespaces(\$includepath);
897 $onefile = $includepath . $installer::globals::separator . $$searchfilenameref;
899 if ( -f $onefile )
901 $foundsourcefile = 1;
902 last;
906 if (!($foundsourcefile))
908 $onefile = ""; # the sourcepath has to be empty
909 if ( $write_logfile)
911 $infoline = "ERROR: Source for $$searchfilenameref not found (classic)!\n"; # Important message in log file
912 push( @installer::globals::logfileinfo, $infoline);
915 else
917 if ( $write_logfile)
919 $infoline = "SUCCESS: Source for $$searchfilenameref: $onefile\n";
920 push( @installer::globals::logfileinfo, $infoline);
924 return \$onefile;
927 ##########################################################################
928 # Input is one file name, output the complete absolute path of this file
929 ##########################################################################
931 sub get_sourcepath_from_filename_and_includepath
933 my ($searchfilenameref, $unused, $write_logfile) = @_;
935 my ($onefile, $includepath, $infoline);
937 my $foundsourcefile = 0;
938 my $foundnewname = 0;
940 for ( my $j = 0; $j <= $#installer::globals::allincludepaths; $j++ )
942 my $allfiles = $installer::globals::allincludepaths[$j];
944 if ( exists( $allfiles->{$$searchfilenameref} ))
946 $onefile = $allfiles->{'includepath'} . $installer::globals::separator . $$searchfilenameref;
947 $foundsourcefile = 1;
948 last;
952 if (!($foundsourcefile)) # testing with lowercase filename
954 # Attention: README01.html is copied for Windows to readme01.html, not case sensitive
956 for ( my $j = 0; $j <= $#installer::globals::allincludepaths; $j++ )
958 my $allfiles = $installer::globals::allincludepaths[$j];
960 my $newfilename = $$searchfilenameref;
961 $newfilename =~ s/readme/README/; # special handling for readme files
962 $newfilename =~ s/license/LICENSE/; # special handling for license files
964 if ( exists( $allfiles->{$newfilename} ))
966 $onefile = $allfiles->{'includepath'} . $installer::globals::separator . $newfilename;
967 $foundsourcefile = 1;
968 $foundnewname = 1;
969 last;
974 if (!($foundsourcefile))
976 $onefile = ""; # the sourcepath has to be empty
977 if ( $write_logfile)
979 $infoline = "ERROR: Source for $$searchfilenameref not found!\n"; # Important message in log file
980 push( @installer::globals::logfileinfo, $infoline);
983 else
985 if ( $write_logfile)
987 if (!($foundnewname))
989 $infoline = "SUCCESS: Source for $$searchfilenameref: $onefile\n";
991 else
993 $infoline = "SUCCESS/WARNING: Special handling for $$searchfilenameref: $onefile\n";
995 push( @installer::globals::logfileinfo, $infoline);
999 return \$onefile;
1002 ##############################################################
1003 # Getting all source paths for all files to be packed
1004 # $item can be "Files" or "ScpActions"
1005 ##############################################################
1007 sub get_Source_Directory_For_Files_From_Includepathlist
1009 my ($filesarrayref, $includepatharrayref, $dirsref, $item, $allvariables) = @_;
1011 installer::logger::include_header_into_logfile("$item:");
1013 my ($foundit, $dontcare, $extrarootdir) =
1014 get_office_directory_gid_and_hostname($dirsref);
1015 my $infoline = "";
1017 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1019 my $onefile = ${$filesarrayref}[$i];
1020 my $onelanguage = $onefile->{'specificlanguage'};
1022 if ( ! $onefile->{'Name'} ) { installer::exiter::exit_program("ERROR: $item without name ! GID: $onefile->{'gid'} ! Language: $onelanguage", "get_Source_Directory_For_Files_From_Includepathlist"); }
1024 my $onefilename = $onefile->{'Name'};
1025 if ( $item eq "ScpActions" ) { $onefilename =~ s/\//$installer::globals::separator/g; }
1026 $onefilename =~ s/^\s*\Q$installer::globals::separator\E//; # filename begins with a slash, for instance /registry/schema/org/openoffice/VCL.xcs
1028 my $styles = "";
1029 my $file_can_miss = 0;
1030 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1032 if (( $installer::globals::languagepack ) && ( ! $onefile->{'ismultilingual'} ) && ( ! ( $styles =~ /\bFORCELANGUAGEPACK\b/ ))) { $file_can_miss = 1; }
1033 if (( $installer::globals::helppack ) && ( ! $onefile->{'ismultilingual'} ) && ( ! ( $styles =~ /\bFORCEHELPPACK\b/ ))) { $file_can_miss = 1; }
1035 my $sourcepathref = "";
1037 my $destination = $onefile->{'destination'};
1038 my $instdirdestination;
1039 if ($destination)
1041 if (($installer::globals::iswindowsbuild) && $foundit && $extrarootdir)
1043 $destination =~ s,$extrarootdir/,,; # remove it from path
1045 if (($installer::globals::languagepack) && ($installer::globals::ismacbuild))
1046 { # source files are in $(PRODUCTNAME).app where they will
1047 # actually copied by the user executing the Language Pack.app
1048 $destination =~ s, Language Pack.app/,.app/,;
1050 $instdirdestination = $ENV{'INSTDIR'} . $installer::globals::separator . $destination;
1052 if ($instdirdestination && -f $instdirdestination)
1054 $infoline = "SUCCESS: INSTDIR Source for $onefilename: $instdirdestination\n";
1055 push( @installer::globals::logfileinfo, $infoline);
1056 $$sourcepathref = $instdirdestination;
1058 else
1060 if ( $file_can_miss ) { $sourcepathref = get_sourcepath_from_filename_and_includepath(\$onefilename, $includepatharrayref, 0); }
1061 else { $sourcepathref = get_sourcepath_from_filename_and_includepath(\$onefilename, $includepatharrayref, 1); }
1064 $onefile->{'sourcepath'} = $$sourcepathref; # This $$sourcepathref is empty, if no source was found
1067 $infoline = "\n"; # empty line after listing of all files
1068 push( @installer::globals::logfileinfo, $infoline);
1071 #################################################################################
1072 # Removing files, that shall not be included into languagepacks
1073 # (because of rpm conflicts)
1074 #################################################################################
1076 sub remove_Files_For_Languagepacks
1078 my ($itemsarrayref) = @_;
1080 my $infoline;
1082 my @newitemsarray = ();
1084 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1086 my $oneitem = ${$itemsarrayref}[$i];
1087 my $gid = $oneitem->{'gid'};
1089 # scp Todo: Remove asap after removal of old setup
1091 if (( $gid eq "gid_File_Extra_Fontunxpsprint" ) ||
1092 ( $gid eq "gid_File_Extra_Migration_Lang" ))
1094 $infoline = "ATTENTION: Removing item $oneitem->{'gid'} from the installation set.\n";
1095 push( @installer::globals::logfileinfo, $infoline);
1097 next;
1100 push(@newitemsarray, $oneitem);
1103 return \@newitemsarray;
1106 #################################################################################
1107 # Files, whose source directory is not found, are removed now (this is an ERROR)
1108 #################################################################################
1110 sub remove_Files_Without_Sourcedirectory
1112 my ($filesarrayref) = @_;
1114 my $infoline;
1116 my $error_occurred = 0;
1117 my @missingfiles = ();
1118 push(@missingfiles, "ERROR: The following files could not be found: \n");
1120 my @newfilesarray = ();
1122 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1124 my $onefile = ${$filesarrayref}[$i];
1125 my $sourcepath = $onefile->{'sourcepath'};
1127 if ($sourcepath eq "")
1129 my $styles = $onefile->{'Styles'};
1130 my $filename = $onefile->{'Name'};
1132 if ( ! $installer::globals::languagepack && !$installer::globals::helppack)
1134 $infoline = "ERROR: Removing file $filename from file list.\n";
1135 push( @installer::globals::logfileinfo, $infoline);
1137 push(@missingfiles, "ERROR: File not found: $filename\n");
1138 $error_occurred = 1;
1140 next; # removing this file from list, if sourcepath is empty
1142 elsif ( $installer::globals::languagepack ) # special case for language packs
1144 if (( $onefile->{'ismultilingual'} ) || ( $styles =~ /\bFORCELANGUAGEPACK\b/ ))
1146 $infoline = "ERROR: Removing file $filename from file list.\n";
1147 push( @installer::globals::logfileinfo, $infoline);
1149 push(@missingfiles, "ERROR: File not found: $filename\n");
1150 $error_occurred = 1;
1152 next; # removing this file from list, if sourcepath is empty
1154 else
1156 $infoline = "INFO: Removing file $filename from file list. It is not language dependent.\n";
1157 push( @installer::globals::logfileinfo, $infoline);
1158 $infoline = "INFO: It is not language dependent and can be ignored in language packs.\n";
1159 push( @installer::globals::logfileinfo, $infoline);
1161 next; # removing this file from list, if sourcepath is empty
1164 else # special case for help packs
1166 if (( $onefile->{'ismultilingual'} ) || ( $styles =~ /\bFORCEHELPPACK\b/ ))
1168 $infoline = "ERROR: Removing file $filename from file list.\n";
1169 push( @installer::globals::logfileinfo, $infoline);
1171 push(@missingfiles, "ERROR: File not found: $filename\n");
1172 $error_occurred = 1;
1174 next; # removing this file from list, if sourcepath is empty
1176 else
1178 $infoline = "INFO: Removing file $filename from file list. It is not language dependent.\n";
1179 push( @installer::globals::logfileinfo, $infoline);
1180 $infoline = "INFO: It is not language dependent and can be ignored in help packs.\n";
1181 push( @installer::globals::logfileinfo, $infoline);
1183 next; # removing this file from list, if sourcepath is empty
1188 push(@newfilesarray, $onefile);
1191 $infoline = "\n";
1192 push( @installer::globals::logfileinfo, $infoline);
1194 if ( $error_occurred )
1196 for ( my $i = 0; $i <= $#missingfiles; $i++ ) { print "$missingfiles[$i]"; }
1197 installer::exiter::exit_program("ERROR: Missing files", "remove_Files_Without_Sourcedirectory");
1200 return \@newfilesarray;
1203 ############################################################################
1204 # License and Readme files in the default language have to be installed
1205 # in the directory with flag OFFICEDIRECTORY. If this is not defined
1206 # they have to be installed in the installation root.
1207 ############################################################################
1209 sub get_office_directory_gid_and_hostname
1211 my ($dirsarrayref) = @_;
1213 my $foundofficedir = 0;
1214 my $gid = "";
1215 my $hostname = "";
1217 for ( my $i = 0; $i <= $#{$dirsarrayref}; $i++ )
1219 my $onedir = ${$dirsarrayref}[$i];
1220 if ( $onedir->{'Styles'} )
1222 my $styles = $onedir->{'Styles'};
1224 if ( $styles =~ /\bOFFICEDIRECTORY\b/ )
1226 $foundofficedir = 1;
1227 $gid = $onedir->{'gid'};
1228 $hostname = $onedir->{'HostName'};
1229 last;
1234 return ($foundofficedir, $gid, $hostname);
1237 ############################################################################
1238 # License and Readme files in the default language have to be installed
1239 # in the installation root (next to the program dir). This is in scp
1240 # project done by a post install basic script
1241 ############################################################################
1243 sub add_License_Files_into_Installdir
1245 my ($filesarrayref, $dirsarrayref, $languagesarrayref) = @_;
1247 my $infoline;
1249 my @newfilesarray = ();
1251 my $defaultlanguage = installer::languages::get_default_language($languagesarrayref);
1253 my ($foundofficedir, $officedirectorygid, $officedirectoryhostname) = get_office_directory_gid_and_hostname($dirsarrayref);
1255 # copy all files from directory share/readme, that contain the default language in their name
1256 # without default language into the installation root. This makes the settings of the correct
1257 # file names superfluous. On the other hand this requires a dependency to the directory
1258 # share/readme
1260 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1262 my $onefile = ${$filesarrayref}[$i];
1263 my $destination = $onefile->{'destination'};
1264 my $styles = "";
1265 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1267 if ( ( $destination =~ /share\Q$installer::globals::separator\Ereadme\Q$installer::globals::separator\E(\w+?)_?$defaultlanguage\.?(\w*)\s*/ )
1268 || (( $styles =~ /\bROOTLICENSEFILE\b/ ) && ( $destination =~ /\Q$installer::globals::separator\E?(\w+?)_?$defaultlanguage\.?(\w*?)\s*$/ )) )
1270 my $filename = $1;
1271 my $extension = $2;
1273 my $newfilename;
1275 if ( $extension eq "" ) { $newfilename = $filename; }
1276 else { $newfilename = $filename . "\." . $extension; }
1278 my %newfile = ();
1279 my $newfile = \%newfile;
1281 installer::converter::copy_item_object($onefile, $newfile);
1283 $newfile->{'gid'} = $onefile->{'gid'} . "_Copy";
1284 $newfile->{'Name'} = $newfilename;
1285 $newfile->{'ismultilingual'} = "0";
1286 $newfile->{'specificlanguage'} = "";
1287 $newfile->{'haslanguagemodule'} = "0";
1289 if ( defined $newfile->{'InstallName'} )
1291 if ( $newfile->{'InstallName'} =~ /^\s*(.*?)_$defaultlanguage\.?(\w*?)\s*$/ )
1293 my $localfilename = $1;
1294 my $localextension = $2;
1296 if ( $localextension eq "" ) { $newfile->{'InstallName'} = $localfilename; }
1297 else { $newfile->{'InstallName'} = $localfilename . "\." . $localextension; }
1301 $newfile->{'removelangfromfile'} = "1"; # Important for files with an InstallName, because language also has to be removed there.
1303 if ( $foundofficedir )
1305 $newfile->{'Dir'} = $officedirectorygid;
1306 $newfile->{'destination'} = $officedirectoryhostname . $installer::globals::separator . $newfilename;
1308 else
1310 $newfile->{'Dir'} = "PREDEFINED_PROGDIR";
1311 $newfile->{'destination'} = $newfilename;
1314 # Also setting "modules=gid_Module_Root_Brand" (module with style: ROOT_BRAND_PACKAGE)
1315 if ( $installer::globals::rootbrandpackageset )
1317 $newfile->{'modules'} = $installer::globals::rootbrandpackage;
1320 push(@newfilesarray, $newfile);
1322 $infoline = "New files: Adding file $newfilename for the installation root to the file list. Language: $defaultlanguage\n";
1323 push( @installer::globals::logfileinfo, $infoline);
1325 if ( defined $newfile->{'InstallName'} )
1327 $infoline = "New files: Using installation name: $newfile->{'InstallName'}\n";
1328 push( @installer::globals::logfileinfo, $infoline);
1332 push(@newfilesarray, $onefile);
1335 return \@newfilesarray;
1338 ############################################################################
1339 # Some files are included for more than one language and have the same
1340 # name and the same destination directory for all languages. This would
1341 # lead to conflicts, if the filenames are not changed.
1342 # In scp project this files must have the flag MAKE_LANG_SPECIFIC
1343 # For this files, the language is included into the filename.
1344 ############################################################################
1346 sub make_filename_language_specific
1348 my ($filesarrayref) = @_;
1350 my $infoline = "";
1352 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1354 my $onefile = ${$filesarrayref}[$i];
1356 if ( $onefile->{'ismultilingual'} )
1358 my $styles = "";
1359 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1360 if ( $styles =~ /\bMAKE_LANG_SPECIFIC\b/ )
1362 my $language = $onefile->{'specificlanguage'};
1363 my $olddestination = $onefile->{'destination'};
1364 my $oldname = $onefile->{'Name'};
1366 # Including the language into the file name.
1367 # But be sure, to include the language before the file extension.
1369 my $fileextension = "";
1371 if ( $onefile->{'Name'} =~ /(\.\w+?)\s*$/ ) { $fileextension = $1; }
1372 if ( $fileextension ne "" )
1374 $onefile->{'Name'} =~ s/\Q$fileextension\E\s*$/_$language$fileextension/;
1375 $onefile->{'destination'} =~ s/\Q$fileextension\E\s*$/_$language$fileextension/;
1378 $infoline = "Flag MAKE_LANG_SPECIFIC:\n";
1379 push( @installer::globals::logfileinfo, $infoline);
1380 $infoline = "Changing name from $oldname to $onefile->{'Name'} !\n";
1381 push( @installer::globals::logfileinfo, $infoline);
1382 $infoline = "Changing destination from $olddestination to $onefile->{'destination'} !\n";
1383 push( @installer::globals::logfileinfo, $infoline);
1389 ############################################################################
1390 # Because of the item "File" the source name must be "Name". Therefore
1391 # "Copy" is changed to "Name" and "Name" is changed to "DestinationName".
1392 ############################################################################
1394 sub change_keys_of_scpactions
1396 my ($itemsarrayref) = @_;
1398 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1400 my $oneitem = ${$itemsarrayref}[$i];
1402 my $key;
1404 # First Name to DestinationName, then deleting Name
1405 foreach $key (keys %{$oneitem})
1407 if ( $key =~ /\bName\b/ )
1409 my $value = $oneitem->{$key};
1410 my $oldkey = $key;
1411 $key =~ s/Name/DestinationName/;
1412 $oneitem->{$key} = $value;
1413 delete($oneitem->{$oldkey});
1417 # Second Copy to Name, then deleting Copy
1418 foreach $key (keys %{$oneitem})
1420 if ( $key =~ /\bCopy\b/ )
1422 my $value = $oneitem->{$key};
1423 my $oldkey = $key;
1424 $key =~ s/Copy/Name/;
1425 $oneitem->{$key} = $value;
1426 delete($oneitem->{$oldkey});
1432 ############################################################################
1433 # Removing all language pack files from installation set (files with
1434 # the style LANGUAGEPACK), except this is a language pack.
1435 ############################################################################
1437 sub remove_Languagepacklibraries_from_Installset
1439 my ($itemsarrayref) = @_;
1441 my $infoline;
1443 my @newitemsarray = ();
1445 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1447 my $oneitem = ${$itemsarrayref}[$i];
1448 my $styles = "";
1449 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
1451 if ( $styles =~ /\bLANGUAGEPACK\b/ )
1453 $infoline = "Removing language pack file $oneitem->{'gid'} from the installation set.\n";
1454 push( @installer::globals::globallogfileinfo, $infoline);
1456 next;
1459 push(@newitemsarray, $oneitem);
1462 $infoline = "\n";
1463 push( @installer::globals::globallogfileinfo, $infoline);
1465 return \@newitemsarray;
1468 ############################################################################
1469 # Removing all help pack files from installation set (files with
1470 # the style HELPPACK), except this is a help pack.
1471 ############################################################################
1473 sub remove_Helppacklibraries_from_Installset
1475 my ($itemsarrayref) = @_;
1477 my $infoline;
1479 my @newitemsarray = ();
1481 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1483 my $oneitem = ${$itemsarrayref}[$i];
1484 my $styles = "";
1485 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
1487 if ( $styles =~ /\bHELPPACK\b/ )
1489 $infoline = "Removing help pack file $oneitem->{'gid'} from the installation set.\n";
1490 push( @installer::globals::globallogfileinfo, $infoline);
1492 next;
1495 push(@newitemsarray, $oneitem);
1498 $infoline = "\n";
1499 push( @installer::globals::globallogfileinfo, $infoline);
1501 return \@newitemsarray;
1504 ############################################################################
1505 # Some files cotain a $ in their name. epm conflicts with such files.
1506 # Solution: Renaming this files, converting "$" to "$$"
1507 ############################################################################
1509 sub quoting_illegal_filenames
1511 my ($filesarrayref) = @_;
1513 # This function has to be removed as soon as possible!
1515 installer::logger::include_header_into_logfile("Renaming illegal filenames:");
1517 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1519 my $onefile = ${$filesarrayref}[$i];
1520 my $filename = $onefile->{'Name'};
1522 if ( $filename =~ /\$/ )
1524 my $sourcepath = $onefile->{'sourcepath'};
1525 my $destpath = $onefile->{'destination'};
1527 # sourcepath and destination have to be quoted for epm list file
1529 $destpath =~ s/\$/\$\$/g;
1530 $sourcepath =~ s/\$/\$\$/g;
1532 my $infoline = "ATTENTION: Files: Quoting sourcepath $onefile->{'sourcepath'} to $sourcepath\n";
1533 push( @installer::globals::logfileinfo, $infoline);
1534 $infoline = "ATTENTION: Files: Quoting destination path $onefile->{'destination'} to $destpath\n";
1535 push( @installer::globals::logfileinfo, $infoline);
1537 $onefile->{'sourcepath'} = $sourcepath;
1538 $onefile->{'destination'} = $destpath;
1543 ############################################################################
1544 # Removing multiple occurrences of same module.
1545 ############################################################################
1547 sub optimize_list
1549 my ( $longlist ) = @_;
1550 my %tmpHash;
1552 $longlist =~ s/^\s+//;
1553 $longlist =~ s/\s+$//;
1554 $longlist =~ s/\s*,\s*/,/g;
1556 @tmpHash{split /,/, $longlist} = ();
1557 return join(",", sort keys %tmpHash);
1560 #######################################################################
1561 # Collecting all directories needed for the epm list
1562 # 1. Looking for all destination paths in the files array
1563 # 2. Looking for directories with CREATE flag in the directory array
1564 #######################################################################
1566 ##################################
1567 # Collecting directories: Part 1
1568 ##################################
1570 sub collect_directories_from_filesarray
1572 my ($filesarrayref) = @_;
1574 my @alldirectories = ();
1575 my %alldirectoryhash = ();
1577 my $predefinedprogdir_added = 0;
1579 # Preparing this already as hash, although the only needed value at the moment is the HostName
1580 # But also adding: "specificlanguage" and "Dir" (for instance gid_Dir_Program)
1582 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1584 my $onefile = ${$filesarrayref}[$i];
1585 my $destinationpath = $onefile->{'destination'};
1586 installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationpath);
1587 $destinationpath =~ s/\Q$installer::globals::separator\E\s*$//; # removing ending slashes or backslashes
1591 if (!exists($alldirectoryhash{$destinationpath}))
1593 my %directoryhash = ();
1594 $directoryhash{'HostName'} = $destinationpath;
1595 $directoryhash{'specificlanguage'} = $onefile->{'specificlanguage'};
1596 $directoryhash{'Dir'} = $onefile->{'Dir'};
1597 $directoryhash{'modules'} = $onefile->{'modules'}; # NEW, saving modules
1599 $predefinedprogdir_added ||= $onefile->{'Dir'} eq "PREDEFINED_PROGDIR";
1601 $alldirectoryhash{$destinationpath} = \%directoryhash;
1603 else
1605 # Adding the modules to the module list!
1606 $alldirectoryhash{$destinationpath}->{'modules'} .= "," . $onefile->{'modules'};
1608 } while ($destinationpath =~ s/(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/$1/); # as long as the path contains slashes
1611 # if there is no file in the root directory PREDEFINED_PROGDIR, it has to be included into the directory array now
1612 # HostName= specificlanguage= Dir=PREDEFINED_PROGDIR
1614 if (! $predefinedprogdir_added )
1616 my %directoryhash = ();
1617 $directoryhash{'HostName'} = "";
1618 $directoryhash{'specificlanguage'} = "";
1619 $directoryhash{'modules'} = ""; # ToDo?
1620 $directoryhash{'Dir'} = "PREDEFINED_PROGDIR";
1622 push(@alldirectories, \%directoryhash);
1625 # Creating directory array
1626 foreach my $destdir ( sort keys %alldirectoryhash )
1628 $alldirectoryhash{$destdir}->{'modules'} = optimize_list($alldirectoryhash{$destdir}->{'modules'});
1629 push(@alldirectories, $alldirectoryhash{$destdir});
1632 return (\@alldirectories, \%alldirectoryhash);
1635 ##################################
1636 # Collecting directories: Part 2
1637 ##################################
1639 sub collect_directories_with_create_flag_from_directoryarray
1641 my ($directoryarrayref, $alldirectoryhash) = @_;
1643 my $alreadyincluded = 0;
1644 my @alldirectories = ();
1646 for ( my $i = 0; $i <= $#{$directoryarrayref}; $i++ )
1648 my $onedir = ${$directoryarrayref}[$i];
1649 my $styles = "";
1650 $newdirincluded = 0;
1652 if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
1654 if ( $styles =~ /\bCREATE\b/ )
1656 my $directoryname = "";
1658 if ( $onedir->{'HostName'} ) { $directoryname = $onedir->{'HostName'}; }
1659 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"); }
1661 $alreadyincluded = 0;
1662 if ( exists($alldirectoryhash->{$directoryname}) ) { $alreadyincluded = 1; }
1664 if (!($alreadyincluded))
1666 my %directoryhash = ();
1667 $directoryhash{'HostName'} = $directoryname;
1668 $directoryhash{'specificlanguage'} = $onedir->{'specificlanguage'};
1669 $directoryhash{'Dir'} = $onedir->{'gid'};
1670 $directoryhash{'Styles'} = $onedir->{'Styles'};
1672 # saving also the modules
1673 if ( ! $onedir->{'modules'} ) { installer::exiter::exit_program("ERROR: No assigned modules found for directory $onedir->{'gid'}", "collect_directories_with_create_flag_from_directoryarray"); }
1674 $directoryhash{'modules'} = $onedir->{'modules'};
1676 $alldirectoryhash->{$directoryname} = \%directoryhash;
1677 $newdirincluded = 1;
1679 # Problem: The $destinationpath can be share/registry/schema/org/openoffice
1680 # but not all directories contain files and will be added to this list.
1681 # Therefore the path has to be analyzed.
1683 while ( $directoryname =~ /(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/ ) # as long as the path contains slashes
1685 $directoryname = $1;
1687 $alreadyincluded = 0;
1688 if ( exists($alldirectoryhash->{$directoryname}) ) { $alreadyincluded = 1; }
1690 if (!($alreadyincluded))
1692 my %directoryhash = ();
1694 $directoryhash{'HostName'} = $directoryname;
1695 $directoryhash{'specificlanguage'} = $onedir->{'specificlanguage'};
1696 $directoryhash{'Dir'} = $onedir->{'gid'};
1697 if ( ! $installer::globals::iswindowsbuild ) { $directoryhash{'Styles'} = "(CREATE)"; } # Exeception for Windows?
1699 # saving also the modules
1700 $directoryhash{'modules'} = $onedir->{'modules'};
1702 $alldirectoryhash->{$directoryname} = \%directoryhash;
1703 $newdirincluded = 1;
1705 else
1707 # Adding the modules to the module list!
1708 $alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $onedir->{'modules'};
1712 else
1714 # Adding the modules to the module list!
1715 $alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $onedir->{'modules'};
1717 while ( $directoryname =~ /(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/ ) # as long as the path contains slashes
1719 $directoryname = $1;
1720 # Adding the modules to the module list!
1721 $alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $onedir->{'modules'};
1726 # Saving the styles for already added directories in function collect_directories_from_filesarray
1728 if (( ! $newdirincluded ) && ( $styles ne "" ))
1730 $styles =~ s/\bWORKSTATION\b//;
1731 $styles =~ s/\bCREATE\b//;
1733 if (( ! ( $styles =~ /^\s*\(\s*\)\s*$/ )) && ( ! ( $styles =~ /^\s*\(\s*\,\s*\)\s*$/ )) && ( ! ( $styles =~ /^\s*$/ ))) # checking, if there are styles left
1735 my $directoryname = "";
1736 if ( $onedir->{'HostName'} ) { $directoryname = $onedir->{'HostName'}; }
1737 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"); }
1739 if ( exists($alldirectoryhash->{$directoryname}) )
1741 $alldirectoryhash->{$directoryname}->{'Styles'} = $styles;
1747 # Creating directory array
1748 foreach my $destdir ( sort keys %{$alldirectoryhash} )
1750 $alldirectoryhash->{$destdir}->{'modules'} = optimize_list($alldirectoryhash->{$destdir}->{'modules'});
1751 push(@alldirectories, $alldirectoryhash->{$destdir});
1754 return (\@alldirectories, \%alldirectoryhash);
1757 #################################################
1758 # Determining the destination file of a link
1759 #################################################
1761 sub get_destination_file_path_for_links
1763 my ($linksarrayref, $filesarrayref) = @_;
1765 my $infoline;
1767 for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ )
1769 my $fileid = "";
1770 my $onelink = ${$linksarrayref}[$i];
1771 if ( $onelink->{'FileID'} ) { $fileid = $onelink->{'FileID'}; }
1773 if (!( $fileid eq "" ))
1775 my $foundfile = 0;
1777 for ( my $j = 0; $j <= $#{$filesarrayref}; $j++ )
1779 my $onefile = ${$filesarrayref}[$j];
1780 my $filegid = $onefile->{'gid'};
1782 if ( $filegid eq $fileid )
1784 $foundfile = 1;
1785 $onelink->{'destinationfile'} = $onefile->{'destination'};
1786 last;
1790 if (!($foundfile))
1792 $infoline = "Warning: FileID $fileid for Link $onelink->{'gid'} not found!\n";
1793 push( @installer::globals::logfileinfo, $infoline);
1798 $infoline = "\n";
1799 push( @installer::globals::logfileinfo, $infoline);
1802 #################################################
1803 # Determining the destination link of a link
1804 #################################################
1806 sub get_destination_link_path_for_links
1808 my ($linksarrayref) = @_;
1810 my $infoline;
1812 for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ )
1814 my $shortcutid = "";
1815 my $onelink = ${$linksarrayref}[$i];
1816 if ( $onelink->{'ShortcutID'} ) { $shortcutid = $onelink->{'ShortcutID'}; }
1818 if (!( $shortcutid eq "" ))
1820 my $foundlink = 0;
1822 for ( my $j = 0; $j <= $#{$linksarrayref}; $j++ )
1824 my $destlink = ${$linksarrayref}[$j];
1825 $shortcutgid = $destlink->{'gid'};
1827 if ( $shortcutgid eq $shortcutid )
1829 $foundlink = 1;
1830 $onelink->{'destinationfile'} = $destlink->{'destination'}; # making key 'destinationfile'
1831 last;
1835 if (!($foundlink))
1837 $infoline = "Warning: ShortcutID $shortcutid for Link $onelink->{'gid'} not found!\n";
1838 push( @installer::globals::logfileinfo, $infoline);
1843 $infoline = "\n";
1844 push( @installer::globals::logfileinfo, $infoline);
1847 ###################################################################################
1848 # Items with flag WORKSTATION are not needed (here: links and configurationitems)
1849 ###################################################################################
1851 sub remove_workstation_only_items
1853 my ($itemarrayref) = @_;
1855 my @newitemarray = ();
1857 for ( my $i = 0; $i <= $#{$itemarrayref}; $i++ )
1859 my $oneitem = ${$itemarrayref}[$i];
1860 my $styles = $oneitem->{'Styles'};
1862 if (( $styles =~ /\bWORKSTATION\b/ ) &&
1863 (!( $styles =~ /\bNETWORK\b/ )) &&
1864 (!( $styles =~ /\bSTANDALONE\b/ )))
1866 next; # removing this link, it is only needed for a workstation installation
1869 push(@newitemarray, $oneitem);
1872 return \@newitemarray;
1875 ################################################
1876 # Resolving relative path in links
1877 ################################################
1879 sub resolve_links_with_flag_relative
1881 my ($linksarrayref) = @_;
1883 # Before this step is:
1884 # destination=program/libsalhelperC52.so.3, this will be the name of the link
1885 # destinationfile=program/libsalhelperC52.so.3, this will be the linked file or name
1886 # If the flag RELATIVE is set, the paths have to be analyzed. If the flag is not set
1887 # (this will not occur in the future?) destinationfile has to be an absolute path name
1889 for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ )
1891 my $onelink = ${$linksarrayref}[$i];
1892 my $styles = $onelink->{'Styles'};
1894 if ( $styles =~ /\bRELATIVE\b/ )
1896 # ToDo: This is only a simple not sufficient mechanism
1898 my $destination = $onelink->{'destination'};
1899 my $destinationfile = $onelink->{'destinationfile'};
1901 my $destinationpath = $destination;
1903 installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationpath);
1905 my $destinationfilepath = $destinationfile;
1907 # it is possible, that the destinationfile is no longer part of the files collector
1908 if ($destinationfilepath) { installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationfilepath); }
1909 else { $destinationfilepath = ""; }
1911 if ( $destinationpath eq $destinationfilepath )
1913 # link and file are in the same directory
1914 # Therefore the path of the file can be removed
1916 my $newdestinationfile = $destinationfile;
1917 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$newdestinationfile);
1919 $onelink->{'destinationfile'} = $newdestinationfile;
1925 ########################################################################
1926 # This function is a helper of function "assigning_modules_to_items"
1927 ########################################################################
1929 sub insert_for_item ($$$)
1931 my ($hash, $item, $id) = @_;
1933 if (!defined $hash->{$item})
1935 my @gids = ();
1936 $hash->{$item} = \@gids;
1938 my $gid_list = $hash->{$item};
1939 push @{$gid_list}, $id;
1940 $hash->{$item} = $gid_list;
1943 sub build_modulegids_table
1945 my ($modulesref, $itemname) = @_;
1947 my %module_lookup_table = ();
1949 # build map of item names to list of respective module gids
1950 # containing these items
1951 for my $onemodule (@{$modulesref})
1953 next if ( ! defined $onemodule->{$itemname} );
1954 # these are the items contained in this module
1955 # eg. Files = (gid_a_b_c,gid_d_e_f)
1956 my $module_gids = $onemodule->{$itemname};
1958 # prune outer brackets
1959 $module_gids =~ s|^\s*\(||g;
1960 $module_gids =~ s|\)\s*$||g;
1961 for my $id (split (/,/, $module_gids))
1963 chomp $id;
1964 insert_for_item(\%module_lookup_table, lc ($id), $onemodule->{'gid'});
1968 return \%module_lookup_table;
1971 ########################################################################
1972 # Items like files do not know their modules
1973 # This function is a helper of function "assigning_modules_to_items"
1974 ########################################################################
1976 sub get_string_of_modulegids_for_itemgid
1978 my ($module_lookup_table, $modulesref, $itemgid, $itemname) = @_;
1980 my $allmodules = "";
1981 my $haslanguagemodule = 0;
1982 my %foundmodules = ();
1984 my $gid_list = $module_lookup_table->{lc($itemgid)};
1986 for my $gid (@{$gid_list})
1988 $foundmodules{$gid} = 1;
1989 $allmodules = $allmodules . "," . $gid;
1990 # Is this module a language module? This info should be stored at the file.
1991 if ( exists($installer::globals::alllangmodules{$gid}) ) { $haslanguagemodule = 1; }
1994 $allmodules =~ s/^\s*\,//; # removing leading comma
1996 # Check: All modules or no module must have flag LANGUAGEMODULE
1997 if ( $haslanguagemodule )
1999 my $isreallylanguagemodule = _key_in_a_is_also_key_in_b(\%foundmodules, \%installer::globals::alllangmodules);
2000 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"); }
2003 return ($allmodules, $haslanguagemodule);
2006 ########################################################
2007 # Items like files do not know their modules
2008 # This function add the {'modules'} to these items
2009 ########################################################
2011 sub assigning_modules_to_items
2013 my ($modulesref, $itemsref, $itemname) = @_;
2015 my $infoline = "";
2016 my $languageassignmenterror = 0;
2017 my @languageassignmenterrors = ();
2019 my $module_lookup_table = build_modulegids_table($modulesref, $itemname);
2021 for my $oneitem (@{$itemsref})
2023 my $itemgid = $oneitem->{'gid'};
2025 my $styles = "";
2026 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
2027 if (( $itemname eq "Dirs" ) && ( ! ( $styles =~ /\bCREATE\b/ ))) { next; }
2029 if ( $itemgid eq "" )
2031 installer::exiter::exit_program("ERROR in item collection: No gid for item $oneitem->{'Name'}", "assigning_modules_to_items");
2034 # every item can belong to many modules
2036 my ($modulegids, $haslanguagemodule) = get_string_of_modulegids_for_itemgid($module_lookup_table, $modulesref, $itemgid, $itemname);
2038 if ($modulegids eq "")
2040 installer::exiter::exit_program("ERROR in file collection: No module found for $itemname $itemgid", "assigning_modules_to_items");
2043 $oneitem->{'modules'} = $modulegids;
2044 $oneitem->{'haslanguagemodule'} = $haslanguagemodule;
2046 # Important check: "ismultilingual" and "haslanguagemodule" must have the same value !
2047 if (( $oneitem->{'ismultilingual'} ) && ( ! $oneitem->{'haslanguagemodule'} ))
2049 $infoline = "Error: \"$oneitem->{'gid'}\" is multi lingual, but not in language pack (Assigned module: $modulegids)!\n";
2050 push( @installer::globals::globallogfileinfo, $infoline);
2051 push( @languageassignmenterrors, $infoline );
2052 $languageassignmenterror = 1;
2054 if (( $oneitem->{'haslanguagemodule'} ) && ( ! $oneitem->{'ismultilingual'} ))
2056 $infoline = "Error: \"$oneitem->{'gid'}\" is in language pack, but not multi lingual (Assigned module: $modulegids)!\n";
2057 push( @installer::globals::globallogfileinfo, $infoline);
2058 push( @languageassignmenterrors, $infoline );
2059 $languageassignmenterror = 1;
2063 if ($languageassignmenterror)
2065 for ( my $i = 0; $i <= $#languageassignmenterrors; $i++ ) { print "$languageassignmenterrors[$i]"; }
2066 installer::exiter::exit_program("ERROR: Incorrect assignments for language packs.", "assigning_modules_to_items");
2071 #################################################################################################
2072 # Root path (for instance /opt/openofficeorg20) needs to be added to directories, files and links
2073 #################################################################################################
2075 sub add_rootpath_to_directories
2077 my ($dirsref, $rootpath) = @_;
2079 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
2081 my $onedir = ${$dirsref}[$i];
2082 my $dir = "";
2084 if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; }
2086 if (!($dir =~ /\bPREDEFINED_/ ))
2088 my $hostname = $onedir->{'HostName'};
2089 $hostname = $rootpath . $installer::globals::separator . $hostname;
2090 $onedir->{'HostName'} = $hostname;
2093 # added
2095 if ( $dir =~ /\bPREDEFINED_PROGDIR\b/ )
2097 my $hostname = $onedir->{'HostName'};
2098 if ( $hostname eq "" ) { $onedir->{'HostName'} = $rootpath; }
2099 else { $onedir->{'HostName'} = $rootpath . $installer::globals::separator . $hostname; }
2104 sub add_rootpath_to_files
2106 my ($filesref, $rootpath) = @_;
2108 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
2110 my $onefile = ${$filesref}[$i];
2111 my $destination = $onefile->{'destination'};
2112 $destination = $rootpath . $installer::globals::separator . $destination;
2113 $onefile->{'destination'} = $destination;
2117 sub add_rootpath_to_links
2119 my ($linksref, $rootpath) = @_;
2121 for ( my $i = 0; $i <= $#{$linksref}; $i++ )
2123 my $onelink = ${$linksref}[$i];
2124 my $styles = $onelink->{'Styles'};
2126 my $destination = $onelink->{'destination'};
2127 $destination = $rootpath . $installer::globals::separator . $destination;
2128 $onelink->{'destination'} = $destination;
2130 if (!($styles =~ /\bRELATIVE\b/ )) # for absolute links
2132 my $destinationfile = $onelink->{'destinationfile'};
2133 $destinationfile = $rootpath . $installer::globals::separator . $destinationfile;
2134 $onelink->{'destinationfile'} = $destinationfile;
2139 #################################################################################
2140 # Collecting all parent gids
2141 #################################################################################
2143 sub collect_all_parent_feature
2145 my ($modulesref) = @_;
2147 my @allparents = ();
2149 my $found_root_module = 0;
2151 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2153 my $onefeature = ${$modulesref}[$i];
2155 my $parentgid = "";
2156 if ( $onefeature->{'ParentID'} )
2158 $parentgid = $onefeature->{'ParentID'};
2161 if ( $parentgid ne "" )
2163 if (! grep {$_ eq $parentgid} @allparents)
2165 push(@allparents, $parentgid);
2169 # Setting the global root module
2171 if ( $parentgid eq "" )
2173 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"); }
2174 $installer::globals::rootmodulegid = $onefeature->{'gid'};
2175 $found_root_module = 1;
2176 $infoline = "Setting Root Module: $installer::globals::rootmodulegid\n";
2177 push( @installer::globals::globallogfileinfo, $infoline);
2180 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"); }
2184 return \@allparents;
2187 #################################################################################
2188 # Checking for every feature, whether it has children
2189 #################################################################################
2191 sub set_children_flag
2193 my ($modulesref) = @_;
2195 my $allparents = collect_all_parent_feature($modulesref);
2197 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2199 my $onefeature = ${$modulesref}[$i];
2200 my $gid = $onefeature->{'gid'};
2202 # is this gid a parent?
2204 if ( grep {$_ eq $gid} @{$allparents} )
2206 $onefeature->{'has_children'} = 1;
2208 else
2210 $onefeature->{'has_children'} = 0;
2215 #################################################################################
2216 # All modules, that use a template module, do now get the assignments of
2217 # the template module.
2218 #################################################################################
2220 sub resolve_assigned_modules
2222 my ($modulesref) = @_;
2224 # collecting all template modules
2226 my %directaccess = ();
2228 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2230 my $onefeature = ${$modulesref}[$i];
2231 my $styles = "";
2232 if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
2233 if ( $styles =~ /\bTEMPLATEMODULE\b/ ) { $directaccess{$onefeature->{'gid'}} = $onefeature; }
2235 # also looking for module with flag ROOT_BRAND_PACKAGE, to save is for further usage
2236 if ( $styles =~ /\bROOT_BRAND_PACKAGE\b/ )
2238 $installer::globals::rootbrandpackage = $onefeature->{'gid'};
2239 $installer::globals::rootbrandpackageset = 1;
2243 # looking, where template modules are assigned
2245 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2247 my $onefeature = ${$modulesref}[$i];
2248 if ( $onefeature->{'Assigns'} )
2250 my $templategid = $onefeature->{'Assigns'};
2252 if ( ! exists($directaccess{$templategid}) )
2254 installer::exiter::exit_program("ERROR: Did not find definition of assigned template module \"$templategid\"", "resolve_assigned_modules");
2257 # Currently no merging of Files, Dirs, ...
2258 # This has to be included here, if it is required
2259 my @items_at_modules = ("Files", "Dirs", "Unixlinks");
2260 for my $item (@items_at_modules)
2262 if ( exists($directaccess{$templategid}->{$item}) ) { $onefeature->{$item} = $directaccess{$templategid}->{$item}; }
2268 #################################################################################
2269 # Removing the template modules from the list, after all
2270 # assignments are transferred to the "real" modules.
2271 #################################################################################
2273 sub remove_template_modules
2275 my ($modulesref) = @_;
2277 my @modules = ();
2279 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2281 my $onefeature = ${$modulesref}[$i];
2282 my $styles = "";
2283 if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
2284 if ( $styles =~ /\bTEMPLATEMODULE\b/ ) { next; }
2286 push(@modules, $onefeature);
2289 return \@modules;
2292 #################################################################################
2293 # Collecting all modules with flag LANGUAGEMODULE in a global
2294 # collector.
2295 #################################################################################
2297 sub collect_all_languagemodules
2299 my ($modulesref) = @_;
2301 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2303 my $onefeature = ${$modulesref}[$i];
2304 my $styles = "";
2305 if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
2306 if ( $styles =~ /\bLANGUAGEMODULE\b/ )
2308 if ( ! exists($onefeature->{'Language'}) ) { installer::exiter::exit_program("ERROR: \"$onefeature->{'gid'}\" has flag LANGUAGEMODULE, but does not know its language!", "collect_all_languagemodules"); }
2309 $installer::globals::alllangmodules{$onefeature->{'gid'}} = $onefeature->{'Language'};
2310 # Collecting also the english names, that are used for nsis unpack directory for language packs
2311 my $lang = $onefeature->{'Language'};
2312 my $name = "";
2313 foreach my $localkey ( keys %{$onefeature} )
2315 if ( $localkey =~ /^\s*Name\s*\(\s*en-US\s*\)\s*$/ )
2317 $installer::globals::all_english_languagestrings{$lang} = $onefeature->{$localkey};
2324 #################################################################################
2325 # Selecting from all collected english language strings those, that are really
2326 # required in this installation set.
2327 #################################################################################
2329 sub select_required_language_strings
2331 my ($modulesref) = @_;
2333 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2335 my $onefeature = ${$modulesref}[$i];
2336 my $styles = "";
2337 if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
2338 if ( $styles =~ /\bLANGUAGEMODULE\b/ )
2340 if ( ! exists($onefeature->{'Language'}) ) { installer::exiter::exit_program("ERROR: \"$onefeature->{'gid'}\" has flag LANGUAGEMODULE, but does not know its language!", "select_required_language_strings"); }
2341 my $lang = $onefeature->{'Language'};
2343 if (( exists($installer::globals::all_english_languagestrings{$lang}) ) && ( ! exists($installer::globals::all_required_english_languagestrings{$lang}) ))
2345 $installer::globals::all_required_english_languagestrings{$lang} = $installer::globals::all_english_languagestrings{$lang};
2351 ################################################
2352 # Controlling that all keys in hash A are
2353 # also key in hash B.
2354 ################################################
2356 sub _key_in_a_is_also_key_in_b
2358 my ( $hashref_a, $hashref_b) = @_;
2360 my $returnvalue = 1;
2362 my $key;
2363 foreach $key ( keys %{$hashref_a} )
2365 if ( ! exists($hashref_b->{$key}) )
2367 print "*****\n";
2368 foreach $keyb ( keys %{$hashref_b} ) { print "$keyb : $hashref_b->{$keyb}\n"; }
2369 print "*****\n";
2370 $returnvalue = 0;
2374 return $returnvalue;