| 1 |
# |
| 2 |
# This file is part of the LibreOffice project. |
| 3 |
# |
| 4 |
# This Source Code Form is subject to the terms of the Mozilla Public |
| 5 |
# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 7 |
# |
| 8 |
# This file incorporates work covered by the following license notice: |
| 9 |
# |
| 10 |
# Licensed to the Apache Software Foundation (ASF) under one or more |
| 11 |
# contributor license agreements. See the NOTICE file distributed |
| 12 |
# with this work for additional information regarding copyright |
| 13 |
# ownership. The ASF licenses this file to you under the Apache |
| 14 |
# License, Version 2.0 (the "License"); you may not use this file |
| 15 |
# except in compliance with the License. You may obtain a copy of |
| 16 |
# the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 17 |
# |
| 18 |
|
| 19 |
package installer::epmfile; |
| 20 |
|
| 21 |
use strict; |
| 22 |
use warnings; |
| 23 |
|
| 24 |
use Cwd qw(); |
| 25 |
use installer::converter; |
| 26 |
use installer::exiter; |
| 27 |
use installer::files; |
| 28 |
use installer::globals; |
| 29 |
use installer::logger; |
| 30 |
use installer::packagelist; |
| 31 |
use installer::pathanalyzer; |
| 32 |
use installer::remover; |
| 33 |
use installer::scpzipfiles; |
| 34 |
use installer::scriptitems; |
| 35 |
use installer::systemactions; |
| 36 |
use POSIX; |
| 37 |
|
| 38 |
# please Debian packaging, fdo#53341 |
| 39 |
sub debian_rewrite($) |
| 40 |
{ |
| 41 |
my $dep = shift; |
| 42 |
if ( $installer::globals::debian ) { |
| 43 |
$dep =~ s/_/-/g; # Debian allows no underline in package name |
| 44 |
$dep = lc ($dep); |
| 45 |
} |
| 46 |
return $dep; |
| 47 |
} |
| 48 |
|
| 49 |
############################################################################ |
| 50 |
# Reading the package map to find Solaris package names for |
| 51 |
# the corresponding abbreviations |
| 52 |
############################################################################ |
| 53 |
|
| 54 |
sub read_packagemap |
| 55 |
{ |
| 56 |
my ($allvariables, $includepatharrayref, $languagesarrayref) = @_; |
| 57 |
|
| 58 |
my $packagemapname = ""; |
| 59 |
if ( $allvariables->{'PACKAGEMAP'} ) { $packagemapname = $allvariables->{'PACKAGEMAP'}; } |
| 60 |
if ( $packagemapname eq "" ) { installer::exiter::exit_program("ERROR: Property PACKAGEMAP must be defined!", "read_packagemap"); } |
| 61 |
|
| 62 |
my $infoline = "\n\nCollected abbreviations and package names:\n"; |
| 63 |
push(@installer::globals::logfileinfo, $infoline); |
| 64 |
|
| 65 |
# Can be a comma separated list. All files have to be found in include paths |
| 66 |
my $allpackagemapnames = installer::converter::convert_stringlist_into_hash(\$packagemapname, ","); |
| 67 |
foreach my $onepackagemapname ( keys %{$allpackagemapnames} ) |
| 68 |
{ |
| 69 |
my $packagemapref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$onepackagemapname, $includepatharrayref, 0); |
| 70 |
|
| 71 |
if ( $$packagemapref eq "" ) { installer::exiter::exit_program("ERROR: Could not find package map file \"$onepackagemapname\" (property PACKAGEMAP)!", "read_packagemap"); } |
| 72 |
|
| 73 |
my $packagemapcontent = installer::files::read_file($$packagemapref); |
| 74 |
|
| 75 |
for ( my $i = 0; $i <= $#{$packagemapcontent}; $i++ ) |
| 76 |
{ |
| 77 |
my $line = ${$packagemapcontent}[$i]; |
| 78 |
|
| 79 |
if ( $line =~ /^\s*\#/ ) { next; } # comment line |
| 80 |
if ( $line =~ /^\s*$/ ) { next; } # empty line |
| 81 |
|
| 82 |
if ( $line =~ /^\s*(.*?)\t(.*?)\s*$/ ) |
| 83 |
{ |
| 84 |
my $abbreviation = $1; |
| 85 |
my $packagename = $2; |
| 86 |
installer::packagelist::resolve_packagevariables(\$abbreviation, $allvariables, 0); |
| 87 |
installer::packagelist::resolve_packagevariables(\$packagename, $allvariables, 0); |
| 88 |
|
| 89 |
# Special handling for language strings %LANGUAGESTRING |
| 90 |
|
| 91 |
if (( $abbreviation =~ /\%LANGUAGESTRING/ ) || ( $packagename =~ /\%LANGUAGESTRING/ )) |
| 92 |
{ |
| 93 |
foreach my $onelang ( @{$languagesarrayref} ) |
| 94 |
{ |
| 95 |
my $local_abbreviation = $abbreviation; |
| 96 |
my $local_packagename = $packagename; |
| 97 |
$local_abbreviation =~ s/\%LANGUAGESTRING/$onelang/g; |
| 98 |
$local_packagename =~ s/\%LANGUAGESTRING/$onelang/g; |
| 99 |
|
| 100 |
# Logging all abbreviations and packagenames |
| 101 |
$infoline = "$onelang : $local_abbreviation : $local_packagename\n"; |
| 102 |
push(@installer::globals::logfileinfo, $infoline); |
| 103 |
|
| 104 |
if ( exists($installer::globals::dependfilenames{$local_abbreviation}) ) |
| 105 |
{ |
| 106 |
installer::exiter::exit_program("ERROR: Packagename for Solaris package $local_abbreviation already defined ($installer::globals::dependfilenames{$local_abbreviation})!", "read_packagemap"); |
| 107 |
} |
| 108 |
else |
| 109 |
{ |
| 110 |
$installer::globals::dependfilenames{$local_abbreviation} = $local_packagename; |
| 111 |
} |
| 112 |
} |
| 113 |
} |
| 114 |
else |
| 115 |
{ |
| 116 |
# Logging all abbreviations and packagenames |
| 117 |
$infoline = "$abbreviation : $packagename\n"; |
| 118 |
push(@installer::globals::logfileinfo, $infoline); |
| 119 |
|
| 120 |
if ( exists($installer::globals::dependfilenames{$abbreviation}) ) |
| 121 |
{ |
| 122 |
installer::exiter::exit_program("ERROR: Packagename for Solaris package $abbreviation already defined ($installer::globals::dependfilenames{$abbreviation})!", "read_packagemap"); |
| 123 |
} |
| 124 |
else |
| 125 |
{ |
| 126 |
$installer::globals::dependfilenames{$abbreviation} = $packagename; |
| 127 |
} |
| 128 |
} |
| 129 |
} |
| 130 |
else |
| 131 |
{ |
| 132 |
my $errorline = $i + 1; |
| 133 |
installer::exiter::exit_program("ERROR: Wrong syntax in file \"$onepackagemapname\" (line $errorline)!", "read_packagemap"); |
| 134 |
} |
| 135 |
} |
| 136 |
} |
| 137 |
|
| 138 |
$infoline = "\n\n"; |
| 139 |
push(@installer::globals::logfileinfo, $infoline); |
| 140 |
|
| 141 |
} |
| 142 |
|
| 143 |
########################################################## |
| 144 |
# Filling the epm file with directories, files and links |
| 145 |
########################################################## |
| 146 |
|
| 147 |
sub put_directories_into_epmfile |
| 148 |
{ |
| 149 |
my ($directoriesarrayref, $epmfileref, $allvariables, $packagerootpath) = @_; |
| 150 |
my $group = "bin"; |
| 151 |
|
| 152 |
if ( $installer::globals::islinuxbuild ) |
| 153 |
{ |
| 154 |
$group = "root"; |
| 155 |
} |
| 156 |
|
| 157 |
for ( my $i = 0; $i <= $#{$directoriesarrayref}; $i++ ) |
| 158 |
{ |
| 159 |
my $onedir = ${$directoriesarrayref}[$i]; |
| 160 |
my $dir = ""; |
| 161 |
|
| 162 |
if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; } |
| 163 |
|
| 164 |
if ((!($dir =~ /\bPREDEFINED_/ )) || ( $dir =~ /\bPREDEFINED_PROGDIR\b/ )) |
| 165 |
{ |
| 166 |
my $hostname = $onedir->{'HostName'}; |
| 167 |
|
| 168 |
my $line = "d 755 root $group $hostname -\n"; |
| 169 |
|
| 170 |
push(@{$epmfileref}, $line) |
| 171 |
} |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
sub put_files_into_epmfile |
| 176 |
{ |
| 177 |
my ($filesinproductarrayref, $epmfileref) = @_; |
| 178 |
|
| 179 |
for ( my $i = 0; $i <= $#{$filesinproductarrayref}; $i++ ) |
| 180 |
{ |
| 181 |
my $onefile = ${$filesinproductarrayref}[$i]; |
| 182 |
|
| 183 |
my $unixrights = $onefile->{'UnixRights'}; |
| 184 |
my $destination = $onefile->{'destination'}; |
| 185 |
my $sourcepath = $onefile->{'sourcepath'}; |
| 186 |
|
| 187 |
my $filetype = "f"; |
| 188 |
my $styles = ""; |
| 189 |
if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; } |
| 190 |
if ( $styles =~ /\bCONFIGFILE\b/ ) { $filetype = "c"; } |
| 191 |
|
| 192 |
my $group = "bin"; |
| 193 |
if ( $installer::globals::islinuxbuild ) { $group = "root"; } |
| 194 |
if (( $installer::globals::issolarisbuild ) && ( $onefile->{'SolarisGroup'} )) { $group = $onefile->{'SolarisGroup'}; } |
| 195 |
|
| 196 |
my $line = "$filetype $unixrights root $group $destination $sourcepath\n"; |
| 197 |
|
| 198 |
push(@{$epmfileref}, $line); |
| 199 |
} |
| 200 |
} |
| 201 |
|
| 202 |
sub put_links_into_epmfile |
| 203 |
{ |
| 204 |
my ($linksinproductarrayref, $epmfileref) = @_; |
| 205 |
my $group = "bin"; |
| 206 |
|
| 207 |
if ( $installer::globals::islinuxbuild ) |
| 208 |
{ |
| 209 |
$group = "root"; |
| 210 |
} |
| 211 |
|
| 212 |
|
| 213 |
for ( my $i = 0; $i <= $#{$linksinproductarrayref}; $i++ ) |
| 214 |
{ |
| 215 |
my $onelink = ${$linksinproductarrayref}[$i]; |
| 216 |
my $destination = $onelink->{'destination'}; |
| 217 |
my $destinationfile = $onelink->{'destinationfile'}; |
| 218 |
|
| 219 |
my $line = "l 000 root $group $destination $destinationfile\n"; |
| 220 |
|
| 221 |
push(@{$epmfileref}, $line) |
| 222 |
} |
| 223 |
} |
| 224 |
|
| 225 |
sub put_unixlinks_into_epmfile |
| 226 |
{ |
| 227 |
my ($unixlinksinproductarrayref, $epmfileref) = @_; |
| 228 |
my $group = "bin"; |
| 229 |
|
| 230 |
if ( $installer::globals::islinuxbuild ) { $group = "root"; } |
| 231 |
|
| 232 |
for ( my $i = 0; $i <= $#{$unixlinksinproductarrayref}; $i++ ) |
| 233 |
{ |
| 234 |
my $onelink = ${$unixlinksinproductarrayref}[$i]; |
| 235 |
my $destination = $onelink->{'destination'}; |
| 236 |
my $target = $onelink->{'Target'}; |
| 237 |
|
| 238 |
my $line = "l 000 root $group $destination $target\n"; |
| 239 |
|
| 240 |
push(@{$epmfileref}, $line) |
| 241 |
} |
| 242 |
} |
| 243 |
|
| 244 |
############################################### |
| 245 |
# Creating epm header file |
| 246 |
############################################### |
| 247 |
|
| 248 |
sub create_epm_header |
| 249 |
{ |
| 250 |
my ($variableshashref, $filesinproduct, $languagesref, $onepackage) = @_; |
| 251 |
|
| 252 |
my @epmheader = (); |
| 253 |
|
| 254 |
my ($licensefilename, $readmefilename, $readmefilenameen); |
| 255 |
|
| 256 |
my $foundlicensefile = 0; |
| 257 |
my $foundreadmefile = 0; |
| 258 |
|
| 259 |
my $line = ""; |
| 260 |
my $infoline = ""; |
| 261 |
|
| 262 |
# %product LibreOffice Software |
| 263 |
# %version 2.0 |
| 264 |
# %description A really great software |
| 265 |
# %copyright 1999-2003 by OOo |
| 266 |
# %vendor LibreOffice |
| 267 |
# %license /test/replace/01/LICENSE01 |
| 268 |
# %readme /test/replace/01/README01 |
| 269 |
# %requires foo |
| 270 |
# %provides bar |
| 271 |
# %replaces bar |
| 272 |
# %incompat bar |
| 273 |
|
| 274 |
# The first language in the languages array determines the language of license and readme file |
| 275 |
|
| 276 |
my $searchlanguage = ${$languagesref}[0]; |
| 277 |
|
| 278 |
# using the description for the %product line in the epm list file |
| 279 |
|
| 280 |
my $productnamestring = $onepackage->{'description'}; |
| 281 |
installer::packagelist::resolve_packagevariables(\$productnamestring, $variableshashref, 0); |
| 282 |
if ( $variableshashref->{'PRODUCTEXTENSION'} ) { $productnamestring = $productnamestring . $variableshashref->{'PRODUCTEXTENSION'}; } |
| 283 |
|
| 284 |
$line = "%product" . " " . $productnamestring . "\n"; |
| 285 |
push(@epmheader, $line); |
| 286 |
|
| 287 |
# Determining the release version |
| 288 |
# This release version has to be listed in the line %version : %version versionnumber releasenumber |
| 289 |
|
| 290 |
if ( ! $onepackage->{'packageversion'} ) { installer::exiter::exit_program("ERROR: No packageversion defined for package: $onepackage->{'module'}!", "create_epm_header"); } |
| 291 |
$installer::globals::packageversion = $onepackage->{'packageversion'}; |
| 292 |
installer::packagelist::resolve_packagevariables(\$installer::globals::packageversion, $variableshashref, 0); |
| 293 |
if ( $variableshashref->{'PACKAGEREVISION'} ) { $installer::globals::packagerevision = $variableshashref->{'PACKAGEREVISION'}; } |
| 294 |
|
| 295 |
$line = "%version" . " " . $installer::globals::packageversion . "\n"; |
| 296 |
push(@epmheader, $line); |
| 297 |
|
| 298 |
$line = "%release" . " " . $installer::globals::packagerevision . "\n"; |
| 299 |
if ( $installer::globals::isrpmbuild ) { $line = "%release" . " " . $installer::globals::buildid . "\n"; } |
| 300 |
push(@epmheader, $line); |
| 301 |
|
| 302 |
# Description, Copyright and Vendor are multilingual and are defined in |
| 303 |
# the string file for the header file ($headerfileref) |
| 304 |
|
| 305 |
my $descriptionstring = $onepackage->{'description'}; |
| 306 |
installer::packagelist::resolve_packagevariables(\$descriptionstring, $variableshashref, 0); |
| 307 |
$line = "%description" . " " . $descriptionstring . "\n"; |
| 308 |
push(@epmheader, $line); |
| 309 |
|
| 310 |
my $copyrightstring = $onepackage->{'copyright'}; |
| 311 |
installer::packagelist::resolve_packagevariables(\$copyrightstring, $variableshashref, 0); |
| 312 |
$line = "%copyright" . " " . $copyrightstring . "\n"; |
| 313 |
push(@epmheader, $line); |
| 314 |
|
| 315 |
my $vendorstring = $onepackage->{'vendor'}; |
| 316 |
installer::packagelist::resolve_packagevariables(\$vendorstring, $variableshashref, 0); |
| 317 |
$line = "%vendor" . " " . $vendorstring . "\n"; |
| 318 |
push(@epmheader, $line); |
| 319 |
|
| 320 |
# License and Readme file can be included automatically from the file list |
| 321 |
|
| 322 |
if ( $installer::globals::iswindowsbuild ) |
| 323 |
{ |
| 324 |
$licensefilename = "license.txt"; |
| 325 |
$readmefilename = "readme.txt"; |
| 326 |
$readmefilenameen = "readme_en-US.txt"; |
| 327 |
} |
| 328 |
else |
| 329 |
{ |
| 330 |
$licensefilename = "LICENSE"; |
| 331 |
$readmefilename = "README"; |
| 332 |
$readmefilenameen = "README_en-US"; |
| 333 |
} |
| 334 |
|
| 335 |
if (( $installer::globals::languagepack ) # in language packs and help packs the files LICENSE and README are removed, because they are not language specific |
| 336 |
|| ( $installer::globals::helppack ) |
| 337 |
|| ( $variableshashref->{'NO_README_IN_ROOTDIR'} )) |
| 338 |
{ |
| 339 |
if ( $installer::globals::iswindowsbuild ) |
| 340 |
{ |
| 341 |
$licensefilename = "license.txt"; |
| 342 |
$readmefilename = "readme_$searchlanguage.txt"; |
| 343 |
} |
| 344 |
else |
| 345 |
{ |
| 346 |
$licensefilename = "LICENSE"; |
| 347 |
$readmefilename = "README_$searchlanguage"; |
| 348 |
} |
| 349 |
} |
| 350 |
|
| 351 |
my $license_in_package_defined = 0; |
| 352 |
|
| 353 |
if ( $installer::globals::issolarisbuild ) |
| 354 |
{ |
| 355 |
if ( $onepackage->{'solariscopyright'} ) |
| 356 |
{ |
| 357 |
$licensefilename = $onepackage->{'solariscopyright'}; |
| 358 |
$license_in_package_defined = 1; |
| 359 |
} |
| 360 |
} |
| 361 |
|
| 362 |
# Process for Linux packages, in which only a very basic license file is |
| 363 |
# included into the package. |
| 364 |
|
| 365 |
if ( $installer::globals::islinuxbuild ) |
| 366 |
{ |
| 367 |
if ( $variableshashref->{'COPYRIGHT_INTO_LINUXPACKAGE'} ) |
| 368 |
{ |
| 369 |
$licensefilename = "linuxcopyrightfile"; |
| 370 |
$license_in_package_defined = 1; |
| 371 |
} |
| 372 |
} |
| 373 |
|
| 374 |
# searching for and readme file; |
| 375 |
# URE uses special README; others use README_en-US |
| 376 |
# it does not matter which one is passed for epm if both are packaged |
| 377 |
foreach my $possiblereadmefilename ($readmefilenameen, $readmefilename) |
| 378 |
{ |
| 379 |
last if ($foundreadmefile); |
| 380 |
for ( my $i = 0; $i <= $#{$filesinproduct}; $i++ ) |
| 381 |
{ |
| 382 |
my $onefile = ${$filesinproduct}[$i]; |
| 383 |
my $filename = $onefile->{'Name'}; |
| 384 |
# in the SDK it's in subdirectory sdk/share/readme |
| 385 |
if ( $filename =~ /$possiblereadmefilename$/ ) |
| 386 |
{ |
| 387 |
$foundreadmefile = 1; |
| 388 |
$line = "%readme" . " " . $onefile->{'sourcepath'} . "\n"; |
| 389 |
push(@epmheader, $line); |
| 390 |
last; |
| 391 |
} |
| 392 |
} |
| 393 |
} |
| 394 |
|
| 395 |
# the readme file need not be packaged more times in the help content |
| 396 |
# it needs to be installed in parallel with the main package anyway |
| 397 |
# try to find the README file between all available files (not only between the packaged) |
| 398 |
if (!($foundreadmefile) && $installer::globals::helppack) |
| 399 |
{ |
| 400 |
my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$readmefilenameen, "" , 0); |
| 401 |
if($$fileref ne "" ) |
| 402 |
{ |
| 403 |
$infoline = "Fallback to readme file: \"$$fileref\"!\n"; |
| 404 |
push(@installer::globals::logfileinfo, $infoline); |
| 405 |
|
| 406 |
$foundreadmefile = 1; |
| 407 |
$line = "%readme" . " " . $$fileref . "\n"; |
| 408 |
push(@epmheader, $line); |
| 409 |
} |
| 410 |
} |
| 411 |
|
| 412 |
if (!$foundreadmefile && $variableshashref->{'NO_README_IN_ROOTDIR'}) |
| 413 |
{ |
| 414 |
$infoline = "Fallback to dummy readme file\n"; |
| 415 |
push(@installer::globals::logfileinfo, $infoline); |
| 416 |
|
| 417 |
$foundreadmefile = 1; |
| 418 |
$line = "%readme DUMMY\n"; |
| 419 |
push(@epmheader, $line); |
| 420 |
} |
| 421 |
|
| 422 |
# searching for and license file |
| 423 |
|
| 424 |
if ( $license_in_package_defined ) |
| 425 |
{ |
| 426 |
my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, "" , 0); |
| 427 |
|
| 428 |
if ( $$fileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find license file $licensefilename (A)!", "create_epm_header"); } |
| 429 |
|
| 430 |
# Special handling to add the content of the file "license_en-US" to the solaris copyrightfile. But not for all products |
| 431 |
|
| 432 |
if (( $installer::globals::issolarispkgbuild ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} )) |
| 433 |
{ |
| 434 |
if ( ! $installer::globals::englishlicenseset ) { _set_english_license($variableshashref) } |
| 435 |
|
| 436 |
# The location for the new file |
| 437 |
my $languagestring = ""; |
| 438 |
for ( my $i = 0; $i <= $#{$languagesref}; $i++ ) { $languagestring = $languagestring . "_" . ${$languagesref}[$i]; } |
| 439 |
$languagestring =~ s/^\s*_//; |
| 440 |
|
| 441 |
my $copyrightdir = installer::systemactions::create_directories("copyright", \$languagestring); |
| 442 |
|
| 443 |
my $copyrightfile = installer::files::read_file($$fileref); |
| 444 |
|
| 445 |
# Adding license content to copyright file |
| 446 |
push(@{$copyrightfile}, "\n"); |
| 447 |
for ( my $i = 0; $i <= $#{$installer::globals::englishlicense}; $i++ ) { push(@{$copyrightfile}, ${$installer::globals::englishlicense}[$i]); } |
| 448 |
|
| 449 |
# New destination for $$fileref |
| 450 |
$$fileref = $copyrightdir . $installer::globals::separator . "solariscopyrightfile_" . $onepackage->{'module'}; |
| 451 |
if ( -f $$fileref ) { unlink $$fileref; } |
| 452 |
installer::files::save_file($$fileref, $copyrightfile); |
| 453 |
} |
| 454 |
|
| 455 |
$infoline = "Using license file: \"$$fileref\"!\n"; |
| 456 |
push(@installer::globals::logfileinfo, $infoline); |
| 457 |
|
| 458 |
$foundlicensefile = 1; |
| 459 |
$line = "%license" . " " . $$fileref . "\n"; |
| 460 |
push(@epmheader, $line); |
| 461 |
} |
| 462 |
else |
| 463 |
{ |
| 464 |
for my $onefile (@{$filesinproduct}) |
| 465 |
{ |
| 466 |
# in the SDK it's in subdirectory sdk/share/readme so try to match that |
| 467 |
if ($onefile->{'Name'} =~ /$licensefilename$/) |
| 468 |
{ |
| 469 |
push @epmheader, "%license" . " " . $onefile->{'sourcepath'} . "\n"; |
| 470 |
$foundlicensefile = 1; |
| 471 |
last; |
| 472 |
} |
| 473 |
} |
| 474 |
|
| 475 |
# the license file need not be packaged more times in the langpacks |
| 476 |
# they need to be installed in parallel with the main package anyway |
| 477 |
# try to find the LICENSE file between all available files (not only between the packaged) |
| 478 |
if (!($foundlicensefile) && ($installer::globals::languagepack || $installer::globals::helppack)) |
| 479 |
{ |
| 480 |
my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, "" , 0); |
| 481 |
if($$fileref ne "" ) |
| 482 |
{ |
| 483 |
$infoline = "Fallback to license file: \"$$fileref\"!\n"; |
| 484 |
push(@installer::globals::logfileinfo, $infoline); |
| 485 |
|
| 486 |
$foundlicensefile = 1; |
| 487 |
$line = "%license" . " " . $$fileref . "\n"; |
| 488 |
push(@epmheader, $line); |
| 489 |
} |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
if (!($foundlicensefile)) |
| 494 |
{ |
| 495 |
installer::exiter::exit_program("ERROR: Could not find license file $licensefilename (B)", "create_epm_header"); |
| 496 |
} |
| 497 |
|
| 498 |
if (!($foundreadmefile)) |
| 499 |
{ |
| 500 |
installer::exiter::exit_program("ERROR: Could not find readme file $readmefilename (C)", "create_epm_header"); |
| 501 |
} |
| 502 |
|
| 503 |
# including %replaces |
| 504 |
|
| 505 |
my $replaces = ""; |
| 506 |
|
| 507 |
if ( $installer::globals::issolarispkgbuild ) |
| 508 |
{ |
| 509 |
$replaces = "solarisreplaces"; # the name in the packagelist |
| 510 |
} |
| 511 |
elsif ( $installer::globals::islinuxbuild ) |
| 512 |
{ |
| 513 |
$replaces = "linuxreplaces"; # the name in the packagelist |
| 514 |
} |
| 515 |
|
| 516 |
if ( $replaces ) |
| 517 |
{ |
| 518 |
if ( $onepackage->{$replaces} ) |
| 519 |
{ |
| 520 |
my $replacesstring = $onepackage->{$replaces}; |
| 521 |
|
| 522 |
my $allreplaces = installer::converter::convert_stringlist_into_array(\$replacesstring, ","); |
| 523 |
|
| 524 |
for ( my $i = 0; $i <= $#{$allreplaces}; $i++ ) |
| 525 |
{ |
| 526 |
my $onereplaces = ${$allreplaces}[$i]; |
| 527 |
$onereplaces =~ s/\s*$//; |
| 528 |
installer::packagelist::resolve_packagevariables(\$onereplaces, $variableshashref, 1); |
| 529 |
$onereplaces = debian_rewrite($onereplaces); |
| 530 |
$line = "%replaces" . " " . $onereplaces . "\n"; |
| 531 |
push(@epmheader, $line); |
| 532 |
} |
| 533 |
} |
| 534 |
} |
| 535 |
|
| 536 |
# including %incompat |
| 537 |
|
| 538 |
my $incompat = ""; |
| 539 |
|
| 540 |
if (( $installer::globals::issolarispkgbuild ) && ( ! $installer::globals::patch )) |
| 541 |
{ |
| 542 |
$incompat = "solarisincompat"; # the name in the packagelist |
| 543 |
} |
| 544 |
elsif (( $installer::globals::islinuxbuild ) && ( ! $installer::globals::patch )) |
| 545 |
{ |
| 546 |
$incompat = "linuxincompat"; # the name in the packagelist |
| 547 |
} |
| 548 |
|
| 549 |
if (( $incompat ) && ( ! $installer::globals::patch )) |
| 550 |
{ |
| 551 |
if ( $onepackage->{$incompat} ) |
| 552 |
{ |
| 553 |
my $incompatstring = $onepackage->{$incompat}; |
| 554 |
|
| 555 |
my $allincompat = installer::converter::convert_stringlist_into_array(\$incompatstring, ","); |
| 556 |
|
| 557 |
for ( my $i = 0; $i <= $#{$allincompat}; $i++ ) |
| 558 |
{ |
| 559 |
my $oneincompat = ${$allincompat}[$i]; |
| 560 |
$oneincompat =~ s/\s*$//; |
| 561 |
installer::packagelist::resolve_packagevariables(\$oneincompat, $variableshashref, 1); |
| 562 |
$oneincompat = debian_rewrite($oneincompat); |
| 563 |
$line = "%incompat" . " " . $oneincompat . "\n"; |
| 564 |
push(@epmheader, $line); |
| 565 |
} |
| 566 |
} |
| 567 |
} |
| 568 |
|
| 569 |
# including the directives for %requires and %provides |
| 570 |
|
| 571 |
my $provides = ""; |
| 572 |
my $requires = ""; |
| 573 |
|
| 574 |
if ( $installer::globals::issolarispkgbuild ) |
| 575 |
{ |
| 576 |
$provides = "solarisprovides"; # the name in the packagelist |
| 577 |
$requires = "solarisrequires"; # the name in the packagelist |
| 578 |
} |
| 579 |
elsif ( $installer::globals::isfreebsdpkgbuild ) |
| 580 |
{ |
| 581 |
$provides = "freebsdprovides"; # the name in the packagelist |
| 582 |
$requires = "freebsdrequires"; # the name in the packagelist |
| 583 |
} |
| 584 |
else |
| 585 |
{ |
| 586 |
$provides = "provides"; # the name in the packagelist |
| 587 |
$requires = "requires"; # the name in the packagelist |
| 588 |
} |
| 589 |
|
| 590 |
my $isdict = 0; |
| 591 |
if ( $onepackage->{'packagename'} =~ /-dict-/ ) { $isdict = 1; } |
| 592 |
|
| 593 |
if ( $onepackage->{$provides} ) |
| 594 |
{ |
| 595 |
my $providesstring = $onepackage->{$provides}; |
| 596 |
|
| 597 |
my $allprovides = installer::converter::convert_stringlist_into_array(\$providesstring, ","); |
| 598 |
|
| 599 |
for ( my $i = 0; $i <= $#{$allprovides}; $i++ ) |
| 600 |
{ |
| 601 |
my $oneprovides = ${$allprovides}[$i]; |
| 602 |
$oneprovides =~ s/\s*$//; |
| 603 |
installer::packagelist::resolve_packagevariables(\$oneprovides, $variableshashref, 1); |
| 604 |
$oneprovides = debian_rewrite($oneprovides); |
| 605 |
$line = "%provides" . " " . $oneprovides . "\n"; |
| 606 |
push(@epmheader, $line); |
| 607 |
} |
| 608 |
} |
| 609 |
|
| 610 |
if ( $onepackage->{$requires} ) |
| 611 |
{ |
| 612 |
my $requiresstring = $onepackage->{$requires}; |
| 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 |
$onerequires = debian_rewrite($onerequires); |
| 633 |
$line = "%requires" . " " . $onerequires . "\n"; |
| 634 |
push(@epmheader, $line); |
| 635 |
} |
| 636 |
} |
| 637 |
|
| 638 |
return \@epmheader; |
| 639 |
} |
| 640 |
|
| 641 |
####################################### |
| 642 |
# Adding header to epm file |
| 643 |
####################################### |
| 644 |
|
| 645 |
sub adding_header_to_epm_file |
| 646 |
{ |
| 647 |
my ($epmfileref, $epmheaderref) = @_; |
| 648 |
|
| 649 |
for ( my $i = 0; $i <= $#{$epmheaderref}; $i++ ) |
| 650 |
{ |
| 651 |
push( @{$epmfileref}, ${$epmheaderref}[$i] ); |
| 652 |
} |
| 653 |
|
| 654 |
push( @{$epmfileref}, "\n\n" ); |
| 655 |
} |
| 656 |
|
| 657 |
##################################################### |
| 658 |
# Replace one in shell scripts ( ${VARIABLENAME} ) |
| 659 |
##################################################### |
| 660 |
|
| 661 |
sub replace_variable_in_shellscripts |
| 662 |
{ |
| 663 |
my ($scriptref, $variable, $searchstring) = @_; |
| 664 |
|
| 665 |
for ( my $i = 0; $i <= $#{$scriptref}; $i++ ) |
| 666 |
{ |
| 667 |
${$scriptref}[$i] =~ s/\$\{$searchstring\}/$variable/g; |
| 668 |
} |
| 669 |
} |
| 670 |
|
| 671 |
################################################ |
| 672 |
# Replacing many variables in shell scripts |
| 673 |
################################################ |
| 674 |
|
| 675 |
sub replace_many_variables_in_shellscripts |
| 676 |
{ |
| 677 |
my ($scriptref, $variableshashref) = @_; |
| 678 |
|
| 679 |
my $key; |
| 680 |
|
| 681 |
foreach $key (keys %{$variableshashref}) |
| 682 |
{ |
| 683 |
my $value = $variableshashref->{$key}; |
| 684 |
replace_variable_in_shellscripts($scriptref, $value, $key); |
| 685 |
} |
| 686 |
} |
| 687 |
|
| 688 |
####################################### |
| 689 |
# Adding shell scripts to epm file |
| 690 |
####################################### |
| 691 |
|
| 692 |
sub adding_shellscripts_to_epm_file |
| 693 |
{ |
| 694 |
my ($epmfileref, $shellscriptsfilename, $localrootpath, $allvariableshashref, $filesinpackage) = @_; |
| 695 |
|
| 696 |
push( @{$epmfileref}, "\n\n" ); |
| 697 |
|
| 698 |
my $shellscriptsfileref = installer::files::read_file($shellscriptsfilename); |
| 699 |
|
| 700 |
replace_variable_in_shellscripts($shellscriptsfileref, $localrootpath, "rootpath"); |
| 701 |
|
| 702 |
replace_many_variables_in_shellscripts($shellscriptsfileref, $allvariableshashref); |
| 703 |
|
| 704 |
for ( my $i = 0; $i <= $#{$shellscriptsfileref}; $i++ ) |
| 705 |
{ |
| 706 |
push( @{$epmfileref}, ${$shellscriptsfileref}[$i] ); |
| 707 |
} |
| 708 |
|
| 709 |
push( @{$epmfileref}, "\n" ); |
| 710 |
} |
| 711 |
|
| 712 |
################################################# |
| 713 |
# Determining the epm on the system |
| 714 |
################################################# |
| 715 |
|
| 716 |
sub find_epm_on_system |
| 717 |
{ |
| 718 |
my ($includepatharrayref) = @_; |
| 719 |
|
| 720 |
installer::logger::include_header_into_logfile("Check epm on system"); |
| 721 |
|
| 722 |
my $epmname = "epm"; |
| 723 |
|
| 724 |
# epm should be defined through the configure script but we need to |
| 725 |
# check for it to be defined because of the Sun environment. |
| 726 |
# Check the environment variable first and if it is not defined, |
| 727 |
# or if it is but the location is not executable, search further. |
| 728 |
# It has to be found in the solver or it has to be in the path |
| 729 |
# (saved in $installer::globals::epm_in_path) or we get the specified |
| 730 |
# one through the environment (i.e. when --with-epm=... is specified) |
| 731 |
|
| 732 |
if ($ENV{'EPM'}) |
| 733 |
{ |
| 734 |
if (($ENV{'EPM'} ne "") && (-x "$ENV{'EPM'}")) |
| 735 |
{ |
| 736 |
$epmname = $ENV{'EPM'}; |
| 737 |
} |
| 738 |
else |
| 739 |
{ |
| 740 |
installer::exiter::exit_program("Environment variable EPM set (\"$ENV{'EPM'}\"), but file does not exist or is not executable!", "find_epm_on_system"); |
| 741 |
} |
| 742 |
} |
| 743 |
else |
| 744 |
{ |
| 745 |
my $epmfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$epmname, $includepatharrayref, 0); |
| 746 |
|
| 747 |
if (($$epmfileref eq "") && (!($installer::globals::epm_in_path))) { installer::exiter::exit_program("ERROR: Could not find program $epmname!", "find_epm_on_system"); } |
| 748 |
if (($$epmfileref eq "") && ($installer::globals::epm_in_path)) { $epmname = $installer::globals::epm_path; } |
| 749 |
if (!($$epmfileref eq "")) { $epmname = $$epmfileref; } |
| 750 |
} |
| 751 |
|
| 752 |
my $infoline = "Using epmfile: $epmname\n"; |
| 753 |
push( @installer::globals::logfileinfo, $infoline); |
| 754 |
|
| 755 |
return $epmname; |
| 756 |
} |
| 757 |
|
| 758 |
################################################# |
| 759 |
# Determining the epm patch state |
| 760 |
# saved in $installer::globals::is_special_epm |
| 761 |
################################################# |
| 762 |
|
| 763 |
sub set_patch_state |
| 764 |
{ |
| 765 |
my ($epmexecutable) = @_; |
| 766 |
|
| 767 |
my $infoline = ""; |
| 768 |
|
| 769 |
my $systemcall = "$epmexecutable |"; |
| 770 |
open (EPMPATCH, "$systemcall"); |
| 771 |
|
| 772 |
while (<EPMPATCH>) |
| 773 |
{ |
| 774 |
chop; |
| 775 |
if ( $_ =~ /Patched for .*Office/ ) { $installer::globals::is_special_epm = 1; } |
| 776 |
} |
| 777 |
|
| 778 |
close (EPMPATCH); |
| 779 |
|
| 780 |
if ( $installer::globals::is_special_epm ) |
| 781 |
{ |
| 782 |
$infoline = "\nPatch state: This is a patched version of epm!\n\n"; |
| 783 |
push( @installer::globals::logfileinfo, $infoline); |
| 784 |
} |
| 785 |
else |
| 786 |
{ |
| 787 |
$infoline = "\nPatch state: This is an unpatched version of epm!\n\n"; |
| 788 |
push( @installer::globals::logfileinfo, $infoline); |
| 789 |
} |
| 790 |
|
| 791 |
if ( ( $installer::globals::is_special_epm ) && (($installer::globals::isrpmbuild) || ($installer::globals::issolarispkgbuild)) ) |
| 792 |
{ |
| 793 |
# Special postprocess handling only for Linux RPM and Solaris packages |
| 794 |
$installer::globals::postprocess_specialepm = 1; |
| 795 |
$installer::globals::postprocess_standardepm = 0; |
| 796 |
} |
| 797 |
else |
| 798 |
{ |
| 799 |
$installer::globals::postprocess_specialepm = 0; |
| 800 |
$installer::globals::postprocess_standardepm = 1; |
| 801 |
} |
| 802 |
} |
| 803 |
|
| 804 |
################################################# |
| 805 |
# Calling epm to create the installation sets |
| 806 |
################################################# |
| 807 |
|
| 808 |
sub call_epm |
| 809 |
{ |
| 810 |
my ($epmname, $epmlistfilename, $packagename, $includepatharrayref) = @_; |
| 811 |
|
| 812 |
installer::logger::include_header_into_logfile("epm call for $packagename"); |
| 813 |
|
| 814 |
my $packageformat = $installer::globals::packageformat; |
| 815 |
|
| 816 |
my $localpackagename = $packagename; |
| 817 |
# Debian allows only lowercase letters in package name |
| 818 |
if ( $installer::globals::debian ) { $localpackagename = lc($localpackagename); } |
| 819 |
|
| 820 |
my $outdirstring = ""; |
| 821 |
if ( $installer::globals::epmoutpath ne "" ) { $outdirstring = " --output-dir $installer::globals::epmoutpath"; } |
| 822 |
|
| 823 |
# Debian package build needs to be run with fakeroot for correct ownerships/permissions |
| 824 |
|
| 825 |
my $fakerootstring = ""; |
| 826 |
|
| 827 |
if ( $installer::globals::debian ) { $fakerootstring = "fakeroot "; } |
| 828 |
|
| 829 |
my $extraflags = ""; |
| 830 |
if ($ENV{'EPM_FLAGS'}) { $extraflags = $ENV{'EPM_FLAGS'}; } |
| 831 |
|
| 832 |
$extraflags .= ' -g' unless $installer::globals::strip; |
| 833 |
|
| 834 |
my $verboseflag = "-v"; |
| 835 |
if ( ! $installer::globals::quiet ) { $verboseflag = "-v2"; }; |
| 836 |
|
| 837 |
my $systemcall = $fakerootstring . $epmname . " -f " . $packageformat . " " . $extraflags . " " . $localpackagename . " " . $epmlistfilename . $outdirstring . " " . $verboseflag . " " . " 2\>\&1 |"; |
| 838 |
|
| 839 |
installer::logger::print_message( "... $systemcall ...\n" ); |
| 840 |
|
| 841 |
my $maxepmcalls = 3; |
| 842 |
|
| 843 |
for ( my $i = 1; $i <= $maxepmcalls; $i++ ) |
| 844 |
{ |
| 845 |
my @epmoutput = (); |
| 846 |
|
| 847 |
open (EPM, "$systemcall"); |
| 848 |
while (<EPM>) {push(@epmoutput, $_); } |
| 849 |
close (EPM); |
| 850 |
|
| 851 |
my $returnvalue = $?; # $? contains the return value of the systemcall |
| 852 |
|
| 853 |
my $infoline = "Systemcall (Try $i): $systemcall\n"; |
| 854 |
push( @installer::globals::logfileinfo, $infoline); |
| 855 |
|
| 856 |
for ( my $j = 0; $j <= $#epmoutput; $j++ ) |
| 857 |
{ |
| 858 |
if ( $i < $maxepmcalls ) { $epmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; } |
| 859 |
push( @installer::globals::logfileinfo, "$epmoutput[$j]"); |
| 860 |
} |
| 861 |
|
| 862 |
if ($returnvalue) |
| 863 |
{ |
| 864 |
$infoline = "Try $i : Could not execute \"$systemcall\"!\n"; |
| 865 |
push( @installer::globals::logfileinfo, $infoline); |
| 866 |
if ( $i == $maxepmcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "call_epm"); } |
| 867 |
} |
| 868 |
else |
| 869 |
{ |
| 870 |
installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" ); |
| 871 |
$infoline = "Success: Executed \"$systemcall\" successfully!\n"; |
| 872 |
push( @installer::globals::logfileinfo, $infoline); |
| 873 |
last; |
| 874 |
} |
| 875 |
} |
| 876 |
} |
| 877 |
|
| 878 |
##################################################################### |
| 879 |
# Adding the new line for relocatables into pkginfo file (Solaris) |
| 880 |
# or spec file (Linux) created by epm |
| 881 |
##################################################################### |
| 882 |
|
| 883 |
sub add_one_line_into_file |
| 884 |
{ |
| 885 |
my ($file, $insertline, $filename) = @_; |
| 886 |
|
| 887 |
if ( $installer::globals::issolarispkgbuild ) |
| 888 |
{ |
| 889 |
push(@{$file}, $insertline); # simply adding at the end of pkginfo file |
| 890 |
} |
| 891 |
|
| 892 |
if ( $installer::globals::isrpmbuild ) |
| 893 |
{ |
| 894 |
# Adding behind the line beginning with: Group: |
| 895 |
|
| 896 |
my $inserted_line = 0; |
| 897 |
|
| 898 |
for ( my $i = 0; $i <= $#{$file}; $i++ ) |
| 899 |
{ |
| 900 |
if ( ${$file}[$i] =~ /^\s*Group\:\s*/ ) |
| 901 |
{ |
| 902 |
splice(@{$file},$i+1,0,$insertline); |
| 903 |
$inserted_line = 1; |
| 904 |
last; |
| 905 |
} |
| 906 |
} |
| 907 |
|
| 908 |
if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "add_one_line_into_file"); } |
| 909 |
} |
| 910 |
|
| 911 |
$insertline =~ s/\s*$//; # removing line end for correct logging |
| 912 |
my $infoline = "Success: Added line $insertline into file $filename!\n"; |
| 913 |
push( @installer::globals::logfileinfo, $infoline); |
| 914 |
} |
| 915 |
|
| 916 |
##################################################################### |
| 917 |
# Setting the revision VERSION=1.9,REV=66 . |
| 918 |
# Also adding the new line: "AutoReqProv: no" |
| 919 |
##################################################################### |
| 920 |
|
| 921 |
sub set_revision_in_pkginfo |
| 922 |
{ |
| 923 |
my ($file, $filename, $variables, $packagename) = @_; |
| 924 |
|
| 925 |
my $revisionstring = "\,REV\=" . $installer::globals::packagerevision; |
| 926 |
|
| 927 |
# Adding also a time string to the revision. Syntax: VERSION=8.0.0,REV=66.2005.01.24 |
| 928 |
|
| 929 |
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); |
| 930 |
|
| 931 |
$mday = $mday; |
| 932 |
$mon = $mon + 1; |
| 933 |
$year = $year + 1900; |
| 934 |
|
| 935 |
if ( $mday < 10 ) { $mday = "0" . $mday; } |
| 936 |
if ( $mon < 10 ) { $mon = "0" . $mon; } |
| 937 |
my $datestring = $year . "." . $mon . "." . $mday; |
| 938 |
$revisionstring = $revisionstring . "." . $datestring; |
| 939 |
|
| 940 |
for ( my $i = 0; $i <= $#{$file}; $i++ ) |
| 941 |
{ |
| 942 |
if ( ${$file}[$i] =~ /^\s*(VERSION\=.*?)\s*$/ ) |
| 943 |
{ |
| 944 |
my $oldstring = $1; |
| 945 |
my $newstring = $oldstring . $revisionstring; # also adding the date string |
| 946 |
${$file}[$i] =~ s/$oldstring/$newstring/; |
| 947 |
my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n"; |
| 948 |
push( @installer::globals::logfileinfo, $infoline); |
| 949 |
last; |
| 950 |
} |
| 951 |
} |
| 952 |
|
| 953 |
# For Update and Patch reasons, this string can also be kept constant |
| 954 |
|
| 955 |
my $pkgversion = "SOLSPARCPKGVERSION"; |
| 956 |
if ( $installer::globals::issolarisx86build ) { $pkgversion = "SOLIAPKGVERSION"; } |
| 957 |
|
| 958 |
if (( $variables->{$pkgversion} ) && ( $variables->{$pkgversion} ne "" )) |
| 959 |
{ |
| 960 |
if ( $variables->{$pkgversion} ne "FINALVERSION" ) |
| 961 |
{ |
| 962 |
# In OOo 3.x timeframe, this string is no longer unique for all packages, because of the three layer. |
| 963 |
# 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 |
| 964 |
# and therefore be set as $pkgversion. |
| 965 |
# The first part "3.0.0" has to be derived from the |
| 966 |
|
| 967 |
my $version = $installer::globals::packageversion; |
| 968 |
if ( $version =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ ) |
| 969 |
{ |
| 970 |
my $major = $1; |
| 971 |
my $minor = $2; |
| 972 |
my $micro = $3; |
| 973 |
|
| 974 |
my $finalmajor = $major; |
| 975 |
my $finalminor = $minor; |
| 976 |
my $finalmicro = 0; |
| 977 |
|
| 978 |
$version = "$finalmajor.$finalminor.$finalmicro"; |
| 979 |
} |
| 980 |
|
| 981 |
my $datestring = $variables->{$pkgversion}; |
| 982 |
|
| 983 |
# Allowing some packages to have another date of creation. |
| 984 |
# They can be defined in product definition using a key like "SOLSPARCPKGVERSION_$packagename" |
| 985 |
|
| 986 |
my $additionalkey = $pkgversion . "_" . $packagename; |
| 987 |
if (( $variables->{$additionalkey} ) && ( $variables->{$additionalkey} ne "" )) { $datestring = $variables->{$additionalkey}; } |
| 988 |
|
| 989 |
my $versionstring = "$version,$datestring"; |
| 990 |
|
| 991 |
for ( my $i = 0; $i <= $#{$file}; $i++ ) |
| 992 |
{ |
| 993 |
if ( ${$file}[$i] =~ /^\s*(VERSION\=).*?\s*$/ ) |
| 994 |
{ |
| 995 |
my $start = $1; |
| 996 |
my $newstring = $start . $versionstring . "\n"; # setting the complete new string |
| 997 |
my $oldstring = ${$file}[$i]; |
| 998 |
${$file}[$i] = $newstring; |
| 999 |
$oldstring =~ s/\s*$//; |
| 1000 |
$newstring =~ s/\s*$//; |
| 1001 |
my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n"; |
| 1002 |
push( @installer::globals::logfileinfo, $infoline); |
| 1003 |
last; |
| 1004 |
} |
| 1005 |
} |
| 1006 |
} |
| 1007 |
} |
| 1008 |
} |
| 1009 |
|
| 1010 |
######################################################## |
| 1011 |
# Setting MAXINST=1000 into the pkginfo file. |
| 1012 |
######################################################## |
| 1013 |
|
| 1014 |
sub set_maxinst_in_pkginfo |
| 1015 |
{ |
| 1016 |
my ($changefile, $filename) = @_; |
| 1017 |
|
| 1018 |
my $newline = "MAXINST\=1000\n"; |
| 1019 |
|
| 1020 |
add_one_line_into_file($changefile, $newline, $filename); |
| 1021 |
} |
| 1022 |
|
| 1023 |
############################################################# |
| 1024 |
# Setting several Solaris variables into the pkginfo file. |
| 1025 |
############################################################# |
| 1026 |
|
| 1027 |
sub set_solaris_parameter_in_pkginfo |
| 1028 |
{ |
| 1029 |
my ($changefile, $filename, $allvariables) = @_; |
| 1030 |
|
| 1031 |
my $newline = ""; |
| 1032 |
|
| 1033 |
# SUNW_PRODNAME |
| 1034 |
# SUNW_PRODVERS |
| 1035 |
# SUNW_PKGVERS |
| 1036 |
# Not: SUNW_PKGTYPE |
| 1037 |
# HOTLINE |
| 1038 |
# EMAIL |
| 1039 |
|
| 1040 |
my $productname = $allvariables->{'PRODUCTNAME'}; |
| 1041 |
$newline = "SUNW_PRODNAME=$productname\n"; |
| 1042 |
add_one_line_into_file($changefile, $newline, $filename); |
| 1043 |
|
| 1044 |
my $productversion = ""; |
| 1045 |
if ( $allvariables->{'PRODUCTVERSION'} ) |
| 1046 |
{ |
| 1047 |
$productversion = $allvariables->{'PRODUCTVERSION'}; |
| 1048 |
if ( $allvariables->{'PRODUCTEXTENSION'} ) { $productversion = $productversion . "/" . $allvariables->{'PRODUCTEXTENSION'}; } |
| 1049 |
} |
| 1050 |
$newline = "SUNW_PRODVERS=$productversion\n"; |
| 1051 |
add_one_line_into_file($changefile, $newline, $filename); |
| 1052 |
|
| 1053 |
$newline = "SUNW_PKGVERS=1\.0\n"; |
| 1054 |
add_one_line_into_file($changefile, $newline, $filename); |
| 1055 |
|
| 1056 |
if ( $allvariables->{'SUNW_PKGTYPE'} ) |
| 1057 |
{ |
| 1058 |
$newline = "SUNW_PKGTYPE=$allvariables->{'SUNW_PKGTYPE'}\n"; |
| 1059 |
add_one_line_into_file($changefile, $newline, $filename); |
| 1060 |
} |
| 1061 |
else |
| 1062 |
{ |
| 1063 |
$newline = "SUNW_PKGTYPE=\n"; |
| 1064 |
add_one_line_into_file($changefile, $newline, $filename); |
| 1065 |
} |
| 1066 |
|
| 1067 |
$newline = "HOTLINE=Please contact your local service provider\n"; |
| 1068 |
add_one_line_into_file($changefile, $newline, $filename); |
| 1069 |
|
| 1070 |
$newline = "EMAIL=\n"; |
| 1071 |
add_one_line_into_file($changefile, $newline, $filename); |
| 1072 |
|
| 1073 |
} |
| 1074 |
|
| 1075 |
##################################################################### |
| 1076 |
# epm uses as architecture for Solaris x86 "i86pc". This has to be |
| 1077 |
# changed to "i386". |
| 1078 |
##################################################################### |
| 1079 |
|
| 1080 |
sub fix_architecture_setting |
| 1081 |
{ |
| 1082 |
my ($changefile) = @_; |
| 1083 |
|
| 1084 |
for ( my $i = 0; $i <= $#{$changefile}; $i++ ) |
| 1085 |
{ |
| 1086 |
if ( ${$changefile}[$i] =~ /^\s*ARCH=i86pc\s*$/ ) |
| 1087 |
{ |
| 1088 |
${$changefile}[$i] =~ s/i86pc/i386/; |
| 1089 |
last; |
| 1090 |
} |
| 1091 |
|
| 1092 |
} |
| 1093 |
} |
| 1094 |
|
| 1095 |
##################################################################### |
| 1096 |
# Adding a new line for topdir into specfile, removing old |
| 1097 |
# topdir if set. |
| 1098 |
##################################################################### |
| 1099 |
|
| 1100 |
sub set_topdir_in_specfile |
| 1101 |
{ |
| 1102 |
my ($changefile, $filename, $newepmdir) = @_; |
| 1103 |
|
| 1104 |
$newepmdir = Cwd::cwd() . $installer::globals::separator . $newepmdir; # only absolute path allowed |
| 1105 |
|
| 1106 |
# removing "%define _topdir", if existing |
| 1107 |
|
| 1108 |
for ( my $i = 0; $i <= $#{$changefile}; $i++ ) |
| 1109 |
{ |
| 1110 |
if ( ${$changefile}[$i] =~ /^\s*\%define _topdir\s+/ ) |
| 1111 |
{ |
| 1112 |
my $removeline = ${$changefile}[$i]; |
| 1113 |
$removeline =~ s/\s*$//; |
| 1114 |
splice(@{$changefile},$i,1); |
| 1115 |
my $infoline = "Info: Removed line \"$removeline\" from file $filename!\n"; |
| 1116 |
push( @installer::globals::logfileinfo, $infoline); |
| 1117 |
last; |
| 1118 |
} |
| 1119 |
} |
| 1120 |
|
| 1121 |
# Adding "topdir" behind the line beginning with: Group: |
| 1122 |
|
| 1123 |
my $inserted_line = 0; |
| 1124 |
|
| 1125 |
my $topdirline = "\%define _topdir $newepmdir\n"; |
| 1126 |
|
| 1127 |
for ( my $i = 0; $i <= $#{$changefile}; $i++ ) |
| 1128 |
{ |
| 1129 |
if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ ) |
| 1130 |
{ |
| 1131 |
splice(@{$changefile},$i+1,0,$topdirline); |
| 1132 |
$inserted_line = 1; |
| 1133 |
$topdirline =~ s/\s*$//; |
| 1134 |
my $infoline = "Success: Added line $topdirline into file $filename!\n"; |
| 1135 |
push( @installer::globals::logfileinfo, $infoline); |
| 1136 |
} |
| 1137 |
} |
| 1138 |
|
| 1139 |
if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "set_topdir_in_specfile"); } |
| 1140 |
|
| 1141 |
} |
| 1142 |
|
| 1143 |
##################################################################### |
| 1144 |
# Setting the packager in the spec file |
| 1145 |
# Syntax: Packager: abc@def |
| 1146 |
##################################################################### |
| 1147 |
|
| 1148 |
sub set_packager_in_specfile |
| 1149 |
{ |
| 1150 |
my ($changefile) = @_; |
| 1151 |
|
| 1152 |
my $packager = $installer::globals::longmanufacturer; |
| 1153 |
|
| 1154 |
for ( my $i = 0; $i <= $#{$changefile}; $i++ ) |
| 1155 |
{ |
| 1156 |
if ( ${$changefile}[$i] =~ /^\s*Packager\s*:\s*(.+?)\s*$/ ) |
| 1157 |
{ |
| 1158 |
my $oldstring = $1; |
| 1159 |
${$changefile}[$i] =~ s/\Q$oldstring\E/$packager/; |
| 1160 |
my $infoline = "Info: Changed Packager in spec file from $oldstring to $packager!\n"; |
| 1161 |
push( @installer::globals::logfileinfo, $infoline); |
| 1162 |
last; |
| 1163 |
} |
| 1164 |
} |
| 1165 |
} |
| 1166 |
|
| 1167 |
##################################################################### |
| 1168 |
# Setting the requirements in the spec file (i81494) |
| 1169 |
# Syntax: PreReq: "requirements" (only for shared extensions) |
| 1170 |
##################################################################### |
| 1171 |
|
| 1172 |
sub set_prereq_in_specfile |
| 1173 |
{ |
| 1174 |
my ($changefile) = @_; |
| 1175 |
|
| 1176 |
my $prereq = "PreReq:"; |
| 1177 |
|
| 1178 |
for ( my $i = 0; $i <= $#{$changefile}; $i++ ) |
| 1179 |
{ |
| 1180 |
if ( ${$changefile}[$i] =~ /^\s*Requires:\s*(.+?)\s*$/ ) |
| 1181 |
{ |
| 1182 |
my $oldstring = ${$changefile}[$i]; |
| 1183 |
${$changefile}[$i] =~ s/Requires:/$prereq/; |
| 1184 |
my $infoline = "Info: Changed requirements in spec file from $oldstring to ${$changefile}[$i]!\n"; |
| 1185 |
push( @installer::globals::logfileinfo, $infoline); |
| 1186 |
} |
| 1187 |
} |
| 1188 |
} |
| 1189 |
|
| 1190 |
##################################################################### |
| 1191 |
# Setting the Auto[Req]Prov line and __find_requires |
| 1192 |
##################################################################### |
| 1193 |
|
| 1194 |
sub set_autoprovreq_in_specfile |
| 1195 |
{ |
| 1196 |
my ($changefile, $findrequires, $bindir) = @_; |
| 1197 |
|
| 1198 |
my $autoreqprovline = "AutoReqProv\: no\n"; |
| 1199 |
|
| 1200 |
if ( $findrequires ) |
| 1201 |
{ |
| 1202 |
# don't let rpm invoke it, we never want to use AutoReq because |
| 1203 |
# rpm will generate Requires: config(packagename) |
| 1204 |
open (FINDREQUIRES, "echo | $bindir/$findrequires |"); |
| 1205 |
while (<FINDREQUIRES>) { $autoreqprovline .= "Requires: $_\n"; } |
| 1206 |
close (FINDREQUIRES); |
| 1207 |
} |
| 1208 |
|
| 1209 |
$autoreqprovline .= "%define _binary_filedigest_algorithm 1\n%define _binary_payload w1T.xzdio\n"; |
| 1210 |
|
| 1211 |
for ( my $i = 0; $i <= $#{$changefile}; $i++ ) |
| 1212 |
{ |
| 1213 |
# Adding "autoreqprov" behind the line beginning with: Group: |
| 1214 |
if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ ) |
| 1215 |
{ |
| 1216 |
splice(@{$changefile},$i+1,0,$autoreqprovline); |
| 1217 |
$autoreqprovline =~ s/\s*$//; |
| 1218 |
my $infoline = "Success: Added line $autoreqprovline into spec file!\n"; |
| 1219 |
push( @installer::globals::logfileinfo, $infoline); |
| 1220 |
|
| 1221 |
last; |
| 1222 |
} |
| 1223 |
} |
| 1224 |
} |
| 1225 |
|
| 1226 |
##################################################################### |
| 1227 |
# Replacing Copyright with License in the spec file |
| 1228 |
# Syntax: License: LGPLv3 (or MPLv2 on ALv2, older usages were LGPL, SISSL) |
| 1229 |
##################################################################### |
| 1230 |
|
| 1231 |
sub set_license_in_specfile |
| 1232 |
{ |
| 1233 |
my ($changefile, $variableshashref) = @_; |
| 1234 |
|
| 1235 |
my $license = $variableshashref->{'LICENSENAME'}; |
| 1236 |
|
| 1237 |
for ( my $i = 0; $i <= $#{$changefile}; $i++ ) |
| 1238 |
{ |
| 1239 |
if ( ${$changefile}[$i] =~ /^\s*Copyright\s*:\s*(.+?)\s*$/ ) |
| 1240 |
{ |
| 1241 |
${$changefile}[$i] = "License: $license\n"; |
| 1242 |
my $infoline = "Info: Replaced Copyright with License: $license !\n"; |
| 1243 |
push( @installer::globals::logfileinfo, $infoline); |
| 1244 |
last; |
| 1245 |
} |
| 1246 |
} |
| 1247 |
} |
| 1248 |
|
| 1249 |
######################################################### |
| 1250 |
# Building relocatable Solaris packages means: |
| 1251 |
# 1. Add "BASEDIR=/opt" into pkginfo |
| 1252 |
# 2. Remove "/opt/" from all objects in prototype file |
| 1253 |
# For step2 this function exists |
| 1254 |
# Sample: d none /opt/openofficeorg20/help 0755 root other |
| 1255 |
# -> d none openofficeorg20/help 0755 root other |
| 1256 |
######################################################### |
| 1257 |
|
| 1258 |
sub make_prototypefile_relocatable |
| 1259 |
{ |
| 1260 |
my ($prototypefile, $relocatablepath) = @_; |
| 1261 |
|
| 1262 |
for ( my $i = 0; $i <= $#{$prototypefile}; $i++ ) |
| 1263 |
{ |
| 1264 |
if ( ${$prototypefile}[$i] =~ /^\s*\w\s+\w+\s+\/\w+/ ) # this is an object line |
| 1265 |
{ |
| 1266 |
${$prototypefile}[$i] =~ s/$relocatablepath//; # Important: $relocatablepath has a "/" at the end. Example "/opt/" |
| 1267 |
} |
| 1268 |
} |
| 1269 |
|
| 1270 |
# If the $relocatablepath is "/opt/openoffice20/" the line "d none /opt/openoffice20" was not changed. |
| 1271 |
# This line has to be removed now |
| 1272 |
|
| 1273 |
if ( $relocatablepath ne "/" ) { $relocatablepath =~ s/\/\s*$//; } # removing the ending slash |
| 1274 |
|
| 1275 |
for ( my $i = 0; $i <= $#{$prototypefile}; $i++ ) |
| 1276 |
{ |
| 1277 |
if ( ${$prototypefile}[$i] =~ /^\s*d\s+\w+\s+\Q$relocatablepath\E/ ) |
| 1278 |
{ |
| 1279 |
my $line = ${$prototypefile}[$i]; |
| 1280 |
splice(@{$prototypefile},$i,1); # removing the line |
| 1281 |
$line =~ s/\s*$//; |
| 1282 |
my $infoline = "Info: Removed line \"$line\" from prototype file!\n"; |
| 1283 |
push( @installer::globals::logfileinfo, $infoline); |
| 1284 |
last; |
| 1285 |
} |
| 1286 |
} |
| 1287 |
|
| 1288 |
# Making "\$" to "$" in prototype file. "\$" was created by epm. |
| 1289 |
|
| 1290 |
for ( my $i = 0; $i <= $#{$prototypefile}; $i++ ) |
| 1291 |
{ |
| 1292 |
if ( ${$prototypefile}[$i] =~ /\\\$/ ) |
| 1293 |
{ |
| 1294 |
${$prototypefile}[$i] =~ s/\\\$/\$/g; |
| 1295 |
my $infoline2 = "Info: Changed line in prototype file: ${$prototypefile}[$i] !\n"; |
| 1296 |
push( @installer::globals::logfileinfo, $infoline2); |
| 1297 |
} |
| 1298 |
} |
| 1299 |
} |
| 1300 |
|
| 1301 |
######################################################################### |
| 1302 |
# Replacing the variables in the shell scripts or in the epm list file |
| 1303 |
# Linux: spec file |
| 1304 |
# Solaris: preinstall, postinstall, preremove, postremove |
| 1305 |
# If epm is used in the original version (not relocatable) |
| 1306 |
# the variables have to be exchanged in the list file, |
| 1307 |
# created for epm. |
| 1308 |
######################################################################### |
| 1309 |
|
| 1310 |
sub replace_variables_in_shellscripts |
| 1311 |
{ |
| 1312 |
my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_; |
| 1313 |
|
| 1314 |
my $debug = 0; |
| 1315 |
if ( $oldstring eq "PRODUCTDIRECTORYNAME" ) { $debug = 1; } |
| 1316 |
|
| 1317 |
for ( my $i = 0; $i <= $#{$scriptfile}; $i++ ) |
| 1318 |
{ |
| 1319 |
if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ ) |
| 1320 |
{ |
| 1321 |
my $oldline = ${$scriptfile}[$i]; |
| 1322 |
${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g; |
| 1323 |
${$scriptfile}[$i] =~ s/\/\//\//g; # replacing "//" by "/" , if path $newstring is empty! |
| 1324 |
my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n"; |
| 1325 |
push(@installer::globals::logfileinfo, $infoline); |
| 1326 |
if ( $debug ) |
| 1327 |
{ |
| 1328 |
$infoline = "Old Line: $oldline"; |
| 1329 |
push(@installer::globals::logfileinfo, $infoline); |
| 1330 |
$infoline = "New Line: ${$scriptfile}[$i]"; |
| 1331 |
push(@installer::globals::logfileinfo, $infoline); |
| 1332 |
} |
| 1333 |
} |
| 1334 |
} |
| 1335 |
} |
| 1336 |
|
| 1337 |
############################################################ |
| 1338 |
# Determining the directory created by epm, in which the |
| 1339 |
# RPMS or Solaris packages are created. |
| 1340 |
############################################################ |
| 1341 |
|
| 1342 |
sub determine_installdir_ooo |
| 1343 |
{ |
| 1344 |
# A simple "ls" command returns the directory name |
| 1345 |
|
| 1346 |
my $dirname = ""; |
| 1347 |
|
| 1348 |
my $systemcall = "ls |"; |
| 1349 |
open (LS, "$systemcall"); |
| 1350 |
$dirname = <LS>; |
| 1351 |
close (LS); |
| 1352 |
|
| 1353 |
$dirname =~ s/\s*$//; |
| 1354 |
|
| 1355 |
my $infoline = "Info: Directory created by epm: $dirname\n"; |
| 1356 |
push(@installer::globals::logfileinfo, $infoline); |
| 1357 |
|
| 1358 |
return $dirname; |
| 1359 |
} |
| 1360 |
|
| 1361 |
############################################################ |
| 1362 |
# Setting the tab content into the file container |
| 1363 |
############################################################ |
| 1364 |
|
| 1365 |
sub set_tab_into_datafile |
| 1366 |
{ |
| 1367 |
my ($changefile, $filesref) = @_; |
| 1368 |
|
| 1369 |
my @newclasses = (); |
| 1370 |
my $newclassesstring = ""; |
| 1371 |
|
| 1372 |
if ( $installer::globals::issolarispkgbuild ) |
| 1373 |
{ |
| 1374 |
for ( my $i = 0; $i <= $#{$filesref}; $i++ ) |
| 1375 |
{ |
| 1376 |
my $onefile = ${$filesref}[$i]; |
| 1377 |
|
| 1378 |
if ( $onefile->{'SolarisClass'} ) |
| 1379 |
{ |
| 1380 |
my $sourcepath = $onefile->{'sourcepath'}; |
| 1381 |
|
| 1382 |
for ( my $j = 0; $j <= $#{$changefile}; $j++ ) |
| 1383 |
{ |
| 1384 |
if (( ${$changefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$changefile}[$j] =~ /\=\Q$sourcepath\E\s+/ )) |
| 1385 |
{ |
| 1386 |
my $oldline = ${$changefile}[$j]; |
| 1387 |
${$changefile}[$j] =~ s/f\s+none/e $onefile->{'SolarisClass'}/; |
| 1388 |
my $newline = ${$changefile}[$j]; |
| 1389 |
$oldline =~ s/\s*$//; |
| 1390 |
$newline =~ s/\s*$//; |
| 1391 |
|
| 1392 |
my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n"; |
| 1393 |
push(@installer::globals::logfileinfo, $infoline); |
| 1394 |
|
| 1395 |
# collecting all new classes |
| 1396 |
if (! grep {$_ eq $onefile->{'SolarisClass'}} @newclasses) |
| 1397 |
{ |
| 1398 |
push(@newclasses, $onefile->{'SolarisClass'}); |
| 1399 |
} |
| 1400 |
|
| 1401 |
last; |
| 1402 |
} |
| 1403 |
} |
| 1404 |
} |
| 1405 |
} |
| 1406 |
|
| 1407 |
$newclassesstring = installer::converter::convert_array_to_space_separated_string(\@newclasses); |
| 1408 |
} |
| 1409 |
|
| 1410 |
if ( $installer::globals::isrpmbuild ) |
| 1411 |
{ |
| 1412 |
for ( my $i = 0; $i <= $#{$filesref}; $i++ ) |
| 1413 |
{ |
| 1414 |
my $onefile = ${$filesref}[$i]; |
| 1415 |
|
| 1416 |
if ( $onefile->{'SpecFileContent'} ) |
| 1417 |
{ |
| 1418 |
my $destination = $onefile->{'destination'}; |
| 1419 |
|
| 1420 |
for ( my $j = 0; $j <= $#{$changefile}; $j++ ) |
| 1421 |
{ |
| 1422 |
if ( ${$changefile}[$j] =~ /^\s*(\%attr\(.*\))\s+(\".*?\Q$destination\E\"\s*)$/ ) |
| 1423 |
{ |
| 1424 |
my $begin = $1; |
| 1425 |
my $end = $2; |
| 1426 |
|
| 1427 |
my $oldline = ${$changefile}[$j]; |
| 1428 |
${$changefile}[$j] = $begin . " " . $onefile->{'SpecFileContent'} . " " . $end; |
| 1429 |
my $newline = ${$changefile}[$j]; |
| 1430 |
|
| 1431 |
$oldline =~ s/\s*$//; |
| 1432 |
$newline =~ s/\s*$//; |
| 1433 |
|
| 1434 |
my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n"; |
| 1435 |
push(@installer::globals::logfileinfo, $infoline); |
| 1436 |
|
| 1437 |
last; |
| 1438 |
} |
| 1439 |
} |
| 1440 |
} |
| 1441 |
} |
| 1442 |
} |
| 1443 |
|
| 1444 |
return $newclassesstring; |
| 1445 |
} |
| 1446 |
|
| 1447 |
############################################################ |
| 1448 |
# Including additional classes into the pkginfo file |
| 1449 |
############################################################ |
| 1450 |
|
| 1451 |
sub include_classes_into_pkginfo |
| 1452 |
{ |
| 1453 |
my ($changefile, $classesstring) = @_; |
| 1454 |
|
| 1455 |
for ( my $i = 0; $i <= $#{$changefile}; $i++ ) |
| 1456 |
{ |
| 1457 |
if ( ${$changefile}[$i] =~ /^\s*CLASSES\=none/ ) |
| 1458 |
{ |
| 1459 |
${$changefile}[$i] =~ s/\s*$//; |
| 1460 |
my $oldline = ${$changefile}[$i]; |
| 1461 |
${$changefile}[$i] = ${$changefile}[$i] . " " . $classesstring . "\n"; |
| 1462 |
my $newline = ${$changefile}[$i]; |
| 1463 |
$newline =~ s/\s*$//; |
| 1464 |
|
| 1465 |
my $infoline = "pkginfo file: Changing content from \"$oldline\" to \"$newline\" .\n"; |
| 1466 |
push(@installer::globals::logfileinfo, $infoline); |
| 1467 |
} |
| 1468 |
} |
| 1469 |
} |
| 1470 |
|
| 1471 |
########################################################################################## |
| 1472 |
# Checking, if an extension is included into the package (Linux). |
| 1473 |
# All extension files have to be installed into directory |
| 1474 |
# share/extension/install |
| 1475 |
# %attr(0444,root,root) "/opt/staroffice8/share/extension/install/SunSearchToolbar.oxt" |
| 1476 |
########################################################################################## |
| 1477 |
|
| 1478 |
sub is_extension_package |
| 1479 |
{ |
| 1480 |
my ($specfile) = @_; |
| 1481 |
|
| 1482 |
my $is_extension_package = 0; |
| 1483 |
|
| 1484 |
for ( my $i = 0; $i <= $#{$specfile}; $i++ ) |
| 1485 |
{ |
| 1486 |
my $line = ${$specfile}[$i]; |
| 1487 |
if ( $line =~ /share\/extension\/install\/.*?\.oxt\"\s*$/ ) |
| 1488 |
{ |
| 1489 |
$is_extension_package = 1; |
| 1490 |
last; |
| 1491 |
} |
| 1492 |
} |
| 1493 |
|
| 1494 |
return $is_extension_package; |
| 1495 |
} |
| 1496 |
|
| 1497 |
###################################################################### |
| 1498 |
# Checking, if an extension is included into the package (Solaris). |
| 1499 |
# All extension files have to be installed into directory |
| 1500 |
# share/extension/install |
| 1501 |
###################################################################### |
| 1502 |
|
| 1503 |
sub contains_extension_dir |
| 1504 |
{ |
| 1505 |
my ($prototypefile) = @_; |
| 1506 |
|
| 1507 |
my $contains_extension_dir = 0; |
| 1508 |
|
| 1509 |
# d none opt/libreoffice/share/extensions/ |
| 1510 |
|
| 1511 |
for ( my $i = 0; $i <= $#{$prototypefile}; $i++ ) |
| 1512 |
{ |
| 1513 |
my $line = ${$prototypefile}[$i]; |
| 1514 |
if ( $line =~ /^\s*d\s+none\s.*\/share\/extensions\// ) |
| 1515 |
{ |
| 1516 |
$contains_extension_dir = 1; |
| 1517 |
last; |
| 1518 |
} |
| 1519 |
} |
| 1520 |
|
| 1521 |
return $contains_extension_dir; |
| 1522 |
} |
| 1523 |
|
| 1524 |
############################################################ |
| 1525 |
# Setting the correct Solaris locales |
| 1526 |
############################################################ |
| 1527 |
|
| 1528 |
sub get_solaris_language_for_langpack |
| 1529 |
{ |
| 1530 |
my ( $onelanguage ) = @_; |
| 1531 |
|
| 1532 |
my $sollanguage = $onelanguage; |
| 1533 |
$sollanguage =~ s/\-/\_/; |
| 1534 |
|
| 1535 |
if ( $sollanguage eq "de" ) { $sollanguage = "de"; } |
| 1536 |
elsif ( $sollanguage eq "en_US" ) { $sollanguage = "en_AU,en_CA,en_GB,en_IE,en_MT,en_NZ,en_US,en_US.UTF-8"; } |
| 1537 |
elsif ( $sollanguage eq "es" ) { $sollanguage = "es"; } |
| 1538 |
elsif ( $sollanguage eq "fr" ) { $sollanguage = "fr"; } |
| 1539 |
elsif ( $sollanguage eq "hu" ) { $sollanguage = "hu_HU"; } |
| 1540 |
elsif ( $sollanguage eq "it" ) { $sollanguage = "it"; } |
| 1541 |
elsif ( $sollanguage eq "nl" ) { $sollanguage = "nl_BE,nl_NL"; } |
| 1542 |
elsif ( $sollanguage eq "pl" ) { $sollanguage = "pl_PL"; } |
| 1543 |
elsif ( $sollanguage eq "sv" ) { $sollanguage = "sv"; } |
| 1544 |
elsif ( $sollanguage eq "pt" ) { $sollanguage = "pt_PT"; } |
| 1545 |
elsif ( $sollanguage eq "pt_BR" ) { $sollanguage = "pt_BR"; } |
| 1546 |
elsif ( $sollanguage eq "ru" ) { $sollanguage = "ru_RU"; } |
| 1547 |
elsif ( $sollanguage eq "ja" ) { $sollanguage = "ja,ja_JP,ja_JP.PCK,ja_JP.UTF-8"; } |
| 1548 |
elsif ( $sollanguage eq "ko" ) { $sollanguage = "ko,ko.UTF-8"; } |
| 1549 |
elsif ( $sollanguage eq "zh_CN" ) { $sollanguage = "zh,zh.GBK,zh_CN.GB18030,zh.UTF-8"; } |
| 1550 |
elsif ( $sollanguage eq "zh_TW" ) { $sollanguage = "zh_TW,zh_TW.BIG5,zh_TW.UTF-8,zh_HK.BIG5HK,zh_HK.UTF-8"; } |
| 1551 |
|
| 1552 |
return $sollanguage; |
| 1553 |
} |
| 1554 |
|
| 1555 |
############################################################ |
| 1556 |
# Adding language infos in pkginfo file |
| 1557 |
############################################################ |
| 1558 |
|
| 1559 |
sub include_languageinfos_into_pkginfo |
| 1560 |
{ |
| 1561 |
my ( $changefile, $filename, $languagestringref, $onepackage, $variableshashref ) = @_; |
| 1562 |
|
| 1563 |
# SUNWPKG_LIST=core01 |
| 1564 |
# SUNW_LOC=de |
| 1565 |
|
| 1566 |
my $locallang = $onepackage->{'language'}; |
| 1567 |
my $solarislanguage = get_solaris_language_for_langpack($locallang); |
| 1568 |
|
| 1569 |
my $newline = "SUNW_LOC=" . $solarislanguage . "\n"; |
| 1570 |
add_one_line_into_file($changefile, $newline, $filename); |
| 1571 |
|
| 1572 |
# SUNW_PKGLIST is required, if SUNW_LOC is defined. |
| 1573 |
if ( $onepackage->{'pkg_list_entry'} ) |
| 1574 |
{ |
| 1575 |
my $packagelistentry = $onepackage->{'pkg_list_entry'}; |
| 1576 |
installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1); |
| 1577 |
$newline = "SUNW_PKGLIST=" . $packagelistentry . "\n"; |
| 1578 |
add_one_line_into_file($changefile, $newline, $filename); |
| 1579 |
} |
| 1580 |
else |
| 1581 |
{ |
| 1582 |
# Using default package ooobasis30-core01. |
| 1583 |
my $packagelistentry = "%BASISPACKAGEPREFIX%WITHOUTDOTPRODUCTVERSION-core01"; |
| 1584 |
installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1); |
| 1585 |
$newline = "SUNW_PKGLIST=" . $packagelistentry . "\n"; |
| 1586 |
add_one_line_into_file($changefile, $newline, $filename); |
| 1587 |
} |
| 1588 |
} |
| 1589 |
|
| 1590 |
############################################################ |
| 1591 |
# Including package names into the depend files. |
| 1592 |
# The package names have to be included into |
| 1593 |
# packagelist. They are already saved in |
| 1594 |
# %installer::globals::dependfilenames. |
| 1595 |
############################################################ |
| 1596 |
|
| 1597 |
sub put_packagenames_into_dependfile |
| 1598 |
{ |
| 1599 |
my ( $file ) = @_; |
| 1600 |
|
| 1601 |
for ( my $i = 0; $i <= $#{$file}; $i++ ) |
| 1602 |
{ |
| 1603 |
my $line = ${$file}[$i]; |
| 1604 |
if ( $line =~ /^\s*\w\s+(.*?)\s*$/ ) |
| 1605 |
{ |
| 1606 |
my $abbreviation = $1; |
| 1607 |
|
| 1608 |
if ( $abbreviation =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package abbreviation \"$abbreviation\"!", "read_packagemap"); } |
| 1609 |
|
| 1610 |
if ( exists($installer::globals::dependfilenames{$abbreviation}) ) |
| 1611 |
{ |
| 1612 |
my $packagename = $installer::globals::dependfilenames{$abbreviation}; |
| 1613 |
if ( $packagename =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package name \"$packagename\"!", "read_packagemap"); } |
| 1614 |
|
| 1615 |
$line =~ s/\s*$//; |
| 1616 |
${$file}[$i] = $line . "\t" . $packagename . "\n"; |
| 1617 |
} |
| 1618 |
else |
| 1619 |
{ |
| 1620 |
installer::exiter::exit_program("ERROR: Missing packagename for Solaris package \"$abbreviation\"!", "put_packagenames_into_dependfile"); |
| 1621 |
} |
| 1622 |
} |
| 1623 |
} |
| 1624 |
} |
| 1625 |
|
| 1626 |
############################################################ |
| 1627 |
# Including the relocatable directory into |
| 1628 |
# spec file and pkginfo file |
| 1629 |
# Linux: set topdir in specfile |
| 1630 |
# Solaris: remove $relocatablepath (/opt/) |
| 1631 |
# for all objects in prototype file |
| 1632 |
# and changing "topdir" for Linux |
| 1633 |
############################################################ |
| 1634 |
|
| 1635 |
sub prepare_packages |
| 1636 |
{ |
| 1637 |
my ($loggingdir, $packagename, $staticpath, $relocatablepath, $onepackage, $variableshashref, $filesref, $languagestringref) = @_; |
| 1638 |
|
| 1639 |
my $filename = ""; |
| 1640 |
my $newline = ""; |
| 1641 |
my $newepmdir = $installer::globals::epmoutpath . $installer::globals::separator; |
| 1642 |
|
| 1643 |
my $localrelocatablepath = $relocatablepath; |
| 1644 |
if ( $localrelocatablepath ne "/" ) { $localrelocatablepath =~ s/\/\s*$//; } |
| 1645 |
|
| 1646 |
if ( $installer::globals::issolarispkgbuild ) |
| 1647 |
{ |
| 1648 |
$filename = $packagename . ".pkginfo"; |
| 1649 |
$newline = "BASEDIR\=" . $localrelocatablepath . "\n"; |
| 1650 |
} |
| 1651 |
|
| 1652 |
if ( $installer::globals::isrpmbuild ) |
| 1653 |
{ |
| 1654 |
$filename = $packagename . ".spec"; |
| 1655 |
$newline = "Prefix\:\ " . $localrelocatablepath . "\n"; |
| 1656 |
} |
| 1657 |
|
| 1658 |
my $completefilename = $newepmdir . $filename; |
| 1659 |
|
| 1660 |
if ( ! -f $completefilename) { installer::exiter::exit_program("ERROR: Did not find file: $completefilename", "prepare_packages"); } |
| 1661 |
my $changefile = installer::files::read_file($completefilename); |
| 1662 |
if ( $newline ne "" ) |
| 1663 |
{ |
| 1664 |
add_one_line_into_file($changefile, $newline, $filename); |
| 1665 |
installer::files::save_file($completefilename, $changefile); |
| 1666 |
} |
| 1667 |
|
| 1668 |
# adding new "topdir" and removing old "topdir" in specfile |
| 1669 |
|
| 1670 |
if ( $installer::globals::isrpmbuild ) |
| 1671 |
{ |
| 1672 |
set_topdir_in_specfile($changefile, $filename, $newepmdir); |
| 1673 |
set_autoprovreq_in_specfile($changefile, $onepackage->{'findrequires'}, "$installer::globals::workpath" . "/bin"); |
| 1674 |
set_packager_in_specfile($changefile); |
| 1675 |
if ( is_extension_package($changefile) ) { set_prereq_in_specfile($changefile); } |
| 1676 |
set_license_in_specfile($changefile, $variableshashref); |
| 1677 |
set_tab_into_datafile($changefile, $filesref); |
| 1678 |
installer::files::save_file($completefilename, $changefile); |
| 1679 |
} |
| 1680 |
|
| 1681 |
# removing the relocatable path in prototype file |
| 1682 |
|
| 1683 |
if ( $installer::globals::issolarispkgbuild ) |
| 1684 |
{ |
| 1685 |
set_revision_in_pkginfo($changefile, $filename, $variableshashref, $packagename); |
| 1686 |
set_maxinst_in_pkginfo($changefile, $filename); |
| 1687 |
set_solaris_parameter_in_pkginfo($changefile, $filename, $variableshashref); |
| 1688 |
if ( $installer::globals::issolarisx86build ) { fix_architecture_setting($changefile); } |
| 1689 |
if (( $onepackage->{'language'} ) && ( $onepackage->{'language'} ne "" ) && ( $onepackage->{'language'} ne "en-US" )) { include_languageinfos_into_pkginfo($changefile, $filename, $languagestringref, $onepackage, $variableshashref); } |
| 1690 |
installer::files::save_file($completefilename, $changefile); |
| 1691 |
|
| 1692 |
my $prototypefilename = $packagename . ".prototype"; |
| 1693 |
$prototypefilename = $newepmdir . $prototypefilename; |
| 1694 |
if (! -f $prototypefilename) { installer::exiter::exit_program("ERROR: Did not find prototype file: $prototypefilename", "prepare_packages"); } |
| 1695 |
|
| 1696 |
my $prototypefile = installer::files::read_file($prototypefilename); |
| 1697 |
make_prototypefile_relocatable($prototypefile, $relocatablepath); |
| 1698 |
my $classesstring = set_tab_into_datafile($prototypefile, $filesref); |
| 1699 |
if ($classesstring) |
| 1700 |
{ |
| 1701 |
include_classes_into_pkginfo($changefile, $classesstring); |
| 1702 |
installer::files::save_file($completefilename, $changefile); |
| 1703 |
} |
| 1704 |
|
| 1705 |
installer::files::save_file($prototypefilename, $prototypefile); |
| 1706 |
|
| 1707 |
# Adding package names into depend files for Solaris (not supported by epm) |
| 1708 |
my $dependfilename = $packagename . ".depend"; |
| 1709 |
$dependfilename = $newepmdir . $dependfilename; |
| 1710 |
if ( -f $dependfilename) |
| 1711 |
{ |
| 1712 |
my $dependfile = installer::files::read_file($dependfilename); |
| 1713 |
put_packagenames_into_dependfile($dependfile); |
| 1714 |
installer::files::save_file($dependfilename, $dependfile); |
| 1715 |
} |
| 1716 |
} |
| 1717 |
|
| 1718 |
return $newepmdir; |
| 1719 |
} |
| 1720 |
|
| 1721 |
############################################################################### |
| 1722 |
# Replacement of PRODUCTINSTALLLOCATION and PRODUCTDIRECTORYNAME in the |
| 1723 |
# epm list file. |
| 1724 |
# The complete rootpath is stored in $installer::globals::rootpath |
| 1725 |
# or for each package in $onepackage->{'destpath'} |
| 1726 |
# The static rootpath is stored in $staticpath |
| 1727 |
# The relocatable path is stored in $relocatablepath |
| 1728 |
# PRODUCTINSTALLLOCATION is the relocatable part ("/opt") and |
| 1729 |
# PRODUCTDIRECTORYNAME the static path ("openofficeorg20"). |
| 1730 |
# In standard epm process: |
| 1731 |
# No usage of package specific variables like $BASEDIR, because |
| 1732 |
# 1. These variables would be replaced in epm process |
| 1733 |
# 2. epm version 3.7 does not support relocatable packages |
| 1734 |
############################################################################### |
| 1735 |
|
| 1736 |
sub resolve_path_in_epm_list_before_packaging |
| 1737 |
{ |
| 1738 |
my ($listfile, $listfilename, $variable, $path) = @_; |
| 1739 |
|
| 1740 |
installer::logger::include_header_into_logfile("Replacing variables in epm list file:"); |
| 1741 |
|
| 1742 |
$path =~ s/\/\s*$//; |
| 1743 |
replace_variables_in_shellscripts($listfile, $listfilename, $variable, $path); |
| 1744 |
|
| 1745 |
} |
| 1746 |
|
| 1747 |
################################################################# |
| 1748 |
# Determining the rpm version. Beginning with rpm version 4.0 |
| 1749 |
# the tool to create RPMs is "rpmbuild" and no longer "rpm" |
| 1750 |
################################################################# |
| 1751 |
|
| 1752 |
sub determine_rpm_version |
| 1753 |
{ |
| 1754 |
my $rpmversion = 0; |
| 1755 |
my $rpmout = ""; |
| 1756 |
my $systemcall = ""; |
| 1757 |
|
| 1758 |
# "rpm --version" has problems since LD_LIBRARY_PATH was removed. Therefore the content of $RPM has to be called. |
| 1759 |
# "rpm --version" and "rpmbuild --version" have the same output. Therefore $RPM can be used. Its value |
| 1760 |
# is saved in $installer::globals::rpm |
| 1761 |
|
| 1762 |
if ( $installer::globals::rpm ne "" ) |
| 1763 |
{ |
| 1764 |
$systemcall = "$installer::globals::rpm --version |"; |
| 1765 |
} |
| 1766 |
else |
| 1767 |
{ |
| 1768 |
$systemcall = "rpm --version |"; |
| 1769 |
} |
| 1770 |
|
| 1771 |
open (RPM, "$systemcall"); |
| 1772 |
$rpmout = <RPM>; |
| 1773 |
close (RPM); |
| 1774 |
|
| 1775 |
if ( $rpmout ne "" ) |
| 1776 |
{ |
| 1777 |
$rpmout =~ s/\s*$//g; |
| 1778 |
|
| 1779 |
my $infoline = "Systemcall: $systemcall\n"; |
| 1780 |
push( @installer::globals::logfileinfo, $infoline); |
| 1781 |
|
| 1782 |
if ( $rpmout eq "" ) { $infoline = "ERROR: Could not find file \"rpm\" !\n"; } |
| 1783 |
else { $infoline = "Success: rpm version: $rpmout\n"; } |
| 1784 |
|
| 1785 |
push( @installer::globals::logfileinfo, $infoline); |
| 1786 |
|
| 1787 |
if ( $rpmout =~ /(\d+)\.(\d+)\.(\d+)/ ) { $rpmversion = $1; } |
| 1788 |
elsif ( $rpmout =~ /(\d+)\.(\d+)/ ) { $rpmversion = $1; } |
| 1789 |
elsif ( $rpmout =~ /(\d+)/ ) { $rpmversion = $1; } |
| 1790 |
else { installer::exiter::exit_program("ERROR: Unknown format: $rpmout ! Expected: \"a.b.c\", or \"a.b\", or \"a\"", "determine_rpm_version"); } |
| 1791 |
} |
| 1792 |
|
| 1793 |
return $rpmversion; |
| 1794 |
} |
| 1795 |
|
| 1796 |
#################################################### |
| 1797 |
# Writing some info about rpm into the log file |
| 1798 |
#################################################### |
| 1799 |
|
| 1800 |
sub log_rpm_info |
| 1801 |
{ |
| 1802 |
my $systemcall = ""; |
| 1803 |
my $infoline = ""; |
| 1804 |
|
| 1805 |
$infoline = "\nLogging rpmrc content using --showrc\n\n"; |
| 1806 |
push( @installer::globals::logfileinfo, $infoline); |
| 1807 |
|
| 1808 |
if ( $installer::globals::rpm ne "" ) |
| 1809 |
{ |
| 1810 |
$systemcall = "$installer::globals::rpm --showrc |"; |
| 1811 |
} |
| 1812 |
else |
| 1813 |
{ |
| 1814 |
$systemcall = "rpm --showrc |"; |
| 1815 |
} |
| 1816 |
|
| 1817 |
my @fullrpmout = (); |
| 1818 |
|
| 1819 |
open (RPM, "$systemcall"); |
| 1820 |
while (<RPM>) {push(@fullrpmout, $_); } |
| 1821 |
close (RPM); |
| 1822 |
|
| 1823 |
if ( $#fullrpmout > -1 ) |
| 1824 |
{ |
| 1825 |
for ( my $i = 0; $i <= $#fullrpmout; $i++ ) |
| 1826 |
{ |
| 1827 |
my $rpmout = $fullrpmout[$i]; |
| 1828 |
$rpmout =~ s/\s*$//g; |
| 1829 |
|
| 1830 |
$infoline = "$rpmout\n"; |
| 1831 |
$infoline =~ s/error/e_r_r_o_r/gi; # avoiding log problems |
| 1832 |
push( @installer::globals::logfileinfo, $infoline); |
| 1833 |
} |
| 1834 |
} |
| 1835 |
else |
| 1836 |
{ |
| 1837 |
$infoline = "Problem in systemcall: $systemcall : No return value\n"; |
| 1838 |
push( @installer::globals::logfileinfo, $infoline); |
| 1839 |
} |
| 1840 |
|
| 1841 |
$infoline = "End of logging rpmrc\n\n"; |
| 1842 |
push( @installer::globals::logfileinfo, $infoline); |
| 1843 |
} |
| 1844 |
|
| 1845 |
################################################# |
| 1846 |
# Systemcall to start the packaging process |
| 1847 |
################################################# |
| 1848 |
|
| 1849 |
sub create_packages_without_epm |
| 1850 |
{ |
| 1851 |
my ($epmdir, $packagename, $includepatharrayref, $allvariables, $languagestringref) = @_; |
| 1852 |
|
| 1853 |
# Solaris: pkgmk -o -f solaris-2.8-sparc/SUNWso8m34.prototype -d solaris-2.8-sparc |
| 1854 |
# Solaris: pkgtrans solaris-2.8-sparc SUNWso8m34.pkg SUNWso8m34 |
| 1855 |
# Solaris: tar -cf - SUNWso8m34 | $installer::globals::packertool > SUNWso8m34.tar.gz |
| 1856 |
|
| 1857 |
if ( $installer::globals::issolarispkgbuild ) |
| 1858 |
{ |
| 1859 |
my $prototypefile = $epmdir . $packagename . ".prototype"; |
| 1860 |
if (! -f $prototypefile) { installer::exiter::exit_program("ERROR: Did not find file: $prototypefile", "create_packages_without_epm"); } |
| 1861 |
|
| 1862 |
my $destinationdir = $prototypefile; |
| 1863 |
installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationdir); |
| 1864 |
$destinationdir =~ s/\/\s*$//; # removing ending slashes |
| 1865 |
|
| 1866 |
my $systemcall = "pkgmk -l 1073741824 -o -f $prototypefile -d $destinationdir 2\>\&1 |"; |
| 1867 |
installer::logger::print_message( "... $systemcall ...\n" ); |
| 1868 |
|
| 1869 |
my $maxpkgmkcalls = 3; |
| 1870 |
|
| 1871 |
for ( my $i = 1; $i <= $maxpkgmkcalls; $i++ ) |
| 1872 |
{ |
| 1873 |
my @pkgmkoutput = (); |
| 1874 |
|
| 1875 |
open (PKGMK, "$systemcall"); |
| 1876 |
while (<PKGMK>) {push(@pkgmkoutput, $_); } |
| 1877 |
close (PKGMK); |
| 1878 |
|
| 1879 |
my $returnvalue = $?; # $? contains the return value of the systemcall |
| 1880 |
|
| 1881 |
my $infoline = "Systemcall (Try $i): $systemcall\n"; |
| 1882 |
push( @installer::globals::logfileinfo, $infoline); |
| 1883 |
|
| 1884 |
for ( my $j = 0; $j <= $#pkgmkoutput; $j++ ) |
| 1885 |
{ |
| 1886 |
if ( $i < $maxpkgmkcalls ) { $pkgmkoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; } |
| 1887 |
push( @installer::globals::logfileinfo, "$pkgmkoutput[$j]"); |
| 1888 |
} |
| 1889 |
|
| 1890 |
if ($returnvalue) |
| 1891 |
{ |
| 1892 |
$infoline = "Try $i : Could not execute \"$systemcall\"!\n"; |
| 1893 |
push( @installer::globals::logfileinfo, $infoline); |
| 1894 |
if ( $i == $maxpkgmkcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); } |
| 1895 |
} |
| 1896 |
else |
| 1897 |
{ |
| 1898 |
installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" ); |
| 1899 |
$infoline = "Success: Executed \"$systemcall\" successfully!\n"; |
| 1900 |
push( @installer::globals::logfileinfo, $infoline); |
| 1901 |
last; |
| 1902 |
} |
| 1903 |
} |
| 1904 |
|
| 1905 |
# It might be necessary to save uncompressed Solaris packages |
| 1906 |
|
| 1907 |
# compressing packages |
| 1908 |
|
| 1909 |
if ( ! $installer::globals::solarisdontcompress ) |
| 1910 |
{ |
| 1911 |
my $faspac = "faspac-so.sh"; |
| 1912 |
|
| 1913 |
my $compressorref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$faspac, $includepatharrayref, 0); |
| 1914 |
if ($$compressorref ne "") |
| 1915 |
{ |
| 1916 |
# Saving original pkginfo, to set time stamp later |
| 1917 |
my $pkginfoorig = "$destinationdir/$packagename/pkginfo"; |
| 1918 |
my $pkginfotmp = "$destinationdir/$packagename" . ".pkginfo.tmp"; |
| 1919 |
$systemcall = "cp -p $pkginfoorig $pkginfotmp"; |
| 1920 |
installer::systemactions::make_systemcall($systemcall); |
| 1921 |
|
| 1922 |
$faspac = $$compressorref; |
| 1923 |
my $infoline = "Found compressor: $faspac\n"; |
| 1924 |
push( @installer::globals::logfileinfo, $infoline); |
| 1925 |
|
| 1926 |
installer::logger::print_message( "... $faspac ...\n" ); |
| 1927 |
installer::logger::include_timestamp_into_logfile("Starting $faspac"); |
| 1928 |
|
| 1929 |
$systemcall = "/bin/sh $faspac -a -q -d $destinationdir $packagename"; # $faspac has to be the absolute path! |
| 1930 |
installer::systemactions::make_systemcall($systemcall); |
| 1931 |
|
| 1932 |
# Setting time stamp for pkginfo, because faspac-so.sh |
| 1933 |
# changed the pkginfo file, updated the size and |
| 1934 |
# checksum, but not the time stamp. |
| 1935 |
$systemcall = "touch -r $pkginfotmp $pkginfoorig"; |
| 1936 |
installer::systemactions::make_systemcall($systemcall); |
| 1937 |
if ( -f $pkginfotmp ) { unlink($pkginfotmp); } |
| 1938 |
|
| 1939 |
installer::logger::include_timestamp_into_logfile("End of $faspac"); |
| 1940 |
} |
| 1941 |
else |
| 1942 |
{ |
| 1943 |
my $infoline = "Not found: $faspac\n"; |
| 1944 |
push( @installer::globals::logfileinfo, $infoline); |
| 1945 |
} |
| 1946 |
} |
| 1947 |
|
| 1948 |
# Setting unix rights to "775" for all created directories inside the package |
| 1949 |
|
| 1950 |
$systemcall = "cd $destinationdir; find $packagename -type d | xargs -i chmod 775 \{\} \;"; |
| 1951 |
installer::logger::print_message( "... $systemcall ...\n" ); |
| 1952 |
|
| 1953 |
my $returnvalue = system($systemcall); |
| 1954 |
|
| 1955 |
my $infoline = "Systemcall: $systemcall\n"; |
| 1956 |
push( @installer::globals::logfileinfo, $infoline); |
| 1957 |
|
| 1958 |
if ($returnvalue) |
| 1959 |
{ |
| 1960 |
$infoline = "ERROR: Could not execute \"$systemcall\"!\n"; |
| 1961 |
push( @installer::globals::logfileinfo, $infoline); |
| 1962 |
} |
| 1963 |
else |
| 1964 |
{ |
| 1965 |
$infoline = "Success: Executed \"$systemcall\" successfully!\n"; |
| 1966 |
push( @installer::globals::logfileinfo, $infoline); |
| 1967 |
} |
| 1968 |
|
| 1969 |
|
| 1970 |
###################### |
| 1971 |
# making pkg files |
| 1972 |
###################### |
| 1973 |
|
| 1974 |
# my $streamname = $packagename . ".pkg"; |
| 1975 |
# $systemcall = "pkgtrans $destinationdir $streamname $packagename"; |
| 1976 |
# print "... $systemcall ...\n"; |
| 1977 |
|
| 1978 |
# $returnvalue = system($systemcall); |
| 1979 |
|
| 1980 |
# $infoline = "Systemcall: $systemcall\n"; |
| 1981 |
# push( @installer::globals::logfileinfo, $infoline); |
| 1982 |
|
| 1983 |
# if ($returnvalue) |
| 1984 |
# { |
| 1985 |
# $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; |
| 1986 |
# push( @installer::globals::logfileinfo, $infoline); |
| 1987 |
# } |
| 1988 |
# else |
| 1989 |
# { |
| 1990 |
# $infoline = "Success: Executed \"$systemcall\" successfully!\n"; |
| 1991 |
# push( @installer::globals::logfileinfo, $infoline); |
| 1992 |
# } |
| 1993 |
|
| 1994 |
######################### |
| 1995 |
# making tar.gz files |
| 1996 |
######################### |
| 1997 |
|
| 1998 |
# my $targzname = $packagename . ".tar.gz"; |
| 1999 |
# $systemcall = "cd $destinationdir; tar -cf - $packagename | $installer::globals::packertool > $targzname"; |
| 2000 |
# print "... $systemcall ...\n"; |
| 2001 |
|
| 2002 |
# $returnvalue = system($systemcall); |
| 2003 |
|
| 2004 |
# $infoline = "Systemcall: $systemcall\n"; |
| 2005 |
# push( @installer::globals::logfileinfo, $infoline); |
| 2006 |
|
| 2007 |
# if ($returnvalue) |
| 2008 |
# { |
| 2009 |
# $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; |
| 2010 |
# push( @installer::globals::logfileinfo, $infoline); |
| 2011 |
# } |
| 2012 |
# else |
| 2013 |
# { |
| 2014 |
# $infoline = "Success: Executed \"$systemcall\" successfully!\n"; |
| 2015 |
# push( @installer::globals::logfileinfo, $infoline); |
| 2016 |
# } |
| 2017 |
|
| 2018 |
} |
| 2019 |
|
| 2020 |
# Linux: rpm -bb so8m35.spec ( -> dependency check abklemmen? ) |
| 2021 |
|
| 2022 |
if ( $installer::globals::isrpmbuild ) |
| 2023 |
{ |
| 2024 |
my $specfilename = $epmdir . $packagename . ".spec"; |
| 2025 |
if (! -f $specfilename) { installer::exiter::exit_program("ERROR: Did not find file: $specfilename", "create_packages_without_epm"); } |
| 2026 |
|
| 2027 |
my $rpmcommand = $installer::globals::rpm; |
| 2028 |
my $rpmversion = determine_rpm_version(); |
| 2029 |
|
| 2030 |
my $target = ""; |
| 2031 |
if ( $installer::globals::platformid eq 'linux_x86') |
| 2032 |
{ |
| 2033 |
$target = "i586"; |
| 2034 |
} |
| 2035 |
elsif ( $installer::globals::os eq 'LINUX') |
| 2036 |
{ |
| 2037 |
$target = (POSIX::uname())[4]; |
| 2038 |
} |
| 2039 |
|
| 2040 |
# rpm 4.6 ignores buildroot tag in spec file |
| 2041 |
|
| 2042 |
my $buildrootstring = ""; |
| 2043 |
|
| 2044 |
if ( $rpmversion >= 4 ) |
| 2045 |
{ |
| 2046 |
my $dir = Cwd::getcwd; |
| 2047 |
my $buildroot = $dir . "/" . $epmdir . "buildroot/"; |
| 2048 |
$buildrootstring = "--buildroot=$buildroot"; |
| 2049 |
mkdir($buildroot = $dir . "/" . $epmdir . "BUILD/"); |
| 2050 |
} |
| 2051 |
|
| 2052 |
if ( ! $installer::globals::rpminfologged ) |
| 2053 |
{ |
| 2054 |
log_rpm_info(); |
| 2055 |
$installer::globals::rpminfologged = 1; |
| 2056 |
} |
| 2057 |
|
| 2058 |
my $systemcall = "$rpmcommand -bb --define \"_unpackaged_files_terminate_build 0\" --define \"_build_id_links none\" $specfilename --target $target $buildrootstring 2\>\&1 |"; |
| 2059 |
|
| 2060 |
installer::logger::print_message( "... $systemcall ...\n" ); |
| 2061 |
|
| 2062 |
my $maxrpmcalls = 3; |
| 2063 |
my $rpm_failed = 0; |
| 2064 |
|
| 2065 |
for ( my $i = 1; $i <= $maxrpmcalls; $i++ ) |
| 2066 |
{ |
| 2067 |
my @rpmoutput = (); |
| 2068 |
|
| 2069 |
open (RPM, "$systemcall"); |
| 2070 |
while (<RPM>) {push(@rpmoutput, $_); } |
| 2071 |
close (RPM); |
| 2072 |
|
| 2073 |
my $returnvalue = $?; # $? contains the return value of the systemcall |
| 2074 |
|
| 2075 |
my $infoline = "Systemcall (Try $i): $systemcall\n"; |
| 2076 |
push( @installer::globals::logfileinfo, $infoline); |
| 2077 |
|
| 2078 |
for ( my $j = 0; $j <= $#rpmoutput; $j++ ) |
| 2079 |
{ |
| 2080 |
$rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; |
| 2081 |
push( @installer::globals::logfileinfo, "$rpmoutput[$j]"); |
| 2082 |
} |
| 2083 |
|
| 2084 |
if ($returnvalue) |
| 2085 |
{ |
| 2086 |
$infoline = "Try $i : Could not execute \"$systemcall\"!\n"; |
| 2087 |
push( @installer::globals::logfileinfo, $infoline); |
| 2088 |
$rpm_failed = 1; |
| 2089 |
} |
| 2090 |
else |
| 2091 |
{ |
| 2092 |
installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" ); |
| 2093 |
$infoline = "Success: Executed \"$systemcall\" successfully!\n"; |
| 2094 |
push( @installer::globals::logfileinfo, $infoline); |
| 2095 |
$rpm_failed = 0; |
| 2096 |
last; |
| 2097 |
} |
| 2098 |
} |
| 2099 |
|
| 2100 |
if ( $rpm_failed ) |
| 2101 |
{ |
| 2102 |
# Because of the problems with LD_LIBRARY_PATH, a direct call of local "rpm" or "rpmbuild" might be successful |
| 2103 |
my $rpmprog = ""; |
| 2104 |
if ( -f "/usr/bin/rpmbuild" ) { $rpmprog = "/usr/bin/rpmbuild"; } |
| 2105 |
elsif ( -f "/usr/bin/rpm" ) { $rpmprog = "/usr/bin/rpm"; } |
| 2106 |
|
| 2107 |
if ( $rpmprog ne "" ) |
| 2108 |
{ |
| 2109 |
installer::logger::print_message( "... $rpmprog ...\n" ); |
| 2110 |
|
| 2111 |
my $helpersystemcall = "$rpmprog -bb $specfilename --target $target $buildrootstring 2\>\&1 |"; |
| 2112 |
|
| 2113 |
my @helperrpmoutput = (); |
| 2114 |
|
| 2115 |
open (RPM, "$helpersystemcall"); |
| 2116 |
while (<RPM>) {push(@helperrpmoutput, $_); } |
| 2117 |
close (RPM); |
| 2118 |
|
| 2119 |
my $helperreturnvalue = $?; # $? contains the return value of the systemcall |
| 2120 |
|
| 2121 |
my $infoline = "\nLast try: Using $rpmprog directly (problem with LD_LIBRARY_PATH)\n"; |
| 2122 |
push( @installer::globals::logfileinfo, $infoline); |
| 2123 |
|
| 2124 |
$infoline = "\nSystemcall: $helpersystemcall\n"; |
| 2125 |
push( @installer::globals::logfileinfo, $infoline); |
| 2126 |
|
| 2127 |
for ( my $j = 0; $j <= $#helperrpmoutput; $j++ ) { push( @installer::globals::logfileinfo, "$helperrpmoutput[$j]"); } |
| 2128 |
|
| 2129 |
if ($helperreturnvalue) |
| 2130 |
{ |
| 2131 |
$infoline = "Could not execute \"$helpersystemcall\"!\n"; |
| 2132 |
push( @installer::globals::logfileinfo, $infoline); |
| 2133 |
} |
| 2134 |
else |
| 2135 |
{ |
| 2136 |
installer::logger::print_message( "Success: \"$helpersystemcall\"\n" ); |
| 2137 |
$infoline = "Success: Executed \"$helpersystemcall\" successfully!\n"; |
| 2138 |
push( @installer::globals::logfileinfo, $infoline); |
| 2139 |
$rpm_failed = 0; |
| 2140 |
} |
| 2141 |
} |
| 2142 |
|
| 2143 |
# Now it is really time to exit this packaging process, if the error still occurs |
| 2144 |
if ( $rpm_failed ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); } |
| 2145 |
} |
| 2146 |
} |
| 2147 |
} |
| 2148 |
|
| 2149 |
################################################# |
| 2150 |
# Removing all temporary files created by epm |
| 2151 |
################################################# |
| 2152 |
|
| 2153 |
sub remove_temporary_epm_files |
| 2154 |
{ |
| 2155 |
my ($epmdir, $loggingdir, $packagename) = @_; |
| 2156 |
|
| 2157 |
# saving the files into the loggingdir |
| 2158 |
|
| 2159 |
if ( $installer::globals::issolarispkgbuild ) |
| 2160 |
{ |
| 2161 |
my @extensions = (); |
| 2162 |
push(@extensions, ".pkginfo"); |
| 2163 |
push(@extensions, ".prototype"); |
| 2164 |
push(@extensions, ".postinstall"); |
| 2165 |
push(@extensions, ".postremove"); |
| 2166 |
push(@extensions, ".preinstall"); |
| 2167 |
push(@extensions, ".preremove"); |
| 2168 |
push(@extensions, ".depend"); |
| 2169 |
|
| 2170 |
for ( my $i = 0; $i <= $#extensions; $i++ ) |
| 2171 |
{ |
| 2172 |
my $removefile = $epmdir . $packagename . $extensions[$i]; |
| 2173 |
my $destfile = $loggingdir . $packagename . $extensions[$i] . ".log"; |
| 2174 |
|
| 2175 |
if (! -f $removefile) { next; } |
| 2176 |
|
| 2177 |
my $systemcall = "mv -f $removefile $destfile"; |
| 2178 |
system($systemcall); # ignoring the return value |
| 2179 |
my $infoline = "Systemcall: $systemcall\n"; |
| 2180 |
push( @installer::globals::logfileinfo, $infoline); |
| 2181 |
} |
| 2182 |
} |
| 2183 |
|
| 2184 |
if ( $installer::globals::isrpmbuild ) |
| 2185 |
{ |
| 2186 |
my $removefile = $epmdir . $packagename . ".spec"; |
| 2187 |
my $destfile = $loggingdir . $packagename . ".spec.log"; |
| 2188 |
|
| 2189 |
my $systemcall = "mv -f $removefile $destfile"; |
| 2190 |
system($systemcall); # ignoring the return value |
| 2191 |
my $infoline = "Systemcall: $systemcall\n"; |
| 2192 |
push( @installer::globals::logfileinfo, $infoline); |
| 2193 |
|
| 2194 |
# removing the directory "buildroot" |
| 2195 |
|
| 2196 |
my $removedir = $epmdir . "buildroot"; |
| 2197 |
|
| 2198 |
$systemcall = "rm -rf $removedir"; |
| 2199 |
|
| 2200 |
installer::logger::print_message( "... $systemcall ...\n" ); |
| 2201 |
|
| 2202 |
my $returnvalue = system($systemcall); |
| 2203 |
|
| 2204 |
$removedir = $epmdir . "BUILD"; |
| 2205 |
|
| 2206 |
$systemcall = "rm -rf $removedir"; |
| 2207 |
|
| 2208 |
installer::logger::print_message( "... $systemcall ...\n" ); |
| 2209 |
|
| 2210 |
$returnvalue = system($systemcall); |
| 2211 |
|
| 2212 |
|
| 2213 |
$infoline = "Systemcall: $systemcall\n"; |
| 2214 |
push( @installer::globals::logfileinfo, $infoline); |
| 2215 |
|
| 2216 |
if ($returnvalue) |
| 2217 |
{ |
| 2218 |
$infoline = "ERROR: Could not execute \"$systemcall\"!\n"; |
| 2219 |
push( @installer::globals::logfileinfo, $infoline); |
| 2220 |
} |
| 2221 |
else |
| 2222 |
{ |
| 2223 |
$infoline = "Success: Executed \"$systemcall\" successfully!\n"; |
| 2224 |
push( @installer::globals::logfileinfo, $infoline); |
| 2225 |
} |
| 2226 |
} |
| 2227 |
} |
| 2228 |
|
| 2229 |
########################################################### |
| 2230 |
# Creating a better directory structure in the solver. |
| 2231 |
########################################################### |
| 2232 |
|
| 2233 |
sub create_new_directory_structure |
| 2234 |
{ |
| 2235 |
my ($newepmdir) = @_; |
| 2236 |
|
| 2237 |
my $newdir = $installer::globals::epmoutpath; |
| 2238 |
|
| 2239 |
if ( $installer::globals::isrpmbuild ) |
| 2240 |
{ |
| 2241 |
my $rpmdir; |
| 2242 |
my $machine = ""; |
| 2243 |
if ( $installer::globals::platformid eq 'linux_x86') |
| 2244 |
{ |
| 2245 |
$rpmdir = "$installer::globals::epmoutpath/RPMS/i586"; |
| 2246 |
} |
| 2247 |
elsif ( $installer::globals::os eq 'LINUX') |
| 2248 |
{ |
| 2249 |
$machine = (POSIX::uname())[4]; |
| 2250 |
$rpmdir = "$installer::globals::epmoutpath/RPMS/$machine"; |
| 2251 |
} |
| 2252 |
else |
| 2253 |
{ |
| 2254 |
installer::exiter::exit_program("ERROR: rpmdir undefined !", "create_new_directory_structure"); |
| 2255 |
} |
| 2256 |
|
| 2257 |
my $systemcall = "mv $rpmdir/* $newdir"; # moving the rpms into the directory "RPMS" |
| 2258 |
|
| 2259 |
my $returnvalue = system($systemcall); |
| 2260 |
|
| 2261 |
my $infoline = "Systemcall: $systemcall\n"; |
| 2262 |
push( @installer::globals::logfileinfo, $infoline); |
| 2263 |
|
| 2264 |
if ($returnvalue) |
| 2265 |
{ |
| 2266 |
$infoline = "ERROR: Could not move content of \"$rpmdir\" to \"$newdir\"!\n"; |
| 2267 |
push( @installer::globals::logfileinfo, $infoline); |
| 2268 |
} |
| 2269 |
else |
| 2270 |
{ |
| 2271 |
$infoline = "Success: Moved content of \"$rpmdir\" to \"$newdir\"!\n"; |
| 2272 |
push( @installer::globals::logfileinfo, $infoline); |
| 2273 |
} |
| 2274 |
|
| 2275 |
# and removing the empty directory |
| 2276 |
|
| 2277 |
if ( $machine ne "" ) |
| 2278 |
{ |
| 2279 |
rmdir "$installer::globals::epmoutpath/RPMS/$machine"; |
| 2280 |
} |
| 2281 |
rmdir "$installer::globals::epmoutpath/RPMS/powerpc"; |
| 2282 |
rmdir "$installer::globals::epmoutpath/RPMS/x86_64"; |
| 2283 |
rmdir "$installer::globals::epmoutpath/RPMS/i586"; |
| 2284 |
rmdir "$installer::globals::epmoutpath/RPMS/i386"; |
| 2285 |
rmdir "$installer::globals::epmoutpath/RPMS" |
| 2286 |
or warn "Could not remove RPMS dir: $!"; |
| 2287 |
} |
| 2288 |
|
| 2289 |
# Setting unix rights to "775" for $newdir ("RPMS" or "packages") |
| 2290 |
chmod 0775, $newdir; |
| 2291 |
} |
| 2292 |
|
| 2293 |
###################################################### |
| 2294 |
# Collect modules with product specific styles. |
| 2295 |
###################################################### |
| 2296 |
|
| 2297 |
sub collect_modules_with_style |
| 2298 |
{ |
| 2299 |
my ($style, $modulesarrayref) = @_; |
| 2300 |
|
| 2301 |
my @allmodules = (); |
| 2302 |
|
| 2303 |
for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ ) |
| 2304 |
{ |
| 2305 |
my $onemodule = ${$modulesarrayref}[$i]; |
| 2306 |
my $styles = ""; |
| 2307 |
if ( $onemodule->{'Styles'} ) { $styles = $onemodule->{'Styles'}; } |
| 2308 |
if ( $styles =~ /\b\Q$style\E\b/ ) |
| 2309 |
{ |
| 2310 |
push(@allmodules, $onemodule); |
| 2311 |
} |
| 2312 |
} |
| 2313 |
|
| 2314 |
return \@allmodules; |
| 2315 |
} |
| 2316 |
|
| 2317 |
###################################################### |
| 2318 |
# Remove modules without packagecontent. |
| 2319 |
###################################################### |
| 2320 |
|
| 2321 |
sub remove_modules_without_package |
| 2322 |
{ |
| 2323 |
my ($allmodules) = @_; |
| 2324 |
|
| 2325 |
my @allmodules = (); |
| 2326 |
|
| 2327 |
for ( my $i = 0; $i <= $#{$allmodules}; $i++ ) |
| 2328 |
{ |
| 2329 |
my $onemodule = ${$allmodules}[$i]; |
| 2330 |
my $packagename = ""; |
| 2331 |
if ( $onemodule->{'PackageName'} ) { $packagename = $onemodule->{'PackageName'}; } |
| 2332 |
if ( $packagename ne "" ) |
| 2333 |
{ |
| 2334 |
push(@allmodules, $onemodule); |
| 2335 |
} |
| 2336 |
} |
| 2337 |
|
| 2338 |
return \@allmodules; |
| 2339 |
} |
| 2340 |
|
| 2341 |
###################################################### |
| 2342 |
# Copying files for system integration. |
| 2343 |
###################################################### |
| 2344 |
|
| 2345 |
sub copy_and_unpack_tar_gz_files |
| 2346 |
{ |
| 2347 |
my ($sourcefile, $destdir) = @_; |
| 2348 |
|
| 2349 |
my $systemcall = "cd $destdir; cat $sourcefile | gunzip | tar -xf -"; |
| 2350 |
installer::systemactions::make_systemcall($systemcall); |
| 2351 |
} |
| 2352 |
|
| 2353 |
###################################################### |
| 2354 |
# Checking whether the new content is a directory and |
| 2355 |
# not a package. If it is a directory, the complete |
| 2356 |
# content of the directory has to be added to the |
| 2357 |
# array newcontent. |
| 2358 |
###################################################### |
| 2359 |
|
| 2360 |
sub control_subdirectories |
| 2361 |
{ |
| 2362 |
my ($content, $subdir) = @_; |
| 2363 |
|
| 2364 |
my @newcontent = (); |
| 2365 |
|
| 2366 |
for ( my $i = 0; $i <= $#{$content}; $i++ ) |
| 2367 |
{ |
| 2368 |
if ( -d ${$content}[$i] ) |
| 2369 |
{ |
| 2370 |
$subdir = ${$content}[$i]; |
| 2371 |
installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$subdir); |
| 2372 |
my $allpackages = installer::systemactions::read_directory(${$content}[$i]); |
| 2373 |
for ( my $j = 0; $j <= $#{$allpackages}; $j++ ) |
| 2374 |
{ |
| 2375 |
# Currently only Linux rpm is supported, debian packages cannot be installed via xpd installer |
| 2376 |
if (( $installer::globals::islinuxbuild ) && ( ! ( ${$allpackages}[$j] =~ /\.rpm\s*$/ ))) { next; } |
| 2377 |
push(@newcontent, ${$allpackages}[$j]); |
| 2378 |
} |
| 2379 |
} |
| 2380 |
else |
| 2381 |
{ |
| 2382 |
push(@newcontent, ${$content}[$i]); |
| 2383 |
} |
| 2384 |
} |
| 2385 |
|
| 2386 |
return (\@newcontent, $subdir); |
| 2387 |
} |
| 2388 |
|
| 2389 |
###################################################### |
| 2390 |
# Including the system integration files into the |
| 2391 |
# installation sets. |
| 2392 |
###################################################### |
| 2393 |
|
| 2394 |
sub put_systemintegration_into_installset |
| 2395 |
{ |
| 2396 |
my ($newdir, $includepatharrayref, $allvariables, $modulesarrayref) = @_; |
| 2397 |
|
| 2398 |
my $destdir = $newdir; |
| 2399 |
|
| 2400 |
# adding System integration files |
| 2401 |
|
| 2402 |
my $sourcefile = ""; |
| 2403 |
|
| 2404 |
# Finding the modules defined in scp (with flag SYSTEMMODULE) |
| 2405 |
# Getting name of package from scp-Module |
| 2406 |
# Search package in list of all include files |
| 2407 |
# Copy file into installation set and unpack it (always tar.gz) |
| 2408 |
# tar.gz can contain a different number of packages -> automatically create hidden sub modules |
| 2409 |
|
| 2410 |
# Collect all modules with flag "SYSTEMMODULE" |
| 2411 |
my $allmodules = collect_modules_with_style("SYSTEMMODULE", $modulesarrayref); |
| 2412 |
$allmodules = remove_modules_without_package($allmodules); |
| 2413 |
|
| 2414 |
for ( my $i = 0; $i <= $#{$allmodules}; $i++ ) |
| 2415 |
{ |
| 2416 |
my $onemodule = ${$allmodules}[$i]; |
| 2417 |
my $packagetarfilename = $onemodule->{'PackageName'}; |
| 2418 |
|
| 2419 |
my $infoline = "Including into installation set: $packagetarfilename\n"; |
| 2420 |
push( @installer::globals::logfileinfo, $infoline); |
| 2421 |
|
| 2422 |
my $sourcepathref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packagetarfilename, $includepatharrayref, 1); |
| 2423 |
if ( $$sourcepathref eq "" ) { installer::exiter::exit_program("ERROR: Source path not found for $packagetarfilename!", "copy_systemintegration_files"); } |
| 2424 |
|
| 2425 |
# Collecting all packages in directory "packages" or "RPMS" |
| 2426 |
my $oldcontent = installer::systemactions::read_directory($destdir); |
| 2427 |
|
| 2428 |
copy_and_unpack_tar_gz_files($$sourcepathref, $destdir); |
| 2429 |
|
| 2430 |
# Finding new content -> that is the package name |
| 2431 |
my ($newcontent, $allcontent ) = installer::systemactions::find_new_content_in_directory($destdir, $oldcontent); |
| 2432 |
|
| 2433 |
# special handling, if new content is a directory |
| 2434 |
my $subdir = ""; |
| 2435 |
if ( ! $installer::globals::issolarispkgbuild ) { ($newcontent, $subdir) = control_subdirectories($newcontent); } |
| 2436 |
|
| 2437 |
# Adding license content into Solaris packages |
| 2438 |
if (( $installer::globals::issolarispkgbuild ) && ( $installer::globals::englishlicenseset ) && ( ! $allvariables->{'NO_LICENSE_INTO_COPYRIGHT'} )) { _add_license_into_systemintegrationpackages($destdir, $newcontent); } |
| 2439 |
} |
| 2440 |
} |
| 2441 |
|
| 2442 |
###################################################### |
| 2443 |
# Analyzing the Unix installation path. |
| 2444 |
# From the installation path /opt/openofficeorg20 |
| 2445 |
# is the part /opt relocatable and the part |
| 2446 |
# openofficeorg20 static. |
| 2447 |
###################################################### |
| 2448 |
|
| 2449 |
sub analyze_rootpath |
| 2450 |
{ |
| 2451 |
my ($rootpath, $staticpathref, $relocatablepathref, $allvariables) = @_; |
| 2452 |
|
| 2453 |
$rootpath =~ s/\/\s*$//; # removing ending slash |
| 2454 |
|
| 2455 |
############################################################## |
| 2456 |
# Version 3: "/" is variable and "/opt/openofficeorg20" fixed |
| 2457 |
############################################################## |
| 2458 |
|
| 2459 |
$$relocatablepathref = "/"; |
| 2460 |
# Static path has to contain the office directory name. This is replaced in shellscripts. |
| 2461 |
$$staticpathref = $rootpath . $installer::globals::separator . $installer::globals::officedirhostname; |
| 2462 |
# For RPM version 3.x it is required, that Prefix is not "/" in spec file. In this case --relocate will not work, |
| 2463 |
# because RPM 3.x says, that the package is not relocatable. Therefore we have to use Prefix=/opt and for |
| 2464 |
# all usages of --relocate this path has to be on both sides of the "=": --relocate /opt=<myselectdir>/opt . |
| 2465 |
if ( $installer::globals::isrpmbuild ) |
| 2466 |
{ |
| 2467 |
$$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/" |
| 2468 |
$$staticpathref = $installer::globals::officedirhostname; # to be used as replacement in shell scripts |
| 2469 |
} |
| 2470 |
|
| 2471 |
if ( $installer::globals::isdebbuild ) |
| 2472 |
{ |
| 2473 |
$$relocatablepathref = ""; |
| 2474 |
# $$staticpathref is already "/opt/libreoffice", no additional $rootpath required. |
| 2475 |
} |
| 2476 |
|
| 2477 |
} |
| 2478 |
|
| 2479 |
################################################ |
| 2480 |
# Defining the English license text to add |
| 2481 |
# it into Solaris packages. |
| 2482 |
################################################ |
| 2483 |
|
| 2484 |
sub _set_english_license |
| 2485 |
{ |
| 2486 |
my ($variableshashref) = @_; |
| 2487 |
|
| 2488 |
my $additional_license_name = $installer::globals::englishsolarislicensename; # always the English file |
| 2489 |
my $licensefileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$additional_license_name, "" , 0); |
| 2490 |
if ( $$licensefileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find license file $additional_license_name!", "set_english_license"); } |
| 2491 |
$installer::globals::englishlicenseset = 1; |
| 2492 |
$installer::globals::englishlicense = installer::files::read_file($$licensefileref); |
| 2493 |
installer::scpzipfiles::replace_all_ziplistvariables_in_file($installer::globals::englishlicense, $variableshashref); |
| 2494 |
} |
| 2495 |
|
| 2496 |
################################################ |
| 2497 |
# Adding the content of the English license |
| 2498 |
# file into the system integration packages. |
| 2499 |
################################################ |
| 2500 |
|
| 2501 |
sub _add_license_into_systemintegrationpackages |
| 2502 |
{ |
| 2503 |
my ($destdir, $packages) = @_; |
| 2504 |
|
| 2505 |
for ( my $i = 0; $i <= $#{$packages}; $i++ ) |
| 2506 |
{ |
| 2507 |
my $copyrightfilename = ${$packages}[$i] . $installer::globals::separator . "install" . $installer::globals::separator . "copyright"; |
| 2508 |
if ( ! -f $copyrightfilename ) { installer::exiter::exit_program("ERROR: Could not find license file in system integration package: $copyrightfilename!", "add_license_into_systemintegrationpackages"); } |
| 2509 |
my $copyrightfile = installer::files::read_file($copyrightfilename); |
| 2510 |
|
| 2511 |
# Saving time stamp of old copyrightfile |
| 2512 |
my $savcopyrightfilename = $copyrightfilename . ".sav"; |
| 2513 |
installer::systemactions::copy_one_file($copyrightfilename, $savcopyrightfilename); |
| 2514 |
_set_time_stamp_for_file($copyrightfilename, $savcopyrightfilename); # now $savcopyrightfile has the time stamp of $copyrightfile |
| 2515 |
|
| 2516 |
# Adding license content to copyright file |
| 2517 |
push(@{$copyrightfile}, "\n"); |
| 2518 |
for ( my $i = 0; $i <= $#{$installer::globals::englishlicense}; $i++ ) { push(@{$copyrightfile}, ${$installer::globals::englishlicense}[$i]); } |
| 2519 |
installer::files::save_file($copyrightfilename, $copyrightfile); |
| 2520 |
|
| 2521 |
# Setting the old time stamp saved with $savcopyrightfilename |
| 2522 |
_set_time_stamp_for_file($savcopyrightfilename, $copyrightfilename); # now $copyrightfile has the time stamp of $savcopyrightfile |
| 2523 |
unlink($savcopyrightfilename); |
| 2524 |
|
| 2525 |
# Changing content of copyright file in pkgmap |
| 2526 |
my $pkgmapfilename = ${$packages}[$i] . $installer::globals::separator . "pkgmap"; |
| 2527 |
if ( ! -f $pkgmapfilename ) { installer::exiter::exit_program("ERROR: Could not find pkgmap in system integration package: $pkgmapfilename!", "add_license_into_systemintegrationpackages"); } |
| 2528 |
my $pkgmap = installer::files::read_file($pkgmapfilename); |
| 2529 |
_change_onefile_in_pkgmap($pkgmap, $copyrightfilename, "copyright"); |
| 2530 |
installer::files::save_file($pkgmapfilename, $pkgmap); |
| 2531 |
} |
| 2532 |
} |
| 2533 |
|
| 2534 |
############################################## |
| 2535 |
# Setting time stamp of copied files to avoid |
| 2536 |
# errors from pkgchk. |
| 2537 |
############################################## |
| 2538 |
|
| 2539 |
sub _set_time_stamp_for_file |
| 2540 |
{ |
| 2541 |
my ($sourcefile, $destfile) = @_; |
| 2542 |
|
| 2543 |
my $systemcall = "touch -r $sourcefile $destfile"; |
| 2544 |
|
| 2545 |
my $returnvalue = system($systemcall); |
| 2546 |
|
| 2547 |
my $infoline = "Systemcall: $systemcall\n"; |
| 2548 |
push( @installer::globals::logfileinfo, $infoline); |
| 2549 |
|
| 2550 |
if ($returnvalue) |
| 2551 |
{ |
| 2552 |
$infoline = "ERROR: \"$systemcall\" failed!\n"; |
| 2553 |
push( @installer::globals::logfileinfo, $infoline); |
| 2554 |
} |
| 2555 |
else |
| 2556 |
{ |
| 2557 |
$infoline = "Success: \"$systemcall\" !\n"; |
| 2558 |
push( @installer::globals::logfileinfo, $infoline); |
| 2559 |
} |
| 2560 |
} |
| 2561 |
|
| 2562 |
############################################## |
| 2563 |
# Setting checksum and wordcount for changed |
| 2564 |
# pkginfo file into pkgmap. |
| 2565 |
############################################## |
| 2566 |
|
| 2567 |
sub _change_onefile_in_pkgmap |
| 2568 |
{ |
| 2569 |
my ($pkgmapfile, $fullfilename, $shortfilename) = @_; |
| 2570 |
|
| 2571 |
# 1 i pkginfo 442 34577 1166716297 |
| 2572 |
# -> |
| 2573 |
# 1 i pkginfo 443 34737 1166716297 |
| 2574 |
# |
| 2575 |
# wc -c pkginfo | cut -f6 -d' ' -> 442 (variable) |
| 2576 |
# sum pkginfo | cut -f1 -d' ' -> 34577 (variable) |
| 2577 |
# grep 'pkginfo' pkgmap | cut -f6 -d' ' -> 1166716297 (fix) |
| 2578 |
|
| 2579 |
my $checksum = _call_sum($fullfilename); |
| 2580 |
if ( $checksum =~ /^\s*(\d+)\s+.*$/ ) { $checksum = $1; } |
| 2581 |
|
| 2582 |
my $wordcount = _call_wc($fullfilename); |
| 2583 |
if ( $wordcount =~ /^\s*(\d+)\s+.*$/ ) { $wordcount = $1; } |
| 2584 |
|
| 2585 |
for ( my $i = 0; $i <= $#{$pkgmapfile}; $i++ ) |
| 2586 |
{ |
| 2587 |
if ( ${$pkgmapfile}[$i] =~ /(^.*\b\Q$shortfilename\E\b\s+)(\d+)(\s+)(\d+)(\s+)(\d+)(\s*$)/ ) |
| 2588 |
{ |
| 2589 |
my $newline = $1 . $wordcount . $3 . $checksum . $5 . $6 . $7; |
| 2590 |
${$pkgmapfile}[$i] = $newline; |
| 2591 |
last; |
| 2592 |
} |
| 2593 |
} |
| 2594 |
} |
| 2595 |
|
| 2596 |
######################################################### |
| 2597 |
# Calling sum |
| 2598 |
######################################################### |
| 2599 |
|
| 2600 |
sub _call_sum |
| 2601 |
{ |
| 2602 |
my ($filename) = @_; |
| 2603 |
|
| 2604 |
my $sumfile = "/usr/bin/sum"; |
| 2605 |
|
| 2606 |
if ( ! -f $sumfile ) { installer::exiter::exit_program("ERROR: No file /usr/bin/sum", "call_sum"); } |
| 2607 |
|
| 2608 |
my $systemcall = "$sumfile $filename |"; |
| 2609 |
|
| 2610 |
my $sumoutput = ""; |
| 2611 |
|
| 2612 |
open (SUM, "$systemcall"); |
| 2613 |
$sumoutput = <SUM>; |
| 2614 |
close (SUM); |
| 2615 |
|
| 2616 |
my $returnvalue = $?; # $? contains the return value of the systemcall |
| 2617 |
|
| 2618 |
my $infoline = "Systemcall: $systemcall\n"; |
| 2619 |
push( @installer::globals::logfileinfo, $infoline); |
| 2620 |
|
| 2621 |
if ($returnvalue) |
| 2622 |
{ |
| 2623 |
$infoline = "ERROR: Could not execute \"$systemcall\"!\n"; |
| 2624 |
push( @installer::globals::logfileinfo, $infoline); |
| 2625 |
} |
| 2626 |
else |
| 2627 |
{ |
| 2628 |
$infoline = "Success: Executed \"$systemcall\" successfully!\n"; |
| 2629 |
push( @installer::globals::logfileinfo, $infoline); |
| 2630 |
} |
| 2631 |
|
| 2632 |
return $sumoutput; |
| 2633 |
} |
| 2634 |
|
| 2635 |
######################################################### |
| 2636 |
# Calling wc |
| 2637 |
# wc -c pkginfo | cut -f6 -d' ' |
| 2638 |
######################################################### |
| 2639 |
|
| 2640 |
sub _call_wc |
| 2641 |
{ |
| 2642 |
my ($filename) = @_; |
| 2643 |
|
| 2644 |
my $wcfile = "/usr/bin/wc"; |
| 2645 |
|
| 2646 |
if ( ! -f $wcfile ) { installer::exiter::exit_program("ERROR: No file /usr/bin/wc", "call_wc"); } |
| 2647 |
|
| 2648 |
my $systemcall = "$wcfile -c $filename |"; |
| 2649 |
|
| 2650 |
my $wcoutput = ""; |
| 2651 |
|
| 2652 |
open (WC, "$systemcall"); |
| 2653 |
$wcoutput = <WC>; |
| 2654 |
close (WC); |
| 2655 |
|
| 2656 |
my $returnvalue = $?; # $? contains the return value of the systemcall |
| 2657 |
|
| 2658 |
my $infoline = "Systemcall: $systemcall\n"; |
| 2659 |
push( @installer::globals::logfileinfo, $infoline); |
| 2660 |
|
| 2661 |
if ($returnvalue) |
| 2662 |
{ |
| 2663 |
$infoline = "ERROR: Could not execute \"$systemcall\"!\n"; |
| 2664 |
push( @installer::globals::logfileinfo, $infoline); |
| 2665 |
} |
| 2666 |
else |
| 2667 |
{ |
| 2668 |
$infoline = "Success: Executed \"$systemcall\" successfully!\n"; |
| 2669 |
push( @installer::globals::logfileinfo, $infoline); |
| 2670 |
} |
| 2671 |
|
| 2672 |
return $wcoutput; |
| 2673 |
} |
| 2674 |
|
| 2675 |
1; |