| 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::packagelist; |
| 20 |
|
| 21 |
use strict; |
| 22 |
use warnings; |
| 23 |
|
| 24 |
use installer::converter; |
| 25 |
use installer::exiter; |
| 26 |
use installer::globals; |
| 27 |
use installer::remover; |
| 28 |
use installer::scriptitems; |
| 29 |
|
| 30 |
######################################## |
| 31 |
# Check existence of module |
| 32 |
######################################## |
| 33 |
|
| 34 |
sub check_module_existence |
| 35 |
{ |
| 36 |
my ($onegid, $moduleslist) = @_; |
| 37 |
|
| 38 |
my $foundgid = 0; |
| 39 |
|
| 40 |
for ( my $i = 0; $i <= $#{$moduleslist}; $i++ ) |
| 41 |
{ |
| 42 |
my $gid = ${$moduleslist}[$i]->{'gid'}; |
| 43 |
|
| 44 |
if ( $gid eq $onegid ) |
| 45 |
{ |
| 46 |
$foundgid = 1; |
| 47 |
last; |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
return $foundgid; |
| 52 |
} |
| 53 |
|
| 54 |
################################################### |
| 55 |
# Analyzing the gids, defined in the packagelist |
| 56 |
################################################### |
| 57 |
|
| 58 |
sub analyze_list |
| 59 |
{ |
| 60 |
my ($packagelist, $moduleslist) = @_; |
| 61 |
|
| 62 |
my @allpackages = (); |
| 63 |
|
| 64 |
my $moduleshash = get_module_hash($moduleslist); |
| 65 |
|
| 66 |
for ( my $i = 0; $i <= $#{$packagelist}; $i++ ) |
| 67 |
{ |
| 68 |
my $onepackage = ${$packagelist}[$i]; |
| 69 |
|
| 70 |
my $onegid = $onepackage->{'module'}; |
| 71 |
|
| 72 |
installer::remover::remove_leading_and_ending_whitespaces(\$onegid); |
| 73 |
|
| 74 |
my $moduleexists = check_module_existence($onegid, $moduleslist); |
| 75 |
|
| 76 |
if ( ! $moduleexists ) { next; } |
| 77 |
|
| 78 |
my @allmodules = (); |
| 79 |
|
| 80 |
push(@allmodules, $onegid); |
| 81 |
|
| 82 |
get_children_with_hash($moduleshash, $onegid, \@allmodules); |
| 83 |
|
| 84 |
$onepackage->{'allmodules'} = \@allmodules; |
| 85 |
|
| 86 |
push(@allpackages, $onepackage); |
| 87 |
} |
| 88 |
|
| 89 |
return \@allpackages; |
| 90 |
} |
| 91 |
|
| 92 |
################################################### |
| 93 |
# Creating a hash, that contains the module gids |
| 94 |
# as keys and the parentids as values |
| 95 |
################################################### |
| 96 |
|
| 97 |
sub get_module_hash |
| 98 |
{ |
| 99 |
my ($moduleslist) = @_; |
| 100 |
|
| 101 |
my %modulehash = (); |
| 102 |
|
| 103 |
for ( my $i = 0; $i <= $#{$moduleslist}; $i++ ) |
| 104 |
{ |
| 105 |
my $gid = ${$moduleslist}[$i]->{'gid'}; |
| 106 |
# Containing only modules with parent. Root modules can be ignored. |
| 107 |
if ( ${$moduleslist}[$i]->{'ParentID'} ) { $modulehash{$gid} = ${$moduleslist}[$i]->{'ParentID'}; } |
| 108 |
} |
| 109 |
|
| 110 |
return \%modulehash; |
| 111 |
} |
| 112 |
|
| 113 |
######################################################## |
| 114 |
# Recursively defined procedure to order |
| 115 |
# modules and directories |
| 116 |
######################################################## |
| 117 |
|
| 118 |
sub get_children_with_hash |
| 119 |
{ |
| 120 |
my ($modulehash, $parentgid, $newitemorder) = @_; |
| 121 |
|
| 122 |
foreach my $gid ( keys %{$modulehash} ) |
| 123 |
{ |
| 124 |
my $parent = $modulehash->{$gid}; |
| 125 |
|
| 126 |
if ( $parent eq $parentgid ) |
| 127 |
{ |
| 128 |
push(@{$newitemorder}, $gid); |
| 129 |
my $parent = $gid; |
| 130 |
get_children_with_hash($modulehash, $parent, $newitemorder); # recursive! |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
######################################################## |
| 136 |
# Recursively defined procedure to order |
| 137 |
# modules and directories |
| 138 |
######################################################## |
| 139 |
|
| 140 |
sub get_children |
| 141 |
{ |
| 142 |
my ($allitems, $startparent, $newitemorder) = @_; |
| 143 |
|
| 144 |
for ( my $i = 0; $i <= $#{$allitems}; $i++ ) |
| 145 |
{ |
| 146 |
my $gid = ${$allitems}[$i]->{'gid'}; |
| 147 |
my $parent = ""; |
| 148 |
if ( ${$allitems}[$i]->{'ParentID'} ) { $parent = ${$allitems}[$i]->{'ParentID'}; } |
| 149 |
|
| 150 |
if ( $parent eq $startparent ) |
| 151 |
{ |
| 152 |
push(@{$newitemorder}, $gid); |
| 153 |
my $parent = $gid; |
| 154 |
get_children($allitems, $parent, $newitemorder); # recursive! |
| 155 |
} |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
##################################################################### |
| 160 |
# All modules below a defined gid_Module_A are collected now for |
| 161 |
# each modules defined in the packagelist. Now the modules have |
| 162 |
# to be removed, that are part of more than one package. |
| 163 |
##################################################################### |
| 164 |
|
| 165 |
sub remove_multiple_modules_packages |
| 166 |
{ |
| 167 |
my ($allpackagemodules) = @_; |
| 168 |
|
| 169 |
# iterating over all packages |
| 170 |
|
| 171 |
for ( my $i = 0; $i <= $#{$allpackagemodules}; $i++ ) |
| 172 |
{ |
| 173 |
my $onepackage = ${$allpackagemodules}[$i]; |
| 174 |
my $allmodules = $onepackage->{'allmodules'}; |
| 175 |
|
| 176 |
# Comparing each package, with all following packages. If a |
| 177 |
# gid for the module is part of more than one package, it is |
| 178 |
# removed if the number of modules in the package is greater |
| 179 |
# in the current package than in the compare package. |
| 180 |
|
| 181 |
# Taking all modules from package $i |
| 182 |
|
| 183 |
my $packagecount = $#{$allmodules}; |
| 184 |
|
| 185 |
my @optimizedpackage = (); |
| 186 |
|
| 187 |
# iterating over all modules of this package |
| 188 |
|
| 189 |
for ( my $j = 0; $j <= $#{$allmodules}; $j++ ) |
| 190 |
{ |
| 191 |
my $onemodule = ${$allmodules}[$j]; # this is the module, that shall be removed or not |
| 192 |
|
| 193 |
my $put_module_into_new_package = 1; |
| 194 |
|
| 195 |
# iterating over all other packages |
| 196 |
|
| 197 |
for ( my $k = 0; $k <= $#{$allpackagemodules}; $k++ ) |
| 198 |
{ |
| 199 |
if ( $k == $i ) { next; } # not comparing equal module |
| 200 |
|
| 201 |
if (! $put_module_into_new_package) { next; } # do not compare, if already found |
| 202 |
|
| 203 |
my $comparepackage = ${$allpackagemodules}[$k]; |
| 204 |
my $allcomparemodules = $comparepackage->{'allmodules'}; |
| 205 |
|
| 206 |
my $comparepackagecount = $#{$allcomparemodules}; |
| 207 |
|
| 208 |
# modules will only be removed from packages, that have more modules |
| 209 |
# than the compare package |
| 210 |
|
| 211 |
if ( $packagecount < $comparepackagecount ) { next; } # nothing to do, take next package |
| 212 |
|
| 213 |
# iterating over all modules of this package |
| 214 |
|
| 215 |
for ( my $m = 0; $m <= $#{$allcomparemodules}; $m++ ) |
| 216 |
{ |
| 217 |
my $onecomparemodule = ${$allcomparemodules}[$m]; |
| 218 |
|
| 219 |
if ( $onemodule eq $onecomparemodule ) # this $onemodule has to be removed |
| 220 |
{ |
| 221 |
$put_module_into_new_package = 0; |
| 222 |
} |
| 223 |
} |
| 224 |
} |
| 225 |
|
| 226 |
if ( $put_module_into_new_package ) |
| 227 |
{ |
| 228 |
push(@optimizedpackage, $onemodule) |
| 229 |
} |
| 230 |
} |
| 231 |
|
| 232 |
$onepackage->{'allmodules'} = \@optimizedpackage; |
| 233 |
} |
| 234 |
} |
| 235 |
|
| 236 |
##################################################################### |
| 237 |
# Analyzing all files if they belong to a special package. |
| 238 |
# A package is described by a list of modules. |
| 239 |
##################################################################### |
| 240 |
|
| 241 |
sub find_files_for_package |
| 242 |
{ |
| 243 |
my ($filelist, $onepackage) = @_; |
| 244 |
|
| 245 |
my @newfilelist; |
| 246 |
my $lastmodules = ''; |
| 247 |
my $lastincludefile = 0; |
| 248 |
|
| 249 |
my %packagemodules = map {$_ => 1} @{$onepackage->{'allmodules'}}; |
| 250 |
|
| 251 |
for my $onefile (@$filelist) |
| 252 |
{ |
| 253 |
my $modulesstring = $onefile->{'modules'}; # comma separated modules list |
| 254 |
|
| 255 |
# check if the modules string is the same as in the last file |
| 256 |
if ($modulesstring eq $lastmodules) |
| 257 |
{ |
| 258 |
push(@newfilelist, $onefile) if $lastincludefile; |
| 259 |
next; |
| 260 |
} |
| 261 |
|
| 262 |
my $moduleslist = installer::converter::convert_stringlist_into_array(\$modulesstring, ","); |
| 263 |
|
| 264 |
my $includefile = 0; |
| 265 |
|
| 266 |
# iterating over all modules of this file |
| 267 |
for my $filemodule (@$moduleslist) { |
| 268 |
installer::remover::remove_leading_and_ending_whitespaces(\$filemodule); |
| 269 |
if ($packagemodules{$filemodule}) { |
| 270 |
$includefile = 1; |
| 271 |
last; |
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
push(@newfilelist, $onefile) if $includefile; |
| 276 |
|
| 277 |
# cache last result for this modules list |
| 278 |
$lastmodules = $modulesstring; |
| 279 |
$lastincludefile = $includefile; |
| 280 |
|
| 281 |
} |
| 282 |
return \@newfilelist; |
| 283 |
} |
| 284 |
|
| 285 |
##################################################################### |
| 286 |
# Analyzing all links if they belong to a special package. |
| 287 |
# A package is described by a list of modules. |
| 288 |
# A link is inserted into the package, if the corresponding |
| 289 |
# file is also inserted. |
| 290 |
##################################################################### |
| 291 |
|
| 292 |
sub find_links_for_package |
| 293 |
{ |
| 294 |
my ($linklist, $filelist) = @_; |
| 295 |
|
| 296 |
# First looking for all links with a FileID. |
| 297 |
# Then looking for all links with a ShortcutID. |
| 298 |
|
| 299 |
my @newlinklist = (); |
| 300 |
|
| 301 |
for ( my $i = 0; $i <= $#{$linklist}; $i++ ) |
| 302 |
{ |
| 303 |
my $includelink = 0; |
| 304 |
|
| 305 |
my $onelink = ${$linklist}[$i]; |
| 306 |
|
| 307 |
my $fileid = ""; |
| 308 |
if ( $onelink->{'FileID'} ) { $fileid = $onelink->{'FileID'}; } |
| 309 |
|
| 310 |
if ( $fileid eq "" ) { next; } # A link with a ShortcutID |
| 311 |
|
| 312 |
for ( my $j = 0; $j <= $#{$filelist}; $j++ ) # iterating over file list |
| 313 |
{ |
| 314 |
my $onefile = ${$filelist}[$j]; |
| 315 |
my $gid = $onefile->{'gid'}; |
| 316 |
|
| 317 |
if ( $gid eq $fileid ) |
| 318 |
{ |
| 319 |
$includelink = 1; |
| 320 |
last; |
| 321 |
} |
| 322 |
} |
| 323 |
|
| 324 |
if ( $includelink ) |
| 325 |
{ |
| 326 |
push(@newlinklist, $onelink); |
| 327 |
} |
| 328 |
} |
| 329 |
|
| 330 |
# iterating over the new list, because of all links with a ShortcutID |
| 331 |
|
| 332 |
for ( my $i = 0; $i <= $#{$linklist}; $i++ ) |
| 333 |
{ |
| 334 |
my $includelink = 0; |
| 335 |
|
| 336 |
my $onelink = ${$linklist}[$i]; |
| 337 |
|
| 338 |
my $shortcutid = ""; |
| 339 |
if ( $onelink->{'ShortcutID'} ) { $shortcutid = $onelink->{'ShortcutID'}; } |
| 340 |
|
| 341 |
if ( $shortcutid eq "" ) { next; } # A link with a ShortcutID |
| 342 |
|
| 343 |
for ( my $j = 0; $j <= $#newlinklist; $j++ ) # iterating over newly created link list |
| 344 |
{ |
| 345 |
my $onefilelink = $newlinklist[$j]; |
| 346 |
my $gid = $onefilelink->{'gid'}; |
| 347 |
|
| 348 |
if ( $gid eq $shortcutid ) |
| 349 |
{ |
| 350 |
$includelink = 1; |
| 351 |
last; |
| 352 |
} |
| 353 |
} |
| 354 |
|
| 355 |
if ( $includelink ) |
| 356 |
{ |
| 357 |
push(@newlinklist, $onelink); |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
return \@newlinklist; |
| 362 |
} |
| 363 |
|
| 364 |
##################################################################### |
| 365 |
# Analyzing all directories if they belong to a special package. |
| 366 |
# A package is described by a list of modules. |
| 367 |
# Directories are included into the package, if they are needed |
| 368 |
# by a file or a link included into the package. |
| 369 |
# Attention: A directory with the flag CREATE, is only included |
| 370 |
# into the root module: |
| 371 |
# ($packagename eq $installer::globals::rootmodulegid) |
| 372 |
##################################################################### |
| 373 |
|
| 374 |
sub find_dirs_for_package |
| 375 |
{ |
| 376 |
my ($dirlist, $onepackage) = @_; |
| 377 |
|
| 378 |
my @newdirlist = (); |
| 379 |
|
| 380 |
for ( my $i = 0; $i <= $#{$dirlist}; $i++ ) |
| 381 |
{ |
| 382 |
my $onedir = ${$dirlist}[$i]; |
| 383 |
my $modulesstring = $onedir->{'modules'}; # comma separated modules list |
| 384 |
my $moduleslist = installer::converter::convert_stringlist_into_array(\$modulesstring, ","); |
| 385 |
|
| 386 |
my $includedir = 0; |
| 387 |
|
| 388 |
# iterating over all modules of this dir |
| 389 |
|
| 390 |
for ( my $j = 0; $j <= $#{$moduleslist}; $j++ ) |
| 391 |
{ |
| 392 |
if ( $includedir ) { last; } |
| 393 |
my $dirmodule = ${$moduleslist}[$j]; |
| 394 |
installer::remover::remove_leading_and_ending_whitespaces(\$dirmodule); |
| 395 |
|
| 396 |
# iterating over all modules of the package |
| 397 |
|
| 398 |
my $packagemodules = $onepackage->{'allmodules'}; |
| 399 |
|
| 400 |
for ( my $k = 0; $k <= $#{$packagemodules}; $k++ ) |
| 401 |
{ |
| 402 |
my $packagemodule = ${$packagemodules}[$k]; |
| 403 |
|
| 404 |
if ( $dirmodule eq $packagemodule ) |
| 405 |
{ |
| 406 |
$includedir = 1; |
| 407 |
last; |
| 408 |
} |
| 409 |
} |
| 410 |
} |
| 411 |
|
| 412 |
if ( $includedir ) |
| 413 |
{ |
| 414 |
push(@newdirlist, $onedir); |
| 415 |
} |
| 416 |
} |
| 417 |
|
| 418 |
return \@newdirlist; |
| 419 |
} |
| 420 |
|
| 421 |
##################################################################### |
| 422 |
# Resolving all variables in the packagename. |
| 423 |
##################################################################### |
| 424 |
|
| 425 |
sub resolve_packagevariables |
| 426 |
{ |
| 427 |
my ($packagenameref, $variableshashref, $make_lowercase) = @_; |
| 428 |
|
| 429 |
my $key; |
| 430 |
|
| 431 |
# Special handling for dictionaries |
| 432 |
if ( $$packagenameref =~ /-dict-/ ) |
| 433 |
{ |
| 434 |
if (exists($variableshashref->{'DICTIONARYUNIXPRODUCTNAME'}) ) { $$packagenameref =~ s/\%UNIXPRODUCTNAME/$variableshashref->{'DICTIONARYUNIXPRODUCTNAME'}/g; } |
| 435 |
if (exists($variableshashref->{'DICTIONARYBRANDPACKAGEVERSION'}) ) { $$packagenameref =~ s/\%BRANDPACKAGEVERSION/$variableshashref->{'DICTIONARYBRANDPACKAGEVERSION'}/g; } |
| 436 |
} |
| 437 |
|
| 438 |
foreach $key (keys %{$variableshashref}) |
| 439 |
{ |
| 440 |
my $value = $variableshashref->{$key}; |
| 441 |
if ( $make_lowercase ) { $value = lc($value); } |
| 442 |
$$packagenameref =~ s/\%$key/$value/g; |
| 443 |
} |
| 444 |
} |
| 445 |
|
| 446 |
##################################################################### |
| 447 |
# Resolving all variables in the packagename. |
| 448 |
##################################################################### |
| 449 |
|
| 450 |
sub resolve_packagevariables2 |
| 451 |
{ |
| 452 |
my ($packagenameref, $variableshashref, $make_lowercase, $isdict ) = @_; |
| 453 |
|
| 454 |
my $key; |
| 455 |
|
| 456 |
# Special handling for dictionaries |
| 457 |
if ( $isdict ) |
| 458 |
{ |
| 459 |
if (exists($variableshashref->{'DICTIONARYUNIXPRODUCTNAME'}) ) { $$packagenameref =~ s/\%UNIXPRODUCTNAME/$variableshashref->{'DICTIONARYUNIXPRODUCTNAME'}/g; } |
| 460 |
if (exists($variableshashref->{'DICTIONARYBRANDPACKAGEVERSION'}) ) { $$packagenameref =~ s/\%BRANDPACKAGEVERSION/$variableshashref->{'DICTIONARYBRANDPACKAGEVERSION'}/g; } |
| 461 |
} |
| 462 |
|
| 463 |
foreach $key (keys %{$variableshashref}) |
| 464 |
{ |
| 465 |
my $value = $variableshashref->{$key}; |
| 466 |
if ( $make_lowercase ) { $value = lc($value); } |
| 467 |
$$packagenameref =~ s/\%$key/$value/g; |
| 468 |
} |
| 469 |
} |
| 470 |
|
| 471 |
##################################################################### |
| 472 |
# New packages system. |
| 473 |
##################################################################### |
| 474 |
|
| 475 |
################################################################## |
| 476 |
# Controlling the content of the packagelist |
| 477 |
# 1. Items in @installer::globals::packagelistitems must exist |
| 478 |
# 2. If a shellscript file is defined, it must exist |
| 479 |
################################################################## |
| 480 |
|
| 481 |
sub check_packagelist |
| 482 |
{ |
| 483 |
my ($packages) = @_; |
| 484 |
|
| 485 |
if ( ! ( $#{$packages} > -1 )) { installer::exiter::exit_program("ERROR: No packages defined!", "check_packagelist"); } |
| 486 |
|
| 487 |
for ( my $i = 0; $i <= $#{$packages}; $i++ ) |
| 488 |
{ |
| 489 |
my $onepackage = ${$packages}[$i]; |
| 490 |
|
| 491 |
my $element; |
| 492 |
|
| 493 |
# checking all items that must be defined |
| 494 |
|
| 495 |
foreach $element (@installer::globals::packagelistitems) |
| 496 |
{ |
| 497 |
if ( ! exists($onepackage->{$element}) ) |
| 498 |
{ |
| 499 |
installer::exiter::exit_program("ERROR in package list: No value for $element !", "check_packagelist"); |
| 500 |
} |
| 501 |
} |
| 502 |
|
| 503 |
# checking the existence of the script file, if defined |
| 504 |
|
| 505 |
if ( $onepackage->{'script'} ) |
| 506 |
{ |
| 507 |
my $scriptfile = $onepackage->{'script'}; |
| 508 |
my $gid = $onepackage->{'module'}; |
| 509 |
my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptfile, "" , 0); |
| 510 |
|
| 511 |
if ( $$fileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find script file $scriptfile for module $gid!", "check_packagelist"); } |
| 512 |
|
| 513 |
my $infoline = "$gid: Using script file: \"$$fileref\"!\n"; |
| 514 |
push( @installer::globals::logfileinfo, $infoline); |
| 515 |
|
| 516 |
$onepackage->{'script'} = $$fileref; |
| 517 |
} |
| 518 |
} |
| 519 |
} |
| 520 |
|
| 521 |
##################################################################### |
| 522 |
# Reading pack info for one module from packinfo file. |
| 523 |
##################################################################### |
| 524 |
|
| 525 |
sub get_packinfo |
| 526 |
{ |
| 527 |
my ($gid, $filename, $packages, $onelanguage, $islanguagemodule) = @_; |
| 528 |
|
| 529 |
my $packagelist = installer::files::read_file($filename); |
| 530 |
|
| 531 |
my @allpackages = (); |
| 532 |
|
| 533 |
for ( my $i = 0; $i <= $#{$packagelist}; $i++ ) |
| 534 |
{ |
| 535 |
my $line = ${$packagelist}[$i]; |
| 536 |
|
| 537 |
if ( $line =~ /^\s*\#/ ) { next; } # this is a comment line |
| 538 |
|
| 539 |
if ( $line =~ /^\s*Start\s*$/i ) # a new package definition |
| 540 |
{ |
| 541 |
my %onepackage = (); |
| 542 |
|
| 543 |
my $counter = $i + 1; |
| 544 |
|
| 545 |
while (!( ${$packagelist}[$counter] =~ /^\s*End\s*$/i )) |
| 546 |
{ |
| 547 |
if ( ${$packagelist}[$counter] =~ /^\s*(\S+)\s*\=\s*\"(.*)\"/ ) |
| 548 |
{ |
| 549 |
my $key = $1; |
| 550 |
my $value = $2; |
| 551 |
$onepackage{$key} = $value; |
| 552 |
} |
| 553 |
|
| 554 |
$counter++; |
| 555 |
} |
| 556 |
|
| 557 |
$onepackage{'islanguagemodule'} = $islanguagemodule; |
| 558 |
if ( $islanguagemodule ) |
| 559 |
{ |
| 560 |
my $saveonelanguage = $onelanguage; |
| 561 |
$saveonelanguage =~ s/_/-/g; |
| 562 |
$onepackage{'language'} = $saveonelanguage; |
| 563 |
} |
| 564 |
|
| 565 |
push(@allpackages, \%onepackage); |
| 566 |
} |
| 567 |
} |
| 568 |
|
| 569 |
# looking for the packinfo with the correct gid |
| 570 |
|
| 571 |
my $foundgid = 0; |
| 572 |
my $onepackage; |
| 573 |
foreach $onepackage (@allpackages) |
| 574 |
{ |
| 575 |
# Adding the language to the module gid for LanguagePacks ! |
| 576 |
# Making the module gid language specific: gid_Module_Root -> gir_Module_Root_pt_BR (as defined in scp2) |
| 577 |
if ( $onelanguage ne "" ) { $onepackage->{'module'} = $onepackage->{'module'} . "_$onelanguage"; } |
| 578 |
|
| 579 |
if ( $onepackage->{'module'} eq $gid ) |
| 580 |
{ |
| 581 |
# Resolving the language identifier |
| 582 |
my $onekey; |
| 583 |
foreach $onekey ( keys %{$onepackage} ) |
| 584 |
{ |
| 585 |
# Some keys require "-" instead of "_" for example in "en-US". All package names do not use underlines. |
| 586 |
my $locallang = $onelanguage; |
| 587 |
if (( $onekey eq "solarispackagename" ) || |
| 588 |
( $onekey eq "solarisrequires" ) || |
| 589 |
( $onekey eq "packagename" ) || |
| 590 |
( $onekey eq "requires" )) { $locallang =~ s/_/-/g; } # avoiding illegal package abbreviation |
| 591 |
$onepackage->{$onekey} =~ s/\%LANGUAGESTRING/$locallang/g; |
| 592 |
} |
| 593 |
|
| 594 |
# Saving the language for the package |
| 595 |
my $lang = $onelanguage; |
| 596 |
$lang =~ s/_/-/g; |
| 597 |
$onepackage->{'specificlanguage'} = $lang; |
| 598 |
|
| 599 |
push(@{$packages}, $onepackage); |
| 600 |
$foundgid = 1; |
| 601 |
last; |
| 602 |
} |
| 603 |
} |
| 604 |
|
| 605 |
if ( ! $foundgid ) |
| 606 |
{ |
| 607 |
installer::exiter::exit_program("ERROR: Could not find package info for module $gid in file \"$filename\"!", "get_packinfo"); |
| 608 |
} |
| 609 |
} |
| 610 |
|
| 611 |
##################################################################### |
| 612 |
# Collecting all packages from scp project. |
| 613 |
##################################################################### |
| 614 |
|
| 615 |
sub collectpackages |
| 616 |
{ |
| 617 |
my ( $allmodules, $languagesarrayref ) = @_; |
| 618 |
|
| 619 |
installer::logger::include_header_into_logfile("Collecting packages:"); |
| 620 |
|
| 621 |
my @packages = (); |
| 622 |
my %gid_analyzed = (); |
| 623 |
|
| 624 |
my $onemodule; |
| 625 |
foreach $onemodule ( @{$allmodules} ) |
| 626 |
{ |
| 627 |
if ( $onemodule->{'PackageInfo'} ) # this is a package module! |
| 628 |
{ |
| 629 |
my $modulegid = $onemodule->{'gid'}; |
| 630 |
|
| 631 |
my $styles = ""; |
| 632 |
if ( $onemodule->{'Styles'} ) { $styles = $onemodule->{'Styles'}; } |
| 633 |
|
| 634 |
# checking modules with style LANGUAGEMODULE |
| 635 |
my $islanguagemodule = 0; |
| 636 |
my $onelanguage = ""; |
| 637 |
if ( $styles =~ /\bLANGUAGEMODULE\b/ ) |
| 638 |
{ |
| 639 |
$islanguagemodule = 1; |
| 640 |
$onelanguage = $onemodule->{'Language'}; # already checked, that it is set. |
| 641 |
$onelanguage =~ s/-/_/g; # pt-BR -> pt_BR in scp |
| 642 |
} |
| 643 |
|
| 644 |
# Modules in different languages are listed more than once in multilingual installation sets |
| 645 |
if ( exists($gid_analyzed{$modulegid}) ) { next; } |
| 646 |
$gid_analyzed{$modulegid} = 1; |
| 647 |
|
| 648 |
my $packinfofile = $onemodule->{'PackageInfo'}; |
| 649 |
|
| 650 |
# The file with package information has to be found in path list |
| 651 |
my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packinfofile, "" , 0); |
| 652 |
|
| 653 |
if ( $$fileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find file $packinfofile for module $modulegid!", "collectpackages"); } |
| 654 |
|
| 655 |
my $infoline = "$modulegid: Using packinfo: \"$$fileref\"!\n"; |
| 656 |
push( @installer::globals::logfileinfo, $infoline); |
| 657 |
|
| 658 |
get_packinfo($modulegid, $$fileref, \@packages, $onelanguage, $islanguagemodule); |
| 659 |
} |
| 660 |
} |
| 661 |
|
| 662 |
return \@packages; |
| 663 |
} |
| 664 |
|
| 665 |
##################################################################### |
| 666 |
# Printing packages content for debugging purposes |
| 667 |
##################################################################### |
| 668 |
|
| 669 |
sub log_packages_content |
| 670 |
{ |
| 671 |
my ($packages) = @_; |
| 672 |
|
| 673 |
if ( ! ( $#{$packages} > -1 )) { installer::exiter::exit_program("ERROR: No packages defined!", "print_content"); } |
| 674 |
|
| 675 |
installer::logger::include_header_into_logfile("Logging packages content:"); |
| 676 |
|
| 677 |
my $infoline = ""; |
| 678 |
|
| 679 |
for ( my $i = 0; $i <= $#{$packages}; $i++ ) |
| 680 |
{ |
| 681 |
my $onepackage = ${$packages}[$i]; |
| 682 |
|
| 683 |
# checking all items that must be defined |
| 684 |
|
| 685 |
$infoline = "Package $onepackage->{'module'}\n"; |
| 686 |
push(@installer::globals::logfileinfo, $infoline); |
| 687 |
|
| 688 |
my $key; |
| 689 |
foreach $key (sort keys %{$onepackage}) |
| 690 |
{ |
| 691 |
if ( $key =~ /^\s*\;/ ) { next; } |
| 692 |
|
| 693 |
if ( $key eq "allmodules" ) |
| 694 |
{ |
| 695 |
$infoline = "\t$key:\n"; |
| 696 |
push(@installer::globals::logfileinfo, $infoline); |
| 697 |
my $onemodule; |
| 698 |
foreach $onemodule ( @{$onepackage->{$key}} ) |
| 699 |
{ |
| 700 |
$infoline = "\t\t$onemodule\n"; |
| 701 |
push(@installer::globals::logfileinfo, $infoline); |
| 702 |
} |
| 703 |
} |
| 704 |
else |
| 705 |
{ |
| 706 |
$infoline = "\t$key: $onepackage->{$key}\n"; |
| 707 |
push(@installer::globals::logfileinfo, $infoline); |
| 708 |
} |
| 709 |
} |
| 710 |
|
| 711 |
$infoline = "\n"; |
| 712 |
push(@installer::globals::logfileinfo, $infoline); |
| 713 |
|
| 714 |
} |
| 715 |
} |
| 716 |
|
| 717 |
##################################################################### |
| 718 |
# Creating assignments from modules to destination paths. |
| 719 |
# This is required for logging in fileinfo file. Otherwise |
| 720 |
# the complete destination file would not be known in file list. |
| 721 |
# Saved in %installer::globals::moduledestination |
| 722 |
##################################################################### |
| 723 |
|
| 724 |
sub create_module_destination_hash |
| 725 |
{ |
| 726 |
my ($packages, $allvariables) = @_; |
| 727 |
|
| 728 |
for ( my $i = 0; $i <= $#{$packages}; $i++ ) |
| 729 |
{ |
| 730 |
my $onepackage = ${$packages}[$i]; |
| 731 |
|
| 732 |
my $defaultdestination = $onepackage->{'destpath'}; |
| 733 |
resolve_packagevariables(\$defaultdestination, $allvariables, 1); |
| 734 |
if ( $^O =~ /darwin/i ) { $defaultdestination =~ s/\/opt\//\/Applications\//; } |
| 735 |
|
| 736 |
foreach my $onemodule ( @{$onepackage->{'allmodules'}} ) |
| 737 |
{ |
| 738 |
$installer::globals::moduledestination{$onemodule} = $defaultdestination; |
| 739 |
} |
| 740 |
} |
| 741 |
} |
| 742 |
|
| 743 |
##################################################################### |
| 744 |
# Adding the default paths into the files collector for Unixes. |
| 745 |
# This is necessary to know the complete destination path in |
| 746 |
# fileinfo log file. |
| 747 |
##################################################################### |
| 748 |
|
| 749 |
sub add_defaultpaths_into_filescollector |
| 750 |
{ |
| 751 |
my ($allfiles) = @_; |
| 752 |
|
| 753 |
for ( my $i = 0; $i <= $#{$allfiles}; $i++ ) |
| 754 |
{ |
| 755 |
my $onefile = ${$allfiles}[$i]; |
| 756 |
|
| 757 |
if ( ! $onefile->{'destination'} ) { installer::exiter::exit_program("ERROR: No destination found at file $onefile->{'gid'}!", "add_defaultpaths_into_filescollector"); } |
| 758 |
my $destination = $onefile->{'destination'}; |
| 759 |
|
| 760 |
if ( ! $onefile->{'modules'} ) { installer::exiter::exit_program("ERROR: No modules found at file $onefile->{'gid'}!", "add_defaultpaths_into_filescollector"); } |
| 761 |
my $module = $onefile->{'modules'}; |
| 762 |
# If modules contains a list of modules, only taking the first one. |
| 763 |
if ( $module =~ /^\s*(.*?)\,/ ) { $module = $1; } |
| 764 |
|
| 765 |
if ( ! exists($installer::globals::moduledestination{$module}) ) { installer::exiter::exit_program("ERROR: No default destination path found for module $module!", "add_defaultpaths_into_filescollector"); } |
| 766 |
my $defaultpath = $installer::globals::moduledestination{$module}; |
| 767 |
$defaultpath =~ s/\/\s*$//; # removing ending slashes |
| 768 |
my $fulldestpath = $defaultpath . $installer::globals::separator . $destination; |
| 769 |
|
| 770 |
$onefile->{'fulldestpath'} = $fulldestpath; |
| 771 |
} |
| 772 |
} |
| 773 |
|
| 774 |
##################################################################### |
| 775 |
# Creating list of cabinet files from packages |
| 776 |
##################################################################### |
| 777 |
|
| 778 |
sub prepare_cabinet_files |
| 779 |
{ |
| 780 |
my ($packages, $allvariables) = @_; |
| 781 |
|
| 782 |
if ( ! ( $#{$packages} > -1 )) { installer::exiter::exit_program("ERROR: No packages defined!", "print_content"); } |
| 783 |
|
| 784 |
installer::logger::include_header_into_logfile("Preparing cabinet files:"); |
| 785 |
|
| 786 |
my $infoline = ""; |
| 787 |
|
| 788 |
for ( my $i = 0; $i <= $#{$packages}; $i++ ) |
| 789 |
{ |
| 790 |
my $onepackage = ${$packages}[$i]; |
| 791 |
|
| 792 |
my $cabinetfile = "$onepackage->{'packagename'}\.cab"; |
| 793 |
|
| 794 |
resolve_packagevariables(\$cabinetfile, $allvariables, 0); |
| 795 |
|
| 796 |
$installer::globals::allcabinets{$cabinetfile} = 1; |
| 797 |
|
| 798 |
# checking all items that must be defined |
| 799 |
|
| 800 |
$infoline = "Package $onepackage->{'module'}\n"; |
| 801 |
push(@installer::globals::logfileinfo, $infoline); |
| 802 |
|
| 803 |
# Assigning the cab file to the module and also to all corresponding sub modules |
| 804 |
|
| 805 |
my $onemodule; |
| 806 |
foreach $onemodule ( @{$onepackage->{'allmodules'}} ) |
| 807 |
{ |
| 808 |
if ( ! exists($installer::globals::allcabinetassigns{$onemodule}) ) |
| 809 |
{ |
| 810 |
$installer::globals::allcabinetassigns{$onemodule} = $cabinetfile; |
| 811 |
} |
| 812 |
else |
| 813 |
{ |
| 814 |
my $infoline = "Warning: Already existing assignment: $onemodule : $installer::globals::allcabinetassigns{$onemodule}\n"; |
| 815 |
push(@installer::globals::logfileinfo, $infoline); |
| 816 |
$infoline = "Ignoring further assignment: $onemodule : $cabinetfile\n"; |
| 817 |
push(@installer::globals::logfileinfo, $infoline); |
| 818 |
} |
| 819 |
} |
| 820 |
} |
| 821 |
} |
| 822 |
|
| 823 |
##################################################################### |
| 824 |
# Logging assignments of cabinet files |
| 825 |
##################################################################### |
| 826 |
|
| 827 |
sub log_cabinet_assignments |
| 828 |
{ |
| 829 |
installer::logger::include_header_into_logfile("Logging cabinet files:"); |
| 830 |
|
| 831 |
my $infoline = "List of cabinet files:\n"; |
| 832 |
push(@installer::globals::logfileinfo, $infoline); |
| 833 |
|
| 834 |
my $key; |
| 835 |
foreach $key ( sort keys %installer::globals::allcabinets ) { push(@installer::globals::logfileinfo, "\t$key\n"); } |
| 836 |
|
| 837 |
$infoline = "\nList of assignments from modules to cabinet files:\n"; |
| 838 |
push(@installer::globals::logfileinfo, $infoline); |
| 839 |
|
| 840 |
foreach $key ( sort keys %installer::globals::allcabinetassigns ) { push(@installer::globals::logfileinfo, "\t$key : $installer::globals::allcabinetassigns{$key}\n"); } |
| 841 |
} |
| 842 |
|
| 843 |
1; |