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