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 $installer::logger::Lang->printf("%s: Using script file: \"%s\"!\n", $gid, $$fileref); 531 532 $onepackage->{'script'} = $$fileref; 533 } 534 } 535} 536 537##################################################################### 538# Reading pack info for one module from packinfo file. 539##################################################################### 540 541sub get_packinfo 542{ 543 my ($gid, $filename, $packages, $onelanguage, $islanguagemodule) = @_; 544 545 my $packagelist = installer::files::read_file($filename); 546 547 my @allpackages = (); 548 549 for ( my $i = 0; $i <= $#{$packagelist}; $i++ ) 550 { 551 my $line = ${$packagelist}[$i]; 552 553 if ( $line =~ /^\s*\#/ ) { next; } # this is a comment line 554 555 if ( $line =~ /^\s*Start\s*$/i ) # a new package definition 556 { 557 my %onepackage = (); 558 559 my $counter = $i + 1; 560 561 while (!( ${$packagelist}[$counter] =~ /^\s*End\s*$/i )) 562 { 563 if ( ${$packagelist}[$counter] =~ /^\s*(\S+)\s*\=\s*\"(.*)\"/ ) 564 { 565 my $key = $1; 566 my $value = $2; 567 $onepackage{$key} = $value; 568 } 569 570 $counter++; 571 } 572 573 $onepackage{'islanguagemodule'} = $islanguagemodule; 574 if ( $islanguagemodule ) 575 { 576 $saveonelanguage = $onelanguage; 577 $saveonelanguage =~ s/_/-/g; 578 $onepackage{'language'} = $saveonelanguage; 579 } 580 581 push(@allpackages, \%onepackage); 582 } 583 } 584 585 # looking for the packinfo with the correct gid 586 587 my $foundgid = 0; 588 my $onepackage; 589 foreach $onepackage (@allpackages) 590 { 591 # Adding the language to the module gid for LanguagePacks ! 592 # Making the module gid language specific: gid_Module_Root -> gir_Module_Root_pt_BR (as defined in scp2) 593 if ( $onelanguage ne "" ) { $onepackage->{'module'} = $onepackage->{'module'} . "_$onelanguage"; } 594 595 if ( $onepackage->{'module'} eq $gid ) 596 { 597 # Resolving the language identifier 598 my $onekey; 599 foreach $onekey ( keys %{$onepackage} ) 600 { 601 # Some keys require "-" instead of "_" for example in "en-US". All package names do not use underlines. 602 my $locallang = $onelanguage; 603 if (( $onekey eq "solarispackagename" ) || 604 ( $onekey eq "solarisrequires" ) || 605 ( $onekey eq "packagename" ) || 606 ( $onekey eq "linuxreplaces" ) || 607 ( $onekey eq "provides" ) || 608 ( $onekey eq "requires" )) { $locallang =~ s/_/-/g; } # avoiding illegal package abbreviation 609 $onepackage->{$onekey} =~ s/\%LANGUAGESTRING/$locallang/g; 610 } 611 612 # Saving the language for the package 613 my $lang = $onelanguage; 614 $lang =~ s/_/-/g; 615 $onepackage->{'specificlanguage'} = $lang; 616 617 push(@{$packages}, $onepackage); 618 $foundgid = 1; 619 last; 620 } 621 } 622 623 if ( ! $foundgid ) 624 { 625 installer::exiter::exit_program("ERROR: Could not find package info for module $gid in file \"$filename\"!", "get_packinfo"); 626 } 627} 628 629##################################################################### 630# Collecting all packages from scp project. 631##################################################################### 632 633sub collectpackages 634{ 635 my ( $allmodules, $languagesarrayref ) = @_; 636 637 installer::logger::include_header_into_logfile("Collecting packages:"); 638 639 my @packages = (); 640 my %gid_analyzed = (); 641 642 my $onemodule; 643 foreach $onemodule ( @{$allmodules} ) 644 { 645 my $packageinfo = "PackageInfo"; 646 if (( $installer::globals::tab ) && ( $onemodule->{"TabPackageInfo"} )) { $packageinfo = "TabPackageInfo" } 647 648 if ( $onemodule->{$packageinfo} ) # this is a package module! 649 { 650 my $modulegid = $onemodule->{'gid'}; 651 652 # Only collecting modules with correct language for language packs 653# if ( $installer::globals::languagepack ) { if ( ! ( $modulegid =~ /_$onelanguage\s*$/ )) { next; } } 654 # Resetting language, if this is no language pack 655# if ( ! $installer::globals::languagepack ) { $onelanguage = ""; } 656 657 my $styles = ""; 658 if ( $onemodule->{'Styles'} ) { $styles = $onemodule->{'Styles'}; } 659 660 # checking modules with style LANGUAGEMODULE 661 my $islanguagemodule = 0; 662 my $onelanguage = ""; 663 if ( $styles =~ /\bLANGUAGEMODULE\b/ ) 664 { 665 $islanguagemodule = 1; 666 $onelanguage = $onemodule->{'Language'}; # already checked, that it is set. 667 $onelanguage =~ s/-/_/g; # pt-BR -> pt_BR in scp 668 } 669 670 # Modules in different languages are listed more than once in multilingual installation sets 671 if ( exists($gid_analyzed{$modulegid}) ) { next; } 672 $gid_analyzed{$modulegid} = 1; 673 674 my $packinfofile = $onemodule->{$packageinfo}; 675 676 # The file with package information has to be found in path list 677 my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packinfofile, "" , 0); 678 679 if ( $$fileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find file $packinfofile for module $modulegid!", "collectpackages"); } 680 681 $installer::logger::Lang->printf("%s: Using packinfo: \"%s\"!\n", $modulegid, $$fileref); 682 683 get_packinfo($modulegid, $$fileref, \@packages, $onelanguage, $islanguagemodule); 684 } 685 } 686 687 return \@packages; 688} 689 690##################################################################### 691# Printing packages content for debugging purposes 692##################################################################### 693 694sub log_packages_content 695{ 696 my ($packages) = @_; 697 698 if ( ! ( $#{$packages} > -1 )) { installer::exiter::exit_program("ERROR: No packages defined!", "print_content"); } 699 700 installer::logger::include_header_into_logfile("Logging packages content:"); 701 702 my $infoline = ""; 703 704 for ( my $i = 0; $i <= $#{$packages}; $i++ ) 705 { 706 my $onepackage = ${$packages}[$i]; 707 708 # checking all items that must be defined 709 710 $installer::logger::Lang->printf("Package %s\n", $onepackage->{'module'}); 711 712 my $key; 713 foreach $key (sort keys %{$onepackage}) 714 { 715 if ( $key =~ /^\s*\;/ ) { next; } 716 717 if ( $key eq "allmodules" ) 718 { 719 $installer::logger::Lang->printf("\t%s:\n", $key); 720 my $onemodule; 721 foreach $onemodule ( @{$onepackage->{$key}} ) 722 { 723 $installer::logger::Lang->printf("\t\t%s\n", $onemodule); 724 } 725 } 726 else 727 { 728 $installer::logger::Lang->printf("\t%s: %s\n", $key, $onepackage->{$key}); 729 } 730 } 731 732 $installer::logger::Lang->printf("\n"); 733 734 } 735} 736 737##################################################################### 738# Creating assignments from modules to destination pathes. 739# This is required for logging in fileinfo file. Otherwise 740# the complete destination file would not be known in file list. 741# Saved in %installer::globals::moduledestination 742##################################################################### 743 744sub create_module_destination_hash 745{ 746 my ($packages, $allvariables) = @_; 747 748 for ( my $i = 0; $i <= $#{$packages}; $i++ ) 749 { 750 my $onepackage = ${$packages}[$i]; 751 752 my $defaultdestination = $onepackage->{'destpath'}; 753 resolve_packagevariables(\$defaultdestination, $allvariables, 1); 754 if ( $^O =~ /darwin/i ) { $defaultdestination =~ s/\/opt\//\/Applications\//; } 755 756 foreach my $onemodule ( @{$onepackage->{'allmodules'}} ) 757 { 758 $installer::globals::moduledestination{$onemodule} = $defaultdestination; 759 } 760 } 761} 762 763##################################################################### 764# Adding the default pathes into the files collector for Unixes. 765# This is necessary to know the complete destination path in 766# fileinfo log file. 767##################################################################### 768 769sub add_defaultpathes_into_filescollector 770{ 771 my ($allfiles) = @_; 772 773 for ( my $i = 0; $i <= $#{$allfiles}; $i++ ) 774 { 775 my $onefile = ${$allfiles}[$i]; 776 777 if ( ! $onefile->{'destination'} ) { installer::exiter::exit_program("ERROR: No destination found at file $onefile->{'gid'}!", "add_defaultpathes_into_filescollector"); } 778 my $destination = $onefile->{'destination'}; 779 780 if ( ! $onefile->{'modules'} ) { installer::exiter::exit_program("ERROR: No modules found at file $onefile->{'gid'}!", "add_defaultpathes_into_filescollector"); } 781 my $module = $onefile->{'modules'}; 782 # If modules contains a list of modules, only taking the first one. 783 if ( $module =~ /^\s*(.*?)\,/ ) { $module = $1; } 784 785 if ( ! exists($installer::globals::moduledestination{$module}) ) { installer::exiter::exit_program("ERROR: No default destination path found for module $module!", "add_defaultpathes_into_filescollector"); } 786 my $defaultpath = $installer::globals::moduledestination{$module}; 787 $defaultpath =~ s/\/\s*$//; # removing ending slashes 788 my $fulldestpath = $defaultpath . $installer::globals::separator . $destination; 789 790 $onefile->{'fulldestpath'} = $fulldestpath; 791 } 792} 793 794##################################################################### 795# Creating list of cabinet files from packages 796##################################################################### 797 798sub prepare_cabinet_files 799{ 800 my ($packages, $allvariables) = @_; 801 802 if ( ! ( $#{$packages} > -1 )) { installer::exiter::exit_program("ERROR: No packages defined!", "print_content"); } 803 804 installer::logger::include_header_into_logfile("Preparing cabinet files:"); 805 806 my $infoline = ""; 807 808 for ( my $i = 0; $i <= $#{$packages}; $i++ ) 809 { 810 my $onepackage = ${$packages}[$i]; 811 812 my $cabinetfile = "$onepackage->{'packagename'}\.cab"; 813 814 resolve_packagevariables(\$cabinetfile, $allvariables, 0); 815 816 $installer::globals::allcabinets{$cabinetfile} = 1; 817 818 # checking all items that must be defined 819 820 $installer::logger::Lang->printf("Package %s\n", $onepackage->{'module'}); 821 822 # Assigning the cab file to the module and also to all corresponding sub modules 823 824 my $onemodule; 825 foreach $onemodule ( @{$onepackage->{'allmodules'}} ) 826 { 827 if ( ! exists($installer::globals::allcabinetassigns{$onemodule}) ) 828 { 829 $installer::globals::allcabinetassigns{$onemodule} = $cabinetfile; 830 } 831 else 832 { 833 $installer::logger::Lang->printf("Warning: Already existing assignment: %s : %s\n", 834 $onemodule, 835 $installer::globals::allcabinetassigns{$onemodule}); 836 $installer::logger::Lang->printf("Ignoring further assignment: %s : %s\n", 837 $onemodule, 838 $cabinetfile); 839 } 840 } 841 } 842} 843 844##################################################################### 845# Logging assignments of cabinet files 846##################################################################### 847 848sub log_cabinet_assignments 849{ 850 installer::logger::include_header_into_logfile("Logging cabinet files:"); 851 852 $installer::logger::Lang->printf("List of cabinet files:\n"); 853 854 my $key; 855 foreach $key ( sort keys %installer::globals::allcabinets ) 856 { 857 $installer::logger::Lang->printf("\t%s\n", $key); 858 } 859 860 $installer::logger::Lang->printf("\n"); 861 $installer::logger::Lang->printf("List of assignments from modules to cabinet files:\n"); 862 863 foreach $key ( sort keys %installer::globals::allcabinetassigns ) 864 { 865 $installer::logger::Lang->printf("\t%s : %s\n", 866 $key, 867 $installer::globals::allcabinetassigns{$key}); 868 } 869} 870 8711; 872