Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / solenv / bin / modules / installer / scriptitems.pm
blob01f29f06719886543d5fa7898cfca15052e7e06d
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 $libo_version_major = "";
636 if ( $hashref->{'LIBO_VERSION_MAJOR'} ) { $libo_version_major = $hashref->{'LIBO_VERSION_MAJOR'}; }
637 my $productkey = $productname . " " . $productversion;
639 # string $buildid, which is used to replace the setup variable <buildid>
641 my $localbuild = $installer::globals::build;
643 if ( $localbuild =~ /^\s*(\w+?)(\d+)\s*$/ ) { $localbuild = $2; } # using "680" instead of "src680"
645 my $buildidstring = `cd $ENV{'SRCDIR'} 2>&1 >/dev/null && git log -n 1 --pretty=format:"%H"`;
646 if ($? || !$buildidstring) {
647 $buildidstring = $localbuild . "(Build:" . $installer::globals::buildid . ")";
650 my $updateid = $productname . "_" . $libo_version_major . "_" . $$languagestringref;
651 $updateid =~ s/ /_/g;
653 my $updatechannel = "";
654 if ( $ENV{'UPDATE_CONFIG'} && $ENV{'UPDATE_CONFIG'} ne "")
656 open(CONFIG, glob($ENV{'UPDATE_CONFIG'}));
657 while (<CONFIG>)
659 chomp;
660 if (/^s*(\S+)=(\S+)$/)
662 $key = $1;
663 $val = $2;
664 if ($key eq "channel")
666 $updatechannel = $val;
670 close(CONFIG);
673 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
675 my $oneitem = ${$itemsarrayref}[$i];
676 my $value = $oneitem->{'Value'};
678 $value =~ s/\<buildid\>/$buildidstring/;
679 $value =~ s/\<sequence_languages\>/$languagesstring/;
680 $value =~ s/\<productkey\>/$productkey/;
681 $value =~ s/\<productcode\>/$installer::globals::productcode/;
682 $value =~ s/\<upgradecode\>/$installer::globals::upgradecode/;
683 $value =~ s/\<alllanguages\>/$languagesstring/;
684 $value =~ s/\<sourceid\>/$installer::globals::build/;
685 $value =~ s/\<updateid\>/$updateid/;
686 $value =~ s/\<updatechannel\>/$updatechannel/;
687 $value =~ s/\<pkgformat\>/$installer::globals::packageformat/;
688 $ENV{'OOO_VENDOR'} = "" if !defined $ENV{'OOO_VENDOR'};
689 $value =~ s/\<vendor\>/$ENV{'OOO_VENDOR'}/;
690 $ENV{'BUILD_VER_STRING'} = "" if !defined $ENV{'BUILD_VER_STRING'};
691 $value =~ s/\<buildversion\>/$ENV{'BUILD_VER_STRING'}/;
693 $oneitem->{'Value'} = $value;
697 ################################################################################
698 # By defining variable LOCALUSERDIR in *.lst it is possible to change
699 # the standard destination of user directory defined in scp2 ($SYSUSERCONFIG).
700 ################################################################################
702 sub replace_userdir_variable
704 my ($itemsarrayref) = @_;
706 my $userdir = "";
707 if ( $allvariableshashref->{'LOCALUSERDIR'} ) { $userdir = $allvariableshashref->{'LOCALUSERDIR'}; }
708 else { $userdir = $installer::globals::simpledefaultuserdir; }
710 if ( $userdir ne "" )
712 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
714 my $oneitem = ${$itemsarrayref}[$i];
715 $oneitem->{'Value'} =~ s/\$SYSUSERCONFIG/$userdir/;
720 #####################################################################################
721 # Files and ConfigurationItems are not included for all languages.
722 # For instance asian fonts. These can be removed, if no "Name" is found.
723 # ConfigurationItems are not always defined in the linguistic configuration file.
724 # The "Key" cannot be found for them.
725 #####################################################################################
727 sub remove_non_existent_languages_in_productlists
729 my ($itemsarrayref, $languagestringref, $searchkey, $itemtype) = @_;
731 # Removing of all non existent files, for instance asian fonts
733 installer::logger::include_header_into_logfile("Removing for this language $$languagestringref:");
735 my @allexistentitems = ();
737 my $infoline;
739 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
741 my $oneitem = ${$itemsarrayref}[$i];
742 my $oneitemname = ""; # $searchkey is "Name" for files and "Key" for ConfigurationItems
744 if ( $oneitem->{$searchkey} ) { $oneitemname = $oneitem->{$searchkey} }
746 my $itemtoberemoved = 0;
748 if ($oneitemname eq "") # for instance asian font in english installation set
750 $itemtoberemoved = 1;
753 if ($itemtoberemoved)
755 $infoline = "WARNING: Language $$languagestringref: No $itemtype packed for $oneitem->{'gid'}!\n";
756 push( @installer::globals::logfileinfo, $infoline);
758 else
760 push(@allexistentitems, $oneitem);
764 $infoline = "\n";
765 push( @installer::globals::logfileinfo, $infoline);
767 return \@allexistentitems;
770 ########################################################################
771 # Input is the directory gid, output the "HostName" of the directory
772 ########################################################################
774 sub get_Directoryname_From_Directorygid
776 my ($dirsarrayref ,$searchgid, $onelanguage, $oneitemgid) = @_;
778 my $directoryname = "";
779 my $onedirectory;
780 my $foundgid = 0;
782 for ( my $i = 0; $i <= $#{$dirsarrayref}; $i++ )
784 $onedirectory = ${$dirsarrayref}[$i];
785 my $directorygid = $onedirectory->{'gid'};
787 if ($directorygid eq $searchgid)
789 $foundgid = 1;
790 last;
794 if (!($foundgid))
796 installer::exiter::exit_program("ERROR: Gid $searchgid not defined in $installer::globals::setupscriptname", "get_Directoryname_From_Directorygid");
799 if ( ! ( $onedirectory->{'ismultilingual'} )) # the directory is not language dependent
801 $directoryname = $onedirectory->{'HostName'};
803 else
805 $directoryname = $onedirectory->{"HostName ($onelanguage)"};
808 # gid_Dir_Template_Wizard_Letter is defined as language dependent directory, but the file gid_Dir_Template_Wizard_Letter
809 # is not language dependent. Therefore $onelanguage is not defined. But which language is the correct language for the
810 # directory?
811 # Perhaps better solution: In scp it must be forbidden to have a language independent file in a language dependent directory.
813 if (( ! $directoryname ) && ( $onelanguage eq "" ))
815 installer::exiter::exit_program("ERROR (in scp): Directory $searchgid is language dependent, but not $oneitemgid inside this directory", "get_Directoryname_From_Directorygid");
818 return \$directoryname;
821 ##################################################################
822 # Getting destination direcotory for links, files and profiles
823 ##################################################################
825 sub get_Destination_Directory_For_Item_From_Directorylist # this is used for Files, Profiles and Links
827 my ($itemarrayref, $dirsarrayref) = @_;
829 for ( my $i = 0; $i <= $#{$itemarrayref}; $i++ )
831 my $oneitem = ${$itemarrayref}[$i];
832 my $oneitemgid = $oneitem->{'gid'};
833 my $directorygid = $oneitem->{'Dir'}; # for instance gid_Dir_Program
834 my $netdirectorygid = "";
835 my $onelanguage = $oneitem->{'specificlanguage'};
836 my $ispredefinedprogdir = 0;
837 my $ispredefinedconfigdir = 0;
839 my $oneitemname = $oneitem->{'Name'};
841 if ( $oneitem->{'NetDir'} ) { $netdirectorygid = $oneitem->{'NetDir'}; }
843 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$oneitemname); # making /registry/schema/org/openoffice/VCL.xcs to VCL.xcs
845 my $searchdirgid;
847 if ( $netdirectorygid eq "" ) # if NetDir is defined, it is privileged
849 $searchdirgid = $directorygid
851 else
853 $searchdirgid = $netdirectorygid
856 if ($searchdirgid =~ /PREDEFINED_PROGDIR/) # the root directory is not defined in setup script
858 $ispredefinedprogdir = 1;
861 if ($searchdirgid =~ /PREDEFINED_CONFIGDIR/) # the root directory is not defined in setup script
863 $ispredefinedconfigdir = 1;
866 my $destfilename;
868 if ($oneitem->{'DoNotMessWithSymlinks'})
870 $destfilename = $oneitem->{'Name'};
872 elsif ((!( $ispredefinedprogdir )) && (!( $ispredefinedconfigdir )))
874 my $directorynameref = get_Directoryname_From_Directorygid($dirsarrayref, $searchdirgid, $onelanguage, $oneitemgid);
875 my $styles = "";
876 if ($oneitem->{'Styles'}) { $styles = $oneitem->{'Styles'}; }
877 if ($styles =~ /\bFILELIST\b/)
879 $destfilename = $$directorynameref . $installer::globals::separator . $oneitemname;
881 else
883 $destfilename = $$directorynameref . $installer::globals::separator . $oneitem->{'Name'};
886 else
888 $destfilename = $oneitemname;
891 $oneitem->{'destination'} = $destfilename;
895 ##########################################################################
896 # Searching a file in a list of paths
897 ##########################################################################
899 sub get_sourcepath_from_filename_and_includepath_classic
901 my ($searchfilenameref, $includepatharrayref, $write_logfile) = @_;
903 my ($onefile, $includepath, $infoline);
905 my $foundsourcefile = 0;
907 for ( my $j = 0; $j <= $#{$includepatharrayref}; $j++ )
909 $includepath = ${$includepatharrayref}[$j];
910 installer::remover::remove_leading_and_ending_whitespaces(\$includepath);
912 $onefile = $includepath . $installer::globals::separator . $$searchfilenameref;
914 if ( -f $onefile )
916 $foundsourcefile = 1;
917 last;
921 if (!($foundsourcefile))
923 $onefile = ""; # the sourcepath has to be empty
924 if ( $write_logfile)
926 $infoline = "ERROR: Source for $$searchfilenameref not found (classic)!\n"; # Important message in log file
927 push( @installer::globals::logfileinfo, $infoline);
930 else
932 if ( $write_logfile)
934 $infoline = "SUCCESS: Source for $$searchfilenameref: $onefile\n";
935 push( @installer::globals::logfileinfo, $infoline);
939 return \$onefile;
942 ##########################################################################
943 # Input is one file name, output the complete absolute path of this file
944 ##########################################################################
946 sub get_sourcepath_from_filename_and_includepath
948 my ($searchfilenameref, $unused, $write_logfile) = @_;
950 my ($onefile, $includepath, $infoline);
952 my $foundsourcefile = 0;
953 my $foundnewname = 0;
955 for ( my $j = 0; $j <= $#installer::globals::allincludepaths; $j++ )
957 my $allfiles = $installer::globals::allincludepaths[$j];
959 if ( exists( $allfiles->{$$searchfilenameref} ))
961 $onefile = $allfiles->{'includepath'} . $installer::globals::separator . $$searchfilenameref;
962 $foundsourcefile = 1;
963 last;
967 if (!($foundsourcefile)) # testing with lowercase filename
969 # Attention: README01.html is copied for Windows to readme01.html, not case sensitive
971 for ( my $j = 0; $j <= $#installer::globals::allincludepaths; $j++ )
973 my $allfiles = $installer::globals::allincludepaths[$j];
975 my $newfilename = $$searchfilenameref;
976 $newfilename =~ s/readme/README/; # special handling for readme files
977 $newfilename =~ s/license/LICENSE/; # special handling for license files
979 if ( exists( $allfiles->{$newfilename} ))
981 $onefile = $allfiles->{'includepath'} . $installer::globals::separator . $newfilename;
982 $foundsourcefile = 1;
983 $foundnewname = 1;
984 last;
989 if (!($foundsourcefile))
991 $onefile = ""; # the sourcepath has to be empty
992 if ( $write_logfile)
994 $infoline = "ERROR: Source for $$searchfilenameref not found!\n"; # Important message in log file
995 push( @installer::globals::logfileinfo, $infoline);
998 else
1000 if ( $write_logfile)
1002 if (!($foundnewname))
1004 $infoline = "SUCCESS: Source for $$searchfilenameref: $onefile\n";
1006 else
1008 $infoline = "SUCCESS/WARNING: Special handling for $$searchfilenameref: $onefile\n";
1010 push( @installer::globals::logfileinfo, $infoline);
1014 return \$onefile;
1017 ##############################################################
1018 # Getting all source paths for all files to be packed
1019 # $item can be "Files" or "ScpActions"
1020 ##############################################################
1022 sub get_Source_Directory_For_Files_From_Includepathlist
1024 my ($filesarrayref, $includepatharrayref, $dirsref, $item, $allvariables) = @_;
1026 installer::logger::include_header_into_logfile("$item:");
1028 my ($foundit, $dontcare, $extrarootdir) =
1029 get_office_directory_gid_and_hostname($dirsref);
1030 my $infoline = "";
1032 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1034 my $onefile = ${$filesarrayref}[$i];
1035 my $onelanguage = $onefile->{'specificlanguage'};
1037 if ( ! $onefile->{'Name'} ) { installer::exiter::exit_program("ERROR: $item without name ! GID: $onefile->{'gid'} ! Language: $onelanguage", "get_Source_Directory_For_Files_From_Includepathlist"); }
1039 my $onefilename = $onefile->{'Name'};
1040 if ( $item eq "ScpActions" ) { $onefilename =~ s/\//$installer::globals::separator/g; }
1041 $onefilename =~ s/^\s*\Q$installer::globals::separator\E//; # filename begins with a slash, for instance /registry/schema/org/openoffice/VCL.xcs
1043 my $styles = "";
1044 my $file_can_miss = 0;
1045 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1047 if (( $installer::globals::languagepack ) && ( ! $onefile->{'ismultilingual'} ) && ( ! ( $styles =~ /\bFORCELANGUAGEPACK\b/ ))) { $file_can_miss = 1; }
1048 if (( $installer::globals::helppack ) && ( ! $onefile->{'ismultilingual'} ) && ( ! ( $styles =~ /\bFORCEHELPPACK\b/ ))) { $file_can_miss = 1; }
1050 my $sourcepathref = "";
1052 my $destination = $onefile->{'destination'};
1053 my $instdirdestination;
1054 if ($destination)
1056 if (($installer::globals::iswindowsbuild) && $foundit && $extrarootdir)
1058 $destination =~ s,$extrarootdir/,,; # remove it from path
1060 if (($installer::globals::languagepack) && ($installer::globals::ismacbuild))
1061 { # source files are in $(PRODUCTNAME).app where they will
1062 # actually copied by the user executing the Language Pack.app
1063 $destination =~ s, Language Pack.app/,.app/,;
1065 $instdirdestination = $ENV{'INSTDIR'} . $installer::globals::separator . $destination;
1067 if ($instdirdestination && -f $instdirdestination)
1069 $infoline = "SUCCESS: INSTDIR Source for $onefilename: $instdirdestination\n";
1070 push( @installer::globals::logfileinfo, $infoline);
1071 $$sourcepathref = $instdirdestination;
1073 else
1075 if ( $file_can_miss ) { $sourcepathref = get_sourcepath_from_filename_and_includepath(\$onefilename, $includepatharrayref, 0); }
1076 else { $sourcepathref = get_sourcepath_from_filename_and_includepath(\$onefilename, $includepatharrayref, 1); }
1079 $onefile->{'sourcepath'} = $$sourcepathref; # This $$sourcepathref is empty, if no source was found
1082 $infoline = "\n"; # empty line after listing of all files
1083 push( @installer::globals::logfileinfo, $infoline);
1086 #################################################################################
1087 # Removing files, that shall not be included into languagepacks
1088 # (because of rpm conflicts)
1089 #################################################################################
1091 sub remove_Files_For_Languagepacks
1093 my ($itemsarrayref) = @_;
1095 my $infoline;
1097 my @newitemsarray = ();
1099 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1101 my $oneitem = ${$itemsarrayref}[$i];
1102 my $gid = $oneitem->{'gid'};
1104 # scp Todo: Remove asap after removal of old setup
1106 if (( $gid eq "gid_File_Extra_Fontunxpsprint" ) ||
1107 ( $gid eq "gid_File_Extra_Migration_Lang" ))
1109 $infoline = "ATTENTION: Removing item $oneitem->{'gid'} from the installation set.\n";
1110 push( @installer::globals::logfileinfo, $infoline);
1112 next;
1115 push(@newitemsarray, $oneitem);
1118 return \@newitemsarray;
1121 #################################################################################
1122 # Files, whose source directory is not found, are removed now (this is an ERROR)
1123 #################################################################################
1125 sub remove_Files_Without_Sourcedirectory
1127 my ($filesarrayref) = @_;
1129 my $infoline;
1131 my $error_occurred = 0;
1132 my @missingfiles = ();
1133 push(@missingfiles, "ERROR: The following files could not be found: \n");
1135 my @newfilesarray = ();
1137 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1139 my $onefile = ${$filesarrayref}[$i];
1140 my $sourcepath = $onefile->{'sourcepath'};
1142 if ($sourcepath eq "")
1144 my $styles = $onefile->{'Styles'};
1145 my $filename = $onefile->{'Name'};
1147 if ( ! $installer::globals::languagepack && !$installer::globals::helppack)
1149 $infoline = "ERROR: Removing file $filename from file list.\n";
1150 push( @installer::globals::logfileinfo, $infoline);
1152 push(@missingfiles, "ERROR: File not found: $filename\n");
1153 $error_occurred = 1;
1155 next; # removing this file from list, if sourcepath is empty
1157 elsif ( $installer::globals::languagepack ) # special case for language packs
1159 if (( $onefile->{'ismultilingual'} ) || ( $styles =~ /\bFORCELANGUAGEPACK\b/ ))
1161 $infoline = "ERROR: Removing file $filename from file list.\n";
1162 push( @installer::globals::logfileinfo, $infoline);
1164 push(@missingfiles, "ERROR: File not found: $filename\n");
1165 $error_occurred = 1;
1167 next; # removing this file from list, if sourcepath is empty
1169 else
1171 $infoline = "INFO: Removing file $filename from file list. It is not language dependent.\n";
1172 push( @installer::globals::logfileinfo, $infoline);
1173 $infoline = "INFO: It is not language dependent and can be ignored in language packs.\n";
1174 push( @installer::globals::logfileinfo, $infoline);
1176 next; # removing this file from list, if sourcepath is empty
1179 else # special case for help packs
1181 if (( $onefile->{'ismultilingual'} ) || ( $styles =~ /\bFORCEHELPPACK\b/ ))
1183 $infoline = "ERROR: Removing file $filename from file list.\n";
1184 push( @installer::globals::logfileinfo, $infoline);
1186 push(@missingfiles, "ERROR: File not found: $filename\n");
1187 $error_occurred = 1;
1189 next; # removing this file from list, if sourcepath is empty
1191 else
1193 $infoline = "INFO: Removing file $filename from file list. It is not language dependent.\n";
1194 push( @installer::globals::logfileinfo, $infoline);
1195 $infoline = "INFO: It is not language dependent and can be ignored in help packs.\n";
1196 push( @installer::globals::logfileinfo, $infoline);
1198 next; # removing this file from list, if sourcepath is empty
1203 push(@newfilesarray, $onefile);
1206 $infoline = "\n";
1207 push( @installer::globals::logfileinfo, $infoline);
1209 if ( $error_occurred )
1211 for ( my $i = 0; $i <= $#missingfiles; $i++ ) { print "$missingfiles[$i]"; }
1212 installer::exiter::exit_program("ERROR: Missing files", "remove_Files_Without_Sourcedirectory");
1215 return \@newfilesarray;
1218 ############################################################################
1219 # License and Readme files in the default language have to be installed
1220 # in the directory with flag OFFICEDIRECTORY. If this is not defined
1221 # they have to be installed in the installation root.
1222 ############################################################################
1224 sub get_office_directory_gid_and_hostname
1226 my ($dirsarrayref) = @_;
1228 my $foundofficedir = 0;
1229 my $gid = "";
1230 my $hostname = "";
1232 for ( my $i = 0; $i <= $#{$dirsarrayref}; $i++ )
1234 my $onedir = ${$dirsarrayref}[$i];
1235 if ( $onedir->{'Styles'} )
1237 my $styles = $onedir->{'Styles'};
1239 if ( $styles =~ /\bOFFICEDIRECTORY\b/ )
1241 $foundofficedir = 1;
1242 $gid = $onedir->{'gid'};
1243 $hostname = $onedir->{'HostName'};
1244 last;
1249 return ($foundofficedir, $gid, $hostname);
1252 ############################################################################
1253 # License and Readme files in the default language have to be installed
1254 # in the installation root (next to the program dir). This is in scp
1255 # project done by a post install basic script
1256 ############################################################################
1258 sub add_License_Files_into_Installdir
1260 my ($filesarrayref, $dirsarrayref, $languagesarrayref) = @_;
1262 my $infoline;
1264 my @newfilesarray = ();
1266 my $defaultlanguage = installer::languages::get_default_language($languagesarrayref);
1268 my ($foundofficedir, $officedirectorygid, $officedirectoryhostname) = get_office_directory_gid_and_hostname($dirsarrayref);
1270 # copy all files from directory share/readme, that contain the default language in their name
1271 # without default language into the installation root. This makes the settings of the correct
1272 # file names superfluous. On the other hand this requires a dependency to the directory
1273 # share/readme
1275 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1277 my $onefile = ${$filesarrayref}[$i];
1278 my $destination = $onefile->{'destination'};
1279 my $styles = "";
1280 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1282 if ( ( $destination =~ /share\Q$installer::globals::separator\Ereadme\Q$installer::globals::separator\E(\w+?)_?$defaultlanguage\.?(\w*)\s*/ )
1283 || (( $styles =~ /\bROOTLICENSEFILE\b/ ) && ( $destination =~ /\Q$installer::globals::separator\E?(\w+?)_?$defaultlanguage\.?(\w*?)\s*$/ )) )
1285 my $filename = $1;
1286 my $extension = $2;
1288 my $newfilename;
1290 if ( $extension eq "" ) { $newfilename = $filename; }
1291 else { $newfilename = $filename . "\." . $extension; }
1293 my %newfile = ();
1294 my $newfile = \%newfile;
1296 installer::converter::copy_item_object($onefile, $newfile);
1298 $newfile->{'gid'} = $onefile->{'gid'} . "_Copy";
1299 $newfile->{'Name'} = $newfilename;
1300 $newfile->{'ismultilingual'} = "0";
1301 $newfile->{'specificlanguage'} = "";
1302 $newfile->{'haslanguagemodule'} = "0";
1304 if ( defined $newfile->{'InstallName'} )
1306 if ( $newfile->{'InstallName'} =~ /^\s*(.*?)_$defaultlanguage\.?(\w*?)\s*$/ )
1308 my $localfilename = $1;
1309 my $localextension = $2;
1311 if ( $localextension eq "" ) { $newfile->{'InstallName'} = $localfilename; }
1312 else { $newfile->{'InstallName'} = $localfilename . "\." . $localextension; }
1316 $newfile->{'removelangfromfile'} = "1"; # Important for files with an InstallName, because language also has to be removed there.
1318 if ( $foundofficedir )
1320 $newfile->{'Dir'} = $officedirectorygid;
1321 $newfile->{'destination'} = $officedirectoryhostname . $installer::globals::separator . $newfilename;
1323 else
1325 $newfile->{'Dir'} = "PREDEFINED_PROGDIR";
1326 $newfile->{'destination'} = $newfilename;
1329 # Also setting "modules=gid_Module_Root_Brand" (module with style: ROOT_BRAND_PACKAGE)
1330 if ( $installer::globals::rootbrandpackageset )
1332 $newfile->{'modules'} = $installer::globals::rootbrandpackage;
1335 push(@newfilesarray, $newfile);
1337 $infoline = "New files: Adding file $newfilename for the installation root to the file list. Language: $defaultlanguage\n";
1338 push( @installer::globals::logfileinfo, $infoline);
1340 if ( defined $newfile->{'InstallName'} )
1342 $infoline = "New files: Using installation name: $newfile->{'InstallName'}\n";
1343 push( @installer::globals::logfileinfo, $infoline);
1347 push(@newfilesarray, $onefile);
1350 return \@newfilesarray;
1353 ############################################################################
1354 # Some files are included for more than one language and have the same
1355 # name and the same destination directory for all languages. This would
1356 # lead to conflicts, if the filenames are not changed.
1357 # In scp project this files must have the flag MAKE_LANG_SPECIFIC
1358 # For this files, the language is included into the filename.
1359 ############################################################################
1361 sub make_filename_language_specific
1363 my ($filesarrayref) = @_;
1365 my $infoline = "";
1367 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1369 my $onefile = ${$filesarrayref}[$i];
1371 if ( $onefile->{'ismultilingual'} )
1373 my $styles = "";
1374 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1375 if ( $styles =~ /\bMAKE_LANG_SPECIFIC\b/ )
1377 my $language = $onefile->{'specificlanguage'};
1378 my $olddestination = $onefile->{'destination'};
1379 my $oldname = $onefile->{'Name'};
1381 # Including the language into the file name.
1382 # But be sure, to include the language before the file extension.
1384 my $fileextension = "";
1386 if ( $onefile->{'Name'} =~ /(\.\w+?)\s*$/ ) { $fileextension = $1; }
1387 if ( $fileextension ne "" )
1389 $onefile->{'Name'} =~ s/\Q$fileextension\E\s*$/_$language$fileextension/;
1390 $onefile->{'destination'} =~ s/\Q$fileextension\E\s*$/_$language$fileextension/;
1393 $infoline = "Flag MAKE_LANG_SPECIFIC:\n";
1394 push( @installer::globals::logfileinfo, $infoline);
1395 $infoline = "Changing name from $oldname to $onefile->{'Name'} !\n";
1396 push( @installer::globals::logfileinfo, $infoline);
1397 $infoline = "Changing destination from $olddestination to $onefile->{'destination'} !\n";
1398 push( @installer::globals::logfileinfo, $infoline);
1404 ############################################################################
1405 # Because of the item "File" the source name must be "Name". Therefore
1406 # "Copy" is changed to "Name" and "Name" is changed to "DestinationName".
1407 ############################################################################
1409 sub change_keys_of_scpactions
1411 my ($itemsarrayref) = @_;
1413 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1415 my $oneitem = ${$itemsarrayref}[$i];
1417 my $key;
1419 # First Name to DestinationName, then deleting Name
1420 foreach $key (keys %{$oneitem})
1422 if ( $key =~ /\bName\b/ )
1424 my $value = $oneitem->{$key};
1425 my $oldkey = $key;
1426 $key =~ s/Name/DestinationName/;
1427 $oneitem->{$key} = $value;
1428 delete($oneitem->{$oldkey});
1432 # Second Copy to Name, then deleting Copy
1433 foreach $key (keys %{$oneitem})
1435 if ( $key =~ /\bCopy\b/ )
1437 my $value = $oneitem->{$key};
1438 my $oldkey = $key;
1439 $key =~ s/Copy/Name/;
1440 $oneitem->{$key} = $value;
1441 delete($oneitem->{$oldkey});
1447 ############################################################################
1448 # Removing all language pack files from installation set (files with
1449 # the style LANGUAGEPACK), except this is a language pack.
1450 ############################################################################
1452 sub remove_Languagepacklibraries_from_Installset
1454 my ($itemsarrayref) = @_;
1456 my $infoline;
1458 my @newitemsarray = ();
1460 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1462 my $oneitem = ${$itemsarrayref}[$i];
1463 my $styles = "";
1464 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
1466 if ( $styles =~ /\bLANGUAGEPACK\b/ )
1468 $infoline = "Removing language pack file $oneitem->{'gid'} from the installation set.\n";
1469 push( @installer::globals::globallogfileinfo, $infoline);
1471 next;
1474 push(@newitemsarray, $oneitem);
1477 $infoline = "\n";
1478 push( @installer::globals::globallogfileinfo, $infoline);
1480 return \@newitemsarray;
1483 ############################################################################
1484 # Removing all help pack files from installation set (files with
1485 # the style HELPPACK), except this is a help pack.
1486 ############################################################################
1488 sub remove_Helppacklibraries_from_Installset
1490 my ($itemsarrayref) = @_;
1492 my $infoline;
1494 my @newitemsarray = ();
1496 for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1498 my $oneitem = ${$itemsarrayref}[$i];
1499 my $styles = "";
1500 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
1502 if ( $styles =~ /\bHELPPACK\b/ )
1504 $infoline = "Removing help pack file $oneitem->{'gid'} from the installation set.\n";
1505 push( @installer::globals::globallogfileinfo, $infoline);
1507 next;
1510 push(@newitemsarray, $oneitem);
1513 $infoline = "\n";
1514 push( @installer::globals::globallogfileinfo, $infoline);
1516 return \@newitemsarray;
1519 ############################################################################
1520 # Some files contain a $ in their name. epm conflicts with such files.
1521 # Solution: Renaming this files, converting "$" to "$$"
1522 ############################################################################
1524 sub quoting_illegal_filenames
1526 my ($filesarrayref) = @_;
1528 # This function has to be removed as soon as possible!
1530 installer::logger::include_header_into_logfile("Renaming illegal filenames:");
1532 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1534 my $onefile = ${$filesarrayref}[$i];
1535 my $filename = $onefile->{'Name'};
1537 if ( $filename =~ /\$/ )
1539 my $sourcepath = $onefile->{'sourcepath'};
1540 my $destpath = $onefile->{'destination'};
1542 # sourcepath and destination have to be quoted for epm list file
1544 $destpath =~ s/\$/\$\$/g;
1545 $sourcepath =~ s/\$/\$\$/g;
1547 my $infoline = "ATTENTION: Files: Quoting sourcepath $onefile->{'sourcepath'} to $sourcepath\n";
1548 push( @installer::globals::logfileinfo, $infoline);
1549 $infoline = "ATTENTION: Files: Quoting destination path $onefile->{'destination'} to $destpath\n";
1550 push( @installer::globals::logfileinfo, $infoline);
1552 $onefile->{'sourcepath'} = $sourcepath;
1553 $onefile->{'destination'} = $destpath;
1558 ############################################################################
1559 # Removing multiple occurrences of same module.
1560 ############################################################################
1562 sub optimize_list
1564 my ( $longlist ) = @_;
1565 my %tmpHash;
1567 $longlist =~ s/^\s+//;
1568 $longlist =~ s/\s+$//;
1569 $longlist =~ s/\s*,\s*/,/g;
1571 @tmpHash{split /,/, $longlist} = ();
1572 return join(",", sort keys %tmpHash);
1575 #######################################################################
1576 # Collecting all directories needed for the epm list
1577 # 1. Looking for all destination paths in the files array
1578 # 2. Looking for directories with CREATE flag in the directory array
1579 #######################################################################
1581 ##################################
1582 # Collecting directories: Part 1
1583 ##################################
1585 sub collect_directories_from_filesarray
1587 my ($filesarrayref, $unixlinksarrayref) = @_;
1588 my @allfiles;
1589 push @allfiles, @{$filesarrayref};
1590 push @allfiles, @{$unixlinksarrayref};
1592 my @alldirectories = ();
1593 my %alldirectoryhash = ();
1595 my $predefinedprogdir_added = 0;
1597 # Preparing this already as hash, although the only needed value at the moment is the HostName
1598 # But also adding: "specificlanguage" and "Dir" (for instance gid_Dir_Program)
1600 for ( my $i = 0; $i <= $#allfiles; $i++ )
1602 my $onefile = $allfiles[$i];
1603 my $destinationpath = $onefile->{'destination'};
1604 installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationpath);
1605 $destinationpath =~ s/\Q$installer::globals::separator\E\s*$//; # removing ending slashes or backslashes
1609 if (!exists($alldirectoryhash{$destinationpath}))
1611 my %directoryhash = ();
1612 $directoryhash{'HostName'} = $destinationpath;
1613 $directoryhash{'specificlanguage'} = $onefile->{'specificlanguage'};
1614 $directoryhash{'Dir'} = $onefile->{'Dir'};
1615 $directoryhash{'modules'} = $onefile->{'modules'}; # NEW, saving modules
1616 $directoryhash{'gid'} = $onefile->{'gid'};
1618 $predefinedprogdir_added ||= $onefile->{'Dir'} eq "PREDEFINED_PROGDIR";
1620 $alldirectoryhash{$destinationpath} = \%directoryhash;
1622 else
1624 # Adding the modules to the module list!
1625 $alldirectoryhash{$destinationpath}->{'modules'} .= "," . $onefile->{'modules'};
1626 # Save file's gid iff this directory appears in only a single
1627 # file's FILELIST (so that unused directories will be filtered
1628 # out in remove_not_required_spellcheckerlanguage_files, based
1629 # on gid):
1630 if ($alldirectoryhash{$destinationpath}->{'gid'}
1631 ne $onefile->{'gid'})
1633 $alldirectoryhash{$destinationpath}->{'gid'} = '';
1636 } while ($destinationpath =~ s/(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/$1/); # as long as the path contains slashes
1639 # if there is no file in the root directory PREDEFINED_PROGDIR, it has to be included into the directory array now
1640 # HostName= specificlanguage= Dir=PREDEFINED_PROGDIR
1642 if (! $predefinedprogdir_added )
1644 my %directoryhash = ();
1645 $directoryhash{'HostName'} = "";
1646 $directoryhash{'specificlanguage'} = "";
1647 $directoryhash{'modules'} = ""; # ToDo?
1648 $directoryhash{'Dir'} = "PREDEFINED_PROGDIR";
1650 push(@alldirectories, \%directoryhash);
1653 # Creating directory array
1654 foreach my $destdir ( sort keys %alldirectoryhash )
1656 $alldirectoryhash{$destdir}->{'modules'} = optimize_list($alldirectoryhash{$destdir}->{'modules'});
1657 push(@alldirectories, $alldirectoryhash{$destdir});
1660 return (\@alldirectories, \%alldirectoryhash);
1663 ##################################
1664 # Collecting directories: Part 2
1665 ##################################
1667 sub collect_directories_with_create_flag_from_directoryarray
1669 my ($directoryarrayref, $alldirectoryhash) = @_;
1671 my $alreadyincluded = 0;
1672 my @alldirectories = ();
1674 for ( my $i = 0; $i <= $#{$directoryarrayref}; $i++ )
1676 my $onedir = ${$directoryarrayref}[$i];
1677 my $styles = "";
1678 $newdirincluded = 0;
1680 if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
1682 if ( $styles =~ /\bCREATE\b/ )
1684 my $directoryname = "";
1686 if ( $onedir->{'HostName'} ) { $directoryname = $onedir->{'HostName'}; }
1687 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"); }
1689 $alreadyincluded = 0;
1690 if ( exists($alldirectoryhash->{$directoryname}) ) { $alreadyincluded = 1; }
1692 if (!($alreadyincluded))
1694 my %directoryhash = ();
1695 $directoryhash{'HostName'} = $directoryname;
1696 $directoryhash{'specificlanguage'} = $onedir->{'specificlanguage'};
1697 $directoryhash{'Dir'} = $onedir->{'gid'};
1698 $directoryhash{'Styles'} = $onedir->{'Styles'};
1700 # saving also the modules
1701 if ( ! $onedir->{'modules'} ) { installer::exiter::exit_program("ERROR: No assigned modules found for directory $onedir->{'gid'}", "collect_directories_with_create_flag_from_directoryarray"); }
1702 $directoryhash{'modules'} = $onedir->{'modules'};
1704 $alldirectoryhash->{$directoryname} = \%directoryhash;
1705 $newdirincluded = 1;
1707 # Problem: The $destinationpath can be share/registry/schema/org/openoffice
1708 # but not all directories contain files and will be added to this list.
1709 # Therefore the path has to be analyzed.
1711 while ( $directoryname =~ /(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/ ) # as long as the path contains slashes
1713 $directoryname = $1;
1715 $alreadyincluded = 0;
1716 if ( exists($alldirectoryhash->{$directoryname}) ) { $alreadyincluded = 1; }
1718 if (!($alreadyincluded))
1720 my %directoryhash = ();
1722 $directoryhash{'HostName'} = $directoryname;
1723 $directoryhash{'specificlanguage'} = $onedir->{'specificlanguage'};
1724 $directoryhash{'Dir'} = $onedir->{'gid'};
1725 if ( ! $installer::globals::iswindowsbuild ) { $directoryhash{'Styles'} = "(CREATE)"; } # Exception for Windows?
1727 # saving also the modules
1728 $directoryhash{'modules'} = $onedir->{'modules'};
1730 $alldirectoryhash->{$directoryname} = \%directoryhash;
1731 $newdirincluded = 1;
1733 else
1735 # Adding the modules to the module list!
1736 $alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $onedir->{'modules'};
1740 else
1742 # Adding the modules to the module list!
1743 $alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $onedir->{'modules'};
1745 while ( $directoryname =~ /(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/ ) # as long as the path contains slashes
1747 $directoryname = $1;
1748 # Adding the modules to the module list!
1749 $alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $onedir->{'modules'};
1754 # Saving the styles for already added directories in function collect_directories_from_filesarray
1756 if (( ! $newdirincluded ) && ( $styles ne "" ))
1758 $styles =~ s/\bWORKSTATION\b//;
1759 $styles =~ s/\bCREATE\b//;
1761 if (( ! ( $styles =~ /^\s*\(\s*\)\s*$/ )) && ( ! ( $styles =~ /^\s*\(\s*\,\s*\)\s*$/ )) && ( ! ( $styles =~ /^\s*$/ ))) # checking, if there are styles left
1763 my $directoryname = "";
1764 if ( $onedir->{'HostName'} ) { $directoryname = $onedir->{'HostName'}; }
1765 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"); }
1767 if ( exists($alldirectoryhash->{$directoryname}) )
1769 $alldirectoryhash->{$directoryname}->{'Styles'} = $styles;
1775 # Creating directory array
1776 foreach my $destdir ( sort keys %{$alldirectoryhash} )
1778 $alldirectoryhash->{$destdir}->{'modules'} = optimize_list($alldirectoryhash->{$destdir}->{'modules'});
1779 push(@alldirectories, $alldirectoryhash->{$destdir});
1782 return (\@alldirectories, \%alldirectoryhash);
1785 #################################################
1786 # Determining the destination file of a link
1787 #################################################
1789 sub get_destination_file_path_for_links
1791 my ($linksarrayref, $filesarrayref) = @_;
1793 my $infoline;
1795 for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ )
1797 my $fileid = "";
1798 my $onelink = ${$linksarrayref}[$i];
1799 if ( $onelink->{'FileID'} ) { $fileid = $onelink->{'FileID'}; }
1801 if (!( $fileid eq "" ))
1803 my $foundfile = 0;
1805 for ( my $j = 0; $j <= $#{$filesarrayref}; $j++ )
1807 my $onefile = ${$filesarrayref}[$j];
1808 my $filegid = $onefile->{'gid'};
1810 if ( $filegid eq $fileid )
1812 $foundfile = 1;
1813 $onelink->{'destinationfile'} = $onefile->{'destination'};
1814 last;
1818 if (!($foundfile))
1820 $infoline = "Warning: FileID $fileid for Link $onelink->{'gid'} not found!\n";
1821 push( @installer::globals::logfileinfo, $infoline);
1826 $infoline = "\n";
1827 push( @installer::globals::logfileinfo, $infoline);
1830 #################################################
1831 # Determining the destination link of a link
1832 #################################################
1834 sub get_destination_link_path_for_links
1836 my ($linksarrayref) = @_;
1838 my $infoline;
1840 for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ )
1842 my $shortcutid = "";
1843 my $onelink = ${$linksarrayref}[$i];
1844 if ( $onelink->{'ShortcutID'} ) { $shortcutid = $onelink->{'ShortcutID'}; }
1846 if (!( $shortcutid eq "" ))
1848 my $foundlink = 0;
1850 for ( my $j = 0; $j <= $#{$linksarrayref}; $j++ )
1852 my $destlink = ${$linksarrayref}[$j];
1853 $shortcutgid = $destlink->{'gid'};
1855 if ( $shortcutgid eq $shortcutid )
1857 $foundlink = 1;
1858 $onelink->{'destinationfile'} = $destlink->{'destination'}; # making key 'destinationfile'
1859 last;
1863 if (!($foundlink))
1865 $infoline = "Warning: ShortcutID $shortcutid for Link $onelink->{'gid'} not found!\n";
1866 push( @installer::globals::logfileinfo, $infoline);
1871 $infoline = "\n";
1872 push( @installer::globals::logfileinfo, $infoline);
1875 ###################################################################################
1876 # Items with flag WORKSTATION are not needed (here: links and configurationitems)
1877 ###################################################################################
1879 sub remove_workstation_only_items
1881 my ($itemarrayref) = @_;
1883 my @newitemarray = ();
1885 for ( my $i = 0; $i <= $#{$itemarrayref}; $i++ )
1887 my $oneitem = ${$itemarrayref}[$i];
1888 my $styles = $oneitem->{'Styles'};
1890 if (( $styles =~ /\bWORKSTATION\b/ ) &&
1891 (!( $styles =~ /\bNETWORK\b/ )) &&
1892 (!( $styles =~ /\bSTANDALONE\b/ )))
1894 next; # removing this link, it is only needed for a workstation installation
1897 push(@newitemarray, $oneitem);
1900 return \@newitemarray;
1903 ################################################
1904 # Resolving relative path in links
1905 ################################################
1907 sub resolve_links_with_flag_relative
1909 my ($linksarrayref) = @_;
1911 # Before this step is:
1912 # destination=program/libsalhelperC52.so.3, this will be the name of the link
1913 # destinationfile=program/libsalhelperC52.so.3, this will be the linked file or name
1914 # If the flag RELATIVE is set, the paths have to be analyzed. If the flag is not set
1915 # (this will not occur in the future?) destinationfile has to be an absolute path name
1917 for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ )
1919 my $onelink = ${$linksarrayref}[$i];
1920 my $styles = $onelink->{'Styles'};
1922 if ( $styles =~ /\bRELATIVE\b/ )
1924 # ToDo: This is only a simple not sufficient mechanism
1926 my $destination = $onelink->{'destination'};
1927 my $destinationfile = $onelink->{'destinationfile'};
1929 my $destinationpath = $destination;
1931 installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationpath);
1933 my $destinationfilepath = $destinationfile;
1935 # it is possible, that the destinationfile is no longer part of the files collector
1936 if ($destinationfilepath) { installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationfilepath); }
1937 else { $destinationfilepath = ""; }
1939 if ( $destinationpath eq $destinationfilepath )
1941 # link and file are in the same directory
1942 # Therefore the path of the file can be removed
1944 my $newdestinationfile = $destinationfile;
1945 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$newdestinationfile);
1947 $onelink->{'destinationfile'} = $newdestinationfile;
1953 ########################################################################
1954 # This function is a helper of function "assigning_modules_to_items"
1955 ########################################################################
1957 sub insert_for_item ($$$)
1959 my ($hash, $item, $id) = @_;
1961 if (!defined $hash->{$item})
1963 my @gids = ();
1964 $hash->{$item} = \@gids;
1966 my $gid_list = $hash->{$item};
1967 push @{$gid_list}, $id;
1968 $hash->{$item} = $gid_list;
1971 sub build_modulegids_table
1973 my ($modulesref, $itemname) = @_;
1975 my %module_lookup_table = ();
1977 # build map of item names to list of respective module gids
1978 # containing these items
1979 for my $onemodule (@{$modulesref})
1981 next if ( ! defined $onemodule->{$itemname} );
1982 # these are the items contained in this module
1983 # eg. Files = (gid_a_b_c,gid_d_e_f)
1984 my $module_gids = $onemodule->{$itemname};
1986 # prune outer brackets
1987 $module_gids =~ s|^\s*\(||g;
1988 $module_gids =~ s|\)\s*$||g;
1989 for my $id (split (/,/, $module_gids))
1991 chomp $id;
1992 insert_for_item(\%module_lookup_table, lc ($id), $onemodule->{'gid'});
1996 return \%module_lookup_table;
1999 ########################################################################
2000 # Items like files do not know their modules
2001 # This function is a helper of function "assigning_modules_to_items"
2002 ########################################################################
2004 sub get_string_of_modulegids_for_itemgid
2006 my ($module_lookup_table, $modulesref, $itemgid, $itemname) = @_;
2008 my $allmodules = "";
2009 my $haslanguagemodule = 0;
2010 my %foundmodules = ();
2012 my $gid_list = $module_lookup_table->{lc($itemgid)};
2014 for my $gid (@{$gid_list})
2016 $foundmodules{$gid} = 1;
2017 $allmodules = $allmodules . "," . $gid;
2018 # Is this module a language module? This info should be stored at the file.
2019 if ( exists($installer::globals::alllangmodules{$gid}) ) { $haslanguagemodule = 1; }
2022 $allmodules =~ s/^\s*\,//; # removing leading comma
2024 # Check: All modules or no module must have flag LANGUAGEMODULE
2025 if ( $haslanguagemodule )
2027 my $isreallylanguagemodule = _key_in_a_is_also_key_in_b(\%foundmodules, \%installer::globals::alllangmodules);
2028 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"); }
2031 return ($allmodules, $haslanguagemodule);
2034 ########################################################
2035 # Items like files do not know their modules
2036 # This function add the {'modules'} to these items
2037 ########################################################
2039 sub assigning_modules_to_items
2041 my ($modulesref, $itemsref, $itemname) = @_;
2043 my $infoline = "";
2044 my $languageassignmenterror = 0;
2045 my @languageassignmenterrors = ();
2047 my $module_lookup_table = build_modulegids_table($modulesref, $itemname);
2049 for my $oneitem (@{$itemsref})
2051 my $itemgid = $oneitem->{'gid'};
2053 my $styles = "";
2054 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
2055 if (( $itemname eq "Dirs" ) && ( ! ( $styles =~ /\bCREATE\b/ ))) { next; }
2057 if ( $itemgid eq "" )
2059 installer::exiter::exit_program("ERROR in item collection: No gid for item $oneitem->{'Name'}", "assigning_modules_to_items");
2062 # every item can belong to many modules
2064 my ($modulegids, $haslanguagemodule) = get_string_of_modulegids_for_itemgid($module_lookup_table, $modulesref, $itemgid, $itemname);
2066 if ($modulegids eq "")
2068 installer::exiter::exit_program("ERROR in file collection: No module found for $itemname $itemgid", "assigning_modules_to_items");
2071 $oneitem->{'modules'} = $modulegids;
2072 $oneitem->{'haslanguagemodule'} = $haslanguagemodule;
2074 # Important check: "ismultilingual" and "haslanguagemodule" must have the same value !
2075 if (( $oneitem->{'ismultilingual'} ) && ( ! $oneitem->{'haslanguagemodule'} ))
2077 $infoline = "Error: \"$oneitem->{'gid'}\" is multi lingual, but not in language pack (Assigned module: $modulegids)!\n";
2078 push( @installer::globals::globallogfileinfo, $infoline);
2079 push( @languageassignmenterrors, $infoline );
2080 $languageassignmenterror = 1;
2082 if (( $oneitem->{'haslanguagemodule'} ) && ( ! $oneitem->{'ismultilingual'} ))
2084 $infoline = "Error: \"$oneitem->{'gid'}\" is in language pack, but not multi lingual (Assigned module: $modulegids)!\n";
2085 push( @installer::globals::globallogfileinfo, $infoline);
2086 push( @languageassignmenterrors, $infoline );
2087 $languageassignmenterror = 1;
2091 if ($languageassignmenterror)
2093 for ( my $i = 0; $i <= $#languageassignmenterrors; $i++ ) { print "$languageassignmenterrors[$i]"; }
2094 installer::exiter::exit_program("ERROR: Incorrect assignments for language packs.", "assigning_modules_to_items");
2099 #################################################################################################
2100 # Root path (for instance /opt/openofficeorg20) needs to be added to directories, files and links
2101 #################################################################################################
2103 sub add_rootpath_to_directories
2105 my ($dirsref, $rootpath) = @_;
2107 for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
2109 my $onedir = ${$dirsref}[$i];
2110 my $dir = "";
2112 if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; }
2114 if (!($dir =~ /\bPREDEFINED_/ ))
2116 my $hostname = $onedir->{'HostName'};
2117 $hostname = $rootpath . $installer::globals::separator . $hostname;
2118 $onedir->{'HostName'} = $hostname;
2121 # added
2123 if ( $dir =~ /\bPREDEFINED_PROGDIR\b/ )
2125 my $hostname = $onedir->{'HostName'};
2126 if ( $hostname eq "" ) { $onedir->{'HostName'} = $rootpath; }
2127 else { $onedir->{'HostName'} = $rootpath . $installer::globals::separator . $hostname; }
2132 sub add_rootpath_to_files
2134 my ($filesref, $rootpath) = @_;
2136 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
2138 my $onefile = ${$filesref}[$i];
2139 my $destination = $onefile->{'destination'};
2140 $destination = $rootpath . $installer::globals::separator . $destination;
2141 $onefile->{'destination'} = $destination;
2145 sub add_rootpath_to_links
2147 my ($linksref, $rootpath) = @_;
2149 for ( my $i = 0; $i <= $#{$linksref}; $i++ )
2151 my $onelink = ${$linksref}[$i];
2152 my $styles = $onelink->{'Styles'};
2154 my $destination = $onelink->{'destination'};
2155 $destination = $rootpath . $installer::globals::separator . $destination;
2156 $onelink->{'destination'} = $destination;
2158 if (!($styles =~ /\bRELATIVE\b/ )) # for absolute links
2160 my $destinationfile = $onelink->{'destinationfile'};
2161 $destinationfile = $rootpath . $installer::globals::separator . $destinationfile;
2162 $onelink->{'destinationfile'} = $destinationfile;
2167 #################################################################################
2168 # Collecting all parent gids
2169 #################################################################################
2171 sub collect_all_parent_feature
2173 my ($modulesref) = @_;
2175 my @allparents = ();
2177 my $found_root_module = 0;
2179 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2181 my $onefeature = ${$modulesref}[$i];
2183 my $parentgid = "";
2184 if ( $onefeature->{'ParentID'} )
2186 $parentgid = $onefeature->{'ParentID'};
2189 if ( $parentgid ne "" )
2191 if (! grep {$_ eq $parentgid} @allparents)
2193 push(@allparents, $parentgid);
2197 # Setting the global root module
2199 if ( $parentgid eq "" )
2201 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"); }
2202 $installer::globals::rootmodulegid = $onefeature->{'gid'};
2203 $found_root_module = 1;
2204 $infoline = "Setting Root Module: $installer::globals::rootmodulegid\n";
2205 push( @installer::globals::globallogfileinfo, $infoline);
2208 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"); }
2212 return \@allparents;
2215 #################################################################################
2216 # Checking for every feature, whether it has children
2217 #################################################################################
2219 sub set_children_flag
2221 my ($modulesref) = @_;
2223 my $allparents = collect_all_parent_feature($modulesref);
2225 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2227 my $onefeature = ${$modulesref}[$i];
2228 my $gid = $onefeature->{'gid'};
2230 # is this gid a parent?
2232 if ( grep {$_ eq $gid} @{$allparents} )
2234 $onefeature->{'has_children'} = 1;
2236 else
2238 $onefeature->{'has_children'} = 0;
2243 #################################################################################
2244 # All modules, that use a template module, do now get the assignments of
2245 # the template module.
2246 #################################################################################
2248 sub resolve_assigned_modules
2250 my ($modulesref) = @_;
2252 # collecting all template modules
2254 my %directaccess = ();
2256 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2258 my $onefeature = ${$modulesref}[$i];
2259 my $styles = "";
2260 if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
2261 if ( $styles =~ /\bTEMPLATEMODULE\b/ ) { $directaccess{$onefeature->{'gid'}} = $onefeature; }
2263 # also looking for module with flag ROOT_BRAND_PACKAGE, to save is for further usage
2264 if ( $styles =~ /\bROOT_BRAND_PACKAGE\b/ )
2266 $installer::globals::rootbrandpackage = $onefeature->{'gid'};
2267 $installer::globals::rootbrandpackageset = 1;
2271 # looking, where template modules are assigned
2273 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2275 my $onefeature = ${$modulesref}[$i];
2276 if ( $onefeature->{'Assigns'} )
2278 my $templategid = $onefeature->{'Assigns'};
2280 if ( ! exists($directaccess{$templategid}) )
2282 installer::exiter::exit_program("ERROR: Did not find definition of assigned template module \"$templategid\"", "resolve_assigned_modules");
2285 # Currently no merging of Files, Dirs, ...
2286 # This has to be included here, if it is required
2287 my @items_at_modules = ("Files", "Dirs", "Unixlinks");
2288 for my $item (@items_at_modules)
2290 if ( exists($directaccess{$templategid}->{$item}) ) { $onefeature->{$item} = $directaccess{$templategid}->{$item}; }
2296 #################################################################################
2297 # Removing the template modules from the list, after all
2298 # assignments are transferred to the "real" modules.
2299 #################################################################################
2301 sub remove_template_modules
2303 my ($modulesref) = @_;
2305 my @modules = ();
2307 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2309 my $onefeature = ${$modulesref}[$i];
2310 my $styles = "";
2311 if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
2312 if ( $styles =~ /\bTEMPLATEMODULE\b/ ) { next; }
2314 push(@modules, $onefeature);
2317 return \@modules;
2320 #################################################################################
2321 # Collecting all modules with flag LANGUAGEMODULE in a global
2322 # collector.
2323 #################################################################################
2325 sub collect_all_languagemodules
2327 my ($modulesref) = @_;
2329 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2331 my $onefeature = ${$modulesref}[$i];
2332 my $styles = "";
2333 if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
2334 if ( $styles =~ /\bLANGUAGEMODULE\b/ )
2336 if ( ! exists($onefeature->{'Language'}) ) { installer::exiter::exit_program("ERROR: \"$onefeature->{'gid'}\" has flag LANGUAGEMODULE, but does not know its language!", "collect_all_languagemodules"); }
2337 $installer::globals::alllangmodules{$onefeature->{'gid'}} = $onefeature->{'Language'};
2338 # Collecting also the english names, that are used for nsis unpack directory for language packs
2339 my $lang = $onefeature->{'Language'};
2340 my $name = "";
2341 foreach my $localkey ( keys %{$onefeature} )
2343 if ( $localkey =~ /^\s*Name\s*\(\s*en-US\s*\)\s*$/ )
2345 $installer::globals::all_english_languagestrings{$lang} = $onefeature->{$localkey};
2352 #################################################################################
2353 # Selecting from all collected english language strings those, that are really
2354 # required in this installation set.
2355 #################################################################################
2357 sub select_required_language_strings
2359 my ($modulesref) = @_;
2361 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2363 my $onefeature = ${$modulesref}[$i];
2364 my $styles = "";
2365 if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
2366 if ( $styles =~ /\bLANGUAGEMODULE\b/ )
2368 if ( ! exists($onefeature->{'Language'}) ) { installer::exiter::exit_program("ERROR: \"$onefeature->{'gid'}\" has flag LANGUAGEMODULE, but does not know its language!", "select_required_language_strings"); }
2369 my $lang = $onefeature->{'Language'};
2371 if (( exists($installer::globals::all_english_languagestrings{$lang}) ) && ( ! exists($installer::globals::all_required_english_languagestrings{$lang}) ))
2373 $installer::globals::all_required_english_languagestrings{$lang} = $installer::globals::all_english_languagestrings{$lang};
2379 ################################################
2380 # Controlling that all keys in hash A are
2381 # also key in hash B.
2382 ################################################
2384 sub _key_in_a_is_also_key_in_b
2386 my ( $hashref_a, $hashref_b) = @_;
2388 my $returnvalue = 1;
2390 my $key;
2391 foreach $key ( keys %{$hashref_a} )
2393 if ( ! exists($hashref_b->{$key}) )
2395 print "*****\n";
2396 foreach $keyb ( keys %{$hashref_b} ) { print "$keyb : $hashref_b->{$keyb}\n"; }
2397 print "*****\n";
2398 $returnvalue = 0;
2402 return $returnvalue;