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
;
24 use File
::Temp
qw(tmpnam);
26 use installer
::control
;
27 use installer
::converter
;
28 use installer
::exiter
;
30 use installer
::globals
;
31 use installer
::logger
;
32 use installer
::pathanalyzer
;
33 use installer
::scpzipfiles
;
34 use installer
::scriptitems
;
35 use installer
::systemactions
;
36 use installer
::windows
::language
;
38 #########################################
39 # Saving the patchlist file
40 #########################################
42 sub _save_patchlist_file
44 my ($installlogdir, $patchlistfilename) = @_;
46 my $installpatchlistdir = installer
::systemactions
::create_directory_next_to_directory
($installlogdir, "patchlist");
47 $patchlistfilename =~ s/log\_/patchfiles\_/;
48 $patchlistfilename =~ s/\.log/\.txt/;
49 installer
::files
::save_file
($installpatchlistdir . $installer::globals
::separator
. $patchlistfilename, \
@installer::globals
::patchfilecollector
);
50 installer
::logger
::print_message
( "... creating patchlist file $patchlistfilename \n" );
54 ###############################################################
55 # Removing all directories of a special language
56 # in the directory $basedir
57 ###############################################################
59 sub remove_old_installation_sets
63 installer
::logger
::print_message
( "... removing old installation directories ...\n" );
65 my $removedir = $basedir;
67 if ( -d
$removedir ) { installer
::systemactions
::remove_complete_directory
($removedir, 1); }
69 # looking for non successful old installation sets
71 $removedir = $basedir . "_witherror";
72 if ( -d
$removedir ) { installer
::systemactions
::remove_complete_directory
($removedir, 1); }
74 $removedir = $basedir . "_inprogress";
75 if ( -d
$removedir ) { installer
::systemactions
::remove_complete_directory
($removedir, 1); }
77 # finally the $basedir can be created empty
79 if ( $installer::globals
::localinstalldirset
) { installer
::systemactions
::create_directory_structure
($basedir); }
81 installer
::systemactions
::create_directory
($basedir);
84 ###############################################################
85 # Creating the installation directory structure
86 ###############################################################
88 sub create_installation_directory
90 my ($shipinstalldir, $languagestringref, $current_install_number_ref) = @_;
94 my $languageref = $languagestringref;
96 $installdir = installer
::systemactions
::create_directories
("install", $languageref);
97 installer
::logger
::print_message
( "... creating installation set in $installdir ...\n" );
98 remove_old_installation_sets
($installdir);
99 my $inprogressinstalldir = $installdir . "_inprogress";
100 installer
::systemactions
::rename_directory
($installdir, $inprogressinstalldir);
101 $installdir = $inprogressinstalldir;
103 $installer::globals
::saveinstalldir
= $installdir; # saving directory globally, in case of exiting
108 ###############################################################
109 # Analyzing and creating the log file
110 ###############################################################
112 sub analyze_and_save_logfile
114 my ($loggingdir, $installdir, $installlogdir, $allsettingsarrayref, $languagestringref, $current_install_number) = @_;
117 my $finalinstalldir = "";
119 installer
::logger
::print_message
( "... checking log file " . $loggingdir . $installer::globals
::logfilename
. "\n" );
121 my $contains_error = installer
::control
::check_logfile
(\
@installer::globals
::logfileinfo
);
123 # Dependent from the success, the installation directory can be renamed.
125 if ( $contains_error )
127 my $errordir = installer
::systemactions
::rename_string_in_directory
($installdir, "_inprogress", "_witherror");
128 # Error output to STDERR
129 for ( my $j = 0; $j <= $#installer::globals
::errorlogfileinfo
; $j++ )
131 my $line = $installer::globals
::errorlogfileinfo
[$j];
133 installer
::logger
::print_error
( $line );
137 $finalinstalldir = $errordir;
143 $destdir = installer
::systemactions
::rename_string_in_directory
($installdir, "_inprogress", "");
145 $finalinstalldir = $destdir;
148 # Saving the logfile in the log file directory and additionally in a log directory in the install directory
150 my $numberedlogfilename = $installer::globals
::logfilename
;
151 installer
::logger
::print_message
( "... creating log file $numberedlogfilename \n" );
152 installer
::files
::save_file
($loggingdir . $numberedlogfilename, \
@installer::globals
::logfileinfo
);
153 installer
::files
::save_file
($installlogdir . $installer::globals
::separator
. $numberedlogfilename, \
@installer::globals
::logfileinfo
);
155 # Saving the list of patchfiles in a patchlist directory in the install directory
156 if ( $installer::globals
::creating_windows_installer_patch
) { _save_patchlist_file
($installlogdir, $numberedlogfilename); }
158 if ( $installer::globals
::creating_windows_installer_patch
) { $installer::globals
::creating_windows_installer_patch
= 0; }
160 # Exiting the packaging process, if an error occurred.
161 # This is important, to get an error code "-1", if an error was found in the log file,
162 # that did not break the packaging process
164 if ( ! $is_success) { installer
::exiter
::exit_program
("ERROR: Found an error in the logfile. Packaging failed.", "analyze_and_save_logfile"); }
166 return ($is_success, $finalinstalldir);
169 ###############################################################
170 # Removing all directories that are saved in the
171 # global directory @installer::globals::removedirs
172 ###############################################################
174 sub clean_output_tree
176 installer
::logger
::print_message
( "... cleaning the output tree ...\n" );
178 for ( my $i = 0; $i <= $#installer::globals
::removedirs
; $i++ )
180 if ( -d
$installer::globals
::removedirs
[$i] )
182 installer
::logger
::print_message
( "... removing directory $installer::globals::removedirs[$i] ...\n" );
183 installer
::systemactions
::remove_complete_directory
($installer::globals
::removedirs
[$i], 1);
187 # Last try to remove the ship test directory
189 if ( $installer::globals
::shiptestdirectory
)
191 if ( -d
$installer::globals
::shiptestdirectory
)
193 my $infoline = "Last try to remove $installer::globals::shiptestdirectory . \n";
194 push(@installer::globals
::logfileinfo
, $infoline);
195 my $systemcall = "rmdir $installer::globals::shiptestdirectory";
196 my $returnvalue = system($systemcall);
201 ###########################################################
202 # Setting one language in the language independent
203 # array of include paths with $(LANG)
204 ###########################################################
206 sub get_language_specific_include_paths
208 my ( $patharrayref, $onelanguage ) = @_;
212 for ( my $i = 0; $i <= $#{$patharrayref}; $i++ )
214 my $line = ${$patharrayref}[$i];
215 $line =~ s/\$\(LANG\)/$onelanguage/g;
216 push(@patharray ,$line);
222 ##############################################################
223 # Collecting all items with a defined flag
224 ##############################################################
226 sub collect_all_items_with_special_flag
228 my ($itemsref, $flag) = @_;
232 for ( my $i = 0; $i <= $#{$itemsref}; $i++ )
234 my $oneitem = ${$itemsref}[$i];
236 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'} };
238 if ( $styles =~ /\b$flag\b/ )
240 push( @allitems, $oneitem );
247 ##############################################################
248 # Collecting all items without a defined flag
249 ##############################################################
251 sub collect_all_items_without_special_flag
253 my ($itemsref, $flag) = @_;
257 for ( my $i = 0; $i <= $#{$itemsref}; $i++ )
259 my $oneitem = ${$itemsref}[$i];
261 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'} };
263 if ( !( $styles =~ /\b$flag\b/ ))
265 push( @allitems, $oneitem );
272 ##############################################################
273 # Removing all items with a defined flag from collector
274 ##############################################################
276 sub remove_all_items_with_special_flag
278 my ($itemsref, $flag) = @_;
282 for ( my $i = 0; $i <= $#{$itemsref}; $i++ )
284 my $oneitem = ${$itemsref}[$i];
286 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'} };
287 if ( $styles =~ /\b$flag\b/ )
289 my $infoline = "Attention: Removing from collector: $oneitem->{'Name'} !\n";
290 push( @installer::globals
::logfileinfo
, $infoline);
291 if ( $flag eq "BINARYTABLE_ONLY" ) { push(@installer::globals
::binarytableonlyfiles
, $oneitem); }
294 push( @allitems, $oneitem );
300 ###########################################################
301 # Mechanism for simple installation without packing
302 ###########################################################
304 sub install_simple
($$$$$$)
306 my ($packagename, $languagestring, $directoriesarray, $filesarray, $linksarray, $unixlinksarray) = @_;
308 installer
::logger
::print_message
( "... installing module $packagename ...\n" );
310 my $destdir = $installer::globals
::destdir
;
313 installer
::logger
::print_message
( "DestDir: $destdir \n" );
314 installer
::logger
::print_message
( "Rootpath: $installer::globals::rootpath \n" );
316 `mkdir -p $destdir` if $destdir ne "";
317 `mkdir -p $destdir$installer::globals::rootpath`;
320 for ( my $i = 0; $i <= $#{$directoriesarray}; $i++ )
322 my $onedir = ${$directoriesarray}[$i];
325 if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; }
327 if ((!($dir =~ /\bPREDEFINED_/ )) || ( $dir =~ /\bPREDEFINED_PROGDIR\b/ ))
329 my $hostname = $onedir->{'HostName'};
331 # ignore '.' subdirectories
332 next if ( $hostname =~ m/\.$/ );
333 # remove './' from the path
334 $hostname =~ s/\.\///g
;
336 # printf "mkdir $destdir$hostname\n";
337 mkdir $destdir . $hostname;
338 push @lines, "%dir " . $hostname . "\n";
342 for ( my $i = 0; $i <= $#{$filesarray}; $i++ )
344 my $onefile = ${$filesarray}[$i];
345 my $unixrights = $onefile->{'UnixRights'};
346 my $destination = $onefile->{'destination'};
347 my $sourcepath = $onefile->{'sourcepath'};
349 # This is necessary to install SDK that includes files with $ in its name
350 # Otherwise, the following shell commands does not work and the file list
352 $destination =~ s/\$\$/\$/;
353 $sourcepath =~ s/\$\$/\$/;
355 # remove './' from the path
356 $sourcepath =~ s/\.\///g
;
357 $destination =~ s/\.\///g
;
359 push @lines, "$destination\n";
360 if(-d
"$destdir$destination"){
361 rmtree
("$destdir$destination");
363 if(-e
"$destdir$destination") {
364 unlink "$destdir$destination";
367 if ( -l
"$sourcepath" ) {
368 symlink (readlink ("$sourcepath"), "$destdir$destination") || die "Can't symlink $destdir$destination -> " . readlink ("$sourcepath") . "$!";
371 copy
("$sourcepath", "$destdir$destination") || die "Can't copy file: $sourcepath -> $destdir$destination $!";
372 my $sourcestat = stat($sourcepath);
373 utime ($sourcestat->atime, $sourcestat->mtime, "$destdir$destination");
374 chmod (oct($unixrights), "$destdir$destination") || die "Can't change permissions: $!";
376 push @lines, "$destination\n";
379 for ( my $i = 0; $i <= $#{$linksarray}; $i++ )
381 my $onelink = ${$linksarray}[$i];
382 my $destination = $onelink->{'destination'};
383 my $destinationfile = $onelink->{'destinationfile'};
385 if(-e
"$destdir$destination") {
386 unlink "$destdir$destination";
388 symlink ("$destinationfile", "$destdir$destination") || die "Can't create symlink: $!";
389 push @lines, "$destination\n";
392 for ( my $i = 0; $i <= $#{$unixlinksarray}; $i++ )
394 my $onelink = ${$unixlinksarray}[$i];
395 my $target = $onelink->{'Target'};
396 my $destination = $onelink->{'destination'};
397 my $cmd = "ln -sf '$target' '$destdir$destination'";
399 system($cmd) && die "Failed \"$cmd\"";
400 push @lines, "$destination\n";
403 if ( $destdir ne "" )
406 my $fname = $installer::globals
::destdir
. "/$packagename";
407 open ($filelist, ">$fname") || die "Can't open $fname: $!";
408 print $filelist @lines;
414 ###########################################################
415 # Selecting langpack items
416 ###########################################################
418 sub select_langpack_items
420 my ( $itemsref, $itemname ) = @_;
422 installer
::logger
::include_header_into_logfile
("Selecting RegistryItems for Language Packs");
426 for ( my $i = 0; $i <= $#{$itemsref}; $i++ )
428 my $oneitem = ${$itemsref}[$i];
430 # Items with style "LANGUAGEPACK" have to be included into the patch
432 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
433 if (( $styles =~ /\bLANGUAGEPACK\b/ ) || ( $styles =~ /\bFORCELANGUAGEPACK\b/ )) { push(@itemsarray, $oneitem); }
439 ###########################################################
440 # Selecting helppack items
441 ###########################################################
443 sub select_helppack_items
445 my ( $itemsref, $itemname ) = @_;
447 installer
::logger
::include_header_into_logfile
("Selecting RegistryItems for Help Packs");
451 for ( my $i = 0; $i <= $#{$itemsref}; $i++ )
453 my $oneitem = ${$itemsref}[$i];
455 # Items with style "HELPPACK" have to be included into the patch
457 if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
458 if (( $styles =~ /\bHELPPACK\b/ ) || ( $styles =~ /\bFORCEHELPPACK\b/ )) { push(@itemsarray, $oneitem); }
464 ###########################################################
465 # Replacing %-variables with the content
466 # of $allvariableshashref
467 ###########################################################
469 sub replace_variables_in_string
471 my ( $string, $variableshashref ) = @_;
473 if ( $string =~ /^.*\%\w+.*$/ )
477 # we want to substitute FOO_BR before FOO to avoid floating _BR suffixes
478 foreach $key (sort { length ($b) <=> length ($a) } keys %{$variableshashref})
480 my $value = $variableshashref->{$key};
482 $string =~ s/\Q$key\E/$value/g;
489 #################################################################
490 # Copying the files defined as ScpActions into the
492 #################################################################
494 sub put_scpactions_into_installset
496 my ($installdir) = @_;
498 installer
::logger
::include_header_into_logfile
("Start: Copying scp action files into installation set");
500 for ( my $i = 0; $i <= $#installer::globals
::allscpactions
; $i++ )
502 my $onescpaction = $installer::globals
::allscpactions
[$i];
505 if ( $onescpaction->{'Subdir'} ) { $subdir = $onescpaction->{'Subdir'}; }
507 if ( $onescpaction->{'Name'} eq "loader.exe" ) { next; } # do not copy this ScpAction loader
509 my $destdir = $installdir;
510 $destdir =~ s/\Q$installer::globals::separator\E\s*$//;
511 if ( $subdir ) { $destdir = $destdir . $installer::globals
::separator
. $subdir; }
513 my $sourcefile = $onescpaction->{'sourcepath'};
514 my $destfile = $destdir . $installer::globals
::separator
. $onescpaction->{'DestinationName'};
517 if ( $onescpaction->{'Styles'} ) { $styles = $onescpaction->{'Styles'}; }
518 if (( $styles =~ /\bFILE_CAN_MISS\b/ ) && ( $sourcefile eq "" )) { next; }
520 if (( $subdir =~ /\// ) || ( $subdir =~ /\\/ ))
522 installer
::systemactions
::create_directory_structure
($destdir);
526 installer
::systemactions
::create_directory
($destdir);
529 installer
::systemactions
::copy_one_file
($sourcefile, $destfile);
531 if ( $onescpaction->{'UnixRights'} )
533 chmod oct($onescpaction->{'UnixRights'}), $destfile;
538 installer
::logger
::include_header_into_logfile
("End: Copying scp action files into installation set");
542 #################################################################
543 # Collecting scp actions for all languages
544 #################################################################
546 sub collect_scpactions
548 my ($allscpactions) = @_;
550 for ( my $i = 0; $i <= $#{$allscpactions}; $i++ )
552 push(@installer::globals
::allscpactions
, ${$allscpactions}[$i]);
556 ###########################################################
557 # Adding additional variables into the variableshashref,
558 # that are defined in include files in the solver. The
559 # names of the include files are stored in
560 # ADD_INCLUDE_FILES (comma separated list).
561 ###########################################################
563 sub add_variables_from_inc_to_hashref
565 my ($allvariables, $includepatharrayref) = @_;
568 my $includefilelist = $allvariables->{'ADD_INCLUDE_FILES'} || "";
570 for my $includefilename (split /,\s*/, $includefilelist)
572 $includefilename =~ s/^\s*//;
573 $includefilename =~ s/\s*$//;
574 $includefilenameref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$includefilename, $includepatharrayref, 1);
575 if ( $$includefilenameref eq "" ) { installer
::exiter
::exit_program
("Include file $includefilename not found!\nADD_INCLUDE_FILES = $allvariables->{'ADD_INCLUDE_FILES'}", "add_variables_from_inc_to_hashref"); }
577 $infoline = "Including inc file: $$includefilenameref \n";
578 push( @installer::globals
::globallogfileinfo
, $infoline);
580 my $includefile = installer
::files
::read_file
($$includefilenameref);
582 for ( my $j = 0; $j <= $#{$includefile}; $j++ )
584 # Analyzing all "key=value" lines
585 my $oneline = ${$includefile}[$j];
587 if ( $oneline =~ /^\s*(\S+)\s*\=\s*(.*?)\s*$/ ) # no white space allowed in key
591 $allvariables->{$key} = $value;
592 $infoline = "Setting of variable: $key = $value\n";
593 push( @installer::globals
::globallogfileinfo
, $infoline);
599 ##############################################
600 # Collecting all files from include paths
601 ##############################################
603 sub collect_all_files_from_includepaths
605 my ($patharrayref) = @_;
607 installer
::logger
::globallog
("Reading all directories: Start");
608 installer
::logger
::print_message
( "... reading include paths ...\n" );
611 @installer::globals
::allincludepaths
=();
614 for ( my $i = 0; $i <= $#{$patharrayref}; $i++ )
616 $includepath = ${$patharrayref}[$i];
617 installer
::remover
::remove_leading_and_ending_whitespaces
(\
$includepath);
619 if ( ! -d
$includepath )
621 $infoline = "$includepath does not exist. (Can be removed from include path list?)\n";
622 push( @installer::globals
::globallogfileinfo
, $infoline);
626 my @sourcefiles = ();
628 installer
::systemactions
::read_full_directory
($includepath, $pathstring, \
@sourcefiles);
630 if ( ! ( $#sourcefiles > -1 ))
632 $infoline = "$includepath is empty. (Can be removed from include path list?)\n";
633 push( @installer::globals
::globallogfileinfo
, $infoline);
637 my $number = $#sourcefiles + 1;
638 $infoline = "Directory $includepath contains $number files (including subdirs)\n";
639 push( @installer::globals
::globallogfileinfo
, $infoline);
641 my %allfileshash = ();
642 $allfileshash{'includepath'} = $includepath;
644 for ( my $j = 0; $j <= $#sourcefiles; $j++ )
646 $allfileshash{$sourcefiles[$j]} = 1;
649 push(@installer::globals
::allincludepaths
, \
%allfileshash);
653 $installer::globals
::include_paths_read
= 1;
655 installer
::logger
::globallog
("Reading all directories: End");
656 push( @installer::globals
::globallogfileinfo
, "\n");
659 ##############################################
660 # Searching for a file with the gid
661 ##############################################
665 my ( $filesref, $gid ) = @_;
670 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
672 $onefile = ${$filesref}[$i];
673 my $filegid = $onefile->{'gid'};
675 if ( $filegid eq $gid )
682 if (! $foundfile ) { $onefile = ""; }
687 #################################################
688 # Generating paths for cygwin (second version)
689 # This function generates smaller files for
690 #################################################
692 sub generate_cygwin_paths
696 installer
::logger
::include_timestamp_into_logfile
("Starting generating cygwin paths");
698 my $infoline = "Generating cygwin paths (generate_cygwin_paths)\n";
699 push( @installer::globals
::logfileinfo
, $infoline);
701 my $max = 5000; # number of paths in one file
703 my @pathcollector = ();
707 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
709 my $line = ${$filesref}[$i]->{'sourcepath'} . "\n";
710 push(@pathcollector, $line);
713 if (( $i == $#{$filesref} ) || ((( $counter % $max ) == 0 ) && ( $i > 0 )))
715 my $tmpfilename = "cygwinhelper_" . $i . ".txt";
716 my $temppath = $installer::globals
::temppath
;
717 $temppath =~ s/\Q$installer::globals::separator\E\s*$//;
718 $tmpfilename = $temppath . $installer::globals
::separator
. $tmpfilename;
719 $infoline = "Creating temporary file for cygwin conversion: $tmpfilename (contains $counter paths)\n";
720 push( @installer::globals
::logfileinfo
, $infoline);
721 if ( -f
$tmpfilename ) { unlink $tmpfilename; }
723 installer
::files
::save_file
($tmpfilename, \
@pathcollector);
726 my @cyg_sourcepathlist = qx{cygpath
-w
-f
"$tmpfilename"};
727 chomp @cyg_sourcepathlist;
729 # Validating the array, it has to contain the correct number of values
730 my $new_paths = $#cyg_sourcepathlist + 1;
731 if ( $new_paths == $counter ) { $success = 1; }
735 $infoline = "Success: Successfully converted to cygwin paths!\n";
736 push( @installer::globals
::logfileinfo
, $infoline);
740 $infoline = "ERROR: Failed to convert to cygwin paths!\n";
741 push( @installer::globals
::logfileinfo
, $infoline);
742 installer
::exiter
::exit_program
("ERROR: Failed to convert to cygwin paths!", "generate_cygwin_paths");
745 for ( my $j = 0; $j <= $#cyg_sourcepathlist; $j++ )
747 my $number = $startnumber + $j;
748 ${$filesref}[$number]->{'cyg_sourcepath'} = $cyg_sourcepathlist[$j];
751 if ( -f
$tmpfilename ) { unlink $tmpfilename; }
754 $startnumber = $startnumber + $max;
759 # Checking existence fo cyg_sourcepath for every file
760 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
762 if (( ! exists(${$filesref}[$i]->{'cyg_sourcepath'}) ) || ( ${$filesref}[$i]->{'cyg_sourcepath'} eq "" ))
764 $infoline = "ERROR: No cygwin sourcepath defined for file ${$filesref}[$i]->{'sourcepath'}\n";
765 push( @installer::globals
::logfileinfo
, $infoline);
766 installer
::exiter
::exit_program
("ERROR: No cygwin sourcepath defined for file ${$filesref}[$i]->{'sourcepath'}!", "generate_cygwin_paths");
770 installer
::logger
::include_timestamp_into_logfile
("Ending generating cygwin paths");
773 ################################################
774 # Files with flag HIDDEN get a dot at the
775 # beginning of the file name. This cannot be
776 # defined in scp2 project, because tooling
777 # cannot handle files with beginning dot
779 ################################################
781 sub resolving_hidden_flag
783 my ($filesarrayref, $variableshashref, $item, $languagestringref) = @_;
785 my $diritem = lc($item);
788 my $hiddendirbase = installer
::systemactions
::create_directories
("hidden_$diritem", $languagestringref);
790 installer
::logger
::include_header_into_logfile
("$item with flag HIDDEN:");
792 for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
794 my $onefile = ${$filesarrayref}[$i];
797 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
799 if ( $styles =~ /\bHIDDEN\b/ )
801 # Language specific subdirectory
803 my $onelanguage = $onefile->{'specificlanguage'};
805 if ($onelanguage eq "")
807 $onelanguage = "00"; # files without language into directory "00"
810 my $hiddendir = $hiddendirbase . $installer::globals
::separator
. $onelanguage . $installer::globals
::separator
;
811 installer
::systemactions
::create_directory
($hiddendir); # creating language specific directories
813 # copy files and edit them with the variables defined in the zip.lst
815 my $onefilename = $onefile->{'Name'};
816 my $newfilename = "\." . $onefilename;
817 my $sourcefile = $onefile->{'sourcepath'};
818 my $destfile = $hiddendir . $newfilename;
820 my $copysuccess = installer
::systemactions
::copy_one_file
($sourcefile, $destfile);
824 $onefile->{'sourcepath'} = $destfile;
825 $destination = $onefile->{'destination'};
826 installer
::pathanalyzer
::get_path_from_fullqualifiedname
(\
$destination);
827 if ( $destination eq "" ) { $onefile->{'destination'} = $newfilename; }
828 else { $onefile->{'destination'} = $destination . $installer::globals
::separator
. $newfilename; }
830 $infoline = "Success: Using file with flag HIDDEN from \"$onefile->{'sourcepath'}\"!\n";
831 push( @installer::globals
::logfileinfo
, $infoline);
835 $infoline = "Error: Failed to copy HIDDEN file from \"$sourcefile\" to \"$destfile\"!\n";
836 push( @installer::globals
::logfileinfo
, $infoline);
842 push( @installer::globals
::logfileinfo
, $infoline);
845 ######################################################
846 # Getting the first entry from a list of languages
847 ######################################################
849 sub get_first_from_list
855 if ( $list =~ /^\s*(.+?),(.+)\s*$/) # "?" for minimal matching
863 ################################################
864 # Setting all spellchecker languages
865 ################################################
867 sub set_spellcheckerlanguages
869 my ( $productlanguagesarrayref, $allvariables ) = @_;
871 my %productlanguages = ();
872 for ( my $i = 0; $i <= $#{$productlanguagesarrayref}; $i++ ) { $productlanguages{${$productlanguagesarrayref}[$i]} = 1; }
874 my $spellcheckfilename = $allvariables->{'SPELLCHECKERFILE'};
876 my $spellcheckfileref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$spellcheckfilename, "", 1);
878 if ($$spellcheckfileref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find $spellcheckfilename!", "set_spellcheckerlanguages"); }
880 my $infoline = "Using spellchecker file: $$spellcheckfileref \n";
881 push( @installer::globals
::globallogfileinfo
, $infoline);
883 my $spellcheckfile = installer
::files
::read_file
($$spellcheckfileref);
884 my %spellcheckhash = ();
886 for ( my $j = 0; $j <= $#{$spellcheckfile}; $j++ )
888 # Analyzing all "key=value" lines
889 my $oneline = ${$spellcheckfile}[$j];
891 if ( $oneline =~ /^\s*(\S+)\s*\=\s*\"(.*?)\"\s*$/ ) # no white space allowed in key
894 my $languagelist = $2;
896 # Special handling for language packs. Only include the first language of the language list.
897 # If no spellchecker shall be included, the keyword "EMPTY" can be used.
899 if ( $installer::globals
::languagepack
)
901 my $first = get_first_from_list
($languagelist);
903 if ( $first eq "EMPTY" ) # no spellchecker into language pack
909 $languagelist = $first;
912 else # no language pack, so EMPTY is not required
914 $languagelist =~ s/^\s*EMPTY\s*,//; # removing the entry EMPTY
917 $spellcheckhash{$onelang} = $languagelist;
921 # Collecting all required languages in %installer::globals::spellcheckerlanguagehash
923 foreach my $lang (keys %productlanguages)
925 my $languagelist = "";
926 if ( exists($spellcheckhash{$lang}) ) { $languagelist = $spellcheckhash{$lang}; }
927 else { $languagelist = ""; } # no dictionary unless defined in SPELLCHECKERFILE
929 my $langlisthash = installer
::converter
::convert_stringlist_into_hash
(\
$languagelist, ",");
930 foreach my $onelang ( keys %{$langlisthash} ) { $installer::globals
::spellcheckerlanguagehash
{$onelang} = 1; }
933 $installer::globals
::analyze_spellcheckerlanguage
= 1;
938 foreach my $lang (sort keys %installer::globals
::spellcheckerlanguagehash
) { $langstring = $langstring . "," . $lang }
939 $langstring =~ s/^\s*,//;
941 $infoline = "Collected spellchecker languages for spellchecker: $langstring \n";
942 push( @installer::globals
::globallogfileinfo
, $infoline);
945 ################################################
946 # Including a license text into setup script
947 ################################################
949 sub put_license_into_setup
951 my ($installdir, $includepatharrayref) = @_;
953 # find and read the license file
954 my $licenselanguage = "en-US"; # always english !
955 my $licensefilename = "license";
956 # my $licensefilename = "LICENSE" . ".txt";
957 my $licenseincludepatharrayref = get_language_specific_include_paths
($includepatharrayref, $licenselanguage);
959 my $licenseref = installer
::scriptitems
::get_sourcepath_from_filename_and_includepath
(\
$licensefilename, $licenseincludepatharrayref, 0);
960 if ($$licenseref eq "") { installer
::exiter
::exit_program
("ERROR: Could not find License file $licensefilename!", "put_license_into_setup"); }
961 my $licensefile = installer
::files
::read_file
($$licenseref);
964 my $setupfilename = $installdir . $installer::globals
::separator
. "setup";
965 my $setupfile = installer
::files
::read_file
($setupfilename);
968 my $infoline = "Adding licensefile into setup script\n";
969 push( @installer::globals
::logfileinfo
, $infoline);
971 my $includestring = "";
972 for ( my $i = 0; $i <= $#{$licensefile}; $i++ ) { $includestring = $includestring . ${$licensefile}[$i]; }
973 for ( my $i = 0; $i <= $#{$setupfile}; $i++ ) { ${$setupfile}[$i] =~ s/LICENSEFILEPLACEHOLDER/$includestring/; }
976 installer
::files
::save_file
($setupfilename, $setupfile);
979 #########################################################
980 # Collecting all pkgmap files from an installation set
981 #########################################################
983 sub collectpackagemaps
985 my ( $installdir, $languagestringref, $allvariables ) = @_;
987 installer
::logger
::include_header_into_logfile
("Collecing all packagemaps (pkgmap):");
989 my $pkgmapdir = installer
::systemactions
::create_directories
("pkgmap", $languagestringref);
990 my $subdirname = $allvariables->{'UNIXPRODUCTNAME'} . "_pkgmaps";
991 my $pkgmapsubdir = $pkgmapdir . $installer::globals
::separator
. $subdirname;
992 if ( -d
$pkgmapsubdir ) { installer
::systemactions
::remove_complete_directory
($pkgmapsubdir); }
993 if ( ! -d
$pkgmapsubdir ) { installer
::systemactions
::create_directory
($pkgmapsubdir); }
995 $installdir =~ s/\/\s*$//;
996 # Collecting all packages in $installdir and its sub package ("packages")
997 my $searchdir = $installdir . $installer::globals
::separator
. $installer::globals
::epmoutpath
;
999 my $allpackages = installer
::systemactions
::get_all_directories_without_path
($searchdir);
1001 for ( my $i = 0; $i <= $#{$allpackages}; $i++ )
1003 my $pkgmapfile = $searchdir . $installer::globals
::separator
. ${$allpackages}[$i] . $installer::globals
::separator
. "pkgmap";
1004 my $destfilename = $pkgmapsubdir . $installer::globals
::separator
. ${$allpackages}[$i] . "_pkgmap";
1005 installer
::systemactions
::copy_one_file
($pkgmapfile, $destfilename);
1008 # Create a tar gz file with all package maps
1009 my $tarfilename = $subdirname . ".tar";
1010 my $targzname = $tarfilename . ".gz";
1011 $systemcall = "cd $pkgmapdir; tar -cf - $subdirname | gzip > $targzname";
1012 installer
::systemactions
::make_systemcall
($systemcall);
1013 installer
::systemactions
::remove_complete_directory
($pkgmapsubdir, 1);