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