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 $verboseflag = "-v"; 947 if ( ! $installer::globals::quiet ) { $verboseflag = "-v2"; }; 948 949 my $systemcall = $ldpreloadstring . $epmname . " -f " . $packageformat . " " . $extraflags . " " . $localpackagename . " " . $epmlistfilename . $outdirstring . " " . $verboseflag . " " . " 2\>\&1 |"; 950 951 installer::logger::print_message( "... $systemcall ...\n" ); 952 953 my $maxepmcalls = 3; 954 955 for ( my $i = 1; $i <= $maxepmcalls; $i++ ) 956 { 957 my @epmoutput = (); 958 959 open (EPM, "$systemcall"); 960 while (<EPM>) {push(@epmoutput, $_); } 961 close (EPM); 962 963 my $returnvalue = $?; # $? contains the return value of the systemcall 964 965 my $infoline = "Systemcall (Try $i): $systemcall\n"; 966 push( @installer::globals::logfileinfo, $infoline); 967 968 for ( my $j = 0; $j <= $#epmoutput; $j++ ) 969 { 970 if ( $i < $maxepmcalls ) { $epmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; } 971 push( @installer::globals::logfileinfo, "$epmoutput[$j]"); 972 } 973 974 if ($returnvalue) 975 { 976 $infoline = "Try $i : Could not execute \"$systemcall\"!\n"; 977 push( @installer::globals::logfileinfo, $infoline); 978 if ( $i == $maxepmcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "call_epm"); } 979 } 980 else 981 { 982 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" ); 983 $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 984 push( @installer::globals::logfileinfo, $infoline); 985 last; 986 } 987 } 988} 989 990##################################################################### 991# Adding the new line for relocatables into pkginfo file (Solaris) 992# or spec file (Linux) created by epm 993##################################################################### 994 995sub add_one_line_into_file 996{ 997 my ($file, $insertline, $filename) = @_; 998 999 if ( $installer::globals::issolarispkgbuild ) 1000 { 1001 push(@{$file}, $insertline); # simply adding at the end of pkginfo file 1002 } 1003 1004 if ( $installer::globals::islinuxrpmbuild ) 1005 { 1006 # Adding behind the line beginning with: Group: 1007 1008 my $inserted_line = 0; 1009 1010 for ( my $i = 0; $i <= $#{$file}; $i++ ) 1011 { 1012 if ( ${$file}[$i] =~ /^\s*Group\:\s*/ ) 1013 { 1014 splice(@{$file},$i+1,0,$insertline); 1015 $inserted_line = 1; 1016 last; 1017 } 1018 } 1019 1020 if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "add_one_line_into_file"); } 1021 } 1022 1023 $insertline =~ s/\s*$//; # removing line end for correct logging 1024 my $infoline = "Success: Added line $insertline into file $filename!\n"; 1025 push( @installer::globals::logfileinfo, $infoline); 1026} 1027 1028##################################################################### 1029# Setting the revision VERSION=1.9,REV=66 . 1030# Also adding the new line: "AutoReqProv: no" 1031##################################################################### 1032 1033sub set_revision_in_pkginfo 1034{ 1035 my ($file, $filename, $variables, $packagename) = @_; 1036 1037 my $revisionstring = "\,REV\=" . $installer::globals::packagerevision; 1038 1039 # Adding also a time string to the revision. Syntax: VERSION=8.0.0,REV=66.2005.01.24 1040 1041 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); 1042 1043 $mday = $mday; 1044 $mon = $mon + 1; 1045 $year = $year + 1900; 1046 1047 if ( $mday < 10 ) { $mday = "0" . $mday; } 1048 if ( $mon < 10 ) { $mon = "0" . $mon; } 1049 $datestring = $year . "." . $mon . "." . $mday; 1050 $revisionstring = $revisionstring . "." . $datestring; 1051 1052 for ( my $i = 0; $i <= $#{$file}; $i++ ) 1053 { 1054 if ( ${$file}[$i] =~ /^\s*(VERSION\=.*?)\s*$/ ) 1055 { 1056 my $oldstring = $1; 1057 my $newstring = $oldstring . $revisionstring; # also adding the date string 1058 ${$file}[$i] =~ s/$oldstring/$newstring/; 1059 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n"; 1060 push( @installer::globals::logfileinfo, $infoline); 1061 last; 1062 } 1063 } 1064 1065 # For Update and Patch reasons, this string can also be kept constant 1066 1067 my $pkgversion = "SOLSPARCPKGVERSION"; 1068 if ( $installer::globals::issolarisx86build ) { $pkgversion = "SOLIAPKGVERSION"; } 1069 1070 if (( $variables->{$pkgversion} ) && ( $variables->{$pkgversion} ne "" )) 1071 { 1072 if ( $variables->{$pkgversion} ne "FINALVERSION" ) 1073 { 1074 # In OOo 3.x timeframe, this string is no longer unique for all packages, because of the three layer. 1075 # 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 1076 # and therefore be set as $pkgversion. 1077 # The first part "3.0.0" has to be derived from the 1078 1079 my $version = $installer::globals::packageversion; 1080 if ( $version =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ ) 1081 { 1082 my $major = $1; 1083 my $minor = $2; 1084 my $micro = $3; 1085 1086 my $finalmajor = $major; 1087 my $finalminor = $minor; 1088 my $finalmicro = 0; 1089 1090 # if (( $packagename =~ /-ure\s*$/ ) && ( $finalmajor == 1 )) { $finalminor = 4; } 1091 1092 $version = "$finalmajor.$finalminor.$finalmicro"; 1093 } 1094 1095 my $datestring = $variables->{$pkgversion}; 1096 1097 # Allowing some packages to have another date of creation. 1098 # They can be defined in product definition using a key like "SOLSPARCPKGVERSION_$packagename" 1099 1100 my $additionalkey = $pkgversion . "_" . $packagename; 1101 if (( $variables->{$additionalkey} ) && ( $variables->{$additionalkey} ne "" )) { $datestring = $variables->{$additionalkey}; } 1102 1103 my $versionstring = "$version,$datestring"; 1104 1105 for ( my $i = 0; $i <= $#{$file}; $i++ ) 1106 { 1107 if ( ${$file}[$i] =~ /^\s*(VERSION\=).*?\s*$/ ) 1108 { 1109 my $start = $1; 1110 my $newstring = $start . $versionstring . "\n"; # setting the complete new string 1111 my $oldstring = ${$file}[$i]; 1112 ${$file}[$i] = $newstring; 1113 $oldstring =~ s/\s*$//; 1114 $newstring =~ s/\s*$//; 1115 my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n"; 1116 push( @installer::globals::logfileinfo, $infoline); 1117 last; 1118 } 1119 } 1120 } 1121 } 1122} 1123 1124######################################################## 1125# Setting Patch information for Respin versions 1126# into pkginfo file. This prevents Respin versions 1127# from patching. 1128######################################################## 1129 1130sub set_patchlist_in_pkginfo_for_respin 1131{ 1132 my ($changefile, $filename, $allvariables, $packagename) = @_; 1133 1134 my $patchlistname = "SOLSPARCPATCHLISTFORRESPIN"; 1135 if ( $installer::globals::issolarisx86build ) { $patchlistname = "SOLIAPATCHLISTFORRESPIN"; } 1136 1137 if ( $allvariables->{$patchlistname} ) 1138 { 1139 # patchlist separator is a blank 1140 my $allpatchesstring = $allvariables->{$patchlistname}; 1141 my @usedpatches = (); 1142 1143 # Analyzing the patchlist 1144 # Syntax: 120186-10 126411-01(+core-01) -> use 126411-01 only for core-01 1145 # Syntax: 120186-10 126411-01(-core-01) -> use 126411-01 for all packages except for core-01 1146 my $allpatches = installer::converter::convert_whitespace_stringlist_into_array(\$allpatchesstring); 1147 1148 for ( my $i = 0; $i <= $#{$allpatches}; $i++ ) 1149 { 1150 my $patchdefinition = ${$allpatches}[$i]; 1151 1152 my $patchid = ""; 1153 my $symbol = ""; 1154 my $constraint = ""; 1155 my $isusedpatch = 0; 1156 1157 if ( $patchdefinition =~ /^\s*(.+)\(([+-])(.+)\)\s*$/ ) 1158 { 1159 $patchid = $1; 1160 $symbol = $2; 1161 $constraint = $3; 1162 } 1163 elsif (( $patchdefinition =~ /\(/ ) || ( $patchdefinition =~ /\)/ )) # small syntax check 1164 { 1165 # if there is a bracket in the $patchdefinition, but it does not 1166 # match the if-condition, this is an erroneous definition. 1167 installer::exiter::exit_program("ERROR: Unknown patch string: $patchdefinition", "set_patchlist_in_pkginfo_for_respin"); 1168 } 1169 else 1170 { 1171 $patchid = $patchdefinition; 1172 $isusedpatch = 1; # patches without constraint are always included 1173 } 1174 1175 if ( $symbol ne "" ) 1176 { 1177 if ( $symbol eq "+" ) 1178 { 1179 if ( $packagename =~ /^.*\Q$constraint\E\s*$/ ) { $isusedpatch = 1; } 1180 } 1181 1182 if ( $symbol eq "-" ) 1183 { 1184 if ( ! ( $packagename =~ /^.*\Q$constraint\E\s*$/ )) { $isusedpatch = 1; } 1185 } 1186 } 1187 1188 if ( $isusedpatch ) { push(@usedpatches, $patchid); } 1189 } 1190 1191 if ( $#usedpatches > -1 ) 1192 { 1193 my $patchstring = installer::converter::convert_array_to_space_separated_string(\@usedpatches); 1194 1195 my $newline = "PATCHLIST=" . $patchstring . "\n"; 1196 add_one_line_into_file($changefile, $newline, $filename); 1197 1198 # Adding patch info for each used patch in the patchlist 1199 1200 for ( my $i = 0; $i <= $#usedpatches; $i++ ) 1201 { 1202 my $patchid = $usedpatches[$i]; 1203 my $key = "PATCH_INFO_" . $patchid; 1204 $key =~ s/\s*$//; 1205 1206 if ( ! $allvariables->{$key} ) { installer::exiter::exit_program("ERROR: No Patch info available in zip list file for $key", "set_patchlist_in_pkginfo"); } 1207 my $value = set_timestamp_in_patchinfo($allvariables->{$key}); 1208 $newline = $key . "=" . $value . "\n"; 1209 1210 add_one_line_into_file($changefile, $newline, $filename); 1211 } 1212 } 1213 } 1214} 1215 1216######################################################## 1217# Solaris requires, that the time of patch installation 1218# must not be empty. 1219# Format: Mon Mar 24 11:20:56 PDT 2008 1220# Log file: Tue Apr 29 23:26:19 2008 (04:31 min.) 1221# Replace string: ${TIMESTAMP} 1222######################################################## 1223 1224sub set_timestamp_in_patchinfo 1225{ 1226 my ($value) = @_; 1227 1228 my $currenttime = localtime(); 1229 1230 if ( $currenttime =~ /^\s*(.+?)(\d\d\d\d)\s*$/ ) 1231 { 1232 my $start = $1; 1233 my $year = $2; 1234 $currenttime = $start . "CET " . $year; 1235 } 1236 1237 $value =~ s/\$\{TIMESTAMP\}/$currenttime/; 1238 1239 return $value; 1240} 1241 1242######################################################## 1243# Setting MAXINST=1000 into the pkginfo file. 1244######################################################## 1245 1246sub set_maxinst_in_pkginfo 1247{ 1248 my ($changefile, $filename) = @_; 1249 1250 my $newline = "MAXINST\=1000\n"; 1251 1252 add_one_line_into_file($changefile, $newline, $filename); 1253} 1254 1255############################################################# 1256# Setting several Solaris variables into the pkginfo file. 1257############################################################# 1258 1259sub set_solaris_parameter_in_pkginfo 1260{ 1261 my ($changefile, $filename, $allvariables) = @_; 1262 1263 my $newline = ""; 1264 1265 # SUNW_PRODNAME 1266 # SUNW_PRODVERS 1267 # SUNW_PKGVERS 1268 # Not: SUNW_PKGTYPE 1269 # HOTLINE 1270 # EMAIL 1271 1272 my $productname = $allvariables->{'PRODUCTNAME'}; 1273 $newline = "SUNW_PRODNAME=$productname\n"; 1274 add_one_line_into_file($changefile, $newline, $filename); 1275 1276 my $productversion = ""; 1277 if ( $allvariables->{'PRODUCTVERSION'} ) 1278 { 1279 $productversion = $allvariables->{'PRODUCTVERSION'}; 1280 if ( $allvariables->{'PRODUCTEXTENSION'} ) { $productversion = $productversion . "/" . $allvariables->{'PRODUCTEXTENSION'}; } 1281 } 1282 $newline = "SUNW_PRODVERS=$productversion\n"; 1283 add_one_line_into_file($changefile, $newline, $filename); 1284 1285 $newline = "SUNW_PKGVERS=1\.0\n"; 1286 add_one_line_into_file($changefile, $newline, $filename); 1287 1288 if ( $allvariables->{'SUNW_PKGTYPE'} ) 1289 { 1290 $newline = "SUNW_PKGTYPE=$allvariables->{'SUNW_PKGTYPE'}\n"; 1291 add_one_line_into_file($changefile, $newline, $filename); 1292 } 1293 else 1294 { 1295 $newline = "SUNW_PKGTYPE=\n"; 1296 add_one_line_into_file($changefile, $newline, $filename); 1297 } 1298 1299 $newline = "HOTLINE=Please contact your local service provider\n"; 1300 add_one_line_into_file($changefile, $newline, $filename); 1301 1302 $newline = "EMAIL=\n"; 1303 add_one_line_into_file($changefile, $newline, $filename); 1304 1305} 1306 1307##################################################################### 1308# epm uses as archtecture for Solaris x86 "i86pc". This has to be 1309# changed to "i386". 1310##################################################################### 1311 1312sub fix_architecture_setting 1313{ 1314 my ($changefile) = @_; 1315 1316 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1317 { 1318 if ( ${$changefile}[$i] =~ /^\s*ARCH=i86pc\s*$/ ) 1319 { 1320 ${$changefile}[$i] =~ s/i86pc/i386/; 1321 last; 1322 } 1323 1324 } 1325} 1326 1327##################################################################### 1328# Adding a new line for topdir into specfile, removing old 1329# topdir if set. 1330##################################################################### 1331 1332sub set_topdir_in_specfile 1333{ 1334 my ($changefile, $filename, $newepmdir) = @_; 1335 1336 # $newepmdir =~ s/^\s*\.//; # removing leading "." 1337 $newepmdir = cwd() . $installer::globals::separator . $newepmdir; # only absolute path allowed 1338 1339 # removing "%define _topdir", if existing 1340 1341 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1342 { 1343 if ( ${$changefile}[$i] =~ /^\s*\%define _topdir\s+/ ) 1344 { 1345 my $removeline = ${$changefile}[$i]; 1346 $removeline =~ s/\s*$//; 1347 splice(@{$changefile},$i,1); 1348 my $infoline = "Info: Removed line \"$removeline\" from file $filename!\n"; 1349 push( @installer::globals::logfileinfo, $infoline); 1350 last; 1351 } 1352 } 1353 1354 # Adding "topdir" behind the line beginning with: Group: 1355 1356 my $inserted_line = 0; 1357 1358 my $topdirline = "\%define _topdir $newepmdir\n"; 1359 1360 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1361 { 1362 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ ) 1363 { 1364 splice(@{$changefile},$i+1,0,$topdirline); 1365 $inserted_line = 1; 1366 $topdirline =~ s/\s*$//; 1367 my $infoline = "Success: Added line $topdirline into file $filename!\n"; 1368 push( @installer::globals::logfileinfo, $infoline); 1369 } 1370 } 1371 1372 if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "set_topdir_in_specfile"); } 1373 1374} 1375 1376##################################################################### 1377# Setting the packager in the spec file 1378# Syntax: Packager: abc@def 1379##################################################################### 1380 1381sub set_packager_in_specfile 1382{ 1383 my ($changefile) = @_; 1384 1385 my $packager = $installer::globals::longmanufacturer; 1386 1387 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1388 { 1389 if ( ${$changefile}[$i] =~ /^\s*Packager\s*:\s*(.+?)\s*$/ ) 1390 { 1391 my $oldstring = $1; 1392 ${$changefile}[$i] =~ s/\Q$oldstring\E/$packager/; 1393 my $infoline = "Info: Changed Packager in spec file from $oldstring to $packager!\n"; 1394 push( @installer::globals::logfileinfo, $infoline); 1395 last; 1396 } 1397 } 1398} 1399 1400##################################################################### 1401# Setting the requirements in the spec file (i81494) 1402# Syntax: PreReq: "requirements" (only for shared extensions) 1403##################################################################### 1404 1405sub set_prereq_in_specfile 1406{ 1407 my ($changefile) = @_; 1408 1409 my $prereq = "PreReq:"; 1410 1411 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1412 { 1413 if ( ${$changefile}[$i] =~ /^\s*Requires:\s*(.+?)\s*$/ ) 1414 { 1415 my $oldstring = ${$changefile}[$i]; 1416 ${$changefile}[$i] =~ s/Requires:/$prereq/; 1417 my $infoline = "Info: Changed requirements in spec file from $oldstring to ${$changefile}[$i]!\n"; 1418 push( @installer::globals::logfileinfo, $infoline); 1419 } 1420 } 1421} 1422 1423##################################################################### 1424# Setting the Auto[Req]Prov line and __find_requires 1425##################################################################### 1426 1427sub set_autoprovreq_in_specfile 1428{ 1429 my ($changefile, $findrequires, $bindir) = @_; 1430 1431 my $autoreqprovline; 1432 1433 if ( $findrequires ) 1434 { 1435 $autoreqprovline = "AutoProv\: no\n%define __find_requires $bindir/$findrequires\n"; 1436 } 1437 else 1438 { 1439 $autoreqprovline = "AutoReqProv\: no\n"; 1440 } 1441 1442 $autoreqprovline .= "%define _binary_filedigest_algorithm 1\n%define _binary_payload w9.gzdio\n"; 1443 1444 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1445 { 1446 # Adding "autoreqprov" behind the line beginning with: Group: 1447 if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ ) 1448 { 1449 splice(@{$changefile},$i+1,0,$autoreqprovline); 1450 $autoreqprovline =~ s/\s*$//; 1451 $infoline = "Success: Added line $autoreqprovline into spec file!\n"; 1452 push( @installer::globals::logfileinfo, $infoline); 1453 1454 last; 1455 } 1456 } 1457} 1458 1459##################################################################### 1460# Replacing Copyright with License in the spec file 1461# Syntax: License: LGPL, SISSL 1462##################################################################### 1463 1464sub set_license_in_specfile 1465{ 1466 my ($changefile, $variableshashref) = @_; 1467 1468 my $license = $variableshashref->{'LICENSENAME'}; 1469 1470 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1471 { 1472 if ( ${$changefile}[$i] =~ /^\s*Copyright\s*:\s*(.+?)\s*$/ ) 1473 { 1474 ${$changefile}[$i] = "License: $license\n"; 1475 my $infoline = "Info: Replaced Copyright with License: $license !\n"; 1476 push( @installer::globals::logfileinfo, $infoline); 1477 last; 1478 } 1479 } 1480} 1481 1482######################################################### 1483# Building relocatable Solaris packages means: 1484# 1. Add "BASEDIR=/opt" into pkginfo 1485# 2. Remove "/opt/" from all objects in prototype file 1486# For step2 this function exists 1487# Sample: d none /opt/openofficeorg20/help 0755 root other 1488# -> d none openofficeorg20/help 0755 root other 1489######################################################### 1490 1491sub make_prototypefile_relocatable 1492{ 1493 my ($prototypefile, $relocatablepath) = @_; 1494 1495 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ ) 1496 { 1497 if ( ${$prototypefile}[$i] =~ /^\s*\w\s+\w+\s+\/\w+/ ) # this is an object line 1498 { 1499 ${$prototypefile}[$i] =~ s/$relocatablepath//; # Important: $relocatablepath has a "/" at the end. Example "/opt/" 1500 } 1501 } 1502 1503 # If the $relocatablepath is "/opt/openoffice20/" the line "d none /opt/openoffice20" was not changed. 1504 # This line has to be removed now 1505 1506 if ( $relocatablepath ne "/" ) { $relocatablepath =~ s/\/\s*$//; } # removing the ending slash 1507 1508 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ ) 1509 { 1510 if ( ${$prototypefile}[$i] =~ /^\s*d\s+\w+\s+\Q$relocatablepath\E/ ) 1511 { 1512 my $line = ${$prototypefile}[$i]; 1513 splice(@{$prototypefile},$i,1); # removing the line 1514 $line =~ s/\s*$//; 1515 my $infoline = "Info: Removed line \"$line\" from prototype file!\n"; 1516 push( @installer::globals::logfileinfo, $infoline); 1517 last; 1518 } 1519 } 1520 1521 # Making "\$" to "$" in prototype file. "\$" was created by epm. 1522 1523 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ ) 1524 { 1525 if ( ${$prototypefile}[$i] =~ /\\\$/ ) 1526 { 1527 ${$prototypefile}[$i] =~ s/\\\$/\$/g; 1528 my $infoline2 = "Info: Changed line in prototype file: ${$prototypefile}[$i] !\n"; 1529 push( @installer::globals::logfileinfo, $infoline2); 1530 } 1531 } 1532} 1533 1534 1535######################################################################### 1536# In scp the flag VOLATEFILE can be used. This shall lead to style "v" 1537# in Solaris prototype file. This is not supported by epm and has 1538# therefore to be included in prototypefile, not in epm list file. 1539######################################################################### 1540 1541sub set_volatilefile_into_prototypefile 1542{ 1543 my ($prototypefile, $filesref) = @_; 1544 1545 for ( my $i = 0; $i <= $#{$filesref}; $i++ ) 1546 { 1547 my $onefile = ${$filesref}[$i]; 1548 1549 my $styles = ""; 1550 if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; } 1551 1552 if ( $styles =~ /\bVOLATILEFILE\b/ ) 1553 { 1554 my $sourcepath = $onefile->{'sourcepath'}; 1555 1556 for ( my $j = 0; $j <= $#{$prototypefile}; $j++ ) 1557 { 1558 if (( ${$prototypefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$prototypefile}[$j] =~ /\=\Q$sourcepath\E\s+/ )) 1559 { 1560 my $oldline = ${$prototypefile}[$j]; 1561 ${$prototypefile}[$j] =~ s/^\s*f/v/; 1562 my $newline = ${$prototypefile}[$j]; 1563 $oldline =~ s/\s*$//; 1564 $newline =~ s/\s*$//; 1565 my $infoline = "Volatile file: Changing content from \"$oldline\" to \"$newline\" .\n"; 1566 push(@installer::globals::logfileinfo, $infoline); 1567 last; 1568 } 1569 } 1570 } 1571 } 1572} 1573 1574######################################################################### 1575# Replacing the variables in the Solaris patch shell scripts. 1576# Taking care, that multiple slashes are not always removed. 1577######################################################################### 1578 1579sub replace_variables_in_shellscripts_for_patch 1580{ 1581 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_; 1582 1583 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 1584 { 1585 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ ) 1586 { 1587 my $oldline = ${$scriptfile}[$i]; 1588 if (( $oldstring eq "PRODUCTDIRECTORYNAME" ) && ( $newstring eq "" )) { $oldstring = $oldstring . "/"; } 1589 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g; 1590 my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n"; 1591 push(@installer::globals::logfileinfo, $infoline); 1592 } 1593 } 1594} 1595 1596######################################################################### 1597# Replacing the variables in the shell scripts or in the epm list file 1598# Linux: spec file 1599# Solaris: preinstall, postinstall, preremove, postremove 1600# If epm is used in the original version (not relocatable) 1601# the variables have to be exchanged in the list file, 1602# created for epm. 1603######################################################################### 1604 1605sub replace_variables_in_shellscripts 1606{ 1607 my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_; 1608 1609 my $debug = 0; 1610 if ( $oldstring eq "PRODUCTDIRECTORYNAME" ) { $debug = 1; } 1611 1612 for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) 1613 { 1614 if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ ) 1615 { 1616 my $oldline = ${$scriptfile}[$i]; 1617 ${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g; 1618 ${$scriptfile}[$i] =~ s/\/\//\//g; # replacing "//" by "/" , if path $newstring is empty! 1619 my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n"; 1620 push(@installer::globals::logfileinfo, $infoline); 1621 if ( $debug ) 1622 { 1623 $infoline = "Old Line: $oldline"; 1624 push(@installer::globals::logfileinfo, $infoline); 1625 $infoline = "New Line: ${$scriptfile}[$i]"; 1626 push(@installer::globals::logfileinfo, $infoline); 1627 } 1628 } 1629 } 1630} 1631 1632############################################################ 1633# Determinig the directory created by epm, in which the 1634# RPMS or Solaris packages are created. 1635############################################################ 1636 1637sub determine_installdir_ooo 1638{ 1639 # A simple "ls" command returns the directory name 1640 1641 my $dirname = ""; 1642 1643 my $systemcall = "ls |"; 1644 open (LS, "$systemcall"); 1645 $dirname = <LS>; 1646 close (LS); 1647 1648 $dirname =~ s/\s*$//; 1649 1650 my $infoline = "Info: Directory created by epm: $dirname\n"; 1651 push(@installer::globals::logfileinfo, $infoline); 1652 1653 return $dirname; 1654} 1655 1656############################################################ 1657# Setting the tab content into the file container 1658############################################################ 1659 1660sub set_tab_into_datafile 1661{ 1662 my ($changefile, $filesref) = @_; 1663 1664 my @newclasses = (); 1665 my $newclassesstring = ""; 1666 1667 if ( $installer::globals::issolarispkgbuild ) 1668 { 1669 for ( my $i = 0; $i <= $#{$filesref}; $i++ ) 1670 { 1671 my $onefile = ${$filesref}[$i]; 1672 1673 if ( $onefile->{'SolarisClass'} ) 1674 { 1675 my $sourcepath = $onefile->{'sourcepath'}; 1676 1677 for ( my $j = 0; $j <= $#{$changefile}; $j++ ) 1678 { 1679 if (( ${$changefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$changefile}[$j] =~ /\=\Q$sourcepath\E\s+/ )) 1680 { 1681 my $oldline = ${$changefile}[$j]; 1682 ${$changefile}[$j] =~ s/f\s+none/e $onefile->{'SolarisClass'}/; 1683 my $newline = ${$changefile}[$j]; 1684 $oldline =~ s/\s*$//; 1685 $newline =~ s/\s*$//; 1686 1687 my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n"; 1688 push(@installer::globals::logfileinfo, $infoline); 1689 1690 # collecting all new classes 1691 if (! installer::existence::exists_in_array($onefile->{'SolarisClass'}, \@newclasses)) 1692 { 1693 push(@newclasses, $onefile->{'SolarisClass'}); 1694 } 1695 1696 last; 1697 } 1698 } 1699 } 1700 } 1701 1702 $newclassesstring = installer::converter::convert_array_to_space_separated_string(\@newclasses); 1703 } 1704 1705 if ( $installer::globals::islinuxrpmbuild ) 1706 { 1707 for ( my $i = 0; $i <= $#{$filesref}; $i++ ) 1708 { 1709 my $onefile = ${$filesref}[$i]; 1710 1711 if ( $onefile->{'SpecFileContent'} ) 1712 { 1713 my $destination = $onefile->{'destination'}; 1714 1715 for ( my $j = 0; $j <= $#{$changefile}; $j++ ) 1716 { 1717 if ( ${$changefile}[$j] =~ /^\s*(\%attr\(.*\))\s+(\".*?\Q$destination\E\"\s*)$/ ) 1718 { 1719 my $begin = $1; 1720 my $end = $2; 1721 1722 my $oldline = ${$changefile}[$j]; 1723 ${$changefile}[$j] = $begin . " " . $onefile->{'SpecFileContent'} . " " . $end; 1724 my $newline = ${$changefile}[$j]; 1725 1726 $oldline =~ s/\s*$//; 1727 $newline =~ s/\s*$//; 1728 1729 my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n"; 1730 push(@installer::globals::logfileinfo, $infoline); 1731 1732 last; 1733 } 1734 } 1735 } 1736 } 1737 } 1738 1739 return $newclassesstring; 1740} 1741 1742############################################################ 1743# Including additional classes into the pkginfo file 1744############################################################ 1745 1746sub include_classes_into_pkginfo 1747{ 1748 my ($changefile, $classesstring) = @_; 1749 1750 for ( my $i = 0; $i <= $#{$changefile}; $i++ ) 1751 { 1752 if ( ${$changefile}[$i] =~ /^\s*CLASSES\=none/ ) 1753 { 1754 ${$changefile}[$i] =~ s/\s*$//; 1755 my $oldline = ${$changefile}[$i]; 1756 ${$changefile}[$i] = ${$changefile}[$i] . " " . $classesstring . "\n"; 1757 my $newline = ${$changefile}[$i]; 1758 $newline =~ s/\s*$//; 1759 1760 my $infoline = "pkginfo file: Changing content from \"$oldline\" to \"$newline\" .\n"; 1761 push(@installer::globals::logfileinfo, $infoline); 1762 } 1763 } 1764} 1765 1766########################################################################################## 1767# Checking, if an extension is included into the package (Linux). 1768# All extension files have to be installed into directory 1769# share/extension/install 1770# %attr(0444,root,root) "/opt/staroffice8/share/extension/install/SunSearchToolbar.oxt" 1771########################################################################################## 1772 1773sub is_extension_package 1774{ 1775 my ($specfile) = @_; 1776 1777 my $is_extension_package = 0; 1778 1779 for ( my $i = 0; $i <= $#{$specfile}; $i++ ) 1780 { 1781 my $line = ${$specfile}[$i]; 1782 if ( $line =~ /share\/extension\/install\/.*?\.oxt\"\s*$/ ) 1783 { 1784 $is_extension_package = 1; 1785 last; 1786 } 1787 } 1788 1789 return $is_extension_package; 1790} 1791 1792###################################################################### 1793# Checking, if an extension is included into the package (Solaris). 1794# All extension files have to be installed into directory 1795# share/extension/install 1796###################################################################### 1797 1798sub contains_extension_dir 1799{ 1800 my ($prototypefile) = @_; 1801 1802 my $contains_extension_dir = 0; 1803 1804 # d none opt/openoffice.org3/share/extensions/ 1805 1806 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ ) 1807 { 1808 my $line = ${$prototypefile}[$i]; 1809 if ( $line =~ /^\s*d\s+none\s.*\/share\/extensions\// ) 1810 { 1811 $contains_extension_dir = 1; 1812 last; 1813 } 1814 } 1815 1816 return $contains_extension_dir; 1817} 1818 1819############################################################ 1820# A Solaris patch contains 7 specific scripts 1821############################################################ 1822 1823sub add_scripts_into_prototypefile 1824{ 1825 my ($prototypefile, $prototypefilename, $languagestringref, $staticpath) = @_; 1826 1827 # The files are stored in the directory $installer::globals::patchincludepath 1828 # The file names are available via @installer::globals::solarispatchscripts 1829 1830 my $path = $installer::globals::patchincludepath; 1831 $path =~ s/\/\s*$//; 1832 $path = $path . $installer::globals::separator; 1833 1834 my @newlines = (); 1835 my $is_extension_package = contains_extension_dir($prototypefile); 1836 1837 if ( $is_extension_package ) 1838 { 1839 for ( my $i = 0; $i <= $#installer::globals::solarispatchscriptsforextensions; $i++ ) 1840 { 1841 my $sourcefilename = $path . $installer::globals::solarispatchscriptsforextensions[$i]; 1842 my $destfile = $installer::globals::solarispatchscriptsforextensions[$i]; 1843 1844 # If the sourcepath has "_extension" in its name, this has to be removed 1845 $destfile =~ s/_extensions\s*$//; # hard coded renaming of script name 1846 1847 # Creating unique directory name with $prototypefilename 1848 my $extensiondir = installer::systemactions::create_directories("extensionscripts", $languagestringref); 1849 1850 if ( $prototypefilename =~ /\/(\S*?)\s*$/ ) { $prototypefilename = $1; } 1851 $prototypefilename =~ s/\./_/g; 1852 my $destdir = $extensiondir . $installer::globals::separator . $prototypefilename; 1853 if ( ! -d $destdir ) { installer::systemactions::create_directory($destdir); } 1854 my $destpath = $destdir . $installer::globals::separator . $destfile; 1855 if ( -f $destpath ) { unlink($destpath); } 1856 1857 # Reading file 1858 my $scriptfile = installer::files::read_file($sourcefilename); 1859 1860 # Replacing variables 1861 my $oldstring = "PRODUCTDIRECTORYNAME"; 1862 replace_variables_in_shellscripts_for_patch($scriptfile, $destpath, $oldstring, $staticpath); 1863 1864 # Saving file 1865 installer::files::save_file($destpath, $scriptfile); 1866 1867 # Writing file destination into prototype file 1868 my $line = "i $destfile=" . $destpath . "\n"; 1869 push(@newlines, $line); 1870 } 1871 } 1872 else 1873 { 1874 for ( my $i = 0; $i <= $#installer::globals::solarispatchscripts; $i++ ) 1875 { 1876 my $line = "i $installer::globals::solarispatchscripts[$i]=" . $path . $installer::globals::solarispatchscripts[$i] . "\n"; 1877 push(@newlines, $line); 1878 } 1879 } 1880 1881 # Including the new lines after the last line starting with "i" 1882 1883 for ( my $i = 0; $i <= $#{$prototypefile}; $i++ ) 1884 { 1885 if ( ${$prototypefile}[$i] =~ /^\s*i\s+copyright/ ) 1886 { 1887 splice(@{$prototypefile}, $i, 1); # ignoring old copyright text, using patch standard 1888 next; 1889 } 1890 if ( ${$prototypefile}[$i] =~ /^\s*i\s+/ ) { next; } 1891 splice(@{$prototypefile}, $i, 0, @newlines); 1892 last; 1893 } 1894} 1895 1896############################################################ 1897# Adding patch infos in pkginfo file 1898############################################################ 1899 1900sub include_patchinfos_into_pkginfo 1901{ 1902 my ( $changefile, $filename, $variableshashref ) = @_; 1903 1904 # SUNW_PATCHID=101998-10 1905 # SUNW_OBSOLETES=114999-01 113999-01 1906 # SUNW_PKGTYPE=usr 1907 # SUNW_PKGVERS=1.0 1908 # SUNW_REQUIRES=126411-01 1909 1910 my $patchidname = "SOLSPARCPATCHID"; 1911 if ( $installer::globals::issolarisx86build ) { $patchidname = "SOLIAPATCHID"; } 1912 1913 if ( ! $variableshashref->{$patchidname} ) { installer::exiter::exit_program("ERROR: Variable $patchidname not defined in zip list file!", "include_patchinfos_into_pkginfo"); } 1914 1915 my $newline = "SUNW_PATCHID=" . $variableshashref->{$patchidname} . "\n"; 1916 add_one_line_into_file($changefile, $newline, $filename); 1917 1918 my $patchobsoletesname = "SOLSPARCPATCHOBSOLETES"; 1919 if ( $installer::globals::issolarisx86build ) { $patchobsoletesname = "SOLIAPATCHOBSOLETES"; } 1920 1921 my $obsoletes = ""; 1922 if ( $variableshashref->{$patchobsoletesname} ) { $obsoletes = $variableshashref->{$patchobsoletesname}; } 1923 $newline = "SUNW_OBSOLETES=" . $obsoletes . "\n"; 1924 add_one_line_into_file($changefile, $newline, $filename); 1925 1926 my $patchrequiresname = "SOLSPARCPATCHREQUIRES"; 1927 if ( $installer::globals::issolarisx86build ) { $patchrequiresname = "SOLIAPATCHREQUIRES"; } 1928 1929 if ( $variableshashref->{$patchrequiresname} ) 1930 { 1931 my $requires = $variableshashref->{$patchrequiresname}; 1932 $newline = "SUNW_REQUIRES=" . $requires . "\n"; 1933 add_one_line_into_file($changefile, $newline, $filename); 1934 } 1935 $newline = "SUNW_PATCH_PROPERTIES=\n"; 1936 add_one_line_into_file($changefile, $newline, $filename); 1937 # $newline = "SUNW_PKGTYPE=usr\n"; 1938 # add_one_line_into_file($changefile, $newline, $filename); 1939 1940 # $newline = "SUNW_PKGVERS=1.0\n"; 1941 # add_one_line_into_file($changefile, $newline, $filename); 1942} 1943 1944############################################################ 1945# Setting the correct Solaris locales 1946############################################################ 1947 1948sub get_solaris_language_for_langpack 1949{ 1950 my ( $onelanguage ) = @_; 1951 1952 my $sollanguage = $onelanguage; 1953 $sollanguage =~ s/\-/\_/; 1954 1955 if ( $sollanguage eq "de" ) { $sollanguage = "de"; } 1956 elsif ( $sollanguage eq "en_US" ) { $sollanguage = "en_AU,en_CA,en_GB,en_IE,en_MT,en_NZ,en_US,en_US.UTF-8"; } 1957 elsif ( $sollanguage eq "es" ) { $sollanguage = "es"; } 1958 elsif ( $sollanguage eq "fr" ) { $sollanguage = "fr"; } 1959 elsif ( $sollanguage eq "hu" ) { $sollanguage = "hu_HU"; } 1960 elsif ( $sollanguage eq "it" ) { $sollanguage = "it"; } 1961 elsif ( $sollanguage eq "nl" ) { $sollanguage = "nl_BE,nl_NL"; } 1962 elsif ( $sollanguage eq "pl" ) { $sollanguage = "pl_PL"; } 1963 elsif ( $sollanguage eq "sv" ) { $sollanguage = "sv"; } 1964 elsif ( $sollanguage eq "pt" ) { $sollanguage = "pt_PT"; } 1965 elsif ( $sollanguage eq "pt_BR" ) { $sollanguage = "pt_BR"; } 1966 elsif ( $sollanguage eq "ru" ) { $sollanguage = "ru_RU"; } 1967 elsif ( $sollanguage eq "ja" ) { $sollanguage = "ja,ja_JP,ja_JP.PCK,ja_JP.UTF-8"; } 1968 elsif ( $sollanguage eq "ko" ) { $sollanguage = "ko,ko.UTF-8"; } 1969 elsif ( $sollanguage eq "zh_CN" ) { $sollanguage = "zh,zh.GBK,zh_CN.GB18030,zh.UTF-8"; } 1970 elsif ( $sollanguage eq "zh_TW" ) { $sollanguage = "zh_TW,zh_TW.BIG5,zh_TW.UTF-8,zh_HK.BIG5HK,zh_HK.UTF-8"; } 1971 1972 return $sollanguage; 1973} 1974 1975############################################################ 1976# Adding language infos in pkginfo file 1977############################################################ 1978 1979sub include_languageinfos_into_pkginfo 1980{ 1981 my ( $changefile, $filename, $languagestringref, $onepackage, $variableshashref ) = @_; 1982 1983 # SUNWPKG_LIST=core01 1984 # SUNW_LOC=de 1985 1986 my $locallang = $onepackage->{'language'}; 1987 my $solarislanguage = get_solaris_language_for_langpack($locallang); 1988 1989 my $newline = "SUNW_LOC=" . $solarislanguage . "\n"; 1990 add_one_line_into_file($changefile, $newline, $filename); 1991 1992 # SUNW_PKGLIST is required, if SUNW_LOC is defined. 1993 if ( $onepackage->{'pkg_list_entry'} ) 1994 { 1995 my $packagelistentry = $onepackage->{'pkg_list_entry'}; 1996 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1); 1997 $newline = "SUNW_PKGLIST=" . $packagelistentry . "\n"; 1998 add_one_line_into_file($changefile, $newline, $filename); 1999 } 2000 else 2001 { 2002 # Using default package ooobasis30-core01. 2003 my $packagelistentry = "%BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core01"; 2004 installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1); 2005 $newline = "SUNW_PKGLIST=" . $packagelistentry . "\n"; 2006 add_one_line_into_file($changefile, $newline, $filename); 2007 } 2008} 2009 2010############################################################ 2011# Collecting all files included in patch in 2012# @installer::globals::patchfilecollector 2013############################################################ 2014 2015sub collect_patch_files 2016{ 2017 my ($file, $packagename, $prefix) = @_; 2018 2019 # $file is the spec file or the prototypefile 2020 2021 $prefix = $prefix . "/"; 2022 my $packagenamestring = "Package " . $packagename . " \:\n"; 2023 push(@installer::globals::patchfilecollector, $packagenamestring); 2024 2025 for ( my $i = 0; $i <= $#{$file}; $i++ ) 2026 { 2027 my $line = ${$file}[$i]; 2028 2029 if ( $installer::globals::islinuxrpmbuild ) 2030 { 2031 # %attr(0444,root,root) "/opt/openofficeorg20/program/about.bmp" 2032 2033 if ( $line =~ /^\s*\%attr\(.*\)\s*\"(.*?)\"\s*$/ ) 2034 { 2035 my $filename = $1 . "\n"; 2036 $filename =~ s/^\s*\Q$prefix\E//; 2037 push(@installer::globals::patchfilecollector, $filename); 2038 } 2039 } 2040 2041 if ( $installer::globals::issolarispkgbuild ) 2042 { 2043 # f none program/msomrl.rdb=/ab/SRC680/unxsols4.pro/bin/msomrl.rdb 0444 root bin 2044 2045 if ( $line =~ /^\s*f\s+\w+\s+(.*?)\=/ ) 2046 { 2047 my $filename = $1 . "\n"; 2048 push(@installer::globals::patchfilecollector, $filename); 2049 } 2050 } 2051 } 2052 2053 push(@installer::globals::patchfilecollector, "\n"); 2054 2055} 2056 2057############################################################ 2058# Including package names into the depend files. 2059# The package names have to be included into 2060# packagelist. They are already saved in 2061# %installer::globals::dependfilenames. 2062############################################################ 2063 2064sub put_packagenames_into_dependfile 2065{ 2066 my ( $file ) = @_; 2067 2068 for ( my $i = 0; $i <= $#{$file}; $i++ ) 2069 { 2070 my $line = ${$file}[$i]; 2071 if ( $line =~ /^\s*\w\s+(.*?)\s*$/ ) 2072 { 2073 my $abbreviation = $1; 2074 2075 if ( $abbreviation =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package abbreviation \"$abbreviation\"!", "read_packagemap"); } 2076 2077 if ( exists($installer::globals::dependfilenames{$abbreviation}) ) 2078 { 2079 my $packagename = $installer::globals::dependfilenames{$abbreviation}; 2080 if ( $packagename =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package name \"$packagename\"!", "read_packagemap"); } 2081 2082 $line =~ s/\s*$//; 2083 ${$file}[$i] = $line . "\t" . $packagename . "\n"; 2084 } 2085 else 2086 { 2087 installer::exiter::exit_program("ERROR: Missing packagename for Solaris package \"$abbreviation\"!", "put_packagenames_into_dependfile"); 2088 } 2089 } 2090 } 2091} 2092 2093############################################################ 2094# Including the relocatable directory into 2095# spec file and pkginfo file 2096# Linux: set topdir in specfile 2097# Solaris: remove $relocatablepath (/opt/) 2098# for all objects in prototype file 2099# and changing "topdir" for Linux 2100############################################################ 2101 2102sub prepare_packages 2103{ 2104 my ($loggingdir, $packagename, $staticpath, $relocatablepath, $onepackage, $variableshashref, $filesref, $languagestringref) = @_; 2105 2106 my $filename = ""; 2107 my $newline = ""; 2108 my $newepmdir = $installer::globals::epmoutpath . $installer::globals::separator; 2109 2110 my $localrelocatablepath = $relocatablepath; 2111 if ( $localrelocatablepath ne "/" ) { $localrelocatablepath =~ s/\/\s*$//; } 2112 2113 if ( $installer::globals::issolarispkgbuild ) 2114 { 2115 $filename = $packagename . ".pkginfo"; 2116 $newline = "BASEDIR\=" . $localrelocatablepath . "\n"; 2117 } 2118 2119 if ( $installer::globals::islinuxrpmbuild ) 2120 { 2121 # if ( $localrelocatablepath =~ /^\s*$/ ) { $localrelocatablepath = "/"; }; # at least the "/" 2122 $filename = $packagename . ".spec"; 2123 $newline = "Prefix\:\ " . $localrelocatablepath . "\n"; 2124 } 2125 2126 my $completefilename = $newepmdir . $filename; 2127 2128 if ( ! -f $completefilename) { installer::exiter::exit_program("ERROR: Did not find file: $completefilename", "prepare_packages"); } 2129 my $changefile = installer::files::read_file($completefilename); 2130 if ( $newline ne "" ) 2131 { 2132 add_one_line_into_file($changefile, $newline, $filename); 2133 installer::files::save_file($completefilename, $changefile); 2134 } 2135 2136 # my $newepmdir = $completefilename; 2137 # installer::pathanalyzer::get_path_from_fullqualifiedname(\$newepmdir); 2138 2139 # adding new "topdir" and removing old "topdir" in specfile 2140 2141 if ( $installer::globals::islinuxrpmbuild ) 2142 { 2143 set_topdir_in_specfile($changefile, $filename, $newepmdir); 2144 set_autoprovreq_in_specfile($changefile, $onepackage->{'findrequires'}, "$installer::globals::unpackpath" . "/bin"); 2145 set_packager_in_specfile($changefile); 2146 if ( is_extension_package($changefile) ) { set_prereq_in_specfile($changefile); } 2147 set_license_in_specfile($changefile, $variableshashref); 2148 set_tab_into_datafile($changefile, $filesref); 2149 # check_requirements_in_specfile($changefile); 2150 installer::files::save_file($completefilename, $changefile); 2151 if ( $installer::globals::patch ) { collect_patch_files($changefile, $packagename, $localrelocatablepath); } 2152 } 2153 2154 # removing the relocatable path in prototype file 2155 2156 if ( $installer::globals::issolarispkgbuild ) 2157 { 2158 set_revision_in_pkginfo($changefile, $filename, $variableshashref, $packagename); 2159 set_maxinst_in_pkginfo($changefile, $filename); 2160 set_solaris_parameter_in_pkginfo($changefile, $filename, $variableshashref); 2161 if ( $installer::globals::issolarisx86build ) { fix_architecture_setting($changefile); } 2162 if ( ! $installer::globals::patch ) { set_patchlist_in_pkginfo_for_respin($changefile, $filename, $variableshashref, $packagename); } 2163 if ( $installer::globals::patch ) { include_patchinfos_into_pkginfo($changefile, $filename, $variableshashref); } 2164 if (( $onepackage->{'language'} ) && ( $onepackage->{'language'} ne "" ) && ( $onepackage->{'language'} ne "en-US" )) { include_languageinfos_into_pkginfo($changefile, $filename, $languagestringref, $onepackage, $variableshashref); } 2165 installer::files::save_file($completefilename, $changefile); 2166 2167 my $prototypefilename = $packagename . ".prototype"; 2168 $prototypefilename = $newepmdir . $prototypefilename; 2169 if (! -f $prototypefilename) { installer::exiter::exit_program("ERROR: Did not find prototype file: $prototypefilename", "prepare_packages"); } 2170 2171 my $prototypefile = installer::files::read_file($prototypefilename); 2172 make_prototypefile_relocatable($prototypefile, $relocatablepath); 2173 set_volatilefile_into_prototypefile($prototypefile, $filesref); 2174 my $classesstring = set_tab_into_datafile($prototypefile, $filesref); 2175 if ($classesstring) 2176 { 2177 include_classes_into_pkginfo($changefile, $classesstring); 2178 installer::files::save_file($completefilename, $changefile); 2179 } 2180 2181 if ( $installer::globals::patch ) { add_scripts_into_prototypefile($prototypefile, $prototypefilename, $languagestringref, $staticpath); } 2182 2183 installer::files::save_file($prototypefilename, $prototypefile); 2184 if ( $installer::globals::patch ) { collect_patch_files($prototypefile, $packagename, ""); } 2185 2186 # Adding package names into depend files for Solaris (not supported by epm) 2187 my $dependfilename = $packagename . ".depend"; 2188 $dependfilename = $newepmdir . $dependfilename; 2189 if ( -f $dependfilename) 2190 { 2191 my $dependfile = installer::files::read_file($dependfilename); 2192 put_packagenames_into_dependfile($dependfile); 2193 installer::files::save_file($dependfilename, $dependfile); 2194 } 2195 } 2196 2197 return $newepmdir; 2198} 2199 2200############################################################ 2201# Linux requirement for perl is changed by epm from 2202# /usr/bin/perl to perl . 2203# Requires: perl 2204############################################################ 2205 2206sub check_requirements_in_specfile 2207{ 2208 my ( $specfile ) = @_; 2209 2210 for ( my $i = 0; $i <= $#{$specfile}; $i++ ) 2211 { 2212 if (( ${$specfile}[$i] =~ /^\s*Requires/ ) && ( ${$specfile}[$i] =~ /\bperl\b/ ) && ( ! ( ${$specfile}[$i] =~ /\/usr\/bin\/perl\b/ ))) 2213 { 2214 my $oldline = ${$specfile}[$i]; 2215 ${$specfile}[$i] =~ s/perl/\/usr\/bin\/perl/; 2216 my $newline = ${$specfile}[$i]; 2217 2218 $oldline =~ s/\s*$//; 2219 $newline =~ s/\s*$//; 2220 my $infoline = "Spec File: Changing content from \"$oldline\" to \"$newline\".\n"; 2221 push(@installer::globals::logfileinfo, $infoline); 2222 } 2223 } 2224} 2225 2226############################################################################### 2227# Replacement of PRODUCTINSTALLLOCATION and PRODUCTDIRECTORYNAME in the 2228# epm list file. 2229# The complete rootpath is stored in $installer::globals::rootpath 2230# or for each package in $onepackage->{'destpath'} 2231# The static rootpath is stored in $staticpath 2232# The relocatable path is stored in $relocatablepath 2233# PRODUCTINSTALLLOCATION is the relocatable part ("/opt") and 2234# PRODUCTDIRECTORYNAME the static path ("openofficeorg20"). 2235# In standard epm process: 2236# No usage of package specific variables like $BASEDIR, because 2237# 1. These variables would be replaced in epm process 2238# 2. epm version 3.7 does not support relocatable packages 2239############################################################################### 2240 2241sub resolve_path_in_epm_list_before_packaging 2242{ 2243 my ($listfile, $listfilename, $variable, $path) = @_; 2244 2245 installer::logger::include_header_into_logfile("Replacing variables in epm list file:"); 2246 2247 $path =~ s/\/\s*$//; 2248 replace_variables_in_shellscripts($listfile, $listfilename, $variable, $path); 2249 2250} 2251 2252################################################################# 2253# Determining the rpm version. Beginning with rpm version 4.0 2254# the tool to create RPMs is "rpmbuild" and no longer "rpm" 2255################################################################# 2256 2257sub determine_rpm_version 2258{ 2259 my $rpmversion = 0; 2260 my $rpmout = ""; 2261 my $systemcall = ""; 2262 2263 # my $systemcall = "rpm --version |"; 2264 # "rpm --version" has problems since LD_LIBRARY_PATH was removed. Therefore the content of $RPM has to be called. 2265 # "rpm --version" and "rpmbuild --version" have the same output. Therefore $RPM can be used. Its value 2266 # is saved in $installer::globals::rpm 2267 2268 if ( $installer::globals::rpm ne "" ) 2269 { 2270 $systemcall = "$installer::globals::rpm --version |"; 2271 } 2272 else 2273 { 2274 $systemcall = "rpm --version |"; 2275 } 2276 2277 open (RPM, "$systemcall"); 2278 $rpmout = <RPM>; 2279 close (RPM); 2280 2281 if ( $rpmout ne "" ) 2282 { 2283 $rpmout =~ s/\s*$//g; 2284 2285 my $infoline = "Systemcall: $systemcall\n"; 2286 push( @installer::globals::logfileinfo, $infoline); 2287 2288 if ( $rpmout eq "" ) { $infoline = "ERROR: Could not find file \"rpm\" !\n"; } 2289 else { $infoline = "Success: rpm version: $rpmout\n"; } 2290 2291 push( @installer::globals::logfileinfo, $infoline); 2292 2293 if ( $rpmout =~ /(\d+)\.(\d+)\.(\d+)/ ) { $rpmversion = $1; } 2294 elsif ( $rpmout =~ /(\d+)\.(\d+)/ ) { $rpmversion = $1; } 2295 elsif ( $rpmout =~ /(\d+)/ ) { $rpmversion = $1; } 2296 else { installer::exiter::exit_program("ERROR: Unknown format: $rpmout ! Expected: \"a.b.c\", or \"a.b\", or \"a\"", "determine_rpm_version"); } 2297 } 2298 2299 return $rpmversion; 2300} 2301 2302#################################################### 2303# Writing some info about rpm into the log file 2304#################################################### 2305 2306sub log_rpm_info 2307{ 2308 my $systemcall = ""; 2309 my $infoline = ""; 2310 2311 $infoline = "\nLogging rpmrc content using --showrc\n\n"; 2312 push( @installer::globals::logfileinfo, $infoline); 2313 2314 if ( $installer::globals::rpm ne "" ) 2315 { 2316 $systemcall = "$installer::globals::rpm --showrc |"; 2317 } 2318 else 2319 { 2320 $systemcall = "rpm --showrc |"; 2321 } 2322 2323 my @fullrpmout = (); 2324 2325 open (RPM, "$systemcall"); 2326 while (<RPM>) {push(@fullrpmout, $_); } 2327 close (RPM); 2328 2329 if ( $#fullrpmout > -1 ) 2330 { 2331 for ( my $i = 0; $i <= $#fullrpmout; $i++ ) 2332 { 2333 my $rpmout = $fullrpmout[$i]; 2334 $rpmout =~ s/\s*$//g; 2335 2336 $infoline = "$rpmout\n"; 2337 $infoline =~ s/error/e_r_r_o_r/gi; # avoiding log problems 2338 push( @installer::globals::logfileinfo, $infoline); 2339 } 2340 } 2341 else 2342 { 2343 $infoline = "Problem in systemcall: $systemcall : No return value\n"; 2344 push( @installer::globals::logfileinfo, $infoline); 2345 } 2346 2347 $infoline = "End of logging rpmrc\n\n"; 2348 push( @installer::globals::logfileinfo, $infoline); 2349} 2350 2351################################################# 2352# Systemcall to start the packaging process 2353################################################# 2354 2355sub create_packages_without_epm 2356{ 2357 my ($epmdir, $packagename, $includepatharrayref, $allvariables, $languagestringref) = @_; 2358 2359 # Solaris: pkgmk -o -f solaris-2.8-sparc/SUNWso8m34.prototype -d solaris-2.8-sparc 2360 # Solaris: pkgtrans solaris-2.8-sparc SUNWso8m34.pkg SUNWso8m34 2361 # Solaris: tar -cf - SUNWso8m34 | gzip > SUNWso8m34.tar.gz 2362 2363 if ( $installer::globals::issolarispkgbuild ) 2364 { 2365 my $prototypefile = $epmdir . $packagename . ".prototype"; 2366 if (! -f $prototypefile) { installer::exiter::exit_program("ERROR: Did not find file: $prototypefile", "create_packages_without_epm"); } 2367 2368 my $destinationdir = $prototypefile; 2369 installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationdir); 2370 $destinationdir =~ s/\/\s*$//; # removing ending slashes 2371 2372 # my $systemcall = "pkgmk -o -f $prototypefile -d $destinationdir \> /dev/null 2\>\&1"; 2373 my $systemcall = "pkgmk -l 1073741824 -o -f $prototypefile -d $destinationdir 2\>\&1 |"; 2374 installer::logger::print_message( "... $systemcall ...\n" ); 2375 2376 my $maxpkgmkcalls = 3; 2377 2378 for ( my $i = 1; $i <= $maxpkgmkcalls; $i++ ) 2379 { 2380 my @pkgmkoutput = (); 2381 2382 open (PKGMK, "$systemcall"); 2383 while (<PKGMK>) {push(@pkgmkoutput, $_); } 2384 close (PKGMK); 2385 2386 my $returnvalue = $?; # $? contains the return value of the systemcall 2387 2388 my $infoline = "Systemcall (Try $i): $systemcall\n"; 2389 push( @installer::globals::logfileinfo, $infoline); 2390 2391 for ( my $j = 0; $j <= $#pkgmkoutput; $j++ ) 2392 { 2393 if ( $i < $maxpkgmkcalls ) { $pkgmkoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; } 2394 push( @installer::globals::logfileinfo, "$pkgmkoutput[$j]"); 2395 } 2396 2397 if ($returnvalue) 2398 { 2399 $infoline = "Try $i : Could not execute \"$systemcall\"!\n"; 2400 push( @installer::globals::logfileinfo, $infoline); 2401 if ( $i == $maxpkgmkcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); } 2402 } 2403 else 2404 { 2405 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" ); 2406 $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2407 push( @installer::globals::logfileinfo, $infoline); 2408 last; 2409 } 2410 } 2411 2412 # It might be necessary to save uncompressed Solaris packages 2413 2414 if ( $allvariables->{'JDSBUILD'} ) 2415 { 2416 if ( ! $installer::globals::jds_language_controlled ) 2417 { 2418 my $correct_language = installer::worker::check_jds_language($allvariables, $languagestringref); 2419 $installer::globals::correct_jds_language = $correct_language; 2420 $installer::globals::jds_language_controlled = 1; 2421 } 2422 2423 if ( $installer::globals::correct_jds_language ) 2424 { 2425 if ( $installer::globals::saved_packages_path eq "" ) 2426 { 2427 $packagestempdir = installer::systemactions::create_directories("jds", $languagestringref); 2428 $installer::globals::saved_packages_path = $packagestempdir; 2429 push(@installer::globals::jdsremovedirs, $packagestempdir); 2430 } 2431 2432 $systemcall = "cd $destinationdir; cp -p -R $packagename $installer::globals::saved_packages_path;"; 2433 make_systemcall($systemcall); 2434 installer::logger::print_message( "... $systemcall ...\n" ); 2435 2436 # Setting unix rights to "775" for all created directories inside the package, 2437 # that is saved in temp directory 2438 2439 $systemcall = "cd $packagestempdir; find $packagename -type d -exec chmod 775 \{\} \\\;"; 2440 installer::logger::print_message( "... $systemcall ...\n" ); 2441 2442 $returnvalue = system($systemcall); 2443 2444 $infoline = "Systemcall: $systemcall\n"; 2445 push( @installer::globals::logfileinfo, $infoline); 2446 2447 if ($returnvalue) 2448 { 2449 $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 2450 push( @installer::globals::logfileinfo, $infoline); 2451 } 2452 else 2453 { 2454 $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2455 push( @installer::globals::logfileinfo, $infoline); 2456 } 2457 } 2458 } 2459 2460 # compressing packages 2461 2462 if ( ! $installer::globals::solarisdontcompress ) 2463 { 2464 my $faspac = "faspac-so.sh"; 2465 2466 my $compressorref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$faspac, $includepatharrayref, 0); 2467 if ($$compressorref ne "") 2468 { 2469 # Saving original pkginfo, to set time stamp later 2470 my $pkginfoorig = "$destinationdir/$packagename/pkginfo"; 2471 my $pkginfotmp = "$destinationdir/$packagename" . ".pkginfo.tmp"; 2472 $systemcall = "cp -p $pkginfoorig $pkginfotmp"; 2473 make_systemcall($systemcall); 2474 2475 $faspac = $$compressorref; 2476 $infoline = "Found compressor: $faspac\n"; 2477 push( @installer::globals::logfileinfo, $infoline); 2478 2479 installer::logger::print_message( "... $faspac ...\n" ); 2480 installer::logger::include_timestamp_into_logfile("Starting $faspac"); 2481 2482 $systemcall = "/bin/sh $faspac -a -q -d $destinationdir $packagename"; # $faspac has to be the absolute path! 2483 make_systemcall($systemcall); 2484 2485 # Setting time stamp for pkginfo, because faspac-so.sh changed the pkginfo file, 2486 # updated the size and checksum, but not the time stamp. 2487 $systemcall = "touch -r $pkginfotmp $pkginfoorig"; 2488 make_systemcall($systemcall); 2489 if ( -f $pkginfotmp ) { unlink($pkginfotmp); } 2490 2491 installer::logger::include_timestamp_into_logfile("End of $faspac"); 2492 } 2493 else 2494 { 2495 $infoline = "Not found: $faspac\n"; 2496 push( @installer::globals::logfileinfo, $infoline); 2497 } 2498 } 2499 2500 # Setting unix rights to "775" for all created directories inside the package 2501 2502 $systemcall = "cd $destinationdir; find $packagename -type d -exec chmod 775 \{\} \\\;"; 2503 installer::logger::print_message( "... $systemcall ...\n" ); 2504 2505 $returnvalue = system($systemcall); 2506 2507 $infoline = "Systemcall: $systemcall\n"; 2508 push( @installer::globals::logfileinfo, $infoline); 2509 2510 if ($returnvalue) 2511 { 2512 $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 2513 push( @installer::globals::logfileinfo, $infoline); 2514 } 2515 else 2516 { 2517 $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2518 push( @installer::globals::logfileinfo, $infoline); 2519 } 2520 2521 ###################### 2522 # making pkg files 2523 ###################### 2524 2525 # my $streamname = $packagename . ".pkg"; 2526 # $systemcall = "pkgtrans $destinationdir $streamname $packagename"; 2527 # print "... $systemcall ...\n"; 2528 2529 # $returnvalue = system($systemcall); 2530 2531 # $infoline = "Systemcall: $systemcall\n"; 2532 # push( @installer::globals::logfileinfo, $infoline); 2533 2534 # if ($returnvalue) 2535 # { 2536 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 2537 # push( @installer::globals::logfileinfo, $infoline); 2538 # } 2539 # else 2540 # { 2541 # $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2542 # push( @installer::globals::logfileinfo, $infoline); 2543 # } 2544 2545 ######################### 2546 # making tar.gz files 2547 ######################### 2548 2549 # my $targzname = $packagename . ".tar.gz"; 2550 # $systemcall = "cd $destinationdir; tar -cf - $packagename | gzip > $targzname"; 2551 # print "... $systemcall ...\n"; 2552 2553 # $returnvalue = system($systemcall); 2554 2555 # $infoline = "Systemcall: $systemcall\n"; 2556 # push( @installer::globals::logfileinfo, $infoline); 2557 2558 # if ($returnvalue) 2559 # { 2560 # $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 2561 # push( @installer::globals::logfileinfo, $infoline); 2562 # } 2563 # else 2564 # { 2565 # $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2566 # push( @installer::globals::logfileinfo, $infoline); 2567 # } 2568 } 2569 2570 # Linux: rpm -bb so8m35.spec ( -> dependency check abklemmen? ) 2571 2572 if ( $installer::globals::islinuxrpmbuild ) 2573 { 2574 my $specfilename = $epmdir . $packagename . ".spec"; 2575 if (! -f $specfilename) { installer::exiter::exit_program("ERROR: Did not find file: $specfilename", "create_packages_without_epm"); } 2576 2577 # my $rpmcommand = "rpm"; 2578 my $rpmcommand = $installer::globals::rpm; 2579 my $rpmversion = determine_rpm_version(); 2580 2581 # if ( $rpmversion >= 4 ) { $rpmcommand = "rpmbuild"; } 2582 2583 # saving globally for later usage 2584 $installer::globals::rpmcommand = $rpmcommand; 2585 $installer::globals::rpmquerycommand = "rpm"; 2586 2587 my $target = ""; 2588 if ( $installer::globals::compiler =~ /unxlngi/) { $target = "i586"; } 2589 elsif ( $installer::globals::compiler =~ /unxlng/) {$target = (POSIX::uname())[4]; } 2590 2591 # rpm 4.6 ignores buildroot tag in spec file 2592 2593 my $buildrootstring = ""; 2594 2595 if ( $rpmversion >= 4 ) 2596 { 2597 my $dir = getcwd; 2598 my $buildroot = $dir . "/" . $epmdir . "buildroot/"; 2599 $buildrootstring = "--buildroot=$buildroot"; 2600 mkdir($buildroot = $dir . "/" . $epmdir . "BUILD/"); 2601 } 2602 2603 if ( ! $installer::globals::rpminfologged ) 2604 { 2605 log_rpm_info(); 2606 $installer::globals::rpminfologged = 1; 2607 } 2608 2609 my $systemcall = "$rpmcommand -bb --define \"_unpackaged_files_terminate_build 0\" $specfilename --target $target $buildrootstring 2\>\&1 |"; 2610 2611 installer::logger::print_message( "... $systemcall ...\n" ); 2612 2613 my $maxrpmcalls = 3; 2614 my $rpm_failed = 0; 2615 2616 for ( my $i = 1; $i <= $maxrpmcalls; $i++ ) 2617 { 2618 my @rpmoutput = (); 2619 2620 open (RPM, "$systemcall"); 2621 while (<RPM>) {push(@rpmoutput, $_); } 2622 close (RPM); 2623 2624 my $returnvalue = $?; # $? contains the return value of the systemcall 2625 2626 my $infoline = "Systemcall (Try $i): $systemcall\n"; 2627 push( @installer::globals::logfileinfo, $infoline); 2628 2629 for ( my $j = 0; $j <= $#rpmoutput; $j++ ) 2630 { 2631 # if ( $i < $maxrpmcalls ) { $rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; } 2632 $rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; 2633 push( @installer::globals::logfileinfo, "$rpmoutput[$j]"); 2634 } 2635 2636 if ($returnvalue) 2637 { 2638 $infoline = "Try $i : Could not execute \"$systemcall\"!\n"; 2639 push( @installer::globals::logfileinfo, $infoline); 2640 $rpm_failed = 1; 2641 } 2642 else 2643 { 2644 installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" ); 2645 $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2646 push( @installer::globals::logfileinfo, $infoline); 2647 $rpm_failed = 0; 2648 last; 2649 } 2650 } 2651 2652 if ( $rpm_failed ) 2653 { 2654 # Because of the problems with LD_LIBARY_PATH, a direct call of local "rpm" or "rpmbuild" might be successful 2655 my $rpmprog = ""; 2656 if ( -f "/usr/bin/rpmbuild" ) { $rpmprog = "/usr/bin/rpmbuild"; } 2657 elsif ( -f "/usr/bin/rpm" ) { $rpmprog = "/usr/bin/rpm"; } 2658 2659 if ( $rpmprog ne "" ) 2660 { 2661 installer::logger::print_message( "... $rpmprog ...\n" ); 2662 2663 my $helpersystemcall = "$rpmprog -bb $specfilename --target $target $buildrootstring 2\>\&1 |"; 2664 2665 my @helperrpmoutput = (); 2666 2667 open (RPM, "$helpersystemcall"); 2668 while (<RPM>) {push(@helperrpmoutput, $_); } 2669 close (RPM); 2670 2671 my $helperreturnvalue = $?; # $? contains the return value of the systemcall 2672 2673 $infoline = "\nLast try: Using $rpmprog directly (problem with LD_LIBARY_PATH)\n"; 2674 push( @installer::globals::logfileinfo, $infoline); 2675 2676 $infoline = "\nSystemcall: $helpersystemcall\n"; 2677 push( @installer::globals::logfileinfo, $infoline); 2678 2679 for ( my $j = 0; $j <= $#helperrpmoutput; $j++ ) { push( @installer::globals::logfileinfo, "$helperrpmoutput[$j]"); } 2680 2681 if ($helperreturnvalue) 2682 { 2683 $infoline = "Could not execute \"$helpersystemcall\"!\n"; 2684 push( @installer::globals::logfileinfo, $infoline); 2685 } 2686 else 2687 { 2688 installer::logger::print_message( "Success: \"$helpersystemcall\"\n" ); 2689 $infoline = "Success: Executed \"$helpersystemcall\" successfully!\n"; 2690 push( @installer::globals::logfileinfo, $infoline); 2691 $rpm_failed = 0; 2692 } 2693 } 2694 2695 # Now it is really time to exit this packaging process, if the error still occurs 2696 if ( $rpm_failed ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); } 2697 } 2698 } 2699} 2700 2701################################################# 2702# Removing all temporary files created by epm 2703################################################# 2704 2705sub remove_temporary_epm_files 2706{ 2707 my ($epmdir, $loggingdir, $packagename) = @_; 2708 2709 # saving the files into the loggingdir 2710 2711 if ( $installer::globals::issolarispkgbuild ) 2712 { 2713 my @extensions = (); 2714 push(@extensions, ".pkginfo"); 2715 push(@extensions, ".prototype"); 2716 push(@extensions, ".postinstall"); 2717 push(@extensions, ".postremove"); 2718 push(@extensions, ".preinstall"); 2719 push(@extensions, ".preremove"); 2720 push(@extensions, ".depend"); 2721 2722 for ( my $i = 0; $i <= $#extensions; $i++ ) 2723 { 2724 my $removefile = $epmdir . $packagename . $extensions[$i]; 2725 my $destfile = $loggingdir . $packagename . $extensions[$i] . ".log"; 2726 2727 if (! -f $removefile) { next; } 2728 2729 my $systemcall = "mv -f $removefile $destfile"; 2730 system($systemcall); # ignoring the return value 2731 $infoline = "Systemcall: $systemcall\n"; 2732 push( @installer::globals::logfileinfo, $infoline); 2733 } 2734 2735 # removing the package 2736 2737# my $removedir = $epmdir . $packagename; 2738# 2739# my $systemcall = "rm -rf $removedir"; 2740# 2741# print "... $systemcall ...\n"; 2742# 2743# my $returnvalue = system($systemcall); 2744# 2745# my $infoline = "Systemcall: $systemcall\n"; 2746# push( @installer::globals::logfileinfo, $infoline); 2747# 2748# if ($returnvalue) 2749# { 2750# $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 2751# push( @installer::globals::logfileinfo, $infoline); 2752# } 2753# else 2754# { 2755# $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2756# push( @installer::globals::logfileinfo, $infoline); 2757# } 2758 } 2759 2760 if ( $installer::globals::islinuxrpmbuild ) 2761 { 2762 my $removefile = $epmdir . $packagename . ".spec"; 2763 my $destfile = $loggingdir . $packagename . ".spec.log"; 2764 2765 # if (! -f $removefile) { next; } 2766 2767 my $systemcall = "mv -f $removefile $destfile"; 2768 system($systemcall); # ignoring the return value 2769 $infoline = "Systemcall: $systemcall\n"; 2770 push( @installer::globals::logfileinfo, $infoline); 2771 2772 # removing the directory "buildroot" 2773 2774 my $removedir = $epmdir . "buildroot"; 2775 2776 $systemcall = "rm -rf $removedir"; 2777 2778 installer::logger::print_message( "... $systemcall ...\n" ); 2779 2780 my $returnvalue = system($systemcall); 2781 2782 $removedir = $epmdir . "BUILD"; 2783 2784 $systemcall = "rm -rf $removedir"; 2785 2786 installer::logger::print_message( "... $systemcall ...\n" ); 2787 2788 $returnvalue = system($systemcall); 2789 2790 2791 my $infoline = "Systemcall: $systemcall\n"; 2792 push( @installer::globals::logfileinfo, $infoline); 2793 2794 if ($returnvalue) 2795 { 2796 $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 2797 push( @installer::globals::logfileinfo, $infoline); 2798 } 2799 else 2800 { 2801 $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2802 push( @installer::globals::logfileinfo, $infoline); 2803 } 2804 } 2805} 2806 2807###################################################### 2808# Making the systemcall 2809###################################################### 2810 2811sub make_systemcall 2812{ 2813 my ($systemcall) = @_; 2814 2815 my $returnvalue = system($systemcall); 2816 2817 my $infoline = "Systemcall: $systemcall\n"; 2818 push( @installer::globals::logfileinfo, $infoline); 2819 2820 if ($returnvalue) 2821 { 2822 $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 2823 push( @installer::globals::logfileinfo, $infoline); 2824 } 2825 else 2826 { 2827 $infoline = "Success: Executed \"$systemcall\" successfully!\n"; 2828 push( @installer::globals::logfileinfo, $infoline); 2829 } 2830} 2831 2832########################################################### 2833# Creating a better directory structure in the solver. 2834########################################################### 2835 2836sub create_new_directory_structure 2837{ 2838 my ($newepmdir) = @_; 2839 2840 my $newdir = $installer::globals::epmoutpath; 2841 2842 if ( $installer::globals::islinuxrpmbuild ) 2843 { 2844 my $rpmdir; 2845 my $machine = ""; 2846 if ( $installer::globals::compiler =~ /unxlngi/) { 2847 $rpmdir = "$installer::globals::epmoutpath/RPMS/i586"; 2848 } 2849 elsif ( $installer::globals::compiler =~ /unxlng/) { 2850 $machine = (POSIX::uname())[4]; 2851 $rpmdir = "$installer::globals::epmoutpath/RPMS/$machine"; 2852 } 2853 else { installer::exiter::exit_program("ERROR: rpmdir undefined !", "create_new_directory_structure"); } 2854 2855 my $systemcall = "mv $rpmdir/* $newdir"; # moving the rpms into the directory "RPMS" 2856 2857 my $returnvalue = system($systemcall); 2858 2859 my $infoline = "Systemcall: $systemcall\n"; 2860 push( @installer::globals::logfileinfo, $infoline); 2861 2862 if ($returnvalue) 2863 { 2864 $infoline = "ERROR: Could not move content of \"$rpmdir\" to \"$newdir\"!\n"; 2865 push( @installer::globals::logfileinfo, $infoline); 2866 } 2867 else 2868 { 2869 $infoline = "Success: Moved content of \"$rpmdir\" to \"$newdir\"!\n"; 2870 push( @installer::globals::logfileinfo, $infoline); 2871 } 2872 2873 # and removing the empty directory 2874 2875 if ( $machine ne "" ) 2876 { 2877 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/$machine"); 2878 } 2879 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/x86_64"); 2880 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/i586"); 2881 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/i386"); 2882 installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS"); 2883 2884 } 2885 2886 # Setting unix rights to "775" for $newdir ("RPMS" or "packages") 2887 2888 my $localcall = "chmod 775 $newdir \>\/dev\/null 2\>\&1"; 2889 my $callreturnvalue = system($localcall); 2890 2891 my $callinfoline = "Systemcall: $localcall\n"; 2892 push( @installer::globals::logfileinfo, $callinfoline); 2893 2894 if ($callreturnvalue) 2895 { 2896 $callinfoline = "ERROR: Could not execute \"$localcall\"!\n"; 2897 push( @installer::globals::logfileinfo, $callinfoline); 2898 } 2899 else 2900 { 2901 $callinfoline = "Success: Executed \"$localcall\" successfully!\n"; 2902 push( @installer::globals::logfileinfo, $callinfoline); 2903 } 2904} 2905 2906###################################################### 2907# Collect modules with product specific styles. 2908###################################################### 2909 2910sub collect_modules_with_style 2911{ 2912 my ($style, $modulesarrayref) = @_; 2913 2914 my @allmodules = (); 2915 2916 for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ ) 2917 { 2918 my $onemodule = ${$modulesarrayref}[$i]; 2919 my $styles = ""; 2920 if ( $onemodule->{'Styles'} ) { $styles = $onemodule->{'Styles'}; } 2921 if ( $styles =~ /\b\Q$style\E\b/ ) 2922 { 2923 push(@allmodules, $onemodule); 2924 } 2925 } 2926 2927 return \@allmodules; 2928} 2929 2930###################################################### 2931# Remove modules without packagecontent. 2932###################################################### 2933 2934sub remove_modules_without_package 2935{ 2936 my ($allmodules) = @_; 2937 2938 my @allmodules = (); 2939 2940 for ( my $i = 0; $i <= $#{$allmodules}; $i++ ) 2941 { 2942 my $onemodule = ${$allmodules}[$i]; 2943 my $packagename = ""; 2944 if ( $onemodule->{'PackageName'} ) { $packagename = $onemodule->{'PackageName'}; } 2945 if ( $packagename ne "" ) 2946 { 2947 push(@allmodules, $onemodule); 2948 } 2949 } 2950 2951 return \@allmodules; 2952} 2953 2954###################################################### 2955# Unpacking tar.gz file and setting new packagename. 2956###################################################### 2957 2958sub unpack_tar_gz_file 2959{ 2960 my ($packagename, $destdir) = @_; 2961 2962 my $newpackagename = ""; 2963 2964 if ( $packagename =~ /\.tar\.gz\s*$/ ) 2965 { 2966 # Collecting all packages in directory "packages" 2967 my $oldcontent = installer::systemactions::read_directory($destdir); 2968 2969 # unpacking gunzip 2970 my $systemcall = "cd $destdir; cat $packagename | gunzip | tar -xf -"; 2971 make_systemcall($systemcall); 2972 2973 # deleting the tar.gz files 2974 $systemcall = "cd $destdir; rm -f $packagename"; 2975 make_systemcall($systemcall); 2976 2977 # Finding new content -> that is the package name 2978 my ($newcontent, $allcontent ) = installer::systemactions::find_new_content_in_directory($destdir, $oldcontent); 2979 $newpackagename = ${$newcontent}[0]; 2980 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$newpackagename); 2981 } 2982 2983 if ( $newpackagename ne "" ) { $packagename = $newpackagename; } 2984 2985 return $packagename; 2986} 2987 2988###################################################### 2989# Copying files of child projects. 2990###################################################### 2991 2992sub copy_childproject_files 2993{ 2994 my ($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, $subdir, $includepatharrayref, $use_sopackpath) = @_; 2995 2996 for ( my $i = 0; $i <= $#{$allmodules}; $i++ ) 2997 { 2998 my $localdestdir = $destdir; 2999 my $onemodule = ${$allmodules}[$i]; 3000 my $packagename = $onemodule->{'PackageName'}; 3001 my $sourcefile = ""; 3002 if ( $use_sopackpath ) 3003 { 3004 $sourcefile = $sopackpath . $installer::globals::separator . $installer::globals::compiler . $installer::globals::separator . $subdir . $installer::globals::separator . $packagename; 3005 } 3006 else 3007 { 3008 my $sourcepathref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packagename, $includepatharrayref, 1); 3009 $sourcefile = $$sourcepathref; 3010 } 3011 3012 if ( ! -f $sourcefile ) { installer::exiter::exit_program("ERROR: File not found: $sourcefile ($packagename) !", "copy_childproject_files"); } 3013 if ( $onemodule->{'Subdir'} ) 3014 { 3015 $localdestdir = $localdestdir . $installer::globals::separator . $onemodule->{'Subdir'}; 3016 if ( ! -d $localdestdir ) { installer::systemactions::create_directory($localdestdir); } 3017 } 3018 installer::systemactions::copy_one_file($sourcefile, $localdestdir); 3019 # Solaris: unpacking tar.gz files and setting new packagename 3020 if ( $installer::globals::issolarispkgbuild ) { $packagename = unpack_tar_gz_file($packagename, $localdestdir); } 3021 3022 if (( $installer::globals::isxpdplatform ) && ( $allvariables->{'XPDINSTALLER'} )) 3023 { 3024 installer::xpdinstaller::create_xpd_file_for_childproject($onemodule, $localdestdir, $packagename, $allvariableshashref, $modulesarrayref); 3025 } 3026 } 3027 3028} 3029 3030###################################################### 3031# Copying files for system integration. 3032###################################################### 3033 3034sub copy_and_unpack_tar_gz_files 3035{ 3036 my ($sourcefile, $destdir) = @_; 3037 3038 my $systemcall = "cd $destdir; cat $sourcefile | gunzip | tar -xf -"; 3039 make_systemcall($systemcall); 3040} 3041 3042###################################################### 3043# Including child packages into the 3044# installation set. 3045###################################################### 3046 3047sub put_childprojects_into_installset 3048{ 3049 my ($newdir, $allvariables, $modulesarrayref, $includepatharrayref) = @_; 3050 3051 my $infoline = ""; 3052 3053 my $sopackpath = ""; 3054 if ( $ENV{'SO_PACK'} ) { $sopackpath = $ENV{'SO_PACK'}; } 3055 else { installer::exiter::exit_program("ERROR: Environment variable SO_PACK not set!", "put_childprojects_into_installset"); } 3056 3057 my $destdir = "$newdir"; 3058 3059 # adding Java 3060 3061 my $sourcefile = ""; 3062 3063 # Finding the modules defined in scp (with flag JAVAMODULE, ADAMODULE, ...) 3064 # Getting name of package from scp-Module 3065 # Copy file into installation set 3066 # Create xpd file and put it into xpd directory 3067 # xpd file has to be created completely from module and package itself (-> no packagelist!) 3068 3069 if ( $allvariables->{'JAVAPRODUCT'} ) 3070 { 3071 # Collect all modules with flag "JAVAMODULE" 3072 my $allmodules = collect_modules_with_style("JAVAMODULE", $modulesarrayref); 3073 $allmodules = remove_modules_without_package($allmodules); 3074 copy_childproject_files($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "jre", $includepatharrayref, 1); 3075 } 3076 3077 # Adding additional required packages (freetype). 3078 # This package names are stored in global array @installer::globals::requiredpackages 3079 3080 if ( $allvariables->{'ADDREQUIREDPACKAGES'} ) 3081 { 3082 # Collect all modules with flag "REQUIREDPACKAGEMODULE" 3083 my $allmodules = collect_modules_with_style("REQUIREDPACKAGEMODULE", $modulesarrayref); 3084 $allmodules = remove_modules_without_package($allmodules); 3085 copy_childproject_files($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "requiredpackages", $includepatharrayref, 1); 3086 } 3087 3088 # Collect all modules with flag "USERLANDMODULE" 3089 my $alluserlandmodules = collect_modules_with_style("USERLANDMODULE", $modulesarrayref); 3090 $alluserlandmodules = remove_modules_without_package($alluserlandmodules); 3091 copy_childproject_files($alluserlandmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "", $includepatharrayref, 0); 3092 3093} 3094 3095###################################################### 3096# Checking whether the new content is a directory and 3097# not a package. If it is a directory, the complete 3098# content of the directory has to be added to the 3099# array newcontent. 3100###################################################### 3101 3102sub control_subdirectories 3103{ 3104 my ($content, $subdir) = @_; 3105 3106 my @newcontent = (); 3107 3108 for ( my $i = 0; $i <= $#{$content}; $i++ ) 3109 { 3110 if ( -d ${$content}[$i] ) 3111 { 3112 $subdir = ${$content}[$i]; 3113 installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$subdir); 3114 my $allpackages = installer::systemactions::read_directory(${$content}[$i]); 3115 for ( my $j = 0; $j <= $#{$allpackages}; $j++ ) 3116 { 3117 # Currently only Linux rpm is supported, debian packages cannot be installed via xpd installer 3118 if (( $installer::globals::islinuxbuild ) && ( ! ( ${$allpackages}[$j] =~ /\.rpm\s*$/ ))) { next; } 3119 push(@newcontent, ${$allpackages}[$j]); 3120 } 3121 } 3122 else 3123 { 3124 push(@newcontent, ${$content}[$i]); 3125 } 3126 } 3127 3128 return (\@newcontent, $subdir); 3129} 3130 3131###################################################### 3132# Including the system integration files into the 3133# installation sets. 3134###################################################### 3135 3136sub put_systemintegration_into_installset 3137{ 3138 my ($newdir, $includepatharrayref, $allvariables, $modulesarrayref) = @_; 3139 3140 my $destdir = $newdir; 3141 3142 # adding System integration files 3143 3144 my $sourcefile = ""; 3145 3146 # Finding the modules defined in scp (with flag SYSTEMMODULE) 3147 # Getting name of package from scp-Module 3148 # Search package in list off all include files 3149 # Copy file into installation set and unpack it (always tar.gz) 3150 # Create xpd file and put it into xpd directory 3151 # tar.gz can contain a different number of packages -> automatically create hidden sub modules 3152 # xpd file has to be created completely from module and package itself (-> no packagelist!) 3153 3154 # Collect all modules with flag "SYSTEMMODULE" 3155 my $allmodules = collect_modules_with_style("SYSTEMMODULE", $modulesarrayref); 3156 $allmodules = remove_modules_without_package($allmodules); 3157 3158 for ( my $i = 0; $i <= $#{$allmodules}; $i++ ) 3159 { 3160 my $onemodule = ${$allmodules}[$i]; 3161 my $packagetarfilename = $onemodule->{'PackageName'}; 3162 3163 my $infoline = "Including into installation set: $packagetarfilename\n"; 3164 push( @installer::globals::logfileinfo, $infoline); 3165 3166 my $sourcepathref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packagetarfilename, $includepatharrayref, 1); 3167 if ( $$sourcepathref eq "" ) { installer::exiter::exit_program("ERROR: Source path not found for $packagetarfilename!", "copy_systemintegration_files"); } 3168 3169 # Collecting all packages in directory "packages" or "RPMS" 3170 my $oldcontent = installer::systemactions::read_directory($destdir); 3171 3172 copy_and_unpack_tar_gz_files($$sourcepathref, $destdir); 3173 3174 # Finding new content -> that is the package name 3175 my ($newcontent, $allcontent ) = installer::systemactions::find_new_content_in_directory($destdir, $oldcontent); 3176 3177 # special handling, if new content is a directory 3178 my $subdir = ""; 3179 if ( ! $installer::globals::issolarispkgbuild ) { ($newcontent, $subdir) = control_subdirectories($newcontent); } 3180 3181 # Adding license content into Solaris packages 3182 if (( $installer::globals::issolarispkgbuild ) && ( $installer::globals::englishlicenseset ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} )) { installer::worker::add_license_into_systemintegrationpackages($destdir, $newcontent); } 3183 3184 if (( $installer::globals::isxpdplatform ) && ( $allvariables->{'XPDINSTALLER'} )) 3185 { 3186 installer::xpdinstaller::create_xpd_file_for_systemintegration($onemodule, $newcontent, $modulesarrayref, $subdir); 3187 } 3188 } 3189} 3190 3191###################################################### 3192# Analyzing the Unix installation path. 3193# From the installation path /opt/openofficeorg20 3194# is the part /opt relocatable and the part 3195# openofficeorg20 static. 3196###################################################### 3197 3198sub analyze_rootpath 3199{ 3200 my ($rootpath, $staticpathref, $relocatablepathref, $allvariables) = @_; 3201 3202 $rootpath =~ s/\/\s*$//; # removing ending slash 3203 3204 ############################################################## 3205 # Version 1: "/opt" is variable and "openofficeorg20" fixed 3206 ############################################################## 3207 3208 # my $staticpath = $rootpath; 3209 # installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$staticpath); 3210 # $$staticpathref = $staticpath; # will be "openofficeorg20" 3211 3212 # my $relocatablepath = $rootpath; 3213 # installer::pathanalyzer::get_path_from_fullqualifiedname(\$relocatablepath); 3214 # $$relocatablepathref = $relocatablepath; # will be "/opt/" 3215 3216 ############################################################## 3217 # Version 2: "/opt/openofficeorg20" is variable and "" fixed 3218 ############################################################## 3219 3220 # if ( $$relocatablepathref eq "" ) # relocatablepath is not defined in package list 3221 # { 3222 # $$staticpathref = ""; # will be "" 3223 # $$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/openofficeorg20/" 3224 # # setting the static path to the hostname of the directory with style OFFICEDIRECTORY 3225 # if ( $allvariables->{'SETSTATICPATH'} ) { $$staticpathref = $installer::globals::officedirhostname; } 3226 # 3227 # } 3228 # else # relocatablepath is defined in package list 3229 # { 3230 # $$relocatablepathref =~ s/\/\s*$//; # removing ending slash 3231 # $$relocatablepathref = $$relocatablepathref . "\/"; # relocatable path must end with "/" 3232 # my $staticpath = $rootpath; 3233 # $staticpath =~ s/\Q$$relocatablepathref\E//; 3234 # $staticpath =~ s/\/\s*$//; 3235 # $$staticpathref = $staticpath; 3236 # } 3237 3238 ############################################################## 3239 # Version 3: "/" is variable and "/opt/openofficeorg20" fixed 3240 ############################################################## 3241 3242 $$relocatablepathref = "/"; 3243 # Static path has to contain the office directory name. This is replaced in shellscripts. 3244 $$staticpathref = $rootpath . $installer::globals::separator . $installer::globals::officedirhostname; 3245 # For RPM version 3.x it is required, that Prefix is not "/" in spec file. In this case --relocate will not work, 3246 # because RPM 3.x says, that the package is not relocatable. Therefore we have to use Prefix=/opt and for 3247 # all usages of --relocate this path has to be on both sides of the "=": --relocate /opt=<myselectdir>/opt . 3248 if ( $installer::globals::islinuxrpmbuild ) 3249 { 3250 $$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/" 3251 $$staticpathref = $installer::globals::officedirhostname; # to be used as replacement in shell scripts 3252 } 3253 3254 if ( $installer::globals::islinuxdebbuild ) 3255 { 3256 $$relocatablepathref = ""; 3257 # $$staticpathref is already "/opt/openoffice.org3", no additional $rootpath required. 3258 # $$staticpathref = $rootpath . $installer::globals::separator . $$staticpathref; # no relocatibility for Debian 3259 } 3260 3261} 3262 3263###################################################### 3264# Including license and readme into 3265# Unix installation sets. 3266###################################################### 3267 3268sub put_installsetfiles_into_installset 3269{ 3270 my ($destdir) = @_; 3271 3272 # All files for the installation set are saved in the global 3273 # array @installer::globals::installsetfiles 3274 3275 for ( my $i = 0; $i <= $#installer::globals::installsetfiles; $i++ ) 3276 { 3277 my $onefile = $installer::globals::installsetfiles[$i]; 3278 my $sourcefile = $onefile->{'sourcepath'}; 3279 my $destfile = ""; 3280 if ( $installer::globals::addjavainstaller ) { $destfile = $onefile->{'Name'}; } 3281 else { $destfile = $destdir . $installer::globals::separator . $onefile->{'Name'}; } 3282 installer::systemactions::copy_one_file($sourcefile, $destfile); 3283 3284 my $infoline = "Adding to installation set \"$destfile\" from source \"$sourcefile\".\n"; 3285 push( @installer::globals::logfileinfo, $infoline); 3286 } 3287} 3288 3289###################################################### 3290# Replacing one variable in patchinfo file 3291###################################################### 3292 3293sub replace_one_variable_in_file 3294{ 3295 my ( $file, $placeholder, $value ) = @_; 3296 3297 for ( my $i = 0; $i <= $#{$file}; $i++ ) 3298 { 3299 ${$file}[$i] =~ s/$placeholder/$value/g; 3300 } 3301} 3302 3303###################################################### 3304# Setting variables in the patchinfo file 3305###################################################### 3306 3307sub set_patchinfo 3308{ 3309 my ( $patchinfofile, $patchid, $allvariables ) = @_; 3310 3311 # Setting: PATCHIDPLACEHOLDER and ARCHITECTUREPLACEHOLDER and PATCHCORRECTSPLACEHOLDER 3312 3313 replace_one_variable_in_file($patchinfofile, "PATCHIDPLACEHOLDER", $patchid); 3314 3315 my $architecture = ""; 3316 if ( $installer::globals::issolarissparcbuild ) { $architecture = "sparc"; } 3317 if ( $installer::globals::issolarisx86build ) { $architecture = "i386"; } 3318 3319 replace_one_variable_in_file($patchinfofile, "ARCHITECTUREPLACEHOLDER", $architecture); 3320 3321 if ( ! $allvariables->{'SOLARISPATCHCORRECTS'} ) { installer::exiter::exit_program("ERROR: No setting for PATCH_CORRECTS in zip list file!", "set_patchinfo"); } 3322 my $patchcorrects = $allvariables->{'SOLARISPATCHCORRECTS'}; 3323 3324 replace_one_variable_in_file($patchinfofile, "PATCHCORRECTSPLACEHOLDER", $patchcorrects); 3325 3326 # Setting also PATCH_REQUIRES in patch info file, if entry in zip list file exists 3327 my $requiresstring = ""; 3328 if ( $installer::globals::issolarissparcbuild ) { $requiresstring = "SOLSPARCPATCHREQUIRES"; } 3329 if ( $installer::globals::issolarisx86build ) { $requiresstring = "SOLIAPATCHREQUIRES"; } 3330 3331 if ( $allvariables->{$requiresstring} ) 3332 { 3333 my $newline = "PATCH_REQUIRES=\"" . $allvariables->{$requiresstring} . "\"" . "\n"; 3334 push(@{$patchinfofile}, $newline); 3335 } 3336} 3337 3338###################################################### 3339# Finalizing patch: Renaming directory and 3340# including additional patch files. 3341###################################################### 3342 3343sub finalize_patch 3344{ 3345 my ( $newepmdir, $allvariables ) = @_; 3346 3347 my $patchidname = "SOLSPARCPATCHID"; 3348 if ( $installer::globals::issolarisx86build ) { $patchidname = "SOLIAPATCHID"; } 3349 3350 if ( ! $allvariables->{$patchidname} ) { installer::exiter::exit_program("ERROR: Variable $patchidname not defined in zip list file!", "finalize_patch"); } 3351 my $patchid = $allvariables->{$patchidname}; 3352 installer::systemactions::rename_directory($newepmdir, $patchid); 3353 3354 # Copying all typical patch files into the patch directory 3355 # All patch file names are stored in @installer::globals::solarispatchfiles 3356 # Location of the file is $installer::globals::patchincludepath 3357 3358 my $sourcepath = $installer::globals::patchincludepath; 3359 $sourcepath =~ s/\/\s*$//; 3360 3361 for ( my $i = 0; $i <= $#installer::globals::solarispatchfiles; $i++ ) 3362 { 3363 my $sourcefile = $sourcepath . $installer::globals::separator . $installer::globals::solarispatchfiles[$i]; 3364 my $destfile = $patchid . $installer::globals::separator . $installer::globals::solarispatchfiles[$i]; 3365 installer::systemactions::copy_one_file($sourcefile, $destfile); 3366 } 3367 3368 # And editing the patchinfo file 3369 3370 my $patchinfofilename = $patchid . $installer::globals::separator . "patchinfo"; 3371 my $patchinfofile = installer::files::read_file($patchinfofilename); 3372 set_patchinfo($patchinfofile, $patchid, $allvariables); 3373 installer::files::save_file($patchinfofilename, $patchinfofile); 3374} 3375 3376###################################################### 3377# Finalizing Linux patch: Renaming directory and 3378# including additional patch files. 3379###################################################### 3380 3381sub finalize_linux_patch 3382{ 3383 my ( $newepmdir, $allvariables, $includepatharrayref ) = @_; 3384 3385 # Copying the setup into the patch directory 3386 # and including the list of RPMs into it 3387 3388 print "... creating patch setup ...\n"; 3389 3390 installer::logger::include_header_into_logfile("Creating Linux patch setup:"); 3391 3392 # find and read setup script template 3393 3394 my $scriptfilename = "linuxpatchscript.sh"; 3395 my $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptfilename, $includepatharrayref, 0); 3396 if ($$scriptref eq "") { installer::exiter::exit_program("ERROR: Could not find patch script template $scriptfilename!", "finalize_linux_patch"); } 3397 my $scriptfile = installer::files::read_file($$scriptref); 3398 3399 my $infoline = "Found script file $scriptfilename: $$scriptref \n"; 3400 push( @installer::globals::logfileinfo, $infoline); 3401 3402 # Collecting all RPMs in the patch directory 3403 3404 my $fileextension = "rpm"; 3405 my $rpmfiles = installer::systemactions::find_file_with_file_extension($fileextension, $newepmdir); 3406 if ( ! ( $#{$rpmfiles} > -1 )) { installer::exiter::exit_program("ERROR: Could not find rpm in directory $newepmdir!", "finalize_linux_patch"); } 3407 for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ ) { installer::pathanalyzer::make_absolute_filename_to_relative_filename(\${$rpmfiles}[$i]); } 3408 3409# my $installline = ""; 3410# 3411# for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ ) 3412# { 3413# $installline = $installline . " rpm --prefix \$PRODUCTINSTALLLOCATION -U $newepmdir/${$rpmfiles}[$i]\n"; 3414# } 3415# 3416# $installline =~ s/\s*$//; 3417# 3418# for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) 3419# { 3420# ${$scriptfile}[$j] =~ s/INSTALLLINES/$installline/; 3421# } 3422 3423 # Searching packagename containing -core01 3424 my $found_package = 0; 3425 my $searchpackagename = ""; 3426 for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ ) 3427 { 3428 if ( ${$rpmfiles}[$i] =~ /-core01-/ ) 3429 { 3430 $searchpackagename = ${$rpmfiles}[$i]; 3431 $found_package = 1; 3432 if ( $searchpackagename =~ /^\s*(.*?-core01)-.*/ ) { $searchpackagename = $1; } 3433 last; 3434 } 3435 } 3436 3437 if ( ! $found_package ) { installer::exiter::exit_program("ERROR: No package containing \"-core01\" found in directory \"$newepmdir\"", "finalize_linux_patch"); } 3438 3439 # Replacing the searchpackagename 3440 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/SEARCHPACKAGENAMEPLACEHOLDER/$searchpackagename/; } 3441 3442 # Setting the PRODUCTDIRECTORYNAME to $installer::globals::officedirhostname 3443 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/PRODUCTDIRECTORYNAME/$installer::globals::officedirhostname/; } 3444 3445 # Replacing the productname 3446 my $productname = $allvariables->{'PRODUCTNAME'}; 3447 $productname = lc($productname); 3448 $productname =~ s/ /_/g; # abc office -> abc_office 3449# $productname =~ s/\.//g; # openoffice.org -> openofficeorg 3450 3451 $infoline = "Adding productname $productname into Linux patch script\n"; 3452 push( @installer::globals::logfileinfo, $infoline); 3453 3454 for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/PRODUCTNAMEPLACEHOLDER/$productname/; } 3455 3456 # Saving the file 3457 3458 my $newscriptfilename = "setup"; # $newepmdir . $installer::globals::separator . "setup"; 3459 installer::files::save_file($newscriptfilename, $scriptfile); 3460 3461 $infoline = "Saved Linux patch setup $newscriptfilename \n"; 3462 push( @installer::globals::logfileinfo, $infoline); 3463 3464 # Setting unix rights 755 3465 my $localcall = "chmod 775 $newscriptfilename \>\/dev\/null 2\>\&1"; 3466 system($localcall); 3467} 3468 34691; 3470