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