update dev300-m58
[ooovba.git] / solenv / bin / modules / installer / javainstaller.pm
blob19b8970f727d4d60fcea1500d2682512fa8c7c26
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: javainstaller.pm,v $
11 # $Revision: 1.30 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
31 package installer::javainstaller;
33 use Cwd;
34 use installer::exiter;
35 use installer::files;
36 use installer::globals;
37 use installer::languages;
38 use installer::pathanalyzer;
39 use installer::scriptitems;
40 use installer::systemactions;
41 use installer::worker;
42 use installer::logger;
44 ##############################################################
45 # Returning a specific language string from the block
46 # of all translations
47 ##############################################################
49 sub get_language_string_from_language_block
51 my ($language_block, $language, $oldstring) = @_;
53 my $newstring = "";
55 for ( my $i = 0; $i <= $#{$language_block}; $i++ )
57 if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
59 $newstring = $1;
60 last;
64 if ( $newstring eq "" )
66 $language = "en-US"; # defaulting to english
68 for ( my $i = 0; $i <= $#{$language_block}; $i++ )
70 if ( ${$language_block}[$i] =~ /^\s*$language\s*\=\s*\"(.*)\"\s*$/ )
72 $newstring = $1;
73 last;
78 return $newstring;
81 ##############################################################
82 # Returning the complete block in all languages
83 # for a specified string
84 ##############################################################
86 sub get_language_block_from_language_file
88 my ($searchstring, $languagefile) = @_;
90 my @language_block = ();
92 for ( my $i = 0; $i <= $#{$languagefile}; $i++ )
94 if ( ${$languagefile}[$i] =~ /^\s*\[\s*$searchstring\s*\]\s*$/ )
96 my $counter = $i;
98 push(@language_block, ${$languagefile}[$counter]);
99 $counter++;
101 while (( $counter <= $#{$languagefile} ) && (!( ${$languagefile}[$counter] =~ /^\s*\[/ )))
103 push(@language_block, ${$languagefile}[$counter]);
104 $counter++;
107 last;
111 return \@language_block;
114 #######################################################
115 # Searching for the module name and description in the
116 # modules collector
117 #######################################################
119 sub get_module_name_description
121 my ($modulesarrayref, $onelanguage, $gid, $type) = @_;
123 my $found = 0;
125 my $newstring = "";
127 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
129 my $onemodule = ${$modulesarrayref}[$i];
131 if ( $onemodule->{'gid'} eq $gid )
133 my $typestring = $type . " " . "(" . $onelanguage . ")";
134 if ( $onemodule->{$typestring} ) { $newstring = $onemodule->{$typestring}; }
135 $found = 1;
138 if ( $found ) { last; }
141 # defaulting to english
143 if ( ! $found )
145 my $defaultlanguage = "en-US";
147 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
149 my $onemodule = ${$modulesarrayref}[$i];
151 if ( $onemodule->{'gid'} eq $gid )
153 my $typestring = $type . " " . "(" . $defaultlanguage . ")";
154 if ( $onemodule->{$typestring} ) { $newstring = $onemodule->{$typestring}; }
155 $found = 1;
158 if ( $found ) { last; }
162 return $newstring;
165 #######################################################
166 # Setting the productname and productversion
167 #######################################################
169 sub set_productname_and_productversion
171 my ($templatefile, $variableshashref) = @_;
173 my $infoline = "\nSetting product name and product version in Java template file\n";
174 push( @installer::globals::logfileinfo, $infoline);
176 my $productname = $variableshashref->{'PRODUCTNAME'};
177 my $productversion = $variableshashref->{'PRODUCTVERSION'};
179 for ( my $i = 0; $i <= $#{$templatefile}; $i++ )
181 ${$templatefile}[$i] =~ s/\{PRODUCTNAME\}/$productname/g;
182 ${$templatefile}[$i] =~ s/\{PRODUCTVERSION\}/$productversion/g;
185 $infoline = "End of: Setting product name and product version in Java template file\n\n";
186 push( @installer::globals::logfileinfo, $infoline);
189 #######################################################
190 # Setting the localized Module name and description
191 #######################################################
193 sub set_component_name_and_description
195 my ($templatefile, $modulesarrayref, $onelanguage) = @_;
197 my $infoline = "\nSetting component names and description in Java template file\n";
198 push( @installer::globals::logfileinfo, $infoline);
200 for ( my $i = 0; $i <= $#{$templatefile}; $i++ )
202 # OOO_gid_Module_Prg_Wrt_Name
203 # OOO_gid_Module_Prg_Wrt_Description
205 my $oneline = ${$templatefile}[$i];
206 my $oldstring = "";
207 my $gid = "";
208 my $type = "";
210 if ( $oneline =~ /\b(OOO_gid_\w+)\b/ )
212 $oldstring = $1;
214 $infoline = "Found: $oldstring\n";
215 push( @installer::globals::logfileinfo, $infoline);
217 if ( $oldstring =~ /^\s*OOO_(gid_\w+)_(\w+?)\s*$/ )
219 $gid = $1;
220 $type = $2;
223 my $newstring = get_module_name_description($modulesarrayref, $onelanguage, $gid, $type);
225 $infoline = "\tReplacing (language $onelanguage): OLDSTRING: $oldstring NEWSTRING $newstring\n";
226 push( @installer::globals::logfileinfo, $infoline);
228 ${$templatefile}[$i] =~ s/$oldstring/$newstring/; # always substitute, even if $newstring eq ""
232 $infoline = "End of: Setting component names and description in Java template file\n\n";
233 push( @installer::globals::logfileinfo, $infoline);
236 #######################################################
237 # Translating the Java file
238 #######################################################
240 sub translate_javafile
242 my ($templatefile, $languagefile, $onelanguage) = @_;
244 for ( my $i = 0; $i <= $#{$templatefile}; $i++ )
246 my @allstrings = ();
248 my $oneline = ${$templatefile}[$i];
250 while ( $oneline =~ /\b(OOO_\w+)\b/ )
252 my $replacestring = $1;
253 push(@allstrings, $replacestring);
254 $oneline =~ s/$replacestring//;
257 my $oldstring;
259 foreach $oldstring (@allstrings)
261 my $language_block = get_language_block_from_language_file($oldstring, $languagefile);
262 my $newstring = get_language_string_from_language_block($language_block, $onelanguage, $oldstring);
264 $newstring =~ s/\"/\\\"/g; # masquerading the "
265 $newstring =~ s/\\\\\"/\\\"/g; # unmasquerading if \" was converted to \\" (because " was already masked)
267 # if (!( $newstring eq "" )) { ${$idtfile}[$i] =~ s/$oldstring/$newstring/; }
268 ${$templatefile}[$i] =~ s/$oldstring/$newstring/; # always substitute, even if $newstring eq ""
273 ###########################################################
274 # Returning the license file name for a defined language
275 ###########################################################
277 sub get_licensefilesource
279 my ($language, $includepatharrayref) = @_;
281 my $licensefilename = "LICENSE_" . $language;
283 my $licenseref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, $includepatharrayref, 0);
284 if ($$licenseref eq "") { installer::exiter::exit_program("ERROR: Could not find License file $licensefilename!", "get_licensefilesource"); }
286 my $infoline = "Found licensefile $licensefilename: $$licenseref \n";
287 push( @installer::globals::logfileinfo, $infoline);
289 return $$licenseref;
292 #######################################################
293 # Converting the license string into the
294 # Java specific encoding.
295 #######################################################
297 sub convert_licenstring
299 my ($licensefile, $includepatharrayref, $javadir, $onelanguage) = @_;
301 my $licensedir = $javadir . $installer::globals::separator . "license";
302 installer::systemactions::create_directory($licensedir);
304 # saving the original license file
306 my $licensefilename = $licensedir . $installer::globals::separator . "licensefile.txt";
307 installer::files::save_file($licensefilename, $licensefile);
309 # creating the ulf file from the license file
311 $licensefilename = $licensedir . $installer::globals::separator . "licensefile.ulf";
312 my @licensearray = ();
314 my $section = "\[TRANSLATE\]\n";
315 push(@licensearray, $section);
317 for ( my $i = 0; $i <= $#{$licensefile}; $i++ )
319 my $oneline = ${$licensefile}[$i];
321 if ($i == 0) { $oneline =~ s/^\s*\ï\»\¿//; }
323 $oneline =~ s/\s*$//;
324 $oneline =~ s/\"/\\\"/g; # masquerading the "
325 $oneline =~ s/\'/\\\'/g; # masquerading the '
327 $oneline =~ s/\$\{/\{/g; # replacement of variables, only {PRODUCTNAME}, not ${PRODUCTNAME}
329 my $ulfstring = $onelanguage . " = " . "\"" . $oneline . "\"\n";
330 push(@licensearray, $ulfstring);
333 installer::files::save_file($licensefilename, \@licensearray);
335 # converting the ulf file to the jlf file with ulfconv
337 @licensearray = ();
339 my $converter = "ulfconv";
341 my $converterref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$converter, $includepatharrayref, 0);
342 if ($$converterref eq "") { installer::exiter::exit_program("ERROR: Could not find converter $converter!", "convert_licenstring"); }
344 my $infoline = "Found converter file $converter: $$converterref \n";
345 push( @installer::globals::logfileinfo, $infoline);
347 my $systemcall = "$$converterref $licensefilename |";
348 open (CONV, "$systemcall");
349 @licensearray = <CONV>;
350 close (CONV);
352 $licensefilename = $licensedir . $installer::globals::separator . "licensefile.jlf";
353 installer::files::save_file($licensefilename, \@licensearray);
355 # creating the license string from the jlf file
357 $licensestring = "";
359 for ( my $i = 1; $i <= $#licensearray; $i++ ) # not the first line!
361 my $oneline = $licensearray[$i];
362 $oneline =~ s/^\s*$onelanguage\s*\=\s*\"//;
363 $oneline =~ s/\"\s*$//;
364 $licensestring = $licensestring . $oneline . "\\n";
367 $infoline = "Systemcall: $systemcall\n";
368 push( @installer::globals::logfileinfo, $infoline);
370 if ( $licensestring eq "" )
372 $infoline = "ERROR: Could not convert $licensefilename !\n";
373 push( @installer::globals::logfileinfo, $infoline);
376 return $licensestring;
379 #######################################################
380 # Adding the license file into the java file
381 # In the template java file there are two
382 # occurences of INSTALLSDK_GUI_LICENSE
383 # and INSTALLSDK_CONSOLE_LICENSE
384 #######################################################
386 sub add_license_file_into_javafile
388 my ( $templatefile, $licensefile, $includepatharrayref, $javadir, $onelanguage ) = @_;
390 my $licensestring = convert_licenstring($licensefile, $includepatharrayref, $javadir, $onelanguage);
392 # saving the licensestring in an ulf file
393 # converting the file using "ulfconv license.ulf"
394 # including the new string into the java file
396 for ( my $i = 0; $i <= $#{$templatefile}; $i++ )
398 ${$templatefile}[$i] =~ s/INSTALLSDK_GUI_LICENSE/$licensestring/;
399 ${$templatefile}[$i] =~ s/INSTALLSDK_CONSOLE_LICENSE/$licensestring/;
403 #######################################################
404 # Executing one system call
405 #######################################################
407 sub make_systemcall
409 my ( $systemcall, $logreturn ) = @_;
411 my @returns = ();
413 installer::logger::print_message( "... $systemcall ...\n" );
415 open (REG, "$systemcall");
416 while (<REG>) {push(@returns, $_); }
417 close (REG);
419 my $returnvalue = $?; # $? contains the return value of the systemcall
421 my $infoline = "Systemcall: $systemcall\n";
422 push( @installer::globals::logfileinfo, $infoline);
424 if ( $logreturn )
426 for ( my $j = 0; $j <= $#returns; $j++ ) { push( @installer::globals::logfileinfo, "$returns[$j]"); }
429 if ($returnvalue)
431 $infoline = "ERROR: $systemcall\n";
432 push( @installer::globals::logfileinfo, $infoline);
433 $error_occured = 1;
435 else
437 $infoline = "SUCCESS: $systemcall\n";
438 push( @installer::globals::logfileinfo, $infoline);
441 return \@returns;
444 #######################################################
445 # Setting the class path for the Installer SDK
446 #######################################################
448 sub set_classpath_for_install_sdk
450 my ( $directory ) = @_;
452 my $installsdk = "";
453 my $solarVersion = "";
454 my $inPath = "";
455 my $updMinorExt = "";
457 if ( defined( $ENV{ 'SOLARVERSION' } ) ) { $solarVersion = $ENV{'SOLARVERSION'}; }
458 else { installer::exiter::exit_program("ERROR: Environment variable \"SOLARVERSION\" not set!", "set_classpath_for_install_sdk"); }
460 if ( defined( $ENV{ 'INPATH' } ) ) { $inPath = $ENV{'INPATH'}; }
461 else { installer::exiter::exit_program("ERROR: Environment variable \"INPATH\" not set!", "set_classpath_for_install_sdk"); }
463 if ( defined( $ENV{ 'UPDMINOREXT' } ) ) { $updMinorExt = $ENV{'UPDMINOREXT'}; }
464 else { installer::exiter::exit_program("ERROR: Environment variable \"UPDMINOREXT\" not set!", "set_classpath_for_install_sdk") if ( ! $ENV{UPDATER} ); }
466 $installsdk = $solarVersion . $installer::globals::separator . $inPath . $installer::globals::separator . "bin" . $updMinorExt;
467 $installsdk = $installsdk . $installer::globals::separator . "javainstaller";
469 if ( $ENV{'INSTALLSDK_SOURCE'} ) { $installsdk = $ENV{'INSTALLSDK_SOURCE'}; } # overriding the Install SDK with INSTALLSDK_SOURCE
471 # The variable CLASSPATH has to contain:
472 # $installsdk/classes:$installsdk/classes/setupsdk.jar:
473 # $installsdk/classes/parser.jar:$installsdk/classes/jaxp.jar:
474 # $installsdk/classes/ldapjdk.jar:$directory
476 my @additional_classpath = ();
477 push(@additional_classpath, "$installsdk\/classes");
478 push(@additional_classpath, "$installsdk\/installsdk.jar");
479 push(@additional_classpath, "$installsdk\/classes\/parser.jar");
480 push(@additional_classpath, "$installsdk\/classes\/jaxp.jar");
481 push(@additional_classpath, "$directory");
483 my $newclasspathstring = "";
484 my $oldclasspathstring = "";
485 if ( $ENV{'CLASSPATH'} ) { $oldclasspathstring = $ENV{'CLASSPATH'}; }
486 else { $oldclasspathstring = "\."; }
488 for ( my $i = 0; $i <= $#additional_classpath; $i++ )
490 $newclasspathstring = $newclasspathstring . $additional_classpath[$i] . ":";
493 $newclasspathstring = $newclasspathstring . $oldclasspathstring;
495 $ENV{'CLASSPATH'} = $newclasspathstring;
497 my $infoline = "Setting CLASSPATH to $ENV{'CLASSPATH'}\n";
498 push( @installer::globals::logfileinfo, $infoline);
501 #######################################################
502 # Setting the class file name in the Java locale file
503 #######################################################
505 sub set_classfilename
507 my ($templatefile, $classfilename, $searchstring) = @_;
509 for ( my $j = 0; $j <= $#{$templatefile}; $j++ )
511 if ( ${$templatefile}[$j] =~ /\Q$searchstring\E/ )
513 ${$templatefile}[$j] =~ s/$searchstring/$classfilename/;
514 last;
519 #######################################################
520 # Substituting one variable in the xml file
521 #######################################################
523 sub replace_one_variable
525 my ($xmlfile, $variable, $searchstring) = @_;
527 for ( my $i = 0; $i <= $#{$xmlfile}; $i++ )
529 ${$xmlfile}[$i] =~ s/\$\{$searchstring\}/$variable/g;
533 #######################################################
534 # Substituting the variables in the xml file
535 #######################################################
537 sub substitute_variables
539 my ($xmlfile, $variableshashref) = @_;
541 my $key;
543 foreach $key (keys %{$variableshashref})
545 my $value = $variableshashref->{$key};
546 replace_one_variable($xmlfile, $value, $key);
550 ##########################################################
551 # Finding the line number in xml file of a special
552 # component
553 ##########################################################
555 sub find_component_line
557 my ($xmlfile, $componentname) = @_;
559 my $linenumber = 0;
561 for ( my $i = 0; $i <= $#{$xmlfile}; $i++ )
563 if ( ${$xmlfile}[$i] =~ /name\s*\=\'\s*$componentname/ )
565 $linenumber = $i;
566 last;
570 return $linenumber;
573 ##########################################################
574 # Removing one package from the xml file
575 ##########################################################
577 sub remove_package
579 my ($xmlfile, $packagename) = @_;
581 my $searchstring = $packagename;
582 if ( $searchstring =~ /\-(\S+?)\s*$/ ) { $searchstring = $1; } # "SUNW%PRODUCTNAME-mailcap" -> "mailcap"
584 my $packagestring = "";
585 my $namestring = "";
586 my $infoline = "";
588 if ( $installer::globals::issolarispkgbuild )
590 $packagestring = "\<pkgunit";
591 $namestring = "pkgName";
593 elsif ( $installer::globals::islinuxrpmbuild )
595 $packagestring = "\<rpmunit";
596 $namestring = "rpmUniqueName";
599 my $removed_packge = 0;
601 for ( my $i = 0; $i <= $#{$xmlfile}; $i++ )
603 if ( ${$xmlfile}[$i] =~ /^\s*\Q$packagestring\E/ )
605 # this is a package, but is it the correct one?
607 my $do_delete = 0;
608 my $linecounter = 1;
609 my $startline = $i+1;
610 my $line = ${$xmlfile}[$startline];
611 if (($line =~ /^\s*\Q$namestring\E\s*\=/) && ($line =~ /\-\Q$searchstring\E/)) { $do_delete = 1; }
613 # but not deleting fonts package in language packs
614 if ( $line =~ /-ONELANGUAGE-/ ) { $do_delete = 0; }
616 my $endcounter = 0;
618 while ((!( $line =~ /\/\>/ )) && ( $startline <= $#{$xmlfile} ))
620 $linecounter++;
621 $startline++;
622 $line = ${$xmlfile}[$startline];
623 if (($line =~ /^\s*\Q$namestring\E\s*\=/) && ($line =~ /\-\Q$searchstring\E/)) { $do_delete = 1; }
626 $linecounter = $linecounter + 1;
628 if ( $do_delete )
630 my $infoline = "\tReally removing package $packagename from xml file.\n";
631 push( @installer::globals::logfileinfo, $infoline);
632 splice(@{$xmlfile},$i, $linecounter); # removing $linecounter lines, beginning in line $i
633 $removed_packge = 1;
634 last;
639 if ( $removed_packge )
641 $infoline = "Package $packagename successfully removed from xml file.\n";
642 push( @installer::globals::logfileinfo, $infoline);
644 else
646 $infoline = "Did not find package $packagename in xml file.\n";
647 push( @installer::globals::logfileinfo, $infoline);
652 ##########################################################
653 # Removing one component from the xml file
654 ##########################################################
656 sub remove_component
658 my ($xmlfile, $componentname) = @_;
660 my @removed_lines = ();
662 push(@removed_lines, "\n");
664 for ( my $i = 0; $i <= $#{$xmlfile}; $i++ )
666 if ( ${$xmlfile}[$i] =~ /name\s*\=\'\s*$componentname/ )
668 # Counting the lines till the second "</component>"
670 push(@removed_lines, ${$xmlfile}[$i]);
671 my $linecounter = 1;
672 my $startline = $i+1;
673 my $line = ${$xmlfile}[$startline];
674 push(@removed_lines, $line);
675 my $endcounter = 0;
677 while ((!( $line =~ /^\s*\<\/component\>\s*$/ )) && ( $startline <= $#{$xmlfile} ))
679 $linecounter++;
680 $startline++;
681 $line = ${$xmlfile}[$startline];
682 push(@removed_lines, $line);
685 $linecounter = $linecounter + 2; # last line and following empty line
687 splice(@{$xmlfile},$i, $linecounter); # removing $linecounter lines, beginning in line $i
688 last;
692 return \@removed_lines;
695 ##########################################################
696 # If this is an installation set without language packs
697 # the language pack module can be removed
698 ##########################################################
700 sub remove_languagepack_from_xmlfile
702 my ($xmlfile) = @_;
704 # Component begins with "<component selected="true" name='module_languagepacks' componentVersion="${PRODUCTVERSION}">"
705 # and ends with "</component>" (the second "</component>" !)
707 remove_component($xmlfile, "languagepack_DEFAULT");
708 remove_component($xmlfile, "languagepack_ONELANGUAGE");
709 remove_component($xmlfile, "module_languagepacks");
712 ##########################################################
713 # Duplicating a component
714 ##########################################################
716 sub duplicate_component
718 my ( $arrayref ) = @_;
720 @newarray = ();
722 for ( my $i = 0; $i <= $#{$arrayref}; $i++ )
724 push(@newarray, ${$arrayref}[$i]);
727 return \@newarray;
730 ##########################################################
731 # Including a component into the xml file
732 # at a specified line
733 ##########################################################
735 sub include_component_at_specific_line
737 my ($xmlfile, $unit, $line) = @_;
739 splice(@{$xmlfile},$line, 0, @{$unit});
742 ##########################################################
743 # Font packages do not exist for all languages.
744 ##########################################################
746 sub remove_font_package_from_unit
748 my ( $unitcopy, $onelanguage ) = @_;
750 my $searchstring = "-fonts";
752 my $packagestring = "";
753 my $namestring = "";
755 if ( $installer::globals::issolarispkgbuild )
757 $packagestring = "\<pkgunit";
758 $namestring = "pkgName";
760 elsif ( $installer::globals::islinuxrpmbuild )
762 $packagestring = "\<rpmunit";
763 $namestring = "rpmUniqueName";
766 for ( my $i = 0; $i <= $#{$unitcopy}; $i++ )
768 if ( ${$unitcopy}[$i] =~ /^\s*\Q$packagestring\E/ )
770 # this is a package, but is it the correct one?
772 my $do_delete = 0;
773 my $linecounter = 1;
774 my $startline = $i+1;
775 my $line = ${$unitcopy}[$startline];
776 if (($line =~ /^\s*\Q$namestring\E\s*\=/) && ($line =~ /\Q$searchstring\E/)) { $do_delete = 1; }
778 my $endcounter = 0;
780 while ((!( $line =~ /\/\>/ )) && ( $startline <= $#{$unitcopy} ))
782 $linecounter++;
783 $startline++;
784 $line = ${$unitcopy}[$startline];
785 if (($line =~ /^\s*\Q$namestring\E\s*\=/) && ($line =~ /\Q$searchstring\E/)) { $do_delete = 1; }
788 $linecounter = $linecounter + 1;
790 if ( $do_delete )
792 splice(@{$unitcopy},$i, $linecounter); # removing $linecounter lines, beginning in line $i
793 last;
799 ##########################################################
800 # If this is an installation set with language packs,
801 # modules for each language pack have to be created
802 # dynamically
803 ##########################################################
805 sub duplicate_languagepack_in_xmlfile
807 my ($xmlfile, $languagesarrayref) = @_;
809 my $unit = remove_component($xmlfile, "languagepack_ONELANGUAGE");
810 my $startline = find_component_line($xmlfile, "module_languagepacks");
811 my $infoline = "";
812 $startline = $startline + 1;
814 for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ )
816 my $onelanguage = ${$languagesarrayref}[$i];
817 my $unitcopy = duplicate_component($unit);
819 # replacing string ONELANGUAGE in the unit copy
820 for ( my $j = 0; $j <= $#{$unitcopy}; $j++ ) { ${$unitcopy}[$j] =~ s/ONELANGUAGE/$onelanguage/g; }
822 # including the unitcopy into the xml file
823 include_component_at_specific_line($xmlfile, $unitcopy, $startline);
824 $startline = $startline + $#{$unitcopy} + 1;
827 # adding the default language as language pack, too
828 $unit = remove_component($xmlfile, "languagepack_DEFAULT");
829 $startline = find_component_line($xmlfile, "module_languagepacks");
830 $startline = $startline + 1;
832 $onelanguage = ${$languagesarrayref}[0];
833 $unitcopy = duplicate_component($unit);
835 # replacing string DEFAULT in the unit copy
836 for ( my $j = 0; $j <= $#{$unitcopy}; $j++ ) { ${$unitcopy}[$j] =~ s/DEFAULT/$onelanguage/g; }
838 # including the unitcopy into the xml file
839 include_component_at_specific_line($xmlfile, $unitcopy, $startline);
840 $startline = $startline + $#{$unitcopy} + 1;
843 #######################################################
844 # Removing empty packages from xml file. The names
845 # are stored in @installer::globals::emptypackages
846 #######################################################
848 sub remove_empty_packages_in_xmlfile
850 my ($xmlfile) = @_;
852 for ( my $i = 0; $i <= $#installer::globals::emptypackages; $i++ )
854 my $packagename = $installer::globals::emptypackages[$i];
855 my $infoline = "Try to remove package $packagename from xml file.\n";
856 push( @installer::globals::logfileinfo, $infoline);
857 remove_package($xmlfile, $packagename);
861 #######################################################
862 # Preparing the language packs in the xml file
863 #######################################################
865 sub prepare_language_pack_in_xmlfile
867 my ($xmlfile, $languagesarrayref) = @_;
869 # if ( ! $installer::globals::is_unix_multi )
871 # remove_languagepack_from_xmlfile($xmlfile);
873 # else
875 duplicate_languagepack_in_xmlfile($xmlfile, $languagesarrayref);
880 #######################################################
881 # Returning a rpm unit from a xml file
882 #######################################################
884 sub get_rpm_unit_from_xmlfile
886 my ($rpmname, $xmlfile) = @_;
888 my $infoline = "Searching for $rpmname in xml file.\n";
889 push( @installer::globals::logfileinfo, $infoline);
891 my @rpmunit = ();
892 my $includeline = 0;
893 my $record = 0;
894 my $foundrpm = 0;
896 for ( my $i = 0; $i <= $#{$xmlfile}; $i++ )
898 my $oneline = ${$xmlfile}[$i];
900 if ( $oneline =~ /^\s*\<rpmunit/ ) { $record = 1; }
902 if ( $record ) { push(@rpmunit, $oneline); }
904 if ( $oneline =~ /^\s*rpmUniqueName\s*=\s*\"\Q$rpmname\E\"\s*$/ ) { $foundrpm = 1; }
906 if (( $record ) && ( $oneline =~ /\/\>\s*$/ )) { $record = 0; }
908 if (( ! $foundrpm ) && ( ! $record )) { @rpmunit = (); }
910 if (( $foundrpm ) && ( ! $record )) { $includeline = $i + 1; }
912 if (( $foundrpm ) && ( ! $record )) { last; }
915 if ( ! $foundrpm ) { installer::exiter::exit_program("ERROR: Did not find rpmunit $rpmname in xml file!", "get_rpm_unit_from_xmlfile"); }
917 $infoline = "Found $rpmname in xml file. Returning block lines: $#rpmunit + 1. Includeline: $includeline \n";
918 push( @installer::globals::logfileinfo, $infoline);
920 return (\@rpmunit, $includeline);
923 #######################################################
924 # Exchanging package names in xml file
925 #######################################################
927 sub exchange_name_in_rpmunit
929 my ($rpmunit, $oldpackagename, $newpackagename) = @_;
931 for ( my $i = 0; $i <= $#{$rpmunit}; $i++ )
933 ${$rpmunit}[$i] =~ s/$oldpackagename/$newpackagename/;
937 #######################################################
938 # Preparing link RPMs in the xml file
939 #######################################################
941 sub prepare_linkrpm_in_xmlfile
943 my ($xmlfile, $rpmlist) = @_;
945 for ( my $i = 0; $i <= $#{$rpmlist}; $i++ )
947 my $oldpackagename = "";
948 my $newpackagename = "";
950 my $rpmline = ${$rpmlist}[$i];
952 my $infoline = "Preparing link/patch RPM: $rpmline\n";
953 push( @installer::globals::logfileinfo, $infoline);
955 if ( $rpmline =~ /^\s*(\S.*?\S)\s+(\S.*?\S)\s*$/ )
957 $oldpackagename = $1;
958 $newpackagename = $2;
961 my ($rpmunit, $includeline) = get_rpm_unit_from_xmlfile($oldpackagename, $xmlfile);
962 exchange_name_in_rpmunit($rpmunit, $oldpackagename, $newpackagename);
963 include_component_at_specific_line($xmlfile, $rpmunit, $includeline);
967 #######################################################################
968 # Removing w4w filter module from xml file for Solaris x86 and Linux
969 #######################################################################
971 sub remove_w4w_from_xmlfile
973 my ($xmlfile) = @_;
975 # Component begins with "<component selected='true' name='gid_Module_Prg_Wrt_Flt_W4w' componentVersion="8">"
976 # and ends with "</component>"
978 for ( my $i = 0; $i <= $#{$xmlfile}; $i++ )
980 if ( ${$xmlfile}[$i] =~ /name\s*\=\'\s*gid_Module_Prg_Wrt_Flt_W4w/ )
982 # Counting the lines till "</component>"
984 my $linecounter = 1;
985 my $startline = $i+1;
986 my $line = ${$xmlfile}[$startline];
988 while ((!( $line =~ /^\s*\<\/component\>\s*$/ )) && ( $startline <= $#{$xmlfile} ))
990 $linecounter++;
991 $startline++;
992 $line = ${$xmlfile}[$startline];
995 $linecounter = $linecounter + 2; # last line and following empty line
997 splice(@{$xmlfile},$i, $linecounter); # removing $linecounter lines, beginning in line $i
998 last;
1003 #######################################################################
1004 # Removing module from xml file, if not defined in scp
1005 #######################################################################
1007 sub remove_scpgid_from_xmlfile
1009 my ($xmlfile, $scpgid) = @_;
1011 # Component begins with "<component selected='true' name='$scpgid' componentVersion="8">"
1012 # and ends with "</component>"
1014 my $successfully_removed = 0;
1016 for ( my $i = 0; $i <= $#{$xmlfile}; $i++ )
1018 if ( ${$xmlfile}[$i] =~ /name\s*\=\'\s*\Q$scpgid\E/ )
1020 # Counting the lines till "</component>"
1022 my $linecounter = 1;
1023 my $startline = $i+1;
1024 my $line = ${$xmlfile}[$startline];
1026 while ((!( $line =~ /^\s*\<\/component\>\s*$/ )) && ( $startline <= $#{$xmlfile} ))
1028 $linecounter++;
1029 $startline++;
1030 $line = ${$xmlfile}[$startline];
1033 $linecounter = $linecounter + 2; # last line and following empty line
1035 splice(@{$xmlfile},$i, $linecounter); # removing $linecounter lines, beginning in line $i
1036 $successfully_removed = 1;
1037 last;
1041 my $infoline = "";
1042 if ($successfully_removed)
1044 $infoline = "Module $scpgid successfully removed from xml file.\n";
1045 push( @installer::globals::logfileinfo, $infoline);
1047 else
1049 $infoline = "Module $scpgid not found in xml file (no problem).\n";
1050 push( @installer::globals::logfileinfo, $infoline);
1054 #######################################################################
1055 # Special mechanism for removing modules for xml file, if they are
1056 # not defined in scp (introduced for onlineupdate module).
1057 #######################################################################
1059 sub remove_module_if_not_defined
1061 my ($xmlfile, $modulesarrayref, $scpgid) = @_;
1063 my $infoline = "Checking existence of $scpgid in scp definition\n";
1064 push( @installer::globals::logfileinfo, $infoline);
1066 my $found = 0;
1068 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
1070 my $onemodule = ${$modulesarrayref}[$i];
1071 if ( $onemodule->{'gid'} eq $scpgid ) { $found = 1; }
1072 if ( $found ) { last; }
1075 if ( ! $found )
1077 $infoline = "Module $scpgid not found -> Removing from xml file.\n";
1078 push( @installer::globals::logfileinfo, $infoline);
1079 remove_scpgid_from_xmlfile($xmlfile, $scpgid);
1083 ###########################################################
1084 # Preparing the package subdirectory
1085 ###########################################################
1087 sub create_empty_packages
1089 my ( $xmlfile ) = @_;
1091 if ( $installer::globals::issolarispkgbuild )
1093 my $path = "";
1095 for ( my $i = 0; $i <= $#{$xmlfile}; $i++ )
1097 if ( ${$xmlfile}[$i] =~ /pkgRelativePath\s*\=\s*\'(.*?)\'\s*$/ )
1099 $path = $1;
1100 installer::systemactions::create_directory_structure($path);
1101 last; # only creating one path
1105 for ( my $i = 0; $i <= $#{$xmlfile}; $i++ )
1107 if ( ${$xmlfile}[$i] =~ /pkgName\s*\=\s*\'(.*?)\'\s*$/ )
1109 my $pkgname = $1;
1110 if ( $path ne "" ) { $pkgname = $path . $installer::globals::separator . $pkgname; }
1111 installer::systemactions::create_directory_structure($pkgname);
1116 # "-novalidate" does not work for Linux RPMs
1118 if ( $installer::globals::islinuxrpmbuild )
1120 for ( my $i = 0; $i <= $#{$xmlfile}; $i++ )
1122 if ( ${$xmlfile}[$i] =~ /rpmPath\s*\=\s*\"(.*?)\"\s*$/ )
1124 my $rpmpath = $1;
1125 my $path = "";
1127 if ( $rpmpath =~ /^\s*(.*)\/(.*?)\s*$/ )
1129 $path = $1;
1132 if ( $path ne "" ) { installer::systemactions::create_directory_structure($path); }
1134 my $systemcall = "touch $rpmpath"; # creating empty rpm
1135 system($systemcall);
1141 ###########################################################
1142 # Reading the archive file name from the xml file
1143 ###########################################################
1145 sub get_archivefilename
1147 my ( $xmlfile ) = @_;
1149 my $archivefilename = "";
1151 for ( my $j = 0; $j <= $#{$xmlfile}; $j++ )
1153 if ( ${$xmlfile}[$j] =~ /archiveFileName\s*=\s*\'(.*?)\'/ )
1155 $archivefilename = $1;
1156 last;
1160 return $archivefilename;
1163 #######################################################
1164 # Copying the loader locally
1165 #######################################################
1167 sub copy_setup_locally
1169 my ($includepatharrayref, $loadername, $newname) = @_;
1171 my $loadernameref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$loadername, $includepatharrayref, 0);
1173 if ($$loadernameref eq "") { installer::exiter::exit_program("ERROR: Could not find Java loader $loadername!", "copy_setup_locally"); }
1175 installer::systemactions::copy_one_file($$loadernameref, $newname);
1176 my $localcall = "chmod 775 $newname \>\/dev\/null 2\>\&1";
1177 system($localcall);
1181 #######################################################
1182 # Copying the loader into the installation set
1183 #######################################################
1185 sub put_loader_into_installset
1187 my ($installdir, $filename) = @_;
1189 my $installname = $installdir . $installer::globals::separator . $filename;
1191 installer::systemactions::copy_one_file($filename, $installname);
1193 my $localcall = "chmod 775 $installname \>\/dev\/null 2\>\&1";
1194 system($localcall);
1197 #################################################################
1198 # Setting for Solaris the package names in the Java translation
1199 # file. The name is used for the
1200 # This name is displayed tools like prodreg.
1201 # Unfortunately this name in the component is also used
1202 # in the translation template file for the module name
1203 # and module description translations.
1204 #################################################################
1206 sub replace_component_name_in_java_file
1208 my ($alljavafiles, $oldname, $newname) = @_;
1210 # The new name must not contain white spaces
1212 $newname =~ s/ /\_/g;
1214 for ( my $i = 0; $i <= $#{$alljavafiles}; $i++ )
1216 my $javafilename = ${$alljavafiles}[$i];
1217 my $javafile = installer::files::read_file($javafilename);
1219 my $oldstring = "ComponentDescription-" . $oldname;
1220 my $newstring = "ComponentDescription-" . $newname;
1222 for ( my $j = 0; $j <= $#{$javafile}; $j++ ) { ${$javafile}[$j] =~ s/\b$oldstring\b/$newstring/; }
1224 $oldstring = $oldname . "-install-DisplayName";
1225 $newstring = $newname . "-install-DisplayName";
1227 for ( my $j = 0; $j <= $#{$javafile}; $j++ ) { ${$javafile}[$j] =~ s/\b$oldstring\b/$newstring/; }
1229 $oldstring = $oldname . "-uninstall-DisplayName";
1230 $newstring = $newname . "-uninstall-DisplayName";
1232 for ( my $j = 0; $j <= $#{$javafile}; $j++ ) { ${$javafile}[$j] =~ s/\b$oldstring\b/$newstring/; }
1234 installer::files::save_file($javafilename, $javafile);
1235 $infoline = "Changes in Java file: $javafilename : $oldname \-\> $newname\n";
1236 push( @installer::globals::logfileinfo, $infoline);
1240 #################################################################
1241 # Some module names are not defined in the scp project.
1242 # The names for this modules are searched in the base Java
1243 # translation file.
1244 #################################################################
1246 sub get_module_name_from_basejavafile
1248 my ($componentname, $javatemplateorigfile, $ulffile) = @_;
1250 my $searchname = $componentname . "-install-DisplayName";
1251 my $modulename = "";
1252 my $replacename = "";
1254 # line content: { "coremodule-install-DisplayName", "OOO_INSTALLSDK_117" },
1256 for ( my $i = 0; $i <= $#{$javatemplateorigfile}; $i++ )
1258 if ( ${$javatemplateorigfile}[$i] =~ /\"\s*\Q$searchname\E\s*\"\s*\,\s*\"\s*(.*?)\s*\"\s*\}\s*\,\s*$/ )
1260 $replacename = $1;
1261 last;
1265 if ( $replacename ne "" )
1267 my $language_block = get_language_block_from_language_file($replacename, $ulffile);
1268 $modulename = get_language_string_from_language_block($language_block, "en-US", $replacename);
1271 return $modulename;
1274 #################################################################
1275 # Setting for Solaris the package names in the xml file.
1276 # This name is displayed tools like prodreg.
1277 # Unfortunately this name in the component is also used
1278 # in the translation template file for the module name
1279 # and module description translations.
1280 #################################################################
1282 sub replace_component_names
1284 my ($xmlfile, $templatefilename, $modulesarrayref, $javatemplateorigfile, $ulffile) = @_;
1286 # path in which all java languages files are located
1288 my $javafilesdir = $templatefilename;
1289 installer::pathanalyzer::get_path_from_fullqualifiedname(\$javafilesdir);
1290 my $alljavafiles = installer::systemactions::find_file_with_file_extension("java", $javafilesdir);
1291 for ( my $i = 0; $i <= $#{$alljavafiles}; $i++ ) { ${$alljavafiles}[$i] = $javafilesdir . ${$alljavafiles}[$i]; }
1293 # analyzing the xml file
1295 for ( my $i = 0; $i <= $#{$xmlfile}; $i++ )
1297 my $newstring = "";
1298 my $componentname = "";
1300 if ( ${$xmlfile}[$i] =~ /\bcomponent\b.*\bname\s*\=\'\s*(.*?)\s*\'/ )
1302 $componentname = $1;
1304 # Getting module name from the scp files in $modulesarrayref
1306 my $onelanguage = "en-US";
1307 my $gid = $componentname;
1308 my $type = "Name";
1310 my $modulename = "";
1311 $modulename = get_module_name_description($modulesarrayref, $onelanguage, $gid, $type);
1313 if ( $modulename eq "" )
1315 $infoline = "Info: Modulename for $gid not defined in modules collector. Looking in Java ulf file.\n";
1316 push( @installer::globals::logfileinfo, $infoline);
1319 if ( $modulename eq "" ) # the modulename can also be set in the Java ulf file
1321 $modulename = get_module_name_from_basejavafile($componentname, $javatemplateorigfile, $ulffile);
1324 if ( $modulename ne "" ) # only do something, if the modulename was found
1326 ${$xmlfile}[$i] =~ s/$componentname/$modulename/;
1328 $infoline = "Replacement in xml file (Solaris): $componentname \-\> $modulename\n";
1329 push( @installer::globals::logfileinfo, $infoline);
1331 # Replacement has to be done in all Java language files
1332 replace_component_name_in_java_file($alljavafiles, $componentname, $modulename);
1335 if ( $modulename eq "" ) # the modulename can also be set in the Java ulf file
1337 $infoline = "WARNING: No replacement in xml file for component: $componentname\n";
1338 push( @installer::globals::logfileinfo, $infoline);
1344 #############################################################################
1345 # Collecting all packages or rpms located in the installation directory
1346 #############################################################################
1348 sub get_all_packages_in_installdir
1350 my ($installdir, $subdir) = @_;
1352 my $infoline = "";
1354 my @allrpms = (); # not needed for Solaris at the moment
1355 my $allrpms = \@allrpms;
1357 $installdir =~ s/\Q$installer::globals::separator\E\s*$//;
1358 my $directory = $installdir . $installer::globals::separator . $subdir;
1359 $directory =~ s/\Q$installer::globals::separator\E\s*$//;
1361 if ( $installer::globals::islinuxrpmbuild )
1363 $allrpms = installer::systemactions::find_file_with_file_extension("rpm", $directory);
1365 # collecting rpms with the complete path
1367 for ( my $i = 0; $i <= $#{$allrpms}; $i++ )
1369 ${$allrpms}[$i] = $directory . $installer::globals::separator . ${$allrpms}[$i];
1370 $infoline = "Found RPM: ${$allrpms}[$i]\n";
1371 push( @installer::globals::logfileinfo, $infoline);
1375 return $allrpms;
1378 #######################################################
1379 # Adding the values of the array
1380 #######################################################
1382 sub do_sum
1384 my ( $allnumbers ) = @_;
1386 my $sum = 0;
1388 for ( my $i = 0; $i <= $#{$allnumbers}; $i++ )
1390 $sum = $sum + ${$allnumbers}[$i];
1393 return $sum;
1396 #######################################################
1397 # Setting the filesize for the RPMs in the xml file
1398 #######################################################
1400 sub set_filesize_in_xmlfile
1402 my ($filesize, $rpmname, $xmlfile) = @_;
1404 my $infoline = "";
1405 my $foundrpm = 0;
1406 my $filesizeset = 0;
1408 for ( my $i = 0; $i <= $#{$xmlfile}; $i++ )
1410 my $line = ${$xmlfile}[$i];
1412 # searching for "rpmPath="RPMS/${UNIXPRODUCTNAME}-core01-${PACKAGEVERSION}-${PACKAGEREVISION}.i586.rpm""
1414 if (( $line =~ /rpmPath\s*=/ ) && ( $line =~ /\Q$rpmname\E\"\s*$/ ))
1416 $foundrpm = 1;
1418 my $number = $i;
1419 $number++;
1421 while ( ! ( ${$xmlfile}[$number] =~ /\/\>\s*$/ ))
1423 if ( ${$xmlfile}[$number] =~ /FILESIZEPLACEHOLDER/ )
1425 ${$xmlfile}[$number] =~ s/FILESIZEPLACEHOLDER/$filesize/;
1426 $filesizeset = 1;
1427 $infoline = "Setting filesize for $rpmname : $filesize\n";
1428 push( @installer::globals::logfileinfo, $infoline);
1429 last;
1432 $number++;
1435 last;
1439 if ( ! $foundrpm )
1441 $infoline = "ERROR: Did not find $rpmname in xml file !\n";
1442 push( @installer::globals::logfileinfo, $infoline);
1445 if ( ! $filesizeset )
1447 $infoline = "ERROR: Did not set filesize for $rpmname in xml file !\n";
1448 push( @installer::globals::logfileinfo, $infoline);
1452 ############################################################
1453 # Collecting all rpmUniqueName in xml file.
1454 ############################################################
1456 sub collect_uniquenames_in_xmlfile
1458 my ($xmlfile) = @_;
1460 my @rpmuniquenames = ();
1462 for ( my $i = 0; $i <= $#{$xmlfile}; $i++ )
1464 my $oneline = ${$xmlfile}[$i];
1466 if ( $oneline =~ /^\s*rpmUniqueName\s*\=\s*\"(.*)\"\s*$/ )
1468 my $rpmuniquename = $1;
1469 push(@rpmuniquenames, $rpmuniquename)
1473 return \@rpmuniquenames;
1476 ############################################################
1477 # Searching for the corresponding rpm, that fits to
1478 # the unique rpm name.
1479 # Simple mechanism: The name of the rpm starts with the
1480 # unique rpm name followed by a "-".
1481 ############################################################
1483 sub find_rpmname_to_uniquename
1485 my ($uniquename, $listofpackages) = @_;
1487 my @all_correct_rpms = ();
1488 my $infoline = "";
1490 # special handling for java RPMs, which have a very strange naming schema
1491 my $localuniquename = $uniquename;
1492 if ( $uniquename =~ /^\s*jre\-/ ) { $localuniquename = "jre"; }
1494 for ( my $i = 0; $i <= $#{$listofpackages}; $i++ )
1496 my $completerpmname = ${$listofpackages}[$i];
1497 my $rpmname = $completerpmname;
1498 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$rpmname);
1500 if ( $rpmname =~ /^\s*\Q$localuniquename\E\-\d/ ) { push(@all_correct_rpms, $rpmname); }
1503 # @all_correct_rpms has to contain exactly one value
1505 if ( $#all_correct_rpms > 0 )
1507 my $number = $#all_correct_rpms + 1;
1508 $infoline = "There are $number RPMs for the unique name \"$uniquename\" :\n";
1509 push( @installer::globals::logfileinfo, $infoline);
1510 my $allrpmstring = "";
1511 for ( my $i = 0; $i <= $#all_correct_rpms; $i++ ) { $allrpmstring = $allrpmstring . $all_correct_rpms[$i] . "\n"; }
1512 push( @installer::globals::logfileinfo, $allrpmstring);
1513 installer::exiter::exit_program("ERROR: Found $number RPMs that start with unique name \"$uniquename\". Only one allowed!", "find_rpmname_to_uniquename");
1516 if ( $#all_correct_rpms < 0 )
1518 $infoline = "There is no rpm for the unique name \"$uniquename\"\n";
1519 push( @installer::globals::logfileinfo, $infoline);
1520 installer::exiter::exit_program("ERROR: There is no RPM that start with unique name \"$uniquename\"!", "find_rpmname_to_uniquename");
1523 if ( $#all_correct_rpms == 0 )
1525 $infoline = "Found one rpm for the unique name \"$uniquename\" : $all_correct_rpms[0]\n";
1526 push( @installer::globals::logfileinfo, $infoline);
1529 return $all_correct_rpms[0];
1532 #######################################################
1533 # Including the complete RPM name into the xml file
1534 #######################################################
1536 sub set_rpmname_into_xmlfile
1538 my ($rpmname, $uniquename, $xmlfile) = @_;
1540 my $foundrpm = 0;
1541 my $rpmnameset = 0;
1543 for ( my $i = 0; $i <= $#{$xmlfile}; $i++ )
1545 my $oneline = ${$xmlfile}[$i];
1547 if ( $oneline =~ /^\s*rpmUniqueName\s*\=\s*\"\Q$uniquename\E\"\s*$/ )
1549 $foundrpm = 1;
1551 my $number = $i;
1552 $number++;
1554 while ( ! ( ${$xmlfile}[$number] =~ /\/\>\s*$/ ))
1556 if ( ${$xmlfile}[$number] =~ /RPMFILENAMEPLACEHOLDER/ )
1558 ${$xmlfile}[$number] =~ s/RPMFILENAMEPLACEHOLDER/$rpmname/;
1559 $rpmnameset = 1;
1560 $infoline = "Setting RPM name for $uniquename : $rpmname\n";
1561 push( @installer::globals::logfileinfo, $infoline);
1562 last;
1565 $number++;
1568 last;
1572 if ( ! $foundrpm )
1574 $infoline = "ERROR: Did not find $rpmname in xml file !\n";
1575 push( @installer::globals::logfileinfo, $infoline);
1578 if ( ! $rpmnameset )
1580 $infoline = "ERROR: Did not set rpm name for $uniquename in xml file !\n";
1581 push( @installer::globals::logfileinfo, $infoline);
1586 ############################################################
1587 # Including the rpm path dynamically into the xml file.
1588 # This is introduced, because system integration has
1589 # variable PackageVersion and PackageRevision in xml file.
1590 ############################################################
1592 sub put_rpmpath_into_xmlfile
1594 my ($xmlfile, $listofpackages) = @_;
1596 my $infoline = "";
1598 my $alluniquenames = collect_uniquenames_in_xmlfile($xmlfile);
1600 my $number = $#{$listofpackages} + 1;
1601 $infoline = "Number of packages in installation set: $number\n";
1602 push( @installer::globals::logfileinfo, $infoline);
1603 $number = $#{$alluniquenames} + 1;
1604 $infoline = "Number of unique RPM names in xml file: $number\n";
1605 push( @installer::globals::logfileinfo, $infoline);
1607 $infoline = "\nPackages in installation set:\n";
1608 push( @installer::globals::logfileinfo, $infoline);
1609 for ( my $i = 0; $i <= $#{$listofpackages}; $i++ )
1611 $infoline = "${$listofpackages}[$i]\n";
1612 push( @installer::globals::logfileinfo, $infoline);
1615 $infoline = "\nUnique RPM names in xml file:\n";
1616 push( @installer::globals::logfileinfo, $infoline);
1617 for ( my $i = 0; $i <= $#{$alluniquenames}; $i++ )
1619 $infoline = "${$alluniquenames}[$i]\n";
1620 push( @installer::globals::logfileinfo, $infoline);
1623 if ( $#{$alluniquenames} != $#{$listofpackages} ) { installer::exiter::exit_program("ERROR: xml file contains $#{$alluniquenames} unique names, but there are $#{$listofpackages} packages in installation set!", "put_rpmpath_into_xmlfile"); }
1625 for ( my $i = 0; $i <= $#{$alluniquenames}; $i++ )
1627 my $uniquename = ${$alluniquenames}[$i];
1628 my $rpmname = find_rpmname_to_uniquename($uniquename, $listofpackages);
1629 set_rpmname_into_xmlfile($rpmname, $uniquename, $xmlfile);
1633 #######################################################
1634 # Including the file size of the rpms into the
1635 # xml file
1636 #######################################################
1638 sub put_filesize_into_xmlfile
1640 my ($xmlfile, $listofpackages) = @_;
1642 my $infoline = "";
1644 for ( my $i = 0; $i <= $#{$listofpackages}; $i++ )
1646 my $completerpmname = ${$listofpackages}[$i];
1647 my $rpmname = $completerpmname;
1648 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$rpmname);
1650 if ( ! $installer::globals::rpmquerycommand ) { installer::exiter::exit_program("ERROR: rpm not found for querying packages!", "put_filesize_into_xmlfile"); }
1651 my $systemcall = "$installer::globals::rpmquerycommand -qp --queryformat \"\[\%\{FILESIZES\}\\n\]\" $completerpmname 2\>\&1 |";
1652 my $rpmout = make_systemcall($systemcall, 0);
1653 my $filesize = do_sum($rpmout);
1655 $infoline = "Filesize $rpmname : $filesize\n";
1656 push( @installer::globals::logfileinfo, $infoline);
1658 set_filesize_in_xmlfile($filesize, $rpmname, $xmlfile);
1662 #######################################################
1663 # Creating the java installer class file dynamically
1664 #######################################################
1666 sub create_java_installer
1668 my ( $installdir, $newdir, $languagestringref, $languagesarrayref, $allvariableshashref, $includepatharrayref, $modulesarrayref ) = @_;
1670 installer::logger::include_header_into_logfile("Creating Java installer:");
1672 my $infoline = "";
1674 # collecting all packages or rpms located in the installation directory
1675 my $listofpackages = get_all_packages_in_installdir($installdir, $newdir);
1677 # creating the directory
1678 my $javadir = installer::systemactions::create_directories("javainstaller", $languagestringref);
1679 $javadir =~ s/\/\s*$//;
1680 # push(@installer::globals::removedirs, $javadir);
1682 # copying the content from directory install_sdk into the java directory
1684 my $projectroot = "";
1685 if ( $ENV{'PRJ'} ) { $projectroot = $ENV{'PRJ'}; }
1686 else { installer::exiter::exit_program("ERROR: Environment variable PRJ not set", "create_java_installer"); }
1688 $projectroot =~ s/\/\s*$//;
1689 my $sourcedir = "$projectroot/inc_global/unix/install_sdk";
1690 installer::systemactions::copy_complete_directory_without_cvs($sourcedir, $javadir);
1692 # determining the java template file
1694 my $templatefilename = $javadir . $installer::globals::separator . "locale/resources/MyResources_template.java";
1696 # Saving the content of the template file. It is used in the xml files
1698 my $javatemplateorigfile = installer::files::read_file($templatefilename);
1700 # determining the ulf language file
1702 # my $ulffilename = "installsdk.ulf";
1703 my $ulffilename = "installsdk.jlf";
1704 $ulffilename = $installer::globals::javalanguagepath . $installer::globals::separator . $ulffilename;
1705 my $ulffile = installer::files::read_file($ulffilename);
1707 $infoline = "\nReading ulf file: $ulffilename\n";
1708 push( @installer::globals::logfileinfo, $infoline);
1710 $infoline = "Translating the Java template file\n";
1711 push( @installer::globals::logfileinfo, $infoline);
1713 for ( my $i = 0; $i <= $#{$languagesarrayref}; $i++ )
1715 my $onelanguage = ${$languagesarrayref}[$i];
1717 # replacing all strings in the Java file with content of ulf files
1719 my $templatefile = installer::files::read_file($templatefilename);
1721 set_component_name_and_description($templatefile, $modulesarrayref, $onelanguage);
1722 translate_javafile($templatefile, $ulffile, $onelanguage);
1724 # adding the license file into the Java file
1726 my $licensefilesource = get_licensefilesource($onelanguage, $includepatharrayref);
1727 my $licensefile = installer::files::read_file($licensefilesource);
1728 add_license_file_into_javafile($templatefile, $licensefile, $includepatharrayref, $javadir, $onelanguage);
1730 # setting productname and productversion
1732 set_productname_and_productversion($templatefile, $allvariableshashref);
1734 # setting the class name in the java file ( "MyResources_TEMPLATE" -> "MyResources_en" )
1736 # if ( $onelanguage =~ /^\s*(\w+)\-(\w+)\s*$/ ) { $onelanguage = $1; }
1737 $onelanguage =~ s/en-US/en/; # java file name and class name contain only "_en"
1738 $onelanguage =~ s/\-/\_/; # "pt-BR" -> "pt_BR"
1739 my $classfilename = "MyResources_" . $onelanguage;
1740 set_classfilename($templatefile, $classfilename, "MyResources_TEMPLATE");
1742 # saving the new file
1744 my $newfilename = $templatefilename;
1745 $newfilename =~ s/_template\.java\s*$/_$onelanguage\.java/;
1747 installer::files::save_file($newfilename, $templatefile);
1749 $infoline = "Saving Java file: $newfilename\n";
1750 push( @installer::globals::logfileinfo, $infoline);
1753 # renaming one language java file to "MyResources.java"
1755 my $baselanguage = installer::languages::get_default_language($languagesarrayref);
1756 $baselanguage =~ s/\-/\_/; # "pt-BR" -> "pt_BR"
1757 $baselanguage =~ s/en_US/en/; # java file name and class name contain only "_en"
1758 # if ( $baselanguage =~ /^\s*(\w+)\-(\w+)\s*$/ ) { $baselanguage = $1; } # java file name and class name contain only "_en"
1759 # $baselanguage =~ s/en-US/en/; # java file name and class name contain only "_en"
1760 my $baselanguagefilename = $javadir . $installer::globals::separator . "locale/resources/MyResources_" . $baselanguage . "\.java";
1761 my $basedestfilename = $javadir . $installer::globals::separator . "locale/resources/MyResources.java";
1762 installer::systemactions::copy_one_file($baselanguagefilename, $basedestfilename);
1764 # setting the class file name also for the base class
1766 my $basetemplatefile = installer::files::read_file($basedestfilename);
1767 my $oldclassfilename = $baselanguagefilename;
1768 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$oldclassfilename);
1769 $oldclassfilename =~ s/\.java//;
1770 my $newclassfilename = $basedestfilename;
1771 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$newclassfilename);
1772 $newclassfilename =~ s/\.java//;
1774 set_classfilename($basetemplatefile, $newclassfilename, $oldclassfilename);
1776 installer::files::save_file($basedestfilename, $basetemplatefile);
1778 $infoline = "Created base Java file: $basedestfilename\n";
1779 push( @installer::globals::logfileinfo, $infoline);
1781 # deleting the template file
1783 unlink($templatefilename);
1785 $infoline = "Deleted template Java resource file: $templatefilename\n";
1786 push( @installer::globals::logfileinfo, $infoline);
1788 # changing into Java directory
1790 my $from = cwd();
1792 chdir($javadir);
1794 $infoline = "Changing into directory: $javadir\n";
1795 push( @installer::globals::logfileinfo, $infoline);
1797 # preparing the xml file
1799 my $xmlfilename = "";
1800 my $subdir = "";
1802 if ( $installer::globals::issolarispkgbuild )
1804 $xmlfilename = "pkgUnit.xml";
1806 elsif ( $installer::globals::islinuxrpmbuild )
1808 $xmlfilename = "rpmUnit.xml";
1810 else
1812 installer::exiter::exit_program("ERROR: No platform for Install SDK", "create_java_installer");
1815 # reading, editing and saving the xmlfile
1817 my $xmlfile = installer::files::read_file($xmlfilename);
1818 prepare_language_pack_in_xmlfile($xmlfile, $languagesarrayref);
1819 my $xmlfilename2 = $xmlfilename . ".test2";
1820 installer::files::save_file($xmlfilename2, $xmlfile);
1821 remove_empty_packages_in_xmlfile($xmlfile);
1822 my $xmlfilename3 = $xmlfilename . ".test3";
1823 installer::files::save_file($xmlfilename3, $xmlfile);
1824 substitute_variables($xmlfile, $allvariableshashref);
1825 if (( $installer::globals::islinuxrpmbuild ) && ( $#installer::globals::linkrpms > -1 )) { prepare_linkrpm_in_xmlfile($xmlfile,\@installer::globals::linkrpms); }
1826 if ( $installer::globals::issolarisx86build || $installer::globals::islinuxbuild ) { remove_w4w_from_xmlfile($xmlfile); }
1827 remove_module_if_not_defined($xmlfile, $modulesarrayref, "gid_Module_Optional_Onlineupdate");
1828 replace_component_names($xmlfile, $templatefilename, $modulesarrayref, $javatemplateorigfile, $ulffile);
1829 my $xmlfilename4 = $xmlfilename . ".test4";
1830 installer::files::save_file($xmlfilename4, $xmlfile);
1831 if ( $installer::globals::islinuxrpmbuild ) { put_rpmpath_into_xmlfile($xmlfile, $listofpackages); }
1832 if ( $installer::globals::islinuxrpmbuild ) { put_filesize_into_xmlfile($xmlfile, $listofpackages); }
1833 installer::files::save_file($xmlfilename, $xmlfile);
1834 $infoline = "Saving xml file: $xmlfilename\n";
1835 push( @installer::globals::logfileinfo, $infoline);
1837 # Setting the classpath and starting compiler
1839 set_classpath_for_install_sdk($javadir);
1841 # creating class files:
1842 # language class file, dialog class files, installer class file
1844 my $jdkpath = "";
1845 if ( $ENV{'JDKPATH'} ) { $jdkpath = $ENV{'JDKPATH'}; }
1847 my $javac = "javac";
1848 if ( $jdkpath ) { $javac = $jdkpath . $installer::globals::separator . $javac; }
1850 my $systemcall = "$javac locale\/resources\/\*\.java 2\>\&1 |";
1851 make_systemcall($systemcall, 1);
1853 $systemcall = "$javac com\/sun\/staroffice\/install\/\*\.java 2\>\&1 |";
1854 make_systemcall($systemcall, 1);
1856 # making subdirectory creating empty packages
1857 create_empty_packages($xmlfile);
1859 # Copy "jresetup" from solver locally to include it into the classfile
1860 # Copy "jresetup" from solver to installdir
1862 my $setupname = "jresetup";
1863 my $newname = "setup";
1864 copy_setup_locally($includepatharrayref, $setupname, $newname);
1866 my $java = "java";
1867 if ( $jdkpath ) { $java = $jdkpath . $installer::globals::separator . $java; }
1869 $systemcall = "$java com.sun.setup.builder.InstallBuilder $xmlfilename -novalidate 2\>\&1 |";
1870 make_systemcall($systemcall, 1);
1872 # copying the newly created classfile into the installation set
1874 my $archivefilename = get_archivefilename($xmlfile);
1875 $archivefilename = $archivefilename . ".class";
1877 if ( ! -f $archivefilename ) { installer::exiter::exit_program("ERROR: Could not find Java class file $archivefilename!", "create_java_installer"); }
1879 installer::systemactions::copy_one_file($archivefilename, $installdir);
1881 # Adding the loader into the installation set. The name of the loader is setup.
1882 put_loader_into_installset($installdir, $newname);
1884 chdir($from);
1886 $infoline = "Changing into directory: $from\n";
1887 push( @installer::globals::logfileinfo, $infoline);