update dev300-m58
[ooovba.git] / solenv / bin / modules / installer / xpdinstaller.pm
blob5b97d23f8816c59d100bc7f53a7a032e907a1248
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: xpdinstaller.pm,v $
11 # $Revision: 1.19 $
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::xpdinstaller;
33 use Cwd;
34 use installer::converter;
35 use installer::exiter;
36 use installer::globals;
37 use installer::languages;
38 use installer::logger;
39 use installer::pathanalyzer;
40 use installer::remover;
41 use installer::systemactions;
44 #######################################################
45 # Searching for the module name and description in the
46 # modules collector
47 #######################################################
49 sub get_module_name_description
51 my ($modulesarrayref, $onelanguage, $gid, $type) = @_;
53 my $found = 0;
55 my $newstring = "";
57 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
59 my $onemodule = ${$modulesarrayref}[$i];
61 if ( $onemodule->{'gid'} eq $gid )
63 my $typestring = $type . " " . "(" . $onelanguage . ")";
64 if ( $onemodule->{$typestring} ) { $newstring = $onemodule->{$typestring}; }
65 $found = 1;
68 if ( $found ) { last; }
71 # defaulting to english
73 if ( ! $found )
75 my $defaultlanguage = "en-US";
77 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
79 my $onemodule = ${$modulesarrayref}[$i];
81 if ( $onemodule->{'gid'} eq $gid )
83 my $typestring = $type . " " . "(" . $defaultlanguage . ")";
84 if ( $onemodule->{$typestring} ) { $newstring = $onemodule->{$typestring}; }
85 $found = 1;
88 if ( $found ) { last; }
92 return $newstring;
95 ###################################################
96 # Finding module, specified by the gid
97 ###################################################
99 sub get_module
101 my ($modulegid, $modulesarrayref) = @_;
103 my $found = 0;
104 my $searchmodule = "";
106 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
108 my $onemodule = ${$modulesarrayref}[$i];
110 if ( $onemodule->{'gid'} eq $modulegid )
112 $searchmodule = $onemodule;
113 $found = 1;
114 last;
117 # if ( ! $found ) { installer::exiter::exit_program("ERROR: Could not find module belonging to gid $modulegid!", "get_module (xpdinstaller)"); }
120 return $searchmodule;
123 ###################################################
124 # Creating package start tag
125 ###################################################
127 sub get_package_tag
129 my ( $module, $indent, $linkpackage ) = @_;
131 my $modulegid = $module->{'gid'};
132 if ( $linkpackage ) { $modulegid = $modulegid . "u"; }
133 my $parentgid = "";
134 if ( $module->{'ParentID'} ) { $parentgid = $module->{'ParentID'}; }
135 if ( $parentgid eq "" ) { $parentgid = "root"; }
136 if ( $module->{'XPDParentID'} ) { $parentgid = $module->{'XPDParentID'}; } # changing parent of "Prg" and "Opt" to "root"
138 my $tag = $indent . "<package " . "name=" . "\"" . $modulegid . "\" " . "parent=" . "\"" . $parentgid . "\">" . "\n";
140 return ( $tag, $parentgid );
143 ###################################################
144 # Creating display start tag
145 ###################################################
147 sub get_display_tag
149 my ( $module, $indent ) = @_;
151 # Styles=(HIDDEN_ROOT)
152 my $styles = "";
153 my $type = "";
154 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
155 if ( $styles =~ /\bHIDDEN_ROOT\b/ ) { $type = "hidden"; }
156 else { $type = "show"; }
158 # special handling for language modules. Only visible in multilingual installation set.
159 if (( $styles =~ /\bSHOW_MULTILINGUAL_ONLY\b/ ) && ( ! $installer::globals::ismultilingual )) { $type = "hidden"; }
161 # special handling for the root module, which has no parent
162 my $parentgid = "";
163 if ( $module->{'ParentID'} ) { $parentgid = $module->{'ParentID'}; }
164 if ( $parentgid eq "" ) { $type = "hidden"; }
166 my $tag = $indent . "<display " . "type=" . "\"" . $type . "\"" . ">" . "\n";
168 return $tag;
171 ###################################################
172 # Creating installunit start tag
173 ###################################################
175 sub get_installunit_tag
177 my ( $indent ) = @_;
179 my $type = $installer::globals::packageformat;
181 my $tag = $indent . "<installunit " . "type=" . "\"" . $type . "\"" . ">" . "\n";
183 return $tag;
186 ###################################################
187 # Creating simple start tags
188 ###################################################
190 sub get_start_tag
192 my ( $tag, $indent ) = @_;
194 my $starttag = $indent . "<" . $tag . ">" . "\n";
195 return $starttag;
198 ###################################################
199 # Creating end tags
200 ###################################################
202 sub get_end_tag
204 my ( $tag, $indent ) = @_;
206 my $endtag = $indent . "</" . $tag . ">" . "\n";
207 return $endtag;
210 ###################################################
211 # Creating simple complete tag
212 ###################################################
214 sub get_tag_line
216 my ( $indent, $name, $value ) = @_;
217 $value = '' unless defined $value;
219 my $line = $indent . "<" . $name . ">" . $value . "</" . $name . ">" . "\n";
223 ###################################################
224 # Asking module for sortkey entry
225 ###################################################
227 sub get_sortkey_value
229 my ( $module ) = @_;
231 my $value = "9999";
233 if ( $module->{'Sortkey'} ) { $value = $module->{'Sortkey'}; }
235 return $value;
238 ###################################################
239 # Asking module for default entry
240 ###################################################
242 sub get_default_value
244 my ( $module ) = @_;
246 my $value = "";
248 if ( $module->{'Default'} ) { $value = $module->{'Default'}; } # is YES or NO
250 if ( $value =~ /\bNO\b/i ) { $value = "false"; }
251 else { $value = "true"; }
253 return $value;
256 ###################################################
257 # Asking module for showinuserinstall entry
258 # scp style: DONTSHOWINUSERINSTALL
259 ###################################################
261 sub get_showinuserinstall_value
263 my ( $module ) = @_;
265 my $value = "true";
267 my $styles = "";
268 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
269 if ( $styles =~ /\bDONTSHOWINUSERINSTALL\b/ ) { $value = "false"; }
271 return $value;
274 ###################################################
275 # Asking module for showinuserinstall entry
276 # scp style: USERINSTALLONLY
277 ###################################################
279 sub get_userinstallonly_value
281 my ( $module ) = @_;
283 my $value = "false";
285 my $styles = "";
286 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
287 if ( $styles =~ /\bUSERINSTALLONLY\b/ ) { $value = "true"; }
289 return $value;
292 ###################################################
293 # Asking module for dontuninstall entry
294 # scp style: DONTUNINSTALL
295 ###################################################
297 sub get_dontuninstall_value
299 my ( $module ) = @_;
301 my $value = "false";
303 my $styles = "";
304 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
305 if ( $styles =~ /\bDONTUNINSTALL\b/ ) { $value = "true"; }
307 return $value;
310 ###################################################
311 # Asking module for XpdCheckSolaris entry
312 # (belongs to scp module)
313 ###################################################
315 sub get_checksolaris_value
317 my ( $module ) = @_;
319 my $value = "";
320 if ( $module->{'XpdCheckSolaris'} ) { $value = $module->{'XpdCheckSolaris'}; }
322 return $value;
325 ###################################################
326 # Asking module for isupdatepackage entry
327 # scp style: ISUPDATEPACKAGE
328 ###################################################
330 sub get_isupdatepackage_value
332 my ( $module ) = @_;
334 my $value = "false";
336 my $styles = "";
337 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
338 if ( $styles =~ /\bISUPDATEPACKAGE\b/ ) { $value = "true"; }
340 return $value;
343 ###################################################
344 # Asking module for showmultilingualonly entry
345 # scp style: SHOW_MULTILINGUAL_ONLY
346 ###################################################
348 sub get_showmultilingualonly_value
350 my ( $module ) = @_;
352 my $value = "false";
354 my $styles = "";
355 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
356 if ( $styles =~ /\bSHOW_MULTILINGUAL_ONLY\b/ ) { $value = "true"; }
358 return $value;
361 ###################################################
362 # Asking module for showmultilingualonly entry
363 # scp style: SHOW_MULTILINGUAL_ONLY
364 ###################################################
366 sub get_applicationmodule_value
368 my ( $module ) = @_;
370 my $value = "false";
372 my $styles = "";
373 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
374 if ( $styles =~ /\bAPPLICATIONMODULE\b/ ) { $value = "true"; }
376 return $value;
379 ###################################################
380 # Asking module for java module entry
381 # scp style: JAVAMODULE
382 ###################################################
384 sub get_isjavamodule_value
386 my ( $module ) = @_;
388 my $value = "false";
390 my $styles = "";
391 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
392 if ( $styles =~ /\bJAVAMODULE\b/ ) { $value = "true"; }
394 return $value;
397 #####################################################################
398 # Asking module, if installation shall use --force
399 # scp style: USEFORCE (Linux only)
400 #####################################################################
402 sub get_useforce_value
404 my ( $module ) = @_;
406 my $value = "false";
408 my $styles = "";
409 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
410 if ( $styles =~ /\bUSEFORCE\b/ ) { $value = "true"; }
412 return $value;
415 ###################################################
416 # Asking module, if installation can fail
417 # scp style: INSTALLCANFAIL
418 ###################################################
420 sub get_installcanfail_value
422 my ( $module ) = @_;
424 my $value = "false";
426 my $styles = "";
427 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
428 if ( $styles =~ /\bINSTALLCANFAIL\b/ ) { $value = "true"; }
430 return $value;
433 ###################################################
434 # Asking module, if installation can fail
435 # scp style: INSTALLCANFAIL
436 ###################################################
438 sub get_forceintoupdate_value
440 my ( $module ) = @_;
442 my $value = "false";
444 my $styles = "";
445 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
446 if ( $styles =~ /\bFORCEINTOUPDATE\b/ ) { $value = "true"; }
448 return $value;
451 ###################################################
452 # Substituting all occurences of "\uUXYZ" by
453 # "&#xUXYZ;", because the use xml saxparser does
454 # not know anything about this encoding. Therfore
455 # the xml file can keep standard encoding "UTF-8"
456 # and all strings with "\uUXYZ" do not need to
457 # be converted from the Java installer.
458 ###################################################
460 sub replace_javaencoding_in_string
462 my ( $string ) = @_;
464 while ( $string =~ /(\\u\w\w\w\w)/ )
466 my $oldvalue = $1;
467 my $newvalue = "";
468 if ( $oldvalue =~ /\\u(\w\w\w\w)/ )
470 my $number = $1;
471 $newvalue = "&#x" . $number . ";";
474 $string =~ s/\Q$oldvalue\E/$newvalue/;
477 return $string;
480 ###################################################
481 # Collecting language dependent entries from scp
482 # (Name and Description)
483 ###################################################
485 sub collect_lang_values
487 my ($indent, $module, $xpdfile, $searchentry, $saveentry) = @_;
489 foreach $key (keys %{$module})
491 my $write_line = 0;
492 my $javalanguage = "";
494 if ( $key =~ /^\s*\Q$searchentry\E\s+\((\S+)\)\s*$/ ) # this are the language dependent keys
496 $language = $1;
497 $javalanguage = installer::languages::get_java_language($language);
498 $write_line = 1;
500 elsif ( $key =~ /^\s*\Q$searchentry\E\s*$/ ) # this are the language independent keys
502 $javalanguage = "en_US";
503 $write_line = 1;
506 if ( $write_line )
508 my $value = $module->{$key};
509 $value = replace_javaencoding_in_string($value);
510 my $line = $indent . "<" . $saveentry . " lang=" . "\"" . $javalanguage . "\"" . ">" . $value . "<\/" . $saveentry . ">" . "\n";
511 push(@{$xpdfile}, $line);
516 ###################################################
517 # Removing language dependent entries from
518 # module hash (Name and Description)
519 ###################################################
521 sub remove_lang_values
523 my ($module, $searchentry) = @_;
525 my $key = "";
527 foreach $key (keys %{$module})
529 if ( $key =~ /^\s*\Q$searchentry\E\s+\((\S+)\)\s*$/ ) # this are the language dependent keys
531 delete($module->{$key});
536 ###################################################
537 # Setting package install order
538 ###################################################
540 sub get_order_value
542 my ( $module ) = @_;
544 my $value = "1000"; # Setting the default value
546 if ( $module->{'InstallOrder'} ) { $value = $module->{'InstallOrder'}; }
548 return $value;
551 ###################################################
552 # Checking size of package
553 ###################################################
555 sub get_size_value
557 my ( $packagename, $xpdinfo ) = @_;
559 my $value = "";
561 if ( $xpdinfo->{'FileSize'} )
563 $value = $xpdinfo->{'FileSize'};
564 return $value;
567 my $isrpmfile = 0;
568 if ( $packagename =~ /\.rpm\s*$/ ) { $isrpmfile = 1; }
570 if (( $installer::globals::islinuxrpmbuild ) && ( $isrpmfile ))
572 # if ( ! $installer::globals::rpmquerycommand ) { installer::exiter::exit_program("ERROR: rpm not found for querying packages!", "get_size_value"); }
573 if ( ! $installer::globals::rpmquerycommand ) { $installer::globals::rpmquerycommand = "rpm"; }
575 my $systemcall = "$installer::globals::rpmquerycommand -qp --queryformat \"\[\%\{FILESIZES\}\\n\]\" $packagename 2\>\&1 |";
576 my $ld_library_backup = $ENV{LD_LIBRARY_PATH};
577 if ( defined $ENV{SYSBASE}) {
578 my $sysbase = $ENV{SYSBASE};
579 if ( !defined ($ld_library_backup) or ("$ld_library_backup" eq "") ) {
580 $ld_library_backup = "" if ! defined $ld_library_backup;
581 $ENV{LD_LIBRARY_PATH} = "$sysbase/usr/lib";
582 } else {
583 $ENV{LD_LIBRARY_PATH} = "$ld_library_backup:$sysbase/lib";
586 my ($rpmout, $error) = make_systemcall_allowing_error($systemcall, 0, 1);
587 $ENV{LD_LIBRARY_PATH} = $ld_library_backup;
588 # Evaluating an error, because of rpm problems with removed LD_LIBRARY_PATH
589 if ( $error )
591 installer::logger::print_message( "... trying /usr/bin/rpm ...\n" );
592 my $systemcall = "/usr/bin/rpm -qp --queryformat \"\[\%\{FILESIZES\}\\n\]\" $packagename 2\>\&1 |";
593 ($rpmout, $error) = make_systemcall_allowing_error($systemcall, 0, 0);
594 if ( $error ) { installer::exiter::exit_program("ERROR: rpm failed to query package!", "get_size_value"); }
596 $value = do_sum($rpmout); # adding all filesizes in bytes
597 $value = $value/1000;
599 my $ganzzahl = int $value;
600 if ($ganzzahl < $value) { $value = $ganzzahl + 1; }
601 else { $value = $ganzzahl; }
603 my $rpmname = $packagename;
604 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$rpmname);
605 $infoline = "Filesize $rpmname : $value\n";
606 push( @installer::globals::logfileinfo, $infoline);
609 if ( $installer::globals::issolarispkgbuild )
611 my $filename = "pkgmap";
612 $filename = $packagename . $installer::globals::separator . $filename;
613 $file = installer::files::read_file($filename);
615 for ( my $i = 0; $i <= $#{$file}; $i++ )
617 my $line = ${$file}[$i];
618 if ( $line =~ /^\s*\:\s+\d+\s+(\d+?)\s+/ )
620 $value = $1;
621 if ( ! ( $value%2 == 0 )) { $value = $value + 1; }
622 $value = $value/2; # not blocks, but kB
623 last;
628 if ( $value eq "" ) { $value = "0"; }
630 return $value;
633 ###################################################
634 # Checking md5 of package
635 ###################################################
637 sub get_md5_value
639 my ( $packagename, $xpdinfo ) = @_;
641 my $value = "";
643 if ( $xpdinfo->{'md5sum'} )
645 $value = $xpdinfo->{'md5sum'};
646 return $value;
649 if ( $installer::globals::islinuxrpmbuild )
651 my $md5file = "/usr/bin/md5sum";
653 if ( -x $md5file )
655 my $systemcall = "$md5file $packagename 2\>\&1 |";
656 my $md5out = make_systemcall($systemcall, 1);
657 $value = ${$md5out}[0];
658 if ( $value =~ /^\s*(\S+?)\s+.*$/ )
660 $value = $1;
663 my $rpmname = $packagename;
664 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$rpmname);
665 $infoline = "md5sum of $rpmname : $value\n";
666 push( @installer::globals::logfileinfo, $infoline);
670 return $value;
673 ###################################################
674 # Checking name of package
675 ###################################################
677 sub get_name_value
679 my ( $packagename ) = @_;
681 my $value = $packagename;
683 # $packagename contains the complete path to the package
684 # Only the name of file or directory is required
686 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$value);
688 return $value;
691 ###################################################
692 # Checking full package name (Linux only)
693 ###################################################
695 sub get_fullpkgname_value
697 my ( $packagename, $xpdinfo ) = @_;
699 my $value = "";
700 my $isrpmfile = 0;
701 if ( $packagename =~ /\.rpm\s*$/ ) { $isrpmfile = 1; }
703 if (( $installer::globals::islinuxrpmbuild ) && ( $isrpmfile ))
705 if ( $xpdinfo->{'FullPackageName'} )
707 $value = $xpdinfo->{'FullPackageName'};
708 return $value;
711 # if ( ! $installer::globals::rpmquerycommand ) { installer::exiter::exit_program("ERROR: rpm not found for querying packages!", "get_fullpkgname_value"); }
712 if ( ! $installer::globals::rpmquerycommand ) { $installer::globals::rpmquerycommand = "rpm"; }
713 my $systemcall = "$installer::globals::rpmquerycommand -qp $packagename |";
714 my $ld_library_backup = $ENV{LD_LIBRARY_PATH};
715 if ( defined $ENV{SYSBASE}) {
716 my $sysbase = $ENV{SYSBASE};
717 if ( !defined ($ld_library_backup) or ("$ld_library_backup" eq "") ) {
718 $ld_library_backup = "" if ! defined $ld_library_backup;
719 $ENV{LD_LIBRARY_PATH} = "$sysbase/usr/lib";
720 } else {
721 $ENV{LD_LIBRARY_PATH} = "$ld_library_backup:$sysbase/lib";
724 my ($returnarray, $error) = make_systemcall_allowing_error($systemcall, 0, 1);
725 $ENV{LD_LIBRARY_PATH} = $ld_library_backup;
726 # Evaluating an error, because of rpm problems with removed LD_LIBRARY_PATH
727 if ( $error )
729 installer::logger::print_message( "... trying /usr/bin/rpm ...\n" );
730 my $systemcall = "/usr/bin/rpm -qp $packagename |";
731 ($returnarray, $error) = make_systemcall_allowing_error($systemcall, 0, 0);
732 if ( $error ) { installer::exiter::exit_program("ERROR: rpm failed to query package!", "get_fullpkgname_value"); }
734 $value = ${$returnarray}[0];
735 installer::remover::remove_leading_and_ending_whitespaces(\$value);
737 my $rpmname = $packagename;
738 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$rpmname);
740 $infoline = "Full package name from $rpmname: $value\n";
741 push( @installer::globals::logfileinfo, $infoline);
744 return $value;
747 ###################################################
748 # Checking package version (Solaris only)
749 ###################################################
751 sub get_pkgversion_value
753 my ( $completepackagename, $xpdinfo ) = @_;
755 my $value = "";
757 if ( $xpdinfo->{'PkgVersion'} )
759 $value = $xpdinfo->{'PkgVersion'};
760 return $value;
763 if ( $installer::globals::issolarispkgbuild )
765 my $pkgfile = "pkgparam";
766 my $packagepath = $completepackagename;
767 installer::pathanalyzer::get_path_from_fullqualifiedname(\$packagepath);
769 my $packagename = $completepackagename;
770 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$packagename);
772 my $systemcall = "$pkgfile -d $packagepath $packagename param VERSION 2\>\&1 |";
773 my $returnarray = make_systemcall($systemcall, 0);
775 $value = ${$returnarray}[0];
776 installer::remover::remove_leading_and_ending_whitespaces(\$value);
779 return $value;
782 ###################################################
783 # Writing subdirectory into xpd file
784 ###################################################
786 sub get_subdir_value
788 my ( $packagename, $subdir, $module ) = @_;
790 my $value = "";
792 if ( $subdir ) { $value = $subdir; }
794 if ( $module->{'Subdir'} ) { $value = $module->{'Subdir'}; }
796 return $value;
799 ###################################################
800 # Checking if package is relocatable
801 ###################################################
803 sub get_relocatable_value
805 my ( $module ) = @_;
807 my $value = "true";
809 my $styles = "";
810 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
811 if ( $styles =~ /\bNOTRELOCATABLE\b/ ) { $value = "false"; }
813 return $value;
816 ###################################################
817 # Checking if package is relocatable
818 ###################################################
820 sub get_languagespecific_value
822 my ( $islanguagemodule ) = @_;
824 my $value = "false";
826 if ( defined $islanguagemodule && $islanguagemodule == 1 ) { $value = "true"; }
828 return $value;
831 #######################################################
832 # Adding the values of the array
833 #######################################################
835 sub do_sum
837 my ( $allnumbers ) = @_;
839 my $sum = 0;
841 for ( my $i = 0; $i <= $#{$allnumbers}; $i++ )
843 $sum = $sum + ${$allnumbers}[$i];
846 return $sum;
849 #######################################################
850 # Executing one system call
851 #######################################################
853 sub make_systemcall
855 my ( $systemcall, $logreturn ) = @_;
857 my @returns = ();
859 installer::logger::print_message( "... $systemcall ...\n" );
861 open (REG, "$systemcall");
862 while (<REG>) {push(@returns, $_); }
863 close (REG);
865 my $returnvalue = $?; # $? contains the return value of the systemcall
867 my $infoline = "Systemcall: $systemcall\n";
868 push( @installer::globals::logfileinfo, $infoline);
870 if ( $logreturn )
872 for ( my $j = 0; $j <= $#returns; $j++ ) { push( @installer::globals::logfileinfo, "$returns[$j]"); }
875 if ($returnvalue)
877 $infoline = "ERROR: $systemcall\n";
878 push( @installer::globals::logfileinfo, $infoline);
879 $error_occured = 1;
881 else
883 $infoline = "SUCCESS: $systemcall\n";
884 push( @installer::globals::logfileinfo, $infoline);
887 return \@returns;
890 #######################################################
891 # Executing one system call
892 #######################################################
894 sub make_systemcall_allowing_error
896 my ( $systemcall, $logreturn, $can_fail ) = @_;
898 my @returns = ();
900 installer::logger::print_message( "... $systemcall ...\n" );
902 open (REG, "$systemcall");
903 while (<REG>) {push(@returns, $_); }
904 close (REG);
906 my $returnvalue = $?; # $? contains the return value of the systemcall
908 my $infoline = "Systemcall: $systemcall\n";
909 push( @installer::globals::logfileinfo, $infoline);
911 if ( $logreturn )
913 for ( my $j = 0; $j <= $#returns; $j++ ) { push( @installer::globals::logfileinfo, "$returns[$j]"); }
916 if ($returnvalue)
918 if ( $can_fail )
920 $infoline = "WARNING: Failed system call: $systemcall\n";
921 push( @installer::globals::logfileinfo, $infoline);
922 $error_occured = 1;
924 else
926 $infoline = "ERROR: $systemcall\n";
927 push( @installer::globals::logfileinfo, $infoline);
928 $error_occured = 1;
931 else
933 $infoline = "SUCCESS: $systemcall\n";
934 push( @installer::globals::logfileinfo, $infoline);
937 return (\@returns, $returnvalue);
940 ###################################################
941 # Setting product name tag
942 ###################################################
944 sub get_product_tag
946 my ($allvariables, $indent) = @_;
948 my $productname = $allvariables->{'LCONEWORDPRODUCTNAME'};
949 my $tag = $indent . "<product " . "name=" . "\"" . $productname . "\">" . "\n";
951 return $tag;
954 ###################################################
955 # Macro tags
956 ###################################################
958 sub set_macro_tag
960 my ($allvariables, $indent, $key) = @_;
962 my $property = "";
963 my $value = "";
965 if ( $key eq "product_name" ) { $property = "PRODUCTNAME"; }
966 elsif ( $key eq "product_version" ) { $property = "PRODUCTVERSION"; }
967 elsif ( $key eq "product_suffix" ) { $property = "PRODUCTEXTENSION"; }
968 elsif ( $key eq "product_fullname" ) { $property = "FULLPRODUCTNAME"; }
970 if (( $property eq "PRODUCTNAME" ) || ( $property eq "PRODUCTVERSION" ) || ( $property eq "PRODUCTEXTENSION" ))
972 $value = $allvariables->{$property};
975 if ( $property eq "FULLPRODUCTNAME" )
977 $value = $allvariables->{"PRODUCTNAME"} . " " . $allvariables->{"PRODUCTVERSION"};
978 if ( $allvariables->{"PRODUCTEXTENSION"} ) { $value = $value . " " . $allvariables->{"PRODUCTEXTENSION"}; }
981 my $tag = $indent . "<macro " . "key=" . "\"" . $key . "\">" . $value . "\<\/macro\>" . "\n";
983 return $tag;
987 ###################################################
988 # Setting the minor of the product version
989 # Required to check for Major Upgrades.
990 ###################################################
992 sub set_minor_tag
994 my ($allvariables, $indent) = @_;
996 my $productminor = 0;
997 if ( $allvariables->{"PACKAGEVERSION"} )
999 if ( $allvariables->{"PACKAGEVERSION"} =~ /^\s*\d+\.(\d+)/ ) { $productminor = $1; }
1001 my $tag = $indent . "<productminor>" . $productminor . "</productminor>" . "\n";
1003 return $tag;
1006 ###################################################
1007 # Setting the update behaviour
1008 ###################################################
1010 sub set_update_tag
1012 my ($allvariables, $indent) = @_;
1014 my $updateflag = "false";
1015 if ( $allvariables->{"DONTUPDATE"} ) { $updateflag = "true"; }
1016 my $tag = $indent . "<dontupdate>" . $updateflag . "</dontupdate>" . "\n";
1018 return $tag;
1021 ###################################################
1022 # Setting the license dialog behaviour
1023 ###################################################
1025 sub set_hideeula_tag
1027 my ($allvariables, $indent) = @_;
1029 my $hidelicenseflag = "false";
1030 if ( $allvariables->{"HIDELICENSEDIALOG"} ) { $hidelicenseflag = "true"; }
1031 my $tag = $indent . "<hideeula>" . $hidelicenseflag . "</hideeula>" . "\n";
1033 return $tag;
1036 ###################################################
1037 # Setting default directory
1038 ###################################################
1040 sub set_defaultdir_tag
1042 my ($allvariables, $indent) = @_;
1044 my $defaultdir = "";
1045 if ( $allvariables->{"DEFAULTDESTPATH"} ) { $defaultdir = $allvariables->{"DEFAULTDESTPATH"}; }
1046 my $tag = $indent . "<defaultdir>" . $defaultdir . "</defaultdir>" . "\n";
1048 return $tag;
1051 ###################################################
1052 # Setting product directory
1053 ###################################################
1055 sub set_productdir_tag
1057 my ($allvariables, $indent) = @_;
1059 my $productdir = "";
1060 if ( $allvariables->{"UNIXPRODUCTNAME"} )
1062 $productdir = $allvariables->{"UNIXPRODUCTNAME"};
1064 if ( $allvariables->{"BRANDPACKAGEVERSION"} )
1066 $productdir = $productdir . $allvariables->{"BRANDPACKAGEVERSION"};
1067 # if ( $allvariables->{"LCPRODUCTEXTENSION"} ) { $productdir = $productdir . $allvariables->{"LCPRODUCTEXTENSION"}; }
1069 else
1071 if ( $allvariables->{"PRODUCTVERSION"} )
1073 $productdir = $productdir . $allvariables->{"PRODUCTVERSION"};
1077 my $tag = $indent . "<productdir>" . $productdir . "</productdir>" . "\n";
1079 return $tag;
1082 #####################################################
1083 # Setting the package directory in installation set
1084 #####################################################
1086 sub set_packagedir_tag
1088 my ($indent) = @_;
1090 my $tag = $indent . "<packagedirectory>" . $installer::globals::epmoutpath . "</packagedirectory>" . "\n";
1092 return $tag;
1095 ###################################################
1096 # Setting the packagetype of installation set
1097 ###################################################
1099 sub set_packagetype_tag
1101 my ($indent) = @_;
1103 my $tag = $indent . "<packageformat>" . $installer::globals::packageformat . "</packageformat>" . "\n";
1105 return $tag;
1108 ###################################################
1109 # Setting the architecture of installation set
1110 ###################################################
1112 sub set_architecture_tag
1114 my ($indent) = @_;
1116 my $architecture = "";
1117 if ( $installer::globals::issolarissparcbuild ) { $architecture = "sparc"; }
1118 if ( $installer::globals::issolarisx86build ) { $architecture = "i386"; }
1120 my $tag = $indent . "<architecture>" . $architecture . "</architecture>" . "\n";
1122 return $tag;
1125 ###################################################
1126 # Setting the multi language tag
1127 ###################################################
1129 sub set_multilanguage_tag
1131 my ($indent) = @_;
1133 my $value = "false";
1134 if ( $installer::globals::ismultilingual == 1 ) { $value = "true"; }
1136 my $tag = $indent . "<multilingual>" . $value . "</multilingual>" . "\n";
1138 return $tag;
1141 ###################################################
1142 # Setting the language tag
1143 ###################################################
1145 sub set_language_tag
1147 my ($languagestringref, $indent) = @_;
1149 my $tag = $indent . "<languages>" . $$languagestringref . "</languages>" . "\n";
1151 return $tag;
1154 ###################################################
1155 # Collecting content for product xpd file
1156 ###################################################
1158 # <?xml version='1.0' encoding='utf-8'?>
1160 # <!-- General application description -->
1162 # <product name="openoffice">
1163 # <macro key="product_name">Sun OpenOffice.org</macro>
1164 # <macro key="product_version">1.0</macro>
1165 # <macro key="product_suffix">Mephisto</macro>
1166 # <macro key="product_fullname">Sun OpenOffice.org 1.0 Mephisto</macro>
1167 # <defaultdir>/opt/Sun/OpenOffice.org-Mephisto</defaultdir>
1168 # </product>
1170 sub get_setup_file_content
1172 my ($allvariables, $languagestringref) = @_;
1174 my @xpdfile = ();
1175 my $noindent = "";
1176 my $singleindent = " ";
1178 my $line = "<?xml version='1.0' encoding='utf-8'?>\n\n";
1179 push(@xpdfile, $line);
1180 $line = "<!-- General application description -->\n\n";
1181 push(@xpdfile, $line);
1183 my $tag = get_product_tag($allvariables, $noindent);
1184 push(@xpdfile, $tag);
1186 $tag = set_macro_tag($allvariables, $singleindent, "product_name");
1187 push(@xpdfile, $tag);
1188 $tag = set_macro_tag($allvariables, $singleindent, "product_version");
1189 push(@xpdfile, $tag);
1190 $tag = set_macro_tag($allvariables, $singleindent, "product_suffix");
1191 push(@xpdfile, $tag);
1192 $tag = set_macro_tag($allvariables, $singleindent, "product_fullname");
1193 push(@xpdfile, $tag);
1195 $tag = set_defaultdir_tag($allvariables, $singleindent);
1196 push(@xpdfile, $tag);
1198 $tag = set_productdir_tag($allvariables, $singleindent);
1199 push(@xpdfile, $tag);
1201 $tag = set_minor_tag($allvariables, $singleindent);
1202 push(@xpdfile, $tag);
1204 $tag = set_update_tag($allvariables, $singleindent);
1205 push(@xpdfile, $tag);
1207 $tag = set_packagedir_tag($singleindent);
1208 push(@xpdfile, $tag);
1210 $tag = set_packagetype_tag($singleindent);
1211 push(@xpdfile, $tag);
1213 $tag = set_architecture_tag($singleindent);
1214 push(@xpdfile, $tag);
1216 $tag = set_multilanguage_tag($singleindent);
1217 push(@xpdfile, $tag);
1219 $tag = set_language_tag($languagestringref, $singleindent);
1220 push(@xpdfile, $tag);
1222 $tag = set_hideeula_tag($allvariables, $singleindent);
1223 push(@xpdfile, $tag);
1225 $tag = get_end_tag("product", $noindent);
1226 push(@xpdfile, $tag);
1228 return \@xpdfile;
1231 ###################################################
1232 # Collecting content for xpd file
1233 ###################################################
1235 sub get_file_content
1237 my ( $module, $packagename, $solslanguage, $linkpackage, $isemptyparent, $subdir, $islanguagemodule, $onelanguage, $xpdinfo ) = @_;
1239 my @xpdfile = ();
1240 my $value = "";
1241 my $line = "";
1242 my $noindent = "";
1243 my $singleindent = " ";
1244 my $doubleindent = $singleindent . $singleindent;
1246 my ( $tag, $parentgid ) = get_package_tag($module, $noindent, $linkpackage);
1247 push(@xpdfile, $tag);
1249 # start of installunit tag -> using info from scp module
1251 $tag = get_display_tag($module, $singleindent);
1252 push(@xpdfile, $tag);
1254 $value = get_sortkey_value($module);
1255 $line = get_tag_line($doubleindent, "sortkey", $value);
1256 push(@xpdfile, $line);
1258 $value = get_default_value($module);
1259 $line = get_tag_line($doubleindent, "default", $value);
1260 push(@xpdfile, $line);
1262 $value = get_showinuserinstall_value($module);
1263 $line = get_tag_line($doubleindent, "showinuserinstall", $value);
1264 push(@xpdfile, $line);
1266 $value = get_userinstallonly_value($module);
1267 $line = get_tag_line($doubleindent, "showinuserinstallonly", $value);
1268 push(@xpdfile, $line);
1270 $value = get_dontuninstall_value($module);
1271 $line = get_tag_line($doubleindent, "dontuninstall", $value);
1272 push(@xpdfile, $line);
1274 $value = get_checksolaris_value($module);
1275 $line = get_tag_line($doubleindent, "checksolaris", $value);
1276 push(@xpdfile, $line);
1278 $value = get_isupdatepackage_value($module);
1279 $line = get_tag_line($doubleindent, "isupdatepackage", $value);
1280 push(@xpdfile, $line);
1282 $value = get_showmultilingualonly_value($module);
1283 $line = get_tag_line($doubleindent, "showmultilingualonly", $value);
1284 push(@xpdfile, $line);
1286 $value = get_applicationmodule_value($module);
1287 $line = get_tag_line($doubleindent, "applicationmodule", $value);
1288 push(@xpdfile, $line);
1290 $value = get_isjavamodule_value($module);
1291 $line = get_tag_line($doubleindent, "isjavapackage", $value);
1292 push(@xpdfile, $line);
1294 $value = get_installcanfail_value($module);
1295 $line = get_tag_line($doubleindent, "installcanfail", $value);
1296 push(@xpdfile, $line);
1298 $value = get_forceintoupdate_value($module);
1299 $line = get_tag_line($doubleindent, "forceintoupdate", $value);
1300 push(@xpdfile, $line);
1302 $value = get_useforce_value($module);
1303 $line = get_tag_line($doubleindent, "useforce", $value);
1304 push(@xpdfile, $line);
1306 # iterating over all languages to get names and descriptions
1307 collect_lang_values($doubleindent, $module, \@xpdfile, "Name", "name");
1308 collect_lang_values($doubleindent, $module, \@xpdfile, "Description", "description");
1310 $tag = get_end_tag("display", $singleindent);
1311 push(@xpdfile, $tag);
1313 # end of display tag
1315 if ( ! $isemptyparent )
1317 # start of installunit tag -> using info from package defined in packagelist
1319 $tag = get_installunit_tag($singleindent);
1320 push(@xpdfile, $tag);
1322 $value = get_size_value($packagename, $xpdinfo);
1323 $line = get_tag_line($doubleindent, "size", $value);
1324 push(@xpdfile, $line);
1326 $value = get_order_value($module);
1327 $line = get_tag_line($doubleindent, "installorder", $value);
1328 push(@xpdfile, $line);
1330 $value = get_md5_value($packagename, $xpdinfo);
1331 $line = get_tag_line($doubleindent, "md5", $value);
1332 push(@xpdfile, $line);
1334 $value = get_name_value($packagename);
1335 $line = get_tag_line($doubleindent, "name", $value);
1336 push(@xpdfile, $line);
1338 $value = get_fullpkgname_value($packagename, $xpdinfo);
1339 $line = get_tag_line($doubleindent, "fullpkgname", $value);
1340 push(@xpdfile, $line);
1342 $value = get_pkgversion_value($packagename, $xpdinfo);
1343 $line = get_tag_line($doubleindent, "pkgversion", $value);
1344 push(@xpdfile, $line);
1346 $value = get_subdir_value($packagename, $subdir, $module);
1347 $line = get_tag_line($doubleindent, "subdir", $value);
1348 push(@xpdfile, $line);
1350 $value = get_relocatable_value($module);
1351 $line = get_tag_line($doubleindent, "relocatable", $value);
1352 push(@xpdfile, $line);
1354 $value = get_languagespecific_value($islanguagemodule);
1355 $line = get_tag_line($doubleindent, "languagespecific", $value);
1356 push(@xpdfile, $line);
1358 $value = $onelanguage;
1359 $line = get_tag_line($doubleindent, "language", $value);
1360 push(@xpdfile, $line);
1362 $line = get_tag_line($doubleindent, "solarislanguage", $solslanguage);
1363 push(@xpdfile, $line);
1365 $tag = get_end_tag("installunit", $singleindent);
1366 push(@xpdfile, $tag);
1368 # end of installunit tag
1371 $tag = get_end_tag("package", $noindent);
1372 push(@xpdfile, $tag);
1374 return ( \@xpdfile, $parentgid );
1377 ###################################################
1378 # Setting xpd file name
1379 ###################################################
1381 sub get_xpd_filename
1383 my ($modulegid, $linkpackage) = @_;
1385 if ( $linkpackage ) { $modulegid = $modulegid . "u"; }
1387 my $filename = $modulegid . ".xpd";
1389 return $filename;
1392 ###################################################
1393 # Determine, which package was created newly
1394 ###################################################
1396 sub determine_new_packagename
1398 my ( $installdir, $subdir, $xpdinfo ) = @_;
1400 my $newpackage = "";
1401 $installdir =~ s/\Q$installer::globals::separator\E\s*$//;
1402 my $directory = $installdir . $installer::globals::separator . $subdir;
1403 $directory =~ s/\Q$installer::globals::separator\E\s*$//;
1405 if ( $xpdinfo->{'RealPackageName'} )
1407 $newpackage = $directory . $installer::globals::separator . $xpdinfo->{'RealPackageName'};
1408 push(@installer::globals::currentcontent, $newpackage);
1409 return $newpackage;
1412 my ($newcontent, $allcontent) = installer::systemactions::find_new_content_in_directory($directory, \@installer::globals::currentcontent);
1413 @installer::globals::currentcontent = ();
1414 foreach my $element ( @{$allcontent} ) { push(@installer::globals::currentcontent, $element); }
1416 my $newentriesnumber = $#{$newcontent} + 1;
1417 if ( $newentriesnumber > 1 ) { installer::exiter::exit_program("ERROR: More than one new package in directory $directory", "determine_new_packagename (xpdinstaller)"); }
1418 elsif ( $newentriesnumber < 1 ) { installer::exiter::exit_program("ERROR: No new package in directory $directory", "determine_new_packagename (xpdinstaller)"); }
1419 $newpackage = ${$newcontent}[0];
1421 return $newpackage;
1424 ###################################################
1425 # Checking, if the parentgid is defined in
1426 # another package
1427 ###################################################
1429 sub is_empty_parent
1431 my ($gid, $packages) = @_;
1433 my $is_empty_parent = 1;
1435 for ( my $k = 0; $k <= $#{$packages}; $k++ )
1437 my $onepackage = ${$packages}[$k];
1438 my $packagegid = $onepackage->{'module'};
1440 if ( $packagegid eq $gid )
1442 $is_empty_parent = 0;
1443 last;
1447 return $is_empty_parent;
1450 ###################################################
1451 # Creating additional xpd files for empty parents
1452 ###################################################
1454 sub create_emptyparents_xpd_file
1456 my ($parentgid, $modulesarrayref, $xpddir) = @_;
1458 my $module = get_module($parentgid, $modulesarrayref);
1459 my $grandpagid = "";
1461 if ( $module ne "" )
1463 my $packagename = "";
1464 # all content saved in scp is now available and can be used to create the xpd file
1465 my ( $xpdfile, $newparentgid ) = get_file_content($module, $packagename, "", 0, 1, "", 0, "", "");
1467 $grandpagid = $newparentgid;
1469 my $xpdfilename = get_xpd_filename($parentgid, 0);
1470 $xpdfilename = $xpddir . $installer::globals::separator . $xpdfilename;
1472 installer::files::save_file($xpdfilename, $xpdfile);
1473 push(@installer::globals::allxpdfiles, $xpdfilename);
1474 my $infoline = "Saving xpd file: $xpdfilename\n";
1475 push(@installer::globals::logfileinfo, $infoline);
1478 # push(@installer::globals::emptyxpdparents, $parentgid);
1479 push( @installer::globals::createdxpdfiles, $parentgid);
1481 return $grandpagid;
1484 ###################################################
1485 # Creating additional xpd files for empty parents
1486 ###################################################
1488 sub filter_content_from_xpdfile
1490 my ($xpdfile) = @_;
1492 my @newxpdfile = ();
1494 my $include = 1;
1496 for ( my $i = 0; $i <= $#{$xpdfile}; $i++ )
1498 my $line = ${$xpdfile}[$i];
1500 if (( $line =~ /^\s*\<installunit/ ) && ( $include )) { $include = 0; }
1501 if ( $include ) { push(@newxpdfile, $line); }
1502 if (( $line =~ /^\s*\<\/installunit/ ) && ( ! $include )) { $include = 1; }
1505 return \@newxpdfile;
1508 ##########################################################################
1509 # Changing the parent inside the xpd file
1510 # Old: <package name="gid_Module_Root" parent="root">
1511 # New: <package name="gid_Module_Root_Files_1" parent="gid_Module_Root">
1512 ##########################################################################
1514 sub change_parent_in_xpdfile
1516 my ($xpdfile, $modulename) = @_;
1518 for ( my $i = 0; $i <= $#{$xpdfile}; $i++ )
1520 if ( ${$xpdfile}[$i] =~ /^\s*\<package name\s*=\s*\"(\S+?)\"\s+parent\s*=\s*\"(\S+?)\"\s*\>\s*$/ )
1522 my $oldname = $1;
1523 my $oldparent = $2;
1525 my $newname = $modulename;
1526 my $newparent = $oldname;
1528 ${$xpdfile}[$i] =~ s/\"\Q$oldname\E\"/\"$newname\"/;
1529 ${$xpdfile}[$i] =~ s/\"\Q$oldparent\E\"/\"$newparent\"/;
1531 last;
1536 ###################################################
1537 # Creating one xpd file for each package
1538 ###################################################
1540 sub create_xpd_file
1542 my ($onepackage, $allpackages, $languagestringref, $allvariables, $modulesarrayref, $installdir, $subdir, $linkpackage, $xpdinfo) = @_;
1544 my $infoline = "";
1545 # creating the directory
1546 my $xpddir = installer::systemactions::create_directories("xpdinstaller", $languagestringref);
1547 $xpddir =~ s/\/\s*$//;
1548 $installer::globals::xpddir = $xpddir;
1549 # push(@installer::globals::removedirs, $xpddir);
1551 my $modulegid = $onepackage->{'module'};
1553 my $onelanguage = ""; #
1554 my $solslanguage = ""; #
1555 my $islanguagemodule = 0; #
1556 if ( $onepackage->{'islanguagemodule'} ) { $islanguagemodule = $onepackage->{'islanguagemodule'}; } #
1557 if ( $islanguagemodule ) #
1559 $onelanguage = $onepackage->{'language'}; #
1560 if ( $installer::globals::issolarispkgbuild ) { $solslanguage = installer::epmfile::get_solaris_language_for_langpack($onelanguage); } #
1563 installer::logger::include_header_into_logfile("Creating xpd file ($modulegid):");
1565 my $module = get_module($modulegid, $modulesarrayref);
1567 if ( $module ne "" )
1569 my $packagename = determine_new_packagename($installdir, $subdir, $xpdinfo);
1571 # all content saved in scp is now available and can be used to create the xpd file
1572 my ( $xpdfile, $parentgid ) = get_file_content($module, $packagename, $solslanguage, $linkpackage, 0, "", $islanguagemodule, $onelanguage, $xpdinfo);
1574 my $xpdfilename = get_xpd_filename($modulegid, $linkpackage);
1575 $xpdfilename = $xpddir . $installer::globals::separator . $xpdfilename;
1577 # Very special handling for Root module:
1578 # Because packages should only be assigned to leaves and not to knods,
1579 # the root module is divided into a knod without package and a new
1580 # leave with package. The name of the leave is defined at $module->{'XpdPackageName'}.
1581 if ( $module->{'XpdPackageName'} )
1583 my $newxpdfilename = get_xpd_filename($module->{'XpdPackageName'}, 0);
1584 $newxpdfilename = $xpddir . $installer::globals::separator . $newxpdfilename;
1585 my $emptyfilecontent = filter_content_from_xpdfile($xpdfile);
1587 installer::files::save_file($xpdfilename, $emptyfilecontent);
1588 push(@installer::globals::allxpdfiles, $xpdfilename);
1589 $infoline = "Saving xpd file: $xpdfilename\n";
1590 push( @installer::globals::logfileinfo, $infoline);
1592 $xpdfilename = $newxpdfilename;
1593 change_parent_in_xpdfile($xpdfile, $module->{'XpdPackageName'});
1596 installer::files::save_file($xpdfilename, $xpdfile);
1597 push( @installer::globals::createdxpdfiles, $modulegid);
1598 push(@installer::globals::allxpdfiles, $xpdfilename);
1599 $infoline = "Saving xpd file: $xpdfilename\n";
1600 push( @installer::globals::logfileinfo, $infoline);
1602 my $grandpagid = "root";
1603 if ( $parentgid ne "root" )
1605 my $create_missing_parent = is_empty_parent($parentgid, $allpackages);
1607 # if (( $create_missing_parent ) && ( ! installer::existence::exists_in_array($parentgid, \@installer::globals::emptyxpdparents) ))
1608 if (( $create_missing_parent ) && ( ! installer::existence::exists_in_array($parentgid, \@installer::globals::createdxpdfiles) ))
1610 $grandpagid = create_emptyparents_xpd_file($parentgid, $modulesarrayref, $xpddir);
1614 if ( $grandpagid ne "root" )
1616 my $create_missing_parent = is_empty_parent($grandpagid, $allpackages);
1618 # if (( $create_missing_parent ) && ( ! installer::existence::exists_in_array($parentgid, \@installer::globals::emptyxpdparents) ))
1619 if (( $create_missing_parent ) && ( ! installer::existence::exists_in_array($grandpagid, \@installer::globals::createdxpdfiles) ))
1621 create_emptyparents_xpd_file($grandpagid, $modulesarrayref, $xpddir);
1625 else
1627 installer::exiter::exit_program("ERROR: No module definition found for gid: $modulegid", "create_xpd_file (xpdinstaller)");
1632 ###################################################
1633 # Creating a xpd file for a copied package
1634 ###################################################
1636 sub create_xpd_file_for_childproject
1638 my ($module, $destdir, $packagename, $allvariableshashref, $modulesarrayref) = @_;
1640 my $modulegid = $module->{'gid'};
1642 my $currentdir = cwd();
1643 $destdir =~ s/\/\s*$//;
1644 $currentdir =~ s/\/\s*$//;
1646 my $completepackage = $currentdir . $installer::globals::separator . $destdir . $installer::globals::separator . $packagename;
1648 # all content saved in scp is now available and can be used to create the xpd file
1649 my ( $xpdfile, $parentgid ) = get_file_content($module, $completepackage, "", 0, 0, "", 0, "", "");
1651 my $xpdfilename = get_xpd_filename($modulegid, 0);
1652 $xpdfilename = $installer::globals::xpddir . $installer::globals::separator . $xpdfilename;
1654 installer::files::save_file($xpdfilename, $xpdfile);
1655 push( @installer::globals::createdxpdfiles, $modulegid);
1656 push(@installer::globals::allxpdfiles, $xpdfilename);
1657 my $infoline = "Saving xpd file: $xpdfilename\n";
1658 push( @installer::globals::logfileinfo, $infoline);
1660 if ( $parentgid ne "root" )
1662 # my $create_missing_parent = is_empty_parent($parentgid, $allpackages);
1663 my $create_missing_parent = 1; # -> Always missing parent by child projects!
1664 # Parent is now created, if it was not created before. Attention: Parent module must not come later.
1665 if (( $create_missing_parent ) && ( ! installer::existence::exists_in_array($parentgid, \@installer::globals::createdxpdfiles) ))
1667 create_emptyparents_xpd_file($parentgid, $modulesarrayref, $installer::globals::xpddir);
1672 ##############################################################
1673 # Creating a xpd file for copied system integration package
1674 ##############################################################
1676 sub create_xpd_file_for_systemintegration
1678 my ($module, $newcontent, $modulesarrayref, $subdir) = @_;
1680 my $parentgid = $module->{'gid'};
1682 # Create new visible module from scp info and create
1683 # new hidden module for each package inside in tar file
1685 for ( my $i = 0; $i <= $#{$newcontent}; $i++ )
1687 my $newpackagename = ${$newcontent}[$i];
1689 # installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$newpackagename);
1691 my $infoline = "Creating xpd file for package: $newpackagename\n";
1692 push( @installer::globals::logfileinfo, $infoline);
1694 my $childmodule = installer::worker::copy_hash_from_references($module);
1695 $childmodule->{'ParentID'} = $module->{'gid'}; # the module gid is the new parent
1696 $childmodule->{'InstallOrder'} = $installer::globals::defaultsystemintinstallorder;
1697 my $number = $i + 1;
1698 my $modulegid = $module->{'gid'} . "_child_" . $number; # setting a dynamic new gid
1699 $childmodule->{'gid'} = $modulegid;
1700 $childmodule->{'Styles'} =~ s/\)/\,HIDDEN_ROOT\)/;
1701 # iterating over all languages to get names and descriptions
1702 remove_lang_values($childmodule, "Name");
1703 remove_lang_values($childmodule, "Description");
1705 my $shortpackagename = $newpackagename;
1706 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$shortpackagename);
1707 $childmodule->{'PackageName'} = $shortpackagename;
1708 $childmodule->{'Name'} = $modulegid;
1709 $childmodule->{'Description'} = $modulegid;
1711 # Checking, if installorder can be set:
1712 # scp syntax: InstallOrder = "desktop:1050, suse:1060";
1713 # The string before the number can be compared with $shortpackagename
1714 if ( $module->{'InstallOrder'} )
1716 my $installorder = $module->{'InstallOrder'};
1717 $installorder =~ s/^\s*\"//g;
1718 $installorder =~ s/\"\s*$//g;
1719 # $installorder is comma separated list
1720 my $allorders = installer::converter::convert_stringlist_into_array(\$installorder, ",");
1721 for ( my $j = 0; $j <= $#{$allorders}; $j++ )
1723 my $oneitem = ${$allorders}[$j];
1724 if ( $oneitem =~ /^\s*(\S+?)\s*:\s*(\S+?)\s*$/ )
1726 my $name = $1;
1727 my $order = $2;
1729 if ( $shortpackagename =~ /\Q$name\E/ ) { $childmodule->{'InstallOrder'} = $order; }
1734 # all content saved in scp is now available and can be used to create the xpd file
1735 my ( $xpdfile, $parentgid_ ) = get_file_content($childmodule, $newpackagename, "", 0, 0, $subdir, 0, "", "");
1737 my $xpdfilename = get_xpd_filename($modulegid, 0);
1738 $xpdfilename = $installer::globals::xpddir . $installer::globals::separator . $xpdfilename;
1740 installer::files::save_file($xpdfilename, $xpdfile);
1741 push(@installer::globals::allxpdfiles, $xpdfilename);
1742 $infoline = "Saving xpd file: $xpdfilename\n";
1743 push( @installer::globals::logfileinfo, $infoline);
1746 # Creating the top level visible xpd file
1747 create_emptyparents_xpd_file($parentgid, $modulesarrayref, $installer::globals::xpddir);
1750 ##############################################################
1751 # Copying xpd files into installation set
1752 ##############################################################
1754 sub copy_xpd_files
1756 my ( $destdir ) = @_;
1758 for ( my $i = 0; $i <= $#installer::globals::allxpdfiles; $i++ )
1760 if ( ! -f $installer::globals::allxpdfiles[$i] ) { installer::exiter::exit_program("ERROR: Could not find xpd file: $installer::globals::allxpdfiles[$i]!", "copy_xpd_files"); }
1761 installer::systemactions::copy_one_file($installer::globals::allxpdfiles[$i], $destdir);
1765 ##############################################################
1766 # Copying all xpd files into the installation set
1767 ##############################################################
1769 sub copy_xpd_files_into_installset
1771 my ($installdir) = @_;
1773 $installdir =~ s/\Q$installer::globals::separator\E\s*$//;
1775 my $instdir = $installdir . $installer::globals::separator . "installdata";
1776 installer::systemactions::create_directory($instdir);
1778 my $xpddir = $instdir . $installer::globals::separator . "xpd";
1779 installer::systemactions::create_directory($xpddir);
1780 copy_xpd_files($xpddir);
1783 ##############################################################
1784 # Creating base xpd file with product information
1785 ##############################################################
1787 sub create_setup_xpd
1789 my ($allvariables, $languagestringref) = @_;
1791 my ( $xpdfile ) = get_setup_file_content($allvariables, $languagestringref);
1793 my $xpdfilename = $installer::globals::productxpdfile;
1794 $xpdfilename = $installer::globals::xpddir . $installer::globals::separator . $xpdfilename;
1796 installer::files::save_file($xpdfilename, $xpdfile);
1797 push(@installer::globals::allxpdfiles, $xpdfilename);
1798 my $infoline = "Saving xpd file: $xpdfilename\n";
1799 push( @installer::globals::logfileinfo, $infoline);
1802 ###################################################
1803 # Copying the files needed by the xpd installer
1804 # into the installation directory
1805 ###################################################
1807 sub create_xpd_installer
1809 my ( $installdir, $allvariables, $languagestringref) = @_;
1811 installer::logger::include_header_into_logfile("Creating xpd installer:");
1813 # create setup.xpd file
1814 create_setup_xpd($allvariables, $languagestringref);
1816 # copy xpd files into installation set
1817 copy_xpd_files_into_installset($installdir);