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