| 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::scriptitems; |
| 20 |
|
| 21 |
use strict; |
| 22 |
no strict 'refs'; |
| 23 |
use warnings; |
| 24 |
|
| 25 |
use installer::converter; |
| 26 |
use installer::exiter; |
| 27 |
use installer::globals; |
| 28 |
use installer::languages; |
| 29 |
use installer::logger; |
| 30 |
use installer::pathanalyzer; |
| 31 |
use installer::remover; |
| 32 |
use installer::systemactions; |
| 33 |
|
| 34 |
################################################################ |
| 35 |
# Resolving the GID for the directories defined in setup script |
| 36 |
################################################################ |
| 37 |
|
| 38 |
sub resolve_all_directory_names |
| 39 |
{ |
| 40 |
my ($directoryarrayref) = @_; |
| 41 |
|
| 42 |
# After this procedure the hash shall contain the complete language |
| 43 |
# dependent path, not only the language dependent HostName. |
| 44 |
|
| 45 |
my ($key, $value, $parentvalue, $parentgid, $parentdirectoryhashref); |
| 46 |
|
| 47 |
for ( my $i = 0; $i <= $#{$directoryarrayref}; $i++ ) |
| 48 |
{ |
| 49 |
my $directoryhashref = ${$directoryarrayref}[$i]; |
| 50 |
my $gid = $directoryhashref-> {'gid'}; |
| 51 |
my $parentid = $directoryhashref-> {'ParentID'}; |
| 52 |
|
| 53 |
if ( $parentid ne "PREDEFINED_PROGDIR" ) |
| 54 |
{ |
| 55 |
# find the array of the parentid, which has to be defined before in setup script |
| 56 |
# and is therefore listed before in this array |
| 57 |
|
| 58 |
for ( my $j = 0; $j <= $i; $j++ ) |
| 59 |
{ |
| 60 |
$parentdirectoryhashref = ${$directoryarrayref}[$j]; |
| 61 |
$parentgid = $parentdirectoryhashref->{'gid'}; |
| 62 |
|
| 63 |
if ( $parentid eq $parentgid) |
| 64 |
{ |
| 65 |
last; |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
# and now we can put the path together |
| 70 |
# But take care of the languages! |
| 71 |
|
| 72 |
my $dirismultilingual = $directoryhashref->{'ismultilingual'}; |
| 73 |
my $parentismultilingual = $parentdirectoryhashref->{'ismultilingual'}; |
| 74 |
|
| 75 |
# First: Both directories are language independent or both directories are language dependent |
| 76 |
|
| 77 |
if ((( ! $dirismultilingual ) && ( ! $parentismultilingual )) || |
| 78 |
(( $dirismultilingual ) && ( $parentismultilingual ))) |
| 79 |
{ |
| 80 |
foreach $key (keys %{$directoryhashref}) |
| 81 |
{ |
| 82 |
# the key ("HostName (en-US)") must be usable for both hashes |
| 83 |
|
| 84 |
if ( $key =~ /\bHostName\b/ ) |
| 85 |
{ |
| 86 |
$parentvalue = ""; |
| 87 |
$value = $directoryhashref->{$key}; |
| 88 |
if ( $parentdirectoryhashref->{$key} ) { $parentvalue = $parentdirectoryhashref->{$key}; } |
| 89 |
|
| 90 |
# It is possible, that in scp project, a directory is defined in more languages than |
| 91 |
# the directory parent (happened after automatic generation of macros.inc). |
| 92 |
# Therefore this is checked now and written with a warning into the logfile. |
| 93 |
# This is no error, because (in most cases) the concerned language is not build. |
| 94 |
|
| 95 |
if ($parentvalue eq "") |
| 96 |
{ |
| 97 |
$directoryhashref->{$key} = "FAILURE"; |
| 98 |
my $infoline = "WARNING: No hostname for $parentid with \"$key\". Needed by child directory $gid !\n"; |
| 99 |
push( @installer::globals::globallogfileinfo, $infoline); |
| 100 |
} |
| 101 |
else |
| 102 |
{ |
| 103 |
$directoryhashref->{$key} = $parentvalue . $installer::globals::separator . $value; |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
# Second: The directory is language dependent, the parent not |
| 110 |
|
| 111 |
if (( $dirismultilingual ) && ( ! $parentismultilingual )) |
| 112 |
{ |
| 113 |
$parentvalue = $parentdirectoryhashref->{'HostName'}; # there is only one |
| 114 |
|
| 115 |
foreach $key (keys %{$directoryhashref}) # the current directory |
| 116 |
{ |
| 117 |
if ( $key =~ /\bHostName\b/ ) |
| 118 |
{ |
| 119 |
$value = $directoryhashref->{$key}; |
| 120 |
$directoryhashref->{$key} = $parentvalue . $installer::globals::separator . $value; |
| 121 |
} |
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
# Third: The directory is not language dependent, the parent is language dependent |
| 126 |
|
| 127 |
if (( ! $dirismultilingual ) && ( $parentismultilingual )) |
| 128 |
{ |
| 129 |
$value = $directoryhashref->{'HostName'}; # there is only one |
| 130 |
delete($directoryhashref->{'HostName'}); |
| 131 |
|
| 132 |
foreach $key (keys %{$parentdirectoryhashref}) # the parent directory |
| 133 |
{ |
| 134 |
if ( $key =~ /\bHostName\b/ ) |
| 135 |
{ |
| 136 |
$parentvalue = $parentdirectoryhashref->{$key}; # there is only one |
| 137 |
$directoryhashref->{$key} = $parentvalue . $installer::globals::separator . $value; |
| 138 |
} |
| 139 |
} |
| 140 |
|
| 141 |
$directoryhashref->{'ismultilingual'} = 1; # now this directory is also language dependent |
| 142 |
} |
| 143 |
} |
| 144 |
} |
| 145 |
} |
| 146 |
|
| 147 |
############################################################################# |
| 148 |
# Registryitems for Uninstall have to be removed |
| 149 |
############################################################################# |
| 150 |
|
| 151 |
sub remove_uninstall_regitems_from_script |
| 152 |
{ |
| 153 |
my ($registryarrayref) = @_; |
| 154 |
|
| 155 |
my @newitems = (); |
| 156 |
|
| 157 |
for ( my $i = 0; $i <= $#{$registryarrayref}; $i++ ) |
| 158 |
{ |
| 159 |
my $oneitem = ${$registryarrayref}[$i]; |
| 160 |
my $subkey = ""; |
| 161 |
|
| 162 |
if ( $oneitem->{'Subkey'} ) { $subkey = $oneitem->{'Subkey'}; } |
| 163 |
|
| 164 |
if ( $subkey =~ /Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall/ ) { next; } |
| 165 |
|
| 166 |
push(@newitems, $oneitem); |
| 167 |
} |
| 168 |
|
| 169 |
return \@newitems; |
| 170 |
} |
| 171 |
|
| 172 |
############################################################################## |
| 173 |
# Searching the language module for a specified language |
| 174 |
############################################################################## |
| 175 |
|
| 176 |
sub get_languagespecific_module |
| 177 |
{ |
| 178 |
my ( $lang, $modulestring ) = @_; |
| 179 |
|
| 180 |
my $langmodulestring = ""; |
| 181 |
|
| 182 |
my $module; |
| 183 |
foreach $module ( keys %installer::globals::alllangmodules ) |
| 184 |
{ |
| 185 |
if (( $installer::globals::alllangmodules{$module} eq $lang ) && ( $modulestring =~ /\b$module\b/ )) |
| 186 |
{ |
| 187 |
$langmodulestring = "$langmodulestring,$module"; |
| 188 |
} |
| 189 |
} |
| 190 |
|
| 191 |
$langmodulestring =~ s/^\s*,//; |
| 192 |
|
| 193 |
if ( $langmodulestring eq "" ) { installer::exiter::exit_program("ERROR: No language pack module found for language $lang in string \"$modulestring\"!", "get_languagespecific_module"); } |
| 194 |
|
| 195 |
return $langmodulestring; |
| 196 |
} |
| 197 |
|
| 198 |
############################################################################## |
| 199 |
# Removing all items in product lists which do not have the correct languages |
| 200 |
############################################################################## |
| 201 |
|
| 202 |
sub resolving_all_languages_in_productlists |
| 203 |
{ |
| 204 |
my ($productarrayref, $languagesarrayref) = @_; |
| 205 |
|
| 206 |
my @itemsinalllanguages = (); |
| 207 |
|
| 208 |
my ($key, $value); |
| 209 |
|
| 210 |
for ( my $i = 0; $i <= $#{$productarrayref}; $i++ ) |
| 211 |
{ |
| 212 |
my $oneitem = ${$productarrayref}[$i]; |
| 213 |
|
| 214 |
my $ismultilingual = $oneitem->{'ismultilingual'}; |
| 215 |
|
| 216 |
if (!($ismultilingual)) # nothing to do with single language items |
| 217 |
{ |
| 218 |
$oneitem->{'specificlanguage'} = ""; |
| 219 |
push(@itemsinalllanguages, $oneitem); |
| 220 |
} |
| 221 |
else #all language dependent files |
| 222 |
{ |
| 223 |
for ( my $j = 0; $j <= $#{$languagesarrayref}; $j++ ) # iterating over all languages |
| 224 |
{ |
| 225 |
my $onelanguage = ${$languagesarrayref}[$j]; |
| 226 |
|
| 227 |
my %oneitemhash = (); |
| 228 |
|
| 229 |
foreach $key (keys %{$oneitem}) |
| 230 |
{ |
| 231 |
if ( $key =~ /\(\S+\)/ ) # this are the language dependent keys |
| 232 |
{ |
| 233 |
if ( $key =~ /\(\Q$onelanguage\E\)/ ) |
| 234 |
{ |
| 235 |
$value = $oneitem->{$key}; |
| 236 |
$oneitemhash{$key} = $value; |
| 237 |
} |
| 238 |
} |
| 239 |
else |
| 240 |
{ |
| 241 |
$value = $oneitem->{$key}; |
| 242 |
$oneitemhash{$key} = $value; |
| 243 |
} |
| 244 |
} |
| 245 |
|
| 246 |
$oneitemhash{'specificlanguage'} = $onelanguage; |
| 247 |
|
| 248 |
if ( $oneitemhash{'haslanguagemodule'} ) |
| 249 |
{ |
| 250 |
my $langmodulestring = get_languagespecific_module($onelanguage, $oneitemhash{'modules'}); |
| 251 |
$oneitemhash{'modules'} = $langmodulestring; |
| 252 |
} |
| 253 |
|
| 254 |
push(@itemsinalllanguages, \%oneitemhash); |
| 255 |
} |
| 256 |
} |
| 257 |
} |
| 258 |
|
| 259 |
return \@itemsinalllanguages; |
| 260 |
} |
| 261 |
|
| 262 |
################################################################################ |
| 263 |
# Removing all modules, that have the flag LANGUAGEMODULE, but do not |
| 264 |
# have the correct language |
| 265 |
################################################################################ |
| 266 |
|
| 267 |
sub remove_not_required_language_modules |
| 268 |
{ |
| 269 |
my ($modulesarrayref, $languagesarrayref) = @_; |
| 270 |
|
| 271 |
my @allmodules = (); |
| 272 |
|
| 273 |
for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ ) |
| 274 |
{ |
| 275 |
my $module = ${$modulesarrayref}[$i]; |
| 276 |
my $styles = ""; |
| 277 |
if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; } |
| 278 |
|
| 279 |
if ( $styles =~ /\bLANGUAGEMODULE\b/ ) |
| 280 |
{ |
| 281 |
if ( ! exists($module->{'Language'}) ) { installer::exiter::exit_program("ERROR: \"$module->{'gid'}\" has flag LANGUAGEMODULE, but does not know its language!", "remove_not_required_language_modules"); } |
| 282 |
my $modulelanguage = $module->{'Language'}; |
| 283 |
# checking, if language is required |
| 284 |
my $doinclude = 0; |
| 285 |
for ( my $j = 0; $j <= $#{$languagesarrayref}; $j++ ) |
| 286 |
{ |
| 287 |
my $onelanguage = ${$languagesarrayref}[$j]; |
| 288 |
if ( $onelanguage eq $modulelanguage ) |
| 289 |
{ |
| 290 |
$doinclude = 1; |
| 291 |
last; |
| 292 |
} |
| 293 |
} |
| 294 |
|
| 295 |
if ( $doinclude ) { push(@allmodules, $module); } |
| 296 |
} |
| 297 |
else |
| 298 |
{ |
| 299 |
push(@allmodules, $module); |
| 300 |
} |
| 301 |
} |
| 302 |
|
| 303 |
return \@allmodules; |
| 304 |
} |
| 305 |
|
| 306 |
################################################################################ |
| 307 |
# Removing all modules, that have a spellchecker language that is not |
| 308 |
# required for this product (spellchecker selection). |
| 309 |
# All required spellchecker languages are stored in |
| 310 |
# %installer::globals::spellcheckerlanguagehash |
| 311 |
################################################################################ |
| 312 |
|
| 313 |
sub remove_not_required_spellcheckerlanguage_modules |
| 314 |
{ |
| 315 |
my ($modulesarrayref) = @_; |
| 316 |
|
| 317 |
my $infoline = ""; |
| 318 |
my @allmodules = (); |
| 319 |
|
| 320 |
for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ ) |
| 321 |
{ |
| 322 |
my $module = ${$modulesarrayref}[$i]; |
| 323 |
if ( $module->{'Spellcheckerlanguage'} ) # selecting modules with Spellcheckerlanguage |
| 324 |
{ |
| 325 |
if ( exists($installer::globals::spellcheckerlanguagehash{$module->{'Spellcheckerlanguage'}}) ) |
| 326 |
{ |
| 327 |
push(@allmodules, $module); |
| 328 |
} |
| 329 |
else |
| 330 |
{ |
| 331 |
$infoline = "Spellchecker selection: Removing module $module->{'gid'}\n"; |
| 332 |
push( @installer::globals::logfileinfo, $infoline); |
| 333 |
|
| 334 |
# Collecting all files at modules that are removed |
| 335 |
|
| 336 |
if ( $module->{'Files'} ) |
| 337 |
{ |
| 338 |
if ( $module->{'Files'} =~ /^\s*\((.*?)\)\s*$/ ) |
| 339 |
{ |
| 340 |
my $filelist = $1; |
| 341 |
|
| 342 |
my $filelisthash = installer::converter::convert_stringlist_into_hash(\$filelist, ","); |
| 343 |
foreach my $onefile ( keys %{$filelisthash} ) { $installer::globals::spellcheckerfilehash{$onefile} = 1; } |
| 344 |
} |
| 345 |
} |
| 346 |
} |
| 347 |
} |
| 348 |
else |
| 349 |
{ |
| 350 |
push(@allmodules, $module); |
| 351 |
} |
| 352 |
} |
| 353 |
|
| 354 |
return \@allmodules; |
| 355 |
} |
| 356 |
|
| 357 |
################################################################################ |
| 358 |
# Removing all modules, that belong to a module that was removed |
| 359 |
# in "remove_not_required_spellcheckerlanguage_modules" because of the |
| 360 |
# spellchecker language. The files belonging to the modules are collected |
| 361 |
# in %installer::globals::spellcheckerfilehash. |
| 362 |
################################################################################ |
| 363 |
|
| 364 |
sub remove_not_required_spellcheckerlanguage_files |
| 365 |
{ |
| 366 |
my ($filesarrayref) = @_; |
| 367 |
|
| 368 |
my @filesarray = (); |
| 369 |
my $infoline = ""; |
| 370 |
|
| 371 |
for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ ) |
| 372 |
{ |
| 373 |
my $onefile = ${$filesarrayref}[$i]; |
| 374 |
# FIXME: some items don't have 'gid' |
| 375 |
if ( (defined $onefile->{'gid'}) && exists($installer::globals::spellcheckerfilehash{$onefile->{'gid'}}) ) |
| 376 |
{ |
| 377 |
$infoline = "Spellchecker selection: Removing file $onefile->{'gid'}\n"; |
| 378 |
push( @installer::globals::logfileinfo, $infoline); |
| 379 |
next; |
| 380 |
} |
| 381 |
push(@filesarray, $onefile); |
| 382 |
} |
| 383 |
|
| 384 |
return \@filesarray; |
| 385 |
} |
| 386 |
|
| 387 |
################################################################################ |
| 388 |
# Looking for directories without correct HostName |
| 389 |
################################################################################ |
| 390 |
|
| 391 |
sub checking_directories_with_corrupt_hostname |
| 392 |
{ |
| 393 |
my ($dirsref, $languagesarrayref) = @_; |
| 394 |
|
| 395 |
for ( my $i = 0; $i <= $#{$dirsref}; $i++ ) |
| 396 |
{ |
| 397 |
my $onedir = ${$dirsref}[$i]; |
| 398 |
|
| 399 |
my $hostname = ""; |
| 400 |
|
| 401 |
if ( $onedir->{'HostName'} ) { $hostname = $onedir->{'HostName'}; } |
| 402 |
|
| 403 |
if ( $hostname eq "" ) |
| 404 |
{ |
| 405 |
my $langstring = ""; |
| 406 |
for ( my $j = 0; $j <= $#{$languagesarrayref}; $j++ ) { $langstring .= ${$languagesarrayref}[$j] . " "; } |
| 407 |
installer::exiter::exit_program("ERROR: HostName not defined for $onedir->{'gid'} for specified language. Probably you wanted to create an installation set, in a language not defined in scp2 project. You selected the following language(s): $langstring", "checking_directories_with_corrupt_hostname"); |
| 408 |
} |
| 409 |
|
| 410 |
if ( $hostname eq "FAILURE" ) |
| 411 |
{ |
| 412 |
installer::exiter::exit_program("ERROR: Could not create HostName for $onedir->{'gid'} (missing language at parent). See logfile warning for more info!", "checking_directories_with_corrupt_hostname"); |
| 413 |
} |
| 414 |
} |
| 415 |
} |
| 416 |
|
| 417 |
################################################################################ |
| 418 |
# Setting global properties |
| 419 |
################################################################################ |
| 420 |
|
| 421 |
sub set_global_directory_hostnames |
| 422 |
{ |
| 423 |
my ($dirsref, $allvariables) = @_; |
| 424 |
|
| 425 |
for ( my $i = 0; $i <= $#{$dirsref}; $i++ ) |
| 426 |
{ |
| 427 |
my $onedir = ${$dirsref}[$i]; |
| 428 |
my $styles = ""; |
| 429 |
if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; } |
| 430 |
|
| 431 |
if ( $styles =~ /\bOFFICEDIRECTORY\b/ ) |
| 432 |
{ |
| 433 |
$installer::globals::officedirhostname = $onedir->{'HostName'}; |
| 434 |
$installer::globals::officedirgid = $onedir->{'gid'}; |
| 435 |
$allvariables->{'OFFICEDIRECTORYHOSTNAME'} = $installer::globals::officedirhostname; |
| 436 |
} |
| 437 |
} |
| 438 |
} |
| 439 |
|
| 440 |
######################################################## |
| 441 |
# Recursively defined procedure to order |
| 442 |
# modules and directories |
| 443 |
######################################################## |
| 444 |
|
| 445 |
sub get_children |
| 446 |
{ |
| 447 |
my ($allitems, $startparent, $newitemorder) = @_; |
| 448 |
|
| 449 |
for ( my $i = 0; $i <= $#{$allitems}; $i++ ) |
| 450 |
{ |
| 451 |
my $gid = ${$allitems}[$i]->{'gid'}; |
| 452 |
my $parent = ""; |
| 453 |
if ( ${$allitems}[$i]->{'ParentID'} ) { $parent = ${$allitems}[$i]->{'ParentID'}; } |
| 454 |
|
| 455 |
if ( $parent eq $startparent ) |
| 456 |
{ |
| 457 |
push(@{$newitemorder}, ${$allitems}[$i]); |
| 458 |
my $parent = $gid; |
| 459 |
get_children($allitems, $parent, $newitemorder); # recursive! |
| 460 |
} |
| 461 |
} |
| 462 |
} |
| 463 |
|
| 464 |
################################################################################ |
| 465 |
# Using langpack copy action for language packs |
| 466 |
################################################################################ |
| 467 |
|
| 468 |
sub use_langpack_copy_scpaction |
| 469 |
{ |
| 470 |
my ($scpactionsref) = @_; |
| 471 |
|
| 472 |
for ( my $i = 0; $i <= $#{$scpactionsref}; $i++ ) |
| 473 |
{ |
| 474 |
my $onescpaction = ${$scpactionsref}[$i]; |
| 475 |
if (( $onescpaction->{'LangPackCopy'} ) && ( $onescpaction->{'LangPackCopy'} ne "" )) { $onescpaction->{'Copy'} = $onescpaction->{'LangPackCopy'}; } |
| 476 |
} |
| 477 |
} |
| 478 |
|
| 479 |
################################################################################ |
| 480 |
# Using dev copy patch action for developer snapshot builds |
| 481 |
################################################################################ |
| 482 |
|
| 483 |
sub use_devversion_copy_scpaction |
| 484 |
{ |
| 485 |
my ($scpactionsref) = @_; |
| 486 |
|
| 487 |
for ( my $i = 0; $i <= $#{$scpactionsref}; $i++ ) |
| 488 |
{ |
| 489 |
my $onescpaction = ${$scpactionsref}[$i]; |
| 490 |
if (( $onescpaction->{'DevVersionCopy'} ) && ( $onescpaction->{'DevVersionCopy'} ne "" )) { $onescpaction->{'Copy'} = $onescpaction->{'DevVersionCopy'}; } |
| 491 |
} |
| 492 |
} |
| 493 |
|
| 494 |
################################################################################ |
| 495 |
# Shifting parent directories of URE and Basis layer, so that |
| 496 |
# these directories are located below the Brand layer. |
| 497 |
# Style: SHIFT_BASIS_INTO_BRAND_LAYER |
| 498 |
################################################################################ |
| 499 |
|
| 500 |
sub shift_basis_directory_parents |
| 501 |
{ |
| 502 |
my ($dirsref) = @_; |
| 503 |
|
| 504 |
my @alldirs = (); |
| 505 |
|
| 506 |
my $officedirgid = ""; |
| 507 |
|
| 508 |
for ( my $i = 0; $i <= $#{$dirsref}; $i++ ) |
| 509 |
{ |
| 510 |
my $onedir = ${$dirsref}[$i]; |
| 511 |
my $styles = ""; |
| 512 |
if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; } |
| 513 |
|
| 514 |
if ( $styles =~ /\bOFFICEDIRECTORY\b/ ) { $officedirgid = $onedir->{'gid'}; } |
| 515 |
} |
| 516 |
|
| 517 |
if ( $officedirgid ne "" ) |
| 518 |
{ |
| 519 |
for ( my $i = 0; $i <= $#{$dirsref}; $i++ ) |
| 520 |
{ |
| 521 |
my $onedir = ${$dirsref}[$i]; |
| 522 |
my $styles = ""; |
| 523 |
if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; } |
| 524 |
|
| 525 |
if (( $styles =~ /\bBASISDIRECTORY\b/ ) || ( $styles =~ /\bUREDIRECTORY\b/ )) |
| 526 |
{ |
| 527 |
$onedir->{'ParentID'} = $officedirgid; |
| 528 |
} |
| 529 |
} |
| 530 |
|
| 531 |
# Sorting directories |
| 532 |
my $startgid = "PREDEFINED_PROGDIR"; |
| 533 |
get_children($dirsref, $startgid, \@alldirs); |
| 534 |
} |
| 535 |
|
| 536 |
return \@alldirs; |
| 537 |
} |
| 538 |
|
| 539 |
################################################################################ |
| 540 |
# Setting the name of the directory with style OFFICEDIRECTORY. |
| 541 |
# The name can be defined in property OFFICEDIRECTORYNAME. |
| 542 |
################################################################################ |
| 543 |
|
| 544 |
sub set_officedirectory_name |
| 545 |
{ |
| 546 |
my ($dirsref, $officedirname) = @_; |
| 547 |
|
| 548 |
for ( my $i = 0; $i <= $#{$dirsref}; $i++ ) |
| 549 |
{ |
| 550 |
my $onedir = ${$dirsref}[$i]; |
| 551 |
my $styles = ""; |
| 552 |
if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; } |
| 553 |
if ( $styles =~ /\bOFFICEDIRECTORY\b/ ) |
| 554 |
{ |
| 555 |
$onedir->{'HostName'} = $officedirname; |
| 556 |
last; |
| 557 |
} |
| 558 |
} |
| 559 |
} |
| 560 |
|
| 561 |
################################################################################ |
| 562 |
# Simplifying the name for language dependent items from "Name (xy)" to "Name" |
| 563 |
################################################################################ |
| 564 |
|
| 565 |
sub changing_name_of_language_dependent_keys |
| 566 |
{ |
| 567 |
my ($itemsarrayref) = @_; |
| 568 |
|
| 569 |
# Changing key for multilingual items from "Name ( )" to "Name" or "HostName ( )" to "HostName" |
| 570 |
|
| 571 |
for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ ) |
| 572 |
{ |
| 573 |
my $oneitem = ${$itemsarrayref}[$i]; |
| 574 |
my $onelanguage = $oneitem->{'specificlanguage'}; |
| 575 |
|
| 576 |
if (!($onelanguage eq "" )) # language dependent item |
| 577 |
{ |
| 578 |
my $itemkey; |
| 579 |
|
| 580 |
foreach $itemkey (keys %{$oneitem}) |
| 581 |
{ |
| 582 |
if ( $itemkey =~ /^\s*(\S+?)\s+\(\S+\)\s*$/ ) |
| 583 |
{ |
| 584 |
my $newitemkey = $1; |
| 585 |
my $itemvalue = $oneitem->{$itemkey}; |
| 586 |
$oneitem->{$newitemkey} = $itemvalue; |
| 587 |
delete($oneitem->{$itemkey}); |
| 588 |
} |
| 589 |
} |
| 590 |
} |
| 591 |
} |
| 592 |
} |
| 593 |
|
| 594 |
################################################################################ |
| 595 |
# Replacement of setup variables in ConfigurationItems and ProfileItems |
| 596 |
# <productkey>, <buildid>, <sequence_languages>, <productupdate> |
| 597 |
################################################################################ |
| 598 |
|
| 599 |
sub replace_setup_variables |
| 600 |
{ |
| 601 |
my ($itemsarrayref, $languagestringref, $hashref) = @_; |
| 602 |
|
| 603 |
my $languagesstring = $$languagestringref; |
| 604 |
$languagesstring =~ s/\_/ /g; # replacing underscore with whitespace |
| 605 |
|
| 606 |
my $productname = $hashref->{'PRODUCTNAME'}; |
| 607 |
my $productversion = $hashref->{'PRODUCTVERSION'}; |
| 608 |
my $libo_version_major = ""; |
| 609 |
if ( $hashref->{'LIBO_VERSION_MAJOR'} ) { $libo_version_major = $hashref->{'LIBO_VERSION_MAJOR'}; } |
| 610 |
my $productkey = $productname . " " . $productversion; |
| 611 |
|
| 612 |
# string $buildid, which is used to replace the setup variable <buildid> |
| 613 |
|
| 614 |
my $localbuild = $installer::globals::build; |
| 615 |
|
| 616 |
if ( $localbuild =~ /^\s*(\w+?)(\d+)\s*$/ ) { $localbuild = $2; } # using "680" instead of "src680" |
| 617 |
|
| 618 |
my $buildidstring = `git -C $ENV{'SRCDIR'} log -n 1 --pretty=format:"%H"`; |
| 619 |
if ($? || !$buildidstring) { |
| 620 |
$buildidstring = $localbuild . "(Build:" . $installer::globals::buildid . ")"; |
| 621 |
} |
| 622 |
|
| 623 |
my $updateid = $productname . "_" . $libo_version_major . "_" . $$languagestringref; |
| 624 |
$updateid =~ s/ /_/g; |
| 625 |
|
| 626 |
my $updatechannel = 'LOOnlineUpdater'; |
| 627 |
|
| 628 |
for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ ) |
| 629 |
{ |
| 630 |
my $oneitem = ${$itemsarrayref}[$i]; |
| 631 |
my $value = $oneitem->{'Value'}; |
| 632 |
|
| 633 |
$value =~ s/\<buildid\>/$buildidstring/; |
| 634 |
$value =~ s/\<sequence_languages\>/$languagesstring/; |
| 635 |
$value =~ s/\<productkey\>/$productkey/; |
| 636 |
$value =~ s/\<alllanguages\>/$languagesstring/; |
| 637 |
$value =~ s/\<sourceid\>/$installer::globals::build/; |
| 638 |
$value =~ s/\<updateid\>/$updateid/; |
| 639 |
$value =~ s/\<updatechannel\>/$updatechannel/; |
| 640 |
$value =~ s/\<pkgformat\>/$installer::globals::packageformat/; |
| 641 |
$ENV{'OOO_VENDOR'} = "" if !defined $ENV{'OOO_VENDOR'}; |
| 642 |
$value =~ s/\<vendor\>/$ENV{'OOO_VENDOR'}/; |
| 643 |
|
| 644 |
$oneitem->{'Value'} = $value; |
| 645 |
} |
| 646 |
} |
| 647 |
|
| 648 |
################################################################################ |
| 649 |
# By defining variable LOCALUSERDIR in *.lst it is possible to change |
| 650 |
# the standard destination of user directory defined in scp2 ($SYSUSERCONFIG). |
| 651 |
################################################################################ |
| 652 |
|
| 653 |
sub replace_userdir_variable |
| 654 |
{ |
| 655 |
my ($itemsarrayref, $allvariableshashref) = @_; |
| 656 |
|
| 657 |
my $userdir = ""; |
| 658 |
if ( $allvariableshashref->{'LOCALUSERDIR'} ) { $userdir = $allvariableshashref->{'LOCALUSERDIR'}; } |
| 659 |
else { $userdir = $installer::globals::simpledefaultuserdir; } |
| 660 |
|
| 661 |
if ( $userdir ne "" ) |
| 662 |
{ |
| 663 |
for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ ) |
| 664 |
{ |
| 665 |
my $oneitem = ${$itemsarrayref}[$i]; |
| 666 |
$oneitem->{'Value'} =~ s/\$SYSUSERCONFIG/$userdir/; |
| 667 |
} |
| 668 |
} |
| 669 |
} |
| 670 |
|
| 671 |
##################################################################################### |
| 672 |
# Files and ConfigurationItems are not included for all languages. |
| 673 |
# For instance asian fonts. These can be removed, if no "Name" is found. |
| 674 |
# ConfigurationItems are not always defined in the linguistic configuration file. |
| 675 |
# The "Key" cannot be found for them. |
| 676 |
##################################################################################### |
| 677 |
|
| 678 |
sub remove_non_existent_languages_in_productlists |
| 679 |
{ |
| 680 |
my ($itemsarrayref, $languagestringref, $searchkey, $itemtype) = @_; |
| 681 |
|
| 682 |
# Removing of all non existent files, for instance asian fonts |
| 683 |
|
| 684 |
installer::logger::include_header_into_logfile("Removing for this language $$languagestringref:"); |
| 685 |
|
| 686 |
my @allexistentitems = (); |
| 687 |
|
| 688 |
my $infoline; |
| 689 |
|
| 690 |
for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ ) |
| 691 |
{ |
| 692 |
my $oneitem = ${$itemsarrayref}[$i]; |
| 693 |
my $oneitemname = ""; # $searchkey is "Name" for files and "Key" for ConfigurationItems |
| 694 |
|
| 695 |
if ( $oneitem->{$searchkey} ) { $oneitemname = $oneitem->{$searchkey} } |
| 696 |
|
| 697 |
my $itemtoberemoved = 0; |
| 698 |
|
| 699 |
if ($oneitemname eq "") # for instance asian font in english installation set |
| 700 |
{ |
| 701 |
$itemtoberemoved = 1; |
| 702 |
} |
| 703 |
|
| 704 |
if ($itemtoberemoved) |
| 705 |
{ |
| 706 |
$infoline = "WARNING: Language $$languagestringref: No $itemtype packed for $oneitem->{'gid'}!\n"; |
| 707 |
push( @installer::globals::logfileinfo, $infoline); |
| 708 |
} |
| 709 |
else |
| 710 |
{ |
| 711 |
push(@allexistentitems, $oneitem); |
| 712 |
} |
| 713 |
} |
| 714 |
|
| 715 |
$infoline = "\n"; |
| 716 |
push( @installer::globals::logfileinfo, $infoline); |
| 717 |
|
| 718 |
return \@allexistentitems; |
| 719 |
} |
| 720 |
|
| 721 |
######################################################################## |
| 722 |
# Input is the directory gid, output the "HostName" of the directory |
| 723 |
######################################################################## |
| 724 |
|
| 725 |
sub get_Directoryname_From_Directorygid |
| 726 |
{ |
| 727 |
my ($dirsarrayref ,$searchgid, $onelanguage, $oneitemgid) = @_; |
| 728 |
|
| 729 |
my $directoryname = ""; |
| 730 |
my $onedirectory; |
| 731 |
my $foundgid = 0; |
| 732 |
|
| 733 |
for ( my $i = 0; $i <= $#{$dirsarrayref}; $i++ ) |
| 734 |
{ |
| 735 |
$onedirectory = ${$dirsarrayref}[$i]; |
| 736 |
my $directorygid = $onedirectory->{'gid'}; |
| 737 |
|
| 738 |
if ($directorygid eq $searchgid) |
| 739 |
{ |
| 740 |
$foundgid = 1; |
| 741 |
last; |
| 742 |
} |
| 743 |
} |
| 744 |
|
| 745 |
if (!($foundgid)) |
| 746 |
{ |
| 747 |
installer::exiter::exit_program("ERROR: Gid $searchgid not defined in $installer::globals::setupscriptname", "get_Directoryname_From_Directorygid"); |
| 748 |
} |
| 749 |
|
| 750 |
if ( ! ( $onedirectory->{'ismultilingual'} )) # the directory is not language dependent |
| 751 |
{ |
| 752 |
$directoryname = $onedirectory->{'HostName'}; |
| 753 |
} |
| 754 |
else |
| 755 |
{ |
| 756 |
$directoryname = $onedirectory->{"HostName ($onelanguage)"}; |
| 757 |
} |
| 758 |
|
| 759 |
# gid_Dir_Template_Wizard_Letter is defined as language dependent directory, but the file gid_Dir_Template_Wizard_Letter |
| 760 |
# is not language dependent. Therefore $onelanguage is not defined. But which language is the correct language for the |
| 761 |
# directory? |
| 762 |
# Perhaps better solution: In scp it must be forbidden to have a language independent file in a language dependent directory. |
| 763 |
|
| 764 |
if (( ! $directoryname ) && ( $onelanguage eq "" )) |
| 765 |
{ |
| 766 |
installer::exiter::exit_program("ERROR (in scp): Directory $searchgid is language dependent, but not $oneitemgid inside this directory", "get_Directoryname_From_Directorygid"); |
| 767 |
} |
| 768 |
|
| 769 |
return \$directoryname; |
| 770 |
} |
| 771 |
|
| 772 |
################################################################## |
| 773 |
# Getting destination directory for links, files and profiles |
| 774 |
################################################################## |
| 775 |
|
| 776 |
sub get_Destination_Directory_For_Item_From_Directorylist # this is used for Files, Profiles and Links |
| 777 |
{ |
| 778 |
my ($itemarrayref, $dirsarrayref) = @_; |
| 779 |
|
| 780 |
for ( my $i = 0; $i <= $#{$itemarrayref}; $i++ ) |
| 781 |
{ |
| 782 |
my $oneitem = ${$itemarrayref}[$i]; |
| 783 |
my $oneitemgid = $oneitem->{'gid'}; |
| 784 |
my $directorygid = $oneitem->{'Dir'}; # for instance gid_Dir_Program |
| 785 |
my $netdirectorygid = ""; |
| 786 |
my $onelanguage = $oneitem->{'specificlanguage'}; |
| 787 |
my $ispredefinedprogdir = 0; |
| 788 |
my $ispredefinedconfigdir = 0; |
| 789 |
|
| 790 |
my $oneitemname = $oneitem->{'Name'}; |
| 791 |
|
| 792 |
if ( $oneitem->{'NetDir'} ) { $netdirectorygid = $oneitem->{'NetDir'}; } |
| 793 |
|
| 794 |
installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$oneitemname); # making /registry/schema/org/openoffice/VCL.xcs to VCL.xcs |
| 795 |
|
| 796 |
my $searchdirgid; |
| 797 |
|
| 798 |
if ( $netdirectorygid eq "" ) # if NetDir is defined, it is privileged |
| 799 |
{ |
| 800 |
$searchdirgid = $directorygid |
| 801 |
} |
| 802 |
else |
| 803 |
{ |
| 804 |
$searchdirgid = $netdirectorygid |
| 805 |
} |
| 806 |
|
| 807 |
if ($searchdirgid =~ /PREDEFINED_PROGDIR/) # the root directory is not defined in setup script |
| 808 |
{ |
| 809 |
$ispredefinedprogdir = 1; |
| 810 |
} |
| 811 |
|
| 812 |
if ($searchdirgid =~ /PREDEFINED_CONFIGDIR/) # the root directory is not defined in setup script |
| 813 |
{ |
| 814 |
$ispredefinedconfigdir = 1; |
| 815 |
} |
| 816 |
|
| 817 |
my $destfilename; |
| 818 |
|
| 819 |
if ($oneitem->{'DoNotMessWithSymlinks'}) |
| 820 |
{ |
| 821 |
$destfilename = $oneitem->{'Name'}; |
| 822 |
} |
| 823 |
elsif ((!( $ispredefinedprogdir )) && (!( $ispredefinedconfigdir ))) |
| 824 |
{ |
| 825 |
my $directorynameref = get_Directoryname_From_Directorygid($dirsarrayref, $searchdirgid, $onelanguage, $oneitemgid); |
| 826 |
my $styles = ""; |
| 827 |
if ($oneitem->{'Styles'}) { $styles = $oneitem->{'Styles'}; } |
| 828 |
if ($styles =~ /\bFILELIST\b/) |
| 829 |
{ |
| 830 |
$destfilename = $$directorynameref . $installer::globals::separator . $oneitemname; |
| 831 |
} |
| 832 |
else |
| 833 |
{ |
| 834 |
$destfilename = $$directorynameref . $installer::globals::separator . $oneitem->{'Name'}; |
| 835 |
} |
| 836 |
} |
| 837 |
else |
| 838 |
{ |
| 839 |
$destfilename = $oneitemname; |
| 840 |
} |
| 841 |
|
| 842 |
$oneitem->{'destination'} = $destfilename; |
| 843 |
} |
| 844 |
} |
| 845 |
|
| 846 |
########################################################################## |
| 847 |
# Searching a file in a list of paths |
| 848 |
########################################################################## |
| 849 |
|
| 850 |
sub get_sourcepath_from_filename_and_includepath_classic |
| 851 |
{ |
| 852 |
my ($searchfilenameref, $includepatharrayref, $write_logfile) = @_; |
| 853 |
|
| 854 |
my ($onefile, $includepath, $infoline); |
| 855 |
|
| 856 |
my $foundsourcefile = 0; |
| 857 |
|
| 858 |
for ( my $j = 0; $j <= $#{$includepatharrayref}; $j++ ) |
| 859 |
{ |
| 860 |
$includepath = ${$includepatharrayref}[$j]; |
| 861 |
installer::remover::remove_leading_and_ending_whitespaces(\$includepath); |
| 862 |
|
| 863 |
$onefile = $includepath . $installer::globals::separator . $$searchfilenameref; |
| 864 |
|
| 865 |
if ( -f $onefile ) |
| 866 |
{ |
| 867 |
$foundsourcefile = 1; |
| 868 |
last; |
| 869 |
} |
| 870 |
} |
| 871 |
|
| 872 |
if (!($foundsourcefile)) |
| 873 |
{ |
| 874 |
$onefile = ""; # the sourcepath has to be empty |
| 875 |
if ( $write_logfile) |
| 876 |
{ |
| 877 |
$infoline = "ERROR: Source for $$searchfilenameref not found (classic)!\n"; # Important message in log file |
| 878 |
push( @installer::globals::logfileinfo, $infoline); |
| 879 |
} |
| 880 |
} |
| 881 |
else |
| 882 |
{ |
| 883 |
if ( $write_logfile) |
| 884 |
{ |
| 885 |
$infoline = "SUCCESS: Source for $$searchfilenameref: $onefile\n"; |
| 886 |
push( @installer::globals::logfileinfo, $infoline); |
| 887 |
} |
| 888 |
} |
| 889 |
|
| 890 |
return \$onefile; |
| 891 |
} |
| 892 |
|
| 893 |
########################################################################## |
| 894 |
# Input is one file name, output the complete absolute path of this file |
| 895 |
########################################################################## |
| 896 |
|
| 897 |
sub get_sourcepath_from_filename_and_includepath |
| 898 |
{ |
| 899 |
my ($searchfilenameref, $unused, $write_logfile) = @_; |
| 900 |
|
| 901 |
my ($onefile, $includepath, $infoline); |
| 902 |
|
| 903 |
my $foundsourcefile = 0; |
| 904 |
my $foundnewname = 0; |
| 905 |
|
| 906 |
for ( my $j = 0; $j <= $#installer::globals::allincludepaths; $j++ ) |
| 907 |
{ |
| 908 |
my $allfiles = $installer::globals::allincludepaths[$j]; |
| 909 |
|
| 910 |
if ( exists( $allfiles->{$$searchfilenameref} )) |
| 911 |
{ |
| 912 |
$onefile = $allfiles->{'includepath'} . $installer::globals::separator . $$searchfilenameref; |
| 913 |
$foundsourcefile = 1; |
| 914 |
last; |
| 915 |
} |
| 916 |
} |
| 917 |
|
| 918 |
if (!($foundsourcefile)) # testing with lowercase filename |
| 919 |
{ |
| 920 |
# Attention: README01.html is copied for Windows to readme01.html, not case sensitive |
| 921 |
|
| 922 |
for ( my $j = 0; $j <= $#installer::globals::allincludepaths; $j++ ) |
| 923 |
{ |
| 924 |
my $allfiles = $installer::globals::allincludepaths[$j]; |
| 925 |
|
| 926 |
my $newfilename = $$searchfilenameref; |
| 927 |
$newfilename =~ s/readme/README/; # special handling for readme files |
| 928 |
$newfilename =~ s/license/LICENSE/; # special handling for license files |
| 929 |
|
| 930 |
if ( exists( $allfiles->{$newfilename} )) |
| 931 |
{ |
| 932 |
$onefile = $allfiles->{'includepath'} . $installer::globals::separator . $newfilename; |
| 933 |
$foundsourcefile = 1; |
| 934 |
$foundnewname = 1; |
| 935 |
last; |
| 936 |
} |
| 937 |
} |
| 938 |
} |
| 939 |
|
| 940 |
if (!($foundsourcefile)) |
| 941 |
{ |
| 942 |
$onefile = ""; # the sourcepath has to be empty |
| 943 |
if ( $write_logfile) |
| 944 |
{ |
| 945 |
$infoline = "ERROR: Source for $$searchfilenameref not found!\n"; # Important message in log file |
| 946 |
push( @installer::globals::logfileinfo, $infoline); |
| 947 |
} |
| 948 |
} |
| 949 |
else |
| 950 |
{ |
| 951 |
if ( $write_logfile) |
| 952 |
{ |
| 953 |
if (!($foundnewname)) |
| 954 |
{ |
| 955 |
$infoline = "SUCCESS: Source for $$searchfilenameref: $onefile\n"; |
| 956 |
} |
| 957 |
else |
| 958 |
{ |
| 959 |
$infoline = "SUCCESS/WARNING: Special handling for $$searchfilenameref: $onefile\n"; |
| 960 |
} |
| 961 |
push( @installer::globals::logfileinfo, $infoline); |
| 962 |
} |
| 963 |
} |
| 964 |
|
| 965 |
return \$onefile; |
| 966 |
} |
| 967 |
|
| 968 |
############################################################## |
| 969 |
# Getting all source paths for all files to be packed |
| 970 |
# $item can be "Files" or "ScpActions" |
| 971 |
############################################################## |
| 972 |
|
| 973 |
sub get_Source_Directory_For_Files_From_Includepathlist |
| 974 |
{ |
| 975 |
my ($filesarrayref, $includepatharrayref, $dirsref, $item, $allvariables) = @_; |
| 976 |
|
| 977 |
installer::logger::include_header_into_logfile("$item:"); |
| 978 |
|
| 979 |
my ($foundit, $dontcare, $extrarootdir) = |
| 980 |
get_office_directory_gid_and_hostname($dirsref); |
| 981 |
my $infoline = ""; |
| 982 |
|
| 983 |
for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ ) |
| 984 |
{ |
| 985 |
my $onefile = ${$filesarrayref}[$i]; |
| 986 |
my $onelanguage = $onefile->{'specificlanguage'}; |
| 987 |
|
| 988 |
if ( ! $onefile->{'Name'} ) { installer::exiter::exit_program("ERROR: $item without name ! GID: $onefile->{'gid'} ! Language: $onelanguage", "get_Source_Directory_For_Files_From_Includepathlist"); } |
| 989 |
|
| 990 |
my $onefilename = $onefile->{'Name'}; |
| 991 |
if ( $item eq "ScpActions" ) { $onefilename =~ s/\//$installer::globals::separator/g; } |
| 992 |
$onefilename =~ s/^\s*\Q$installer::globals::separator\E//; # filename begins with a slash, for instance /registry/schema/org/openoffice/VCL.xcs |
| 993 |
|
| 994 |
my $styles = ""; |
| 995 |
my $file_can_miss = 0; |
| 996 |
if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; } |
| 997 |
|
| 998 |
if (( $installer::globals::languagepack ) && ( ! $onefile->{'ismultilingual'} ) && ( ! ( $styles =~ /\bFORCELANGUAGEPACK\b/ ))) { $file_can_miss = 1; } |
| 999 |
if (( $installer::globals::helppack ) && ( ! $onefile->{'ismultilingual'} ) && ( ! ( $styles =~ /\bFORCEHELPPACK\b/ ))) { $file_can_miss = 1; } |
| 1000 |
|
| 1001 |
my $sourcepathref = ""; |
| 1002 |
|
| 1003 |
my $destination = $onefile->{'destination'}; |
| 1004 |
my $instdirdestination; |
| 1005 |
if ($destination) |
| 1006 |
{ |
| 1007 |
if (($installer::globals::iswindowsbuild) && $foundit && $extrarootdir) |
| 1008 |
{ |
| 1009 |
$destination =~ s,$extrarootdir/,,; # remove it from path |
| 1010 |
} |
| 1011 |
if (($installer::globals::languagepack) && ($installer::globals::ismacbuild)) |
| 1012 |
{ # source files are in $(PRODUCTNAME).app where they will |
| 1013 |
# actually copied by the user executing the Language Pack.app |
| 1014 |
$destination =~ s, Language Pack.app/,.app/,; |
| 1015 |
} |
| 1016 |
$instdirdestination = $ENV{'INSTDIR'} . $installer::globals::separator . $destination; |
| 1017 |
} |
| 1018 |
if ($instdirdestination && -f $instdirdestination) |
| 1019 |
{ |
| 1020 |
$infoline = "SUCCESS: INSTDIR Source for $onefilename: $instdirdestination\n"; |
| 1021 |
push( @installer::globals::logfileinfo, $infoline); |
| 1022 |
$$sourcepathref = $instdirdestination; |
| 1023 |
} |
| 1024 |
else |
| 1025 |
{ |
| 1026 |
if ( $file_can_miss ) { $sourcepathref = get_sourcepath_from_filename_and_includepath(\$onefilename, $includepatharrayref, 0); } |
| 1027 |
else { $sourcepathref = get_sourcepath_from_filename_and_includepath(\$onefilename, $includepatharrayref, 1); } |
| 1028 |
} |
| 1029 |
|
| 1030 |
$onefile->{'sourcepath'} = $$sourcepathref; # This $$sourcepathref is empty, if no source was found |
| 1031 |
} |
| 1032 |
|
| 1033 |
$infoline = "\n"; # empty line after listing of all files |
| 1034 |
push( @installer::globals::logfileinfo, $infoline); |
| 1035 |
} |
| 1036 |
|
| 1037 |
################################################################################# |
| 1038 |
# Removing files, that shall not be included into languagepacks |
| 1039 |
# (because of rpm conflicts) |
| 1040 |
################################################################################# |
| 1041 |
|
| 1042 |
sub remove_Files_For_Languagepacks |
| 1043 |
{ |
| 1044 |
my ($itemsarrayref) = @_; |
| 1045 |
|
| 1046 |
my $infoline; |
| 1047 |
|
| 1048 |
my @newitemsarray = (); |
| 1049 |
|
| 1050 |
for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ ) |
| 1051 |
{ |
| 1052 |
my $oneitem = ${$itemsarrayref}[$i]; |
| 1053 |
my $gid = $oneitem->{'gid'}; |
| 1054 |
|
| 1055 |
# scp Todo: Remove asap after removal of old setup |
| 1056 |
|
| 1057 |
if (( $gid eq "gid_File_Extra_Fontunxpsprint" ) || |
| 1058 |
( $gid eq "gid_File_Extra_Migration_Lang" )) |
| 1059 |
{ |
| 1060 |
$infoline = "ATTENTION: Removing item $oneitem->{'gid'} from the installation set.\n"; |
| 1061 |
push( @installer::globals::logfileinfo, $infoline); |
| 1062 |
|
| 1063 |
next; |
| 1064 |
} |
| 1065 |
|
| 1066 |
push(@newitemsarray, $oneitem); |
| 1067 |
} |
| 1068 |
|
| 1069 |
return \@newitemsarray; |
| 1070 |
} |
| 1071 |
|
| 1072 |
################################################################################# |
| 1073 |
# Files, whose source directory is not found, are removed now (this is an ERROR) |
| 1074 |
################################################################################# |
| 1075 |
|
| 1076 |
sub remove_Files_Without_Sourcedirectory |
| 1077 |
{ |
| 1078 |
my ($filesarrayref) = @_; |
| 1079 |
|
| 1080 |
my $infoline; |
| 1081 |
|
| 1082 |
my $error_occurred = 0; |
| 1083 |
my $missingfiles = "The following files could not be found:\n"; |
| 1084 |
|
| 1085 |
my @newfilesarray = (); |
| 1086 |
|
| 1087 |
for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ ) |
| 1088 |
{ |
| 1089 |
my $onefile = ${$filesarrayref}[$i]; |
| 1090 |
my $sourcepath = $onefile->{'sourcepath'}; |
| 1091 |
|
| 1092 |
if ($sourcepath eq "") |
| 1093 |
{ |
| 1094 |
my $styles = $onefile->{'Styles'}; |
| 1095 |
my $filename = $onefile->{'Name'}; |
| 1096 |
|
| 1097 |
if ( ! $installer::globals::languagepack && !$installer::globals::helppack) |
| 1098 |
{ |
| 1099 |
$infoline = "ERROR: Removing file $filename from file list.\n"; |
| 1100 |
push( @installer::globals::logfileinfo, $infoline); |
| 1101 |
|
| 1102 |
$missingfiles = "$missingfiles $filename\n"; |
| 1103 |
$error_occurred = 1; |
| 1104 |
|
| 1105 |
next; # removing this file from list, if sourcepath is empty |
| 1106 |
} |
| 1107 |
elsif ( $installer::globals::languagepack ) # special case for language packs |
| 1108 |
{ |
| 1109 |
if (( $onefile->{'ismultilingual'} ) || ( $styles =~ /\bFORCELANGUAGEPACK\b/ )) |
| 1110 |
{ |
| 1111 |
$infoline = "ERROR: Removing file $filename from file list.\n"; |
| 1112 |
push( @installer::globals::logfileinfo, $infoline); |
| 1113 |
|
| 1114 |
$missingfiles = "$missingfiles $filename\n"; |
| 1115 |
$error_occurred = 1; |
| 1116 |
|
| 1117 |
next; # removing this file from list, if sourcepath is empty |
| 1118 |
} |
| 1119 |
else |
| 1120 |
{ |
| 1121 |
$infoline = "INFO: Removing file $filename from file list. It is not language dependent.\n"; |
| 1122 |
push( @installer::globals::logfileinfo, $infoline); |
| 1123 |
$infoline = "INFO: It is not language dependent and can be ignored in language packs.\n"; |
| 1124 |
push( @installer::globals::logfileinfo, $infoline); |
| 1125 |
|
| 1126 |
next; # removing this file from list, if sourcepath is empty |
| 1127 |
} |
| 1128 |
} |
| 1129 |
else # special case for help packs |
| 1130 |
{ |
| 1131 |
if (( $onefile->{'ismultilingual'} ) || ( $styles =~ /\bFORCEHELPPACK\b/ )) |
| 1132 |
{ |
| 1133 |
$infoline = "ERROR: Removing file $filename from file list.\n"; |
| 1134 |
push( @installer::globals::logfileinfo, $infoline); |
| 1135 |
|
| 1136 |
$missingfiles = "$missingfiles $filename\n"; |
| 1137 |
$error_occurred = 1; |
| 1138 |
|
| 1139 |
next; # removing this file from list, if sourcepath is empty |
| 1140 |
} |
| 1141 |
else |
| 1142 |
{ |
| 1143 |
$infoline = "INFO: Removing file $filename from file list. It is not language dependent.\n"; |
| 1144 |
push( @installer::globals::logfileinfo, $infoline); |
| 1145 |
$infoline = "INFO: It is not language dependent and can be ignored in help packs.\n"; |
| 1146 |
push( @installer::globals::logfileinfo, $infoline); |
| 1147 |
|
| 1148 |
next; # removing this file from list, if sourcepath is empty |
| 1149 |
} |
| 1150 |
} |
| 1151 |
} |
| 1152 |
|
| 1153 |
push(@newfilesarray, $onefile); |
| 1154 |
} |
| 1155 |
|
| 1156 |
$infoline = "\n"; |
| 1157 |
push( @installer::globals::logfileinfo, $infoline); |
| 1158 |
|
| 1159 |
if ( $error_occurred ) |
| 1160 |
{ |
| 1161 |
installer::exiter::exit_program($missingfiles, "remove_Files_Without_Sourcedirectory"); |
| 1162 |
} |
| 1163 |
|
| 1164 |
return \@newfilesarray; |
| 1165 |
} |
| 1166 |
|
| 1167 |
############################################################################ |
| 1168 |
# License and Readme files in the default language have to be installed |
| 1169 |
# in the directory with flag OFFICEDIRECTORY. If this is not defined |
| 1170 |
# they have to be installed in the installation root. |
| 1171 |
############################################################################ |
| 1172 |
|
| 1173 |
sub get_office_directory_gid_and_hostname |
| 1174 |
{ |
| 1175 |
my ($dirsarrayref) = @_; |
| 1176 |
|
| 1177 |
my $foundofficedir = 0; |
| 1178 |
my $gid = ""; |
| 1179 |
my $hostname = ""; |
| 1180 |
|
| 1181 |
for ( my $i = 0; $i <= $#{$dirsarrayref}; $i++ ) |
| 1182 |
{ |
| 1183 |
my $onedir = ${$dirsarrayref}[$i]; |
| 1184 |
if ( $onedir->{'Styles'} ) |
| 1185 |
{ |
| 1186 |
my $styles = $onedir->{'Styles'}; |
| 1187 |
|
| 1188 |
if ( $styles =~ /\bOFFICEDIRECTORY\b/ ) |
| 1189 |
{ |
| 1190 |
$foundofficedir = 1; |
| 1191 |
$gid = $onedir->{'gid'}; |
| 1192 |
$hostname = $onedir->{'HostName'}; |
| 1193 |
last; |
| 1194 |
} |
| 1195 |
} |
| 1196 |
} |
| 1197 |
|
| 1198 |
return ($foundofficedir, $gid, $hostname); |
| 1199 |
} |
| 1200 |
|
| 1201 |
############################################################################ |
| 1202 |
# License and Readme files in the default language have to be installed |
| 1203 |
# in the installation root (next to the program dir). This is in scp |
| 1204 |
# project done by a post install basic script |
| 1205 |
############################################################################ |
| 1206 |
|
| 1207 |
sub add_License_Files_into_Installdir |
| 1208 |
{ |
| 1209 |
my ($filesarrayref, $dirsarrayref, $languagesarrayref) = @_; |
| 1210 |
|
| 1211 |
my $infoline; |
| 1212 |
|
| 1213 |
my @newfilesarray = (); |
| 1214 |
|
| 1215 |
my $defaultlanguage = installer::languages::get_default_language($languagesarrayref); |
| 1216 |
|
| 1217 |
my ($foundofficedir, $officedirectorygid, $officedirectoryhostname) = get_office_directory_gid_and_hostname($dirsarrayref); |
| 1218 |
|
| 1219 |
# copy all files from directory share/readme, that contain the default language in their name |
| 1220 |
# without default language into the installation root. This makes the settings of the correct |
| 1221 |
# file names superfluous. On the other hand this requires a dependency to the directory |
| 1222 |
# share/readme |
| 1223 |
|
| 1224 |
for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ ) |
| 1225 |
{ |
| 1226 |
my $onefile = ${$filesarrayref}[$i]; |
| 1227 |
my $destination = $onefile->{'destination'}; |
| 1228 |
my $styles = ""; |
| 1229 |
if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; } |
| 1230 |
|
| 1231 |
if ( ( $destination =~ /share\Q$installer::globals::separator\Ereadme\Q$installer::globals::separator\E(\w+?)_?$defaultlanguage\.?(\w*)\s*/ ) |
| 1232 |
|| (( $styles =~ /\bROOTLICENSEFILE\b/ ) && ( $destination =~ /\Q$installer::globals::separator\E?(\w+?)_?$defaultlanguage\.?(\w*?)\s*$/ )) ) |
| 1233 |
{ |
| 1234 |
my $filename = $1; |
| 1235 |
my $extension = $2; |
| 1236 |
|
| 1237 |
my $newfilename; |
| 1238 |
|
| 1239 |
if ( $extension eq "" ) { $newfilename = $filename; } |
| 1240 |
else { $newfilename = $filename . "\." . $extension; } |
| 1241 |
|
| 1242 |
my %newfile = (); |
| 1243 |
my $newfile = \%newfile; |
| 1244 |
|
| 1245 |
installer::converter::copy_item_object($onefile, $newfile); |
| 1246 |
|
| 1247 |
$newfile->{'gid'} = $onefile->{'gid'} . "_Copy"; |
| 1248 |
$newfile->{'Name'} = $newfilename; |
| 1249 |
$newfile->{'ismultilingual'} = "0"; |
| 1250 |
$newfile->{'specificlanguage'} = ""; |
| 1251 |
$newfile->{'haslanguagemodule'} = "0"; |
| 1252 |
|
| 1253 |
if ( defined $newfile->{'InstallName'} ) |
| 1254 |
{ |
| 1255 |
if ( $newfile->{'InstallName'} =~ /^\s*(.*?)_$defaultlanguage\.?(\w*?)\s*$/ ) |
| 1256 |
{ |
| 1257 |
my $localfilename = $1; |
| 1258 |
my $localextension = $2; |
| 1259 |
|
| 1260 |
if ( $localextension eq "" ) { $newfile->{'InstallName'} = $localfilename; } |
| 1261 |
else { $newfile->{'InstallName'} = $localfilename . "\." . $localextension; } |
| 1262 |
} |
| 1263 |
} |
| 1264 |
|
| 1265 |
$newfile->{'removelangfromfile'} = "1"; # Important for files with an InstallName, because language also has to be removed there. |
| 1266 |
|
| 1267 |
if ( $foundofficedir ) |
| 1268 |
{ |
| 1269 |
$newfile->{'Dir'} = $officedirectorygid; |
| 1270 |
$newfile->{'destination'} = $officedirectoryhostname . $installer::globals::separator . $newfilename; |
| 1271 |
} |
| 1272 |
else |
| 1273 |
{ |
| 1274 |
$newfile->{'Dir'} = "PREDEFINED_PROGDIR"; |
| 1275 |
$newfile->{'destination'} = $newfilename; |
| 1276 |
} |
| 1277 |
|
| 1278 |
# Also setting "modules=gid_Module_Root_Brand" (module with style: ROOT_BRAND_PACKAGE) |
| 1279 |
if ( $installer::globals::rootbrandpackageset ) |
| 1280 |
{ |
| 1281 |
$newfile->{'modules'} = $installer::globals::rootbrandpackage; |
| 1282 |
} |
| 1283 |
|
| 1284 |
push(@newfilesarray, $newfile); |
| 1285 |
|
| 1286 |
$infoline = "New files: Adding file $newfilename for the installation root to the file list. Language: $defaultlanguage\n"; |
| 1287 |
push( @installer::globals::logfileinfo, $infoline); |
| 1288 |
|
| 1289 |
if ( defined $newfile->{'InstallName'} ) |
| 1290 |
{ |
| 1291 |
$infoline = "New files: Using installation name: $newfile->{'InstallName'}\n"; |
| 1292 |
push( @installer::globals::logfileinfo, $infoline); |
| 1293 |
} |
| 1294 |
} |
| 1295 |
|
| 1296 |
push(@newfilesarray, $onefile); |
| 1297 |
} |
| 1298 |
|
| 1299 |
return \@newfilesarray; |
| 1300 |
} |
| 1301 |
|
| 1302 |
############################################################################ |
| 1303 |
# Some files are included for more than one language and have the same |
| 1304 |
# name and the same destination directory for all languages. This would |
| 1305 |
# lead to conflicts, if the filenames are not changed. |
| 1306 |
# In scp project this files must have the flag MAKE_LANG_SPECIFIC |
| 1307 |
# For this files, the language is included into the filename. |
| 1308 |
############################################################################ |
| 1309 |
|
| 1310 |
sub make_filename_language_specific |
| 1311 |
{ |
| 1312 |
my ($filesarrayref) = @_; |
| 1313 |
|
| 1314 |
my $infoline = ""; |
| 1315 |
|
| 1316 |
for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ ) |
| 1317 |
{ |
| 1318 |
my $onefile = ${$filesarrayref}[$i]; |
| 1319 |
|
| 1320 |
if ( $onefile->{'ismultilingual'} ) |
| 1321 |
{ |
| 1322 |
my $styles = ""; |
| 1323 |
if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; } |
| 1324 |
if ( $styles =~ /\bMAKE_LANG_SPECIFIC\b/ ) |
| 1325 |
{ |
| 1326 |
my $language = $onefile->{'specificlanguage'}; |
| 1327 |
my $olddestination = $onefile->{'destination'}; |
| 1328 |
my $oldname = $onefile->{'Name'}; |
| 1329 |
|
| 1330 |
# Including the language into the file name. |
| 1331 |
# But be sure, to include the language before the file extension. |
| 1332 |
|
| 1333 |
my $fileextension = ""; |
| 1334 |
|
| 1335 |
if ( $onefile->{'Name'} =~ /(\.\w+?)\s*$/ ) { $fileextension = $1; } |
| 1336 |
if ( $fileextension ne "" ) |
| 1337 |
{ |
| 1338 |
$onefile->{'Name'} =~ s/\Q$fileextension\E\s*$/_$language$fileextension/; |
| 1339 |
$onefile->{'destination'} =~ s/\Q$fileextension\E\s*$/_$language$fileextension/; |
| 1340 |
} |
| 1341 |
|
| 1342 |
$infoline = "Flag MAKE_LANG_SPECIFIC:\n"; |
| 1343 |
push( @installer::globals::logfileinfo, $infoline); |
| 1344 |
$infoline = "Changing name from $oldname to $onefile->{'Name'} !\n"; |
| 1345 |
push( @installer::globals::logfileinfo, $infoline); |
| 1346 |
$infoline = "Changing destination from $olddestination to $onefile->{'destination'} !\n"; |
| 1347 |
push( @installer::globals::logfileinfo, $infoline); |
| 1348 |
} |
| 1349 |
} |
| 1350 |
} |
| 1351 |
} |
| 1352 |
|
| 1353 |
############################################################################ |
| 1354 |
# Because of the item "File" the source name must be "Name". Therefore |
| 1355 |
# "Copy" is changed to "Name" and "Name" is changed to "DestinationName". |
| 1356 |
############################################################################ |
| 1357 |
|
| 1358 |
sub change_keys_of_scpactions |
| 1359 |
{ |
| 1360 |
my ($itemsarrayref) = @_; |
| 1361 |
|
| 1362 |
for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ ) |
| 1363 |
{ |
| 1364 |
my $oneitem = ${$itemsarrayref}[$i]; |
| 1365 |
|
| 1366 |
my $key; |
| 1367 |
|
| 1368 |
# First Name to DestinationName, then deleting Name |
| 1369 |
foreach $key (keys %{$oneitem}) |
| 1370 |
{ |
| 1371 |
if ( $key =~ /\bName\b/ ) |
| 1372 |
{ |
| 1373 |
my $value = $oneitem->{$key}; |
| 1374 |
my $oldkey = $key; |
| 1375 |
$key =~ s/Name/DestinationName/; |
| 1376 |
$oneitem->{$key} = $value; |
| 1377 |
delete($oneitem->{$oldkey}); |
| 1378 |
} |
| 1379 |
} |
| 1380 |
|
| 1381 |
# Second Copy to Name, then deleting Copy |
| 1382 |
foreach $key (keys %{$oneitem}) |
| 1383 |
{ |
| 1384 |
if ( $key =~ /\bCopy\b/ ) |
| 1385 |
{ |
| 1386 |
my $value = $oneitem->{$key}; |
| 1387 |
my $oldkey = $key; |
| 1388 |
$key =~ s/Copy/Name/; |
| 1389 |
$oneitem->{$key} = $value; |
| 1390 |
delete($oneitem->{$oldkey}); |
| 1391 |
} |
| 1392 |
} |
| 1393 |
} |
| 1394 |
} |
| 1395 |
|
| 1396 |
############################################################################ |
| 1397 |
# Removing all language pack files from installation set (files with |
| 1398 |
# the style LANGUAGEPACK), except this is a language pack. |
| 1399 |
############################################################################ |
| 1400 |
|
| 1401 |
sub remove_Languagepacklibraries_from_Installset |
| 1402 |
{ |
| 1403 |
my ($itemsarrayref) = @_; |
| 1404 |
|
| 1405 |
my $infoline; |
| 1406 |
|
| 1407 |
my @newitemsarray = (); |
| 1408 |
|
| 1409 |
for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ ) |
| 1410 |
{ |
| 1411 |
my $oneitem = ${$itemsarrayref}[$i]; |
| 1412 |
my $styles = ""; |
| 1413 |
if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; } |
| 1414 |
|
| 1415 |
if ( $styles =~ /\bLANGUAGEPACK\b/ ) |
| 1416 |
{ |
| 1417 |
$infoline = "Removing language pack file $oneitem->{'gid'} from the installation set.\n"; |
| 1418 |
push( @installer::globals::globallogfileinfo, $infoline); |
| 1419 |
|
| 1420 |
next; |
| 1421 |
} |
| 1422 |
|
| 1423 |
push(@newitemsarray, $oneitem); |
| 1424 |
} |
| 1425 |
|
| 1426 |
$infoline = "\n"; |
| 1427 |
push( @installer::globals::globallogfileinfo, $infoline); |
| 1428 |
|
| 1429 |
return \@newitemsarray; |
| 1430 |
} |
| 1431 |
|
| 1432 |
############################################################################ |
| 1433 |
# Removing all help pack files from installation set (files with |
| 1434 |
# the style HELPPACK), except this is a help pack. |
| 1435 |
############################################################################ |
| 1436 |
|
| 1437 |
sub remove_Helppacklibraries_from_Installset |
| 1438 |
{ |
| 1439 |
my ($itemsarrayref) = @_; |
| 1440 |
|
| 1441 |
my $infoline; |
| 1442 |
|
| 1443 |
my @newitemsarray = (); |
| 1444 |
|
| 1445 |
for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ ) |
| 1446 |
{ |
| 1447 |
my $oneitem = ${$itemsarrayref}[$i]; |
| 1448 |
my $styles = ""; |
| 1449 |
if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; } |
| 1450 |
|
| 1451 |
if ( $styles =~ /\bHELPPACK\b/ ) |
| 1452 |
{ |
| 1453 |
$infoline = "Removing help pack file $oneitem->{'gid'} from the installation set.\n"; |
| 1454 |
push( @installer::globals::globallogfileinfo, $infoline); |
| 1455 |
|
| 1456 |
next; |
| 1457 |
} |
| 1458 |
|
| 1459 |
push(@newitemsarray, $oneitem); |
| 1460 |
} |
| 1461 |
|
| 1462 |
$infoline = "\n"; |
| 1463 |
push( @installer::globals::globallogfileinfo, $infoline); |
| 1464 |
|
| 1465 |
return \@newitemsarray; |
| 1466 |
} |
| 1467 |
|
| 1468 |
############################################################################ |
| 1469 |
# Some files contain a $ in their name. epm conflicts with such files. |
| 1470 |
# Solution: Renaming this files, converting "$" to "$$" |
| 1471 |
############################################################################ |
| 1472 |
|
| 1473 |
sub quoting_illegal_filenames |
| 1474 |
{ |
| 1475 |
my ($filesarrayref) = @_; |
| 1476 |
|
| 1477 |
# This function has to be removed as soon as possible! |
| 1478 |
|
| 1479 |
installer::logger::include_header_into_logfile("Renaming illegal filenames:"); |
| 1480 |
|
| 1481 |
for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ ) |
| 1482 |
{ |
| 1483 |
my $onefile = ${$filesarrayref}[$i]; |
| 1484 |
my $filename = $onefile->{'Name'}; |
| 1485 |
|
| 1486 |
if ( $filename =~ /\$/ ) |
| 1487 |
{ |
| 1488 |
my $sourcepath = $onefile->{'sourcepath'}; |
| 1489 |
my $destpath = $onefile->{'destination'}; |
| 1490 |
|
| 1491 |
# sourcepath and destination have to be quoted for epm list file |
| 1492 |
|
| 1493 |
$destpath =~ s/\$/\$\$/g; |
| 1494 |
$sourcepath =~ s/\$/\$\$/g; |
| 1495 |
|
| 1496 |
my $infoline = "ATTENTION: Files: Quoting sourcepath $onefile->{'sourcepath'} to $sourcepath\n"; |
| 1497 |
push( @installer::globals::logfileinfo, $infoline); |
| 1498 |
$infoline = "ATTENTION: Files: Quoting destination path $onefile->{'destination'} to $destpath\n"; |
| 1499 |
push( @installer::globals::logfileinfo, $infoline); |
| 1500 |
|
| 1501 |
$onefile->{'sourcepath'} = $sourcepath; |
| 1502 |
$onefile->{'destination'} = $destpath; |
| 1503 |
} |
| 1504 |
} |
| 1505 |
} |
| 1506 |
|
| 1507 |
############################################################################ |
| 1508 |
# Removing multiple occurrences of same module. |
| 1509 |
############################################################################ |
| 1510 |
|
| 1511 |
sub optimize_list |
| 1512 |
{ |
| 1513 |
my ( $longlist ) = @_; |
| 1514 |
my %tmpHash; |
| 1515 |
|
| 1516 |
$longlist =~ s/^\s+//; |
| 1517 |
$longlist =~ s/\s+$//; |
| 1518 |
$longlist =~ s/\s*,\s*/,/g; |
| 1519 |
|
| 1520 |
@tmpHash{split /,/, $longlist} = (); |
| 1521 |
return join(",", sort keys %tmpHash); |
| 1522 |
} |
| 1523 |
|
| 1524 |
############################################################################### |
| 1525 |
# Add a directory with CREATE flag; save styles for already added directories |
| 1526 |
############################################################################### |
| 1527 |
|
| 1528 |
sub add_directory_with_create_flag_hash |
| 1529 |
{ |
| 1530 |
my ($alldirectoryhash, $directoryname, $specificlanguage, $gid, $styles, $modules) = @_; |
| 1531 |
if ( ! $directoryname ) { installer::exiter::exit_program("No directory name (HostName) set for specified language in gid $gid", "add_directory_with_create_flag_hash"); } |
| 1532 |
my $origdirectoryname = $directoryname; |
| 1533 |
my $newdirincluded = 0; |
| 1534 |
if ( $styles =~ /\bCREATE\b/ ) |
| 1535 |
{ |
| 1536 |
if ( ! $modules ) { installer::exiter::exit_program("No assigned modules found for directory $directoryname", "add_directory_with_create_flag_hash"); } |
| 1537 |
if (!(exists($alldirectoryhash->{$directoryname}))) |
| 1538 |
{ |
| 1539 |
my %directoryhash = (); |
| 1540 |
$directoryhash{'HostName'} = $directoryname; |
| 1541 |
$directoryhash{'specificlanguage'} = $specificlanguage; |
| 1542 |
$directoryhash{'Dir'} = $gid; |
| 1543 |
$directoryhash{'Styles'} = $styles; |
| 1544 |
|
| 1545 |
# saving also the modules |
| 1546 |
$directoryhash{'modules'} = $modules; |
| 1547 |
|
| 1548 |
$alldirectoryhash->{$directoryname} = \%directoryhash; |
| 1549 |
$newdirincluded = 1; |
| 1550 |
|
| 1551 |
# Problem: The $destinationpath can be share/registry/schema/org/openoffice |
| 1552 |
# but not all directories contain files and will be added to this list. |
| 1553 |
# Therefore the path has to be analyzed. |
| 1554 |
|
| 1555 |
while ( $directoryname =~ /(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/ ) # as long as the path contains slashes |
| 1556 |
{ |
| 1557 |
$directoryname = $1; |
| 1558 |
|
| 1559 |
if (!(exists($alldirectoryhash->{$directoryname}))) |
| 1560 |
{ |
| 1561 |
my %directoryhash = (); |
| 1562 |
|
| 1563 |
$directoryhash{'HostName'} = $directoryname; |
| 1564 |
$directoryhash{'specificlanguage'} = $specificlanguage; |
| 1565 |
$directoryhash{'Dir'} = $gid; |
| 1566 |
if ( ! $installer::globals::iswindowsbuild ) { $directoryhash{'Styles'} = "(CREATE)"; } # Exception for Windows? |
| 1567 |
|
| 1568 |
# saving also the modules |
| 1569 |
$directoryhash{'modules'} = $modules; |
| 1570 |
|
| 1571 |
$alldirectoryhash->{$directoryname} = \%directoryhash; |
| 1572 |
} |
| 1573 |
else |
| 1574 |
{ |
| 1575 |
# Adding the modules to the module list! |
| 1576 |
$alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $modules; |
| 1577 |
} |
| 1578 |
} |
| 1579 |
} |
| 1580 |
else |
| 1581 |
{ |
| 1582 |
# Adding the modules to the module list! |
| 1583 |
$alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $modules; |
| 1584 |
|
| 1585 |
while ( $directoryname =~ /(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/ ) # as long as the path contains slashes |
| 1586 |
{ |
| 1587 |
$directoryname = $1; |
| 1588 |
# Adding the modules to the module list! |
| 1589 |
$alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $modules; |
| 1590 |
} |
| 1591 |
} |
| 1592 |
} |
| 1593 |
|
| 1594 |
# Saving the styles for already added directories in function collect_directories_from_filesarray |
| 1595 |
|
| 1596 |
if (( ! $newdirincluded ) && ( $styles ne "" )) |
| 1597 |
{ |
| 1598 |
$styles =~ s/\bWORKSTATION\b//; |
| 1599 |
$styles =~ s/\bCREATE\b//; |
| 1600 |
|
| 1601 |
if (( ! ( $styles =~ /^\s*\(\s*\)\s*$/ )) && ( ! ( $styles =~ /^\s*\(\s*\,\s*\)\s*$/ )) && ( ! ( $styles =~ /^\s*$/ ))) # checking, if there are styles left |
| 1602 |
{ |
| 1603 |
$directoryname = $origdirectoryname; |
| 1604 |
|
| 1605 |
if ( exists($alldirectoryhash->{$directoryname}) ) |
| 1606 |
{ |
| 1607 |
$alldirectoryhash->{$directoryname}->{'Styles'} = $styles; |
| 1608 |
} |
| 1609 |
} |
| 1610 |
} |
| 1611 |
|
| 1612 |
return $alldirectoryhash; |
| 1613 |
} |
| 1614 |
|
| 1615 |
####################################################################### |
| 1616 |
# Collecting all directories needed for the epm list |
| 1617 |
# 1. Looking for all destination paths in the files array |
| 1618 |
# 2. Looking for directories with CREATE flag in the directory array |
| 1619 |
####################################################################### |
| 1620 |
|
| 1621 |
################################## |
| 1622 |
# Collecting directories: Part 1 |
| 1623 |
################################## |
| 1624 |
|
| 1625 |
sub collect_directories_from_filesarray |
| 1626 |
{ |
| 1627 |
my ($filesarrayref, $unixlinksarrayref) = @_; |
| 1628 |
|
| 1629 |
my %alldirectoryhash = (); |
| 1630 |
my @filteredfilesarray = (); # without empty directories |
| 1631 |
foreach my $onefile (@{$filesarrayref}) |
| 1632 |
{ |
| 1633 |
# The "file" can actually be an empty directory added e.g. by gb_Package_add_empty_directory. |
| 1634 |
# TODO/LATER: it would be better if gb_Package_add_empty_directory added empty directories to |
| 1635 |
# "directories with CREATE flag" instead of a filelist. |
| 1636 |
if (-d $onefile->{'sourcepath'}) |
| 1637 |
{ |
| 1638 |
# Do the same as collect_directories_with_create_flag_from_directoryarray does |
| 1639 |
%alldirectoryhash = %{add_directory_with_create_flag_hash(\%alldirectoryhash, $onefile->{'destination'}, $onefile->{'specificlanguage'}, $onefile->{'gid'}, "(CREATE)", $onefile->{'modules'})}; |
| 1640 |
} |
| 1641 |
else { push(@filteredfilesarray, $onefile); } |
| 1642 |
} |
| 1643 |
|
| 1644 |
# Preparing this already as hash, although the only needed value at the moment is the HostName |
| 1645 |
# But also adding: "specificlanguage" and "Dir" (for instance gid_Dir_Program) |
| 1646 |
|
| 1647 |
foreach my $onefile (@filteredfilesarray, @{$unixlinksarrayref}) |
| 1648 |
{ |
| 1649 |
my $destinationpath = $onefile->{'destination'}; |
| 1650 |
|
| 1651 |
installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationpath); |
| 1652 |
$destinationpath =~ s/\Q$installer::globals::separator\E\s*$//; # removing ending slashes or backslashes |
| 1653 |
|
| 1654 |
do |
| 1655 |
{ |
| 1656 |
if (!exists($alldirectoryhash{$destinationpath})) |
| 1657 |
{ |
| 1658 |
my %directoryhash = (); |
| 1659 |
$directoryhash{'HostName'} = $destinationpath; |
| 1660 |
$directoryhash{'specificlanguage'} = $onefile->{'specificlanguage'}; |
| 1661 |
$directoryhash{'Dir'} = $onefile->{'Dir'}; |
| 1662 |
$directoryhash{'modules'} = $onefile->{'modules'}; # NEW, saving modules |
| 1663 |
$directoryhash{'gid'} = $onefile->{'gid'}; |
| 1664 |
|
| 1665 |
$alldirectoryhash{$destinationpath} = \%directoryhash; |
| 1666 |
} |
| 1667 |
else |
| 1668 |
{ |
| 1669 |
# Adding the modules to the module list! |
| 1670 |
$alldirectoryhash{$destinationpath}->{'modules'} .= "," . $onefile->{'modules'}; |
| 1671 |
# Save file's gid iff this directory appears in only a single |
| 1672 |
# file's FILELIST (so that unused directories will be filtered |
| 1673 |
# out in remove_not_required_spellcheckerlanguage_files, based |
| 1674 |
# on gid): |
| 1675 |
if ($alldirectoryhash{$destinationpath}->{'gid'} |
| 1676 |
ne $onefile->{'gid'}) |
| 1677 |
{ |
| 1678 |
$alldirectoryhash{$destinationpath}->{'gid'} = ''; |
| 1679 |
} |
| 1680 |
} |
| 1681 |
} while ($destinationpath =~ s/(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/$1/); # as long as the path contains slashes |
| 1682 |
} |
| 1683 |
|
| 1684 |
# Creating directory array |
| 1685 |
foreach my $destdir ( keys %alldirectoryhash ) |
| 1686 |
{ |
| 1687 |
$alldirectoryhash{$destdir}->{'modules'} = optimize_list($alldirectoryhash{$destdir}->{'modules'}); |
| 1688 |
} |
| 1689 |
|
| 1690 |
@_[0] = \@filteredfilesarray; # out argument |
| 1691 |
return \%alldirectoryhash; |
| 1692 |
} |
| 1693 |
|
| 1694 |
################################## |
| 1695 |
# Collecting directories: Part 2 |
| 1696 |
################################## |
| 1697 |
|
| 1698 |
sub collect_directories_with_create_flag_from_directoryarray |
| 1699 |
{ |
| 1700 |
my ($directoryarrayref, $alldirectoryhash) = @_; |
| 1701 |
|
| 1702 |
my @alldirectories = (); |
| 1703 |
|
| 1704 |
foreach my $onedir (@{$directoryarrayref}) |
| 1705 |
{ |
| 1706 |
$alldirectoryhash = add_directory_with_create_flag_hash($alldirectoryhash, $onedir->{'HostName'}, $onedir->{'specificlanguage'}, $onedir->{'gid'}, $onedir->{'Styles'}, $onedir->{'modules'}); |
| 1707 |
} |
| 1708 |
|
| 1709 |
# Creating directory array |
| 1710 |
foreach my $destdir ( sort keys %{$alldirectoryhash} ) |
| 1711 |
{ |
| 1712 |
$alldirectoryhash->{$destdir}->{'modules'} = optimize_list($alldirectoryhash->{$destdir}->{'modules'}); |
| 1713 |
push(@alldirectories, $alldirectoryhash->{$destdir}); |
| 1714 |
} |
| 1715 |
|
| 1716 |
return \@alldirectories; |
| 1717 |
} |
| 1718 |
|
| 1719 |
################################################# |
| 1720 |
# Determining the destination file of a link |
| 1721 |
################################################# |
| 1722 |
|
| 1723 |
sub get_destination_file_path_for_links |
| 1724 |
{ |
| 1725 |
my ($linksarrayref, $filesarrayref) = @_; |
| 1726 |
|
| 1727 |
my $infoline; |
| 1728 |
|
| 1729 |
for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ ) |
| 1730 |
{ |
| 1731 |
my $fileid = ""; |
| 1732 |
my $onelink = ${$linksarrayref}[$i]; |
| 1733 |
if ( $onelink->{'FileID'} ) { $fileid = $onelink->{'FileID'}; } |
| 1734 |
|
| 1735 |
if (!( $fileid eq "" )) |
| 1736 |
{ |
| 1737 |
my $foundfile = 0; |
| 1738 |
|
| 1739 |
for ( my $j = 0; $j <= $#{$filesarrayref}; $j++ ) |
| 1740 |
{ |
| 1741 |
my $onefile = ${$filesarrayref}[$j]; |
| 1742 |
my $filegid = $onefile->{'gid'}; |
| 1743 |
|
| 1744 |
if ( $filegid eq $fileid ) |
| 1745 |
{ |
| 1746 |
$foundfile = 1; |
| 1747 |
$onelink->{'destinationfile'} = $onefile->{'destination'}; |
| 1748 |
last; |
| 1749 |
} |
| 1750 |
} |
| 1751 |
|
| 1752 |
if (!($foundfile)) |
| 1753 |
{ |
| 1754 |
$infoline = "Warning: FileID $fileid for Link $onelink->{'gid'} not found!\n"; |
| 1755 |
push( @installer::globals::logfileinfo, $infoline); |
| 1756 |
} |
| 1757 |
} |
| 1758 |
} |
| 1759 |
|
| 1760 |
$infoline = "\n"; |
| 1761 |
push( @installer::globals::logfileinfo, $infoline); |
| 1762 |
} |
| 1763 |
|
| 1764 |
################################################# |
| 1765 |
# Determining the destination link of a link |
| 1766 |
################################################# |
| 1767 |
|
| 1768 |
sub get_destination_link_path_for_links |
| 1769 |
{ |
| 1770 |
my ($linksarrayref) = @_; |
| 1771 |
|
| 1772 |
my $infoline; |
| 1773 |
|
| 1774 |
for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ ) |
| 1775 |
{ |
| 1776 |
my $shortcutid = ""; |
| 1777 |
my $onelink = ${$linksarrayref}[$i]; |
| 1778 |
if ( $onelink->{'ShortcutID'} ) { $shortcutid = $onelink->{'ShortcutID'}; } |
| 1779 |
|
| 1780 |
if (!( $shortcutid eq "" )) |
| 1781 |
{ |
| 1782 |
my $foundlink = 0; |
| 1783 |
|
| 1784 |
for ( my $j = 0; $j <= $#{$linksarrayref}; $j++ ) |
| 1785 |
{ |
| 1786 |
my $destlink = ${$linksarrayref}[$j]; |
| 1787 |
my $shortcutgid = $destlink->{'gid'}; |
| 1788 |
|
| 1789 |
if ( $shortcutgid eq $shortcutid ) |
| 1790 |
{ |
| 1791 |
$foundlink = 1; |
| 1792 |
$onelink->{'destinationfile'} = $destlink->{'destination'}; # making key 'destinationfile' |
| 1793 |
last; |
| 1794 |
} |
| 1795 |
} |
| 1796 |
|
| 1797 |
if (!($foundlink)) |
| 1798 |
{ |
| 1799 |
$infoline = "Warning: ShortcutID $shortcutid for Link $onelink->{'gid'} not found!\n"; |
| 1800 |
push( @installer::globals::logfileinfo, $infoline); |
| 1801 |
} |
| 1802 |
} |
| 1803 |
} |
| 1804 |
|
| 1805 |
$infoline = "\n"; |
| 1806 |
push( @installer::globals::logfileinfo, $infoline); |
| 1807 |
} |
| 1808 |
|
| 1809 |
################################################################################### |
| 1810 |
# Items with flag WORKSTATION are not needed (here: links and configurationitems) |
| 1811 |
################################################################################### |
| 1812 |
|
| 1813 |
sub remove_workstation_only_items |
| 1814 |
{ |
| 1815 |
my ($itemarrayref) = @_; |
| 1816 |
|
| 1817 |
my @newitemarray = (); |
| 1818 |
|
| 1819 |
for ( my $i = 0; $i <= $#{$itemarrayref}; $i++ ) |
| 1820 |
{ |
| 1821 |
my $oneitem = ${$itemarrayref}[$i]; |
| 1822 |
my $styles = $oneitem->{'Styles'}; |
| 1823 |
|
| 1824 |
if (( $styles =~ /\bWORKSTATION\b/ ) && |
| 1825 |
(!( $styles =~ /\bNETWORK\b/ )) && |
| 1826 |
(!( $styles =~ /\bSTANDALONE\b/ ))) |
| 1827 |
{ |
| 1828 |
next; # removing this link, it is only needed for a workstation installation |
| 1829 |
} |
| 1830 |
|
| 1831 |
push(@newitemarray, $oneitem); |
| 1832 |
} |
| 1833 |
|
| 1834 |
return \@newitemarray; |
| 1835 |
} |
| 1836 |
|
| 1837 |
################################################ |
| 1838 |
# Resolving relative path in links |
| 1839 |
################################################ |
| 1840 |
|
| 1841 |
sub resolve_links_with_flag_relative |
| 1842 |
{ |
| 1843 |
my ($linksarrayref) = @_; |
| 1844 |
|
| 1845 |
# Before this step is: |
| 1846 |
# destination=program/libsalhelperC52.so.3, this will be the name of the link |
| 1847 |
# destinationfile=program/libsalhelperC52.so.3, this will be the linked file or name |
| 1848 |
# If the flag RELATIVE is set, the paths have to be analyzed. If the flag is not set |
| 1849 |
# (this will not occur in the future?) destinationfile has to be an absolute path name |
| 1850 |
|
| 1851 |
for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ ) |
| 1852 |
{ |
| 1853 |
my $onelink = ${$linksarrayref}[$i]; |
| 1854 |
my $styles = $onelink->{'Styles'}; |
| 1855 |
|
| 1856 |
if ( $styles =~ /\bRELATIVE\b/ ) |
| 1857 |
{ |
| 1858 |
# ToDo: This is only a simple not sufficient mechanism |
| 1859 |
|
| 1860 |
my $destination = $onelink->{'destination'}; |
| 1861 |
my $destinationfile = $onelink->{'destinationfile'}; |
| 1862 |
|
| 1863 |
my $destinationpath = $destination; |
| 1864 |
|
| 1865 |
installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationpath); |
| 1866 |
|
| 1867 |
my $destinationfilepath = $destinationfile; |
| 1868 |
|
| 1869 |
# it is possible, that the destinationfile is no longer part of the files collector |
| 1870 |
if ($destinationfilepath) { installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationfilepath); } |
| 1871 |
else { $destinationfilepath = ""; } |
| 1872 |
|
| 1873 |
if ( $destinationpath eq $destinationfilepath ) |
| 1874 |
{ |
| 1875 |
# link and file are in the same directory |
| 1876 |
# Therefore the path of the file can be removed |
| 1877 |
|
| 1878 |
my $newdestinationfile = $destinationfile; |
| 1879 |
installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$newdestinationfile); |
| 1880 |
|
| 1881 |
$onelink->{'destinationfile'} = $newdestinationfile; |
| 1882 |
} |
| 1883 |
} |
| 1884 |
} |
| 1885 |
} |
| 1886 |
|
| 1887 |
######################################################################## |
| 1888 |
# This function is a helper of function "assigning_modules_to_items" |
| 1889 |
######################################################################## |
| 1890 |
|
| 1891 |
sub insert_for_item ($$$) |
| 1892 |
{ |
| 1893 |
my ($hash, $item, $id) = @_; |
| 1894 |
|
| 1895 |
if (!defined $hash->{$item}) |
| 1896 |
{ |
| 1897 |
my @gids = (); |
| 1898 |
$hash->{$item} = \@gids; |
| 1899 |
} |
| 1900 |
my $gid_list = $hash->{$item}; |
| 1901 |
push @{$gid_list}, $id; |
| 1902 |
$hash->{$item} = $gid_list; |
| 1903 |
} |
| 1904 |
|
| 1905 |
sub build_modulegids_table |
| 1906 |
{ |
| 1907 |
my ($modulesref, $itemname) = @_; |
| 1908 |
|
| 1909 |
my %module_lookup_table = (); |
| 1910 |
|
| 1911 |
# build map of item names to list of respective module gids |
| 1912 |
# containing these items |
| 1913 |
for my $onemodule (@{$modulesref}) |
| 1914 |
{ |
| 1915 |
next if ( ! defined $onemodule->{$itemname} ); |
| 1916 |
# these are the items contained in this module |
| 1917 |
# eg. Files = (gid_a_b_c,gid_d_e_f) |
| 1918 |
my $module_gids = $onemodule->{$itemname}; |
| 1919 |
|
| 1920 |
# prune outer brackets |
| 1921 |
$module_gids =~ s|^\s*\(||g; |
| 1922 |
$module_gids =~ s|\)\s*$||g; |
| 1923 |
for my $id (split (/,/, $module_gids)) |
| 1924 |
{ |
| 1925 |
chomp $id; |
| 1926 |
insert_for_item(\%module_lookup_table, lc ($id), $onemodule->{'gid'}); |
| 1927 |
} |
| 1928 |
} |
| 1929 |
|
| 1930 |
return \%module_lookup_table; |
| 1931 |
} |
| 1932 |
|
| 1933 |
######################################################################## |
| 1934 |
# Items like files do not know their modules |
| 1935 |
# This function is a helper of function "assigning_modules_to_items" |
| 1936 |
######################################################################## |
| 1937 |
|
| 1938 |
sub get_string_of_modulegids_for_itemgid |
| 1939 |
{ |
| 1940 |
my ($module_lookup_table, $modulesref, $itemgid, $itemname) = @_; |
| 1941 |
|
| 1942 |
my $allmodules = ""; |
| 1943 |
my $haslanguagemodule = 0; |
| 1944 |
my %foundmodules = (); |
| 1945 |
|
| 1946 |
my $gid_list = $module_lookup_table->{lc($itemgid)}; |
| 1947 |
|
| 1948 |
for my $gid (@{$gid_list}) |
| 1949 |
{ |
| 1950 |
$foundmodules{$gid} = 1; |
| 1951 |
$allmodules = $allmodules . "," . $gid; |
| 1952 |
# Is this module a language module? This info should be stored at the file. |
| 1953 |
if ( exists($installer::globals::alllangmodules{$gid}) ) { $haslanguagemodule = 1; } |
| 1954 |
} |
| 1955 |
|
| 1956 |
$allmodules =~ s/^\s*\,//; # removing leading comma |
| 1957 |
|
| 1958 |
# Check: All modules or no module must have flag LANGUAGEMODULE |
| 1959 |
if ( $haslanguagemodule ) |
| 1960 |
{ |
| 1961 |
my $isreallylanguagemodule = _key_in_a_is_also_key_in_b(\%foundmodules, \%installer::globals::alllangmodules); |
| 1962 |
if ( ! $isreallylanguagemodule ) { installer::exiter::exit_program("ERROR: \"$itemgid\" is assigned to modules with flag \"LANGUAGEMODULE\" and also to modules without this flag! Modules: $allmodules", "get_string_of_modulegids_for_itemgid"); } |
| 1963 |
} |
| 1964 |
|
| 1965 |
return ($allmodules, $haslanguagemodule); |
| 1966 |
} |
| 1967 |
|
| 1968 |
######################################################## |
| 1969 |
# Items like files do not know their modules |
| 1970 |
# This function add the {'modules'} to these items |
| 1971 |
######################################################## |
| 1972 |
|
| 1973 |
sub assigning_modules_to_items |
| 1974 |
{ |
| 1975 |
my ($modulesref, $itemsref, $itemname) = @_; |
| 1976 |
|
| 1977 |
my $infoline = ""; |
| 1978 |
my $languageassignmenterror = 0; |
| 1979 |
my @languageassignmenterrors = (); |
| 1980 |
|
| 1981 |
my $module_lookup_table = build_modulegids_table($modulesref, $itemname); |
| 1982 |
|
| 1983 |
for my $oneitem (@{$itemsref}) |
| 1984 |
{ |
| 1985 |
my $itemgid = $oneitem->{'gid'}; |
| 1986 |
|
| 1987 |
my $styles = ""; |
| 1988 |
if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; } |
| 1989 |
if (( $itemname eq "Dirs" ) && ( ! ( $styles =~ /\bCREATE\b/ ))) { next; } |
| 1990 |
|
| 1991 |
if ( $itemgid eq "" ) |
| 1992 |
{ |
| 1993 |
installer::exiter::exit_program("ERROR in item collection: No gid for item $oneitem->{'Name'}", "assigning_modules_to_items"); |
| 1994 |
} |
| 1995 |
|
| 1996 |
# every item can belong to many modules |
| 1997 |
|
| 1998 |
my ($modulegids, $haslanguagemodule) = get_string_of_modulegids_for_itemgid($module_lookup_table, $modulesref, $itemgid, $itemname); |
| 1999 |
|
| 2000 |
if ($modulegids eq "") |
| 2001 |
{ |
| 2002 |
installer::exiter::exit_program("ERROR in file collection: No module found for $itemname $itemgid", "assigning_modules_to_items"); |
| 2003 |
} |
| 2004 |
|
| 2005 |
$oneitem->{'modules'} = $modulegids; |
| 2006 |
$oneitem->{'haslanguagemodule'} = $haslanguagemodule; |
| 2007 |
|
| 2008 |
# Important check: "ismultilingual" and "haslanguagemodule" must have the same value ! |
| 2009 |
if (( $oneitem->{'ismultilingual'} ) && ( ! $oneitem->{'haslanguagemodule'} )) |
| 2010 |
{ |
| 2011 |
$infoline = "Error: \"$oneitem->{'gid'}\" is multi lingual, but not in language pack (Assigned module: $modulegids)!\n"; |
| 2012 |
push( @installer::globals::globallogfileinfo, $infoline); |
| 2013 |
push( @languageassignmenterrors, $infoline ); |
| 2014 |
$languageassignmenterror = 1; |
| 2015 |
} |
| 2016 |
if (( $oneitem->{'haslanguagemodule'} ) && ( ! $oneitem->{'ismultilingual'} )) |
| 2017 |
{ |
| 2018 |
$infoline = "Error: \"$oneitem->{'gid'}\" is in language pack, but not multi lingual (Assigned module: $modulegids)!\n"; |
| 2019 |
push( @installer::globals::globallogfileinfo, $infoline); |
| 2020 |
push( @languageassignmenterrors, $infoline ); |
| 2021 |
$languageassignmenterror = 1; |
| 2022 |
} |
| 2023 |
} |
| 2024 |
|
| 2025 |
if ($languageassignmenterror) |
| 2026 |
{ |
| 2027 |
for ( my $i = 0; $i <= $#languageassignmenterrors; $i++ ) { print "$languageassignmenterrors[$i]"; } |
| 2028 |
installer::exiter::exit_program("ERROR: Incorrect assignments for language packs.", "assigning_modules_to_items"); |
| 2029 |
} |
| 2030 |
|
| 2031 |
} |
| 2032 |
|
| 2033 |
################################################################################################# |
| 2034 |
# Root path (for instance /opt/openofficeorg20) needs to be added to directories, files and links |
| 2035 |
################################################################################################# |
| 2036 |
|
| 2037 |
sub add_rootpath_to_directories |
| 2038 |
{ |
| 2039 |
my ($dirsref, $rootpath) = @_; |
| 2040 |
|
| 2041 |
for ( my $i = 0; $i <= $#{$dirsref}; $i++ ) |
| 2042 |
{ |
| 2043 |
my $onedir = ${$dirsref}[$i]; |
| 2044 |
my $dir = ""; |
| 2045 |
|
| 2046 |
if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; } |
| 2047 |
|
| 2048 |
if (!($dir =~ /\bPREDEFINED_/ )) |
| 2049 |
{ |
| 2050 |
my $hostname = $onedir->{'HostName'}; |
| 2051 |
$hostname = $rootpath . $installer::globals::separator . $hostname; |
| 2052 |
$onedir->{'HostName'} = $hostname; |
| 2053 |
} |
| 2054 |
|
| 2055 |
# added |
| 2056 |
|
| 2057 |
if ( $dir =~ /\bPREDEFINED_PROGDIR\b/ ) |
| 2058 |
{ |
| 2059 |
my $hostname = $onedir->{'HostName'}; |
| 2060 |
if ( $hostname eq "" ) { $onedir->{'HostName'} = $rootpath; } |
| 2061 |
else { $onedir->{'HostName'} = $rootpath . $installer::globals::separator . $hostname; } |
| 2062 |
} |
| 2063 |
} |
| 2064 |
} |
| 2065 |
|
| 2066 |
sub add_rootpath_to_files |
| 2067 |
{ |
| 2068 |
my ($filesref, $rootpath) = @_; |
| 2069 |
|
| 2070 |
for ( my $i = 0; $i <= $#{$filesref}; $i++ ) |
| 2071 |
{ |
| 2072 |
my $onefile = ${$filesref}[$i]; |
| 2073 |
my $destination = $onefile->{'destination'}; |
| 2074 |
$destination = $rootpath . $installer::globals::separator . $destination; |
| 2075 |
$onefile->{'destination'} = $destination; |
| 2076 |
} |
| 2077 |
} |
| 2078 |
|
| 2079 |
sub add_rootpath_to_links |
| 2080 |
{ |
| 2081 |
my ($linksref, $rootpath) = @_; |
| 2082 |
|
| 2083 |
for ( my $i = 0; $i <= $#{$linksref}; $i++ ) |
| 2084 |
{ |
| 2085 |
my $onelink = ${$linksref}[$i]; |
| 2086 |
my $styles = $onelink->{'Styles'}; |
| 2087 |
|
| 2088 |
my $destination = $onelink->{'destination'}; |
| 2089 |
$destination = $rootpath . $installer::globals::separator . $destination; |
| 2090 |
$onelink->{'destination'} = $destination; |
| 2091 |
|
| 2092 |
if (!($styles =~ /\bRELATIVE\b/ )) # for absolute links |
| 2093 |
{ |
| 2094 |
my $destinationfile = $onelink->{'destinationfile'}; |
| 2095 |
$destinationfile = $rootpath . $installer::globals::separator . $destinationfile; |
| 2096 |
$onelink->{'destinationfile'} = $destinationfile; |
| 2097 |
} |
| 2098 |
} |
| 2099 |
} |
| 2100 |
|
| 2101 |
################################################################################# |
| 2102 |
# Collecting all parent gids |
| 2103 |
################################################################################# |
| 2104 |
|
| 2105 |
sub collect_all_parent_feature |
| 2106 |
{ |
| 2107 |
my ($modulesref) = @_; |
| 2108 |
|
| 2109 |
my @allparents = (); |
| 2110 |
|
| 2111 |
my $found_root_module = 0; |
| 2112 |
|
| 2113 |
for ( my $i = 0; $i <= $#{$modulesref}; $i++ ) |
| 2114 |
{ |
| 2115 |
my $onefeature = ${$modulesref}[$i]; |
| 2116 |
|
| 2117 |
my $parentgid = ""; |
| 2118 |
if ( $onefeature->{'ParentID'} ) |
| 2119 |
{ |
| 2120 |
$parentgid = $onefeature->{'ParentID'}; |
| 2121 |
} |
| 2122 |
|
| 2123 |
if ( $parentgid ne "" ) |
| 2124 |
{ |
| 2125 |
if (! grep {$_ eq $parentgid} @allparents) |
| 2126 |
{ |
| 2127 |
push(@allparents, $parentgid); |
| 2128 |
} |
| 2129 |
} |
| 2130 |
|
| 2131 |
# Setting the global root module |
| 2132 |
|
| 2133 |
if ( $parentgid eq "" ) |
| 2134 |
{ |
| 2135 |
if ( $found_root_module ) { installer::exiter::exit_program("ERROR: Only one module without ParentID or with empty ParentID allowed ($installer::globals::rootmodulegid, $onefeature->{'gid'}).", "collect_all_parent_feature"); } |
| 2136 |
$installer::globals::rootmodulegid = $onefeature->{'gid'}; |
| 2137 |
$found_root_module = 1; |
| 2138 |
my $infoline = "Setting Root Module: $installer::globals::rootmodulegid\n"; |
| 2139 |
push( @installer::globals::globallogfileinfo, $infoline); |
| 2140 |
} |
| 2141 |
|
| 2142 |
if ( ! $found_root_module ) { installer::exiter::exit_program("ERROR: Could not define root module. No module without ParentID or with empty ParentID exists.", "collect_all_parent_feature"); } |
| 2143 |
|
| 2144 |
} |
| 2145 |
|
| 2146 |
return \@allparents; |
| 2147 |
} |
| 2148 |
|
| 2149 |
################################################################################# |
| 2150 |
# Checking for every feature, whether it has children |
| 2151 |
################################################################################# |
| 2152 |
|
| 2153 |
sub set_children_flag |
| 2154 |
{ |
| 2155 |
my ($modulesref) = @_; |
| 2156 |
|
| 2157 |
my $allparents = collect_all_parent_feature($modulesref); |
| 2158 |
|
| 2159 |
for ( my $i = 0; $i <= $#{$modulesref}; $i++ ) |
| 2160 |
{ |
| 2161 |
my $onefeature = ${$modulesref}[$i]; |
| 2162 |
my $gid = $onefeature->{'gid'}; |
| 2163 |
|
| 2164 |
# is this gid a parent? |
| 2165 |
|
| 2166 |
if ( grep {$_ eq $gid} @{$allparents} ) |
| 2167 |
{ |
| 2168 |
$onefeature->{'has_children'} = 1; |
| 2169 |
} |
| 2170 |
else |
| 2171 |
{ |
| 2172 |
$onefeature->{'has_children'} = 0; |
| 2173 |
} |
| 2174 |
} |
| 2175 |
} |
| 2176 |
|
| 2177 |
################################################################################# |
| 2178 |
# All modules, that use a template module, do now get the assignments of |
| 2179 |
# the template module. |
| 2180 |
################################################################################# |
| 2181 |
|
| 2182 |
sub resolve_assigned_modules |
| 2183 |
{ |
| 2184 |
my ($modulesref) = @_; |
| 2185 |
|
| 2186 |
# collecting all template modules |
| 2187 |
|
| 2188 |
my %directaccess = (); |
| 2189 |
|
| 2190 |
for ( my $i = 0; $i <= $#{$modulesref}; $i++ ) |
| 2191 |
{ |
| 2192 |
my $onefeature = ${$modulesref}[$i]; |
| 2193 |
my $styles = ""; |
| 2194 |
if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; } |
| 2195 |
if ( $styles =~ /\bTEMPLATEMODULE\b/ ) { $directaccess{$onefeature->{'gid'}} = $onefeature; } |
| 2196 |
|
| 2197 |
# also looking for module with flag ROOT_BRAND_PACKAGE, to save is for further usage |
| 2198 |
if ( $styles =~ /\bROOT_BRAND_PACKAGE\b/ ) |
| 2199 |
{ |
| 2200 |
$installer::globals::rootbrandpackage = $onefeature->{'gid'}; |
| 2201 |
$installer::globals::rootbrandpackageset = 1; |
| 2202 |
} |
| 2203 |
} |
| 2204 |
|
| 2205 |
# looking, where template modules are assigned |
| 2206 |
|
| 2207 |
for ( my $i = 0; $i <= $#{$modulesref}; $i++ ) |
| 2208 |
{ |
| 2209 |
my $onefeature = ${$modulesref}[$i]; |
| 2210 |
if ( $onefeature->{'Assigns'} ) |
| 2211 |
{ |
| 2212 |
my $templategid = $onefeature->{'Assigns'}; |
| 2213 |
|
| 2214 |
if ( ! exists($directaccess{$templategid}) ) |
| 2215 |
{ |
| 2216 |
installer::exiter::exit_program("ERROR: Did not find definition of assigned template module \"$templategid\"", "resolve_assigned_modules"); |
| 2217 |
} |
| 2218 |
|
| 2219 |
# Currently no merging of Files, Dirs, ... |
| 2220 |
# This has to be included here, if it is required |
| 2221 |
my @items_at_modules = ("Files", "Dirs", "Unixlinks"); |
| 2222 |
for my $item (@items_at_modules) |
| 2223 |
{ |
| 2224 |
if ( exists($directaccess{$templategid}->{$item}) ) { $onefeature->{$item} = $directaccess{$templategid}->{$item}; } |
| 2225 |
} |
| 2226 |
} |
| 2227 |
} |
| 2228 |
} |
| 2229 |
|
| 2230 |
################################################################################# |
| 2231 |
# Removing the template modules from the list, after all |
| 2232 |
# assignments are transferred to the "real" modules. |
| 2233 |
################################################################################# |
| 2234 |
|
| 2235 |
sub remove_template_modules |
| 2236 |
{ |
| 2237 |
my ($modulesref) = @_; |
| 2238 |
|
| 2239 |
my @modules = (); |
| 2240 |
|
| 2241 |
for ( my $i = 0; $i <= $#{$modulesref}; $i++ ) |
| 2242 |
{ |
| 2243 |
my $onefeature = ${$modulesref}[$i]; |
| 2244 |
my $styles = ""; |
| 2245 |
if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; } |
| 2246 |
if ( $styles =~ /\bTEMPLATEMODULE\b/ ) { next; } |
| 2247 |
|
| 2248 |
push(@modules, $onefeature); |
| 2249 |
} |
| 2250 |
|
| 2251 |
return \@modules; |
| 2252 |
} |
| 2253 |
|
| 2254 |
################################################################################# |
| 2255 |
# Collecting all modules with flag LANGUAGEMODULE in a global |
| 2256 |
# collector. |
| 2257 |
################################################################################# |
| 2258 |
|
| 2259 |
sub collect_all_languagemodules |
| 2260 |
{ |
| 2261 |
my ($modulesref) = @_; |
| 2262 |
|
| 2263 |
for ( my $i = 0; $i <= $#{$modulesref}; $i++ ) |
| 2264 |
{ |
| 2265 |
my $onefeature = ${$modulesref}[$i]; |
| 2266 |
my $styles = ""; |
| 2267 |
if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; } |
| 2268 |
if ( $styles =~ /\bLANGUAGEMODULE\b/ ) |
| 2269 |
{ |
| 2270 |
if ( ! exists($onefeature->{'Language'}) ) { installer::exiter::exit_program("ERROR: \"$onefeature->{'gid'}\" has flag LANGUAGEMODULE, but does not know its language!", "collect_all_languagemodules"); } |
| 2271 |
$installer::globals::alllangmodules{$onefeature->{'gid'}} = $onefeature->{'Language'}; |
| 2272 |
# Collecting also the english names, that are used for nsis unpack directory for language packs |
| 2273 |
my $lang = $onefeature->{'Language'}; |
| 2274 |
my $name = ""; |
| 2275 |
foreach my $localkey ( keys %{$onefeature} ) |
| 2276 |
{ |
| 2277 |
if ( $localkey =~ /^\s*Name\s*\(\s*en-US\s*\)\s*$/ ) |
| 2278 |
{ |
| 2279 |
$installer::globals::all_english_languagestrings{$lang} = $onefeature->{$localkey}; |
| 2280 |
} |
| 2281 |
} |
| 2282 |
} |
| 2283 |
} |
| 2284 |
} |
| 2285 |
|
| 2286 |
################################################################################# |
| 2287 |
# Selecting from all collected english language strings those, that are really |
| 2288 |
# required in this installation set. |
| 2289 |
################################################################################# |
| 2290 |
|
| 2291 |
sub select_required_language_strings |
| 2292 |
{ |
| 2293 |
my ($modulesref) = @_; |
| 2294 |
|
| 2295 |
for ( my $i = 0; $i <= $#{$modulesref}; $i++ ) |
| 2296 |
{ |
| 2297 |
my $onefeature = ${$modulesref}[$i]; |
| 2298 |
my $styles = ""; |
| 2299 |
if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; } |
| 2300 |
if ( $styles =~ /\bLANGUAGEMODULE\b/ ) |
| 2301 |
{ |
| 2302 |
if ( ! exists($onefeature->{'Language'}) ) { installer::exiter::exit_program("ERROR: \"$onefeature->{'gid'}\" has flag LANGUAGEMODULE, but does not know its language!", "select_required_language_strings"); } |
| 2303 |
my $lang = $onefeature->{'Language'}; |
| 2304 |
|
| 2305 |
if (( exists($installer::globals::all_english_languagestrings{$lang}) ) && ( ! exists($installer::globals::all_required_english_languagestrings{$lang}) )) |
| 2306 |
{ |
| 2307 |
$installer::globals::all_required_english_languagestrings{$lang} = $installer::globals::all_english_languagestrings{$lang}; |
| 2308 |
} |
| 2309 |
} |
| 2310 |
} |
| 2311 |
} |
| 2312 |
|
| 2313 |
################################################ |
| 2314 |
# Controlling that all keys in hash A are |
| 2315 |
# also key in hash B. |
| 2316 |
################################################ |
| 2317 |
|
| 2318 |
sub _key_in_a_is_also_key_in_b |
| 2319 |
{ |
| 2320 |
my ( $hashref_a, $hashref_b) = @_; |
| 2321 |
|
| 2322 |
my $returnvalue = 1; |
| 2323 |
|
| 2324 |
my $key; |
| 2325 |
foreach $key ( keys %{$hashref_a} ) |
| 2326 |
{ |
| 2327 |
if ( ! exists($hashref_b->{$key}) ) |
| 2328 |
{ |
| 2329 |
print "*****\n"; |
| 2330 |
foreach my $keyb ( keys %{$hashref_b} ) { print "$keyb : $hashref_b->{$keyb}\n"; } |
| 2331 |
print "*****\n"; |
| 2332 |
$returnvalue = 0; |
| 2333 |
} |
| 2334 |
} |
| 2335 |
|
| 2336 |
return $returnvalue; |
| 2337 |
} |
| 2338 |
|
| 2339 |
1; |