| 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::ziplist; |
| 20 |
|
| 21 |
use strict; |
| 22 |
use warnings; |
| 23 |
|
| 24 |
use base 'Exporter'; |
| 25 |
|
| 26 |
use File::Spec::Functions qw(rel2abs); |
| 27 |
|
| 28 |
use installer::converter; |
| 29 |
use installer::exiter; |
| 30 |
use installer::files; |
| 31 |
use installer::globals; |
| 32 |
use installer::logger; |
| 33 |
use installer::remover; |
| 34 |
use installer::systemactions; |
| 35 |
|
| 36 |
our @EXPORT_OK = qw(read_ziplist); |
| 37 |
|
| 38 |
sub read_ziplist { |
| 39 |
my $ziplistname = shift; |
| 40 |
|
| 41 |
installer::logger::globallog("zip list file: $ziplistname"); |
| 42 |
|
| 43 |
my $ziplistref = installer::files::read_file($ziplistname); |
| 44 |
|
| 45 |
installer::logger::print_message( "... analyzing $ziplistname ... \n" ); |
| 46 |
|
| 47 |
my ($productblockref, $parent) = getproductblock($ziplistref, $installer::globals::product, 1); # product block from zip.lst |
| 48 |
|
| 49 |
my ($settingsblockref, undef) = getproductblock($productblockref, "Settings", 0); # settings block from zip.lst |
| 50 |
$settingsblockref = analyze_settings_block($settingsblockref); # select data from settings block in zip.lst |
| 51 |
|
| 52 |
my $allsettingsarrayref = get_settings_from_ziplist($settingsblockref); |
| 53 |
my $allvariablesarrayref = get_variables_from_ziplist($settingsblockref); |
| 54 |
|
| 55 |
my ($globalproductblockref, undef) = getproductblock($ziplistref, $installer::globals::globalblock, 0); # global product block from zip.lst |
| 56 |
|
| 57 |
while (defined $parent) { |
| 58 |
my $parentproductblockref; |
| 59 |
($parentproductblockref, $parent) = getproductblock($ziplistref, $parent, 1); |
| 60 |
my ($parentsettingsblockref, undef) = getproductblock($parentproductblockref, "Settings", 0); |
| 61 |
$parentsettingsblockref = analyze_settings_block($parentsettingsblockref); |
| 62 |
my $allparentsettingsarrayref = get_settings_from_ziplist($parentsettingsblockref); |
| 63 |
my $allparentvariablesarrayref = get_variables_from_ziplist($parentsettingsblockref); |
| 64 |
$allsettingsarrayref = |
| 65 |
installer::converter::combine_arrays_from_references_first_win( |
| 66 |
$allsettingsarrayref, $allparentsettingsarrayref) |
| 67 |
if $#{$allparentsettingsarrayref} > -1; |
| 68 |
$allvariablesarrayref = |
| 69 |
installer::converter::combine_arrays_from_references_first_win( |
| 70 |
$allvariablesarrayref, $allparentvariablesarrayref) |
| 71 |
if $#{$allparentvariablesarrayref} > -1; |
| 72 |
} |
| 73 |
|
| 74 |
if ( @{$globalproductblockref} ) { |
| 75 |
my ($globalsettingsblockref, undef) = getproductblock($globalproductblockref, "Settings", 0); # settings block from zip.lst |
| 76 |
|
| 77 |
$globalsettingsblockref = analyze_settings_block($globalsettingsblockref); # select data from settings block in zip.lst |
| 78 |
|
| 79 |
my $allglobalsettingsarrayref = get_settings_from_ziplist($globalsettingsblockref); |
| 80 |
|
| 81 |
my $allglobalvariablesarrayref = get_variables_from_ziplist($globalsettingsblockref); |
| 82 |
|
| 83 |
if ( @{$allglobalsettingsarrayref} ) { |
| 84 |
$allsettingsarrayref = installer::converter::combine_arrays_from_references_first_win($allsettingsarrayref, $allglobalsettingsarrayref); |
| 85 |
} |
| 86 |
if ( @{$allglobalvariablesarrayref} ) { |
| 87 |
$allvariablesarrayref = installer::converter::combine_arrays_from_references_first_win($allvariablesarrayref, $allglobalvariablesarrayref); |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
$allsettingsarrayref = remove_multiples_from_ziplist($allsettingsarrayref); |
| 92 |
$allvariablesarrayref = remove_multiples_from_ziplist($allvariablesarrayref); |
| 93 |
|
| 94 |
replace_variables_in_ziplist_variables($allvariablesarrayref); |
| 95 |
|
| 96 |
my $allvariableshashref = installer::converter::convert_array_to_hash($allvariablesarrayref); |
| 97 |
|
| 98 |
set_default_productversion_if_required($allvariableshashref); |
| 99 |
add_variables_to_allvariableshashref($allvariableshashref); |
| 100 |
overwrite_branding( $allvariableshashref ); |
| 101 |
|
| 102 |
return $allsettingsarrayref, $allvariableshashref; |
| 103 |
} |
| 104 |
|
| 105 |
################################################# |
| 106 |
# Getting data from path file and zip list file |
| 107 |
################################################# |
| 108 |
|
| 109 |
sub getproductblock |
| 110 |
{ |
| 111 |
my ($fileref, $search, $inheritance) = @_; |
| 112 |
|
| 113 |
my @searchblock = (); |
| 114 |
my $searchexists = 0; |
| 115 |
my $record = 0; |
| 116 |
my $count = 0; |
| 117 |
my $line; |
| 118 |
my $inh = $inheritance ? '(?::\s*(\S+)\s*)?' : ""; |
| 119 |
my $parent; |
| 120 |
|
| 121 |
for ( my $i = 0; $i <= $#{$fileref}; $i++ ) |
| 122 |
{ |
| 123 |
$line = ${$fileref}[$i]; |
| 124 |
|
| 125 |
if ( $line =~ /^\s*\Q$search\E\s*$inh$/i ) # case insensitive |
| 126 |
{ |
| 127 |
$record = 1; |
| 128 |
$searchexists = 1; |
| 129 |
$parent = $1 if $inheritance; |
| 130 |
} |
| 131 |
|
| 132 |
if ($record) |
| 133 |
{ |
| 134 |
push(@searchblock, $line); |
| 135 |
} |
| 136 |
|
| 137 |
if ( ($record) && ($line =~ /\{/) ) |
| 138 |
{ |
| 139 |
$count++; |
| 140 |
} |
| 141 |
|
| 142 |
if ( ($record) && ($line =~ /\}/) ) |
| 143 |
{ |
| 144 |
$count--; |
| 145 |
} |
| 146 |
|
| 147 |
if ( ($record) && ($line =~ /\}/) && ( $count == 0 ) ) |
| 148 |
{ |
| 149 |
$record = 0; |
| 150 |
} |
| 151 |
} |
| 152 |
|
| 153 |
if (( ! $searchexists ) && ( $search ne $installer::globals::globalblock )) |
| 154 |
{ |
| 155 |
if ($search eq $installer::globals::product ) |
| 156 |
{ |
| 157 |
installer::exiter::exit_program("ERROR: Product $installer::globals::product not defined in $installer::globals::ziplistname", "getproductblock"); |
| 158 |
} |
| 159 |
else # this is not possible |
| 160 |
{ |
| 161 |
installer::exiter::exit_program("ERROR: Unknown value for $search in getproductblock()", "getproductblock"); |
| 162 |
} |
| 163 |
} |
| 164 |
|
| 165 |
return (\@searchblock, $parent); |
| 166 |
} |
| 167 |
|
| 168 |
############################################### |
| 169 |
# Analyzing the settings in the zip list file |
| 170 |
############################################### |
| 171 |
|
| 172 |
sub analyze_settings_block |
| 173 |
{ |
| 174 |
my ($blockref) = @_; |
| 175 |
|
| 176 |
my @newsettingsblock = (); |
| 177 |
my $record = 1; |
| 178 |
my $counter = 0; |
| 179 |
|
| 180 |
# Allowed values in settings block: |
| 181 |
# "Settings", "Variables", "unix" (for destination path and logfile) |
| 182 |
|
| 183 |
# Comment line in settings block begin with "#" or ";" |
| 184 |
|
| 185 |
for ( my $i = 0; $i <= $#{$blockref}; $i++ ) |
| 186 |
{ |
| 187 |
my $line = ${$blockref}[$i]; |
| 188 |
my $nextline = ""; |
| 189 |
|
| 190 |
if ( ${$blockref}[$i+1] ) { $nextline = ${$blockref}[$i+1]; } |
| 191 |
|
| 192 |
# removing comment lines |
| 193 |
|
| 194 |
if (($line =~ /^\s*\#/) || ($line =~ /^\s*\;/)) |
| 195 |
{ |
| 196 |
next; |
| 197 |
} |
| 198 |
|
| 199 |
# complete blocks of unknown strings are not recorded |
| 200 |
|
| 201 |
if ((!($line =~ /^\s*\Q$installer::globals::build\E\s*$/i)) && |
| 202 |
(!($line =~ /^\s*\bSettings\b\s*$/i)) && |
| 203 |
(!($line =~ /^\s*\bVariables\b\s*$/i)) && |
| 204 |
(!($line =~ /^\s*\bunix\b\s*$/i)) && |
| 205 |
($nextline =~ /^\s*\{\s*$/i)) |
| 206 |
{ |
| 207 |
$record = 0; |
| 208 |
next; # continue with next $i |
| 209 |
} |
| 210 |
|
| 211 |
if (!( $record )) |
| 212 |
{ |
| 213 |
if ($line =~ /^\s*\{\s*$/i) |
| 214 |
{ |
| 215 |
$counter++; |
| 216 |
} |
| 217 |
|
| 218 |
if ($line =~ /^\s*\}\s*$/i) |
| 219 |
{ |
| 220 |
$counter--; |
| 221 |
} |
| 222 |
|
| 223 |
if ($counter == 0) |
| 224 |
{ |
| 225 |
$record = 1; |
| 226 |
next; # continue with next $i |
| 227 |
} |
| 228 |
} |
| 229 |
|
| 230 |
if ($record) |
| 231 |
{ |
| 232 |
push(@newsettingsblock, $line); |
| 233 |
} |
| 234 |
} |
| 235 |
|
| 236 |
return \@newsettingsblock; |
| 237 |
} |
| 238 |
|
| 239 |
######################################## |
| 240 |
# Settings in zip list file |
| 241 |
######################################## |
| 242 |
|
| 243 |
sub get_settings_from_ziplist |
| 244 |
{ |
| 245 |
my ($blockref) = @_; |
| 246 |
|
| 247 |
my @allsettings = (); |
| 248 |
my $isvariables = 0; |
| 249 |
my $counter = 0; |
| 250 |
my $variablescounter = 0; |
| 251 |
|
| 252 |
# Take all settings from the settings block |
| 253 |
# Do not take the variables from the settings block |
| 254 |
# If a setting is defined more than once, take the |
| 255 |
# setting with the largest counter (open brackets) |
| 256 |
|
| 257 |
for ( my $i = 0; $i <= $#{$blockref}; $i++ ) |
| 258 |
{ |
| 259 |
my $line = ${$blockref}[$i]; |
| 260 |
my $nextline = ""; |
| 261 |
|
| 262 |
if ( ${$blockref}[$i+1] ) { $nextline = ${$blockref}[$i+1]; } |
| 263 |
|
| 264 |
if (($line =~ /^\s*\S+\s*$/i) && |
| 265 |
($nextline =~ /^\s*\{\s*$/i) && |
| 266 |
(!($line =~ /^\s*Variables\s*$/i))) |
| 267 |
{ |
| 268 |
next; |
| 269 |
} |
| 270 |
|
| 271 |
if ($line =~ /^\s*Variables\s*$/i) |
| 272 |
{ |
| 273 |
# This is a block of variables |
| 274 |
|
| 275 |
$isvariables = 1; |
| 276 |
next; |
| 277 |
} |
| 278 |
|
| 279 |
if ($line =~ /^\s*\{\s*$/i) |
| 280 |
{ |
| 281 |
if ($isvariables) |
| 282 |
{ |
| 283 |
$variablescounter++; |
| 284 |
} |
| 285 |
else |
| 286 |
{ |
| 287 |
$counter++; |
| 288 |
} |
| 289 |
|
| 290 |
next; |
| 291 |
} |
| 292 |
|
| 293 |
if ($line =~ /^\s*\}\s*$/i) |
| 294 |
{ |
| 295 |
if ($isvariables) |
| 296 |
{ |
| 297 |
$variablescounter--; |
| 298 |
|
| 299 |
if ($variablescounter == 0) |
| 300 |
{ |
| 301 |
$isvariables = 0; |
| 302 |
} |
| 303 |
} |
| 304 |
else |
| 305 |
{ |
| 306 |
$counter--; |
| 307 |
} |
| 308 |
|
| 309 |
next; |
| 310 |
} |
| 311 |
|
| 312 |
if ($isvariables) |
| 313 |
{ |
| 314 |
next; |
| 315 |
} |
| 316 |
|
| 317 |
installer::remover::remove_leading_and_ending_whitespaces(\$line); |
| 318 |
|
| 319 |
$line .= "\t##$counter##\n"; |
| 320 |
|
| 321 |
push(@allsettings, $line); |
| 322 |
} |
| 323 |
|
| 324 |
return \@allsettings; |
| 325 |
} |
| 326 |
|
| 327 |
####################################### |
| 328 |
# Variables from zip list file |
| 329 |
####################################### |
| 330 |
|
| 331 |
sub get_variables_from_ziplist |
| 332 |
{ |
| 333 |
my ($blockref) = @_; |
| 334 |
|
| 335 |
my @allvariables = (); |
| 336 |
my $isvariables = 0; |
| 337 |
my $counter = 0; |
| 338 |
my $variablescounter = 0; |
| 339 |
my $countersum = 0; |
| 340 |
|
| 341 |
# Take all variables from the settings block |
| 342 |
# Do not take the other settings from the settings block |
| 343 |
# If a variable is defined more than once, take the |
| 344 |
# variable with the largest counter (open brackets) |
| 345 |
|
| 346 |
for ( my $i = 0; $i <= $#{$blockref}; $i++ ) |
| 347 |
{ |
| 348 |
my $line = ${$blockref}[$i]; |
| 349 |
my $nextline = ${$blockref}[$i+1]; |
| 350 |
|
| 351 |
if ($line =~ /^\s*Variables\s*$/i) |
| 352 |
{ |
| 353 |
# This is a block of variables |
| 354 |
|
| 355 |
$isvariables = 1; |
| 356 |
next; |
| 357 |
} |
| 358 |
|
| 359 |
if ($line =~ /^\s*\{\s*$/i) |
| 360 |
{ |
| 361 |
if ($isvariables) |
| 362 |
{ |
| 363 |
$variablescounter++; |
| 364 |
} |
| 365 |
else |
| 366 |
{ |
| 367 |
$counter++; |
| 368 |
} |
| 369 |
|
| 370 |
next; |
| 371 |
} |
| 372 |
|
| 373 |
if ($line =~ /^\s*\}\s*$/i) |
| 374 |
{ |
| 375 |
if ($isvariables) |
| 376 |
{ |
| 377 |
$variablescounter--; |
| 378 |
|
| 379 |
if ($variablescounter == 0) |
| 380 |
{ |
| 381 |
$isvariables = 0; |
| 382 |
} |
| 383 |
} |
| 384 |
else |
| 385 |
{ |
| 386 |
$counter--; |
| 387 |
} |
| 388 |
|
| 389 |
next; |
| 390 |
} |
| 391 |
|
| 392 |
if (!($isvariables)) |
| 393 |
{ |
| 394 |
next; |
| 395 |
} |
| 396 |
|
| 397 |
$countersum = $counter + $variablescounter; |
| 398 |
|
| 399 |
installer::remover::remove_leading_and_ending_whitespaces(\$line); |
| 400 |
|
| 401 |
$line .= "\t##$countersum##\n"; |
| 402 |
|
| 403 |
push(@allvariables, $line); |
| 404 |
} |
| 405 |
|
| 406 |
return \@allvariables; |
| 407 |
} |
| 408 |
|
| 409 |
####################################################################### |
| 410 |
# Removing multiple variables and settings, defined in zip list file |
| 411 |
####################################################################### |
| 412 |
|
| 413 |
sub remove_multiples_from_ziplist |
| 414 |
{ |
| 415 |
my ($blockref) = @_; |
| 416 |
|
| 417 |
# remove all definitions of settings and variables |
| 418 |
# that occur more than once in the zip list file. |
| 419 |
# Take the one with the most open brackets. This |
| 420 |
# number is stored at the end of the string. |
| 421 |
|
| 422 |
my @newarray = (); |
| 423 |
my @itemarray = (); |
| 424 |
my ($line, $itemname, $itemnumber); |
| 425 |
|
| 426 |
# first collecting all variables and settings names |
| 427 |
|
| 428 |
for ( my $i = 0; $i <= $#{$blockref}; $i++ ) |
| 429 |
{ |
| 430 |
$line = ${$blockref}[$i]; |
| 431 |
|
| 432 |
if ($line =~ /^\s*\b(\S*)\b\s+.*\#\#\d+\#\#\s*$/i) |
| 433 |
{ |
| 434 |
$itemname = $1; |
| 435 |
} |
| 436 |
|
| 437 |
if (! grep {$_ eq $itemname} @itemarray) |
| 438 |
{ |
| 439 |
push(@itemarray, $itemname); |
| 440 |
} |
| 441 |
} |
| 442 |
|
| 443 |
# and now all $items can be selected with the highest number |
| 444 |
|
| 445 |
for ( my $i = 0; $i <= $#itemarray; $i++ ) |
| 446 |
{ |
| 447 |
$itemname = $itemarray[$i]; |
| 448 |
|
| 449 |
my $itemnumbermax = 0; |
| 450 |
my $printline = ""; |
| 451 |
|
| 452 |
for ( my $j = 0; $j <= $#{$blockref}; $j++ ) |
| 453 |
{ |
| 454 |
$line = ${$blockref}[$j]; |
| 455 |
|
| 456 |
if ($line =~ /^\s*\Q$itemname\E\s+.*\#\#(\d+)\#\#\s*$/) |
| 457 |
{ |
| 458 |
$itemnumber = $1; |
| 459 |
|
| 460 |
if ($itemnumber >= $itemnumbermax) |
| 461 |
{ |
| 462 |
$printline = $line; |
| 463 |
$itemnumbermax = $itemnumber; |
| 464 |
} |
| 465 |
} |
| 466 |
} |
| 467 |
|
| 468 |
# removing the ending number from the printline |
| 469 |
# and putting it into the array |
| 470 |
|
| 471 |
$printline =~ s/\#\#\d+\#\#//; |
| 472 |
installer::remover::remove_leading_and_ending_whitespaces(\$line); |
| 473 |
push(@newarray, $printline); |
| 474 |
} |
| 475 |
|
| 476 |
return \@newarray; |
| 477 |
} |
| 478 |
|
| 479 |
######################################################### |
| 480 |
# Reading one variable defined in the zip list file |
| 481 |
######################################################### |
| 482 |
|
| 483 |
sub getinfofromziplist |
| 484 |
{ |
| 485 |
my ($blockref, $variable) = @_; |
| 486 |
|
| 487 |
my $searchstring = ""; |
| 488 |
my $line; |
| 489 |
|
| 490 |
for ( my $i = 0; $i <= $#{$blockref}; $i++ ) |
| 491 |
{ |
| 492 |
$line = ${$blockref}[$i]; |
| 493 |
|
| 494 |
if ( $line =~ /^\s*\Q$variable\E\s+(.+?)\s*$/ ) # "?" for minimal matching |
| 495 |
{ |
| 496 |
$searchstring = $1; |
| 497 |
last; |
| 498 |
} |
| 499 |
} |
| 500 |
|
| 501 |
return \$searchstring; |
| 502 |
} |
| 503 |
|
| 504 |
#################################################### |
| 505 |
# Replacing variables in include path |
| 506 |
#################################################### |
| 507 |
|
| 508 |
sub replace_all_variables_in_paths |
| 509 |
{ |
| 510 |
my ( $patharrayref, $variableshashref ) = @_; |
| 511 |
|
| 512 |
for ( my $i = 0; $i <= $#{$patharrayref}; $i++ ) |
| 513 |
{ |
| 514 |
my $line = ${$patharrayref}[$i]; |
| 515 |
|
| 516 |
my $key; |
| 517 |
|
| 518 |
foreach $key (sort { length ($b) <=> length ($a) } keys %{$variableshashref}) |
| 519 |
{ |
| 520 |
my $value = $variableshashref->{$key}; |
| 521 |
|
| 522 |
if (( $line =~ /\{$key\}/ ) && ( $value eq "" )) { $line = ".\n"; } |
| 523 |
|
| 524 |
$line =~ s/\{\Q$key\E\}/$value/g; |
| 525 |
} |
| 526 |
|
| 527 |
${$patharrayref}[$i] = $line; |
| 528 |
} |
| 529 |
} |
| 530 |
|
| 531 |
#################################################### |
| 532 |
# Replacing minor in include path |
| 533 |
#################################################### |
| 534 |
|
| 535 |
sub replace_minor_in_paths |
| 536 |
{ |
| 537 |
my ( $patharrayref ) = @_; |
| 538 |
|
| 539 |
for ( my $i = 0; $i <= $#{$patharrayref}; $i++ ) |
| 540 |
{ |
| 541 |
my $line = ${$patharrayref}[$i]; |
| 542 |
|
| 543 |
$line =~ s/\.\{minor\}//g; |
| 544 |
$line =~ s/\.\{minornonpre\}//g; |
| 545 |
|
| 546 |
${$patharrayref}[$i] = $line; |
| 547 |
} |
| 548 |
} |
| 549 |
|
| 550 |
#################################################### |
| 551 |
# Replacing packagetype in include path |
| 552 |
#################################################### |
| 553 |
|
| 554 |
sub replace_packagetype_in_paths |
| 555 |
{ |
| 556 |
my ( $patharrayref ) = @_; |
| 557 |
|
| 558 |
for ( my $i = 0; $i <= $#{$patharrayref}; $i++ ) |
| 559 |
{ |
| 560 |
my $line = ${$patharrayref}[$i]; |
| 561 |
|
| 562 |
if (( $installer::globals::installertypedir ) && ( $line =~ /\{pkgtype\}/ )) |
| 563 |
{ |
| 564 |
$line =~ s/\{pkgtype\}/$installer::globals::installertypedir/g; |
| 565 |
} |
| 566 |
|
| 567 |
${$patharrayref}[$i] = $line; |
| 568 |
} |
| 569 |
} |
| 570 |
|
| 571 |
#################################################### |
| 572 |
# Removing ending separators in paths |
| 573 |
#################################################### |
| 574 |
|
| 575 |
sub remove_ending_separator |
| 576 |
{ |
| 577 |
my ( $patharrayref ) = @_; |
| 578 |
|
| 579 |
for ( my $i = 0; $i <= $#{$patharrayref}; $i++ ) |
| 580 |
{ |
| 581 |
my $line = ${$patharrayref}[$i]; |
| 582 |
|
| 583 |
installer::remover::remove_ending_pathseparator(\$line); |
| 584 |
|
| 585 |
$line =~ s/\s*$//; |
| 586 |
$line = $line . "\n"; |
| 587 |
|
| 588 |
${$patharrayref}[$i] = $line; |
| 589 |
} |
| 590 |
} |
| 591 |
|
| 592 |
#################################################### |
| 593 |
# Replacing languages in include path |
| 594 |
#################################################### |
| 595 |
|
| 596 |
sub replace_languages_in_paths |
| 597 |
{ |
| 598 |
my ( $patharrayref, $languagesref ) = @_; |
| 599 |
|
| 600 |
installer::logger::include_header_into_logfile("Replacing languages in include paths:"); |
| 601 |
|
| 602 |
my @patharray = (); |
| 603 |
my $infoline = ""; |
| 604 |
|
| 605 |
for ( my $i = 0; $i <= $#{$patharrayref}; $i++ ) |
| 606 |
{ |
| 607 |
my $line = ${$patharrayref}[$i]; |
| 608 |
|
| 609 |
if ( $line =~ /\$\(LANG\)/ ) |
| 610 |
{ |
| 611 |
my $originalline = $line; |
| 612 |
my $newline = ""; |
| 613 |
|
| 614 |
for ( my $j = 0; $j <= $#{$languagesref}; $j++ ) |
| 615 |
{ |
| 616 |
my $language = ${$languagesref}[$j]; |
| 617 |
$line =~ s/\$\(LANG\)/$language/g; |
| 618 |
push(@patharray ,$line); |
| 619 |
my $newdir = $line; |
| 620 |
$line = $originalline; |
| 621 |
|
| 622 |
installer::remover::remove_leading_and_ending_whitespaces(\$newline); |
| 623 |
|
| 624 |
# Is it necessary to refresh the global array, containing all files of all include paths? |
| 625 |
if ( -d $newdir ) |
| 626 |
{ |
| 627 |
# Checking if $newdir is empty |
| 628 |
if ( ! installer::systemactions::is_empty_dir($newdir) ) |
| 629 |
{ |
| 630 |
$installer::globals::refresh_includepaths = 1; |
| 631 |
$infoline = "Directory $newdir exists and is not empty. Refreshing global file array is required.\n"; |
| 632 |
push( @installer::globals::logfileinfo, $infoline); |
| 633 |
} |
| 634 |
else |
| 635 |
{ |
| 636 |
$infoline = "Directory $newdir is empty. No refresh of global file array required.\n"; |
| 637 |
push( @installer::globals::logfileinfo, $infoline); |
| 638 |
} |
| 639 |
} |
| 640 |
else |
| 641 |
{ |
| 642 |
$infoline = "Directory $newdir does not exist. No refresh of global file array required.\n"; |
| 643 |
push( @installer::globals::logfileinfo, $infoline); |
| 644 |
} |
| 645 |
} |
| 646 |
} |
| 647 |
else # not language dependent include path |
| 648 |
{ |
| 649 |
push(@patharray ,$line); |
| 650 |
} |
| 651 |
} |
| 652 |
|
| 653 |
return \@patharray; |
| 654 |
} |
| 655 |
|
| 656 |
##################################################### |
| 657 |
# Collecting all files from all include paths |
| 658 |
##################################################### |
| 659 |
|
| 660 |
sub list_all_files_from_include_path |
| 661 |
{ |
| 662 |
my ( $patharrayref) = @_; |
| 663 |
|
| 664 |
installer::logger::include_header_into_logfile("Include paths:"); |
| 665 |
|
| 666 |
for ( my $i = 0; $i <= $#{$patharrayref}; $i++ ) |
| 667 |
{ |
| 668 |
my $path = ${$patharrayref}[$i]; |
| 669 |
installer::remover::remove_leading_and_ending_whitespaces(\$path); |
| 670 |
my $infoline = "$path\n"; |
| 671 |
push( @installer::globals::logfileinfo, $infoline); |
| 672 |
} |
| 673 |
|
| 674 |
push( @installer::globals::logfileinfo, "\n"); |
| 675 |
} |
| 676 |
|
| 677 |
##################################################### |
| 678 |
# Collecting all files from all include paths |
| 679 |
##################################################### |
| 680 |
|
| 681 |
sub set_manufacturer |
| 682 |
{ |
| 683 |
my ($allvariables) = @_; |
| 684 |
my $manufacturer; |
| 685 |
|
| 686 |
if( defined $ENV{'OOO_VENDOR'} && $ENV{'OOO_VENDOR'} ne "" ) |
| 687 |
{ |
| 688 |
$manufacturer = $ENV{'OOO_VENDOR'}; |
| 689 |
} |
| 690 |
elsif( defined $ENV{'USERNAME'} && $ENV{'USERNAME'} ne "" ) |
| 691 |
{ |
| 692 |
$manufacturer = $ENV{'USERNAME'}; |
| 693 |
} |
| 694 |
elsif( defined $ENV{'USER'} && $ENV{'USER'} ne "" ) |
| 695 |
{ |
| 696 |
$manufacturer = $ENV{'USER'}; |
| 697 |
} |
| 698 |
else |
| 699 |
{ |
| 700 |
$manufacturer = "default"; |
| 701 |
} |
| 702 |
|
| 703 |
$installer::globals::manufacturer = $manufacturer; |
| 704 |
$installer::globals::longmanufacturer = $manufacturer; |
| 705 |
|
| 706 |
$allvariables->{'MANUFACTURER'} = $installer::globals::manufacturer; |
| 707 |
} |
| 708 |
|
| 709 |
############################################################## |
| 710 |
# A ProductVersion has to be defined. If it is not set in |
| 711 |
# zip.lst, it is set now to "1" |
| 712 |
############################################################## |
| 713 |
|
| 714 |
sub set_default_productversion_if_required |
| 715 |
{ |
| 716 |
my ($allvariables) = @_; |
| 717 |
|
| 718 |
if (!($allvariables->{'PRODUCTVERSION'})) |
| 719 |
{ |
| 720 |
$allvariables->{'PRODUCTVERSION'} = 1; # FAKE |
| 721 |
} |
| 722 |
} |
| 723 |
|
| 724 |
#################################################### |
| 725 |
# Removing .. in paths |
| 726 |
#################################################### |
| 727 |
|
| 728 |
sub simplify_path |
| 729 |
{ |
| 730 |
my ( $pathref ) = @_; |
| 731 |
|
| 732 |
my $oldpath = $$pathref; |
| 733 |
|
| 734 |
my $change = 0; |
| 735 |
|
| 736 |
while ( $oldpath =~ /(^.*)(\Q$installer::globals::separator\E.*\w+?)(\Q$installer::globals::separator\E\.\.)(\Q$installer::globals::separator\E.*$)/ ) |
| 737 |
{ |
| 738 |
my $part1 = $1; |
| 739 |
my $part2 = $4; |
| 740 |
$oldpath = $part1 . $part2; |
| 741 |
$change = 1; |
| 742 |
} |
| 743 |
|
| 744 |
if ( $change ) { $$pathref = $oldpath . "\n"; } |
| 745 |
} |
| 746 |
|
| 747 |
#################################################### |
| 748 |
# Removing ending separators in paths |
| 749 |
#################################################### |
| 750 |
|
| 751 |
sub resolve_relative_paths |
| 752 |
{ |
| 753 |
my ( $patharrayref ) = @_; |
| 754 |
|
| 755 |
for my $path ( @{$patharrayref} ) |
| 756 |
{ |
| 757 |
$path = rel2abs($path); |
| 758 |
simplify_path(\$path); |
| 759 |
} |
| 760 |
} |
| 761 |
|
| 762 |
#################################################### |
| 763 |
# Replacing variables inside zip list variables |
| 764 |
# Example: {milestone} to be replaced by |
| 765 |
# $installer::globals::lastminor |
| 766 |
#################################################### |
| 767 |
|
| 768 |
sub replace_variables_in_ziplist_variables |
| 769 |
{ |
| 770 |
my ($blockref) = @_; |
| 771 |
|
| 772 |
for ( my $i = 0; $i <= $#{$blockref}; $i++ ) |
| 773 |
{ |
| 774 |
${$blockref}[$i] =~ s/\{milestone\}//; |
| 775 |
${$blockref}[$i] =~ s/\{minor\}//; |
| 776 |
if ( $installer::globals::buildid ) { ${$blockref}[$i] =~ s/\{buildid\}/$installer::globals::buildid/; } |
| 777 |
else { ${$blockref}[$i] =~ s/\{buildid\}//; } |
| 778 |
if ( $installer::globals::build ) { ${$blockref}[$i] =~ s/\{buildsource\}/$installer::globals::build/; } |
| 779 |
else { ${$blockref}[$i] =~ s/\{build\}//; } |
| 780 |
} |
| 781 |
} |
| 782 |
|
| 783 |
########################################################### |
| 784 |
# Overwrite branding data in openoffice.lst that is defined in configure |
| 785 |
########################################################### |
| 786 |
|
| 787 |
sub overwrite_branding |
| 788 |
{ |
| 789 |
my ($variableshashref) = @_; |
| 790 |
$variableshashref->{'PROGRESSBARCOLOR'} = $ENV{'PROGRESSBARCOLOR'} , if( defined $ENV{'PROGRESSBARCOLOR'} && $ENV{'PROGRESSBARCOLOR'} ne "" ); |
| 791 |
$variableshashref->{'PROGRESSSIZE'} = $ENV{'PROGRESSSIZE'} , if( defined $ENV{'PROGRESSSIZE'} && $ENV{'PROGRESSSIZE'} ne "" ); |
| 792 |
$variableshashref->{'PROGRESSPOSITION'} = $ENV{'PROGRESSPOSITION'} , if( defined $ENV{'PROGRESSPOSITION'} && $ENV{'PROGRESSPOSITION'} ne "" ); |
| 793 |
$variableshashref->{'PROGRESSFRAMECOLOR'} = $ENV{'PROGRESSFRAMECOLOR'} , if( defined $ENV{'PROGRESSFRAMECOLOR'} && $ENV{'PROGRESSFRAMECOLOR'} ne "" ); |
| 794 |
$variableshashref->{'PROGRESSTEXTCOLOR'} = $ENV{'PROGRESSTEXTCOLOR'} , if( defined $ENV{'PROGRESSTEXTCOLOR'} && $ENV{'PROGRESSTEXTCOLOR'} ne "" ); |
| 795 |
$variableshashref->{'PROGRESSTEXTBASELINE'} = $ENV{'PROGRESSTEXTBASELINE'} , if( defined $ENV{'PROGRESSTEXTBASELINE'} && $ENV{'PROGRESSTEXTBASELINE'} ne "" ); |
| 796 |
} |
| 797 |
|
| 798 |
########################################################### |
| 799 |
# Adding the lowercase variables into the variableshashref |
| 800 |
########################################################### |
| 801 |
|
| 802 |
sub add_variables_to_allvariableshashref |
| 803 |
{ |
| 804 |
my ($variableshashref) = @_; |
| 805 |
|
| 806 |
my $lcvariable = lc($variableshashref->{'PRODUCTNAME'}); |
| 807 |
$variableshashref->{'LCPRODUCTNAME'} = $lcvariable; |
| 808 |
|
| 809 |
if ($variableshashref->{'PRODUCTEXTENSION'}) |
| 810 |
{ |
| 811 |
$variableshashref->{'LCPRODUCTEXTENSION'} = "\-" . lc($variableshashref->{'PRODUCTEXTENSION'}); # including the "-" ! |
| 812 |
} |
| 813 |
else |
| 814 |
{ |
| 815 |
$variableshashref->{'LCPRODUCTEXTENSION'} = ""; |
| 816 |
} |
| 817 |
|
| 818 |
if ( $installer::globals::languagepack ) { $variableshashref->{'PRODUCTADDON'} = $installer::globals::languagepackaddon; } |
| 819 |
elsif ( $installer::globals::helppack ) { $variableshashref->{'PRODUCTADDON'} = $installer::globals::helppackaddon; } |
| 820 |
else { $variableshashref->{'PRODUCTADDON'} = ""; } |
| 821 |
|
| 822 |
my $localbuild = $installer::globals::build; |
| 823 |
if ( $localbuild =~ /^\s*(\w+?)(\d+)\s*$/ ) { $localbuild = $2; } # using "680" instead of "src680" |
| 824 |
$variableshashref->{'PRODUCTMAJOR'} = $localbuild; |
| 825 |
|
| 826 |
$variableshashref->{'PRODUCTBUILDID'} = $installer::globals::buildid; |
| 827 |
} |
| 828 |
|
| 829 |
1; |