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