Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / solenv / bin / modules / installer / worker.pm
blobaab676f9a086fd9574b9186f947a6215f7565fc8
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::worker;
21 use Cwd;
22 use File::Copy;
23 use File::stat;
24 use File::Temp qw(tmpnam);
25 use File::Path;
26 use File::Basename;
27 use installer::control;
28 use installer::converter;
29 use installer::exiter;
30 use installer::files;
31 use installer::globals;
32 use installer::logger;
33 use installer::pathanalyzer;
34 use installer::scpzipfiles;
35 use installer::scriptitems;
36 use installer::systemactions;
37 use installer::windows::language;
39 #########################################
40 # Saving the patchlist file
41 #########################################
43 sub _save_patchlist_file
45 my ($installlogdir, $patchlistfilename) = @_;
47 my $installpatchlistdir = installer::systemactions::create_directory_next_to_directory($installlogdir, "patchlist");
48 $patchlistfilename =~ s/log\_/patchfiles\_/;
49 $patchlistfilename =~ s/\.log/\.txt/;
50 installer::files::save_file($installpatchlistdir . $installer::globals::separator . $patchlistfilename, \@installer::globals::patchfilecollector);
51 installer::logger::print_message( "... creating patchlist file $patchlistfilename \n" );
55 ###############################################################
56 # Removing all directories of a special language
57 # in the directory $basedir
58 ###############################################################
60 sub remove_old_installation_sets
62 my ($basedir) = @_;
64 installer::logger::print_message( "... removing old installation directories ...\n" );
66 my $removedir = $basedir;
68 if ( -d $removedir ) { installer::systemactions::remove_complete_directory($removedir, 1); }
70 # looking for non successful old installation sets
72 $removedir = $basedir . "_witherror";
73 if ( -d $removedir ) { installer::systemactions::remove_complete_directory($removedir, 1); }
75 $removedir = $basedir . "_inprogress";
76 if ( -d $removedir ) { installer::systemactions::remove_complete_directory($removedir, 1); }
78 # finally the $basedir can be created empty
80 if ( $installer::globals::localinstalldirset ) { installer::systemactions::create_directory_structure($basedir); }
82 installer::systemactions::create_directory($basedir);
85 ###############################################################
86 # Creating the installation directory structure
87 ###############################################################
89 sub create_installation_directory
91 my ($shipinstalldir, $languagestringref, $current_install_number_ref) = @_;
93 my $installdir = "";
95 my $languageref = $languagestringref;
97 $installdir = installer::systemactions::create_directories("install", $languageref);
98 installer::logger::print_message( "... creating installation set in $installdir ...\n" );
99 remove_old_installation_sets($installdir);
100 my $inprogressinstalldir = $installdir . "_inprogress";
101 installer::systemactions::rename_directory($installdir, $inprogressinstalldir);
102 $installdir = $inprogressinstalldir;
104 $installer::globals::saveinstalldir = $installdir; # saving directory globally, in case of exiting
106 return $installdir;
109 ###############################################################
110 # Analyzing and creating the log file
111 ###############################################################
113 sub analyze_and_save_logfile
115 my ($loggingdir, $installdir, $installlogdir, $allsettingsarrayref, $languagestringref, $current_install_number) = @_;
117 my $is_success = 1;
118 my $finalinstalldir = "";
120 installer::logger::print_message( "... checking log file " . $loggingdir . $installer::globals::logfilename . "\n" );
122 my $contains_error = installer::control::check_logfile(\@installer::globals::logfileinfo);
124 # Dependent from the success, the installation directory can be renamed.
126 if ( $contains_error )
128 my $errordir = installer::systemactions::rename_string_in_directory($installdir, "_inprogress", "_witherror");
129 # Error output to STDERR
130 for ( my $j = 0; $j <= $#installer::globals::errorlogfileinfo; $j++ )
132 my $line = $installer::globals::errorlogfileinfo[$j];
133 $line =~ s/\s*$//g;
134 installer::logger::print_error( $line );
136 $is_success = 0;
138 $finalinstalldir = $errordir;
140 else
142 my $destdir = "";
144 $destdir = installer::systemactions::rename_string_in_directory($installdir, "_inprogress", "");
146 $finalinstalldir = $destdir;
149 # Saving the logfile in the log file directory and additionally in a log directory in the install directory
151 my $numberedlogfilename = $installer::globals::logfilename;
152 installer::logger::print_message( "... creating log file $numberedlogfilename \n" );
153 installer::files::save_file($loggingdir . $numberedlogfilename, \@installer::globals::logfileinfo);
154 installer::files::save_file($installlogdir . $installer::globals::separator . $numberedlogfilename, \@installer::globals::logfileinfo);
156 # Saving the list of patchfiles in a patchlist directory in the install directory
157 if ( $installer::globals::creating_windows_installer_patch ) { _save_patchlist_file($installlogdir, $numberedlogfilename); }
159 if ( $installer::globals::creating_windows_installer_patch ) { $installer::globals::creating_windows_installer_patch = 0; }
161 # Exiting the packaging process, if an error occurred.
162 # This is important, to get an error code "-1", if an error was found in the log file,
163 # that did not break the packaging process
165 if ( ! $is_success) { installer::exiter::exit_program("ERROR: Found an error in the logfile. Packaging failed.", "analyze_and_save_logfile"); }
167 return ($is_success, $finalinstalldir);
170 ###############################################################
171 # Removing all directories that are saved in the
172 # global directory @installer::globals::removedirs
173 ###############################################################
175 sub clean_output_tree
177 installer::logger::print_message( "... cleaning the output tree ...\n" );
179 for ( my $i = 0; $i <= $#installer::globals::removedirs; $i++ )
181 if ( -d $installer::globals::removedirs[$i] )
183 installer::logger::print_message( "... removing directory $installer::globals::removedirs[$i] ...\n" );
184 installer::systemactions::remove_complete_directory($installer::globals::removedirs[$i], 1);
188 # Last try to remove the ship test directory
190 if ( $installer::globals::shiptestdirectory )
192 if ( -d $installer::globals::shiptestdirectory )
194 my $infoline = "Last try to remove $installer::globals::shiptestdirectory . \n";
195 push(@installer::globals::logfileinfo, $infoline);
196 my $systemcall = "rmdir $installer::globals::shiptestdirectory";
197 my $returnvalue = system($systemcall);
202 ###########################################################
203 # Setting one language in the language independent
204 # array of include paths with $(LANG)
205 ###########################################################
207 sub get_language_specific_include_paths
209 my ( $patharrayref, $onelanguage ) = @_;
211 my @patharray = ();
213 for ( my $i = 0; $i <= $#{$patharrayref}; $i++ )
215 my $line = ${$patharrayref}[$i];
216 $line =~ s/\$\(LANG\)/$onelanguage/g;
217 push(@patharray ,$line);
220 return \@patharray;
223 ##############################################################
224 # Collecting all items with a defined flag
225 ##############################################################
227 sub collect_all_items_with_special_flag
229 my ($itemsref, $flag) = @_;
231 my @allitems = ();
233 for ( my $i = 0; $i <= $#{$itemsref}; $i++ )
235 my $oneitem = ${$itemsref}[$i];
236 my $styles = "";
237 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'} };
239 if ( $styles =~ /\b$flag\b/ )
241 push( @allitems, $oneitem );
245 return \@allitems;
248 ##############################################################
249 # Removing all items with a defined flag from collector
250 ##############################################################
252 sub remove_all_items_with_special_flag
254 my ($itemsref, $flag) = @_;
256 my @allitems = ();
258 for ( my $i = 0; $i <= $#{$itemsref}; $i++ )
260 my $oneitem = ${$itemsref}[$i];
261 my $styles = "";
262 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'} };
263 if ( $styles =~ /\b$flag\b/ )
265 my $infoline = "Attention: Removing from collector: $oneitem->{'Name'} !\n";
266 push( @installer::globals::logfileinfo, $infoline);
267 if ( $flag eq "BINARYTABLE_ONLY" ) { push(@installer::globals::binarytableonlyfiles, $oneitem); }
268 next;
270 push( @allitems, $oneitem );
273 return \@allitems;
276 ###########################################################
277 # Mechanism for simple installation without packing
278 ###########################################################
280 sub install_simple ($$$$$$)
282 my ($packagename, $languagestring, $directoriesarray, $filesarray, $linksarray, $unixlinksarray) = @_;
284 installer::logger::print_message( "... installing module $packagename ...\n" );
286 my $destdir = $installer::globals::destdir;
287 my @lines = ();
289 installer::logger::print_message( "DestDir: $destdir \n" );
290 installer::logger::print_message( "Rootpath: $installer::globals::rootpath \n" );
292 `mkdir -p $destdir` if $destdir ne "";
293 `mkdir -p $destdir$installer::globals::rootpath`;
295 # Create Directories
296 for ( my $i = 0; $i <= $#{$directoriesarray}; $i++ )
298 my $onedir = ${$directoriesarray}[$i];
299 my $dir = "";
301 if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; }
303 if ((!($dir =~ /\bPREDEFINED_/ )) || ( $dir =~ /\bPREDEFINED_PROGDIR\b/ ))
305 my $hostname = $onedir->{'HostName'};
307 # ignore '.' subdirectories
308 next if ( $hostname =~ m/\.$/ );
309 # remove './' from the path
310 $hostname =~ s/\.\///g;
312 # printf "mkdir $destdir$hostname\n";
313 mkdir $destdir . $hostname;
314 push @lines, "%dir " . $hostname . "\n";
318 for ( my $i = 0; $i <= $#{$filesarray}; $i++ )
320 my $onefile = ${$filesarray}[$i];
321 my $unixrights = $onefile->{'UnixRights'};
322 my $destination = $onefile->{'destination'};
323 my $sourcepath = $onefile->{'sourcepath'};
325 # This is necessary to install SDK that includes files with $ in its name
326 # Otherwise, the following shell commands does not work and the file list
327 # is not correct
328 $destination =~ s/\$\$/\$/;
329 $sourcepath =~ s/\$\$/\$/;
331 # remove './' from the path
332 $sourcepath =~ s/\.\///g;
333 $destination =~ s/\.\///g;
335 push @lines, "$destination\n";
336 if(-d "$destdir$destination"){
337 rmtree("$destdir$destination");
339 if(-e "$destdir$destination") {
340 unlink "$destdir$destination";
343 if ( -l "$sourcepath" ) {
344 symlink (readlink ("$sourcepath"), "$destdir$destination") || die "Can't symlink $destdir$destination -> " . readlink ("$sourcepath") . "$!";
346 else {
347 copy ("$sourcepath", "$destdir$destination") || die "Can't copy file: $sourcepath -> $destdir$destination $!";
348 my $sourcestat = stat($sourcepath);
349 utime ($sourcestat->atime, $sourcestat->mtime, "$destdir$destination");
350 chmod (oct($unixrights), "$destdir$destination") || die "Can't change permissions: $!";
352 push @lines, "$destination\n";
355 for ( my $i = 0; $i <= $#{$linksarray}; $i++ )
357 my $onelink = ${$linksarray}[$i];
358 my $destination = $onelink->{'destination'};
359 my $destinationfile = $onelink->{'destinationfile'};
361 if(-e "$destdir$destination") {
362 unlink "$destdir$destination";
364 symlink ("$destinationfile", "$destdir$destination") || die "Can't create symlink: $!";
365 push @lines, "$destination\n";
368 for ( my $i = 0; $i <= $#{$unixlinksarray}; $i++ )
370 my $onelink = ${$unixlinksarray}[$i];
371 my $target = $onelink->{'Target'};
372 my $destination = $onelink->{'destination'};
373 my $cmd = "mkdir -p '" . dirname($destdir . $destination) . "'";
374 system($cmd) && die "Failed to execute \"$cmd\"";
375 $cmd = "ln -sf '$target' '$destdir$destination'";
377 system($cmd) && die "Failed \"$cmd\"";
378 push @lines, "$destination\n";
381 if ( $destdir ne "" )
383 my $filelist;
384 my $fname = $installer::globals::destdir . "/$packagename";
385 open ($filelist, ">$fname") || die "Can't open $fname: $!";
386 print $filelist @lines;
387 close ($filelist);
392 ###########################################################
393 # Selecting langpack items
394 ###########################################################
396 sub select_langpack_items
398 my ( $itemsref, $itemname ) = @_;
400 installer::logger::include_header_into_logfile("Selecting RegistryItems for Language Packs");
402 my @itemsarray = ();
404 for ( my $i = 0; $i <= $#{$itemsref}; $i++ )
406 my $oneitem = ${$itemsref}[$i];
408 # Items with style "LANGUAGEPACK" have to be included into the patch
409 my $styles = "";
410 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
411 if (( $styles =~ /\bLANGUAGEPACK\b/ ) || ( $styles =~ /\bFORCELANGUAGEPACK\b/ )) { push(@itemsarray, $oneitem); }
414 return \@itemsarray;
417 ###########################################################
418 # Selecting helppack items
419 ###########################################################
421 sub select_helppack_items
423 my ( $itemsref, $itemname ) = @_;
425 installer::logger::include_header_into_logfile("Selecting RegistryItems for Help Packs");
427 my @itemsarray = ();
429 for ( my $i = 0; $i <= $#{$itemsref}; $i++ )
431 my $oneitem = ${$itemsref}[$i];
433 # Items with style "HELPPACK" have to be included into the patch
434 my $styles = "";
435 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
436 if (( $styles =~ /\bHELPPACK\b/ ) || ( $styles =~ /\bFORCEHELPPACK\b/ )) { push(@itemsarray, $oneitem); }
439 return \@itemsarray;
442 ###########################################################
443 # Replacing %-variables with the content
444 # of $allvariableshashref
445 ###########################################################
447 sub replace_variables_in_string
449 my ( $string, $variableshashref ) = @_;
451 if ( $string =~ /^.*\%\w+.*$/ )
453 my $key;
455 # we want to substitute FOO_BR before FOO to avoid floating _BR suffixes
456 foreach $key (sort { length ($b) <=> length ($a) } keys %{$variableshashref})
458 my $value = $variableshashref->{$key};
459 $key = "\%" . $key;
460 $string =~ s/\Q$key\E/$value/g;
464 return $string;
467 #################################################################
468 # Copying the files defined as ScpActions into the
469 # installation set.
470 #################################################################
472 sub put_scpactions_into_installset
474 my ($installdir) = @_;
476 installer::logger::include_header_into_logfile("Start: Copying scp action files into installation set");
478 for ( my $i = 0; $i <= $#installer::globals::allscpactions; $i++ )
480 my $onescpaction = $installer::globals::allscpactions[$i];
482 my $subdir = "";
483 if ( $onescpaction->{'Subdir'} ) { $subdir = $onescpaction->{'Subdir'}; }
485 if ( $onescpaction->{'Name'} eq "loader.exe" ) { next; } # do not copy this ScpAction loader
487 my $destdir = $installdir;
488 $destdir =~ s/\Q$installer::globals::separator\E\s*$//;
489 if ( $subdir ) { $destdir = $destdir . $installer::globals::separator . $subdir; }
491 my $sourcefile = $onescpaction->{'sourcepath'};
492 my $destfile = $destdir . $installer::globals::separator . $onescpaction->{'DestinationName'};
494 if (( $subdir =~ /\// ) || ( $subdir =~ /\\/ ))
496 installer::systemactions::create_directory_structure($destdir);
498 else
500 installer::systemactions::create_directory($destdir);
503 installer::systemactions::copy_one_file($sourcefile, $destfile);
505 if ( $onescpaction->{'UnixRights'} )
507 chmod oct($onescpaction->{'UnixRights'}), $destfile;
512 installer::logger::include_header_into_logfile("End: Copying scp action files into installation set");
516 #################################################################
517 # Collecting scp actions for all languages
518 #################################################################
520 sub collect_scpactions
522 my ($allscpactions) = @_;
524 for ( my $i = 0; $i <= $#{$allscpactions}; $i++ )
526 push(@installer::globals::allscpactions, ${$allscpactions}[$i]);
530 ###########################################################
531 # Adding additional variables into the variableshashref,
532 # that are defined in include files in the source tree. The
533 # names of the include files are stored in
534 # ADD_INCLUDE_FILES (comma separated list).
535 ###########################################################
537 sub add_variables_from_inc_to_hashref
539 my ($allvariables, $includepatharrayref) = @_;
541 my $infoline = "";
542 my $includefilelist = $allvariables->{'ADD_INCLUDE_FILES'} || "";
544 for my $includefilename (split /,\s*/, $includefilelist)
546 $includefilename =~ s/^\s*//;
547 $includefilename =~ s/\s*$//;
548 $includefilenameref = $ENV{'SRCDIR'} . "/" . $includefilename;
549 if ( ! -f $includefilenameref ) { installer::exiter::exit_program("Include file $includefilename ($includefilenameref) not found!\nADD_INCLUDE_FILES = $allvariables->{'ADD_INCLUDE_FILES'}", "add_variables_from_inc_to_hashref"); }
551 $infoline = "Including inc file: $includefilenameref \n";
552 push( @installer::globals::globallogfileinfo, $infoline);
554 my $includefile = installer::files::read_file($includefilenameref);
556 for ( my $j = 0; $j <= $#{$includefile}; $j++ )
558 # Analyzing all "key=value" lines
559 my $oneline = ${$includefile}[$j];
561 if ( $oneline =~ /^\s*(\S+)\s*\=\s*(.*?)\s*$/ ) # no white space allowed in key
563 my $key = $1;
564 my $value = $2;
565 $allvariables->{$key} = $value;
566 $infoline = "Setting of variable: $key = $value\n";
567 push( @installer::globals::globallogfileinfo, $infoline);
573 ##############################################
574 # Collecting all files from include paths
575 ##############################################
577 sub collect_all_files_from_includepaths
579 my ($patharrayref) = @_;
581 installer::logger::globallog("Reading all directories: Start");
582 installer::logger::print_message( "... reading include paths ...\n" );
583 # empty the global
585 @installer::globals::allincludepaths =();
586 my $infoline;
588 for ( my $i = 0; $i <= $#{$patharrayref}; $i++ )
590 $includepath = ${$patharrayref}[$i];
591 installer::remover::remove_leading_and_ending_whitespaces(\$includepath);
593 if ( ! -d $includepath )
595 $infoline = "$includepath does not exist. (Can be removed from include path list?)\n";
596 push( @installer::globals::globallogfileinfo, $infoline);
597 next;
600 my @sourcefiles = ();
601 my $pathstring = "";
602 installer::systemactions::read_full_directory($includepath, $pathstring, \@sourcefiles);
604 if ( ! ( $#sourcefiles > -1 ))
606 $infoline = "$includepath is empty. (Can be removed from include path list?)\n";
607 push( @installer::globals::globallogfileinfo, $infoline);
609 else
611 my $number = $#sourcefiles + 1;
612 $infoline = "Directory $includepath contains $number files (including subdirs)\n";
613 push( @installer::globals::globallogfileinfo, $infoline);
615 my %allfileshash = ();
616 $allfileshash{'includepath'} = $includepath;
618 for ( my $j = 0; $j <= $#sourcefiles; $j++ )
620 $allfileshash{$sourcefiles[$j]} = 1;
623 push(@installer::globals::allincludepaths, \%allfileshash);
627 $installer::globals::include_paths_read = 1;
629 installer::logger::globallog("Reading all directories: End");
630 push( @installer::globals::globallogfileinfo, "\n");
633 ##############################################
634 # Searching for a file with the gid
635 ##############################################
637 sub find_file_by_id
639 my ( $filesref, $gid ) = @_;
641 my $foundfile = 0;
642 my $onefile;
644 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
646 $onefile = ${$filesref}[$i];
647 my $filegid = $onefile->{'gid'};
649 if ( $filegid eq $gid )
651 $foundfile = 1;
652 last;
656 if (! $foundfile ) { $onefile = ""; }
658 return $onefile;
661 #################################################
662 # Generating paths for cygwin (second version)
663 # This function generates smaller files for
664 #################################################
666 sub generate_cygwin_paths
668 my ($filesref) = @_;
670 installer::logger::include_timestamp_into_logfile("Starting generating cygwin paths");
672 my $infoline = "Generating cygwin paths (generate_cygwin_paths)\n";
673 push( @installer::globals::logfileinfo, $infoline);
675 my $max = 5000; # number of paths in one file
677 my @pathcollector = ();
678 my $startnumber = 0;
679 my $counter = 0;
681 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
683 my $line = ${$filesref}[$i]->{'sourcepath'} . "\n";
684 push(@pathcollector, $line);
685 $counter++;
687 if (( $i == $#{$filesref} ) || ((( $counter % $max ) == 0 ) && ( $i > 0 )))
689 my $tmpfilename = "cygwinhelper_" . $i . ".txt";
690 my $temppath = $installer::globals::temppath;
691 $temppath =~ s/\Q$installer::globals::separator\E\s*$//;
692 $tmpfilename = $temppath . $installer::globals::separator . $tmpfilename;
693 $infoline = "Creating temporary file for cygwin conversion: $tmpfilename (contains $counter paths)\n";
694 push( @installer::globals::logfileinfo, $infoline);
695 if ( -f $tmpfilename ) { unlink $tmpfilename; }
697 installer::files::save_file($tmpfilename, \@pathcollector);
699 my $success = 0;
700 my @cyg_sourcepathlist = qx{cygpath -w -f "$tmpfilename"};
701 chomp @cyg_sourcepathlist;
703 # Validating the array, it has to contain the correct number of values
704 my $new_paths = $#cyg_sourcepathlist + 1;
705 if ( $new_paths == $counter ) { $success = 1; }
707 if ($success)
709 $infoline = "Success: Successfully converted to cygwin paths!\n";
710 push( @installer::globals::logfileinfo, $infoline);
712 else
714 $infoline = "ERROR: Failed to convert to cygwin paths!\n";
715 push( @installer::globals::logfileinfo, $infoline);
716 installer::exiter::exit_program("ERROR: Failed to convert to cygwin paths!", "generate_cygwin_paths");
719 for ( my $j = 0; $j <= $#cyg_sourcepathlist; $j++ )
721 my $number = $startnumber + $j;
722 ${$filesref}[$number]->{'cyg_sourcepath'} = $cyg_sourcepathlist[$j];
725 if ( -f $tmpfilename ) { unlink $tmpfilename; }
727 @pathcollector = ();
728 $startnumber = $startnumber + $max;
729 $counter = 0;
733 # Checking existence fo cyg_sourcepath for every file
734 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
736 if (( ! exists(${$filesref}[$i]->{'cyg_sourcepath'}) ) || ( ${$filesref}[$i]->{'cyg_sourcepath'} eq "" ))
738 $infoline = "ERROR: No cygwin sourcepath defined for file ${$filesref}[$i]->{'sourcepath'}\n";
739 push( @installer::globals::logfileinfo, $infoline);
740 installer::exiter::exit_program("ERROR: No cygwin sourcepath defined for file ${$filesref}[$i]->{'sourcepath'}!", "generate_cygwin_paths");
744 installer::logger::include_timestamp_into_logfile("Ending generating cygwin paths");
747 ######################################################
748 # Getting the first entry from a list of languages
749 ######################################################
751 sub get_first_from_list
753 my ( $list ) = @_;
755 my $first = $list;
757 if ( $list =~ /^\s*(.+?),(.+)\s*$/) # "?" for minimal matching
759 $first = $1;
762 return $first;
765 ################################################
766 # Setting all spellchecker languages
767 ################################################
769 sub set_spellcheckerlanguages
771 my ( $productlanguagesarrayref, $allvariables ) = @_;
773 my %productlanguages = ();
774 for ( my $i = 0; $i <= $#{$productlanguagesarrayref}; $i++ ) { $productlanguages{${$productlanguagesarrayref}[$i]} = 1; }
776 my $spellcheckfilename = $allvariables->{'SPELLCHECKERFILE'};
778 my $spellcheckfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$spellcheckfilename, "", 1);
780 if ($$spellcheckfileref eq "") { installer::exiter::exit_program("ERROR: Could not find $spellcheckfilename!", "set_spellcheckerlanguages"); }
782 my $infoline = "Using spellchecker file: $$spellcheckfileref \n";
783 push( @installer::globals::globallogfileinfo, $infoline);
785 my $spellcheckfile = installer::files::read_file($$spellcheckfileref);
786 my %spellcheckhash = ();
788 for ( my $j = 0; $j <= $#{$spellcheckfile}; $j++ )
790 # Analyzing all "key=value" lines
791 my $oneline = ${$spellcheckfile}[$j];
793 if ( $oneline =~ /^\s*(\S+)\s*\=\s*\"(.*?)\"\s*$/ ) # no white space allowed in key
795 my $onelang = $1;
796 my $languagelist = $2;
798 # Special handling for language packs. Only include the first language of the language list.
799 # If no spellchecker shall be included, the keyword "EMPTY" can be used.
801 if ( $installer::globals::languagepack )
803 my $first = get_first_from_list($languagelist);
805 if ( $first eq "EMPTY" ) # no spellchecker into language pack
807 $languagelist = "";
809 else
811 $languagelist = $first;
814 else # no language pack, so EMPTY is not required
816 $languagelist =~ s/^\s*EMPTY\s*,//; # removing the entry EMPTY
819 $spellcheckhash{$onelang} = $languagelist;
823 # Collecting all required languages in %installer::globals::spellcheckerlanguagehash
825 foreach my $lang (keys %productlanguages)
827 my $languagelist = "";
828 if ( exists($spellcheckhash{$lang}) ) { $languagelist = $spellcheckhash{$lang}; }
829 else { $languagelist = ""; } # no dictionary unless defined in SPELLCHECKERFILE
831 my $langlisthash = installer::converter::convert_stringlist_into_hash(\$languagelist, ",");
832 foreach my $onelang ( keys %{$langlisthash} ) { $installer::globals::spellcheckerlanguagehash{$onelang} = 1; }
835 $installer::globals::analyze_spellcheckerlanguage = 1;
837 # Logging
839 my $langstring = "";
840 foreach my $lang (sort keys %installer::globals::spellcheckerlanguagehash) { $langstring = $langstring . "," . $lang }
841 $langstring =~ s/^\s*,//;
843 $infoline = "Collected spellchecker languages for spellchecker: $langstring \n";
844 push( @installer::globals::globallogfileinfo, $infoline);
847 ################################################
848 # Including a license text into setup script
849 ################################################
851 sub put_license_into_setup
853 my ($installdir, $includepatharrayref) = @_;
855 # find and read the license file
856 my $licenselanguage = "en-US"; # always english !
857 my $licensefilename = "license";
858 # my $licensefilename = "LICENSE" . ".txt";
859 my $licenseincludepatharrayref = get_language_specific_include_paths($includepatharrayref, $licenselanguage);
861 my $licenseref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, $licenseincludepatharrayref, 0);
862 if ($$licenseref eq "") { installer::exiter::exit_program("ERROR: Could not find License file $licensefilename!", "put_license_into_setup"); }
863 my $licensefile = installer::files::read_file($$licenseref);
865 # Read setup
866 my $setupfilename = $installdir . $installer::globals::separator . "setup";
867 my $setupfile = installer::files::read_file($setupfilename);
869 # Replacement
870 my $infoline = "Adding licensefile into setup script\n";
871 push( @installer::globals::logfileinfo, $infoline);
873 my $includestring = "";
874 for ( my $i = 0; $i <= $#{$licensefile}; $i++ ) { $includestring = $includestring . ${$licensefile}[$i]; }
875 for ( my $i = 0; $i <= $#{$setupfile}; $i++ ) { ${$setupfile}[$i] =~ s/LICENSEFILEPLACEHOLDER/$includestring/; }
877 # Write setup
878 installer::files::save_file($setupfilename, $setupfile);
881 #########################################################
882 # Collecting all pkgmap files from an installation set
883 #########################################################
885 sub collectpackagemaps
887 my ( $installdir, $languagestringref, $allvariables ) = @_;
889 installer::logger::include_header_into_logfile("Collecing all packagemaps (pkgmap):");
891 my $pkgmapdir = installer::systemactions::create_directories("pkgmap", $languagestringref);
892 my $subdirname = $allvariables->{'UNIXPRODUCTNAME'} . "_pkgmaps";
893 my $pkgmapsubdir = $pkgmapdir . $installer::globals::separator . $subdirname;
894 if ( -d $pkgmapsubdir ) { installer::systemactions::remove_complete_directory($pkgmapsubdir); }
895 if ( ! -d $pkgmapsubdir ) { installer::systemactions::create_directory($pkgmapsubdir); }
897 $installdir =~ s/\/\s*$//;
898 # Collecting all packages in $installdir and its sub package ("packages")
899 my $searchdir = $installdir . $installer::globals::separator . $installer::globals::epmoutpath;
901 my $allpackages = installer::systemactions::get_all_directories_without_path($searchdir);
903 for ( my $i = 0; $i <= $#{$allpackages}; $i++ )
905 my $pkgmapfile = $searchdir . $installer::globals::separator . ${$allpackages}[$i] . $installer::globals::separator . "pkgmap";
906 my $destfilename = $pkgmapsubdir . $installer::globals::separator . ${$allpackages}[$i] . "_pkgmap";
907 installer::systemactions::copy_one_file($pkgmapfile, $destfilename);
910 # Create a tar gz file with all package maps
911 my $tarfilename = $subdirname . ".tar";
912 my $targzname = $tarfilename . ".gz";
913 $systemcall = "cd $pkgmapdir; tar -cf - $subdirname | gzip > $targzname";
914 installer::systemactions::make_systemcall($systemcall);
915 installer::systemactions::remove_complete_directory($pkgmapsubdir, 1);