1#************************************************************************* 2# 3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4# 5# Copyright 2000, 2010 Oracle and/or its affiliates. 6# 7# OpenOffice.org - a multi-platform office productivity suite 8# 9# This file is part of OpenOffice.org. 10# 11# OpenOffice.org is free software: you can redistribute it and/or modify 12# it under the terms of the GNU Lesser General Public License version 3 13# only, as published by the Free Software Foundation. 14# 15# OpenOffice.org is distributed in the hope that it will be useful, 16# but WITHOUT ANY WARRANTY; without even the implied warranty of 17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18# GNU Lesser General Public License version 3 for more details 19# (a copy is included in the LICENSE file that accompanied this code). 20# 21# You should have received a copy of the GNU Lesser General Public License 22# version 3 along with OpenOffice.org. If not, see 23# <http://www.openoffice.org/license.html> 24# for a copy of the LGPLv3 License. 25# 26#************************************************************************* 27 28package installer::epmfile; 29 30use Cwd; 31use installer::converter; 32use installer::existence; 33use installer::exiter; 34use installer::files; 35use installer::globals; 36use installer::logger; 37use installer::packagelist; 38use installer::pathanalyzer; 39use installer::remover; 40use installer::scriptitems; 41use installer::systemactions; 42use installer::worker; 43use POSIX; 44 45############################################################################ 46# Reading the package map to find Solaris package names for 47# the corresponding abbreviations 48############################################################################ 49 50sub read_packagemap 51{ 52 my ($allvariables, $includepatharrayref, $languagesarrayref) = @_; 53 54 my $packagemapname = ""; 55 if ( $allvariables->{'PACKAGEMAP'} ) { $packagemapname = $allvariables->{'PACKAGEMAP'}; } 56 if ( $packagemapname eq "" ) { installer::exiter::exit_program("ERROR: Property PACKAGEMAP must be defined!", "read_packagemap"); } 57 58 my $infoline = "\n\nCollected abbreviations and package names:\n"; 59 push(@installer::globals::logfileinfo, $infoline); 60 61 # Can be a comma separated list. All files have to be found in include pathes 62 my $allpackagemapnames = installer::converter::convert_stringlist_into_hash(\$packagemapname, ","); 63 foreach my $onepackagemapname ( keys %{$allpackagemapnames} ) 64 { 65 my $packagemapref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$onepackagemapname, $includepatharrayref, 0); 66 67 if ( $$packagemapref eq "" ) { installer::exiter::exit_program("ERROR: Could not find package map file \"$onepackagemapname\" (propery PACKAGEMAP)!", "read_packagemap"); } 68 69 my $packagemapcontent = installer::files::read_file($$packagemapref); 70 71 for ( my $i = 0; $i <= $#{$packagemapcontent}; $i++ ) 72 { 73 my $line = ${$packagemapcontent}[$i]; 74 75 if ( $line =~ /^\s*\#/ ) { next; } # comment line 76 if ( $line =~ /^\s*$/ ) { next; } # empty line 77 78 if ( $line =~ /^\s*(.*?)\t(.*?)\s*$/ ) 79 { 80 my $abbreviation = $1; 81 my $packagename = $2; 82 installer::packagelist::resolve_packagevariables(\$abbreviation, $allvariables, 0); 83 installer::packagelist::resolve_packagevariables(\$packagename, $allvariables, 0); 84 85 # Special handling for language strings %LANGUAGESTRING 86 87 if (( $abbreviation =~ /\%LANGUAGESTRING/ ) || ( $packagename =~ /\%LANGUAGESTRING/ )) 88 { 89 foreach my $onelang ( @{$languagesarrayref} ) 90 { 91 my $local_abbreviation = $abbreviation; 92 my $local_packagename = $packagename; 93 $local_abbreviation =~ s/\%LANGUAGESTRING/$onelang/g; 94 $local_packagename =~ s/\%LANGUAGESTRING/$onelang/g; 95 96 # Logging all abbreviations and packagenames 97 $infoline = "$onelang : $local_abbreviation : $local_packagename\n"; 98 push(@installer::globals::logfileinfo, $infoline); 99 100 if ( exists($installer::globals::dependfilenames{$local_abbreviation}) ) 101 { 102 installer::exiter::exit_program("ERROR: Packagename for Solaris package $local_abbreviation already defined ($installer::globals::dependfilenames{$local_abbreviation})!", "read_packagemap"); 103 } 104 else 105 { 106 $installer::globals::dependfilenames{$local_abbreviation} = $local_packagename; 107 } 108 } 109 } 110 else 111 { 112 # Logging all abbreviations and packagenames 113 $infoline = "$abbreviation : $packagename\n"; 114 push(@installer::globals::logfileinfo, $infoline); 115 116 if ( exists($installer::globals::dependfilenames{$abbreviation}) ) 117 { 118 installer::exiter::exit_program("ERROR: Packagename for Solaris package $abbreviation already defined ($installer::globals::dependfilenames{$abbreviation})!", "read_packagemap"); 119 } 120 else 121 { 122 $installer::globals::dependfilenames{$abbreviation} = $packagename; 123 } 124 } 125 } 126 else 127 { 128 my $errorline = $i + 1; 129 installer::exiter::exit_program("ERROR: Wrong syntax in file \"$onepackagemapname\" (line $errorline)!", "read_packagemap"); 130 } 131 } 132 } 133 134 $infoline = "\n\n"; 135 push(@installer::globals::logfileinfo, $infoline); 136 137} 138 139############################################################################ 140# The header file contains the strings for the epm header in all languages 141############################################################################ 142 143sub get_string_from_headerfile 144{ 145 my ($searchstring, $language, $fileref) = @_; 146 147 my $returnstring = ""; 148 my $onestring = ""; 149 my $englishstring = ""; 150 my $foundblock = 0; 151 my $foundstring = 0; 152 my $foundenglishstring = 0; 153 my $englishidentifier = "01"; 154 155 $searchstring = "[" . $searchstring . "]"; 156 157 for ( my $i = 0; $i <= $#{$fileref}; $i++ ) 158 { 159 my $line = ${$fileref}[$i]; 160 161 if ( $line =~ /^\s*\Q$searchstring\E\s*$/ ) 162 { 163 $foundblock = 1; 164 my $counter = $i + 1; 165 166 $line = ${$fileref}[$counter]; 167 168 # Beginning of the next block oder Dateiende 169 170 while ((!($line =~ /^\s*\[\s*\w+\s*\]\s*$/ )) && ( $counter <= $#{$fileref} )) 171 { 172 if ( $line =~ /^\s*\Q$language\E\s+\=\s*\"(.*)\"\s*$/ ) 173 { 174 $onestring = $1; 175 $foundstring = 1; 176 last; 177 } 178 179 if ( $line =~ /^\s*\Q$englishidentifier\E\s+\=\s*\"(.*)\"\s*$/ ) 180 { 181 $englishstring = $1; 182 $foundenglishstring = 1; 183 } 184 185 $counter++; 186 $line = ${$fileref}[$counter]; 187 } 188 } 189 } 190 191 if ( $foundstring ) 192 { 193 $returnstring = $onestring; 194 } 195 else 196 { 197 if ( $foundenglishstring ) 198 { 199 $returnstring = $englishstring; 200 } 201 else 202 { 203 installer::exiter::exit_program("ERROR: No string found for $searchstring in epm header file (-h)", "get_string_from_headerfile"); 204 } 205 } 206 207 return \$returnstring; 208} 209 210########################################################## 211# Filling the epm file with directories, files and links 212########################################################## 213 214sub put_directories_into_epmfile 215{ 216 my ($directoriesarrayref, $epmfileref, $allvariables, $packagerootpath) = @_; 217 my $group = "bin"; 218 219 if ( $installer::globals::islinuxbuild ) 220 { 221 $group = "root"; 222 } 223 224 for ( my $i = 0; $i <= $#{$directoriesarrayref}; $i++ ) 225 { 226 my $onedir = ${$directoriesarrayref}[$i]; 227 my $dir = ""; 228 229 if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; } 230 231 # if (!($dir =~ /\bPREDEFINED_/ )) 232 if ((!($dir =~ /\bPREDEFINED_/ )) || ( $dir =~ /\bPREDEFINED_PROGDIR\b/ )) 233 { 234 my $hostname = $onedir->{'HostName'}; 235 236 # not including simple directory "/opt" 237 # if (( $allvariables->{'SETSTATICPATH'} ) && ( $hostname eq $packagerootpath )) { next; } 238 239 my $line = "d 755 root $group $hostname -\n"; 240 241 push(@{$epmfileref}, $line) 242 } 243 } 244} 245 246sub put_files_into_epmfile 247{ 248 my ($filesinproductarrayref, $epmfileref) = @_; 249 250 for ( my $i = 0; $i <= $#{$filesinproductarrayref}; $i++ ) 251 { 252 my $onefile = ${$filesinproductarrayref}[$i]; 253 254 my $unixrights = $onefile->{'UnixRights'}; 255 my $destination = $onefile->{'destination'}; 256 my $sourcepath = $onefile->{'sourcepath'}; 257 258 my $filetype = "f"; 259 my $styles = ""; 260 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; } 261 if ( $styles =~ /\bCONFIGFILE\b/ ) { $filetype = "c"; } 262 263 my $group = "bin"; 264 if ( $installer::globals::islinuxbuild ) { $group = "root"; } 265 if (( $installer::globals::issolarisbuild ) && ( $onefile->{'SolarisGroup'} )) { $group = $onefile->{'SolarisGroup'}; } 266 267 my $line = "$filetype $unixrights root $group $destination $sourcepath\n"; 268 269 push(@{$epmfileref}, $line); 270 } 271} 272 273sub put_links_into_epmfile 274{ 275 my ($linksinproductarrayref, $epmfileref) = @_; 276 my $group = "bin"; 277 278 if ( $installer::globals::islinuxbuild ) 279 { 280 $group = "root"; 281 } 282 283 284 for ( my $i = 0; $i <= $#{$linksinproductarrayref}; $i++ ) 285 { 286 my $onelink = ${$linksinproductarrayref}[$i]; 287 my $destination = $onelink->{'destination'}; 288 my $destinationfile = $onelink->{'destinationfile'}; 289 290 my $line = "l 000 root $group $destination $destinationfile\n"; 291 292 push(@{$epmfileref}, $line) 293 } 294} 295 296sub put_unixlinks_into_epmfile 297{ 298 my ($unixlinksinproductarrayref, $epmfileref) = @_; 299 my $group = "bin"; 300 301 if ( $installer::globals::islinuxbuild ) { $group = "root"; } 302 303 for ( my $i = 0; $i <= $#{$unixlinksinproductarrayref}; $i++ ) 304 { 305 my $onelink = ${$unixlinksinproductarrayref}[$i]; 306 my $destination = $onelink->{'destination'}; 307 my $target = $onelink->{'Target'}; 308 309 my $line = "l 000 root $group $destination $target\n"; 310 311 push(@{$epmfileref}, $line) 312 } 313} 314 315############################################### 316# Creating epm header file 317############################################### 318 319sub create_epm_header 320{ 321 my ($variableshashref, $filesinproduct, $languagesref, $onepackage) = @_; 322 323 my @epmheader = (); 324 325 my ($licensefilename, $readmefilename); 326 327 my $foundlicensefile = 0; 328 my $foundreadmefile = 0; 329 330 my $line = ""; 331 my $infoline = ""; 332 333 # %product OpenOffice.org Software 334 # %version 2.0 335 # %description A really great software 336 # %copyright 1999-2003 by OOo 337 # %vendor OpenOffice.org 338 # %license /test/replace/01/LICENSE01 339 # %readme /test/replace/01/README01 340 # %requires foo 341 # %provides bar 342 343 # The first language in the languages array determines the language of license and readme file 344 345 my $searchlanguage = ${$languagesref}[0]; 346 347 # using the description for the %product line in the epm list file 348 349 my $productnamestring = $onepackage->{'description'}; 350 installer::packagelist::resolve_packagevariables(\$productnamestring, $variableshashref, 0); 351 if ( $variableshashref->{'PRODUCTEXTENSION'} ) { $productnamestring = $productnamestring . " " . $variableshashref->{'PRODUCTEXTENSION'}; } 352 353 $line = "%product" . " " . $productnamestring . "\n"; 354 push(@epmheader, $line); 355 356 # Determining the release version 357 # This release version has to be listed in the line %version : %version versionnumber releasenumber 358 359 # if ( $variableshashref->{'PACKAGEVERSION'} ) { $installer::globals::packageversion = $variableshashref->{'PACKAGEVERSION'}; } 360 if ( ! $onepackage->{'packageversion'} ) { installer::exiter::exit_program("ERROR: No packageversion defined for package: $onepackage->{'module'}!", "create_epm_header"); } 361 $installer::globals::packageversion = $onepackage->{'packageversion'}; 362 installer::packagelist::resolve_packagevariables(\$installer::globals::packageversion, $variableshashref, 0); 363 if ( $variableshashref->{'PACKAGEREVISION'} ) { $installer::globals::packagerevision = $variableshashref->{'PACKAGEREVISION'}; } 364 365 $line = "%version" . " " . $installer::globals::packageversion . "\n"; 366 push(@epmheader, $line); 367 368 $line = "%release" . " " . $installer::globals::packagerevision . "\n"; 369 if ( $installer::globals::islinuxrpmbuild ) { $line = "%release" . " " . $installer::globals::buildid . "\n"; } 370 push(@epmheader, $line); 371 372 # Description, Copyright and Vendor are multilingual and are defined in 373 # the string file for the header file ($headerfileref) 374 375 my $descriptionstring = $onepackage->{'description'}; 376 installer::packagelist::resolve_packagevariables(\$descriptionstring, $variableshashref, 0); 377 $line = "%description" . " " . $descriptionstring . "\n"; 378 push(@epmheader, $line); 379 380 my $copyrightstring = $onepackage->{'copyright'}; 381 installer::packagelist::resolve_packagevariables(\$copyrightstring, $variableshashref, 0); 382 $line = "%copyright" . " " . $copyrightstring . "\n"; 383 push(@epmheader, $line); 384 385 my $vendorstring = $onepackage->{'vendor'}; 386 installer::packagelist::resolve_packagevariables(\$vendorstring, $variableshashref, 0); 387 $line = "%vendor" . " " . $vendorstring . "\n"; 388 push(@epmheader, $line); 389 390 # License and Readme file can be included automatically from the file list 391 392 if ( $installer::globals::iswindowsbuild ) 393 { 394 $licensefilename = "license.txt"; 395 $readmefilename = "readme.txt"; 396 } 397 else 398 { 399 $licensefilename = "LICENSE"; 400 $readmefilename = "README"; 401 } 402 403 if (( $installer::globals::languagepack ) # in language packs the files LICENSE and README are removed, because they are not language specific 404 || ( $variableshashref->{'NO_README_IN_ROOTDIR'} )) 405 { 406 if ( $installer::globals::iswindowsbuild ) 407 { 408 $licensefilename = "license_$searchlanguage.txt"; 409 $readmefilename = "readme_$searchlanguage.txt"; 410 } 411 else 412 { 413 $licensefilename = "LICENSE_$searchlanguage"; 414 $readmefilename = "README_$searchlanguage"; 415 } 416 } 417 418 my $license_in_package_defined = 0; 419 420 if ( $installer::globals::issolarisbuild ) 421 { 422 if ( $onepackage->{'solariscopyright'} ) 423 { 424 $licensefilename = $onepackage->{'solariscopyright'}; 425 $license_in_package_defined = 1; 426 } 427 } 428 429 # Process for Linux packages, in which only a very basic license file is 430 # included into the package. 431 432 if ( $installer::globals::islinuxbuild ) 433 { 434 if ( $variableshashref->{'COPYRIGHT_INTO_LINUXPACKAGE'} ) 435 { 436 $licensefilename = "linuxcopyrightfile"; 437 $license_in_package_defined = 1; 438 } 439 } 440 # searching for and readme file 441 442 for ( my $i = 0; $i <= $#{$filesinproduct}; $i++ ) 443 { 444 my $onefile = ${$filesinproduct}[$i]; 445 my $filename = $onefile->{'Name'}; 446 if ( $filename eq $readmefilename ) 447 { 448 $foundreadmefile = 1; 449 $line = "%readme" . " " . $onefile->{'sourcepath'} . "\n"; 450 push(@epmheader, $line); 451 last; 452 } 453 } 454 455 # searching for and license file 456 457 if ( $license_in_package_defined ) 458 { 459 my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, "" , 0); 460 461 if ( $$fileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find license file $licensefilename (A)!", "create_epm_header"); } 462 463 # Special handling to add the content of the file "license_en-US" to the solaris copyrightfile. But not for all products 464 465 if (( $installer::globals::issolarispkgbuild ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} )) 466 { 467 if ( ! $installer::globals::englishlicenseset ) { installer::worker::set_english_license() } 468 469 # The location for the new file 470 my $languagestring = ""; 471 for ( my $i = 0; $i <= $#{$languagesref}; $i++ ) { $languagestring = $languagestring . "_" . ${$languagesref}[$i]; } 472 $languagestring =~ s/^\s*_//; 473 474 my $copyrightdir = installer::systemactions::create_directories("copyright", \$languagestring); 475 476 my $copyrightfile = installer::files::read_file($$fileref); 477 478 # Adding license content to copyright file 479 push(@{$copyrightfile}, "\n"); 480 for ( my $i = 0; $i <= $#{$installer::globals::englishlicense}; $i++ ) { push(@{$copyrightfile}, ${$installer::globals::englishlicense}[$i]); } 481 482 # New destination for $$fileref 483 $$fileref = $copyrightdir . $installer::globals::separator . "solariscopyrightfile_" . $onepackage->{'module'}; 484 if ( -f $$fileref ) { unlink $$fileref; } 485 installer::files::save_file($$fileref, $copyrightfile); 486 } 487 488 $infoline = "Using license file: \"$$fileref\"!\n"; 489 push(@installer::globals::logfileinfo, $infoline); 490 491 $foundlicensefile = 1; 492 $line = "%license" . " " . $$fileref . "\n"; 493 push(@epmheader, $line); 494 } 495 else 496 { 497 for ( my $i = 0; $i <= $#{$filesinproduct}; $i++ ) 498 { 499 my $onefile = ${$filesinproduct}[$i]; 500 my $filename = $onefile->{'Name'}; 501 502 if ( $filename eq $licensefilename ) 503 { 504 $foundlicensefile = 1; 505 $line = "%license" . " " . $onefile->{'sourcepath'} . "\n"; 506 push(@epmheader, $line); 507 last; 508 } 509 } 510 } 511 512 if (!($foundlicensefile)) 513 { 514 installer::exiter::exit_program("ERROR: Could not find license file $licensefilename (B)", "create_epm_header"); 515 } 516 517 if (!($foundreadmefile)) 518 { 519 installer::exiter::exit_program("ERROR: Could not find readme file $readmefilename (C)", "create_epm_header"); 520 } 521 522 # including %replaces 523 524 my $replaces = ""; 525 526 if (( $installer::globals::issolarispkgbuild ) && ( ! $installer::globals::patch )) 527 { 528 $replaces = "solarisreplaces"; # the name in the packagelist 529 } 530 elsif (( $installer::globals::islinuxbuild ) && ( ! $installer::globals::patch )) 531 { 532 $replaces = "linuxreplaces"; # the name in the packagelist 533 } 534 535 if (( $replaces ) && ( ! $installer::globals::patch )) 536 { 537 if ( $onepackage->{$replaces} ) 538 { 539 my $replacesstring = $onepackage->{$replaces}; 540 541 my $allreplaces = installer::converter::convert_stringlist_into_array(\$replacesstring, ","); 542 543 for ( my $i = 0; $i <= $#{$allreplaces}; $i++ ) 544 { 545 my $onereplaces = ${$allreplaces}[$i]; 546 $onereplaces =~ s/\s*$//; 547 installer::packagelist::resolve_packagevariables(\$onereplaces, $variableshashref, 1); 548 if ( $installer::globals::linuxlinkrpmprocess ) { $onereplaces = $onereplaces . "u"; } 549 if ( $installer::globals::debian ) { $onereplaces =~ s/_/-/g; } # Debian allows no underline in package name 550 $line = "%replaces" . " " . $onereplaces . "\n"; 551 push(@epmheader, $line); 552 553 # Force the openofficeorg packages to get removed, 554 # see http://www.debian.org/doc/debian-policy/ch-relationships.html 555 # 7.5.2 Replacing whole packages, forcing their removal 556 557 if ( $installer::globals::debian ) 558 { 559 $line = "%incompat" . " " . $onereplaces . "\n"; 560 push(@epmheader, $line); 561 } 562 } 563 564 if ( $installer::globals::debian && $variableshashref->{'UNIXPRODUCTNAME'} eq 'openoffice.org' ) 565 { 566 $line = "%provides" . " openoffice.org-unbundled\n"; 567 push(@epmheader, $line); 568 $line = "%incompat" . " openoffice.org-bundled\n"; 569 push(@epmheader, $line); 570 } 571 } 572 } 573 574 # including the directives for %requires and %provides 575 576 my $provides = ""; 577 my $requires = ""; 578 579 if ( $installer::globals::issolarispkgbuild ) 580 { 581 $provides = "solarisprovides"; # the name in the packagelist 582 $requires = "solarisrequires"; # the name in the packagelist 583 } 584 elsif ( $installer::globals::isfreebsdpkgbuild ) 585 { 586 $provides = "freebsdprovides"; # the name in the packagelist 587 $requires = "freebsdrequires"; # the name in the packagelist 588 } 589 elsif (( $installer::globals::islinuxrpmbuild ) && 590 ( $installer::globals::patch ) && 591 ( exists($onepackage->{'linuxpatchrequires'}) )) 592 { 593 $provides = "provides"; # the name in the packagelist 594 $requires = "linuxpatchrequires"; # the name in the packagelist 595 } 596 else 597 { 598 $provides = "provides"; # the name in the packagelist 599 $requires = "requires"; # the name in the packagelist 600 } 601 602 # if ( $installer::globals::patch ) 603 # { 604 # $onepackage->{$provides} = ""; 605 my $isdict = 0; 606 if ( $onepackage->{'packagename'} =~ /-dict-/ ) { $isdict = 1; } 607 608 # $onepackage->{$requires} = ""; 609 # } 610 611 if ( $onepackage->{$provides} ) 612 { 613 my $providesstring = $onepackage->{$provides}; 614 615 my $allprovides = installer::converter::convert_stringlist_into_array(\$providesstring, ","); 616 617 for ( my $i = 0; $i <= $#{$allprovides}; $i++ ) 618 { 619 my $oneprovides = ${$allprovides}[$i]; 620 $oneprovides =~ s/\s*$//; 621 installer::packagelist::resolve_packagevariables(\$oneprovides, $variableshashref, 1); 622 if ( $installer::globals::linuxlinkrpmprocess ) { $oneprovides = $oneprovides . "u"; } 623 if ( $installer::globals::debian ) { $oneprovides =~ s/_/-/g; } # Debian allows no underline in package name 624 $line = "%provides" . " " . $oneprovides . "\n"; 625 push(@epmheader, $line); 626 } 627 } 628 629 if ( $onepackage->{$requires} ) 630 { 631 my $requiresstring = $onepackage->{$requires}; 632 633 if ( $installer::globals::add_required_package ) { $requiresstring = $requiresstring . "," . $installer::globals::add_required_package; } 634 635 # The requires string can contain the separator "," in the names (descriptions) of the packages 636 # (that are required for Solaris depend files). Therefore "," inside such a description has to 637 # masked with a backslash. 638 # This masked separator need to be found and replaced, before the stringlist is converted into an array. 639 # This replacement has to be turned back after the array is created. 640 641 my $replacementstring = "COMMAREPLACEMENT"; 642 $requiresstring = installer::converter::replace_masked_separator($requiresstring, ",", "$replacementstring"); 643 644 my $allrequires = installer::converter::convert_stringlist_into_array(\$requiresstring, ","); 645 646 installer::converter::resolve_masked_separator($allrequires, ",", $replacementstring); 647 648 for ( my $i = 0; $i <= $#{$allrequires}; $i++ ) 649 { 650 my $onerequires = ${$allrequires}[$i]; 651 $onerequires =~ s/\s*$//; 652 installer::packagelist::resolve_packagevariables2(\$onerequires, $variableshashref, 0, $isdict); 653 if ( $installer::globals::debian ) { $onerequires =~ s/_/-/g; } # Debian allows no underline in package name 654 655 # Special handling for Solaris. In depend files, the names of the packages are required, not 656 # only the abbreviation. Therefore there is a special syntax for names in packagelist: 657 # solarisrequires = "SUNWcar (Name="Package name of SUNWcar"),SUNWkvm (Name="Package name of SUNWcar"), ... 658 # if ( $installer::globals::issolarispkgbuild ) 659 # { 660 # if ( $onerequires =~ /^\s*(.*?)\s+\(\s*Name\s*=\s*\"(.*?)\"\s*\)\s*$/ ) 661 # { 662 # $onerequires = $1; 663 # $packagename = $2; 664 # $installer::globals::dependfilenames{$onerequires} = $packagename; 665 # } 666 # } 667 668 $line = "%requires" . " " . $onerequires . "\n"; 669 push(@epmheader, $line); 670 } 671 } 672 else 673 { 674 if ( $installer::globals::add_required_package ) 675 { 676 my $requiresstring = $installer::globals::add_required_package; 677 678 my $replacementstring = "COMMAREPLACEMENT"; 679 $requiresstring = installer::converter::replace_masked_separator($requiresstring, ",", "$replacementstring"); 680 my $allrequires = installer::converter::convert_stringlist_into_array(\$requiresstring, ","); 681 installer::converter::resolve_masked_separator($allrequires, ",", $replacementstring); 682 683 for ( my $i = 0; $i <= $#{$allrequires}; $i++ ) 684 { 685 my $onerequires = ${$allrequires}[$i]; 686 $onerequires =~ s/\s*$//; 687 installer::packagelist::resolve_packagevariables(\$onerequires, $variableshashref, 0); 688 if ( $installer::globals::debian ) { $onerequires =~ s/_/-/g; } # Debian allows no underline in package name 689 690 # Special handling for Solaris. In depend files, the names of the packages are required, not 691 # only the abbreviation. Therefore there is a special syntax for names in packagelist: 692 # solarisrequires = "SUNWcar (Name="Package name of SUNWcar"),SUNWkvm (Name="Package name of SUNWcar"), ... 693 # if ( $installer::globals::issolarispkgbuild ) 694 # { 695 # if ( $onerequires =~ /^\s*(.*?)\s+\(\s*Name\s*=\s*\"(.*?)\"\s*\)\s*$/ ) 696 # { 697 # $onerequires = $1; 698 # $packagename = $2; 699 # $installer::globals::dependfilenames{$onerequires} = $packagename; 700 # } 701 # } 702 703 $line = "%requires" . " " . $onerequires . "\n"; 704 push(@epmheader, $line); 705 } 706 } 707 } 708 709 return \@epmheader; 710} 711 712####################################### 713# Adding header to epm file 714####################################### 715 716sub adding_header_to_epm_file 717{ 718 my ($epmfileref, $epmheaderref) = @_; 719 720 for ( my $i = 0; $i <= $#{$epmheaderref}; $i++ ) 721 { 722 push( @{$epmfileref}, ${$epmheaderref}[$i] ); 723 } 724 725 push( @{$epmfileref}, "\n\n" ); 726} 727 728##################################################### 729# Replace one in shell scripts ( ${VARIABLENAME} ) 730##################################################### 731 732sub replace_variable_in_shellscripts 733{ 734 my ($scriptref, $variable, $searchstring) = @_; 735 736 for ( my $i = 0; $i <= $#{$scriptref}; $i++ ) 737 { 738 ${$scriptref}[$i] =~ s/\$\{$searchstring\}/$variable/g; 739 } 740} 741 742################################################### 743# Replace one in shell scripts ( %VARIABLENAME ) 744################################################### 745 746sub replace_percent_variable_in_shellscripts 747{ 748 my ($scriptref, $variable, $searchstring) = @_; 749 750 for ( my $i = 0; $i <= $#{$scriptref}; $i++ ) 751 { 752 ${$scriptref}[$i] =~ s/\%$searchstring/$variable/g; 753 } 754} 755 756################################################ 757# Replacing many variables in shell scripts 758################################################ 759 760sub replace_many_variables_in_shellscripts 761{ 762 my ($scriptref, $variableshashref) = @_; 763 764 my $key; 765 766 foreach $key (keys %{$variableshashref}) 767 { 768 my $value = $variableshashref->{$key}; 769 # $value = lc($value); # lowercase ! 770 # if ( $installer::globals::issolarisbuild) { $value =~ s/\.org/org/g; } # openofficeorg instead of openoffice.org 771 replace_variable_in_shellscripts($scriptref, $value, $key); 772 } 773} 774 775####################################### 776# Adding shell scripts to epm file 777####################################### 778 779sub adding_shellscripts_to_epm_file 780{ 781 my ($epmfileref, $shellscriptsfilename, $localrootpath, $allvariableshashref, $filesinpackage) = @_; 782 783 # $installer::globals::shellscriptsfilename 784 785 push( @{$epmfileref}, "\n\n" ); 786 787 my $shellscriptsfileref = installer::files::read_file($shellscriptsfilename); 788 789 replace_variable_in_shellscripts($shellscriptsfileref, $localrootpath, "rootpath"); 790 791 replace_many_variables_in_shellscripts($shellscriptsfileref, $allvariableshashref); 792 793 for ( my $i = 0; $i <= $#{$shellscriptsfileref}; $i++ ) 794 { 795 push( @{$epmfileref}, ${$shellscriptsfileref}[$i] ); 796 } 797 798 push( @{$epmfileref}, "\n" ); 799} 800 801################################################# 802# Determining the epm on the system 803################################################# 804 805sub find_epm_on_system 806{ 807 my ($includepatharrayref) = @_; 808 809 installer::logger::include_header_into_logfile("Check epm on system"); 810 811 my $epmname = "epm"; 812 813 # epm should be defined through the configure script but we need to 814 # check for it to be defined because of the Sun environment. 815 # Check the environment variable first and if it is not defined, 816 # or if it is but the location is not executable, search further. 817 # It has to be found in the solver or it has to be in the path 818 # (saved in $installer::globals::epm_in_path) or we get the specified 819 # one through the environment (i.e. when --with-epm=... is specified) 820 821 if ($ENV{'EPM'}) 822 { 823 if (($ENV{'EPM'} ne "") && (-x "$ENV{'EPM'}")) 824 { 825 $epmname = $ENV{'EPM'}; 826 } 827 elsif ( ($ENV{'EPM'} eq "no") || ($ENV{'EPM'} eq "internal") ) 828 { 829 $epmname = "epm"; 830 my $epmref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$epmname, $includepatharrayref, 0); 831 if ($$epmref eq "") { installer::exiter::exit_program("ERROR: Could not find program $epmname (EPM set to \"internal\" or \"no\")!", "find_epm_on_system"); } 832 $epmname = $$epmref; 833 } 834 else 835 { 836 installer::exiter::exit_program("Environment variable EPM set (\"$ENV{'EPM'}\"), but file does not exist or is not executable!", "find_epm_on_system"); 837 } 838 } 839 else 840 { 841 my $epmfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$epmname, $includepatharrayref, 0); 842 843 if (($$epmfileref eq "") && (!($installer::globals::epm_in_path))) { installer::exiter::exit_program("ERROR: Could not find program $epmname!", "find_epm_on_system"); } 844 if (($$epmfileref eq "") && ($installer::globals::epm_in_path)) { $epmname = $installer::globals::epm_path; } 845 if (!($$epmfileref eq "")) { $epmname = $$epmfileref; } 846 } 847 848 my $infoline = "Using epmfile: $epmname\n"; 849 push( @installer::globals::logfileinfo, $infoline); 850 851 return $epmname; 852} 853 854################################################# 855# Determining the epm patch state 856# saved in $installer::globals::is_special_epm 857################################################# 858 859sub set_patch_state 860{ 861 my ($epmexecutable) = @_; 862 863 my $infoline = ""; 864 865 my $systemcall = "$epmexecutable |"; 866 open (EPMPATCH, "$systemcall"); 867 868 while (<EPMPATCH>) 869 { 870 chop; 871 if ( $_ =~ /Patched for OpenOffice.org/ ) { $installer::globals::is_special_epm = 1; } 872 } 873 874 close (EPMPATCH); 875 876 if ( $installer::globals::is_special_epm ) 877 { 878 $infoline = "\nPatch state: This is a patched version of epm!\n\n"; 879 push( @installer::globals::logfileinfo, $infoline); 880 } 881 else 882 { 883 $infoline = "\nPatch state: This is an unpatched version of epm!\n\n"; 884 push( @installer::globals::logfileinfo, $infoline); 885 } 886 887 if ( ( $installer::globals::is_special_epm ) && (($installer::globals::islinuxrpmbuild) || ($installer::globals::issolarispkgbuild)) ) 888 { 889 # Special postprocess handling only for Linux RPM and Solaris packages 890 $installer::globals::postprocess_specialepm = 1; 891 $installer::globals::postprocess_standardepm = 0; 892 } 893 else 894 { 895 $installer::globals::postprocess_specialepm = 0; 896 $installer::globals::postprocess_standardepm = 1; 897 } 898} 899 900################################################# 901# LD_PRELOAD string for Debian packages 902################################################# 903 904sub get_ld_preload_string 905{ 906 my ($includepatharrayref) = @_; 907 908 my $getuidlibraryname = "getuid.so"; 909 910 my $getuidlibraryref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$getuidlibraryname, $includepatharrayref, 0); 911 if ($$getuidlibraryref eq "") { installer::exiter::exit_program("ERROR: Could not find $getuidlibraryname!", "get_ld_preload_string"); } 912 913 my $ldpreloadstring = "LD_PRELOAD=" . $$getuidlibraryref; 914 915 return $ldpreloadstring; 916} 917 918################################################# 919# Calling epm to create the installation sets 920################################################# 921 922sub call_epm 923{ 924 my ($epmname, $epmlistfilename, $packagename, $includepatharrayref) = @_; 925 926 installer::logger::include_header_into_logfile("epm call for $packagename"); 927 928 my $packageformat = $installer::globals::packageformat; 929 930 my $localpackagename = $packagename; 931 # Debian allows only lowercase letters in package name 932 if ( $installer::globals::debian ) { $localpackagename = lc($localpackagename); } 933 934 my $outdirstring = ""; 935 if ( $installer::globals::epmoutpath ne "" ) { $outdirstring = " --output-dir $installer::globals::epmoutpath"; } 936 937 # Debian package build needs a LD_PRELOAD for correct rights 938 939 my $ldpreloadstring = ""; 940 941 if ( $installer::globals::debian ) { $ldpreloadstring = get_ld_preload_string($includepatharrayref) . " "; } 942 943 my $extraflags = ""; 944 if ($ENV{'EPM_FLAGS'}) { $extraflags = $ENV{'EPM_FLAGS'}; } 945 946 my $systemcall = $ldpreloadstring . $epmname . " -f " . $packageformat . " " . $extraflags . " " . $localpackagename . " " . $epmlistfilename . $outdirstring . " -v " . " 2\>\&1 |"; 947 948 installer::logger::print_message( "... $systemcall ...\n" ); 949 950 my $maxepmcalls = 3; 951 952 for ( my $i = 1; $i <= $maxepmcalls; $i++ ) 953 { 954 my @epmoutput = (); 955 956 open (EPM, "$systemcall"); 957 while (<EPM>) {push(@epmoutput, $_); } 958 close (EPM); 959 960 my $returnvalue = $?; # $? contains the return value of the systemcall 961 962 my $infoline = "Systemcall (Try $i): $systemcall\n"; 963 push( @installer::globals::logfileinfo, $infoline); 964 965 for ( my $j = 0; $j <= $#epmoutput; $j++ ) 966 { 967 if ( $i < $maxepmcalls ) { $epmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; } 968 push( @installer::globals::logfileinfo, "$epmoutput[$j]"); 969 } 970 971 if ($returnvalue) 972 { 973 $infoline = "Try $i : Could not execute \"$systemcall\"!\n"; 974 push( @installer::globals::logfileinfo, $infoline); 975 if ( $i == $maxepmcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "call_epm"); } 976 } 977 else 978 { 979 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" ); 980 $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 981 push( @installer::globals::logfileinfo, $infoline); 982 last; 983 } 984 } 985} 986 987##################################################################### 988# Adding the new line for relocatables into pkginfo file (Solaris) 989# or spec file (Linux) created by epm 990##################################################################### 991 992sub add_one_line_into_file 993{ 994 my ($file, $insertline, $filename) = @_; 995 996 if ( $installer::globals::issolarispkgbuild ) 997 { 998 push(@{$file}, $insertline); # simply adding at the end of pkginfo file 999 } 1000 1001 if ( $installer::globals::islinuxrpmbuild ) 1002 { 1003 # Adding behind the line beginning with: Group: 1004 1005 my $inserted_line = 0; 1006 1007 for ( my $i = 0; $i <= $#{$file}; $i++ ) 1008 { 1009 if ( ${$file}[$i] =~ /^\s*Group\:\s*/ ) 1010 { 1011 splice(@{$file},$i+1,0,$insertline); 1012 $inserted_line = 1; 1013 last; 1014 } 1015 } 1016 1017 if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "add_one_line_into_file"); } 1018 } 1019 1020 $insertline =~ s/\s*$//; # removing line end for correct logging 1021 my $infoline = "Success: Added line $insertline into file $filename!\n"; 1022 push( @installer::globals::logfileinfo, $infoline); 1023} 1024 1025##################################################################### 1026# Setting the revision VERSION=1.9,REV=66 . 1027# Also adding the new line: "AutoReqProv: no" 1028##################################################################### 1029 1030sub set_revision_in_pkginfo 1031{ 1032 my ($file, $filename, $variables, $packagename) = @_; 1033 1034 my $revisionstring = "\,REV\=" . $installer::globals::packagerevision; 1035 1036 # Adding also a time string to the revision. Syntax: VERSION=8.0.0,REV=66.2005.01.24 1037 1038 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); 1039 1040 $mday = $mday; 1041 $mon = $mon + 1; 1042 $year = $year + 1900; 1043 1044 if ( $mday < 10 ) { $mday = "0" . $mday; } 1045 if ( $mon < 10 ) { $mon = "0" . $mon; } 1046 $datestring = $year . "." . $mon . "." . $mday; 1047 $revisionstring = $revisionstring . "." . $datestring; 1048 1049 for ( my $i = 0; $i <= $#{$file}; $i++ ) 1050 { 1051 if ( ${$file}[$i] =~ /^\s*(VERSION\=.*?)\s*$/ ) 1052 { 1053 my $oldstring = $1; 1054 my $newstring = $oldstring . $revisionstring; # also adding the date string 1055 ${$file}[$i] =~ s/$oldstring/$newstring/; 1056 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n"; 1057 push( @installer::globals::logfileinfo, $infoline); 1058 last; 1059 } 1060 } 1061 1062 # For Update and Patch reasons, this string can also be kept constant 1063 1064 my $pkgversion = "SOLSPARCPKGVERSION"; 1065 if ( $installer::globals::issolarisx86build ) { $pkgversion = "SOLIAPKGVERSION"; } 1066 1067 if (( $variables->{$pkgversion} ) && ( $variables->{$pkgversion} ne "" )) 1068 { 1069 if ( $variables->{$pkgversion} ne "FINALVERSION" ) 1070 { 1071 # In OOo 3.x timeframe, this string is no longer unique for all packages, because of the three layer. 1072 # In the string: "3.0.0,REV=9.2008.09.30" only the part "REV=9.2008.09.30" can be unique for all packages 1073 # and therefore be set as $pkgversion. 1074 # The first part "3.0.0" has to be derived from the 1075 1076 my $version = $installer::globals::packageversion; 1077 if ( $version =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ ) 1078 { 1079 my $major = $1; 1080 my $minor = $2; 1081 my $micro = $3; 1082 1083 my $finalmajor = $major; 1084 my $finalminor = $minor; 1085 my $finalmicro = 0; 1086 1087 # if (( $packagename =~ /-ure\s*$/ ) && ( $finalmajor == 1 )) { $finalminor = 4; } 1088 1089 $version = "$finalmajor.$finalminor.$finalmicro"; 1090 } 1091 1092 my $datestring = $variables->{$pkgversion}; 1093 1094 # Allowing some packages to have another date of creation. 1095 # They can be defined in product definition using a key like "SOLSPARCPKGVERSION_$packagename" 1096 1097 my $additionalkey = $pkgversion . "_" . $packagename; 1098 if (( $variables->{$additionalkey} ) && ( $variables->{$additionalkey} ne "" )) { $datestring = $variables->{$additionalkey}; } 1099 1100 my $versionstring = "$version,$datestring"; 1101 1102 for ( my $i = 0; $i <= $#{$file}; $i++ ) 1103 { 1104 if ( ${$file}[$i] =~ /^\s*(VERSION\=).*?\s*$/ ) 1105 { 1106 my $start = $1; 1107 my $newstring = $start . $versionstring . "\n"; # setting the complete new string 1108 my $oldstring = ${$file}[$i]; 1109 ${$file}[$i] = $newstring; 1110 $oldstring =~ s/\s*$//; 1111 $newstring =~ s/\s*$//; 1112 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n"; 1113 push( @installer::globals::logfileinfo, $infoline); 1114 last; 1115 } 1116 } 1117 } 1118 } 1119} 1120 1121######################################################## 1122# Setting Patch information for Respin versions 1123# into pkginfo file. This prevents Respin versions 1124# from patching. 1125######################################################## 1126 1127sub set_patchlist_in_pkginfo_for_respin 1128{ 1129 my ($changefile, $filename, $allvariables, $packagename) = @_; 1130 1131 my $patchlistname = "SOLSPARCPATCHLISTFORRESPIN"; 1132 if ( $installer::globals::issolarisx86build ) { $patchlistname = "SOLIAPATCHLISTFORRESPIN"; } 1133 1134 if ( $allvariables->{$patchlistname} ) 1135 { 1136 # patchlist separator is a blank 1137 my $allpatchesstring = $allvariables->{$patchlistname}; 1138 my @usedpatches = (); 1139 1140 # Analyzing the patchlist 1141 # Syntax: 120186-10 126411-01(+core-01) -> use 126411-01 only for core-01 1142 # Syntax: 120186-10 126411-01(-core-01) -> use 126411-01 for all packages except for core-01 1143 my $allpatches = installer::converter::convert_whitespace_stringlist_into_array(\$allpatchesstring); 1144 1145 for ( my $i = 0; $i <= $#{$allpatches}; $i++ ) 1146 { 1147 my $patchdefinition = ${$allpatches}[$i]; 1148 1149 my $patchid = ""; 1150 my $symbol = ""; 1151 my $constraint = ""; 1152 my $isusedpatch = 0; 1153 1154 if ( $patchdefinition =~ /^\s*(.+)\(([+-])(.+)\)\s*$/ ) 1155 { 1156 $patchid = $1; 1157 $symbol = $2; 1158 $constraint = $3; 1159 } 1160 elsif (( $patchdefinition =~ /\(/ ) || ( $patchdefinition =~ /\)/ )) # small syntax check 1161 { 1162 # if there is a bracket in the $patchdefinition, but it does not 1163 # match the if-condition, this is an erroneous definition. 1164 installer::exiter::exit_program("ERROR: Unknown patch string: $patchdefinition", "set_patchlist_in_pkginfo_for_respin"); 1165 } 1166 else 1167 { 1168 $patchid = $patchdefinition; 1169 $isusedpatch = 1; # patches without constraint are always included 1170 } 1171 1172 if ( $symbol ne "" ) 1173 { 1174 if ( $symbol eq "+" ) 1175 { 1176 if ( $packagename =~ /^.*\Q$constraint\E\s*$/ ) { $isusedpatch = 1; } 1177 } 1178 1179 if ( $symbol eq "-" ) 1180 { 1181 if ( ! ( $packagename =~ /^.*\Q$constraint\E\s*$/ )) { $isusedpatch = 1; } 1182 } 1183 } 1184 1185 if ( $isusedpatch ) { push(@usedpatches, $patchid); } 1186 } 1187 1188 if ( $#usedpatches > -1 ) 1189 { 1190 my $patchstring = installer::converter::convert_array_to_space_separated_string(\@usedpatches); 1191 1192 my $newline = "PATCHLIST=" . $patchstring . "\n"; 1193 add_one_line_into_file($changefile, $newline, $filename); 1194 1195 # Adding patch info for each used patch in the patchlist 1196 1197 for ( my $i = 0; $i <= $#usedpatches; $i++ ) 1198 { 1199 my $patchid = $usedpatches[$i]; 1200 my $key = "PATCH_INFO_" . $patchid; 1201 $key =~ s/\s*$//; 1202 1203 if ( ! $allvariables->{$key} ) { installer::exiter::exit_program("ERROR: No Patch info available in zip list file for $key", "set_patchlist_in_pkginfo"); } 1204 my $value = set_timestamp_in_patchinfo($allvariables->{$key}); 1205 $newline = $key . "=" . $value . "\n"; 1206 1207 add_one_line_into_file($changefile, $newline, $filename); 1208 } 1209 } 1210 } 1211} 1212 1213######################################################## 1214# Solaris requires, that the time of patch installation 1215# must not be empty. 1216# Format: Mon Mar 24 11:20:56 PDT 2008 1217# Log file: Tue Apr 29 23:26:19 2008 (04:31 min.) 1218# Replace string: ${TIMESTAMP} 1219######################################################## 1220 1221sub set_timestamp_in_patchinfo 1222{ 1223 my ($value) = @_; 1224 1225 my $currenttime = localtime(); 1226 1227 if ( $currenttime =~ /^\s*(.+?)(\d\d\d\d)\s*$/ ) 1228 { 1229 my $start = $1; 1230 my $year = $2; 1231 $currenttime = $start . "CET " . $year; 1232 } 1233 1234 $value =~ s/\$\{TIMESTAMP\}/$currenttime/; 1235 1236 return $value; 1237} 1238 1239######################################################## 1240# Setting MAXINST=1000 into the pkginfo file. 1241######################################################## 1242 1243sub set_maxinst_in_pkginfo 1244{ 1245 my ($changefile, $filename) = @_; 1246 1247 my $newline = "MAXINST\=1000\n"; 1248 1249 add_one_line_into_file($changefile, $newline, $filename); 1250} 1251 1252############################################################# 1253# Setting several Solaris variables into the pkginfo file. 1254############################################################# 1255 1256sub set_solaris_parameter_in_pkginfo 1257{ 1258 my ($changefile, $filename, $allvariables) = @_; 1259 1260 my $newline = ""; 1261 1262 # SUNW_PRODNAME 1263 # SUNW_PRODVERS 1264 # SUNW_PKGVERS 1265 # Not: SUNW_PKGTYPE 1266 # HOTLINE 1267 # EMAIL 1268 1269 my $productname = $allvariables->{'PRODUCTNAME'}; 1270 $newline = "SUNW_PRODNAME=$productname\n"; 1271 add_one_line_into_file($changefile, $newline, $filename); 1272 1273 my $productversion = ""; 1274 if ( $allvariables->{'PRODUCTVERSION'} ) 1275 { 1276 $productversion = $allvariables->{'PRODUCTVERSION'}; 1277 if ( $allvariables->{'PRODUCTEXTENSION'} ) { $productversion = $productversion . "/" . $allvariables->{'PRODUCTEXTENSION'}; } 1278 } 1279 $newline = "SUNW_PRODVERS=$productversion\n"; 1280 add_one_line_into_file($changefile, $newline, $filename); 1281 1282 $newline = "SUNW_PKGVERS=1\.0\n"; 1283 add_one_line_into_file($changefile, $newline, $filename); 1284 1285 if ( $allvariables->{'SUNW_PKGTYPE'} ) 1286 { 1287 $newline = "SUNW_PKGTYPE=$allvariables->{'SUNW_PKGTYPE'}\n"; 1288 add_one_line_into_file($changefile, $newline, $filename); 1289 } 1290 else 1291 { 1292 $newline = "SUNW_PKGTYPE=\n"; 1293 add_one_line_into_file($changefile, $newline, $filename); 1294 } 1295 1296 $newline = "HOTLINE=Please contact your local service provider\n"; 1297 add_one_line_into_file($changefile, $newline, $filename); 1298 1299 $newline = "EMAIL=\n"; 1300 add_one_line_into_file($changefile, $newline, $filename); 1301 1302} 1303 1304##################################################################### 1305# epm uses as archtecture for Solaris x86 "i86pc". This has to be 1306# changed to "i386". 1307##################################################################### 1308 1309sub fix_architecture_setting 1310{ 1311 my ($changefile) = @_; 1312 1313 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1314 { 1315 if ( ${$changefile}[$i] =~ /^\s*ARCH=i86pc\s*$/ ) 1316 { 1317 ${$changefile}[$i] =~ s/i86pc/i386/; 1318 last; 1319 } 1320 1321 } 1322} 1323 1324##################################################################### 1325# Adding a new line for topdir into specfile, removing old 1326# topdir if set. 1327##################################################################### 1328 1329sub set_topdir_in_specfile 1330{ 1331 my ($changefile, $filename, $newepmdir) = @_; 1332 1333 # $newepmdir =~ s/^\s*\.//; # removing leading "." 1334 $newepmdir = cwd() . $installer::globals::separator . $newepmdir; # only absolute path allowed 1335 1336 # removing "%define _topdir", if existing 1337 1338 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1339 { 1340 if ( ${$changefile}[$i] =~ /^\s*\%define _topdir\s+/ ) 1341 { 1342 my $removeline = ${$changefile}[$i]; 1343 $removeline =~ s/\s*$//; 1344 splice(@{$changefile},$i,1); 1345 my $infoline = "Info: Removed line \"$removeline\" from file $filename!\n"; 1346 push( @installer::globals::logfileinfo, $infoline); 1347 last; 1348 } 1349 } 1350 1351 # Adding "topdir" behind the line beginning with: Group: 1352 1353 my $inserted_line = 0; 1354 1355 my $topdirline = "\%define _topdir $newepmdir\n"; 1356 1357 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1358 { 1359 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ ) 1360 { 1361 splice(@{$changefile},$i+1,0,$topdirline); 1362 $inserted_line = 1; 1363 $topdirline =~ s/\s*$//; 1364 my $infoline = "Success: Added line $topdirline into file $filename!\n"; 1365 push( @installer::globals::logfileinfo, $infoline); 1366 } 1367 } 1368 1369 if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "set_topdir_in_specfile"); } 1370 1371} 1372 1373##################################################################### 1374# Setting the packager in the spec file 1375# Syntax: Packager: abc@def 1376##################################################################### 1377 1378sub set_packager_in_specfile 1379{ 1380 my ($changefile) = @_; 1381 1382 my $packager = $installer::globals::longmanufacturer; 1383 1384 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1385 { 1386 if ( ${$changefile}[$i] =~ /^\s*Packager\s*:\s*(.+?)\s*$/ ) 1387 { 1388 my $oldstring = $1; 1389 ${$changefile}[$i] =~ s/\Q$oldstring\E/$packager/; 1390 my $infoline = "Info: Changed Packager in spec file from $oldstring to $packager!\n"; 1391 push( @installer::globals::logfileinfo, $infoline); 1392 last; 1393 } 1394 } 1395} 1396 1397##################################################################### 1398# Setting the requirements in the spec file (i81494) 1399# Syntax: PreReq: "requirements" (only for shared extensions) 1400##################################################################### 1401 1402sub set_prereq_in_specfile 1403{ 1404 my ($changefile) = @_; 1405 1406 my $prereq = "PreReq:"; 1407 1408 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1409 { 1410 if ( ${$changefile}[$i] =~ /^\s*Requires:\s*(.+?)\s*$/ ) 1411 { 1412 my $oldstring = ${$changefile}[$i]; 1413 ${$changefile}[$i] =~ s/Requires:/$prereq/; 1414 my $infoline = "Info: Changed requirements in spec file from $oldstring to ${$changefile}[$i]!\n"; 1415 push( @installer::globals::logfileinfo, $infoline); 1416 } 1417 } 1418} 1419 1420##################################################################### 1421# Setting the Auto[Req]Prov line and __find_requires 1422##################################################################### 1423 1424sub set_autoprovreq_in_specfile 1425{ 1426 my ($changefile, $findrequires, $bindir) = @_; 1427 1428 my $autoreqprovline; 1429 1430 if ( $findrequires ) 1431 { 1432 $autoreqprovline = "AutoProv\: no\n%define __find_requires $bindir/$findrequires\n"; 1433 } 1434 else 1435 { 1436 $autoreqprovline = "AutoReqProv\: no\n"; 1437 } 1438 1439 $autoreqprovline .= "%define _binary_filedigest_algorithm 1\n%define _binary_payload w9.gzdio\n"; 1440 1441 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1442 { 1443 # Adding "autoreqprov" behind the line beginning with: Group: 1444 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ ) 1445 { 1446 splice(@{$changefile},$i+1,0,$autoreqprovline); 1447 $autoreqprovline =~ s/\s*$//; 1448 $infoline = "Success: Added line $autoreqprovline into spec file!\n"; 1449 push( @installer::globals::logfileinfo, $infoline); 1450 1451 last; 1452 } 1453 } 1454} 1455 1456##################################################################### 1457# Replacing Copyright with License in the spec file 1458# Syntax: License: LGPL, SISSL 1459##################################################################### 1460 1461sub set_license_in_specfile 1462{ 1463 my ($changefile, $variableshashref) = @_; 1464 1465 my $license = $variableshashref->{'LICENSENAME'}; 1466 1467 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1468 { 1469 if ( ${$changefile}[$i] =~ /^\s*Copyright\s*:\s*(.+?)\s*$/ ) 1470 { 1471 ${$changefile}[$i] = "License: $license\n"; 1472 my $infoline = "Info: Replaced Copyright with License: $license !\n"; 1473 push( @installer::globals::logfileinfo, $infoline); 1474 last; 1475 } 1476 } 1477} 1478 1479######################################################### 1480# Building relocatable Solaris packages means: 1481# 1. Add "BASEDIR=/opt" into pkginfo 1482# 2. Remove "/opt/" from all objects in prototype file 1483# For step2 this function exists 1484# Sample: d none /opt/openofficeorg20/help 0755 root other 1485# -> d none openofficeorg20/help 0755 root other 1486######################################################### 1487 1488sub make_prototypefile_relocatable 1489{ 1490 my ($prototypefile, $relocatablepath) = @_; 1491 1492 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ ) 1493 { 1494 if ( ${$prototypefile}[$i] =~ /^\s*\w\s+\w+\s+\/\w+/ ) # this is an object line 1495 { 1496 ${$prototypefile}[$i] =~ s/$relocatablepath//; # Important: $relocatablepath has a "/" at the end. Example "/opt/" 1497 } 1498 } 1499 1500 # If the $relocatablepath is "/opt/openoffice20/" the line "d none /opt/openoffice20" was not changed. 1501 # This line has to be removed now 1502 1503 if ( $relocatablepath ne "/" ) { $relocatablepath =~ s/\/\s*$//; } # removing the ending slash 1504 1505 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ ) 1506 { 1507 if ( ${$prototypefile}[$i] =~ /^\s*d\s+\w+\s+\Q$relocatablepath\E/ ) 1508 { 1509 my $line = ${$prototypefile}[$i]; 1510 splice(@{$prototypefile},$i,1); # removing the line 1511 $line =~ s/\s*$//; 1512 my $infoline = "Info: Removed line \"$line\" from prototype file!\n"; 1513 push( @installer::globals::logfileinfo, $infoline); 1514 last; 1515 } 1516 } 1517 1518 # Making "\$" to "$" in prototype file. "\$" was created by epm. 1519 1520 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ ) 1521 { 1522 if ( ${$prototypefile}[$i] =~ /\\\$/ ) 1523 { 1524 ${$prototypefile}[$i] =~ s/\\\$/\$/g; 1525 my $infoline2 = "Info: Changed line in prototype file: ${$prototypefile}[$i] !\n"; 1526 push( @installer::globals::logfileinfo, $infoline2); 1527 } 1528 } 1529} 1530 1531 1532######################################################################### 1533# In scp the flag VOLATEFILE can be used. This shall lead to style "v" 1534# in Solaris prototype file. This is not supported by epm and has 1535# therefore to be included in prototypefile, not in epm list file. 1536######################################################################### 1537 1538sub set_volatilefile_into_prototypefile 1539{ 1540 my ($prototypefile, $filesref) = @_; 1541 1542 for ( my $i = 0; $i <= $#{$filesref}; $i++ ) 1543 { 1544 my $onefile = ${$filesref}[$i]; 1545 1546 my $styles = ""; 1547 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; } 1548 1549 if ( $styles =~ /\bVOLATILEFILE\b/ ) 1550 { 1551 my $sourcepath = $onefile->{'sourcepath'}; 1552 1553 for ( my $j = 0; $j <= $#{$prototypefile}; $j++ ) 1554 { 1555 if (( ${$prototypefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$prototypefile}[$j] =~ /\=\Q$sourcepath\E\s+/ )) 1556 { 1557 my $oldline = ${$prototypefile}[$j]; 1558 ${$prototypefile}[$j] =~ s/^\s*f/v/; 1559 my $newline = ${$prototypefile}[$j]; 1560 $oldline =~ s/\s*$//; 1561 $newline =~ s/\s*$//; 1562 my $infoline = "Volatile file: Changing content from \"$oldline\" to \"$newline\" .\n"; 1563 push(@installer::globals::logfileinfo, $infoline); 1564 last; 1565 } 1566 } 1567 } 1568 } 1569} 1570 1571######################################################################### 1572# Replacing the variables in the Solaris patch shell scripts. 1573# Taking care, that multiple slashes are not always removed. 1574######################################################################### 1575 1576sub replace_variables_in_shellscripts_for_patch 1577{ 1578 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_; 1579 1580 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 1581 { 1582 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ ) 1583 { 1584 my $oldline = ${$scriptfile}[$i]; 1585 if (( $oldstring eq "PRODUCTDIRECTORYNAME" ) && ( $newstring eq "" )) { $oldstring = $oldstring . "/"; } 1586 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g; 1587 my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n"; 1588 push(@installer::globals::logfileinfo, $infoline); 1589 } 1590 } 1591} 1592 1593######################################################################### 1594# Replacing the variables in the shell scripts or in the epm list file 1595# Linux: spec file 1596# Solaris: preinstall, postinstall, preremove, postremove 1597# If epm is used in the original version (not relocatable) 1598# the variables have to be exchanged in the list file, 1599# created for epm. 1600######################################################################### 1601 1602sub replace_variables_in_shellscripts 1603{ 1604 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_; 1605 1606 my $debug = 0; 1607 if ( $oldstring eq "PRODUCTDIRECTORYNAME" ) { $debug = 1; } 1608 1609 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 1610 { 1611 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ ) 1612 { 1613 my $oldline = ${$scriptfile}[$i]; 1614 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g; 1615 ${$scriptfile}[$i] =~ s/\/\//\//g; # replacing "//" by "/" , if path $newstring is empty! 1616 my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n"; 1617 push(@installer::globals::logfileinfo, $infoline); 1618 if ( $debug ) 1619 { 1620 $infoline = "Old Line: $oldline"; 1621 push(@installer::globals::logfileinfo, $infoline); 1622 $infoline = "New Line: ${$scriptfile}[$i]"; 1623 push(@installer::globals::logfileinfo, $infoline); 1624 } 1625 } 1626 } 1627} 1628 1629############################################################ 1630# Determinig the directory created by epm, in which the 1631# RPMS or Solaris packages are created. 1632############################################################ 1633 1634sub determine_installdir_ooo 1635{ 1636 # A simple "ls" command returns the directory name 1637 1638 my $dirname = ""; 1639 1640 my $systemcall = "ls |"; 1641 open (LS, "$systemcall"); 1642 $dirname = <LS>; 1643 close (LS); 1644 1645 $dirname =~ s/\s*$//; 1646 1647 my $infoline = "Info: Directory created by epm: $dirname\n"; 1648 push(@installer::globals::logfileinfo, $infoline); 1649 1650 return $dirname; 1651} 1652 1653############################################################ 1654# Setting the tab content into the file container 1655############################################################ 1656 1657sub set_tab_into_datafile 1658{ 1659 my ($changefile, $filesref) = @_; 1660 1661 my @newclasses = (); 1662 my $newclassesstring = ""; 1663 1664 if ( $installer::globals::issolarispkgbuild ) 1665 { 1666 for ( my $i = 0; $i <= $#{$filesref}; $i++ ) 1667 { 1668 my $onefile = ${$filesref}[$i]; 1669 1670 if ( $onefile->{'SolarisClass'} ) 1671 { 1672 my $sourcepath = $onefile->{'sourcepath'}; 1673 1674 for ( my $j = 0; $j <= $#{$changefile}; $j++ ) 1675 { 1676 if (( ${$changefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$changefile}[$j] =~ /\=\Q$sourcepath\E\s+/ )) 1677 { 1678 my $oldline = ${$changefile}[$j]; 1679 ${$changefile}[$j] =~ s/f\s+none/e $onefile->{'SolarisClass'}/; 1680 my $newline = ${$changefile}[$j]; 1681 $oldline =~ s/\s*$//; 1682 $newline =~ s/\s*$//; 1683 1684 my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n"; 1685 push(@installer::globals::logfileinfo, $infoline); 1686 1687 # collecting all new classes 1688 if (! installer::existence::exists_in_array($onefile->{'SolarisClass'}, \@newclasses)) 1689 { 1690 push(@newclasses, $onefile->{'SolarisClass'}); 1691 } 1692 1693 last; 1694 } 1695 } 1696 } 1697 } 1698 1699 $newclassesstring = installer::converter::convert_array_to_space_separated_string(\@newclasses); 1700 } 1701 1702 if ( $installer::globals::islinuxrpmbuild ) 1703 { 1704 for ( my $i = 0; $i <= $#{$filesref}; $i++ ) 1705 { 1706 my $onefile = ${$filesref}[$i]; 1707 1708 if ( $onefile->{'SpecFileContent'} ) 1709 { 1710 my $destination = $onefile->{'destination'}; 1711 1712 for ( my $j = 0; $j <= $#{$changefile}; $j++ ) 1713 { 1714 if ( ${$changefile}[$j] =~ /^\s*(\%attr\(.*\))\s+(\".*?\Q$destination\E\"\s*)$/ ) 1715 { 1716 my $begin = $1; 1717 my $end = $2; 1718 1719 my $oldline = ${$changefile}[$j]; 1720 ${$changefile}[$j] = $begin . " " . $onefile->{'SpecFileContent'} . " " . $end; 1721 my $newline = ${$changefile}[$j]; 1722 1723 $oldline =~ s/\s*$//; 1724 $newline =~ s/\s*$//; 1725 1726 my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n"; 1727 push(@installer::globals::logfileinfo, $infoline); 1728 1729 last; 1730 } 1731 } 1732 } 1733 } 1734 } 1735 1736 return $newclassesstring; 1737} 1738 1739############################################################ 1740# Including additional classes into the pkginfo file 1741############################################################ 1742 1743sub include_classes_into_pkginfo 1744{ 1745 my ($changefile, $classesstring) = @_; 1746 1747 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1748 { 1749 if ( ${$changefile}[$i] =~ /^\s*CLASSES\=none/ ) 1750 { 1751 ${$changefile}[$i] =~ s/\s*$//; 1752 my $oldline = ${$changefile}[$i]; 1753 ${$changefile}[$i] = ${$changefile}[$i] . " " . $classesstring . "\n"; 1754 my $newline = ${$changefile}[$i]; 1755 $newline =~ s/\s*$//; 1756 1757 my $infoline = "pkginfo file: Changing content from \"$oldline\" to \"$newline\" .\n"; 1758 push(@installer::globals::logfileinfo, $infoline); 1759 } 1760 } 1761} 1762 1763########################################################################################## 1764# Checking, if an extension is included into the package (Linux). 1765# All extension files have to be installed into directory 1766# share/extension/install 1767# %attr(0444,root,root) "/opt/staroffice8/share/extension/install/SunSearchToolbar.oxt" 1768########################################################################################## 1769 1770sub is_extension_package 1771{ 1772 my ($specfile) = @_; 1773 1774 my $is_extension_package = 0; 1775 1776 for ( my $i = 0; $i <= $#{$specfile}; $i++ ) 1777 { 1778 my $line = ${$specfile}[$i]; 1779 if ( $line =~ /share\/extension\/install\/.*?\.oxt\"\s*$/ ) 1780 { 1781 $is_extension_package = 1; 1782 last; 1783 } 1784 } 1785 1786 return $is_extension_package; 1787} 1788 1789###################################################################### 1790# Checking, if an extension is included into the package (Solaris). 1791# All extension files have to be installed into directory 1792# share/extension/install 1793###################################################################### 1794 1795sub contains_extension_dir 1796{ 1797 my ($prototypefile) = @_; 1798 1799 my $contains_extension_dir = 0; 1800 1801 # d none opt/openoffice.org3/share/extensions/ 1802 1803 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ ) 1804 { 1805 my $line = ${$prototypefile}[$i]; 1806 if ( $line =~ /^\s*d\s+none\s.*\/share\/extensions\// ) 1807 { 1808 $contains_extension_dir = 1; 1809 last; 1810 } 1811 } 1812 1813 return $contains_extension_dir; 1814} 1815 1816############################################################ 1817# A Solaris patch contains 7 specific scripts 1818############################################################ 1819 1820sub add_scripts_into_prototypefile 1821{ 1822 my ($prototypefile, $prototypefilename, $languagestringref, $staticpath) = @_; 1823 1824 # The files are stored in the directory $installer::globals::patchincludepath 1825 # The file names are available via @installer::globals::solarispatchscripts 1826 1827 my $path = $installer::globals::patchincludepath; 1828 $path =~ s/\/\s*$//; 1829 $path = $path . $installer::globals::separator; 1830 1831 my @newlines = (); 1832 my $is_extension_package = contains_extension_dir($prototypefile); 1833 1834 if ( $is_extension_package ) 1835 { 1836 for ( my $i = 0; $i <= $#installer::globals::solarispatchscriptsforextensions; $i++ ) 1837 { 1838 my $sourcefilename = $path . $installer::globals::solarispatchscriptsforextensions[$i]; 1839 my $destfile = $installer::globals::solarispatchscriptsforextensions[$i]; 1840 1841 # If the sourcepath has "_extension" in its name, this has to be removed 1842 $destfile =~ s/_extensions\s*$//; # hard coded renaming of script name 1843 1844 # Creating unique directory name with $prototypefilename 1845 my $extensiondir = installer::systemactions::create_directories("extensionscripts", $languagestringref); 1846 1847 if ( $prototypefilename =~ /\/(\S*?)\s*$/ ) { $prototypefilename = $1; } 1848 $prototypefilename =~ s/\./_/g; 1849 my $destdir = $extensiondir . $installer::globals::separator . $prototypefilename; 1850 if ( ! -d $destdir ) { installer::systemactions::create_directory($destdir); } 1851 my $destpath = $destdir . $installer::globals::separator . $destfile; 1852 if ( -f $destpath ) { unlink($destpath); } 1853 1854 # Reading file 1855 my $scriptfile = installer::files::read_file($sourcefilename); 1856 1857 # Replacing variables 1858 my $oldstring = "PRODUCTDIRECTORYNAME"; 1859 replace_variables_in_shellscripts_for_patch($scriptfile, $destpath, $oldstring, $staticpath); 1860 1861 # Saving file 1862 installer::files::save_file($destpath, $scriptfile); 1863 1864 # Writing file destination into prototype file 1865 my $line = "i $destfile=" . $destpath . "\n"; 1866 push(@newlines, $line); 1867 } 1868 } 1869 else 1870 { 1871 for ( my $i = 0; $i <= $#installer::globals::solarispatchscripts; $i++ ) 1872 { 1873 my $line = "i $installer::globals::solarispatchscripts[$i]=" . $path . $installer::globals::solarispatchscripts[$i] . "\n"; 1874 push(@newlines, $line); 1875 } 1876 } 1877 1878 # Including the new lines after the last line starting with "i" 1879 1880 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ ) 1881 { 1882 if ( ${$prototypefile}[$i] =~ /^\s*i\s+copyright/ ) 1883 { 1884 splice(@{$prototypefile}, $i, 1); # ignoring old copyright text, using patch standard 1885 next; 1886 } 1887 if ( ${$prototypefile}[$i] =~ /^\s*i\s+/ ) { next; } 1888 splice(@{$prototypefile}, $i, 0, @newlines); 1889 last; 1890 } 1891} 1892 1893############################################################ 1894# Adding patch infos in pkginfo file 1895############################################################ 1896 1897sub include_patchinfos_into_pkginfo 1898{ 1899 my ( $changefile, $filename, $variableshashref ) = @_; 1900 1901 # SUNW_PATCHID=101998-10 1902 # SUNW_OBSOLETES=114999-01 113999-01 1903 # SUNW_PKGTYPE=usr 1904 # SUNW_PKGVERS=1.0 1905 # SUNW_REQUIRES=126411-01 1906 1907 my $patchidname = "SOLSPARCPATCHID"; 1908 if ( $installer::globals::issolarisx86build ) { $patchidname = "SOLIAPATCHID"; } 1909 1910 if ( ! $variableshashref->{$patchidname} ) { installer::exiter::exit_program("ERROR: Variable $patchidname not defined in zip list file!", "include_patchinfos_into_pkginfo"); } 1911 1912 my $newline = "SUNW_PATCHID=" . $variableshashref->{$patchidname} . "\n"; 1913 add_one_line_into_file($changefile, $newline, $filename); 1914 1915 my $patchobsoletesname = "SOLSPARCPATCHOBSOLETES"; 1916 if ( $installer::globals::issolarisx86build ) { $patchobsoletesname = "SOLIAPATCHOBSOLETES"; } 1917 1918 my $obsoletes = ""; 1919 if ( $variableshashref->{$patchobsoletesname} ) { $obsoletes = $variableshashref->{$patchobsoletesname}; } 1920 $newline = "SUNW_OBSOLETES=" . $obsoletes . "\n"; 1921 add_one_line_into_file($changefile, $newline, $filename); 1922 1923 my $patchrequiresname = "SOLSPARCPATCHREQUIRES"; 1924 if ( $installer::globals::issolarisx86build ) { $patchrequiresname = "SOLIAPATCHREQUIRES"; } 1925 1926 if ( $variableshashref->{$patchrequiresname} ) 1927 { 1928 my $requires = $variableshashref->{$patchrequiresname}; 1929 $newline = "SUNW_REQUIRES=" . $requires . "\n"; 1930 add_one_line_into_file($changefile, $newline, $filename); 1931 } 1932 $newline = "SUNW_PATCH_PROPERTIES=\n"; 1933 add_one_line_into_file($changefile, $newline, $filename); 1934 # $newline = "SUNW_PKGTYPE=usr\n"; 1935 # add_one_line_into_file($changefile, $newline, $filename); 1936 1937 # $newline = "SUNW_PKGVERS=1.0\n"; 1938 # add_one_line_into_file($changefile, $newline, $filename); 1939} 1940 1941############################################################ 1942# Setting the correct Solaris locales 1943############################################################ 1944 1945sub get_solaris_language_for_langpack 1946{ 1947 my ( $onelanguage ) = @_; 1948 1949 my $sollanguage = $onelanguage; 1950 $sollanguage =~ s/\-/\_/; 1951 1952 if ( $sollanguage eq "de" ) { $sollanguage = "de"; } 1953 elsif ( $sollanguage eq "en_US" ) { $sollanguage = "en_AU,en_CA,en_GB,en_IE,en_MT,en_NZ,en_US,en_US.UTF-8"; } 1954 elsif ( $sollanguage eq "es" ) { $sollanguage = "es"; } 1955 elsif ( $sollanguage eq "fr" ) { $sollanguage = "fr"; } 1956 elsif ( $sollanguage eq "hu" ) { $sollanguage = "hu_HU"; } 1957 elsif ( $sollanguage eq "it" ) { $sollanguage = "it"; } 1958 elsif ( $sollanguage eq "nl" ) { $sollanguage = "nl_BE,nl_NL"; } 1959 elsif ( $sollanguage eq "pl" ) { $sollanguage = "pl_PL"; } 1960 elsif ( $sollanguage eq "sv" ) { $sollanguage = "sv"; } 1961 elsif ( $sollanguage eq "pt" ) { $sollanguage = "pt_PT"; } 1962 elsif ( $sollanguage eq "pt_BR" ) { $sollanguage = "pt_BR"; } 1963 elsif ( $sollanguage eq "ru" ) { $sollanguage = "ru_RU"; } 1964 elsif ( $sollanguage eq "ja" ) { $sollanguage = "ja,ja_JP,ja_JP.PCK,ja_JP.UTF-8"; } 1965 elsif ( $sollanguage eq "ko" ) { $sollanguage = "ko,ko.UTF-8"; } 1966 elsif ( $sollanguage eq "zh_CN" ) { $sollanguage = "zh,zh.GBK,zh_CN.GB18030,zh.UTF-8"; } 1967 elsif ( $sollanguage eq "zh_TW" ) { $sollanguage = "zh_TW,zh_TW.BIG5,zh_TW.UTF-8,zh_HK.BIG5HK,zh_HK.UTF-8"; } 1968 1969 return $sollanguage; 1970} 1971 1972############################################################ 1973# Adding language infos in pkginfo file 1974############################################################ 1975 1976sub include_languageinfos_into_pkginfo 1977{ 1978 my ( $changefile, $filename, $languagestringref, $onepackage, $variableshashref ) = @_; 1979 1980 # SUNWPKG_LIST=core01 1981 # SUNW_LOC=de 1982 1983 my $locallang = $onepackage->{'language'}; 1984 my $solarislanguage = get_solaris_language_for_langpack($locallang); 1985 1986 my $newline = "SUNW_LOC=" . $solarislanguage . "\n"; 1987 add_one_line_into_file($changefile, $newline, $filename); 1988 1989 # SUNW_PKGLIST is required, if SUNW_LOC is defined. 1990 if ( $onepackage->{'pkg_list_entry'} ) 1991 { 1992 my $packagelistentry = $onepackage->{'pkg_list_entry'}; 1993 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1); 1994 $newline = "SUNW_PKGLIST=" . $packagelistentry . "\n"; 1995 add_one_line_into_file($changefile, $newline, $filename); 1996 } 1997 else 1998 { 1999 # Using default package ooobasis30-core01. 2000 my $packagelistentry = "%BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core01"; 2001 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1); 2002 $newline = "SUNW_PKGLIST=" . $packagelistentry . "\n"; 2003 add_one_line_into_file($changefile, $newline, $filename); 2004 } 2005} 2006 2007############################################################ 2008# Collecting all files included in patch in 2009# @installer::globals::patchfilecollector 2010############################################################ 2011 2012sub collect_patch_files 2013{ 2014 my ($file, $packagename, $prefix) = @_; 2015 2016 # $file is the spec file or the prototypefile 2017 2018 $prefix = $prefix . "/"; 2019 my $packagenamestring = "Package " . $packagename . " \:\n"; 2020 push(@installer::globals::patchfilecollector, $packagenamestring); 2021 2022 for ( my $i = 0; $i <= $#{$file}; $i++ ) 2023 { 2024 my $line = ${$file}[$i]; 2025 2026 if ( $installer::globals::islinuxrpmbuild ) 2027 { 2028 # %attr(0444,root,root) "/opt/openofficeorg20/program/about.bmp" 2029 2030 if ( $line =~ /^\s*\%attr\(.*\)\s*\"(.*?)\"\s*$/ ) 2031 { 2032 my $filename = $1 . "\n"; 2033 $filename =~ s/^\s*\Q$prefix\E//; 2034 push(@installer::globals::patchfilecollector, $filename); 2035 } 2036 } 2037 2038 if ( $installer::globals::issolarispkgbuild ) 2039 { 2040 # f none program/msomrl.rdb=/ab/SRC680/unxsols4.pro/bin/msomrl.rdb 0444 root bin 2041 2042 if ( $line =~ /^\s*f\s+\w+\s+(.*?)\=/ ) 2043 { 2044 my $filename = $1 . "\n"; 2045 push(@installer::globals::patchfilecollector, $filename); 2046 } 2047 } 2048 } 2049 2050 push(@installer::globals::patchfilecollector, "\n"); 2051 2052} 2053 2054############################################################ 2055# Including package names into the depend files. 2056# The package names have to be included into 2057# packagelist. They are already saved in 2058# %installer::globals::dependfilenames. 2059############################################################ 2060 2061sub put_packagenames_into_dependfile 2062{ 2063 my ( $file ) = @_; 2064 2065 for ( my $i = 0; $i <= $#{$file}; $i++ ) 2066 { 2067 my $line = ${$file}[$i]; 2068 if ( $line =~ /^\s*\w\s+(.*?)\s*$/ ) 2069 { 2070 my $abbreviation = $1; 2071 2072 if ( $abbreviation =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package abbreviation \"$abbreviation\"!", "read_packagemap"); } 2073 2074 if ( exists($installer::globals::dependfilenames{$abbreviation}) ) 2075 { 2076 my $packagename = $installer::globals::dependfilenames{$abbreviation}; 2077 if ( $packagename =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package name \"$packagename\"!", "read_packagemap"); } 2078 2079 $line =~ s/\s*$//; 2080 ${$file}[$i] = $line . "\t" . $packagename . "\n"; 2081 } 2082 else 2083 { 2084 installer::exiter::exit_program("ERROR: Missing packagename for Solaris package \"$abbreviation\"!", "put_packagenames_into_dependfile"); 2085 } 2086 } 2087 } 2088} 2089 2090############################################################ 2091# Including the relocatable directory into 2092# spec file and pkginfo file 2093# Linux: set topdir in specfile 2094# Solaris: remove $relocatablepath (/opt/) 2095# for all objects in prototype file 2096# and changing "topdir" for Linux 2097############################################################ 2098 2099sub prepare_packages 2100{ 2101 my ($loggingdir, $packagename, $staticpath, $relocatablepath, $onepackage, $variableshashref, $filesref, $languagestringref) = @_; 2102 2103 my $filename = ""; 2104 my $newline = ""; 2105 my $newepmdir = $installer::globals::epmoutpath . $installer::globals::separator; 2106 2107 my $localrelocatablepath = $relocatablepath; 2108 if ( $localrelocatablepath ne "/" ) { $localrelocatablepath =~ s/\/\s*$//; } 2109 2110 if ( $installer::globals::issolarispkgbuild ) 2111 { 2112 $filename = $packagename . ".pkginfo"; 2113 $newline = "BASEDIR\=" . $localrelocatablepath . "\n"; 2114 } 2115 2116 if ( $installer::globals::islinuxrpmbuild ) 2117 { 2118 # if ( $localrelocatablepath =~ /^\s*$/ ) { $localrelocatablepath = "/"; }; # at least the "/" 2119 $filename = $packagename . ".spec"; 2120 $newline = "Prefix\:\ " . $localrelocatablepath . "\n"; 2121 } 2122 2123 my $completefilename = $newepmdir . $filename; 2124 2125 if ( ! -f $completefilename) { installer::exiter::exit_program("ERROR: Did not find file: $completefilename", "prepare_packages"); } 2126 my $changefile = installer::files::read_file($completefilename); 2127 if ( $newline ne "" ) 2128 { 2129 add_one_line_into_file($changefile, $newline, $filename); 2130 installer::files::save_file($completefilename, $changefile); 2131 } 2132 2133 # my $newepmdir = $completefilename; 2134 # installer::pathanalyzer::get_path_from_fullqualifiedname(\$newepmdir); 2135 2136 # adding new "topdir" and removing old "topdir" in specfile 2137 2138 if ( $installer::globals::islinuxrpmbuild ) 2139 { 2140 set_topdir_in_specfile($changefile, $filename, $newepmdir); 2141 set_autoprovreq_in_specfile($changefile, $onepackage->{'findrequires'}, "$installer::globals::unpackpath" . "/bin"); 2142 set_packager_in_specfile($changefile); 2143 if ( is_extension_package($changefile) ) { set_prereq_in_specfile($changefile); } 2144 set_license_in_specfile($changefile, $variableshashref); 2145 set_tab_into_datafile($changefile, $filesref); 2146 # check_requirements_in_specfile($changefile); 2147 installer::files::save_file($completefilename, $changefile); 2148 if ( $installer::globals::patch ) { collect_patch_files($changefile, $packagename, $localrelocatablepath); } 2149 } 2150 2151 # removing the relocatable path in prototype file 2152 2153 if ( $installer::globals::issolarispkgbuild ) 2154 { 2155 set_revision_in_pkginfo($changefile, $filename, $variableshashref, $packagename); 2156 set_maxinst_in_pkginfo($changefile, $filename); 2157 set_solaris_parameter_in_pkginfo($changefile, $filename, $variableshashref); 2158 if ( $installer::globals::issolarisx86build ) { fix_architecture_setting($changefile); } 2159 if ( ! $installer::globals::patch ) { set_patchlist_in_pkginfo_for_respin($changefile, $filename, $variableshashref, $packagename); } 2160 if ( $installer::globals::patch ) { include_patchinfos_into_pkginfo($changefile, $filename, $variableshashref); } 2161 if (( $onepackage->{'language'} ) && ( $onepackage->{'language'} ne "" ) && ( $onepackage->{'language'} ne "en-US" )) { include_languageinfos_into_pkginfo($changefile, $filename, $languagestringref, $onepackage, $variableshashref); } 2162 installer::files::save_file($completefilename, $changefile); 2163 2164 my $prototypefilename = $packagename . ".prototype"; 2165 $prototypefilename = $newepmdir . $prototypefilename; 2166 if (! -f $prototypefilename) { installer::exiter::exit_program("ERROR: Did not find prototype file: $prototypefilename", "prepare_packages"); } 2167 2168 my $prototypefile = installer::files::read_file($prototypefilename); 2169 make_prototypefile_relocatable($prototypefile, $relocatablepath); 2170 set_volatilefile_into_prototypefile($prototypefile, $filesref); 2171 my $classesstring = set_tab_into_datafile($prototypefile, $filesref); 2172 if ($classesstring) 2173 { 2174 include_classes_into_pkginfo($changefile, $classesstring); 2175 installer::files::save_file($completefilename, $changefile); 2176 } 2177 2178 if ( $installer::globals::patch ) { add_scripts_into_prototypefile($prototypefile, $prototypefilename, $languagestringref, $staticpath); } 2179 2180 installer::files::save_file($prototypefilename, $prototypefile); 2181 if ( $installer::globals::patch ) { collect_patch_files($prototypefile, $packagename, ""); } 2182 2183 # Adding package names into depend files for Solaris (not supported by epm) 2184 my $dependfilename = $packagename . ".depend"; 2185 $dependfilename = $newepmdir . $dependfilename; 2186 if ( -f $dependfilename) 2187 { 2188 my $dependfile = installer::files::read_file($dependfilename); 2189 put_packagenames_into_dependfile($dependfile); 2190 installer::files::save_file($dependfilename, $dependfile); 2191 } 2192 } 2193 2194 return $newepmdir; 2195} 2196 2197############################################################ 2198# Linux requirement for perl is changed by epm from 2199# /usr/bin/perl to perl . 2200# Requires: perl 2201############################################################ 2202 2203sub check_requirements_in_specfile 2204{ 2205 my ( $specfile ) = @_; 2206 2207 for ( my $i = 0; $i <= $#{$specfile}; $i++ ) 2208 { 2209 if (( ${$specfile}[$i] =~ /^\s*Requires/ ) && ( ${$specfile}[$i] =~ /\bperl\b/ ) && ( ! ( ${$specfile}[$i] =~ /\/usr\/bin\/perl\b/ ))) 2210 { 2211 my $oldline = ${$specfile}[$i]; 2212 ${$specfile}[$i] =~ s/perl/\/usr\/bin\/perl/; 2213 my $newline = ${$specfile}[$i]; 2214 2215 $oldline =~ s/\s*$//; 2216 $newline =~ s/\s*$//; 2217 my $infoline = "Spec File: Changing content from \"$oldline\" to \"$newline\".\n"; 2218 push(@installer::globals::logfileinfo, $infoline); 2219 } 2220 } 2221} 2222 2223############################################################################### 2224# Replacement of PRODUCTINSTALLLOCATION and PRODUCTDIRECTORYNAME in the 2225# epm list file. 2226# The complete rootpath is stored in $installer::globals::rootpath 2227# or for each package in $onepackage->{'destpath'} 2228# The static rootpath is stored in $staticpath 2229# The relocatable path is stored in $relocatablepath 2230# PRODUCTINSTALLLOCATION is the relocatable part ("/opt") and 2231# PRODUCTDIRECTORYNAME the static path ("openofficeorg20"). 2232# In standard epm process: 2233# No usage of package specific variables like $BASEDIR, because 2234# 1. These variables would be replaced in epm process 2235# 2. epm version 3.7 does not support relocatable packages 2236############################################################################### 2237 2238sub resolve_path_in_epm_list_before_packaging 2239{ 2240 my ($listfile, $listfilename, $variable, $path) = @_; 2241 2242 installer::logger::include_header_into_logfile("Replacing variables in epm list file:"); 2243 2244 $path =~ s/\/\s*$//; 2245 replace_variables_in_shellscripts($listfile, $listfilename, $variable, $path); 2246 2247} 2248 2249################################################################# 2250# Determining the rpm version. Beginning with rpm version 4.0 2251# the tool to create RPMs is "rpmbuild" and no longer "rpm" 2252################################################################# 2253 2254sub determine_rpm_version 2255{ 2256 my $rpmversion = 0; 2257 my $rpmout = ""; 2258 my $systemcall = ""; 2259 2260 # my $systemcall = "rpm --version |"; 2261 # "rpm --version" has problems since LD_LIBRARY_PATH was removed. Therefore the content of $RPM has to be called. 2262 # "rpm --version" and "rpmbuild --version" have the same output. Therefore $RPM can be used. Its value 2263 # is saved in $installer::globals::rpm 2264 2265 if ( $installer::globals::rpm ne "" ) 2266 { 2267 $systemcall = "$installer::globals::rpm --version |"; 2268 } 2269 else 2270 { 2271 $systemcall = "rpm --version |"; 2272 } 2273 2274 open (RPM, "$systemcall"); 2275 $rpmout = <RPM>; 2276 close (RPM); 2277 2278 if ( $rpmout ne "" ) 2279 { 2280 $rpmout =~ s/\s*$//g; 2281 2282 my $infoline = "Systemcall: $systemcall\n"; 2283 push( @installer::globals::logfileinfo, $infoline); 2284 2285 if ( $rpmout eq "" ) { $infoline = "ERROR: Could not find file \"rpm\" !\n"; } 2286 else { $infoline = "Success: rpm version: $rpmout\n"; } 2287 2288 push( @installer::globals::logfileinfo, $infoline); 2289 2290 if ( $rpmout =~ /(\d+)\.(\d+)\.(\d+)/ ) { $rpmversion = $1; } 2291 elsif ( $rpmout =~ /(\d+)\.(\d+)/ ) { $rpmversion = $1; } 2292 elsif ( $rpmout =~ /(\d+)/ ) { $rpmversion = $1; } 2293 else { installer::exiter::exit_program("ERROR: Unknown format: $rpmout ! Expected: \"a.b.c\", or \"a.b\", or \"a\"", "determine_rpm_version"); } 2294 } 2295 2296 return $rpmversion; 2297} 2298 2299#################################################### 2300# Writing some info about rpm into the log file 2301#################################################### 2302 2303sub log_rpm_info 2304{ 2305 my $systemcall = ""; 2306 my $infoline = ""; 2307 2308 $infoline = "\nLogging rpmrc content using --showrc\n\n"; 2309 push( @installer::globals::logfileinfo, $infoline); 2310 2311 if ( $installer::globals::rpm ne "" ) 2312 { 2313 $systemcall = "$installer::globals::rpm --showrc |"; 2314 } 2315 else 2316 { 2317 $systemcall = "rpm --showrc |"; 2318 } 2319 2320 my @fullrpmout = (); 2321 2322 open (RPM, "$systemcall"); 2323 while (<RPM>) {push(@fullrpmout, $_); } 2324 close (RPM); 2325 2326 if ( $#fullrpmout > -1 ) 2327 { 2328 for ( my $i = 0; $i <= $#fullrpmout; $i++ ) 2329 { 2330 my $rpmout = $fullrpmout[$i]; 2331 $rpmout =~ s/\s*$//g; 2332 2333 $infoline = "$rpmout\n"; 2334 $infoline =~ s/error/e_r_r_o_r/gi; # avoiding log problems 2335 push( @installer::globals::logfileinfo, $infoline); 2336 } 2337 } 2338 else 2339 { 2340 $infoline = "Problem in systemcall: $systemcall : No return value\n"; 2341 push( @installer::globals::logfileinfo, $infoline); 2342 } 2343 2344 $infoline = "End of logging rpmrc\n\n"; 2345 push( @installer::globals::logfileinfo, $infoline); 2346} 2347 2348################################################# 2349# Systemcall to start the packaging process 2350################################################# 2351 2352sub create_packages_without_epm 2353{ 2354 my ($epmdir, $packagename, $includepatharrayref, $allvariables, $languagestringref) = @_; 2355 2356 # Solaris: pkgmk -o -f solaris-2.8-sparc/SUNWso8m34.prototype -d solaris-2.8-sparc 2357 # Solaris: pkgtrans solaris-2.8-sparc SUNWso8m34.pkg SUNWso8m34 2358 # Solaris: tar -cf - SUNWso8m34 | gzip > SUNWso8m34.tar.gz 2359 2360 if ( $installer::globals::issolarispkgbuild ) 2361 { 2362 my $prototypefile = $epmdir . $packagename . ".prototype"; 2363 if (! -f $prototypefile) { installer::exiter::exit_program("ERROR: Did not find file: $prototypefile", "create_packages_without_epm"); } 2364 2365 my $destinationdir = $prototypefile; 2366 installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationdir); 2367 $destinationdir =~ s/\/\s*$//; # removing ending slashes 2368 2369 # my $systemcall = "pkgmk -o -f $prototypefile -d $destinationdir \> /dev/null 2\>\&1"; 2370 my $systemcall = "pkgmk -l 1073741824 -o -f $prototypefile -d $destinationdir 2\>\&1 |"; 2371 installer::logger::print_message( "... $systemcall ...\n" ); 2372 2373 my $maxpkgmkcalls = 3; 2374 2375 for ( my $i = 1; $i <= $maxpkgmkcalls; $i++ ) 2376 { 2377 my @pkgmkoutput = (); 2378 2379 open (PKGMK, "$systemcall"); 2380 while (<PKGMK>) {push(@pkgmkoutput, $_); } 2381 close (PKGMK); 2382 2383 my $returnvalue = $?; # $? contains the return value of the systemcall 2384 2385 my $infoline = "Systemcall (Try $i): $systemcall\n"; 2386 push( @installer::globals::logfileinfo, $infoline); 2387 2388 for ( my $j = 0; $j <= $#pkgmkoutput; $j++ ) 2389 { 2390 if ( $i < $maxpkgmkcalls ) { $pkgmkoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; } 2391 push( @installer::globals::logfileinfo, "$pkgmkoutput[$j]"); 2392 } 2393 2394 if ($returnvalue) 2395 { 2396 $infoline = "Try $i : Could not execute \"$systemcall\"!\n"; 2397 push( @installer::globals::logfileinfo, $infoline); 2398 if ( $i == $maxpkgmkcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); } 2399 } 2400 else 2401 { 2402 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" ); 2403 $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2404 push( @installer::globals::logfileinfo, $infoline); 2405 last; 2406 } 2407 } 2408 2409 # It might be necessary to save uncompressed Solaris packages 2410 2411 if ( $allvariables->{'JDSBUILD'} ) 2412 { 2413 if ( ! $installer::globals::jds_language_controlled ) 2414 { 2415 my $correct_language = installer::worker::check_jds_language($allvariables, $languagestringref); 2416 $installer::globals::correct_jds_language = $correct_language; 2417 $installer::globals::jds_language_controlled = 1; 2418 } 2419 2420 if ( $installer::globals::correct_jds_language ) 2421 { 2422 if ( $installer::globals::saved_packages_path eq "" ) 2423 { 2424 $packagestempdir = installer::systemactions::create_directories("jds", $languagestringref); 2425 $installer::globals::saved_packages_path = $packagestempdir; 2426 push(@installer::globals::jdsremovedirs, $packagestempdir); 2427 } 2428 2429 $systemcall = "cd $destinationdir; cp -p -R $packagename $installer::globals::saved_packages_path;"; 2430 make_systemcall($systemcall); 2431 installer::logger::print_message( "... $systemcall ...\n" ); 2432 2433 # Setting unix rights to "775" for all created directories inside the package, 2434 # that is saved in temp directory 2435 2436 $systemcall = "cd $packagestempdir; find $packagename -type d -exec chmod 775 \{\} \\\;"; 2437 installer::logger::print_message( "... $systemcall ...\n" ); 2438 2439 $returnvalue = system($systemcall); 2440 2441 $infoline = "Systemcall: $systemcall\n"; 2442 push( @installer::globals::logfileinfo, $infoline); 2443 2444 if ($returnvalue) 2445 { 2446 $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 2447 push( @installer::globals::logfileinfo, $infoline); 2448 } 2449 else 2450 { 2451 $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2452 push( @installer::globals::logfileinfo, $infoline); 2453 } 2454 } 2455 } 2456 2457 # compressing packages 2458 2459 if ( ! $installer::globals::solarisdontcompress ) 2460 { 2461 my $faspac = "faspac-so.sh"; 2462 2463 my $compressorref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$faspac, $includepatharrayref, 0); 2464 if ($$compressorref ne "") 2465 { 2466 # Saving original pkginfo, to set time stamp later 2467 my $pkginfoorig = "$destinationdir/$packagename/pkginfo"; 2468 my $pkginfotmp = "$destinationdir/$packagename" . ".pkginfo.tmp"; 2469 $systemcall = "cp -p $pkginfoorig $pkginfotmp"; 2470 make_systemcall($systemcall); 2471 2472 $faspac = $$compressorref; 2473 $infoline = "Found compressor: $faspac\n"; 2474 push( @installer::globals::logfileinfo, $infoline); 2475 2476 installer::logger::print_message( "... $faspac ...\n" ); 2477 installer::logger::include_timestamp_into_logfile("Starting $faspac"); 2478 2479 $systemcall = "/bin/sh $faspac -a -q -d $destinationdir $packagename"; # $faspac has to be the absolute path! 2480 make_systemcall($systemcall); 2481 2482 # Setting time stamp for pkginfo, because faspac-so.sh changed the pkginfo file, 2483 # updated the size and checksum, but not the time stamp. 2484 $systemcall = "touch -r $pkginfotmp $pkginfoorig"; 2485 make_systemcall($systemcall); 2486 if ( -f $pkginfotmp ) { unlink($pkginfotmp); } 2487 2488 installer::logger::include_timestamp_into_logfile("End of $faspac"); 2489 } 2490 else 2491 { 2492 $infoline = "Not found: $faspac\n"; 2493 push( @installer::globals::logfileinfo, $infoline); 2494 } 2495 } 2496 2497 # Setting unix rights to "775" for all created directories inside the package 2498 2499 $systemcall = "cd $destinationdir; find $packagename -type d -exec chmod 775 \{\} \\\;"; 2500 installer::logger::print_message( "... $systemcall ...\n" ); 2501 2502 $returnvalue = system($systemcall); 2503 2504 $infoline = "Systemcall: $systemcall\n"; 2505 push( @installer::globals::logfileinfo, $infoline); 2506 2507 if ($returnvalue) 2508 { 2509 $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 2510 push( @installer::globals::logfileinfo, $infoline); 2511 } 2512 else 2513 { 2514 $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2515 push( @installer::globals::logfileinfo, $infoline); 2516 } 2517 2518 ###################### 2519 # making pkg files 2520 ###################### 2521 2522 # my $streamname = $packagename . ".pkg"; 2523 # $systemcall = "pkgtrans $destinationdir $streamname $packagename"; 2524 # print "... $systemcall ...\n"; 2525 2526 # $returnvalue = system($systemcall); 2527 2528 # $infoline = "Systemcall: $systemcall\n"; 2529 # push( @installer::globals::logfileinfo, $infoline); 2530 2531 # if ($returnvalue) 2532 # { 2533 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 2534 # push( @installer::globals::logfileinfo, $infoline); 2535 # } 2536 # else 2537 # { 2538 # $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2539 # push( @installer::globals::logfileinfo, $infoline); 2540 # } 2541 2542 ######################### 2543 # making tar.gz files 2544 ######################### 2545 2546 # my $targzname = $packagename . ".tar.gz"; 2547 # $systemcall = "cd $destinationdir; tar -cf - $packagename | gzip > $targzname"; 2548 # print "... $systemcall ...\n"; 2549 2550 # $returnvalue = system($systemcall); 2551 2552 # $infoline = "Systemcall: $systemcall\n"; 2553 # push( @installer::globals::logfileinfo, $infoline); 2554 2555 # if ($returnvalue) 2556 # { 2557 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 2558 # push( @installer::globals::logfileinfo, $infoline); 2559 # } 2560 # else 2561 # { 2562 # $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2563 # push( @installer::globals::logfileinfo, $infoline); 2564 # } 2565 } 2566 2567 # Linux: rpm -bb so8m35.spec ( -> dependency check abklemmen? ) 2568 2569 if ( $installer::globals::islinuxrpmbuild ) 2570 { 2571 my $specfilename = $epmdir . $packagename . ".spec"; 2572 if (! -f $specfilename) { installer::exiter::exit_program("ERROR: Did not find file: $specfilename", "create_packages_without_epm"); } 2573 2574 # my $rpmcommand = "rpm"; 2575 my $rpmcommand = $installer::globals::rpm; 2576 my $rpmversion = determine_rpm_version(); 2577 2578 # if ( $rpmversion >= 4 ) { $rpmcommand = "rpmbuild"; } 2579 2580 # saving globally for later usage 2581 $installer::globals::rpmcommand = $rpmcommand; 2582 $installer::globals::rpmquerycommand = "rpm"; 2583 2584 my $target = ""; 2585 if ( $installer::globals::compiler =~ /unxlngi/) { $target = "i586"; } 2586 elsif ( $installer::globals::compiler =~ /unxlng/) {$target = (POSIX::uname())[4]; } 2587 2588 # rpm 4.6 ignores buildroot tag in spec file 2589 2590 my $buildrootstring = ""; 2591 2592 if ( $rpmversion >= 4 ) 2593 { 2594 my $dir = getcwd; 2595 my $buildroot = $dir . "/" . $epmdir . "buildroot/"; 2596 $buildrootstring = "--buildroot=$buildroot"; 2597 mkdir($buildroot = $dir . "/" . $epmdir . "BUILD/"); 2598 } 2599 2600 if ( ! $installer::globals::rpminfologged ) 2601 { 2602 log_rpm_info(); 2603 $installer::globals::rpminfologged = 1; 2604 } 2605 2606 my $systemcall = "$rpmcommand -bb --define \"_unpackaged_files_terminate_build 0\" $specfilename --target $target $buildrootstring 2\>\&1 |"; 2607 2608 installer::logger::print_message( "... $systemcall ...\n" ); 2609 2610 my $maxrpmcalls = 3; 2611 my $rpm_failed = 0; 2612 2613 for ( my $i = 1; $i <= $maxrpmcalls; $i++ ) 2614 { 2615 my @rpmoutput = (); 2616 2617 open (RPM, "$systemcall"); 2618 while (<RPM>) {push(@rpmoutput, $_); } 2619 close (RPM); 2620 2621 my $returnvalue = $?; # $? contains the return value of the systemcall 2622 2623 my $infoline = "Systemcall (Try $i): $systemcall\n"; 2624 push( @installer::globals::logfileinfo, $infoline); 2625 2626 for ( my $j = 0; $j <= $#rpmoutput; $j++ ) 2627 { 2628 # if ( $i < $maxrpmcalls ) { $rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; } 2629 $rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; 2630 push( @installer::globals::logfileinfo, "$rpmoutput[$j]"); 2631 } 2632 2633 if ($returnvalue) 2634 { 2635 $infoline = "Try $i : Could not execute \"$systemcall\"!\n"; 2636 push( @installer::globals::logfileinfo, $infoline); 2637 $rpm_failed = 1; 2638 } 2639 else 2640 { 2641 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" ); 2642 $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2643 push( @installer::globals::logfileinfo, $infoline); 2644 $rpm_failed = 0; 2645 last; 2646 } 2647 } 2648 2649 if ( $rpm_failed ) 2650 { 2651 # Because of the problems with LD_LIBARY_PATH, a direct call of local "rpm" or "rpmbuild" might be successful 2652 my $rpmprog = ""; 2653 if ( -f "/usr/bin/rpmbuild" ) { $rpmprog = "/usr/bin/rpmbuild"; } 2654 elsif ( -f "/usr/bin/rpm" ) { $rpmprog = "/usr/bin/rpm"; } 2655 2656 if ( $rpmprog ne "" ) 2657 { 2658 installer::logger::print_message( "... $rpmprog ...\n" ); 2659 2660 my $helpersystemcall = "$rpmprog -bb $specfilename --target $target $buildrootstring 2\>\&1 |"; 2661 2662 my @helperrpmoutput = (); 2663 2664 open (RPM, "$helpersystemcall"); 2665 while (<RPM>) {push(@helperrpmoutput, $_); } 2666 close (RPM); 2667 2668 my $helperreturnvalue = $?; # $? contains the return value of the systemcall 2669 2670 $infoline = "\nLast try: Using $rpmprog directly (problem with LD_LIBARY_PATH)\n"; 2671 push( @installer::globals::logfileinfo, $infoline); 2672 2673 $infoline = "\nSystemcall: $helpersystemcall\n"; 2674 push( @installer::globals::logfileinfo, $infoline); 2675 2676 for ( my $j = 0; $j <= $#helperrpmoutput; $j++ ) { push( @installer::globals::logfileinfo, "$helperrpmoutput[$j]"); } 2677 2678 if ($helperreturnvalue) 2679 { 2680 $infoline = "Could not execute \"$helpersystemcall\"!\n"; 2681 push( @installer::globals::logfileinfo, $infoline); 2682 } 2683 else 2684 { 2685 installer::logger::print_message( "Success: \"$helpersystemcall\"\n" ); 2686 $infoline = "Success: Executed \"$helpersystemcall\" successfully!\n"; 2687 push( @installer::globals::logfileinfo, $infoline); 2688 $rpm_failed = 0; 2689 } 2690 } 2691 2692 # Now it is really time to exit this packaging process, if the error still occurs 2693 if ( $rpm_failed ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); } 2694 } 2695 } 2696} 2697 2698################################################# 2699# Removing all temporary files created by epm 2700################################################# 2701 2702sub remove_temporary_epm_files 2703{ 2704 my ($epmdir, $loggingdir, $packagename) = @_; 2705 2706 # saving the files into the loggingdir 2707 2708 if ( $installer::globals::issolarispkgbuild ) 2709 { 2710 my @extensions = (); 2711 push(@extensions, ".pkginfo"); 2712 push(@extensions, ".prototype"); 2713 push(@extensions, ".postinstall"); 2714 push(@extensions, ".postremove"); 2715 push(@extensions, ".preinstall"); 2716 push(@extensions, ".preremove"); 2717 push(@extensions, ".depend"); 2718 2719 for ( my $i = 0; $i <= $#extensions; $i++ ) 2720 { 2721 my $removefile = $epmdir . $packagename . $extensions[$i]; 2722 my $destfile = $loggingdir . $packagename . $extensions[$i] . ".log"; 2723 2724 if (! -f $removefile) { next; } 2725 2726 my $systemcall = "mv -f $removefile $destfile"; 2727 system($systemcall); # ignoring the return value 2728 $infoline = "Systemcall: $systemcall\n"; 2729 push( @installer::globals::logfileinfo, $infoline); 2730 } 2731 2732 # removing the package 2733 2734# my $removedir = $epmdir . $packagename; 2735# 2736# my $systemcall = "rm -rf $removedir"; 2737# 2738# print "... $systemcall ...\n"; 2739# 2740# my $returnvalue = system($systemcall); 2741# 2742# my $infoline = "Systemcall: $systemcall\n"; 2743# push( @installer::globals::logfileinfo, $infoline); 2744# 2745# if ($returnvalue) 2746# { 2747# $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 2748# push( @installer::globals::logfileinfo, $infoline); 2749# } 2750# else 2751# { 2752# $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2753# push( @installer::globals::logfileinfo, $infoline); 2754# } 2755 } 2756 2757 if ( $installer::globals::islinuxrpmbuild ) 2758 { 2759 my $removefile = $epmdir . $packagename . ".spec"; 2760 my $destfile = $loggingdir . $packagename . ".spec.log"; 2761 2762 # if (! -f $removefile) { next; } 2763 2764 my $systemcall = "mv -f $removefile $destfile"; 2765 system($systemcall); # ignoring the return value 2766 $infoline = "Systemcall: $systemcall\n"; 2767 push( @installer::globals::logfileinfo, $infoline); 2768 2769 # removing the directory "buildroot" 2770 2771 my $removedir = $epmdir . "buildroot"; 2772 2773 $systemcall = "rm -rf $removedir"; 2774 2775 installer::logger::print_message( "... $systemcall ...\n" ); 2776 2777 my $returnvalue = system($systemcall); 2778 2779 $removedir = $epmdir . "BUILD"; 2780 2781 $systemcall = "rm -rf $removedir"; 2782 2783 installer::logger::print_message( "... $systemcall ...\n" ); 2784 2785 $returnvalue = system($systemcall); 2786 2787 2788 my $infoline = "Systemcall: $systemcall\n"; 2789 push( @installer::globals::logfileinfo, $infoline); 2790 2791 if ($returnvalue) 2792 { 2793 $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 2794 push( @installer::globals::logfileinfo, $infoline); 2795 } 2796 else 2797 { 2798 $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2799 push( @installer::globals::logfileinfo, $infoline); 2800 } 2801 } 2802} 2803 2804###################################################### 2805# Making the systemcall 2806###################################################### 2807 2808sub make_systemcall 2809{ 2810 my ($systemcall) = @_; 2811 2812 my $returnvalue = system($systemcall); 2813 2814 my $infoline = "Systemcall: $systemcall\n"; 2815 push( @installer::globals::logfileinfo, $infoline); 2816 2817 if ($returnvalue) 2818 { 2819 $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 2820 push( @installer::globals::logfileinfo, $infoline); 2821 } 2822 else 2823 { 2824 $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2825 push( @installer::globals::logfileinfo, $infoline); 2826 } 2827} 2828 2829########################################################### 2830# Creating a better directory structure in the solver. 2831########################################################### 2832 2833sub create_new_directory_structure 2834{ 2835 my ($newepmdir) = @_; 2836 2837 my $newdir = $installer::globals::epmoutpath; 2838 2839 if ( $installer::globals::islinuxrpmbuild ) 2840 { 2841 my $rpmdir; 2842 my $machine = ""; 2843 if ( $installer::globals::compiler =~ /unxlngi/) { 2844 $rpmdir = "$installer::globals::epmoutpath/RPMS/i586"; 2845 } 2846 elsif ( $installer::globals::compiler =~ /unxlng/) { 2847 $machine = (POSIX::uname())[4]; 2848 $rpmdir = "$installer::globals::epmoutpath/RPMS/$machine"; 2849 } 2850 else { installer::exiter::exit_program("ERROR: rpmdir undefined !", "create_new_directory_structure"); } 2851 2852 my $systemcall = "mv $rpmdir/* $newdir"; # moving the rpms into the directory "RPMS" 2853 2854 my $returnvalue = system($systemcall); 2855 2856 my $infoline = "Systemcall: $systemcall\n"; 2857 push( @installer::globals::logfileinfo, $infoline); 2858 2859 if ($returnvalue) 2860 { 2861 $infoline = "ERROR: Could not move content of \"$rpmdir\" to \"$newdir\"!\n"; 2862 push( @installer::globals::logfileinfo, $infoline); 2863 } 2864 else 2865 { 2866 $infoline = "Success: Moved content of \"$rpmdir\" to \"$newdir\"!\n"; 2867 push( @installer::globals::logfileinfo, $infoline); 2868 } 2869 2870 # and removing the empty directory 2871 2872 if ( $machine ne "" ) 2873 { 2874 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/$machine"); 2875 } 2876 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/x86_64"); 2877 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/i586"); 2878 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/i386"); 2879 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS"); 2880 2881 } 2882 2883 # Setting unix rights to "775" for $newdir ("RPMS" or "packages") 2884 2885 my $localcall = "chmod 775 $newdir \>\/dev\/null 2\>\&1"; 2886 my $callreturnvalue = system($localcall); 2887 2888 my $callinfoline = "Systemcall: $localcall\n"; 2889 push( @installer::globals::logfileinfo, $callinfoline); 2890 2891 if ($callreturnvalue) 2892 { 2893 $callinfoline = "ERROR: Could not execute \"$localcall\"!\n"; 2894 push( @installer::globals::logfileinfo, $callinfoline); 2895 } 2896 else 2897 { 2898 $callinfoline = "Success: Executed \"$localcall\" successfully!\n"; 2899 push( @installer::globals::logfileinfo, $callinfoline); 2900 } 2901} 2902 2903###################################################### 2904# Collect modules with product specific styles. 2905###################################################### 2906 2907sub collect_modules_with_style 2908{ 2909 my ($style, $modulesarrayref) = @_; 2910 2911 my @allmodules = (); 2912 2913 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ ) 2914 { 2915 my $onemodule = ${$modulesarrayref}[$i]; 2916 my $styles = ""; 2917 if ( $onemodule->{'Styles'} ) { $styles = $onemodule->{'Styles'}; } 2918 if ( $styles =~ /\b\Q$style\E\b/ ) 2919 { 2920 push(@allmodules, $onemodule); 2921 } 2922 } 2923 2924 return \@allmodules; 2925} 2926 2927###################################################### 2928# Remove modules without packagecontent. 2929###################################################### 2930 2931sub remove_modules_without_package 2932{ 2933 my ($allmodules) = @_; 2934 2935 my @allmodules = (); 2936 2937 for ( my $i = 0; $i <= $#{$allmodules}; $i++ ) 2938 { 2939 my $onemodule = ${$allmodules}[$i]; 2940 my $packagename = ""; 2941 if ( $onemodule->{'PackageName'} ) { $packagename = $onemodule->{'PackageName'}; } 2942 if ( $packagename ne "" ) 2943 { 2944 push(@allmodules, $onemodule); 2945 } 2946 } 2947 2948 return \@allmodules; 2949} 2950 2951###################################################### 2952# Unpacking tar.gz file and setting new packagename. 2953###################################################### 2954 2955sub unpack_tar_gz_file 2956{ 2957 my ($packagename, $destdir) = @_; 2958 2959 my $newpackagename = ""; 2960 2961 if ( $packagename =~ /\.tar\.gz\s*$/ ) 2962 { 2963 # Collecting all packages in directory "packages" 2964 my $oldcontent = installer::systemactions::read_directory($destdir); 2965 2966 # unpacking gunzip 2967 my $systemcall = "cd $destdir; cat $packagename | gunzip | tar -xf -"; 2968 make_systemcall($systemcall); 2969 2970 # deleting the tar.gz files 2971 $systemcall = "cd $destdir; rm -f $packagename"; 2972 make_systemcall($systemcall); 2973 2974 # Finding new content -> that is the package name 2975 my ($newcontent, $allcontent ) = installer::systemactions::find_new_content_in_directory($destdir, $oldcontent); 2976 $newpackagename = ${$newcontent}[0]; 2977 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$newpackagename); 2978 } 2979 2980 if ( $newpackagename ne "" ) { $packagename = $newpackagename; } 2981 2982 return $packagename; 2983} 2984 2985###################################################### 2986# Copying files of child projects. 2987###################################################### 2988 2989sub copy_childproject_files 2990{ 2991 my ($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, $subdir, $includepatharrayref, $use_sopackpath) = @_; 2992 2993 for ( my $i = 0; $i <= $#{$allmodules}; $i++ ) 2994 { 2995 my $localdestdir = $destdir; 2996 my $onemodule = ${$allmodules}[$i]; 2997 my $packagename = $onemodule->{'PackageName'}; 2998 my $sourcefile = ""; 2999 if ( $use_sopackpath ) 3000 { 3001 $sourcefile = $sopackpath . $installer::globals::separator . $installer::globals::compiler . $installer::globals::separator . $subdir . $installer::globals::separator . $packagename; 3002 } 3003 else 3004 { 3005 my $sourcepathref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packagename, $includepatharrayref, 1); 3006 $sourcefile = $$sourcepathref; 3007 } 3008 3009 if ( ! -f $sourcefile ) { installer::exiter::exit_program("ERROR: File not found: $sourcefile ($packagename) !", "copy_childproject_files"); } 3010 if ( $onemodule->{'Subdir'} ) 3011 { 3012 $localdestdir = $localdestdir . $installer::globals::separator . $onemodule->{'Subdir'}; 3013 if ( ! -d $localdestdir ) { installer::systemactions::create_directory($localdestdir); } 3014 } 3015 installer::systemactions::copy_one_file($sourcefile, $localdestdir); 3016 # Solaris: unpacking tar.gz files and setting new packagename 3017 if ( $installer::globals::issolarispkgbuild ) { $packagename = unpack_tar_gz_file($packagename, $localdestdir); } 3018 3019 if (( $installer::globals::isxpdplatform ) && ( $allvariables->{'XPDINSTALLER'} )) 3020 { 3021 installer::xpdinstaller::create_xpd_file_for_childproject($onemodule, $localdestdir, $packagename, $allvariableshashref, $modulesarrayref); 3022 } 3023 } 3024 3025} 3026 3027###################################################### 3028# Copying files for system integration. 3029###################################################### 3030 3031sub copy_and_unpack_tar_gz_files 3032{ 3033 my ($sourcefile, $destdir) = @_; 3034 3035 my $systemcall = "cd $destdir; cat $sourcefile | gunzip | tar -xf -"; 3036 make_systemcall($systemcall); 3037} 3038 3039###################################################### 3040# Including child packages into the 3041# installation set. 3042###################################################### 3043 3044sub put_childprojects_into_installset 3045{ 3046 my ($newdir, $allvariables, $modulesarrayref, $includepatharrayref) = @_; 3047 3048 my $infoline = ""; 3049 3050 my $sopackpath = ""; 3051 if ( $ENV{'SO_PACK'} ) { $sopackpath = $ENV{'SO_PACK'}; } 3052 else { installer::exiter::exit_program("ERROR: Environment variable SO_PACK not set!", "put_childprojects_into_installset"); } 3053 3054 my $destdir = "$newdir"; 3055 3056 # adding Java 3057 3058 my $sourcefile = ""; 3059 3060 # Finding the modules defined in scp (with flag JAVAMODULE, ADAMODULE, ...) 3061 # Getting name of package from scp-Module 3062 # Copy file into installation set 3063 # Create xpd file and put it into xpd directory 3064 # xpd file has to be created completely from module and package itself (-> no packagelist!) 3065 3066 if ( $allvariables->{'JAVAPRODUCT'} ) 3067 { 3068 # Collect all modules with flag "JAVAMODULE" 3069 my $allmodules = collect_modules_with_style("JAVAMODULE", $modulesarrayref); 3070 $allmodules = remove_modules_without_package($allmodules); 3071 copy_childproject_files($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "jre", $includepatharrayref, 1); 3072 } 3073 3074 # Adding additional required packages (freetype). 3075 # This package names are stored in global array @installer::globals::requiredpackages 3076 3077 if ( $allvariables->{'ADDREQUIREDPACKAGES'} ) 3078 { 3079 # Collect all modules with flag "REQUIREDPACKAGEMODULE" 3080 my $allmodules = collect_modules_with_style("REQUIREDPACKAGEMODULE", $modulesarrayref); 3081 $allmodules = remove_modules_without_package($allmodules); 3082 copy_childproject_files($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "requiredpackages", $includepatharrayref, 1); 3083 } 3084 3085 # Collect all modules with flag "USERLANDMODULE" 3086 my $alluserlandmodules = collect_modules_with_style("USERLANDMODULE", $modulesarrayref); 3087 $alluserlandmodules = remove_modules_without_package($alluserlandmodules); 3088 copy_childproject_files($alluserlandmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "", $includepatharrayref, 0); 3089 3090} 3091 3092###################################################### 3093# Checking whether the new content is a directory and 3094# not a package. If it is a directory, the complete 3095# content of the directory has to be added to the 3096# array newcontent. 3097###################################################### 3098 3099sub control_subdirectories 3100{ 3101 my ($content, $subdir) = @_; 3102 3103 my @newcontent = (); 3104 3105 for ( my $i = 0; $i <= $#{$content}; $i++ ) 3106 { 3107 if ( -d ${$content}[$i] ) 3108 { 3109 $subdir = ${$content}[$i]; 3110 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$subdir); 3111 my $allpackages = installer::systemactions::read_directory(${$content}[$i]); 3112 for ( my $j = 0; $j <= $#{$allpackages}; $j++ ) 3113 { 3114 # Currently only Linux rpm is supported, debian packages cannot be installed via xpd installer 3115 if (( $installer::globals::islinuxbuild ) && ( ! ( ${$allpackages}[$j] =~ /\.rpm\s*$/ ))) { next; } 3116 push(@newcontent, ${$allpackages}[$j]); 3117 } 3118 } 3119 else 3120 { 3121 push(@newcontent, ${$content}[$i]); 3122 } 3123 } 3124 3125 return (\@newcontent, $subdir); 3126} 3127 3128###################################################### 3129# Including the system integration files into the 3130# installation sets. 3131###################################################### 3132 3133sub put_systemintegration_into_installset 3134{ 3135 my ($newdir, $includepatharrayref, $allvariables, $modulesarrayref) = @_; 3136 3137 my $destdir = $newdir; 3138 3139 # adding System integration files 3140 3141 my $sourcefile = ""; 3142 3143 # Finding the modules defined in scp (with flag SYSTEMMODULE) 3144 # Getting name of package from scp-Module 3145 # Search package in list off all include files 3146 # Copy file into installation set and unpack it (always tar.gz) 3147 # Create xpd file and put it into xpd directory 3148 # tar.gz can contain a different number of packages -> automatically create hidden sub modules 3149 # xpd file has to be created completely from module and package itself (-> no packagelist!) 3150 3151 # Collect all modules with flag "SYSTEMMODULE" 3152 my $allmodules = collect_modules_with_style("SYSTEMMODULE", $modulesarrayref); 3153 $allmodules = remove_modules_without_package($allmodules); 3154 3155 for ( my $i = 0; $i <= $#{$allmodules}; $i++ ) 3156 { 3157 my $onemodule = ${$allmodules}[$i]; 3158 my $packagetarfilename = $onemodule->{'PackageName'}; 3159 3160 my $infoline = "Including into installation set: $packagetarfilename\n"; 3161 push( @installer::globals::logfileinfo, $infoline); 3162 3163 my $sourcepathref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packagetarfilename, $includepatharrayref, 1); 3164 if ( $$sourcepathref eq "" ) { installer::exiter::exit_program("ERROR: Source path not found for $packagetarfilename!", "copy_systemintegration_files"); } 3165 3166 # Collecting all packages in directory "packages" or "RPMS" 3167 my $oldcontent = installer::systemactions::read_directory($destdir); 3168 3169 copy_and_unpack_tar_gz_files($$sourcepathref, $destdir); 3170 3171 # Finding new content -> that is the package name 3172 my ($newcontent, $allcontent ) = installer::systemactions::find_new_content_in_directory($destdir, $oldcontent); 3173 3174 # special handling, if new content is a directory 3175 my $subdir = ""; 3176 if ( ! $installer::globals::issolarispkgbuild ) { ($newcontent, $subdir) = control_subdirectories($newcontent); } 3177 3178 # Adding license content into Solaris packages 3179 if (( $installer::globals::issolarispkgbuild ) && ( $installer::globals::englishlicenseset ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} )) { installer::worker::add_license_into_systemintegrationpackages($destdir, $newcontent); } 3180 3181 if (( $installer::globals::isxpdplatform ) && ( $allvariables->{'XPDINSTALLER'} )) 3182 { 3183 installer::xpdinstaller::create_xpd_file_for_systemintegration($onemodule, $newcontent, $modulesarrayref, $subdir); 3184 } 3185 } 3186} 3187 3188###################################################### 3189# Analyzing the Unix installation path. 3190# From the installation path /opt/openofficeorg20 3191# is the part /opt relocatable and the part 3192# openofficeorg20 static. 3193###################################################### 3194 3195sub analyze_rootpath 3196{ 3197 my ($rootpath, $staticpathref, $relocatablepathref, $allvariables) = @_; 3198 3199 $rootpath =~ s/\/\s*$//; # removing ending slash 3200 3201 ############################################################## 3202 # Version 1: "/opt" is variable and "openofficeorg20" fixed 3203 ############################################################## 3204 3205 # my $staticpath = $rootpath; 3206 # installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$staticpath); 3207 # $$staticpathref = $staticpath; # will be "openofficeorg20" 3208 3209 # my $relocatablepath = $rootpath; 3210 # installer::pathanalyzer::get_path_from_fullqualifiedname(\$relocatablepath); 3211 # $$relocatablepathref = $relocatablepath; # will be "/opt/" 3212 3213 ############################################################## 3214 # Version 2: "/opt/openofficeorg20" is variable and "" fixed 3215 ############################################################## 3216 3217 # if ( $$relocatablepathref eq "" ) # relocatablepath is not defined in package list 3218 # { 3219 # $$staticpathref = ""; # will be "" 3220 # $$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/openofficeorg20/" 3221 # # setting the static path to the hostname of the directory with style OFFICEDIRECTORY 3222 # if ( $allvariables->{'SETSTATICPATH'} ) { $$staticpathref = $installer::globals::officedirhostname; } 3223 # 3224 # } 3225 # else # relocatablepath is defined in package list 3226 # { 3227 # $$relocatablepathref =~ s/\/\s*$//; # removing ending slash 3228 # $$relocatablepathref = $$relocatablepathref . "\/"; # relocatable path must end with "/" 3229 # my $staticpath = $rootpath; 3230 # $staticpath =~ s/\Q$$relocatablepathref\E//; 3231 # $staticpath =~ s/\/\s*$//; 3232 # $$staticpathref = $staticpath; 3233 # } 3234 3235 ############################################################## 3236 # Version 3: "/" is variable and "/opt/openofficeorg20" fixed 3237 ############################################################## 3238 3239 $$relocatablepathref = "/"; 3240 # Static path has to contain the office directory name. This is replaced in shellscripts. 3241 $$staticpathref = $rootpath . $installer::globals::separator . $installer::globals::officedirhostname; 3242 # For RPM version 3.x it is required, that Prefix is not "/" in spec file. In this case --relocate will not work, 3243 # because RPM 3.x says, that the package is not relocatable. Therefore we have to use Prefix=/opt and for 3244 # all usages of --relocate this path has to be on both sides of the "=": --relocate /opt=<myselectdir>/opt . 3245 if ( $installer::globals::islinuxrpmbuild ) 3246 { 3247 $$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/" 3248 $$staticpathref = $installer::globals::officedirhostname; # to be used as replacement in shell scripts 3249 } 3250 3251 if ( $installer::globals::islinuxdebbuild ) 3252 { 3253 $$relocatablepathref = ""; 3254 # $$staticpathref is already "/opt/openoffice.org3", no additional $rootpath required. 3255 # $$staticpathref = $rootpath . $installer::globals::separator . $$staticpathref; # no relocatibility for Debian 3256 } 3257 3258} 3259 3260###################################################### 3261# Including license and readme into 3262# Unix installation sets. 3263###################################################### 3264 3265sub put_installsetfiles_into_installset 3266{ 3267 my ($destdir) = @_; 3268 3269 # All files for the installation set are saved in the global 3270 # array @installer::globals::installsetfiles 3271 3272 for ( my $i = 0; $i <= $#installer::globals::installsetfiles; $i++ ) 3273 { 3274 my $onefile = $installer::globals::installsetfiles[$i]; 3275 my $sourcefile = $onefile->{'sourcepath'}; 3276 my $destfile = ""; 3277 if ( $installer::globals::addjavainstaller ) { $destfile = $onefile->{'Name'}; } 3278 else { $destfile = $destdir . $installer::globals::separator . $onefile->{'Name'}; } 3279 installer::systemactions::copy_one_file($sourcefile, $destfile); 3280 3281 my $infoline = "Adding to installation set \"$destfile\" from source \"$sourcefile\".\n"; 3282 push( @installer::globals::logfileinfo, $infoline); 3283 } 3284} 3285 3286###################################################### 3287# Replacing one variable in patchinfo file 3288###################################################### 3289 3290sub replace_one_variable_in_file 3291{ 3292 my ( $file, $placeholder, $value ) = @_; 3293 3294 for ( my $i = 0; $i <= $#{$file}; $i++ ) 3295 { 3296 ${$file}[$i] =~ s/$placeholder/$value/g; 3297 } 3298} 3299 3300###################################################### 3301# Setting variables in the patchinfo file 3302###################################################### 3303 3304sub set_patchinfo 3305{ 3306 my ( $patchinfofile, $patchid, $allvariables ) = @_; 3307 3308 # Setting: PATCHIDPLACEHOLDER and ARCHITECTUREPLACEHOLDER and PATCHCORRECTSPLACEHOLDER 3309 3310 replace_one_variable_in_file($patchinfofile, "PATCHIDPLACEHOLDER", $patchid); 3311 3312 my $architecture = ""; 3313 if ( $installer::globals::issolarissparcbuild ) { $architecture = "sparc"; } 3314 if ( $installer::globals::issolarisx86build ) { $architecture = "i386"; } 3315 3316 replace_one_variable_in_file($patchinfofile, "ARCHITECTUREPLACEHOLDER", $architecture); 3317 3318 if ( ! $allvariables->{'SOLARISPATCHCORRECTS'} ) { installer::exiter::exit_program("ERROR: No setting for PATCH_CORRECTS in zip list file!", "set_patchinfo"); } 3319 my $patchcorrects = $allvariables->{'SOLARISPATCHCORRECTS'}; 3320 3321 replace_one_variable_in_file($patchinfofile, "PATCHCORRECTSPLACEHOLDER", $patchcorrects); 3322 3323 # Setting also PATCH_REQUIRES in patch info file, if entry in zip list file exists 3324 my $requiresstring = ""; 3325 if ( $installer::globals::issolarissparcbuild ) { $requiresstring = "SOLSPARCPATCHREQUIRES"; } 3326 if ( $installer::globals::issolarisx86build ) { $requiresstring = "SOLIAPATCHREQUIRES"; } 3327 3328 if ( $allvariables->{$requiresstring} ) 3329 { 3330 my $newline = "PATCH_REQUIRES=\"" . $allvariables->{$requiresstring} . "\"" . "\n"; 3331 push(@{$patchinfofile}, $newline); 3332 } 3333} 3334 3335###################################################### 3336# Finalizing patch: Renaming directory and 3337# including additional patch files. 3338###################################################### 3339 3340sub finalize_patch 3341{ 3342 my ( $newepmdir, $allvariables ) = @_; 3343 3344 my $patchidname = "SOLSPARCPATCHID"; 3345 if ( $installer::globals::issolarisx86build ) { $patchidname = "SOLIAPATCHID"; } 3346 3347 if ( ! $allvariables->{$patchidname} ) { installer::exiter::exit_program("ERROR: Variable $patchidname not defined in zip list file!", "finalize_patch"); } 3348 my $patchid = $allvariables->{$patchidname}; 3349 installer::systemactions::rename_directory($newepmdir, $patchid); 3350 3351 # Copying all typical patch files into the patch directory 3352 # All patch file names are stored in @installer::globals::solarispatchfiles 3353 # Location of the file is $installer::globals::patchincludepath 3354 3355 my $sourcepath = $installer::globals::patchincludepath; 3356 $sourcepath =~ s/\/\s*$//; 3357 3358 for ( my $i = 0; $i <= $#installer::globals::solarispatchfiles; $i++ ) 3359 { 3360 my $sourcefile = $sourcepath . $installer::globals::separator . $installer::globals::solarispatchfiles[$i]; 3361 my $destfile = $patchid . $installer::globals::separator . $installer::globals::solarispatchfiles[$i]; 3362 installer::systemactions::copy_one_file($sourcefile, $destfile); 3363 } 3364 3365 # And editing the patchinfo file 3366 3367 my $patchinfofilename = $patchid . $installer::globals::separator . "patchinfo"; 3368 my $patchinfofile = installer::files::read_file($patchinfofilename); 3369 set_patchinfo($patchinfofile, $patchid, $allvariables); 3370 installer::files::save_file($patchinfofilename, $patchinfofile); 3371} 3372 3373###################################################### 3374# Finalizing Linux patch: Renaming directory and 3375# including additional patch files. 3376###################################################### 3377 3378sub finalize_linux_patch 3379{ 3380 my ( $newepmdir, $allvariables, $includepatharrayref ) = @_; 3381 3382 # Copying the setup into the patch directory 3383 # and including the list of RPMs into it 3384 3385 print "... creating patch setup ...\n"; 3386 3387 installer::logger::include_header_into_logfile("Creating Linux patch setup:"); 3388 3389 # find and read setup script template 3390 3391 my $scriptfilename = "linuxpatchscript.sh"; 3392 my $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptfilename, $includepatharrayref, 0); 3393 if ($$scriptref eq "") { installer::exiter::exit_program("ERROR: Could not find patch script template $scriptfilename!", "finalize_linux_patch"); } 3394 my $scriptfile = installer::files::read_file($$scriptref); 3395 3396 my $infoline = "Found script file $scriptfilename: $$scriptref \n"; 3397 push( @installer::globals::logfileinfo, $infoline); 3398 3399 # Collecting all RPMs in the patch directory 3400 3401 my $fileextension = "rpm"; 3402 my $rpmfiles = installer::systemactions::find_file_with_file_extension($fileextension, $newepmdir); 3403 if ( ! ( $#{$rpmfiles} > -1 )) { installer::exiter::exit_program("ERROR: Could not find rpm in directory $newepmdir!", "finalize_linux_patch"); } 3404 for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ ) { installer::pathanalyzer::make_absolute_filename_to_relative_filename(\${$rpmfiles}[$i]); } 3405 3406# my $installline = ""; 3407# 3408# for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ ) 3409# { 3410# $installline = $installline . " rpm --prefix \$PRODUCTINSTALLLOCATION -U $newepmdir/${$rpmfiles}[$i]\n"; 3411# } 3412# 3413# $installline =~ s/\s*$//; 3414# 3415# for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) 3416# { 3417# ${$scriptfile}[$j] =~ s/INSTALLLINES/$installline/; 3418# } 3419 3420 # Searching packagename containing -core01 3421 my $found_package = 0; 3422 my $searchpackagename = ""; 3423 for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ ) 3424 { 3425 if ( ${$rpmfiles}[$i] =~ /-core01-/ ) 3426 { 3427 $searchpackagename = ${$rpmfiles}[$i]; 3428 $found_package = 1; 3429 if ( $searchpackagename =~ /^\s*(.*?-core01)-.*/ ) { $searchpackagename = $1; } 3430 last; 3431 } 3432 } 3433 3434 if ( ! $found_package ) { installer::exiter::exit_program("ERROR: No package containing \"-core01\" found in directory \"$newepmdir\"", "finalize_linux_patch"); } 3435 3436 # Replacing the searchpackagename 3437 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/SEARCHPACKAGENAMEPLACEHOLDER/$searchpackagename/; } 3438 3439 # Setting the PRODUCTDIRECTORYNAME to $installer::globals::officedirhostname 3440 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/PRODUCTDIRECTORYNAME/$installer::globals::officedirhostname/; } 3441 3442 # Replacing the productname 3443 my $productname = $allvariables->{'PRODUCTNAME'}; 3444 $productname = lc($productname); 3445 $productname =~ s/ /_/g; # abc office -> abc_office 3446# $productname =~ s/\.//g; # openoffice.org -> openofficeorg 3447 3448 $infoline = "Adding productname $productname into Linux patch script\n"; 3449 push( @installer::globals::logfileinfo, $infoline); 3450 3451 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/PRODUCTNAMEPLACEHOLDER/$productname/; } 3452 3453 # Saving the file 3454 3455 my $newscriptfilename = "setup"; # $newepmdir . $installer::globals::separator . "setup"; 3456 installer::files::save_file($newscriptfilename, $scriptfile); 3457 3458 $infoline = "Saved Linux patch setup $newscriptfilename \n"; 3459 push( @installer::globals::logfileinfo, $infoline); 3460 3461 # Setting unix rights 755 3462 my $localcall = "chmod 775 $newscriptfilename \>\/dev\/null 2\>\&1"; 3463 system($localcall); 3464} 3465 34661; 3467