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