| 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::windows::update; |
| 20 |
|
| 21 |
use strict; |
| 22 |
use warnings; |
| 23 |
|
| 24 |
use installer::converter; |
| 25 |
use installer::exiter; |
| 26 |
use installer::files; |
| 27 |
use installer::globals; |
| 28 |
use installer::pathanalyzer; |
| 29 |
use installer::systemactions; |
| 30 |
|
| 31 |
################################################################################# |
| 32 |
# Extracting all tables from an msi database |
| 33 |
################################################################################# |
| 34 |
|
| 35 |
sub extract_all_tables_from_msidatabase |
| 36 |
{ |
| 37 |
my ($fulldatabasepath, $workdir) = @_; |
| 38 |
|
| 39 |
my $msidb = "msidb.exe"; # Has to be in the path |
| 40 |
my $infoline = ""; |
| 41 |
my $systemcall = ""; |
| 42 |
my $returnvalue = ""; |
| 43 |
my $extraslash = ""; # Has to be set for non-ActiveState perl |
| 44 |
$extraslash = "\\" if ( $^O =~ /cygwin/i ); |
| 45 |
|
| 46 |
# Export of all tables by using "*" |
| 47 |
$systemcall = $msidb . " -d " . $fulldatabasepath . " -f " . $workdir . " -e " . $extraslash . "*"; |
| 48 |
# msidb.exe really wants backslashes. (And double escaping because system() expands the string.) |
| 49 |
$systemcall =~ s/\//\\\\/g; |
| 50 |
|
| 51 |
my $systemcall_output = `$systemcall`; |
| 52 |
my $returnvalue = $? >> 8; |
| 53 |
|
| 54 |
$infoline = "Systemcall: $systemcall\n"; |
| 55 |
push( @installer::globals::logfileinfo, $infoline); |
| 56 |
|
| 57 |
if ($returnvalue) |
| 58 |
{ |
| 59 |
$infoline = "ERROR: Could not execute $systemcall - returncode: $returnvalue - output: $systemcall_output\n"; |
| 60 |
push( @installer::globals::logfileinfo, $infoline); |
| 61 |
installer::exiter::exit_program("ERROR: Could not exclude tables from msi database: $fulldatabasepath !", "extract_all_tables_from_msidatabase"); |
| 62 |
} |
| 63 |
else |
| 64 |
{ |
| 65 |
$infoline = "Success: Executed $systemcall successfully!\n"; |
| 66 |
push( @installer::globals::logfileinfo, $infoline); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
################################################################################# |
| 71 |
# Collecting the keys from the first line of the idt file |
| 72 |
################################################################################# |
| 73 |
|
| 74 |
sub collect_all_keys |
| 75 |
{ |
| 76 |
my ($line) = @_; |
| 77 |
|
| 78 |
my @allkeys = (); |
| 79 |
my $rownumber = 0; |
| 80 |
my $onekey = ""; |
| 81 |
|
| 82 |
while ( $line =~ /^\s*(\S+?)\t(.*)$/ ) |
| 83 |
{ |
| 84 |
$onekey = $1; |
| 85 |
$line = $2; |
| 86 |
$rownumber++; |
| 87 |
push(@allkeys, $onekey); |
| 88 |
} |
| 89 |
|
| 90 |
# and the last key |
| 91 |
|
| 92 |
$onekey = $line; |
| 93 |
$onekey =~ s/^\s*//g; |
| 94 |
$onekey =~ s/\s*$//g; |
| 95 |
|
| 96 |
$rownumber++; |
| 97 |
push(@allkeys, $onekey); |
| 98 |
|
| 99 |
return (\@allkeys, $rownumber); |
| 100 |
} |
| 101 |
|
| 102 |
################################################################################# |
| 103 |
# Analyzing the content of one line of an idt file |
| 104 |
################################################################################# |
| 105 |
|
| 106 |
sub get_oneline_hash |
| 107 |
{ |
| 108 |
my ($line, $allkeys, $rownumber) = @_; |
| 109 |
|
| 110 |
my $counter = 0; |
| 111 |
my %linehash = (); |
| 112 |
|
| 113 |
$line =~ s/^\s*//; |
| 114 |
$line =~ s/\s*$//; |
| 115 |
|
| 116 |
my $value = ""; |
| 117 |
my $onekey = ""; |
| 118 |
|
| 119 |
while ( $line =~ /^(.*?)\t(.*)$/ ) |
| 120 |
{ |
| 121 |
$value = $1; |
| 122 |
$line = $2; |
| 123 |
$onekey = ${$allkeys}[$counter]; |
| 124 |
$linehash{$onekey} = $value; |
| 125 |
$counter++; |
| 126 |
} |
| 127 |
|
| 128 |
# the last column |
| 129 |
|
| 130 |
$value = $line; |
| 131 |
$onekey = ${$allkeys}[$counter]; |
| 132 |
|
| 133 |
$linehash{$onekey} = $value; |
| 134 |
|
| 135 |
return \%linehash; |
| 136 |
} |
| 137 |
|
| 138 |
################################################################################# |
| 139 |
# Analyzing the content of an idt file |
| 140 |
################################################################################# |
| 141 |
|
| 142 |
sub analyze_idt_file |
| 143 |
{ |
| 144 |
my ($filecontent) = @_; |
| 145 |
|
| 146 |
my %table = (); |
| 147 |
# keys are written in first line |
| 148 |
my ($allkeys, $rownumber) = collect_all_keys(${$filecontent}[0]); |
| 149 |
|
| 150 |
for ( my $i = 0; $i <= $#{$filecontent}; $i++ ) |
| 151 |
{ |
| 152 |
if (( $i == 0 ) || ( $i == 1 ) || ( $i == 2 )) { next; } |
| 153 |
|
| 154 |
my $onelinehash = get_oneline_hash(${$filecontent}[$i], $allkeys, $rownumber); |
| 155 |
my $linekey = $i - 2; # ! : The linenumber is the unique key !? Always decrease by two, because of removed first three lines. |
| 156 |
$table{$linekey} = $onelinehash; |
| 157 |
} |
| 158 |
|
| 159 |
return \%table; |
| 160 |
} |
| 161 |
|
| 162 |
################################################################################# |
| 163 |
# Reading all idt files in a specified directory |
| 164 |
################################################################################# |
| 165 |
|
| 166 |
sub read_all_tables_from_msidatabase |
| 167 |
{ |
| 168 |
my ($workdir) = @_; |
| 169 |
|
| 170 |
my %database = (); |
| 171 |
|
| 172 |
my $ext = "idt"; |
| 173 |
|
| 174 |
my $allidtfiles = installer::systemactions::find_file_with_file_extension($ext, $workdir); |
| 175 |
|
| 176 |
for ( my $i = 0; $i <= $#{$allidtfiles}; $i++ ) |
| 177 |
{ |
| 178 |
my $onefilename = ${$allidtfiles}[$i]; |
| 179 |
my $longonefilename = $workdir . $installer::globals::separator . $onefilename; |
| 180 |
if ( ! -f $longonefilename ) { installer::exiter::exit_program("ERROR: Could not find idt file: $longonefilename!", "read_all_tables_from_msidatabase"); } |
| 181 |
my $filecontent = installer::files::read_file($longonefilename); |
| 182 |
my $idtcontent = analyze_idt_file($filecontent); |
| 183 |
if ($onefilename eq "Directory.idt") { |
| 184 |
collect_directories($filecontent, $longonefilename); |
| 185 |
} |
| 186 |
my $key = $onefilename; |
| 187 |
$key =~ s/\.idt\s*$//; |
| 188 |
$database{$key} = $idtcontent; |
| 189 |
} |
| 190 |
|
| 191 |
return \%database; |
| 192 |
} |
| 193 |
|
| 194 |
################################################################################# |
| 195 |
# Checking, if this is the correct database. |
| 196 |
################################################################################# |
| 197 |
|
| 198 |
sub correct_database |
| 199 |
{ |
| 200 |
my ($product, $pro, $langs, $languagestringref) = @_; |
| 201 |
|
| 202 |
my $correct_database = 0; |
| 203 |
|
| 204 |
# Comparing $product with $installer::globals::product and |
| 205 |
# $pro with $installer::globals::pro and |
| 206 |
# $langs with $languagestringref |
| 207 |
|
| 208 |
my $product_is_good = 0; |
| 209 |
|
| 210 |
my $localproduct = $installer::globals::product; |
| 211 |
if ( $installer::globals::languagepack ) { $localproduct = $localproduct . "LanguagePack"; } |
| 212 |
elsif ( $installer::globals::helppack ) { $localproduct = $localproduct . "HelpPack"; } |
| 213 |
|
| 214 |
if ( $product eq $localproduct ) { $product_is_good = 1; } |
| 215 |
|
| 216 |
if ( $product_is_good ) |
| 217 |
{ |
| 218 |
my $pro_is_good = 0; |
| 219 |
|
| 220 |
if ((( $pro eq "pro" ) && ( $installer::globals::pro )) || (( $pro eq "nonpro" ) && ( ! $installer::globals::pro ))) { $pro_is_good = 1; } |
| 221 |
|
| 222 |
if ( $pro_is_good ) |
| 223 |
{ |
| 224 |
my $langlisthash = installer::converter::convert_stringlist_into_hash(\$langs, ","); |
| 225 |
my $langstringhash = installer::converter::convert_stringlist_into_hash($languagestringref, "_"); |
| 226 |
|
| 227 |
my $not_included = 0; |
| 228 |
foreach my $onelang ( keys %{$langlisthash} ) |
| 229 |
{ |
| 230 |
if ( ! exists($langstringhash->{$onelang}) ) |
| 231 |
{ |
| 232 |
$not_included = 1; |
| 233 |
last; |
| 234 |
} |
| 235 |
} |
| 236 |
|
| 237 |
if ( ! $not_included ) |
| 238 |
{ |
| 239 |
foreach my $onelanguage ( keys %{$langstringhash} ) |
| 240 |
{ |
| 241 |
if ( ! exists($langlisthash->{$onelanguage}) ) |
| 242 |
{ |
| 243 |
$not_included = 1; |
| 244 |
last; |
| 245 |
} |
| 246 |
} |
| 247 |
|
| 248 |
if ( ! $not_included ) { $correct_database = 1; } |
| 249 |
} |
| 250 |
} |
| 251 |
} |
| 252 |
|
| 253 |
return $correct_database; |
| 254 |
} |
| 255 |
|
| 256 |
################################################################################# |
| 257 |
# Searching for the path to the reference database for this special product. |
| 258 |
################################################################################# |
| 259 |
|
| 260 |
sub get_databasename_from_list |
| 261 |
{ |
| 262 |
my ($filecontent, $languagestringref, $filename) = @_; |
| 263 |
|
| 264 |
my $databasepath = ""; |
| 265 |
|
| 266 |
for ( my $i = 0; $i <= $#{$filecontent}; $i++ ) |
| 267 |
{ |
| 268 |
my $line = ${$filecontent}[$i]; |
| 269 |
if ( $line =~ /^\s*$/ ) { next; } # empty line |
| 270 |
if ( $line =~ /^\s*\#/ ) { next; } # comment line |
| 271 |
|
| 272 |
if ( $line =~ /^\s*(.+?)\s*\t+\s*(.+?)\s*\t+\s*(.+?)\s*\t+\s*(.+?)\s*$/ ) |
| 273 |
{ |
| 274 |
my $product = $1; |
| 275 |
my $pro = $2; |
| 276 |
my $langs = $3; |
| 277 |
my $path = $4; |
| 278 |
|
| 279 |
if (( $pro ne "pro" ) && ( $pro ne "nonpro" )) { installer::exiter::exit_program("ERROR: Wrong syntax in file: $filename. Only \"pro\" or \"nonpro\" allowed in column 1! Line: \"$line\"", "get_databasename_from_list"); } |
| 280 |
|
| 281 |
if ( correct_database($product, $pro, $langs, $languagestringref) ) |
| 282 |
{ |
| 283 |
$databasepath = $path; |
| 284 |
last; |
| 285 |
} |
| 286 |
} |
| 287 |
else |
| 288 |
{ |
| 289 |
installer::exiter::exit_program("ERROR: Wrong syntax in file: $filename! Line: \"$line\"", "get_databasename_from_list"); |
| 290 |
} |
| 291 |
} |
| 292 |
|
| 293 |
return $databasepath; |
| 294 |
} |
| 295 |
|
| 296 |
################################################################################# |
| 297 |
# Reading an existing database completely |
| 298 |
################################################################################# |
| 299 |
|
| 300 |
sub readdatabase |
| 301 |
{ |
| 302 |
my ($allvariables, $languagestringref, $includepatharrayref) = @_; |
| 303 |
|
| 304 |
my $database = ""; |
| 305 |
my $infoline = ""; |
| 306 |
|
| 307 |
if ( ! $allvariables->{'UPDATE_DATABASE_LISTNAME'} ) { installer::exiter::exit_program("ERROR: If \"UPDATE_DATABASE\" is set, \"UPDATE_DATABASE_LISTNAME\" is required.", "Main"); } |
| 308 |
my $listfilename = $allvariables->{'UPDATE_DATABASE_LISTNAME'}; |
| 309 |
|
| 310 |
# Searching the list in the include paths |
| 311 |
my $listname = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$listfilename, $includepatharrayref, 1); |
| 312 |
if ( $$listname eq "" ) { installer::exiter::exit_program("ERROR: List file not found: $listfilename !", "readdatabase"); } |
| 313 |
my $completelistname = $$listname; |
| 314 |
|
| 315 |
# Reading list file |
| 316 |
my $listfile = installer::files::read_file($completelistname); |
| 317 |
|
| 318 |
# Get name and path of reference database |
| 319 |
my $databasename = get_databasename_from_list($listfile, $languagestringref, $completelistname); |
| 320 |
|
| 321 |
# If the correct database was not found, this is not necessarily an error. But in this case, this is not an update packaging process! |
| 322 |
if (( $databasename ) && ( $databasename ne "" )) # This is an update packaging process! |
| 323 |
{ |
| 324 |
$installer::globals::updatedatabase = 1; |
| 325 |
installer::logger::print_message( "... update process, using database $databasename ...\n" ); |
| 326 |
$infoline = "\nDatabase found in $completelistname: \"$databasename\"\n\n"; |
| 327 |
# Saving in global variable |
| 328 |
$installer::globals::updatedatabasepath = $databasename; |
| 329 |
} |
| 330 |
else |
| 331 |
{ |
| 332 |
$infoline = "\nNo database found in $completelistname. This is no update process!\n\n"; |
| 333 |
} |
| 334 |
push( @installer::globals::logfileinfo, $infoline); |
| 335 |
|
| 336 |
if ( $installer::globals::updatedatabase ) |
| 337 |
{ |
| 338 |
if ( ! -f $databasename ) { installer::exiter::exit_program("ERROR: Could not find reference database: $databasename!", "readdatabase"); } |
| 339 |
|
| 340 |
my $msifilename = $databasename; |
| 341 |
installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$msifilename); |
| 342 |
|
| 343 |
installer::logger::include_timestamp_into_logfile("Performance Info: readdatabase start"); |
| 344 |
|
| 345 |
# create directory for unpacking |
| 346 |
my $databasedir = installer::systemactions::create_directories("database", $languagestringref); |
| 347 |
|
| 348 |
# copy database |
| 349 |
my $fulldatabasepath = $databasedir . $installer::globals::separator . $msifilename; |
| 350 |
installer::systemactions::copy_one_file($databasename, $fulldatabasepath); |
| 351 |
|
| 352 |
installer::logger::include_timestamp_into_logfile("Performance Info: readdatabase: before extracting tables"); |
| 353 |
|
| 354 |
# extract all tables from database |
| 355 |
extract_all_tables_from_msidatabase($fulldatabasepath, $databasedir); |
| 356 |
|
| 357 |
installer::logger::include_timestamp_into_logfile("Performance Info: readdatabase: before reading tables"); |
| 358 |
|
| 359 |
# read all tables |
| 360 |
$database = read_all_tables_from_msidatabase($databasedir); |
| 361 |
|
| 362 |
# Test output: |
| 363 |
|
| 364 |
# foreach my $key1 ( keys %{$database} ) |
| 365 |
# { |
| 366 |
# print "Test1: $key1\n"; |
| 367 |
# foreach my $key2 ( keys %{$database->{$key1}} ) |
| 368 |
# { |
| 369 |
# print "\tTest2: $key2\n"; |
| 370 |
# foreach my $key3 ( keys %{$database->{$key1}->{$key2}} ) |
| 371 |
# { |
| 372 |
# print "\t\tTest3: $key3: $database->{$key1}->{$key2}->{$key3}\n"; |
| 373 |
# } |
| 374 |
# } |
| 375 |
# } |
| 376 |
|
| 377 |
# Example: File table |
| 378 |
|
| 379 |
# my $filetable = $database->{'File'}; |
| 380 |
# foreach my $linenumber ( keys %{$filetable} ) |
| 381 |
# { |
| 382 |
# print "Test Filenumber: $linenumber\n"; |
| 383 |
# foreach my $key ( keys %{$filetable->{$linenumber}} ) |
| 384 |
# { |
| 385 |
# print "\t\tTest: $key: $filetable->{$linenumber}->{$key}\n"; |
| 386 |
# } |
| 387 |
# } |
| 388 |
|
| 389 |
# Example: Searching for ProductCode in table Property |
| 390 |
|
| 391 |
# my $column1 = "Property"; |
| 392 |
# my $column2 = "Value"; |
| 393 |
# my $searchkey = "ProductCode"; |
| 394 |
# my $propertytable = $database->{'Property'}; |
| 395 |
# foreach my $linenumber ( keys %{$propertytable} ) |
| 396 |
# { |
| 397 |
# if ( $propertytable->{$linenumber}->{$column1} eq $searchkey ) |
| 398 |
# { |
| 399 |
# print("Test: $searchkey : $propertytable->{$linenumber}->{$column2}\n"); |
| 400 |
# } |
| 401 |
# } |
| 402 |
|
| 403 |
installer::logger::include_timestamp_into_logfile("Performance Info: readdatabase end"); |
| 404 |
} |
| 405 |
|
| 406 |
return $database; |
| 407 |
} |
| 408 |
|
| 409 |
######################################################################### |
| 410 |
# Reading the file "Directory.idt". |
| 411 |
######################################################################### |
| 412 |
|
| 413 |
sub collect_directories |
| 414 |
{ |
| 415 |
my ($filecontent, $idtfilename) = @_; |
| 416 |
|
| 417 |
for ( my $i = 0; $i <= $#{$filecontent}; $i++ ) |
| 418 |
{ |
| 419 |
if ( $i <= 2 ) { next; } # ignoring first three lines |
| 420 |
if ( ${$filecontent}[$i] =~ /^\s*$/ ) { next; } # ignoring empty lines |
| 421 |
# Format: Directory Directory_Parent DefaultDir |
| 422 |
if ( ${$filecontent}[$i] =~ /^\s*(.+?)\t(.*?)\t(.*?)\s*$/ ) |
| 423 |
{ |
| 424 |
$installer::globals::merge_directory_hash{$1} = 1; |
| 425 |
} |
| 426 |
else |
| 427 |
{ |
| 428 |
my $linecount = $i + 1; |
| 429 |
installer::exiter::exit_program("ERROR: Unknown line format in table \"$idtfilename\" (line $linecount) !", "collect_directories"); |
| 430 |
} |
| 431 |
} |
| 432 |
} |
| 433 |
|
| 434 |
################################################################################# |
| 435 |
# Files can be included in merge modules. This is also important for update. |
| 436 |
################################################################################# |
| 437 |
|
| 438 |
sub readmergedatabase |
| 439 |
{ |
| 440 |
my ( $mergemodules, $languagestringref, $includepatharrayref ) = @_; |
| 441 |
|
| 442 |
installer::logger::include_timestamp_into_logfile("Performance Info: readmergedatabase start"); |
| 443 |
|
| 444 |
my $mergemoduledir = installer::systemactions::create_directories("mergedatabase", $languagestringref); |
| 445 |
|
| 446 |
my %allmergefiles = (); |
| 447 |
|
| 448 |
foreach my $mergemodule ( @{$mergemodules} ) |
| 449 |
{ |
| 450 |
my $filename = $mergemodule->{'Name'}; |
| 451 |
my $mergefile = $ENV{'MSM_PATH'} . $filename; |
| 452 |
|
| 453 |
if ( ! -f $mergefile ) { installer::exiter::exit_program("ERROR: msm file not found: $mergefile !", "readmergedatabase"); } |
| 454 |
my $completesource = $mergefile; |
| 455 |
|
| 456 |
my $mergegid = $mergemodule->{'gid'}; |
| 457 |
my $workdir = $mergemoduledir . $installer::globals::separator . $mergegid; |
| 458 |
if ( ! -d $workdir ) { installer::systemactions::create_directory($workdir); } |
| 459 |
|
| 460 |
my $completedest = $workdir . $installer::globals::separator . $filename; |
| 461 |
installer::systemactions::copy_one_file($completesource, $completedest); |
| 462 |
if ( ! -f $completedest ) { installer::exiter::exit_program("ERROR: msm file not found: $completedest !", "readmergedatabase"); } |
| 463 |
|
| 464 |
# extract all tables from database |
| 465 |
extract_all_tables_from_msidatabase($completedest, $workdir); |
| 466 |
|
| 467 |
# read all tables |
| 468 |
my $onemergefile = read_all_tables_from_msidatabase($workdir); |
| 469 |
|
| 470 |
$allmergefiles{$mergegid} = $onemergefile; |
| 471 |
} |
| 472 |
|
| 473 |
foreach my $mergefilegid ( keys %allmergefiles ) |
| 474 |
{ |
| 475 |
my $onemergefile = $allmergefiles{$mergefilegid}; |
| 476 |
my $filetable = $onemergefile->{'File'}; |
| 477 |
|
| 478 |
foreach my $linenumber ( keys %{$filetable} ) |
| 479 |
{ |
| 480 |
# Collecting all files from merge modules in global hash |
| 481 |
$installer::globals::mergemodulefiles{$filetable->{$linenumber}->{'File'}} = 1; |
| 482 |
} |
| 483 |
} |
| 484 |
|
| 485 |
installer::logger::include_timestamp_into_logfile("Performance Info: readmergedatabase end"); |
| 486 |
} |
| 487 |
|
| 488 |
################################################################################# |
| 489 |
# Creating several useful hashes from old database |
| 490 |
################################################################################# |
| 491 |
|
| 492 |
sub create_database_hashes |
| 493 |
{ |
| 494 |
my ( $database ) = @_; |
| 495 |
|
| 496 |
# 1. Hash ( Component -> UniqueFileName ), required in File table. |
| 497 |
# Read from File table. |
| 498 |
|
| 499 |
my %uniquefilename = (); |
| 500 |
my %allupdatesequences = (); |
| 501 |
my %allupdatecomponents = (); |
| 502 |
my %allupdatefileorder = (); |
| 503 |
my %allupdatecomponentorder = (); |
| 504 |
my %revuniquefilename = (); |
| 505 |
my %revshortfilename = (); |
| 506 |
my %shortdirname = (); |
| 507 |
my %componentid = (); |
| 508 |
my %componentidkeypath = (); |
| 509 |
my %alloldproperties = (); |
| 510 |
my %allupdatelastsequences = (); |
| 511 |
my %allupdatediskids = (); |
| 512 |
|
| 513 |
my $filetable = $database->{'File'}; |
| 514 |
|
| 515 |
foreach my $linenumber ( keys %{$filetable} ) |
| 516 |
{ |
| 517 |
my $comp = $filetable->{$linenumber}->{'Component_'}; |
| 518 |
my $uniquename = $filetable->{$linenumber}->{'File'}; |
| 519 |
my $filename = $filetable->{$linenumber}->{'FileName'}; |
| 520 |
my $sequence = $filetable->{$linenumber}->{'Sequence'}; |
| 521 |
|
| 522 |
my $shortname = ""; |
| 523 |
if ( $filename =~ /^\s*(.*?)\|\s*(.*?)\s*$/ ) |
| 524 |
{ |
| 525 |
$shortname = $1; |
| 526 |
$filename = $2; |
| 527 |
} |
| 528 |
|
| 529 |
# unique is the combination of $component and $filename |
| 530 |
my $key = "$comp/$filename"; |
| 531 |
|
| 532 |
if ( exists($uniquefilename{$key}) ) { installer::exiter::exit_program("ERROR: Component/FileName \"$key\" is not unique in table \"File\" !", "create_database_hashes"); } |
| 533 |
|
| 534 |
my $value = $uniquename; |
| 535 |
if ( $shortname ne "" ) { $value = "$uniquename;$shortname"; } |
| 536 |
$uniquefilename{$key} = $value; # saving the unique keys and short names in hash |
| 537 |
|
| 538 |
# Saving reverse keys too |
| 539 |
$revuniquefilename{$uniquename} = $key; |
| 540 |
if ( $shortname ne "" ) { $revshortfilename{$shortname} = $key; } |
| 541 |
|
| 542 |
# Saving Sequences for unique names (and also components) |
| 543 |
$allupdatesequences{$uniquename} = $sequence; |
| 544 |
$allupdatecomponents{$uniquename} = $comp; |
| 545 |
|
| 546 |
# Saving unique names and components for sequences |
| 547 |
$allupdatefileorder{$sequence} = $uniquename; |
| 548 |
$allupdatecomponentorder{$sequence} = $comp; |
| 549 |
} |
| 550 |
|
| 551 |
# 2. Hash, required in Directory table. |
| 552 |
|
| 553 |
my $dirtable = $database->{'Directory'}; |
| 554 |
|
| 555 |
foreach my $linenumber ( keys %{$dirtable} ) |
| 556 |
{ |
| 557 |
my $dir = $dirtable->{$linenumber}->{'Directory'}; # this is a unique name |
| 558 |
my $defaultdir = $dirtable->{$linenumber}->{'DefaultDir'}; |
| 559 |
|
| 560 |
my $shortname = ""; |
| 561 |
if ( $defaultdir =~ /^\s*(.*?)\|\s*(.*?)\s*$/ ) |
| 562 |
{ |
| 563 |
$shortname = $1; |
| 564 |
$shortdirname{$dir} = $shortname; # collecting only the short names |
| 565 |
} |
| 566 |
} |
| 567 |
|
| 568 |
# 3. Hash, collecting info from Component table. |
| 569 |
# ComponentID and KeyPath have to be reused. |
| 570 |
|
| 571 |
my $comptable = $database->{'Component'}; |
| 572 |
|
| 573 |
foreach my $linenumber ( keys %{$comptable} ) |
| 574 |
{ |
| 575 |
my $comp = $comptable->{$linenumber}->{'Component'}; |
| 576 |
my $compid = $comptable->{$linenumber}->{'ComponentId'}; |
| 577 |
my $keypath = $comptable->{$linenumber}->{'KeyPath'}; |
| 578 |
|
| 579 |
$componentid{$comp} = $compid; |
| 580 |
$componentidkeypath{$comp} = $keypath; |
| 581 |
} |
| 582 |
|
| 583 |
# 4. Hash, property table, required for ProductCode and Installlocation. |
| 584 |
|
| 585 |
my $proptable = $database->{'Property'}; |
| 586 |
|
| 587 |
foreach my $linenumber ( keys %{$proptable} ) |
| 588 |
{ |
| 589 |
my $prop = $proptable->{$linenumber}->{'Property'}; |
| 590 |
my $value = $proptable->{$linenumber}->{'Value'}; |
| 591 |
|
| 592 |
$alloldproperties{$prop} = $value; |
| 593 |
} |
| 594 |
|
| 595 |
# 5. Media table, getting last sequence |
| 596 |
|
| 597 |
my $mediatable = $database->{'Media'}; |
| 598 |
$installer::globals::updatelastsequence = 0; |
| 599 |
|
| 600 |
foreach my $linenumber ( keys %{$mediatable} ) |
| 601 |
{ |
| 602 |
my $cabname = $mediatable->{$linenumber}->{'Cabinet'}; |
| 603 |
my $lastsequence = $mediatable->{$linenumber}->{'LastSequence'}; |
| 604 |
my $diskid = $mediatable->{$linenumber}->{'DiskId'}; |
| 605 |
$allupdatelastsequences{$cabname} = $lastsequence; |
| 606 |
$allupdatediskids{$cabname} = $diskid; |
| 607 |
|
| 608 |
if ( $lastsequence > $installer::globals::updatelastsequence ) { $installer::globals::updatelastsequence = $lastsequence; } |
| 609 |
} |
| 610 |
|
| 611 |
$installer::globals::updatesequencecounter = $installer::globals::updatelastsequence; |
| 612 |
|
| 613 |
return (\%uniquefilename, \%revuniquefilename, \%revshortfilename, \%allupdatesequences, \%allupdatecomponents, \%allupdatefileorder, \%allupdatecomponentorder, \%shortdirname, \%componentid, \%componentidkeypath, \%alloldproperties, \%allupdatelastsequences, \%allupdatediskids); |
| 614 |
} |
| 615 |
|
| 616 |
|
| 617 |
1; |