1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23package installer::xpdinstaller; 24 25use Cwd; 26use installer::converter; 27use installer::exiter; 28use installer::globals; 29use installer::languages; 30use installer::logger; 31use installer::pathanalyzer; 32use installer::remover; 33use installer::systemactions; 34 35 36####################################################### 37# Searching for the module name and description in the 38# modules collector 39####################################################### 40 41sub get_module_name_description 42{ 43 my ($modulesarrayref, $onelanguage, $gid, $type) = @_; 44 45 my $found = 0; 46 47 my $newstring = ""; 48 49 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ ) 50 { 51 my $onemodule = ${$modulesarrayref}[$i]; 52 53 if ( $onemodule->{'gid'} eq $gid ) 54 { 55 my $typestring = $type . " " . "(" . $onelanguage . ")"; 56 if ( $onemodule->{$typestring} ) { $newstring = $onemodule->{$typestring}; } 57 $found = 1; 58 } 59 60 if ( $found ) { last; } 61 } 62 63 # defaulting to english 64 65 if ( ! $found ) 66 { 67 my $defaultlanguage = "en-US"; 68 69 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ ) 70 { 71 my $onemodule = ${$modulesarrayref}[$i]; 72 73 if ( $onemodule->{'gid'} eq $gid ) 74 { 75 my $typestring = $type . " " . "(" . $defaultlanguage . ")"; 76 if ( $onemodule->{$typestring} ) { $newstring = $onemodule->{$typestring}; } 77 $found = 1; 78 } 79 80 if ( $found ) { last; } 81 } 82 } 83 84 return $newstring; 85} 86 87################################################### 88# Finding module, specified by the gid 89################################################### 90 91sub get_module 92{ 93 my ($modulegid, $modulesarrayref) = @_; 94 95 my $found = 0; 96 my $searchmodule = ""; 97 98 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ ) 99 { 100 my $onemodule = ${$modulesarrayref}[$i]; 101 102 if ( $onemodule->{'gid'} eq $modulegid ) 103 { 104 $searchmodule = $onemodule; 105 $found = 1; 106 last; 107 } 108 109 # if ( ! $found ) { installer::exiter::exit_program("ERROR: Could not find module belonging to gid $modulegid!", "get_module (xpdinstaller)"); } 110 } 111 112 return $searchmodule; 113} 114 115################################################### 116# Creating package start tag 117################################################### 118 119sub get_package_tag 120{ 121 my ( $module, $indent, $linkpackage ) = @_; 122 123 my $modulegid = $module->{'gid'}; 124 if ( $linkpackage ) { $modulegid = $modulegid . "u"; } 125 my $parentgid = ""; 126 if ( $module->{'ParentID'} ) { $parentgid = $module->{'ParentID'}; } 127 if ( $parentgid eq "" ) { $parentgid = "root"; } 128 if ( $module->{'XPDParentID'} ) { $parentgid = $module->{'XPDParentID'}; } # changing parent of "Prg" and "Opt" to "root" 129 130 my $tag = $indent . "<package " . "name=" . "\"" . $modulegid . "\" " . "parent=" . "\"" . $parentgid . "\">" . "\n"; 131 132 return ( $tag, $parentgid ); 133} 134 135################################################### 136# Creating display start tag 137################################################### 138 139sub get_display_tag 140{ 141 my ( $module, $indent ) = @_; 142 143 # Styles=(HIDDEN_ROOT) 144 my $styles = ""; 145 my $type = ""; 146 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; } 147 if ( $styles =~ /\bHIDDEN_ROOT\b/ ) { $type = "hidden"; } 148 else { $type = "show"; } 149 150 # special handling for language modules. Only visible in multilingual installation set. 151 if (( $styles =~ /\bSHOW_MULTILINGUAL_ONLY\b/ ) && ( ! $installer::globals::ismultilingual )) { $type = "hidden"; } 152 153 # special handling for the root module, which has no parent 154 my $parentgid = ""; 155 if ( $module->{'ParentID'} ) { $parentgid = $module->{'ParentID'}; } 156 if ( $parentgid eq "" ) { $type = "hidden"; } 157 158 my $tag = $indent . "<display " . "type=" . "\"" . $type . "\"" . ">" . "\n"; 159 160 return $tag; 161} 162 163################################################### 164# Creating installunit start tag 165################################################### 166 167sub get_installunit_tag 168{ 169 my ( $indent ) = @_; 170 171 my $type = $installer::globals::packageformat; 172 173 my $tag = $indent . "<installunit " . "type=" . "\"" . $type . "\"" . ">" . "\n"; 174 175 return $tag; 176} 177 178################################################### 179# Creating simple start tags 180################################################### 181 182sub get_start_tag 183{ 184 my ( $tag, $indent ) = @_; 185 186 my $starttag = $indent . "<" . $tag . ">" . "\n"; 187 return $starttag; 188} 189 190################################################### 191# Creating end tags 192################################################### 193 194sub get_end_tag 195{ 196 my ( $tag, $indent ) = @_; 197 198 my $endtag = $indent . "</" . $tag . ">" . "\n"; 199 return $endtag; 200} 201 202################################################### 203# Creating simple complete tag 204################################################### 205 206sub get_tag_line 207{ 208 my ( $indent, $name, $value ) = @_; 209 $value = '' unless defined $value; 210 211 my $line = $indent . "<" . $name . ">" . $value . "</" . $name . ">" . "\n"; 212 213} 214 215################################################### 216# Asking module for sortkey entry 217################################################### 218 219sub get_sortkey_value 220{ 221 my ( $module ) = @_; 222 223 my $value = "9999"; 224 225 if ( $module->{'Sortkey'} ) { $value = $module->{'Sortkey'}; } 226 227 return $value; 228} 229 230################################################### 231# Asking module for default entry 232################################################### 233 234sub get_default_value 235{ 236 my ( $module ) = @_; 237 238 my $value = ""; 239 240 if ( $module->{'Default'} ) { $value = $module->{'Default'}; } # is YES or NO 241 242 if ( $value =~ /\bNO\b/i ) { $value = "false"; } 243 else { $value = "true"; } 244 245 return $value; 246} 247 248################################################### 249# Asking module for showinuserinstall entry 250# scp style: DONTSHOWINUSERINSTALL 251################################################### 252 253sub get_showinuserinstall_value 254{ 255 my ( $module ) = @_; 256 257 my $value = "true"; 258 259 my $styles = ""; 260 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; } 261 if ( $styles =~ /\bDONTSHOWINUSERINSTALL\b/ ) { $value = "false"; } 262 263 return $value; 264} 265 266################################################### 267# Asking module for showinuserinstall entry 268# scp style: USERINSTALLONLY 269################################################### 270 271sub get_userinstallonly_value 272{ 273 my ( $module ) = @_; 274 275 my $value = "false"; 276 277 my $styles = ""; 278 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; } 279 if ( $styles =~ /\bUSERINSTALLONLY\b/ ) { $value = "true"; } 280 281 return $value; 282} 283 284################################################### 285# Asking module for dontuninstall entry 286# scp style: DONTUNINSTALL 287################################################### 288 289sub get_dontuninstall_value 290{ 291 my ( $module ) = @_; 292 293 my $value = "false"; 294 295 my $styles = ""; 296 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; } 297 if ( $styles =~ /\bDONTUNINSTALL\b/ ) { $value = "true"; } 298 299 return $value; 300} 301 302################################################### 303# Asking module for XpdCheckSolaris entry 304# (belongs to scp module) 305################################################### 306 307sub get_checksolaris_value 308{ 309 my ( $module ) = @_; 310 311 my $value = ""; 312 if ( $module->{'XpdCheckSolaris'} ) { $value = $module->{'XpdCheckSolaris'}; } 313 314 return $value; 315} 316 317################################################### 318# Asking module for isupdatepackage entry 319# scp style: ISUPDATEPACKAGE 320################################################### 321 322sub get_isupdatepackage_value 323{ 324 my ( $module ) = @_; 325 326 my $value = "false"; 327 328 my $styles = ""; 329 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; } 330 if ( $styles =~ /\bISUPDATEPACKAGE\b/ ) { $value = "true"; } 331 332 return $value; 333} 334 335################################################### 336# Asking module for showmultilingualonly entry 337# scp style: SHOW_MULTILINGUAL_ONLY 338################################################### 339 340sub get_showmultilingualonly_value 341{ 342 my ( $module ) = @_; 343 344 my $value = "false"; 345 346 my $styles = ""; 347 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; } 348 if ( $styles =~ /\bSHOW_MULTILINGUAL_ONLY\b/ ) { $value = "true"; } 349 350 return $value; 351} 352 353################################################### 354# Asking module for showmultilingualonly entry 355# scp style: SHOW_MULTILINGUAL_ONLY 356################################################### 357 358sub get_applicationmodule_value 359{ 360 my ( $module ) = @_; 361 362 my $value = "false"; 363 364 my $styles = ""; 365 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; } 366 if ( $styles =~ /\bAPPLICATIONMODULE\b/ ) { $value = "true"; } 367 368 return $value; 369} 370 371################################################### 372# Asking module for java module entry 373# scp style: JAVAMODULE 374################################################### 375 376sub get_isjavamodule_value 377{ 378 my ( $module ) = @_; 379 380 my $value = "false"; 381 382 my $styles = ""; 383 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; } 384 if ( $styles =~ /\bJAVAMODULE\b/ ) { $value = "true"; } 385 386 return $value; 387} 388 389##################################################################### 390# Asking module, if installation shall use --force 391# scp style: USEFORCE (Linux only) 392##################################################################### 393 394sub get_useforce_value 395{ 396 my ( $module ) = @_; 397 398 my $value = "false"; 399 400 my $styles = ""; 401 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; } 402 if ( $styles =~ /\bUSEFORCE\b/ ) { $value = "true"; } 403 404 return $value; 405} 406 407################################################### 408# Asking module, if installation can fail 409# scp style: INSTALLCANFAIL 410################################################### 411 412sub get_installcanfail_value 413{ 414 my ( $module ) = @_; 415 416 my $value = "false"; 417 418 my $styles = ""; 419 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; } 420 if ( $styles =~ /\bINSTALLCANFAIL\b/ ) { $value = "true"; } 421 422 return $value; 423} 424 425################################################### 426# Asking module, if installation can fail 427# scp style: INSTALLCANFAIL 428################################################### 429 430sub get_forceintoupdate_value 431{ 432 my ( $module ) = @_; 433 434 my $value = "false"; 435 436 my $styles = ""; 437 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; } 438 if ( $styles =~ /\bFORCEINTOUPDATE\b/ ) { $value = "true"; } 439 440 return $value; 441} 442 443################################################### 444# Substituting all occurences of "<" by "<" 445# and all occurences of ">" by ">" 446################################################### 447 448sub replace_brackets_in_string 449{ 450 my ( $string ) = @_; 451 452 if ( $string =~ /\</ ) { $string =~ s/\</\<\;/g; } 453 if ( $string =~ /\>/ ) { $string =~ s/\>/\>\;/g; } 454 455 return $string; 456} 457 458################################################### 459# Substituting all occurences of "\uUXYZ" by 460# "&#xUXYZ;", because the use xml saxparser does 461# not know anything about this encoding. Therfore 462# the xml file can keep standard encoding "UTF-8" 463# and all strings with "\uUXYZ" do not need to 464# be converted from the Java installer. 465################################################### 466 467sub replace_javaencoding_in_string 468{ 469 my ( $string ) = @_; 470 471 while ( $string =~ /(\\u\w\w\w\w)/ ) 472 { 473 my $oldvalue = $1; 474 my $newvalue = ""; 475 if ( $oldvalue =~ /\\u(\w\w\w\w)/ ) 476 { 477 my $number = $1; 478 $newvalue = "&#x" . $number . ";"; 479 } 480 481 $string =~ s/\Q$oldvalue\E/$newvalue/; 482 } 483 484 return $string; 485} 486 487################################################### 488# Collecting language dependent entries from scp 489# (Name and Description) 490################################################### 491 492sub collect_lang_values 493{ 494 my ($indent, $module, $xpdfile, $searchentry, $saveentry) = @_; 495 496 foreach $key (keys %{$module}) 497 { 498 my $write_line = 0; 499 my $javalanguage = ""; 500 501 if ( $key =~ /^\s*\Q$searchentry\E\s+\((\S+)\)\s*$/ ) # this are the language dependent keys 502 { 503 $language = $1; 504 $javalanguage = installer::languages::get_java_language($language); 505 $write_line = 1; 506 } 507 elsif ( $key =~ /^\s*\Q$searchentry\E\s*$/ ) # this are the language independent keys 508 { 509 $javalanguage = "en_US"; 510 $write_line = 1; 511 } 512 513 if ( $write_line ) 514 { 515 my $value = $module->{$key}; 516 $value = replace_brackets_in_string($value); 517 $value = replace_javaencoding_in_string($value); 518 my $line = $indent . "<" . $saveentry . " lang=" . "\"" . $javalanguage . "\"" . ">" . $value . "<\/" . $saveentry . ">" . "\n"; 519 push(@{$xpdfile}, $line); 520 } 521 } 522} 523 524################################################### 525# Removing language dependent entries from 526# module hash (Name and Description) 527################################################### 528 529sub remove_lang_values 530{ 531 my ($module, $searchentry) = @_; 532 533 my $key = ""; 534 535 foreach $key (keys %{$module}) 536 { 537 if ( $key =~ /^\s*\Q$searchentry\E\s+\((\S+)\)\s*$/ ) # this are the language dependent keys 538 { 539 delete($module->{$key}); 540 } 541 } 542} 543 544################################################### 545# Setting package install order 546################################################### 547 548sub get_order_value 549{ 550 my ( $module ) = @_; 551 552 my $value = "1000"; # Setting the default value 553 554 if ( $module->{'InstallOrder'} ) { $value = $module->{'InstallOrder'}; } 555 556 return $value; 557} 558 559################################################### 560# Checking size of package 561################################################### 562 563sub get_size_value 564{ 565 my ( $packagename, $xpdinfo ) = @_; 566 567 my $value = ""; 568 569 if ( $xpdinfo->{'FileSize'} ) 570 { 571 $value = $xpdinfo->{'FileSize'}; 572 return $value; 573 } 574 575 my $isrpmfile = 0; 576 if ( $packagename =~ /\.rpm\s*$/ ) { $isrpmfile = 1; } 577 578 if (( $installer::globals::islinuxrpmbuild ) && ( $isrpmfile )) 579 { 580 # if ( ! $installer::globals::rpmquerycommand ) { installer::exiter::exit_program("ERROR: rpm not found for querying packages!", "get_size_value"); } 581 if ( ! $installer::globals::rpmquerycommand ) { $installer::globals::rpmquerycommand = "rpm"; } 582 583 my $systemcall = "$installer::globals::rpmquerycommand -qp --queryformat \"\[\%\{FILESIZES\}\\n\]\" $packagename 2\>\&1 |"; 584 my $ld_library_backup = $ENV{LD_LIBRARY_PATH}; 585 if ( defined $ENV{SYSBASE}) { 586 my $sysbase = $ENV{SYSBASE}; 587 if ( !defined ($ld_library_backup) or ("$ld_library_backup" eq "") ) { 588 $ld_library_backup = "" if ! defined $ld_library_backup; 589 $ENV{LD_LIBRARY_PATH} = "$sysbase/usr/lib"; 590 } else { 591 $ENV{LD_LIBRARY_PATH} = "$ld_library_backup:$sysbase/lib"; 592 } 593 } 594 my ($rpmout, $error) = make_systemcall_allowing_error($systemcall, 0, 1); 595 $ENV{LD_LIBRARY_PATH} = $ld_library_backup; 596 # Evaluating an error, because of rpm problems with removed LD_LIBRARY_PATH 597 if ( $error ) 598 { 599 installer::logger::print_message( "... trying /usr/bin/rpm ...\n" ); 600 my $systemcall = "/usr/bin/rpm -qp --queryformat \"\[\%\{FILESIZES\}\\n\]\" $packagename 2\>\&1 |"; 601 ($rpmout, $error) = make_systemcall_allowing_error($systemcall, 0, 0); 602 if ( $error ) { installer::exiter::exit_program("ERROR: rpm failed to query package!", "get_size_value"); } 603 } 604 $value = do_sum($rpmout); # adding all filesizes in bytes 605 $value = $value/1000; 606 607 my $ganzzahl = int $value; 608 if ($ganzzahl < $value) { $value = $ganzzahl + 1; } 609 else { $value = $ganzzahl; } 610 611 my $rpmname = $packagename; 612 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$rpmname); 613 $infoline = "Filesize $rpmname : $value\n"; 614 push( @installer::globals::logfileinfo, $infoline); 615 } 616 617 if ( $installer::globals::issolarispkgbuild ) 618 { 619 my $filename = "pkgmap"; 620 $filename = $packagename . $installer::globals::separator . $filename; 621 $file = installer::files::read_file($filename); 622 623 for ( my $i = 0; $i <= $#{$file}; $i++ ) 624 { 625 my $line = ${$file}[$i]; 626 if ( $line =~ /^\s*\:\s+\d+\s+(\d+?)\s+/ ) 627 { 628 $value = $1; 629 if ( ! ( $value%2 == 0 )) { $value = $value + 1; } 630 $value = $value/2; # not blocks, but kB 631 last; 632 } 633 } 634 } 635 636 if ( $value eq "" ) { $value = "0"; } 637 638 return $value; 639} 640 641################################################### 642# Checking md5 of package 643################################################### 644 645sub get_md5_value 646{ 647 my ( $packagename, $xpdinfo ) = @_; 648 649 my $value = ""; 650 651 if ( $xpdinfo->{'md5sum'} ) 652 { 653 $value = $xpdinfo->{'md5sum'}; 654 return $value; 655 } 656 657 if ( $installer::globals::islinuxrpmbuild ) 658 { 659 my $md5file = "/usr/bin/md5sum"; 660 661 if ( -x $md5file ) 662 { 663 my $systemcall = "$md5file $packagename 2\>\&1 |"; 664 my $md5out = make_systemcall($systemcall, 1); 665 $value = ${$md5out}[0]; 666 if ( $value =~ /^\s*(\S+?)\s+.*$/ ) 667 { 668 $value = $1; 669 } 670 671 my $rpmname = $packagename; 672 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$rpmname); 673 $infoline = "md5sum of $rpmname : $value\n"; 674 push( @installer::globals::logfileinfo, $infoline); 675 } 676 } 677 678 return $value; 679} 680 681################################################### 682# Checking name of package 683################################################### 684 685sub get_name_value 686{ 687 my ( $packagename ) = @_; 688 689 my $value = $packagename; 690 691 # $packagename contains the complete path to the package 692 # Only the name of file or directory is required 693 694 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$value); 695 696 return $value; 697} 698 699################################################### 700# Checking full package name (Linux only) 701################################################### 702 703sub get_fullpkgname_value 704{ 705 my ( $packagename, $xpdinfo ) = @_; 706 707 my $value = ""; 708 my $isrpmfile = 0; 709 if ( $packagename =~ /\.rpm\s*$/ ) { $isrpmfile = 1; } 710 711 if (( $installer::globals::islinuxrpmbuild ) && ( $isrpmfile )) 712 { 713 if ( $xpdinfo->{'FullPackageName'} ) 714 { 715 $value = $xpdinfo->{'FullPackageName'}; 716 return $value; 717 } 718 719 # if ( ! $installer::globals::rpmquerycommand ) { installer::exiter::exit_program("ERROR: rpm not found for querying packages!", "get_fullpkgname_value"); } 720 if ( ! $installer::globals::rpmquerycommand ) { $installer::globals::rpmquerycommand = "rpm"; } 721 my $systemcall = "$installer::globals::rpmquerycommand -qp $packagename |"; 722 my $ld_library_backup = $ENV{LD_LIBRARY_PATH}; 723 if ( defined $ENV{SYSBASE}) { 724 my $sysbase = $ENV{SYSBASE}; 725 if ( !defined ($ld_library_backup) or ("$ld_library_backup" eq "") ) { 726 $ld_library_backup = "" if ! defined $ld_library_backup; 727 $ENV{LD_LIBRARY_PATH} = "$sysbase/usr/lib"; 728 } else { 729 $ENV{LD_LIBRARY_PATH} = "$ld_library_backup:$sysbase/lib"; 730 } 731 } 732 my ($returnarray, $error) = make_systemcall_allowing_error($systemcall, 0, 1); 733 $ENV{LD_LIBRARY_PATH} = $ld_library_backup; 734 # Evaluating an error, because of rpm problems with removed LD_LIBRARY_PATH 735 if ( $error ) 736 { 737 installer::logger::print_message( "... trying /usr/bin/rpm ...\n" ); 738 my $systemcall = "/usr/bin/rpm -qp $packagename |"; 739 ($returnarray, $error) = make_systemcall_allowing_error($systemcall, 0, 0); 740 if ( $error ) { installer::exiter::exit_program("ERROR: rpm failed to query package!", "get_fullpkgname_value"); } 741 } 742 $value = ${$returnarray}[0]; 743 installer::remover::remove_leading_and_ending_whitespaces(\$value); 744 745 my $rpmname = $packagename; 746 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$rpmname); 747 748 $infoline = "Full package name from $rpmname: $value\n"; 749 push( @installer::globals::logfileinfo, $infoline); 750 } 751 752 return $value; 753} 754 755################################################### 756# Checking package version (Solaris only) 757################################################### 758 759sub get_pkgversion_value 760{ 761 my ( $completepackagename, $xpdinfo ) = @_; 762 763 my $value = ""; 764 765 if ( $xpdinfo->{'PkgVersion'} ) 766 { 767 $value = $xpdinfo->{'PkgVersion'}; 768 return $value; 769 } 770 771 if ( $installer::globals::issolarispkgbuild ) 772 { 773 my $pkgfile = "pkgparam"; 774 my $packagepath = $completepackagename; 775 installer::pathanalyzer::get_path_from_fullqualifiedname(\$packagepath); 776 777 my $packagename = $completepackagename; 778 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$packagename); 779 780 my $systemcall = "$pkgfile -d $packagepath $packagename param VERSION 2\>\&1 |"; 781 my $returnarray = make_systemcall($systemcall, 0); 782 783 $value = ${$returnarray}[0]; 784 installer::remover::remove_leading_and_ending_whitespaces(\$value); 785 } 786 787 return $value; 788} 789 790################################################### 791# Writing subdirectory into xpd file 792################################################### 793 794sub get_subdir_value 795{ 796 my ( $packagename, $subdir, $module ) = @_; 797 798 my $value = ""; 799 800 if ( $subdir ) { $value = $subdir; } 801 802 if ( $module->{'Subdir'} ) { $value = $module->{'Subdir'}; } 803 804 return $value; 805} 806 807################################################### 808# Checking if package is relocatable 809################################################### 810 811sub get_relocatable_value 812{ 813 my ( $module ) = @_; 814 815 my $value = "true"; 816 817 my $styles = ""; 818 if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; } 819 if ( $styles =~ /\bNOTRELOCATABLE\b/ ) { $value = "false"; } 820 821 return $value; 822} 823 824################################################### 825# Checking if package is relocatable 826################################################### 827 828sub get_languagespecific_value 829{ 830 my ( $islanguagemodule ) = @_; 831 832 my $value = "false"; 833 834 if ( defined $islanguagemodule && $islanguagemodule == 1 ) { $value = "true"; } 835 836 return $value; 837} 838 839####################################################### 840# Adding the values of the array 841####################################################### 842 843sub do_sum 844{ 845 my ( $allnumbers ) = @_; 846 847 my $sum = 0; 848 849 for ( my $i = 0; $i <= $#{$allnumbers}; $i++ ) 850 { 851 $sum = $sum + ${$allnumbers}[$i]; 852 } 853 854 return $sum; 855} 856 857####################################################### 858# Executing one system call 859####################################################### 860 861sub make_systemcall 862{ 863 my ( $systemcall, $logreturn ) = @_; 864 865 my @returns = (); 866 867 installer::logger::print_message( "... $systemcall ...\n" ); 868 869 open (REG, "$systemcall"); 870 while (<REG>) {push(@returns, $_); } 871 close (REG); 872 873 my $returnvalue = $?; # $? contains the return value of the systemcall 874 875 my $infoline = "Systemcall: $systemcall\n"; 876 push( @installer::globals::logfileinfo, $infoline); 877 878 if ( $logreturn ) 879 { 880 for ( my $j = 0; $j <= $#returns; $j++ ) { push( @installer::globals::logfileinfo, "$returns[$j]"); } 881 } 882 883 if ($returnvalue) 884 { 885 $infoline = "ERROR: $systemcall\n"; 886 push( @installer::globals::logfileinfo, $infoline); 887 $error_occured = 1; 888 } 889 else 890 { 891 $infoline = "SUCCESS: $systemcall\n"; 892 push( @installer::globals::logfileinfo, $infoline); 893 } 894 895 return \@returns; 896} 897 898####################################################### 899# Executing one system call 900####################################################### 901 902sub make_systemcall_allowing_error 903{ 904 my ( $systemcall, $logreturn, $can_fail ) = @_; 905 906 my @returns = (); 907 908 installer::logger::print_message( "... $systemcall ...\n" ); 909 910 open (REG, "$systemcall"); 911 while (<REG>) {push(@returns, $_); } 912 close (REG); 913 914 my $returnvalue = $?; # $? contains the return value of the systemcall 915 916 my $infoline = "Systemcall: $systemcall\n"; 917 push( @installer::globals::logfileinfo, $infoline); 918 919 if ( $logreturn ) 920 { 921 for ( my $j = 0; $j <= $#returns; $j++ ) { push( @installer::globals::logfileinfo, "$returns[$j]"); } 922 } 923 924 if ($returnvalue) 925 { 926 if ( $can_fail ) 927 { 928 $infoline = "WARNING: Failed system call: $systemcall\n"; 929 push( @installer::globals::logfileinfo, $infoline); 930 $error_occured = 1; 931 } 932 else 933 { 934 $infoline = "ERROR: $systemcall\n"; 935 push( @installer::globals::logfileinfo, $infoline); 936 $error_occured = 1; 937 } 938 } 939 else 940 { 941 $infoline = "SUCCESS: $systemcall\n"; 942 push( @installer::globals::logfileinfo, $infoline); 943 } 944 945 return (\@returns, $returnvalue); 946} 947 948################################################### 949# Setting product name tag 950################################################### 951 952sub get_product_tag 953{ 954 my ($allvariables, $indent) = @_; 955 956 my $productname = $allvariables->{'LCONEWORDPRODUCTNAME'}; 957 my $tag = $indent . "<product " . "name=" . "\"" . $productname . "\">" . "\n"; 958 959 return $tag; 960} 961 962################################################### 963# Macro tags 964################################################### 965 966sub set_macro_tag 967{ 968 my ($allvariables, $indent, $key) = @_; 969 970 my $property = ""; 971 my $value = ""; 972 973 if ( $key eq "product_name" ) { $property = "PRODUCTNAME"; } 974 elsif ( $key eq "product_version" ) { $property = "PRODUCTVERSION"; } 975 elsif ( $key eq "product_suffix" ) { $property = "PRODUCTEXTENSION"; } 976 elsif ( $key eq "product_fullname" ) { $property = "FULLPRODUCTNAME"; } 977 978 if (( $property eq "PRODUCTNAME" ) || ( $property eq "PRODUCTVERSION" ) || ( $property eq "PRODUCTEXTENSION" )) 979 { 980 $value = $allvariables->{$property}; 981 } 982 983 if ( $property eq "FULLPRODUCTNAME" ) 984 { 985 $value = $allvariables->{"PRODUCTNAME"} . " " . $allvariables->{"PRODUCTVERSION"}; 986 if ( $allvariables->{"PRODUCTEXTENSION"} ) { $value = $value . " " . $allvariables->{"PRODUCTEXTENSION"}; } 987 } 988 989 my $tag = $indent . "<macro " . "key=" . "\"" . $key . "\">" . $value . "\<\/macro\>" . "\n"; 990 991 return $tag; 992 993} 994 995################################################### 996# Setting the minor of the product version 997# Required to check for Major Upgrades. 998################################################### 999 1000sub set_minor_tag 1001{ 1002 my ($allvariables, $indent) = @_; 1003 1004 my $productminor = 0; 1005 if ( $allvariables->{"PACKAGEVERSION"} ) 1006 { 1007 if ( $allvariables->{"PACKAGEVERSION"} =~ /^\s*\d+\.(\d+)/ ) { $productminor = $1; } 1008 } 1009 my $tag = $indent . "<productminor>" . $productminor . "</productminor>" . "\n"; 1010 1011 return $tag; 1012} 1013 1014################################################### 1015# Setting the update behaviour 1016################################################### 1017 1018sub set_update_tag 1019{ 1020 my ($allvariables, $indent) = @_; 1021 1022 my $updateflag = "false"; 1023 if ( $allvariables->{"DONTUPDATE"} ) { $updateflag = "true"; } 1024 my $tag = $indent . "<dontupdate>" . $updateflag . "</dontupdate>" . "\n"; 1025 1026 return $tag; 1027} 1028 1029################################################### 1030# Setting the license dialog behaviour 1031################################################### 1032 1033sub set_hideeula_tag 1034{ 1035 my ($allvariables, $indent) = @_; 1036 1037 my $hidelicenseflag = "false"; 1038 if ( $allvariables->{"HIDELICENSEDIALOG"} ) { $hidelicenseflag = "true"; } 1039 my $tag = $indent . "<hideeula>" . $hidelicenseflag . "</hideeula>" . "\n"; 1040 1041 return $tag; 1042} 1043 1044################################################### 1045# Setting default directory 1046################################################### 1047 1048sub set_defaultdir_tag 1049{ 1050 my ($allvariables, $indent) = @_; 1051 1052 my $defaultdir = ""; 1053 if ( $allvariables->{"DEFAULTDESTPATH"} ) { $defaultdir = $allvariables->{"DEFAULTDESTPATH"}; } 1054 my $tag = $indent . "<defaultdir>" . $defaultdir . "</defaultdir>" . "\n"; 1055 1056 return $tag; 1057} 1058 1059################################################### 1060# Setting product directory 1061################################################### 1062 1063sub set_productdir_tag 1064{ 1065 my ($allvariables, $indent) = @_; 1066 1067 my $productdir = ""; 1068 if ( $allvariables->{"UNIXPRODUCTNAME"} ) 1069 { 1070 $productdir = $allvariables->{"UNIXPRODUCTNAME"}; 1071 1072 if ( $allvariables->{"BRANDPACKAGEVERSION"} ) 1073 { 1074 $productdir = $productdir . $allvariables->{"BRANDPACKAGEVERSION"}; 1075# if ( $allvariables->{"LCPRODUCTEXTENSION"} ) { $productdir = $productdir . $allvariables->{"LCPRODUCTEXTENSION"}; } 1076 } 1077 else 1078 { 1079 if ( $allvariables->{"PRODUCTVERSION"} ) 1080 { 1081 $productdir = $productdir . $allvariables->{"PRODUCTVERSION"}; 1082 } 1083 } 1084 } 1085 my $tag = $indent . "<productdir>" . $productdir . "</productdir>" . "\n"; 1086 1087 return $tag; 1088} 1089 1090##################################################### 1091# Setting the package directory in installation set 1092##################################################### 1093 1094sub set_packagedir_tag 1095{ 1096 my ($indent) = @_; 1097 1098 my $tag = $indent . "<packagedirectory>" . $installer::globals::epmoutpath . "</packagedirectory>" . "\n"; 1099 1100 return $tag; 1101} 1102 1103################################################### 1104# Setting the packagetype of installation set 1105################################################### 1106 1107sub set_packagetype_tag 1108{ 1109 my ($indent) = @_; 1110 1111 my $tag = $indent . "<packageformat>" . $installer::globals::packageformat . "</packageformat>" . "\n"; 1112 1113 return $tag; 1114} 1115 1116################################################### 1117# Setting the architecture of installation set 1118################################################### 1119 1120sub set_architecture_tag 1121{ 1122 my ($indent) = @_; 1123 1124 my $architecture = ""; 1125 if ( $installer::globals::issolarissparcbuild ) { $architecture = "sparc"; } 1126 if ( $installer::globals::issolarisx86build ) { $architecture = "i386"; } 1127 1128 my $tag = $indent . "<architecture>" . $architecture . "</architecture>" . "\n"; 1129 1130 return $tag; 1131} 1132 1133################################################### 1134# Setting the multi language tag 1135################################################### 1136 1137sub set_multilanguage_tag 1138{ 1139 my ($indent) = @_; 1140 1141 my $value = "false"; 1142 if ( $installer::globals::ismultilingual == 1 ) { $value = "true"; } 1143 1144 my $tag = $indent . "<multilingual>" . $value . "</multilingual>" . "\n"; 1145 1146 return $tag; 1147} 1148 1149################################################### 1150# Setting the language tag 1151################################################### 1152 1153sub set_language_tag 1154{ 1155 my ($languagestringref, $indent) = @_; 1156 1157 my $tag = $indent . "<languages>" . $$languagestringref . "</languages>" . "\n"; 1158 1159 return $tag; 1160} 1161 1162################################################### 1163# Collecting content for product xpd file 1164################################################### 1165 1166# <?xml version='1.0' encoding='utf-8'?> 1167# 1168# <!-- General application description --> 1169# 1170# <product name="openoffice"> 1171# <macro key="product_name">Sun OpenOffice.org</macro> 1172# <macro key="product_version">1.0</macro> 1173# <macro key="product_suffix">Mephisto</macro> 1174# <macro key="product_fullname">Sun OpenOffice.org 1.0 Mephisto</macro> 1175# <defaultdir>/opt/Sun/OpenOffice.org-Mephisto</defaultdir> 1176# </product> 1177 1178sub get_setup_file_content 1179{ 1180 my ($allvariables, $languagestringref) = @_; 1181 1182 my @xpdfile = (); 1183 my $noindent = ""; 1184 my $singleindent = " "; 1185 1186 my $line = "<?xml version='1.0' encoding='utf-8'?>\n\n"; 1187 push(@xpdfile, $line); 1188 $line = "<!-- General application description -->\n\n"; 1189 push(@xpdfile, $line); 1190 1191 my $tag = get_product_tag($allvariables, $noindent); 1192 push(@xpdfile, $tag); 1193 1194 $tag = set_macro_tag($allvariables, $singleindent, "product_name"); 1195 push(@xpdfile, $tag); 1196 $tag = set_macro_tag($allvariables, $singleindent, "product_version"); 1197 push(@xpdfile, $tag); 1198 $tag = set_macro_tag($allvariables, $singleindent, "product_suffix"); 1199 push(@xpdfile, $tag); 1200 $tag = set_macro_tag($allvariables, $singleindent, "product_fullname"); 1201 push(@xpdfile, $tag); 1202 1203 $tag = set_defaultdir_tag($allvariables, $singleindent); 1204 push(@xpdfile, $tag); 1205 1206 $tag = set_productdir_tag($allvariables, $singleindent); 1207 push(@xpdfile, $tag); 1208 1209 $tag = set_minor_tag($allvariables, $singleindent); 1210 push(@xpdfile, $tag); 1211 1212 $tag = set_update_tag($allvariables, $singleindent); 1213 push(@xpdfile, $tag); 1214 1215 $tag = set_packagedir_tag($singleindent); 1216 push(@xpdfile, $tag); 1217 1218 $tag = set_packagetype_tag($singleindent); 1219 push(@xpdfile, $tag); 1220 1221 $tag = set_architecture_tag($singleindent); 1222 push(@xpdfile, $tag); 1223 1224 $tag = set_multilanguage_tag($singleindent); 1225 push(@xpdfile, $tag); 1226 1227 $tag = set_language_tag($languagestringref, $singleindent); 1228 push(@xpdfile, $tag); 1229 1230 $tag = set_hideeula_tag($allvariables, $singleindent); 1231 push(@xpdfile, $tag); 1232 1233 $tag = get_end_tag("product", $noindent); 1234 push(@xpdfile, $tag); 1235 1236 return \@xpdfile; 1237} 1238 1239################################################### 1240# Collecting content for xpd file 1241################################################### 1242 1243sub get_file_content 1244{ 1245 my ( $module, $packagename, $solslanguage, $linkpackage, $isemptyparent, $subdir, $islanguagemodule, $onelanguage, $xpdinfo ) = @_; 1246 1247 my @xpdfile = (); 1248 my $value = ""; 1249 my $line = ""; 1250 my $noindent = ""; 1251 my $singleindent = " "; 1252 my $doubleindent = $singleindent . $singleindent; 1253 1254 my ( $tag, $parentgid ) = get_package_tag($module, $noindent, $linkpackage); 1255 push(@xpdfile, $tag); 1256 1257 # start of installunit tag -> using info from scp module 1258 1259 $tag = get_display_tag($module, $singleindent); 1260 push(@xpdfile, $tag); 1261 1262 $value = get_sortkey_value($module); 1263 $line = get_tag_line($doubleindent, "sortkey", $value); 1264 push(@xpdfile, $line); 1265 1266 $value = get_default_value($module); 1267 $line = get_tag_line($doubleindent, "default", $value); 1268 push(@xpdfile, $line); 1269 1270 $value = get_showinuserinstall_value($module); 1271 $line = get_tag_line($doubleindent, "showinuserinstall", $value); 1272 push(@xpdfile, $line); 1273 1274 $value = get_userinstallonly_value($module); 1275 $line = get_tag_line($doubleindent, "showinuserinstallonly", $value); 1276 push(@xpdfile, $line); 1277 1278 $value = get_dontuninstall_value($module); 1279 $line = get_tag_line($doubleindent, "dontuninstall", $value); 1280 push(@xpdfile, $line); 1281 1282 $value = get_checksolaris_value($module); 1283 $line = get_tag_line($doubleindent, "checksolaris", $value); 1284 push(@xpdfile, $line); 1285 1286 $value = get_isupdatepackage_value($module); 1287 $line = get_tag_line($doubleindent, "isupdatepackage", $value); 1288 push(@xpdfile, $line); 1289 1290 $value = get_showmultilingualonly_value($module); 1291 $line = get_tag_line($doubleindent, "showmultilingualonly", $value); 1292 push(@xpdfile, $line); 1293 1294 $value = get_applicationmodule_value($module); 1295 $line = get_tag_line($doubleindent, "applicationmodule", $value); 1296 push(@xpdfile, $line); 1297 1298 $value = get_isjavamodule_value($module); 1299 $line = get_tag_line($doubleindent, "isjavapackage", $value); 1300 push(@xpdfile, $line); 1301 1302 $value = get_installcanfail_value($module); 1303 $line = get_tag_line($doubleindent, "installcanfail", $value); 1304 push(@xpdfile, $line); 1305 1306 $value = get_forceintoupdate_value($module); 1307 $line = get_tag_line($doubleindent, "forceintoupdate", $value); 1308 push(@xpdfile, $line); 1309 1310 $value = get_useforce_value($module); 1311 $line = get_tag_line($doubleindent, "useforce", $value); 1312 push(@xpdfile, $line); 1313 1314 # iterating over all languages to get names and descriptions 1315 collect_lang_values($doubleindent, $module, \@xpdfile, "Name", "name"); 1316 collect_lang_values($doubleindent, $module, \@xpdfile, "Description", "description"); 1317 1318 $tag = get_end_tag("display", $singleindent); 1319 push(@xpdfile, $tag); 1320 1321 # end of display tag 1322 1323 if ( ! $isemptyparent ) 1324 { 1325 # start of installunit tag -> using info from package defined in packagelist 1326 1327 $tag = get_installunit_tag($singleindent); 1328 push(@xpdfile, $tag); 1329 1330 $value = get_size_value($packagename, $xpdinfo); 1331 $line = get_tag_line($doubleindent, "size", $value); 1332 push(@xpdfile, $line); 1333 1334 $value = get_order_value($module); 1335 $line = get_tag_line($doubleindent, "installorder", $value); 1336 push(@xpdfile, $line); 1337 1338 $value = get_md5_value($packagename, $xpdinfo); 1339 $line = get_tag_line($doubleindent, "md5", $value); 1340 push(@xpdfile, $line); 1341 1342 $value = get_name_value($packagename); 1343 $line = get_tag_line($doubleindent, "name", $value); 1344 push(@xpdfile, $line); 1345 1346 $value = get_fullpkgname_value($packagename, $xpdinfo); 1347 $line = get_tag_line($doubleindent, "fullpkgname", $value); 1348 push(@xpdfile, $line); 1349 1350 $value = get_pkgversion_value($packagename, $xpdinfo); 1351 $line = get_tag_line($doubleindent, "pkgversion", $value); 1352 push(@xpdfile, $line); 1353 1354 $value = get_subdir_value($packagename, $subdir, $module); 1355 $line = get_tag_line($doubleindent, "subdir", $value); 1356 push(@xpdfile, $line); 1357 1358 $value = get_relocatable_value($module); 1359 $line = get_tag_line($doubleindent, "relocatable", $value); 1360 push(@xpdfile, $line); 1361 1362 $value = get_languagespecific_value($islanguagemodule); 1363 $line = get_tag_line($doubleindent, "languagespecific", $value); 1364 push(@xpdfile, $line); 1365 1366 $value = $onelanguage; 1367 $line = get_tag_line($doubleindent, "language", $value); 1368 push(@xpdfile, $line); 1369 1370 $line = get_tag_line($doubleindent, "solarislanguage", $solslanguage); 1371 push(@xpdfile, $line); 1372 1373 $tag = get_end_tag("installunit", $singleindent); 1374 push(@xpdfile, $tag); 1375 1376 # end of installunit tag 1377 } 1378 1379 $tag = get_end_tag("package", $noindent); 1380 push(@xpdfile, $tag); 1381 1382 return ( \@xpdfile, $parentgid ); 1383} 1384 1385################################################### 1386# Setting xpd file name 1387################################################### 1388 1389sub get_xpd_filename 1390{ 1391 my ($modulegid, $linkpackage) = @_; 1392 1393 if ( $linkpackage ) { $modulegid = $modulegid . "u"; } 1394 1395 my $filename = $modulegid . ".xpd"; 1396 1397 return $filename; 1398} 1399 1400################################################### 1401# Determine, which package was created newly 1402################################################### 1403 1404sub determine_new_packagename 1405{ 1406 my ( $installdir, $subdir, $xpdinfo ) = @_; 1407 1408 my $newpackage = ""; 1409 $installdir =~ s/\Q$installer::globals::separator\E\s*$//; 1410 my $directory = $installdir . $installer::globals::separator . $subdir; 1411 $directory =~ s/\Q$installer::globals::separator\E\s*$//; 1412 1413 if ( $xpdinfo->{'RealPackageName'} ) 1414 { 1415 $newpackage = $directory . $installer::globals::separator . $xpdinfo->{'RealPackageName'}; 1416 push(@installer::globals::currentcontent, $newpackage); 1417 return $newpackage; 1418 } 1419 1420 my ($newcontent, $allcontent) = installer::systemactions::find_new_content_in_directory($directory, \@installer::globals::currentcontent); 1421 @installer::globals::currentcontent = (); 1422 foreach my $element ( @{$allcontent} ) { push(@installer::globals::currentcontent, $element); } 1423 1424 my $newentriesnumber = $#{$newcontent} + 1; 1425 if ( $newentriesnumber > 1 ) { installer::exiter::exit_program("ERROR: More than one new package in directory $directory", "determine_new_packagename (xpdinstaller)"); } 1426 elsif ( $newentriesnumber < 1 ) { installer::exiter::exit_program("ERROR: No new package in directory $directory", "determine_new_packagename (xpdinstaller)"); } 1427 $newpackage = ${$newcontent}[0]; 1428 1429 return $newpackage; 1430} 1431 1432################################################### 1433# Checking, if the parentgid is defined in 1434# another package 1435################################################### 1436 1437sub is_empty_parent 1438{ 1439 my ($gid, $packages) = @_; 1440 1441 my $is_empty_parent = 1; 1442 1443 for ( my $k = 0; $k <= $#{$packages}; $k++ ) 1444 { 1445 my $onepackage = ${$packages}[$k]; 1446 my $packagegid = $onepackage->{'module'}; 1447 1448 if ( $packagegid eq $gid ) 1449 { 1450 $is_empty_parent = 0; 1451 last; 1452 } 1453 } 1454 1455 return $is_empty_parent; 1456} 1457 1458################################################### 1459# Creating additional xpd files for empty parents 1460################################################### 1461 1462sub create_emptyparents_xpd_file 1463{ 1464 my ($parentgid, $modulesarrayref, $xpddir) = @_; 1465 1466 my $module = get_module($parentgid, $modulesarrayref); 1467 my $grandpagid = ""; 1468 1469 if ( $module ne "" ) 1470 { 1471 my $packagename = ""; 1472 # all content saved in scp is now available and can be used to create the xpd file 1473 my ( $xpdfile, $newparentgid ) = get_file_content($module, $packagename, "", 0, 1, "", 0, "", ""); 1474 1475 $grandpagid = $newparentgid; 1476 1477 my $xpdfilename = get_xpd_filename($parentgid, 0); 1478 $xpdfilename = $xpddir . $installer::globals::separator . $xpdfilename; 1479 1480 installer::files::save_file($xpdfilename, $xpdfile); 1481 push(@installer::globals::allxpdfiles, $xpdfilename); 1482 my $infoline = "Saving xpd file: $xpdfilename\n"; 1483 push(@installer::globals::logfileinfo, $infoline); 1484 } 1485 1486 # push(@installer::globals::emptyxpdparents, $parentgid); 1487 push( @installer::globals::createdxpdfiles, $parentgid); 1488 1489 return $grandpagid; 1490} 1491 1492################################################### 1493# Creating additional xpd files for empty parents 1494################################################### 1495 1496sub filter_content_from_xpdfile 1497{ 1498 my ($xpdfile) = @_; 1499 1500 my @newxpdfile = (); 1501 1502 my $include = 1; 1503 1504 for ( my $i = 0; $i <= $#{$xpdfile}; $i++ ) 1505 { 1506 my $line = ${$xpdfile}[$i]; 1507 1508 if (( $line =~ /^\s*\<installunit/ ) && ( $include )) { $include = 0; } 1509 if ( $include ) { push(@newxpdfile, $line); } 1510 if (( $line =~ /^\s*\<\/installunit/ ) && ( ! $include )) { $include = 1; } 1511 } 1512 1513 return \@newxpdfile; 1514} 1515 1516########################################################################## 1517# Changing the parent inside the xpd file 1518# Old: <package name="gid_Module_Root" parent="root"> 1519# New: <package name="gid_Module_Root_Files_1" parent="gid_Module_Root"> 1520########################################################################## 1521 1522sub change_parent_in_xpdfile 1523{ 1524 my ($xpdfile, $modulename) = @_; 1525 1526 for ( my $i = 0; $i <= $#{$xpdfile}; $i++ ) 1527 { 1528 if ( ${$xpdfile}[$i] =~ /^\s*\<package name\s*=\s*\"(\S+?)\"\s+parent\s*=\s*\"(\S+?)\"\s*\>\s*$/ ) 1529 { 1530 my $oldname = $1; 1531 my $oldparent = $2; 1532 1533 my $newname = $modulename; 1534 my $newparent = $oldname; 1535 1536 ${$xpdfile}[$i] =~ s/\"\Q$oldname\E\"/\"$newname\"/; 1537 ${$xpdfile}[$i] =~ s/\"\Q$oldparent\E\"/\"$newparent\"/; 1538 1539 last; 1540 } 1541 } 1542} 1543 1544################################################### 1545# Creating one xpd file for each package 1546################################################### 1547 1548sub create_xpd_file 1549{ 1550 my ($onepackage, $allpackages, $languagestringref, $allvariables, $modulesarrayref, $installdir, $subdir, $linkpackage, $xpdinfo) = @_; 1551 1552 my $infoline = ""; 1553 # creating the directory 1554 my $xpddir = installer::systemactions::create_directories("xpdinstaller", $languagestringref); 1555 $xpddir =~ s/\/\s*$//; 1556 $installer::globals::xpddir = $xpddir; 1557 # push(@installer::globals::removedirs, $xpddir); 1558 1559 my $modulegid = $onepackage->{'module'}; 1560 1561 my $onelanguage = ""; # 1562 my $solslanguage = ""; # 1563 my $islanguagemodule = 0; # 1564 if ( $onepackage->{'islanguagemodule'} ) { $islanguagemodule = $onepackage->{'islanguagemodule'}; } # 1565 if ( $islanguagemodule ) # 1566 { 1567 $onelanguage = $onepackage->{'language'}; # 1568 if ( $installer::globals::issolarispkgbuild ) { $solslanguage = installer::epmfile::get_solaris_language_for_langpack($onelanguage); } # 1569 } 1570 1571 installer::logger::include_header_into_logfile("Creating xpd file ($modulegid):"); 1572 1573 my $module = get_module($modulegid, $modulesarrayref); 1574 1575 if ( $module ne "" ) 1576 { 1577 my $packagename = determine_new_packagename($installdir, $subdir, $xpdinfo); 1578 1579 # all content saved in scp is now available and can be used to create the xpd file 1580 my ( $xpdfile, $parentgid ) = get_file_content($module, $packagename, $solslanguage, $linkpackage, 0, "", $islanguagemodule, $onelanguage, $xpdinfo); 1581 1582 my $xpdfilename = get_xpd_filename($modulegid, $linkpackage); 1583 $xpdfilename = $xpddir . $installer::globals::separator . $xpdfilename; 1584 1585 # Very special handling for Root module: 1586 # Because packages should only be assigned to leaves and not to knods, 1587 # the root module is divided into a knod without package and a new 1588 # leave with package. The name of the leave is defined at $module->{'XpdPackageName'}. 1589 if ( $module->{'XpdPackageName'} ) 1590 { 1591 my $newxpdfilename = get_xpd_filename($module->{'XpdPackageName'}, 0); 1592 $newxpdfilename = $xpddir . $installer::globals::separator . $newxpdfilename; 1593 my $emptyfilecontent = filter_content_from_xpdfile($xpdfile); 1594 1595 installer::files::save_file($xpdfilename, $emptyfilecontent); 1596 push(@installer::globals::allxpdfiles, $xpdfilename); 1597 $infoline = "Saving xpd file: $xpdfilename\n"; 1598 push( @installer::globals::logfileinfo, $infoline); 1599 1600 $xpdfilename = $newxpdfilename; 1601 change_parent_in_xpdfile($xpdfile, $module->{'XpdPackageName'}); 1602 } 1603 1604 installer::files::save_file($xpdfilename, $xpdfile); 1605 push( @installer::globals::createdxpdfiles, $modulegid); 1606 push(@installer::globals::allxpdfiles, $xpdfilename); 1607 $infoline = "Saving xpd file: $xpdfilename\n"; 1608 push( @installer::globals::logfileinfo, $infoline); 1609 1610 my $grandpagid = "root"; 1611 if ( $parentgid ne "root" ) 1612 { 1613 my $create_missing_parent = is_empty_parent($parentgid, $allpackages); 1614 1615 # if (( $create_missing_parent ) && ( ! installer::existence::exists_in_array($parentgid, \@installer::globals::emptyxpdparents) )) 1616 if (( $create_missing_parent ) && ( ! installer::existence::exists_in_array($parentgid, \@installer::globals::createdxpdfiles) )) 1617 { 1618 $grandpagid = create_emptyparents_xpd_file($parentgid, $modulesarrayref, $xpddir); 1619 } 1620 } 1621 1622 if ( $grandpagid ne "root" ) 1623 { 1624 my $create_missing_parent = is_empty_parent($grandpagid, $allpackages); 1625 1626 # if (( $create_missing_parent ) && ( ! installer::existence::exists_in_array($parentgid, \@installer::globals::emptyxpdparents) )) 1627 if (( $create_missing_parent ) && ( ! installer::existence::exists_in_array($grandpagid, \@installer::globals::createdxpdfiles) )) 1628 { 1629 create_emptyparents_xpd_file($grandpagid, $modulesarrayref, $xpddir); 1630 } 1631 } 1632 } 1633 else 1634 { 1635 installer::exiter::exit_program("ERROR: No module definition found for gid: $modulegid", "create_xpd_file (xpdinstaller)"); 1636 } 1637 1638} 1639 1640################################################### 1641# Creating a xpd file for a copied package 1642################################################### 1643 1644sub create_xpd_file_for_childproject 1645{ 1646 my ($module, $destdir, $packagename, $allvariableshashref, $modulesarrayref) = @_; 1647 1648 my $modulegid = $module->{'gid'}; 1649 1650 my $currentdir = cwd(); 1651 $destdir =~ s/\/\s*$//; 1652 $currentdir =~ s/\/\s*$//; 1653 1654 my $completepackage = $currentdir . $installer::globals::separator . $destdir . $installer::globals::separator . $packagename; 1655 1656 # all content saved in scp is now available and can be used to create the xpd file 1657 my ( $xpdfile, $parentgid ) = get_file_content($module, $completepackage, "", 0, 0, "", 0, "", ""); 1658 1659 my $xpdfilename = get_xpd_filename($modulegid, 0); 1660 $xpdfilename = $installer::globals::xpddir . $installer::globals::separator . $xpdfilename; 1661 1662 installer::files::save_file($xpdfilename, $xpdfile); 1663 push( @installer::globals::createdxpdfiles, $modulegid); 1664 push(@installer::globals::allxpdfiles, $xpdfilename); 1665 my $infoline = "Saving xpd file: $xpdfilename\n"; 1666 push( @installer::globals::logfileinfo, $infoline); 1667 1668 if ( $parentgid ne "root" ) 1669 { 1670 # my $create_missing_parent = is_empty_parent($parentgid, $allpackages); 1671 my $create_missing_parent = 1; # -> Always missing parent by child projects! 1672 # Parent is now created, if it was not created before. Attention: Parent module must not come later. 1673 if (( $create_missing_parent ) && ( ! installer::existence::exists_in_array($parentgid, \@installer::globals::createdxpdfiles) )) 1674 { 1675 create_emptyparents_xpd_file($parentgid, $modulesarrayref, $installer::globals::xpddir); 1676 } 1677 } 1678} 1679 1680############################################################## 1681# Creating a xpd file for copied system integration package 1682############################################################## 1683 1684sub create_xpd_file_for_systemintegration 1685{ 1686 my ($module, $newcontent, $modulesarrayref, $subdir) = @_; 1687 1688 my $parentgid = $module->{'gid'}; 1689 1690 # Create new visible module from scp info and create 1691 # new hidden module for each package inside in tar file 1692 1693 for ( my $i = 0; $i <= $#{$newcontent}; $i++ ) 1694 { 1695 my $newpackagename = ${$newcontent}[$i]; 1696 1697 # installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$newpackagename); 1698 1699 my $infoline = "Creating xpd file for package: $newpackagename\n"; 1700 push( @installer::globals::logfileinfo, $infoline); 1701 1702 my $childmodule = installer::worker::copy_hash_from_references($module); 1703 $childmodule->{'ParentID'} = $module->{'gid'}; # the module gid is the new parent 1704 $childmodule->{'InstallOrder'} = $installer::globals::defaultsystemintinstallorder; 1705 my $number = $i + 1; 1706 my $modulegid = $module->{'gid'} . "_child_" . $number; # setting a dynamic new gid 1707 $childmodule->{'gid'} = $modulegid; 1708 $childmodule->{'Styles'} =~ s/\)/\,HIDDEN_ROOT\)/; 1709 # iterating over all languages to get names and descriptions 1710 remove_lang_values($childmodule, "Name"); 1711 remove_lang_values($childmodule, "Description"); 1712 1713 my $shortpackagename = $newpackagename; 1714 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$shortpackagename); 1715 $childmodule->{'PackageName'} = $shortpackagename; 1716 $childmodule->{'Name'} = $modulegid; 1717 $childmodule->{'Description'} = $modulegid; 1718 1719 # Checking, if installorder can be set: 1720 # scp syntax: InstallOrder = "desktop:1050, suse:1060"; 1721 # The string before the number can be compared with $shortpackagename 1722 if ( $module->{'InstallOrder'} ) 1723 { 1724 my $installorder = $module->{'InstallOrder'}; 1725 $installorder =~ s/^\s*\"//g; 1726 $installorder =~ s/\"\s*$//g; 1727 # $installorder is comma separated list 1728 my $allorders = installer::converter::convert_stringlist_into_array(\$installorder, ","); 1729 for ( my $j = 0; $j <= $#{$allorders}; $j++ ) 1730 { 1731 my $oneitem = ${$allorders}[$j]; 1732 if ( $oneitem =~ /^\s*(\S+?)\s*:\s*(\S+?)\s*$/ ) 1733 { 1734 my $name = $1; 1735 my $order = $2; 1736 1737 if ( $shortpackagename =~ /\Q$name\E/ ) { $childmodule->{'InstallOrder'} = $order; } 1738 } 1739 } 1740 } 1741 1742 # all content saved in scp is now available and can be used to create the xpd file 1743 my ( $xpdfile, $parentgid_ ) = get_file_content($childmodule, $newpackagename, "", 0, 0, $subdir, 0, "", ""); 1744 1745 my $xpdfilename = get_xpd_filename($modulegid, 0); 1746 $xpdfilename = $installer::globals::xpddir . $installer::globals::separator . $xpdfilename; 1747 1748 installer::files::save_file($xpdfilename, $xpdfile); 1749 push(@installer::globals::allxpdfiles, $xpdfilename); 1750 $infoline = "Saving xpd file: $xpdfilename\n"; 1751 push( @installer::globals::logfileinfo, $infoline); 1752 } 1753 1754 # Creating the top level visible xpd file 1755 create_emptyparents_xpd_file($parentgid, $modulesarrayref, $installer::globals::xpddir); 1756} 1757 1758############################################################## 1759# Copying xpd files into installation set 1760############################################################## 1761 1762sub copy_xpd_files 1763{ 1764 my ( $destdir ) = @_; 1765 1766 for ( my $i = 0; $i <= $#installer::globals::allxpdfiles; $i++ ) 1767 { 1768 if ( ! -f $installer::globals::allxpdfiles[$i] ) { installer::exiter::exit_program("ERROR: Could not find xpd file: $installer::globals::allxpdfiles[$i]!", "copy_xpd_files"); } 1769 installer::systemactions::copy_one_file($installer::globals::allxpdfiles[$i], $destdir); 1770 } 1771} 1772 1773############################################################## 1774# Copying all xpd files into the installation set 1775############################################################## 1776 1777sub copy_xpd_files_into_installset 1778{ 1779 my ($installdir) = @_; 1780 1781 $installdir =~ s/\Q$installer::globals::separator\E\s*$//; 1782 1783 my $instdir = $installdir . $installer::globals::separator . "installdata"; 1784 installer::systemactions::create_directory($instdir); 1785 1786 my $xpddir = $instdir . $installer::globals::separator . "xpd"; 1787 installer::systemactions::create_directory($xpddir); 1788 copy_xpd_files($xpddir); 1789} 1790 1791############################################################## 1792# Creating base xpd file with product information 1793############################################################## 1794 1795sub create_setup_xpd 1796{ 1797 my ($allvariables, $languagestringref) = @_; 1798 1799 my ( $xpdfile ) = get_setup_file_content($allvariables, $languagestringref); 1800 1801 my $xpdfilename = $installer::globals::productxpdfile; 1802 $xpdfilename = $installer::globals::xpddir . $installer::globals::separator . $xpdfilename; 1803 1804 installer::files::save_file($xpdfilename, $xpdfile); 1805 push(@installer::globals::allxpdfiles, $xpdfilename); 1806 my $infoline = "Saving xpd file: $xpdfilename\n"; 1807 push( @installer::globals::logfileinfo, $infoline); 1808} 1809 1810################################################### 1811# Copying the files needed by the xpd installer 1812# into the installation directory 1813################################################### 1814 1815sub create_xpd_installer 1816{ 1817 my ( $installdir, $allvariables, $languagestringref) = @_; 1818 1819 installer::logger::include_header_into_logfile("Creating xpd installer:"); 1820 1821 # create setup.xpd file 1822 create_setup_xpd($allvariables, $languagestringref); 1823 1824 # copy xpd files into installation set 1825 copy_xpd_files_into_installset($installdir); 1826} 1827 18281; 1829