Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / solenv / bin / modules / installer / worker.pm
blob191ce01eeb16dbed310aecd7d17e4dae0c70c76e
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 strict;
22 use warnings;
24 use Cwd;
25 use File::Copy;
26 use File::stat;
27 use File::Temp qw(tmpnam);
28 use File::Path;
29 use File::Basename;
30 use installer::control;
31 use installer::converter;
32 use installer::exiter;
33 use installer::files;
34 use installer::globals;
35 use installer::logger;
36 use installer::pathanalyzer;
37 use installer::scpzipfiles;
38 use installer::scriptitems;
39 use installer::systemactions;
40 use installer::windows::language;
42 #########################################
43 # Saving the patchlist file
44 #########################################
46 sub _save_patchlist_file
48 my ($installlogdir, $patchlistfilename) = @_;
50 my $installpatchlistdir = installer::systemactions::create_directory_next_to_directory($installlogdir, "patchlist");
51 $patchlistfilename =~ s/log\_/patchfiles\_/;
52 $patchlistfilename =~ s/\.log/\.txt/;
53 installer::files::save_file($installpatchlistdir . $installer::globals::separator . $patchlistfilename, \@installer::globals::patchfilecollector);
54 installer::logger::print_message( "... creating patchlist file $patchlistfilename \n" );
58 ###############################################################
59 # Removing all directories of a special language
60 # in the directory $basedir
61 ###############################################################
63 sub remove_old_installation_sets
65 my ($basedir) = @_;
67 installer::logger::print_message( "... removing old installation directories ...\n" );
69 my $removedir = $basedir;
71 if ( -d $removedir ) { installer::systemactions::remove_complete_directory($removedir, 1); }
73 # looking for non successful old installation sets
75 $removedir = $basedir . "_witherror";
76 if ( -d $removedir ) { installer::systemactions::remove_complete_directory($removedir, 1); }
78 $removedir = $basedir . "_inprogress";
79 if ( -d $removedir ) { installer::systemactions::remove_complete_directory($removedir, 1); }
81 # finally the $basedir can be created empty
83 if ( $installer::globals::localinstalldirset ) { installer::systemactions::create_directory_structure($basedir); }
85 installer::systemactions::create_directory($basedir);
88 ###############################################################
89 # Creating the installation directory structure
90 ###############################################################
92 sub create_installation_directory
94 my ($shipinstalldir, $languagestringref, $current_install_number_ref) = @_;
96 my $installdir = "";
98 my $languageref = $languagestringref;
100 $installdir = installer::systemactions::create_directories("install", $languageref);
101 installer::logger::print_message( "... creating installation set in $installdir ...\n" );
102 remove_old_installation_sets($installdir);
103 my $inprogressinstalldir = $installdir . "_inprogress";
104 installer::systemactions::rename_directory($installdir, $inprogressinstalldir);
105 $installdir = $inprogressinstalldir;
107 $installer::globals::saveinstalldir = $installdir; # saving directory globally, in case of exiting
109 return $installdir;
112 ###############################################################
113 # Analyzing and creating the log file
114 ###############################################################
116 sub analyze_and_save_logfile
118 my ($loggingdir, $installdir, $installlogdir, $allsettingsarrayref, $languagestringref, $current_install_number) = @_;
120 my $is_success = 1;
121 my $finalinstalldir = "";
123 installer::logger::print_message( "... checking log file " . $loggingdir . $installer::globals::logfilename . "\n" );
125 my $contains_error = installer::control::check_logfile(\@installer::globals::logfileinfo);
127 # Dependent from the success, the installation directory can be renamed.
129 if ( $contains_error )
131 my $errordir = installer::systemactions::rename_string_in_directory($installdir, "_inprogress", "_witherror");
132 # Error output to STDERR
133 for ( my $j = 0; $j <= $#installer::globals::errorlogfileinfo; $j++ )
135 my $line = $installer::globals::errorlogfileinfo[$j];
136 $line =~ s/\s*$//g;
137 installer::logger::print_error( $line );
139 $is_success = 0;
141 $finalinstalldir = $errordir;
143 else
145 my $destdir = "";
147 $destdir = installer::systemactions::rename_string_in_directory($installdir, "_inprogress", "");
149 $finalinstalldir = $destdir;
152 # Saving the logfile in the log file directory and additionally in a log directory in the install directory
154 my $numberedlogfilename = $installer::globals::logfilename;
155 installer::logger::print_message( "... creating log file $numberedlogfilename \n" );
156 installer::files::save_file($loggingdir . $numberedlogfilename, \@installer::globals::logfileinfo);
157 installer::files::save_file($installlogdir . $installer::globals::separator . $numberedlogfilename, \@installer::globals::logfileinfo);
159 # Saving the list of patchfiles in a patchlist directory in the install directory
160 if ( $installer::globals::creating_windows_installer_patch ) { _save_patchlist_file($installlogdir, $numberedlogfilename); }
162 if ( $installer::globals::creating_windows_installer_patch ) { $installer::globals::creating_windows_installer_patch = 0; }
164 # Exiting the packaging process, if an error occurred.
165 # This is important, to get an error code "-1", if an error was found in the log file,
166 # that did not break the packaging process
168 if ( ! $is_success) { installer::exiter::exit_program("ERROR: Found an error in the logfile " . $loggingdir . $installer::globals::logfilename . ". Packaging failed.", "analyze_and_save_logfile"); }
170 return ($is_success, $finalinstalldir);
173 ###############################################################
174 # Removing all directories that are saved in the
175 # global directory @installer::globals::removedirs
176 ###############################################################
178 sub clean_output_tree
180 installer::logger::print_message( "... cleaning the output tree ...\n" );
182 for ( my $i = 0; $i <= $#installer::globals::removedirs; $i++ )
184 if ( -d $installer::globals::removedirs[$i] )
186 installer::logger::print_message( "... removing directory $installer::globals::removedirs[$i] ...\n" );
187 installer::systemactions::remove_complete_directory($installer::globals::removedirs[$i], 1);
191 # Last try to remove the ship test directory
193 if ( $installer::globals::shiptestdirectory )
195 if ( -d $installer::globals::shiptestdirectory )
197 my $infoline = "Last try to remove $installer::globals::shiptestdirectory . \n";
198 push(@installer::globals::logfileinfo, $infoline);
199 my $systemcall = "rmdir $installer::globals::shiptestdirectory";
200 my $returnvalue = system($systemcall);
205 ###########################################################
206 # Setting one language in the language independent
207 # array of include paths with $(LANG)
208 ###########################################################
210 sub get_language_specific_include_paths
212 my ( $patharrayref, $onelanguage ) = @_;
214 my @patharray = ();
216 for ( my $i = 0; $i <= $#{$patharrayref}; $i++ )
218 my $line = ${$patharrayref}[$i];
219 $line =~ s/\$\(LANG\)/$onelanguage/g;
220 push(@patharray ,$line);
223 return \@patharray;
226 ##############################################################
227 # Collecting all items with a defined flag
228 ##############################################################
230 sub collect_all_items_with_special_flag
232 my ($itemsref, $flag) = @_;
234 my @allitems = ();
236 for ( my $i = 0; $i <= $#{$itemsref}; $i++ )
238 my $oneitem = ${$itemsref}[$i];
239 my $styles = "";
240 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'} };
242 if ( $styles =~ /\b$flag\b/ )
244 push( @allitems, $oneitem );
248 return \@allitems;
251 ##############################################################
252 # Removing all items with a defined flag from collector
253 ##############################################################
255 sub remove_all_items_with_special_flag
257 my ($itemsref, $flag) = @_;
259 my @allitems = ();
261 for ( my $i = 0; $i <= $#{$itemsref}; $i++ )
263 my $oneitem = ${$itemsref}[$i];
264 my $styles = "";
265 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'} };
266 if ( $styles =~ /\b$flag\b/ )
268 my $infoline = "Attention: Removing from collector: $oneitem->{'Name'} !\n";
269 push( @installer::globals::logfileinfo, $infoline);
270 if ( $flag eq "BINARYTABLE_ONLY" ) { push(@installer::globals::binarytableonlyfiles, $oneitem); }
271 next;
273 push( @allitems, $oneitem );
276 return \@allitems;
279 ###########################################################
280 # Mechanism for simple installation without packing
281 ###########################################################
283 sub install_simple ($$$$$$)
285 my ($packagename, $languagestring, $directoriesarray, $filesarray, $linksarray, $unixlinksarray) = @_;
287 installer::logger::print_message( "... installing module $packagename ...\n" );
289 my $destdir = $installer::globals::destdir;
290 my @lines = ();
292 installer::logger::print_message( "DestDir: $destdir \n" );
293 installer::logger::print_message( "Rootpath: $installer::globals::rootpath \n" );
295 `mkdir -p $destdir` if $destdir ne "";
296 `mkdir -p $destdir$installer::globals::rootpath`;
298 # Create Directories
299 for ( my $i = 0; $i <= $#{$directoriesarray}; $i++ )
301 my $onedir = ${$directoriesarray}[$i];
302 my $dir = "";
304 if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; }
306 if ((!($dir =~ /\bPREDEFINED_/ )) || ( $dir =~ /\bPREDEFINED_PROGDIR\b/ ))
308 my $hostname = $onedir->{'HostName'};
310 # ignore '.' subdirectories
311 next if ( $hostname =~ m/\.$/ );
312 # remove './' from the path
313 $hostname =~ s/\.\///g;
315 # printf "mkdir $destdir$hostname\n";
316 mkdir $destdir . $hostname;
317 push @lines, "%dir " . $hostname . "\n";
321 for ( my $i = 0; $i <= $#{$filesarray}; $i++ )
323 my $onefile = ${$filesarray}[$i];
324 my $unixrights = $onefile->{'UnixRights'};
325 my $destination = $onefile->{'destination'};
326 my $sourcepath = $onefile->{'sourcepath'};
328 # This is necessary to install SDK that includes files with $ in its name
329 # Otherwise, the following shell commands does not work and the file list
330 # is not correct
331 $destination =~ s/\$\$/\$/;
332 $sourcepath =~ s/\$\$/\$/;
334 # remove './' from the path
335 $sourcepath =~ s/\.\///g;
336 $destination =~ s/\.\///g;
338 push @lines, "$destination\n";
339 if(-d "$destdir$destination"){
340 rmtree("$destdir$destination");
342 if(-e "$destdir$destination") {
343 unlink "$destdir$destination";
346 if ( -l "$sourcepath" ) {
347 symlink (readlink ("$sourcepath"), "$destdir$destination") || die "Can't symlink $destdir$destination -> " . readlink ("$sourcepath") . "$!";
349 elsif ( -d $sourcepath ) {
350 `mkdir -p "$destdir$destination"`;
352 else {
353 copy ("$sourcepath", "$destdir$destination") || die "Can't copy file: $sourcepath -> $destdir$destination $!";
354 my $sourcestat = stat($sourcepath);
355 utime ($sourcestat->atime, $sourcestat->mtime, "$destdir$destination");
356 chmod (oct($unixrights), "$destdir$destination") || die "Can't change permissions: $!";
358 push @lines, "$destination\n";
361 for ( my $i = 0; $i <= $#{$linksarray}; $i++ )
363 my $onelink = ${$linksarray}[$i];
364 my $destination = $onelink->{'destination'};
365 my $destinationfile = $onelink->{'destinationfile'};
367 if(-e "$destdir$destination") {
368 unlink "$destdir$destination";
370 symlink ("$destinationfile", "$destdir$destination") || die "Can't create symlink: $!";
371 push @lines, "$destination\n";
374 for ( my $i = 0; $i <= $#{$unixlinksarray}; $i++ )
376 my $onelink = ${$unixlinksarray}[$i];
377 my $target = $onelink->{'Target'};
378 my $destination = $onelink->{'destination'};
379 my $cmd = "mkdir -p '" . dirname($destdir . $destination) . "'";
380 system($cmd) && die "Failed to execute \"$cmd\"";
381 $cmd = "ln -sf '$target' '$destdir$destination'";
383 system($cmd) && die "Failed \"$cmd\"";
384 push @lines, "$destination\n";
387 if ( $destdir ne "" )
389 my $filelist;
390 my $fname = $installer::globals::destdir . "/$packagename";
391 open ($filelist, ">$fname") || die "Can't open $fname: $!";
392 print $filelist @lines;
393 close ($filelist);
398 ###########################################################
399 # Selecting langpack items
400 ###########################################################
402 sub select_langpack_items
404 my ( $itemsref, $itemname ) = @_;
406 installer::logger::include_header_into_logfile("Selecting RegistryItems for Language Packs");
408 my @itemsarray = ();
410 for ( my $i = 0; $i <= $#{$itemsref}; $i++ )
412 my $oneitem = ${$itemsref}[$i];
414 # Items with style "LANGUAGEPACK" have to be included into the patch
415 my $styles = "";
416 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
417 if (( $styles =~ /\bLANGUAGEPACK\b/ ) || ( $styles =~ /\bFORCELANGUAGEPACK\b/ )) { push(@itemsarray, $oneitem); }
420 return \@itemsarray;
423 ###########################################################
424 # Selecting helppack items
425 ###########################################################
427 sub select_helppack_items
429 my ( $itemsref, $itemname ) = @_;
431 installer::logger::include_header_into_logfile("Selecting RegistryItems for Help Packs");
433 my @itemsarray = ();
435 for ( my $i = 0; $i <= $#{$itemsref}; $i++ )
437 my $oneitem = ${$itemsref}[$i];
439 # Items with style "HELPPACK" have to be included into the patch
440 my $styles = "";
441 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
442 if (( $styles =~ /\bHELPPACK\b/ ) || ( $styles =~ /\bFORCEHELPPACK\b/ )) { push(@itemsarray, $oneitem); }
445 return \@itemsarray;
448 ###########################################################
449 # Replacing %-variables with the content
450 # of $allvariableshashref
451 ###########################################################
453 sub replace_variables_in_string
455 my ( $string, $variableshashref ) = @_;
457 if ( $string =~ /^.*\%\w+.*$/ )
459 my $key;
461 # we want to substitute FOO_BR before FOO to avoid floating _BR suffixes
462 foreach $key (sort { length ($b) <=> length ($a) } keys %{$variableshashref})
464 my $value = $variableshashref->{$key};
465 $key = "\%" . $key;
466 $string =~ s/\Q$key\E/$value/g;
470 return $string;
473 #################################################################
474 # Copying the files defined as ScpActions into the
475 # installation set.
476 #################################################################
478 sub put_scpactions_into_installset
480 my ($installdir) = @_;
482 installer::logger::include_header_into_logfile("Start: Copying scp action files into installation set");
484 for ( my $i = 0; $i <= $#installer::globals::allscpactions; $i++ )
486 my $onescpaction = $installer::globals::allscpactions[$i];
488 my $subdir = "";
489 if ( $onescpaction->{'Subdir'} ) { $subdir = $onescpaction->{'Subdir'}; }
491 if ( $onescpaction->{'Name'} eq "loader.exe" ) { next; } # do not copy this ScpAction loader
493 my $destdir = $installdir;
494 $destdir =~ s/\Q$installer::globals::separator\E\s*$//;
495 if ( $subdir ) { $destdir = $destdir . $installer::globals::separator . $subdir; }
497 my $sourcefile = $onescpaction->{'sourcepath'};
498 my $destfile = $destdir . $installer::globals::separator . $onescpaction->{'DestinationName'};
500 if (( $subdir =~ /\// ) || ( $subdir =~ /\\/ ))
502 installer::systemactions::create_directory_structure($destdir);
504 else
506 installer::systemactions::create_directory($destdir);
509 installer::systemactions::copy_one_file($sourcefile, $destfile);
511 if ( $onescpaction->{'UnixRights'} )
513 chmod oct($onescpaction->{'UnixRights'}), $destfile;
518 installer::logger::include_header_into_logfile("End: Copying scp action files into installation set");
522 #################################################################
523 # Collecting scp actions for all languages
524 #################################################################
526 sub collect_scpactions
528 my ($allscpactions) = @_;
530 for ( my $i = 0; $i <= $#{$allscpactions}; $i++ )
532 push(@installer::globals::allscpactions, ${$allscpactions}[$i]);
536 ###########################################################
537 # Adding additional variables into the variableshashref,
538 # that are defined in include files in the source tree. The
539 # names of the include files are stored in
540 # ADD_INCLUDE_FILES (comma separated list).
541 ###########################################################
543 sub add_variables_from_inc_to_hashref
545 my ($allvariables, $includepatharrayref) = @_;
547 my $infoline = "";
548 my $includefilelist = $allvariables->{'ADD_INCLUDE_FILES'} || "";
550 for my $includefilename (split /,\s*/, $includefilelist)
552 $includefilename =~ s/^\s*//;
553 $includefilename =~ s/\s*$//;
554 my $includefilenameref = $ENV{'SRCDIR'} . "/" . $includefilename;
555 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"); }
557 $infoline = "Including inc file: $includefilenameref \n";
558 push( @installer::globals::globallogfileinfo, $infoline);
560 my $includefile = installer::files::read_file($includefilenameref);
562 for ( my $j = 0; $j <= $#{$includefile}; $j++ )
564 # Analyzing all "key=value" lines
565 my $oneline = ${$includefile}[$j];
567 if ( $oneline =~ /^\s*(\S+)\s*\=\s*(.*?)\s*$/ ) # no white space allowed in key
569 my $key = $1;
570 my $value = $2;
571 $allvariables->{$key} = $value;
572 $infoline = "Setting of variable: $key = $value\n";
573 push( @installer::globals::globallogfileinfo, $infoline);
579 ##############################################
580 # Collecting all files from include paths
581 ##############################################
583 sub collect_all_files_from_includepaths
585 my ($patharrayref) = @_;
587 installer::logger::globallog("Reading all directories: Start");
588 installer::logger::print_message( "... reading include paths ...\n" );
589 # empty the global
591 @installer::globals::allincludepaths =();
592 my $infoline;
594 for ( my $i = 0; $i <= $#{$patharrayref}; $i++ )
596 my $includepath = ${$patharrayref}[$i];
597 installer::remover::remove_leading_and_ending_whitespaces(\$includepath);
599 if ( ! -d $includepath )
601 $infoline = "$includepath does not exist. (Can be removed from include path list?)\n";
602 push( @installer::globals::globallogfileinfo, $infoline);
603 next;
606 my @sourcefiles = ();
607 my $pathstring = "";
608 installer::systemactions::read_full_directory($includepath, $pathstring, \@sourcefiles);
610 if ( ! ( $#sourcefiles > -1 ))
612 $infoline = "$includepath is empty. (Can be removed from include path list?)\n";
613 push( @installer::globals::globallogfileinfo, $infoline);
615 else
617 my $number = $#sourcefiles + 1;
618 $infoline = "Directory $includepath contains $number files (including subdirs)\n";
619 push( @installer::globals::globallogfileinfo, $infoline);
621 my %allfileshash = ();
622 $allfileshash{'includepath'} = $includepath;
624 for ( my $j = 0; $j <= $#sourcefiles; $j++ )
626 $allfileshash{$sourcefiles[$j]} = 1;
629 push(@installer::globals::allincludepaths, \%allfileshash);
633 $installer::globals::include_paths_read = 1;
635 installer::logger::globallog("Reading all directories: End");
636 push( @installer::globals::globallogfileinfo, "\n");
639 ##############################################
640 # Searching for a file with the gid
641 ##############################################
643 sub find_file_by_id
645 my ( $filesref, $gid ) = @_;
647 my $foundfile = 0;
648 my $onefile;
650 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
652 $onefile = ${$filesref}[$i];
653 my $filegid = $onefile->{'gid'};
655 if ( $filegid eq $gid )
657 $foundfile = 1;
658 last;
662 if (! $foundfile ) { $onefile = ""; }
664 return $onefile;
667 #################################################
668 # Generating paths for cygwin (second version)
669 # This function generates smaller files for
670 #################################################
672 sub generate_cygwin_paths
674 my ($filesref) = @_;
676 installer::logger::include_timestamp_into_logfile("Starting generating cygwin paths");
678 my $infoline = "Generating cygwin paths (generate_cygwin_paths)\n";
679 push( @installer::globals::logfileinfo, $infoline);
681 my $max = 5000; # number of paths in one file
683 my @pathcollector = ();
684 my $startnumber = 0;
685 my $counter = 0;
687 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
689 my $line = ${$filesref}[$i]->{'sourcepath'} . "\n";
690 push(@pathcollector, $line);
691 $counter++;
693 if (( $i == $#{$filesref} ) || ((( $counter % $max ) == 0 ) && ( $i > 0 )))
695 my $tmpfilename = "cygwinhelper_" . $i . ".txt";
696 my $temppath = $installer::globals::temppath;
697 $temppath =~ s/\Q$installer::globals::separator\E\s*$//;
698 $tmpfilename = $temppath . $installer::globals::separator . $tmpfilename;
699 $infoline = "Creating temporary file for cygwin conversion: $tmpfilename (contains $counter paths)\n";
700 push( @installer::globals::logfileinfo, $infoline);
701 if ( -f $tmpfilename ) { unlink $tmpfilename; }
703 installer::files::save_file($tmpfilename, \@pathcollector);
705 my $success = 0;
706 my @cyg_sourcepathlist = qx{cygpath -w -f "$tmpfilename"};
707 chomp @cyg_sourcepathlist;
709 # Validating the array, it has to contain the correct number of values
710 my $new_paths = $#cyg_sourcepathlist + 1;
711 if ( $new_paths == $counter ) { $success = 1; }
713 if ($success)
715 $infoline = "Success: Successfully converted to cygwin paths!\n";
716 push( @installer::globals::logfileinfo, $infoline);
718 else
720 $infoline = "ERROR: Failed to convert to cygwin paths!\n";
721 push( @installer::globals::logfileinfo, $infoline);
722 installer::exiter::exit_program("ERROR: Failed to convert to cygwin paths!", "generate_cygwin_paths");
725 for ( my $j = 0; $j <= $#cyg_sourcepathlist; $j++ )
727 my $number = $startnumber + $j;
728 ${$filesref}[$number]->{'cyg_sourcepath'} = $cyg_sourcepathlist[$j];
731 if ( -f $tmpfilename ) { unlink $tmpfilename; }
733 @pathcollector = ();
734 $startnumber = $startnumber + $max;
735 $counter = 0;
739 # Checking existence of cyg_sourcepath for every file
740 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
742 if (( ! exists(${$filesref}[$i]->{'cyg_sourcepath'}) ) || ( ${$filesref}[$i]->{'cyg_sourcepath'} eq "" ))
744 $infoline = "ERROR: No cygwin sourcepath defined for file ${$filesref}[$i]->{'sourcepath'}\n";
745 push( @installer::globals::logfileinfo, $infoline);
746 installer::exiter::exit_program("ERROR: No cygwin sourcepath defined for file ${$filesref}[$i]->{'sourcepath'}!", "generate_cygwin_paths");
750 installer::logger::include_timestamp_into_logfile("Ending generating cygwin paths");
753 ######################################################
754 # Getting the first entry from a list of languages
755 ######################################################
757 sub get_first_from_list
759 my ( $list ) = @_;
761 my $first = $list;
763 if ( $list =~ /^\s*(.+?),(.+)\s*$/) # "?" for minimal matching
765 $first = $1;
768 return $first;
771 ################################################
772 # Setting all spellchecker languages
773 ################################################
775 sub set_spellcheckerlanguages
777 my ( $productlanguagesarrayref, $allvariables ) = @_;
779 my %productlanguages = ();
780 for ( my $i = 0; $i <= $#{$productlanguagesarrayref}; $i++ ) { $productlanguages{${$productlanguagesarrayref}[$i]} = 1; }
782 my $spellcheckfilename = $allvariables->{'SPELLCHECKERFILE'};
784 my $spellcheckfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$spellcheckfilename, "", 1);
786 if ($$spellcheckfileref eq "") { installer::exiter::exit_program("ERROR: Could not find $spellcheckfilename!", "set_spellcheckerlanguages"); }
788 my $infoline = "Using spellchecker file: $$spellcheckfileref \n";
789 push( @installer::globals::globallogfileinfo, $infoline);
791 my $spellcheckfile = installer::files::read_file($$spellcheckfileref);
792 my %spellcheckhash = ();
794 for ( my $j = 0; $j <= $#{$spellcheckfile}; $j++ )
796 # Analyzing all "key=value" lines
797 my $oneline = ${$spellcheckfile}[$j];
799 if ( $oneline =~ /^\s*(\S+)\s*\=\s*\"(.*?)\"\s*$/ ) # no white space allowed in key
801 my $onelang = $1;
802 my $languagelist = $2;
804 # Special handling for language packs. Only include the first language of the language list.
805 # If no spellchecker shall be included, the keyword "EMPTY" can be used.
807 if ( $installer::globals::languagepack )
809 my $first = get_first_from_list($languagelist);
811 if ( $first eq "EMPTY" ) # no spellchecker into language pack
813 $languagelist = "";
815 else
817 $languagelist = $first;
820 else # no language pack, so EMPTY is not required
822 $languagelist =~ s/^\s*EMPTY\s*,//; # removing the entry EMPTY
825 $spellcheckhash{$onelang} = $languagelist;
829 # Collecting all required languages in %installer::globals::spellcheckerlanguagehash
831 foreach my $lang (keys %productlanguages)
833 my $languagelist = "";
834 if ( exists($spellcheckhash{$lang}) ) { $languagelist = $spellcheckhash{$lang}; }
835 else { $languagelist = ""; } # no dictionary unless defined in SPELLCHECKERFILE
837 my $langlisthash = installer::converter::convert_stringlist_into_hash(\$languagelist, ",");
838 foreach my $onelang ( keys %{$langlisthash} ) { $installer::globals::spellcheckerlanguagehash{$onelang} = 1; }
841 $installer::globals::analyze_spellcheckerlanguage = 1;
843 # Logging
845 my $langstring = "";
846 foreach my $lang (sort keys %installer::globals::spellcheckerlanguagehash) { $langstring = $langstring . "," . $lang }
847 $langstring =~ s/^\s*,//;
849 $infoline = "Collected spellchecker languages for spellchecker: $langstring \n";
850 push( @installer::globals::globallogfileinfo, $infoline);
853 ################################################
854 # Including a license text into setup script
855 ################################################
857 sub put_license_into_setup
859 my ($installdir, $includepatharrayref) = @_;
861 # find and read the license file
862 my $licenselanguage = "en-US"; # always english !
863 my $licensefilename = "license";
864 # my $licensefilename = "LICENSE" . ".txt";
865 my $licenseincludepatharrayref = get_language_specific_include_paths($includepatharrayref, $licenselanguage);
867 my $licenseref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, $licenseincludepatharrayref, 0);
868 if ($$licenseref eq "") { installer::exiter::exit_program("ERROR: Could not find License file $licensefilename!", "put_license_into_setup"); }
869 my $licensefile = installer::files::read_file($$licenseref);
871 # Read setup
872 my $setupfilename = $installdir . $installer::globals::separator . "setup";
873 my $setupfile = installer::files::read_file($setupfilename);
875 # Replacement
876 my $infoline = "Adding licensefile into setup script\n";
877 push( @installer::globals::logfileinfo, $infoline);
879 my $includestring = "";
880 for ( my $i = 0; $i <= $#{$licensefile}; $i++ ) { $includestring = $includestring . ${$licensefile}[$i]; }
881 for ( my $i = 0; $i <= $#{$setupfile}; $i++ ) { ${$setupfile}[$i] =~ s/LICENSEFILEPLACEHOLDER/$includestring/; }
883 # Write setup
884 installer::files::save_file($setupfilename, $setupfile);
887 #########################################################
888 # Collecting all pkgmap files from an installation set
889 #########################################################
891 sub collectpackagemaps
893 my ( $installdir, $languagestringref, $allvariables ) = @_;
895 installer::logger::include_header_into_logfile("Collecting all packagemaps (pkgmap):");
897 my $pkgmapdir = installer::systemactions::create_directories("pkgmap", $languagestringref);
898 my $subdirname = $allvariables->{'UNIXPRODUCTNAME'} . "_pkgmaps";
899 my $pkgmapsubdir = $pkgmapdir . $installer::globals::separator . $subdirname;
900 if ( -d $pkgmapsubdir ) { installer::systemactions::remove_complete_directory($pkgmapsubdir); }
901 if ( ! -d $pkgmapsubdir ) { installer::systemactions::create_directory($pkgmapsubdir); }
903 $installdir =~ s/\/\s*$//;
904 # Collecting all packages in $installdir and its sub package ("packages")
905 my $searchdir = $installdir . $installer::globals::separator . $installer::globals::epmoutpath;
907 my $allpackages = installer::systemactions::get_all_directories_without_path($searchdir);
909 for ( my $i = 0; $i <= $#{$allpackages}; $i++ )
911 my $pkgmapfile = $searchdir . $installer::globals::separator . ${$allpackages}[$i] . $installer::globals::separator . "pkgmap";
912 my $destfilename = $pkgmapsubdir . $installer::globals::separator . ${$allpackages}[$i] . "_pkgmap";
913 installer::systemactions::copy_one_file($pkgmapfile, $destfilename);
916 # Create a tar gz file with all package maps
917 my $tarfilename = $subdirname . ".tar";
918 my $targzname = $tarfilename . ".gz";
919 my $systemcall = "cd $pkgmapdir; tar -cf - $subdirname | $installer::globals::packertool > $targzname";
920 installer::systemactions::make_systemcall($systemcall);
921 installer::systemactions::remove_complete_directory($pkgmapsubdir, 1);