| 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::msiglobal; |
| 20 |
|
| 21 |
use strict; |
| 22 |
use warnings; |
| 23 |
|
| 24 |
use Cwd; |
| 25 |
use Digest::MD5; |
| 26 |
use installer::converter; |
| 27 |
use installer::exiter; |
| 28 |
use installer::files; |
| 29 |
use installer::globals; |
| 30 |
use installer::logger; |
| 31 |
use installer::pathanalyzer; |
| 32 |
use installer::remover; |
| 33 |
use installer::scriptitems; |
| 34 |
use installer::systemactions; |
| 35 |
use installer::worker; |
| 36 |
use installer::windows::idtglobal; |
| 37 |
use installer::windows::language; |
| 38 |
|
| 39 |
########################################################################### |
| 40 |
# Generating the header of the ddf file. |
| 41 |
# The usage of ddf files is needed, because makecab.exe can only include |
| 42 |
# one sourcefile into a cab file |
| 43 |
########################################################################### |
| 44 |
|
| 45 |
sub write_ddf_file_header |
| 46 |
{ |
| 47 |
my ($ddffileref, $cabinetfile, $installdir) = @_; |
| 48 |
|
| 49 |
my $oneline; |
| 50 |
|
| 51 |
$oneline = ".Set CabinetName1=" . $cabinetfile . "\n"; |
| 52 |
push(@{$ddffileref} ,$oneline); |
| 53 |
$oneline = ".Set ReservePerCabinetSize=128\n"; # This reserves space for a digital signature. |
| 54 |
push(@{$ddffileref} ,$oneline); |
| 55 |
$oneline = ".Set MaxDiskSize=2147483648\n"; # This allows the .cab file to get a size of 2 GB. |
| 56 |
push(@{$ddffileref} ,$oneline); |
| 57 |
$oneline = ".Set CompressionType=LZX\n"; |
| 58 |
push(@{$ddffileref} ,$oneline); |
| 59 |
$oneline = ".Set Compress=ON\n"; |
| 60 |
push(@{$ddffileref} ,$oneline); |
| 61 |
# The window size for LZX compression |
| 62 |
# CompressionMemory=15 | 16 | ... | 21 |
| 63 |
# Reference: http://msdn.microsoft.com/en-us/library/bb417343.aspx |
| 64 |
$oneline = ".Set CompressionMemory=$installer::globals::cabfilecompressionlevel\n"; |
| 65 |
push(@{$ddffileref} ,$oneline); |
| 66 |
$oneline = ".Set Cabinet=ON\n"; |
| 67 |
push(@{$ddffileref} ,$oneline); |
| 68 |
$oneline = ".Set DiskDirectoryTemplate=" . $installdir . "\n"; |
| 69 |
push(@{$ddffileref} ,$oneline); |
| 70 |
} |
| 71 |
|
| 72 |
########################################################################## |
| 73 |
# Lines in ddf files must not contain more than 256 characters |
| 74 |
########################################################################## |
| 75 |
|
| 76 |
sub check_ddf_file |
| 77 |
{ |
| 78 |
my ( $ddffile, $ddffilename ) = @_; |
| 79 |
|
| 80 |
my $maxlength = 0; |
| 81 |
my $maxline = 0; |
| 82 |
my $linelength = 0; |
| 83 |
my $linenumber = 0; |
| 84 |
|
| 85 |
for ( my $i = 0; $i <= $#{$ddffile}; $i++ ) |
| 86 |
{ |
| 87 |
my $oneline = ${$ddffile}[$i]; |
| 88 |
|
| 89 |
$linelength = length($oneline); |
| 90 |
$linenumber = $i + 1; |
| 91 |
|
| 92 |
if ( $linelength > 256 ) |
| 93 |
{ |
| 94 |
installer::exiter::exit_program("ERROR \"$ddffilename\" line $linenumber: Lines in ddf files must not contain more than 256 characters!", "check_ddf_file"); |
| 95 |
} |
| 96 |
|
| 97 |
if ( $linelength > $maxlength ) |
| 98 |
{ |
| 99 |
$maxlength = $linelength; |
| 100 |
$maxline = $linenumber; |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
my $infoline = "Check of ddf file \"$ddffilename\": Maximum length \"$maxlength\" in line \"$maxline\" (allowed line length: 256 characters)\n"; |
| 105 |
push(@installer::globals::logfileinfo, $infoline); |
| 106 |
} |
| 107 |
|
| 108 |
########################################################################## |
| 109 |
# Lines in ddf files must not be longer than 256 characters. |
| 110 |
# Therefore it can be useful to use relative paths. Then it is |
| 111 |
# necessary to change into temp directory before calling |
| 112 |
# makecab.exe. |
| 113 |
########################################################################## |
| 114 |
|
| 115 |
sub make_relative_ddf_path |
| 116 |
{ |
| 117 |
my ( $sourcepath ) = @_; |
| 118 |
|
| 119 |
my $windowstemppath = $installer::globals::temppath; |
| 120 |
|
| 121 |
if ( $^O =~ /cygwin/i ) |
| 122 |
{ |
| 123 |
$windowstemppath = $installer::globals::cyg_temppath; |
| 124 |
} |
| 125 |
|
| 126 |
$sourcepath =~ s/\Q$windowstemppath\E//; |
| 127 |
$sourcepath =~ s/^[\\\/]//; |
| 128 |
|
| 129 |
return $sourcepath; |
| 130 |
} |
| 131 |
|
| 132 |
########################################################################## |
| 133 |
# Returning the order of the sequences in the files array. |
| 134 |
########################################################################## |
| 135 |
|
| 136 |
sub get_sequenceorder |
| 137 |
{ |
| 138 |
my ($filesref) = @_; |
| 139 |
|
| 140 |
my %order = (); |
| 141 |
|
| 142 |
for ( my $i = 0; $i <= $#{$filesref}; $i++ ) |
| 143 |
{ |
| 144 |
my $onefile = ${$filesref}[$i]; |
| 145 |
if ( ! $onefile->{'assignedsequencenumber'} ) { installer::exiter::exit_program("ERROR: No sequence number assigned to $onefile->{'gid'} ($onefile->{'uniquename'})!", "get_sequenceorder"); } |
| 146 |
$order{$onefile->{'assignedsequencenumber'}} = $i; |
| 147 |
} |
| 148 |
|
| 149 |
return \%order; |
| 150 |
} |
| 151 |
|
| 152 |
########################################################################## |
| 153 |
# Generation the list, in which the source of the files is connected |
| 154 |
# with the cabinet destination file. Because more than one file needs |
| 155 |
# to be included into a cab file, this has to be done via ddf files. |
| 156 |
########################################################################## |
| 157 |
|
| 158 |
sub generate_cab_file_list |
| 159 |
{ |
| 160 |
my ($filesref, $installdir, $ddfdir, $allvariables) = @_; |
| 161 |
|
| 162 |
my @cabfilelist = (); |
| 163 |
|
| 164 |
installer::logger::include_header_into_logfile("Generating ddf files"); |
| 165 |
|
| 166 |
installer::logger::include_timestamp_into_logfile("Performance Info: ddf file generation start"); |
| 167 |
|
| 168 |
if ( $^O =~ /cygwin/i ) { installer::worker::generate_cygwin_paths($filesref); } |
| 169 |
|
| 170 |
if (( $installer::globals::fix_number_of_cab_files ) && ( $installer::globals::updatedatabase )) |
| 171 |
{ |
| 172 |
my $sequenceorder = get_sequenceorder($filesref); |
| 173 |
|
| 174 |
my $counter = 1; |
| 175 |
|
| 176 |
while ( ( exists($sequenceorder->{$counter}) ) || ( exists($installer::globals::allmergemodulefilesequences{$counter}) ) ) # Taking care of files from merge modules |
| 177 |
{ |
| 178 |
# if ( exists($installer::globals::allmergemodulefilesequences{$counter}) ) |
| 179 |
# { |
| 180 |
# # Skipping this sequence, it is not included in $filesref, because it is assigned to a file from a merge module.\n"; |
| 181 |
# $counter++; |
| 182 |
# next; |
| 183 |
# } |
| 184 |
|
| 185 |
my $onefile = ${$filesref}[$sequenceorder->{$counter}]; |
| 186 |
$counter++; |
| 187 |
|
| 188 |
my $cabinetfile = $onefile->{'cabinet'}; |
| 189 |
my $sourcepath = $onefile->{'sourcepath'}; |
| 190 |
if ( $^O =~ /cygwin/i ) { $sourcepath = $onefile->{'cyg_sourcepath'}; } |
| 191 |
my $uniquename = $onefile->{'uniquename'}; |
| 192 |
|
| 193 |
my $styles = ""; |
| 194 |
my $doinclude = 1; |
| 195 |
if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }; |
| 196 |
if ( $styles =~ /\bDONT_PACK\b/ ) { $doinclude = 0; } |
| 197 |
|
| 198 |
# to avoid lines with more than 256 characters, it can be useful to use relative paths |
| 199 |
$sourcepath = make_relative_ddf_path($sourcepath); |
| 200 |
|
| 201 |
my @ddffile = (); |
| 202 |
|
| 203 |
write_ddf_file_header(\@ddffile, $cabinetfile, $installdir); |
| 204 |
|
| 205 |
my $ddfline = "\"" . $sourcepath . "\" \"" . $uniquename . "\"\n"; |
| 206 |
if ( $doinclude ) { push(@ddffile, $ddfline); } |
| 207 |
|
| 208 |
my $nextfile = ""; |
| 209 |
if ( ${$filesref}[$sequenceorder->{$counter}] ) { $nextfile = ${$filesref}[$sequenceorder->{$counter}]; } |
| 210 |
|
| 211 |
my $nextcabinetfile = ""; |
| 212 |
|
| 213 |
if ( $nextfile->{'cabinet'} ) { $nextcabinetfile = $nextfile->{'cabinet'}; } |
| 214 |
|
| 215 |
while ( $nextcabinetfile eq $cabinetfile ) |
| 216 |
{ |
| 217 |
$sourcepath = $nextfile->{'sourcepath'}; |
| 218 |
if ( $^O =~ /cygwin/i ) { $sourcepath = $nextfile->{'cyg_sourcepath'}; } |
| 219 |
# to avoid lines with more than 256 characters, it can be useful to use relative paths |
| 220 |
$sourcepath = make_relative_ddf_path($sourcepath); |
| 221 |
$uniquename = $nextfile->{'uniquename'}; |
| 222 |
my $localdoinclude = 1; |
| 223 |
my $nextfilestyles = ""; |
| 224 |
if ( $nextfile->{'Styles'} ) { $nextfilestyles = $nextfile->{'Styles'}; } |
| 225 |
if ( $nextfilestyles =~ /\bDONT_PACK\b/ ) { $localdoinclude = 0; } |
| 226 |
$ddfline = "\"" . $sourcepath . "\" \"" . $uniquename . "\"\n"; |
| 227 |
if ( $localdoinclude ) { push(@ddffile, $ddfline); } |
| 228 |
$counter++; |
| 229 |
$nextfile = ""; |
| 230 |
$nextcabinetfile = "_lastfile_"; |
| 231 |
if (( exists($sequenceorder->{$counter}) ) && ( ${$filesref}[$sequenceorder->{$counter}] )) |
| 232 |
{ |
| 233 |
$nextfile = ${$filesref}[$sequenceorder->{$counter}]; |
| 234 |
$nextcabinetfile = $nextfile->{'cabinet'}; |
| 235 |
} |
| 236 |
} |
| 237 |
|
| 238 |
# creating the DDF file |
| 239 |
|
| 240 |
my $ddffilename = $cabinetfile; |
| 241 |
$ddffilename =~ s/.cab/.ddf/; |
| 242 |
$ddfdir =~ s/\Q$installer::globals::separator\E\s*$//; |
| 243 |
$ddffilename = $ddfdir . $installer::globals::separator . $ddffilename; |
| 244 |
|
| 245 |
installer::files::save_file($ddffilename ,\@ddffile); |
| 246 |
my $infoline = "Created ddf file: $ddffilename\n"; |
| 247 |
push(@installer::globals::logfileinfo, $infoline); |
| 248 |
|
| 249 |
# lines in ddf files must not be longer than 256 characters |
| 250 |
check_ddf_file(\@ddffile, $ddffilename); |
| 251 |
|
| 252 |
# Writing the makecab system call |
| 253 |
|
| 254 |
my $oneline = "makecab.exe /V3 /F " . $ddffilename . " 2\>\&1 |" . "\n"; |
| 255 |
|
| 256 |
push(@cabfilelist, $oneline); |
| 257 |
|
| 258 |
# collecting all ddf files |
| 259 |
push(@installer::globals::allddffiles, $ddffilename); |
| 260 |
} |
| 261 |
} |
| 262 |
elsif ( $installer::globals::fix_number_of_cab_files ) |
| 263 |
{ |
| 264 |
for ( my $i = 0; $i <= $#{$filesref}; $i++ ) |
| 265 |
{ |
| 266 |
my $onefile = ${$filesref}[$i]; |
| 267 |
my $cabinetfile = $onefile->{'cabinet'}; |
| 268 |
my $sourcepath = $onefile->{'sourcepath'}; |
| 269 |
if ( $^O =~ /cygwin/i ) { $sourcepath = $onefile->{'cyg_sourcepath'}; } |
| 270 |
my $uniquename = $onefile->{'uniquename'}; |
| 271 |
|
| 272 |
my $styles = ""; |
| 273 |
my $doinclude = 1; |
| 274 |
if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }; |
| 275 |
if ( $styles =~ /\bDONT_PACK\b/ ) { $doinclude = 0; } |
| 276 |
|
| 277 |
|
| 278 |
# to avoid lines with more than 256 characters, it can be useful to use relative paths |
| 279 |
$sourcepath = make_relative_ddf_path($sourcepath); |
| 280 |
|
| 281 |
# all files with the same cabinetfile are directly behind each other in the files collector |
| 282 |
|
| 283 |
my @ddffile = (); |
| 284 |
|
| 285 |
write_ddf_file_header(\@ddffile, $cabinetfile, $installdir); |
| 286 |
|
| 287 |
my $ddfline = "\"" . $sourcepath . "\" \"" . $uniquename . "\"\n"; |
| 288 |
if ( $doinclude ) { push(@ddffile, $ddfline); } |
| 289 |
|
| 290 |
my $nextfile = ${$filesref}[$i+1]; |
| 291 |
my $nextcabinetfile = ""; |
| 292 |
|
| 293 |
if ( $nextfile->{'cabinet'} ) { $nextcabinetfile = $nextfile->{'cabinet'}; } |
| 294 |
|
| 295 |
while ( $nextcabinetfile eq $cabinetfile ) |
| 296 |
{ |
| 297 |
$sourcepath = $nextfile->{'sourcepath'}; |
| 298 |
if ( $^O =~ /cygwin/i ) { $sourcepath = $nextfile->{'cyg_sourcepath'}; } |
| 299 |
# to avoid lines with more than 256 characters, it can be useful to use relative paths |
| 300 |
$sourcepath = make_relative_ddf_path($sourcepath); |
| 301 |
$uniquename = $nextfile->{'uniquename'}; |
| 302 |
my $localdoinclude = 1; |
| 303 |
my $nextfilestyles = ""; |
| 304 |
if ( $nextfile->{'Styles'} ) { $nextfilestyles = $nextfile->{'Styles'}; } |
| 305 |
if ( $nextfilestyles =~ /\bDONT_PACK\b/ ) { $localdoinclude = 0; } |
| 306 |
$ddfline = "\"" . $sourcepath . "\" \"" . $uniquename . "\"\n"; |
| 307 |
if ( $localdoinclude ) { push(@ddffile, $ddfline); } |
| 308 |
$i++; # increasing the counter! |
| 309 |
$nextfile = ${$filesref}[$i+1]; |
| 310 |
if ( $nextfile ) { $nextcabinetfile = $nextfile->{'cabinet'}; } |
| 311 |
else { $nextcabinetfile = "_lastfile_"; } |
| 312 |
} |
| 313 |
|
| 314 |
# creating the DDF file |
| 315 |
|
| 316 |
my $ddffilename = $cabinetfile; |
| 317 |
$ddffilename =~ s/.cab/.ddf/; |
| 318 |
$ddfdir =~ s/\Q$installer::globals::separator\E\s*$//; |
| 319 |
$ddffilename = $ddfdir . $installer::globals::separator . $ddffilename; |
| 320 |
|
| 321 |
installer::files::save_file($ddffilename ,\@ddffile); |
| 322 |
my $infoline = "Created ddf file: $ddffilename\n"; |
| 323 |
push(@installer::globals::logfileinfo, $infoline); |
| 324 |
|
| 325 |
# lines in ddf files must not be longer than 256 characters |
| 326 |
check_ddf_file(\@ddffile, $ddffilename); |
| 327 |
|
| 328 |
# Writing the makecab system call |
| 329 |
|
| 330 |
my $oneline = "makecab.exe /V3 /F " . $ddffilename . " 2\>\&1 |" . "\n"; |
| 331 |
|
| 332 |
push(@cabfilelist, $oneline); |
| 333 |
|
| 334 |
# collecting all ddf files |
| 335 |
push(@installer::globals::allddffiles, $ddffilename); |
| 336 |
} |
| 337 |
} |
| 338 |
else |
| 339 |
{ |
| 340 |
installer::exiter::exit_program("ERROR: No cab file specification in globals.pm !", "generate_cab_file_list"); |
| 341 |
} |
| 342 |
|
| 343 |
installer::logger::include_timestamp_into_logfile("Performance Info: ddf file generation end"); |
| 344 |
|
| 345 |
return \@cabfilelist; # contains all system calls for packaging process |
| 346 |
} |
| 347 |
|
| 348 |
######################################################################## |
| 349 |
# For update and patch reasons the pack order needs to be saved. |
| 350 |
# The pack order is saved in the ddf files; the names and locations |
| 351 |
# of the ddf files are saved in @installer::globals::allddffiles. |
| 352 |
# The outputfile "packorder.txt" can be saved in |
| 353 |
# $installer::globals::infodirectory . |
| 354 |
######################################################################## |
| 355 |
|
| 356 |
sub save_packorder |
| 357 |
{ |
| 358 |
installer::logger::include_header_into_logfile("Saving pack order"); |
| 359 |
|
| 360 |
installer::logger::include_timestamp_into_logfile("Performance Info: saving pack order start"); |
| 361 |
|
| 362 |
my $packorderfilename = "packorder.txt"; |
| 363 |
$packorderfilename = $installer::globals::infodirectory . $installer::globals::separator . $packorderfilename; |
| 364 |
|
| 365 |
my @packorder = (); |
| 366 |
|
| 367 |
my $headerline = "\# Syntax\: Filetable_Sequence Cabinetfilename Physical_FileName Unique_FileName\n\n"; |
| 368 |
push(@packorder, $headerline); |
| 369 |
|
| 370 |
for ( my $i = 0; $i <= $#installer::globals::allddffiles; $i++ ) |
| 371 |
{ |
| 372 |
my $ddffilename = $installer::globals::allddffiles[$i]; |
| 373 |
my $ddffile = installer::files::read_file($ddffilename); |
| 374 |
my $cabinetfile = ""; |
| 375 |
|
| 376 |
for ( my $j = 0; $j <= $#{$ddffile}; $j++ ) |
| 377 |
{ |
| 378 |
my $oneline = ${$ddffile}[$j]; |
| 379 |
|
| 380 |
# Getting the Cabinet file name |
| 381 |
|
| 382 |
if ( $oneline =~ /^\s*\.Set\s+CabinetName.*\=(.*?)\s*$/ ) { $cabinetfile = $1; } |
| 383 |
if ( $oneline =~ /^\s*\.Set\s+/ ) { next; } |
| 384 |
|
| 385 |
if ( $oneline =~ /^\s*\"(.*?)\"\s+\"(.*?)\"\s*$/ ) |
| 386 |
{ |
| 387 |
my $sourcefile = $1; |
| 388 |
my $uniquefilename = $2; |
| 389 |
|
| 390 |
installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$sourcefile); |
| 391 |
|
| 392 |
# Using the hash created in create_files_table for performance reasons to get the sequence number |
| 393 |
my $filesequence = ""; |
| 394 |
if ( exists($installer::globals::uniquefilenamesequence{$uniquefilename}) ) { $filesequence = $installer::globals::uniquefilenamesequence{$uniquefilename}; } |
| 395 |
else { installer::exiter::exit_program("ERROR: No sequence number value for $uniquefilename !", "save_packorder"); } |
| 396 |
|
| 397 |
my $line = $filesequence . "\t" . $cabinetfile . "\t" . $sourcefile . "\t" . $uniquefilename . "\n"; |
| 398 |
push(@packorder, $line); |
| 399 |
} |
| 400 |
} |
| 401 |
} |
| 402 |
|
| 403 |
installer::files::save_file($packorderfilename ,\@packorder); |
| 404 |
|
| 405 |
installer::logger::include_timestamp_into_logfile("Performance Info: saving pack order end"); |
| 406 |
} |
| 407 |
|
| 408 |
################################################################# |
| 409 |
# Returning the name of the msi database |
| 410 |
################################################################# |
| 411 |
|
| 412 |
sub get_msidatabasename |
| 413 |
{ |
| 414 |
my ($allvariableshashref, $language) = @_; |
| 415 |
|
| 416 |
my $databasename = $allvariableshashref->{'PRODUCTNAME'} . $allvariableshashref->{'PRODUCTVERSION'}; |
| 417 |
$databasename = lc($databasename); |
| 418 |
$databasename =~ s/\.//g; |
| 419 |
$databasename =~ s/\-//g; |
| 420 |
$databasename =~ s/\s//g; |
| 421 |
|
| 422 |
# possibility to overwrite the name with variable DATABASENAME |
| 423 |
if ( $allvariableshashref->{'DATABASENAME'} ) |
| 424 |
{ |
| 425 |
$databasename = $allvariableshashref->{'DATABASENAME'}; |
| 426 |
} |
| 427 |
|
| 428 |
if ( $language ) |
| 429 |
{ |
| 430 |
if (!($language eq "")) |
| 431 |
{ |
| 432 |
$databasename .= "_$language"; |
| 433 |
} |
| 434 |
} |
| 435 |
|
| 436 |
$databasename .= ".msi"; |
| 437 |
|
| 438 |
return $databasename; |
| 439 |
} |
| 440 |
|
| 441 |
################################################################# |
| 442 |
# Creating the msi database |
| 443 |
# This works only on Windows |
| 444 |
################################################################# |
| 445 |
|
| 446 |
sub create_msi_database |
| 447 |
{ |
| 448 |
my ($idtdirbase ,$msifilename) = @_; |
| 449 |
|
| 450 |
# -f : path containing the idt files |
| 451 |
# -d : msi database, including path |
| 452 |
# -c : create database |
| 453 |
# -i : include the following tables ("*" includes all available tables) |
| 454 |
|
| 455 |
my $msidb = "msidb.exe"; # Has to be in the path |
| 456 |
my $extraslash = ""; # Has to be set for non-ActiveState perl |
| 457 |
|
| 458 |
installer::logger::include_header_into_logfile("Creating msi database"); |
| 459 |
|
| 460 |
$idtdirbase = installer::converter::make_path_conform($idtdirbase); |
| 461 |
|
| 462 |
$msifilename = installer::converter::make_path_conform($msifilename); |
| 463 |
|
| 464 |
if ( $^O =~ /cygwin/i || $^O =~ /MSWin/i ) { |
| 465 |
# msidb.exe really wants backslashes. (And double escaping because system() expands the string.) |
| 466 |
$idtdirbase =~ s/\//\\\\/g; |
| 467 |
$msifilename =~ s/\//\\\\/g; |
| 468 |
$extraslash = "\\"; |
| 469 |
} |
| 470 |
if ( $^O =~ /linux/i ) { |
| 471 |
$extraslash = "\\"; |
| 472 |
} |
| 473 |
my $systemcall = $msidb . " -f " . $idtdirbase . " -d " . $msifilename . " -c " . "-i " . $extraslash . "*"; |
| 474 |
|
| 475 |
my $systemcall_output = `$systemcall`; |
| 476 |
my $returnvalue = $? >> 8; |
| 477 |
|
| 478 |
my $infoline = "Systemcall: $systemcall\n"; |
| 479 |
push( @installer::globals::logfileinfo, $infoline); |
| 480 |
|
| 481 |
if ($returnvalue) |
| 482 |
{ |
| 483 |
$infoline = "ERROR: Could not execute $msidb! - returncode: $returnvalue - output:\n$systemcall_output\n"; |
| 484 |
push( @installer::globals::logfileinfo, $infoline); |
| 485 |
} |
| 486 |
else |
| 487 |
{ |
| 488 |
$infoline = "Success: Executed $msidb successfully!\n"; |
| 489 |
push( @installer::globals::logfileinfo, $infoline); |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
################################################################# |
| 494 |
# Returning the template for the Summary Information Stream |
| 495 |
################################################################# |
| 496 |
|
| 497 |
sub get_template_for_sis |
| 498 |
{ |
| 499 |
my ( $language, $allvariables ) = @_; |
| 500 |
|
| 501 |
my $windowslanguage = installer::windows::language::get_windows_language($language); |
| 502 |
|
| 503 |
my $architecture = "Intel"; |
| 504 |
|
| 505 |
if (( $allvariables->{'64BITPRODUCT'} ) && ( $allvariables->{'64BITPRODUCT'} == 1 )) { $architecture = "x64"; } |
| 506 |
|
| 507 |
$architecture = "Arm64" if($ENV{'RTL_ARCH'} eq "AARCH64"); |
| 508 |
|
| 509 |
my $value = "\"" . $architecture . ";" . $windowslanguage; # adding the Windows language |
| 510 |
|
| 511 |
$value = $value . "\""; # adding ending '"' |
| 512 |
|
| 513 |
return $value ; |
| 514 |
} |
| 515 |
|
| 516 |
################################################################# |
| 517 |
# Returning the PackageCode for the Summary Information Stream |
| 518 |
################################################################# |
| 519 |
|
| 520 |
sub get_packagecode_for_sis |
| 521 |
{ |
| 522 |
# always generating a new package code for each package |
| 523 |
|
| 524 |
my $guidref = get_guid_list(1, 1); # only one GUID shall be generated |
| 525 |
|
| 526 |
${$guidref}[0] =~ s/\s*$//; # removing ending spaces |
| 527 |
|
| 528 |
my $guid = "\{" . ${$guidref}[0] . "\}"; |
| 529 |
|
| 530 |
my $infoline = "PackageCode: $guid\n"; |
| 531 |
push( @installer::globals::logfileinfo, $infoline); |
| 532 |
|
| 533 |
return $guid; |
| 534 |
} |
| 535 |
|
| 536 |
################################################################# |
| 537 |
# Writing the Summary information stream into the msi database |
| 538 |
# This works only on Windows |
| 539 |
################################################################# |
| 540 |
|
| 541 |
sub write_summary_into_msi_database |
| 542 |
{ |
| 543 |
my ($msifilename, $language, $allvariableshashref) = @_; |
| 544 |
|
| 545 |
# -g : required msi version |
| 546 |
# -c : codepage |
| 547 |
# -p : template |
| 548 |
|
| 549 |
installer::logger::include_header_into_logfile("Writing summary information stream"); |
| 550 |
|
| 551 |
my $msiinfo = "msiinfo.exe"; # Has to be in the path |
| 552 |
|
| 553 |
# schema version needs to be at least 500 to support 64bit packages on Arm64 |
| 554 |
# see https://learn.microsoft.com/en-us/windows/win32/msi/using-64-bit-windows-installer-packages |
| 555 |
my $msiversion = 500; |
| 556 |
my $codepage = 0; # PID_CODEPAGE summary property in a signed short, therefore it is impossible to set 65001 here. |
| 557 |
my $template = get_template_for_sis($language, $allvariableshashref); |
| 558 |
my $guid = get_packagecode_for_sis(); |
| 559 |
my $title = "\"Installation database\""; |
| 560 |
my $author = "\"" . $installer::globals::longmanufacturer . "\""; |
| 561 |
my $subject = "\"" . $allvariableshashref->{'PRODUCTNAME'} . " " . $allvariableshashref->{'PRODUCTVERSION'} . "\""; |
| 562 |
my $comment = "\"" . $allvariableshashref->{'PRODUCTNAME'} ."\""; |
| 563 |
my $keywords = "\"Install,MSI\""; |
| 564 |
my $appname = "\"Windows Installer\""; |
| 565 |
my $security = 0; |
| 566 |
my $wordcount = 0; |
| 567 |
|
| 568 |
$msifilename = installer::converter::make_path_conform($msifilename); |
| 569 |
|
| 570 |
my $systemcall = $msiinfo . " " . $msifilename . " -g " . $msiversion . " -c " . $codepage |
| 571 |
. " -p " . $template . " -v " . $guid . " -t " . $title . " -a " . $author |
| 572 |
. " -j " . $subject . " -o " . $comment . " -k " . $keywords . " -n " . $appname |
| 573 |
. " -u " . $security . " -w " . $wordcount; |
| 574 |
|
| 575 |
my $systemcall_output = `$systemcall`; |
| 576 |
my $returnvalue = $? >> 8; |
| 577 |
|
| 578 |
my $infoline = "Systemcall: $systemcall\n"; |
| 579 |
push( @installer::globals::logfileinfo, $infoline); |
| 580 |
|
| 581 |
if ($returnvalue) |
| 582 |
{ |
| 583 |
$infoline = "ERROR: Could not execute $systemcall (return $returnvalue) - output:\n$systemcall_output\n"; |
| 584 |
push( @installer::globals::logfileinfo, $infoline); |
| 585 |
} |
| 586 |
else |
| 587 |
{ |
| 588 |
$infoline = "Success: Executed $msiinfo successfully!\n"; |
| 589 |
push( @installer::globals::logfileinfo, $infoline); |
| 590 |
} |
| 591 |
} |
| 592 |
|
| 593 |
######################################################################### |
| 594 |
# For more than one language in the installation set: |
| 595 |
# Use one database and create Transformations for all other languages |
| 596 |
######################################################################### |
| 597 |
|
| 598 |
sub create_transforms |
| 599 |
{ |
| 600 |
my ($languagesarray, $defaultlanguage, $installdir, $allvariableshashref) = @_; |
| 601 |
|
| 602 |
installer::logger::include_header_into_logfile("Creating Transforms"); |
| 603 |
|
| 604 |
my $cscript = "cscript.exe"; # Has to be in the path |
| 605 |
my $msitran = "msitran.exe"; # Has to be in the path |
| 606 |
my $msidb = "msidb.exe"; # Has to be in the path |
| 607 |
my $wilangid = $ENV{WINDOWS_SDK_WILANGID}; |
| 608 |
|
| 609 |
my $from = cwd(); |
| 610 |
|
| 611 |
my $templatevalue = "1033"; |
| 612 |
|
| 613 |
$installdir = installer::converter::make_path_conform($installdir); |
| 614 |
|
| 615 |
# Syntax for creating a transformation |
| 616 |
# msitran.exe -g <baseDB> <referenceDB> <transformfile> [<errorhandling>} |
| 617 |
|
| 618 |
my $basedbname = get_msidatabasename($allvariableshashref, $defaultlanguage); |
| 619 |
$basedbname = $installdir . $installer::globals::separator . $basedbname; |
| 620 |
|
| 621 |
my $errorhandling = "f"; # Suppress "change codepage" error |
| 622 |
|
| 623 |
# Iterating over all files |
| 624 |
|
| 625 |
foreach ( @{$languagesarray} ) |
| 626 |
{ |
| 627 |
my $onelanguage = $_; |
| 628 |
|
| 629 |
if ( $onelanguage eq $defaultlanguage ) { next; } |
| 630 |
|
| 631 |
my $referencedbname = get_msidatabasename($allvariableshashref, $onelanguage); |
| 632 |
$referencedbname = $installdir . $installer::globals::separator . $referencedbname; |
| 633 |
|
| 634 |
my $windowslanguage = installer::windows::language::get_windows_language($onelanguage); |
| 635 |
my $transformfile = $installdir . $installer::globals::separator . $windowslanguage; |
| 636 |
|
| 637 |
my $systemcall = $msitran . " " . " -g " . $basedbname . " " . $referencedbname . " " . $transformfile . " " . $errorhandling; |
| 638 |
|
| 639 |
my $returnvalue = system($systemcall); |
| 640 |
|
| 641 |
my $infoline = "Systemcall: $systemcall\n"; |
| 642 |
push( @installer::globals::logfileinfo, $infoline); |
| 643 |
|
| 644 |
# Problem: msitran.exe in version 4.0 always returns "1", even if no failure occurred. |
| 645 |
# Therefore it has to be checked, if this is version 4.0. If yes, if the mst file |
| 646 |
# exists and if it is larger than 0 bytes. If this is true, then no error occurred. |
| 647 |
# File Version of msitran.exe: 4.0.6000.16384 has checksum: "b66190a70145a57773ec769e16777b29". |
| 648 |
# Same for msitran.exe from wntmsci12: "aa25d3445b94ffde8ef0c1efb77a56b8" |
| 649 |
|
| 650 |
if ($returnvalue) |
| 651 |
{ |
| 652 |
$infoline = "WARNING: Returnvalue of $msitran is not 0. Checking version of $msitran!\n"; |
| 653 |
push( @installer::globals::logfileinfo, $infoline); |
| 654 |
|
| 655 |
open(FILE, "<$installer::globals::msitranpath") or die "ERROR: Can't open $installer::globals::msitranpath for creating file hash"; |
| 656 |
binmode(FILE); |
| 657 |
my $digest = Digest::MD5->new->addfile(*FILE)->hexdigest; |
| 658 |
close(FILE); |
| 659 |
|
| 660 |
my @problemchecksums = ("b66190a70145a57773ec769e16777b29", "aa25d3445b94ffde8ef0c1efb77a56b8", "748206e54fc93efe6a1aaa9d491f3ad1"); |
| 661 |
my $isproblemchecksum = 0; |
| 662 |
|
| 663 |
foreach my $problemchecksum ( @problemchecksums ) |
| 664 |
{ |
| 665 |
$infoline = "Checksum of problematic MsiTran.exe: $problemchecksum\n"; |
| 666 |
push( @installer::globals::logfileinfo, $infoline); |
| 667 |
$infoline = "Checksum of used MsiTran.exe: $digest\n"; |
| 668 |
push( @installer::globals::logfileinfo, $infoline); |
| 669 |
if ( $digest eq $problemchecksum ) { $isproblemchecksum = 1; } |
| 670 |
} |
| 671 |
|
| 672 |
if ( $isproblemchecksum ) |
| 673 |
{ |
| 674 |
# Check existence of mst |
| 675 |
if ( -f $transformfile ) |
| 676 |
{ |
| 677 |
$infoline = "File $transformfile exists.\n"; |
| 678 |
push( @installer::globals::logfileinfo, $infoline); |
| 679 |
my $filesize = ( -s $transformfile ); |
| 680 |
$infoline = "Size of $transformfile: $filesize\n"; |
| 681 |
push( @installer::globals::logfileinfo, $infoline); |
| 682 |
|
| 683 |
if ( $filesize > 0 ) |
| 684 |
{ |
| 685 |
$infoline = "Info: Returnvalue $returnvalue of $msitran is no problem :-) .\n"; |
| 686 |
push( @installer::globals::logfileinfo, $infoline); |
| 687 |
$returnvalue = 0; # reset the error |
| 688 |
} |
| 689 |
else |
| 690 |
{ |
| 691 |
$infoline = "Filesize indicates that an error occurred.\n"; |
| 692 |
push( @installer::globals::logfileinfo, $infoline); |
| 693 |
} |
| 694 |
} |
| 695 |
else |
| 696 |
{ |
| 697 |
$infoline = "File $transformfile does not exist -> An error occurred.\n"; |
| 698 |
push( @installer::globals::logfileinfo, $infoline); |
| 699 |
} |
| 700 |
} |
| 701 |
else |
| 702 |
{ |
| 703 |
$infoline = "This is not a problematic version of msitran.exe. Therefore the error is not caused by problematic msitran.exe.\n"; |
| 704 |
push( @installer::globals::logfileinfo, $infoline); |
| 705 |
} |
| 706 |
} |
| 707 |
|
| 708 |
if ($returnvalue) |
| 709 |
{ |
| 710 |
$infoline = "ERROR: Could not execute $msitran!\n"; |
| 711 |
push( @installer::globals::logfileinfo, $infoline); |
| 712 |
} |
| 713 |
else |
| 714 |
{ |
| 715 |
$infoline = "Success: Executed $msitran successfully!\n"; |
| 716 |
push( @installer::globals::logfileinfo, $infoline); |
| 717 |
} |
| 718 |
|
| 719 |
# The reference database can be deleted |
| 720 |
|
| 721 |
my $result = unlink($referencedbname); |
| 722 |
# $result contains the number of deleted files |
| 723 |
|
| 724 |
if ( $result == 0 ) |
| 725 |
{ |
| 726 |
$infoline = "ERROR while processing language $onelanguage: Could not remove file $referencedbname!\n"; |
| 727 |
push( @installer::globals::logfileinfo, $infoline); |
| 728 |
installer::exiter::exit_program($infoline, "create_transforms"); |
| 729 |
} |
| 730 |
|
| 731 |
chdir($installdir); |
| 732 |
$systemcall = $msidb . " " . " -d " . $basedbname . " -r " . $windowslanguage; |
| 733 |
system($systemcall); |
| 734 |
# fdo#46181 - zh-HK and zh-MO should have fallen back to zh-TW not to zh-CN |
| 735 |
# we need to hack zh-HK and zh-MO LCIDs directly into the MSI |
| 736 |
if($windowslanguage eq '1028') |
| 737 |
{ |
| 738 |
rename 1028,3076; |
| 739 |
$systemcall = $msidb . " " . " -d " . $basedbname . " -r " . 3076; |
| 740 |
system($systemcall); |
| 741 |
rename 3076,5124; |
| 742 |
$systemcall = $msidb . " " . " -d " . $basedbname . " -r " . 5124; |
| 743 |
system($systemcall); |
| 744 |
$templatevalue = $templatevalue . "," . 3076 . "," . 5124; |
| 745 |
rename 5124,1028; |
| 746 |
} |
| 747 |
chdir($from); |
| 748 |
unlink($transformfile); |
| 749 |
|
| 750 |
$infoline = "Systemcall: $systemcall\n"; |
| 751 |
push( @installer::globals::logfileinfo, $infoline); |
| 752 |
|
| 753 |
if ( $windowslanguage ne '1033') |
| 754 |
{ |
| 755 |
$templatevalue = $templatevalue . "," . $windowslanguage; |
| 756 |
} |
| 757 |
} |
| 758 |
|
| 759 |
$ENV{TEMP} = $ENV{TMPDIR}; |
| 760 |
my $systemcall = "$cscript \"$wilangid\" $basedbname Package $templatevalue"; |
| 761 |
my $systemcall_output = `$systemcall`; |
| 762 |
my $returnvalue = $? >> 8; |
| 763 |
|
| 764 |
my $infoline = "Systemcall: $systemcall\n"; |
| 765 |
push( @installer::globals::logfileinfo, $infoline); |
| 766 |
|
| 767 |
if ($returnvalue) |
| 768 |
{ |
| 769 |
$infoline = "ERROR: $returnvalue from $systemcall - output:\n$systemcall_output\n"; |
| 770 |
push( @installer::globals::logfileinfo, $infoline); |
| 771 |
} |
| 772 |
else |
| 773 |
{ |
| 774 |
$infoline = "Success: Executed WiLangId.vbs successfully!\n"; |
| 775 |
push( @installer::globals::logfileinfo, $infoline); |
| 776 |
} |
| 777 |
} |
| 778 |
|
| 779 |
######################################################################### |
| 780 |
# The default language msi database does not need to contain |
| 781 |
# the language in the database name. Therefore the file |
| 782 |
# is renamed. Example: "openofficeorg20_01.msi" to "openofficeorg20.msi" |
| 783 |
######################################################################### |
| 784 |
|
| 785 |
sub rename_msi_database_in_installset |
| 786 |
{ |
| 787 |
my ($defaultlanguage, $installdir, $allvariableshashref) = @_; |
| 788 |
|
| 789 |
installer::logger::include_header_into_logfile("Renaming msi database"); |
| 790 |
|
| 791 |
my $olddatabasename = get_msidatabasename($allvariableshashref, $defaultlanguage); |
| 792 |
$olddatabasename = $installdir . $installer::globals::separator . $olddatabasename; |
| 793 |
|
| 794 |
my $newdatabasename = get_msidatabasename($allvariableshashref); |
| 795 |
|
| 796 |
$installer::globals::shortmsidatabasename = $newdatabasename; |
| 797 |
|
| 798 |
$newdatabasename = $installdir . $installer::globals::separator . $newdatabasename; |
| 799 |
|
| 800 |
installer::systemactions::rename_one_file($olddatabasename, $newdatabasename); |
| 801 |
|
| 802 |
$installer::globals::msidatabasename = $newdatabasename; |
| 803 |
} |
| 804 |
|
| 805 |
################################################################# |
| 806 |
# Copying MergeModules for the Windows installer into the |
| 807 |
# installation set. The list of MergeModules is located |
| 808 |
# in %installer::globals::copy_msm_files |
| 809 |
################################################################# |
| 810 |
|
| 811 |
sub copy_merge_modules_into_installset |
| 812 |
{ |
| 813 |
my ($installdir) = @_; |
| 814 |
|
| 815 |
installer::logger::include_header_into_logfile("Copying Merge files into installation set"); |
| 816 |
|
| 817 |
my $cabfile; |
| 818 |
foreach $cabfile ( keys %installer::globals::copy_msm_files ) |
| 819 |
{ |
| 820 |
my $sourcefile = $installer::globals::copy_msm_files{$cabfile}; |
| 821 |
my $destfile = $installdir . $installer::globals::separator . $cabfile; |
| 822 |
|
| 823 |
installer::systemactions::copy_one_file($sourcefile, $destfile); |
| 824 |
} |
| 825 |
} |
| 826 |
|
| 827 |
################################################################# |
| 828 |
# Getting a list of GUID using uuidgen.exe. |
| 829 |
# This works only on Windows |
| 830 |
################################################################# |
| 831 |
|
| 832 |
sub get_guid_list |
| 833 |
{ |
| 834 |
my ($number, $log) = @_; |
| 835 |
|
| 836 |
if ( $log ) { installer::logger::include_header_into_logfile("Generating $number GUID"); } |
| 837 |
|
| 838 |
my $uuidgen = $ENV{'UUIDGEN'}; # Has to be in the path |
| 839 |
|
| 840 |
# "-c" for uppercase output |
| 841 |
|
| 842 |
my $systemcall = "$uuidgen -n$number |"; |
| 843 |
open (UUIDGEN, "$systemcall" ) or die("uuidgen is missing."); |
| 844 |
my @uuidlist = <UUIDGEN>; |
| 845 |
close (UUIDGEN); |
| 846 |
|
| 847 |
my $infoline = "Systemcall: $systemcall\n"; |
| 848 |
if ( $log ) { push( @installer::globals::logfileinfo, $infoline); } |
| 849 |
|
| 850 |
my $comparenumber = $#uuidlist + 1; |
| 851 |
|
| 852 |
if ( $comparenumber == $number ) |
| 853 |
{ |
| 854 |
$infoline = "Success: Executed $uuidgen successfully!\n"; |
| 855 |
if ( $log ) { push( @installer::globals::logfileinfo, $infoline); } |
| 856 |
} |
| 857 |
else |
| 858 |
{ |
| 859 |
$infoline = "ERROR: Could not execute $uuidgen successfully!\n"; |
| 860 |
if ( $log ) { push( @installer::globals::logfileinfo, $infoline); } |
| 861 |
} |
| 862 |
|
| 863 |
# uppercase, no longer "-c", because this is only supported in uuidgen.exe v.1.01 |
| 864 |
for ( my $i = 0; $i <= $#uuidlist; $i++ ) { $uuidlist[$i] = uc($uuidlist[$i]); } |
| 865 |
|
| 866 |
return \@uuidlist; |
| 867 |
} |
| 868 |
|
| 869 |
################################################################# |
| 870 |
# Calculating a GUID with a string using md5. |
| 871 |
################################################################# |
| 872 |
|
| 873 |
sub calculate_guid |
| 874 |
{ |
| 875 |
my ( $string ) = @_; |
| 876 |
|
| 877 |
my $guid = ""; |
| 878 |
|
| 879 |
my $md5 = Digest::MD5->new; |
| 880 |
$md5->add($string); |
| 881 |
my $digest = $md5->hexdigest; |
| 882 |
$digest = uc($digest); |
| 883 |
|
| 884 |
my ($first, $second, $third, $fourth, $fifth) = unpack ('A8 A4 A4 A4 A12', $digest); |
| 885 |
$guid = "$first-$second-$third-$fourth-$fifth"; |
| 886 |
|
| 887 |
return $guid; |
| 888 |
} |
| 889 |
|
| 890 |
################################################################# |
| 891 |
# Calculating a ID with a string using md5 (very fast). |
| 892 |
################################################################# |
| 893 |
|
| 894 |
sub calculate_id |
| 895 |
{ |
| 896 |
my ( $string, $length ) = @_; |
| 897 |
|
| 898 |
my $id = ""; |
| 899 |
|
| 900 |
my $md5 = Digest::MD5->new; |
| 901 |
$md5->add($string); |
| 902 |
my $digest = lc($md5->hexdigest); |
| 903 |
$id = substr($digest, 0, $length); |
| 904 |
|
| 905 |
return $id; |
| 906 |
} |
| 907 |
|
| 908 |
################################################################# |
| 909 |
# Filling real component GUID into the component table. |
| 910 |
# This works only on Windows |
| 911 |
################################################################# |
| 912 |
|
| 913 |
sub set_uuid_into_component_table |
| 914 |
{ |
| 915 |
my ($idtdirbase, $allvariables) = @_; |
| 916 |
|
| 917 |
my $componenttablename = $idtdirbase . $installer::globals::separator . "Componen.idt"; |
| 918 |
|
| 919 |
my $componenttable = installer::files::read_file($componenttablename); |
| 920 |
|
| 921 |
# For update and patch reasons (small update) the GUID of an existing component must not change! |
| 922 |
# The collection of component GUIDs is saved in the directory $installer::globals::idttemplatepath in the file "components.txt" |
| 923 |
|
| 924 |
my $infoline = ""; |
| 925 |
my $counter = 0; |
| 926 |
|
| 927 |
for ( my $i = 3; $i <= $#{$componenttable}; $i++ ) # ignoring the first three lines |
| 928 |
{ |
| 929 |
my $oneline = ${$componenttable}[$i]; |
| 930 |
my $componentname = ""; |
| 931 |
if ( $oneline =~ /^\s*(\S+?)\t/ ) { $componentname = $1; } |
| 932 |
|
| 933 |
my $uuid = ""; |
| 934 |
|
| 935 |
if ( exists($installer::globals::calculated_component_guids{$componentname})) |
| 936 |
{ |
| 937 |
$uuid = $installer::globals::calculated_component_guids{$componentname}; |
| 938 |
} |
| 939 |
else |
| 940 |
{ |
| 941 |
# Calculating new GUID with the help of the component name. |
| 942 |
|
| 943 |
if ( ! exists($allvariables->{'PRODUCTVERSION'}) ) { installer::exiter::exit_program("ERROR: Could not find variable \"PRODUCTVERSION\" (required value for GUID creation)!", "set_uuid_into_component_table"); } |
| 944 |
my $sourcestring = $componentname . "_" . $allvariables->{'PRODUCTVERSION'}; |
| 945 |
$uuid = calculate_guid($sourcestring); |
| 946 |
$counter++; |
| 947 |
|
| 948 |
# checking, if there is a conflict with an already created guid |
| 949 |
if ( exists($installer::globals::allcalculated_guids{$uuid}) ) { installer::exiter::exit_program("ERROR: \"$uuid\" was already created before!", "set_uuid_into_component_table"); } |
| 950 |
$installer::globals::allcalculated_guids{$uuid} = 1; |
| 951 |
$installer::globals::calculated_component_guids{$componentname} = $uuid; |
| 952 |
} |
| 953 |
|
| 954 |
${$componenttable}[$i] =~ s/COMPONENTGUID/$uuid/; |
| 955 |
} |
| 956 |
|
| 957 |
installer::files::save_file($componenttablename, $componenttable); |
| 958 |
} |
| 959 |
|
| 960 |
######################################################################### |
| 961 |
# Adding final 64 properties into msi database, if required. |
| 962 |
# RegLocator : +16 in type column to search in 64 bit registry. |
| 963 |
# All conditions: "VersionNT" -> "VersionNT64" (several tables). |
| 964 |
# DrLocator: "SystemFolder" -> "System64Folder" |
| 965 |
# Already done: "+256" in Attributes column of table "Component". |
| 966 |
# Still following: Setting "x64" instead of "Intel" in Summary |
| 967 |
# Information Stream of msi database in "get_template_for_sis". |
| 968 |
######################################################################### |
| 969 |
|
| 970 |
sub prepare_64bit_database |
| 971 |
{ |
| 972 |
my ($basedir, $allvariables) = @_; |
| 973 |
|
| 974 |
my $infoline = ""; |
| 975 |
|
| 976 |
if (( $allvariables->{'64BITPRODUCT'} ) && ( $allvariables->{'64BITPRODUCT'} == 1 )) |
| 977 |
{ |
| 978 |
# 1. Beginning with table "RegLocat.idt". Adding "16" to the type. |
| 979 |
|
| 980 |
my $reglocatfile = ""; |
| 981 |
my $reglocatfilename = $basedir . $installer::globals::separator . "RegLocat.idt"; |
| 982 |
|
| 983 |
if ( -f $reglocatfilename ) |
| 984 |
{ |
| 985 |
my $saving_required = 0; |
| 986 |
$reglocatfile = installer::files::read_file($reglocatfilename); |
| 987 |
|
| 988 |
for ( my $i = 3; $i <= $#{$reglocatfile}; $i++ ) # ignoring the first three lines |
| 989 |
{ |
| 990 |
my $oneline = ${$reglocatfile}[$i]; |
| 991 |
|
| 992 |
if ( $oneline =~ /^\s*\#/ ) { next; } # this is a comment line |
| 993 |
if ( $oneline =~ /^\s*$/ ) { next; } |
| 994 |
|
| 995 |
if ( $oneline =~ /^\s*(.*?)\t(.*?)\t(.*?)\t(.*?)\t(\d+)\s*$/ ) |
| 996 |
{ |
| 997 |
# Syntax: Signature_ Root Key Name Type |
| 998 |
my $sig = $1; |
| 999 |
my $root = $2; |
| 1000 |
my $key = $3; |
| 1001 |
my $name = $4; |
| 1002 |
my $type = $5; |
| 1003 |
|
| 1004 |
$type = $type + 16; |
| 1005 |
|
| 1006 |
my $newline = $sig . "\t" . $root . "\t" . $key . "\t" . $name . "\t" . $type . "\n"; |
| 1007 |
${$reglocatfile}[$i] = $newline; |
| 1008 |
|
| 1009 |
$saving_required = 1; |
| 1010 |
} |
| 1011 |
} |
| 1012 |
|
| 1013 |
if ( $saving_required ) |
| 1014 |
{ |
| 1015 |
# Saving the files |
| 1016 |
installer::files::save_file($reglocatfilename ,$reglocatfile); |
| 1017 |
$infoline = "Making idt file 64 bit conform: $reglocatfilename\n"; |
| 1018 |
push(@installer::globals::logfileinfo, $infoline); |
| 1019 |
} |
| 1020 |
} |
| 1021 |
|
| 1022 |
# 2. Replacing all occurrences of "VersionNT" by "VersionNT64" |
| 1023 |
|
| 1024 |
my @versionnt_files = ("Componen.idt", "InstallE.idt", "InstallU.idt", "LaunchCo.idt"); |
| 1025 |
|
| 1026 |
foreach my $onefile ( @versionnt_files ) |
| 1027 |
{ |
| 1028 |
my $fullfilename = $basedir . $installer::globals::separator . $onefile; |
| 1029 |
|
| 1030 |
if ( -f $fullfilename ) |
| 1031 |
{ |
| 1032 |
my $saving_required = 0; |
| 1033 |
my $filecontent = installer::files::read_file($fullfilename); |
| 1034 |
|
| 1035 |
for ( my $i = 3; $i <= $#{$filecontent}; $i++ ) # ignoring the first three lines |
| 1036 |
{ |
| 1037 |
my $oneline = ${$filecontent}[$i]; |
| 1038 |
|
| 1039 |
if ( $oneline =~ /\bVersionNT\b/ ) |
| 1040 |
{ |
| 1041 |
${$filecontent}[$i] =~ s/\bVersionNT\b/VersionNT64/g; |
| 1042 |
$saving_required = 1; |
| 1043 |
} |
| 1044 |
} |
| 1045 |
|
| 1046 |
if ( $saving_required ) |
| 1047 |
{ |
| 1048 |
# Saving the files |
| 1049 |
installer::files::save_file($fullfilename ,$filecontent); |
| 1050 |
$infoline = "Making idt file 64 bit conform: $fullfilename\n"; |
| 1051 |
push(@installer::globals::logfileinfo, $infoline); |
| 1052 |
} |
| 1053 |
} |
| 1054 |
} |
| 1055 |
|
| 1056 |
# 3. Replacing all occurrences of "SystemFolder" by "System64Folder" in "DrLocato.idt" |
| 1057 |
|
| 1058 |
my $drlocatofilename = $basedir . $installer::globals::separator . "DrLocato.idt"; |
| 1059 |
if ( -f $drlocatofilename ) |
| 1060 |
{ |
| 1061 |
my $saving_required = 0; |
| 1062 |
my $drlocatofile = installer::files::read_file($drlocatofilename); |
| 1063 |
|
| 1064 |
for ( my $i = 3; $i <= $#{$drlocatofile}; $i++ ) # ignoring the first three lines |
| 1065 |
{ |
| 1066 |
my $oneline = ${$drlocatofile}[$i]; |
| 1067 |
|
| 1068 |
if ( $oneline =~ /\bSystemFolder\b/ ) |
| 1069 |
{ |
| 1070 |
${$drlocatofile}[$i] =~ s/\bSystemFolder\b/System64Folder/g; |
| 1071 |
$saving_required = 1; |
| 1072 |
} |
| 1073 |
} |
| 1074 |
|
| 1075 |
if ( $saving_required ) |
| 1076 |
{ |
| 1077 |
# Saving the files |
| 1078 |
installer::files::save_file($drlocatofilename ,$drlocatofile); |
| 1079 |
$infoline = "Making idt file 64 bit conform: $drlocatofilename\n"; |
| 1080 |
push(@installer::globals::logfileinfo, $infoline); |
| 1081 |
} |
| 1082 |
} |
| 1083 |
} |
| 1084 |
|
| 1085 |
} |
| 1086 |
|
| 1087 |
################################################################# |
| 1088 |
# Include all cab files into the msi database. |
| 1089 |
# This works only on Windows |
| 1090 |
################################################################# |
| 1091 |
|
| 1092 |
sub include_cabs_into_msi |
| 1093 |
{ |
| 1094 |
my ($installdir) = @_; |
| 1095 |
|
| 1096 |
installer::logger::include_header_into_logfile("Including cabs into msi database"); |
| 1097 |
|
| 1098 |
my $from = cwd(); |
| 1099 |
my $to = $installdir; |
| 1100 |
|
| 1101 |
chdir($to); |
| 1102 |
|
| 1103 |
my $infoline = "Changing into directory: $to"; |
| 1104 |
push( @installer::globals::logfileinfo, $infoline); |
| 1105 |
|
| 1106 |
my $msidb = "msidb.exe"; # Has to be in the path |
| 1107 |
my $extraslash = ""; # Has to be set for non-ActiveState perl |
| 1108 |
|
| 1109 |
my $msifilename = $installer::globals::msidatabasename; |
| 1110 |
|
| 1111 |
$msifilename = installer::converter::make_path_conform($msifilename); |
| 1112 |
|
| 1113 |
# msidb.exe really wants backslashes. (And double escaping because system() expands the string.) |
| 1114 |
$msifilename =~ s/\//\\\\/g; |
| 1115 |
$extraslash = "\\"; |
| 1116 |
|
| 1117 |
my $allcabfiles = installer::systemactions::find_file_with_file_extension("cab", $installdir); |
| 1118 |
|
| 1119 |
for ( my $i = 0; $i <= $#{$allcabfiles}; $i++ ) |
| 1120 |
{ |
| 1121 |
my $systemcall = $msidb . " -d " . $msifilename . " -a " . ${$allcabfiles}[$i]; |
| 1122 |
|
| 1123 |
my $returnvalue = system($systemcall); |
| 1124 |
|
| 1125 |
$infoline = "Systemcall: $systemcall\n"; |
| 1126 |
push( @installer::globals::logfileinfo, $infoline); |
| 1127 |
|
| 1128 |
if ($returnvalue) |
| 1129 |
{ |
| 1130 |
$infoline = "ERROR: Could not execute $systemcall !\n"; |
| 1131 |
push( @installer::globals::logfileinfo, $infoline); |
| 1132 |
} |
| 1133 |
else |
| 1134 |
{ |
| 1135 |
$infoline = "Success: Executed $systemcall successfully!\n"; |
| 1136 |
push( @installer::globals::logfileinfo, $infoline); |
| 1137 |
} |
| 1138 |
|
| 1139 |
# deleting the cab file |
| 1140 |
|
| 1141 |
unlink(${$allcabfiles}[$i]); |
| 1142 |
|
| 1143 |
$infoline = "Deleted cab file: ${$allcabfiles}[$i]\n"; |
| 1144 |
push( @installer::globals::logfileinfo, $infoline); |
| 1145 |
} |
| 1146 |
|
| 1147 |
$infoline = "Changing back into directory: $from"; |
| 1148 |
push( @installer::globals::logfileinfo, $infoline); |
| 1149 |
|
| 1150 |
chdir($from); |
| 1151 |
} |
| 1152 |
|
| 1153 |
################################################################# |
| 1154 |
# Executing the created batch file to pack all files. |
| 1155 |
# This works only on Windows |
| 1156 |
################################################################# |
| 1157 |
|
| 1158 |
sub execute_packaging |
| 1159 |
{ |
| 1160 |
my ($localpackjobref, $loggingdir, $allvariables) = @_; |
| 1161 |
|
| 1162 |
installer::logger::include_header_into_logfile("Packaging process"); |
| 1163 |
|
| 1164 |
installer::logger::include_timestamp_into_logfile("Performance Info: Execute packaging start"); |
| 1165 |
|
| 1166 |
my $infoline = ""; |
| 1167 |
my $from = cwd(); |
| 1168 |
my $to = $loggingdir; |
| 1169 |
|
| 1170 |
chdir($to); |
| 1171 |
$infoline = "chdir: $to \n"; |
| 1172 |
push( @installer::globals::logfileinfo, $infoline); |
| 1173 |
|
| 1174 |
# the ddf file contains relative paths, it is necessary to change into the temp directory |
| 1175 |
$to = $installer::globals::temppath; |
| 1176 |
chdir($to); |
| 1177 |
$infoline = "chdir: $to \n"; |
| 1178 |
push( @installer::globals::logfileinfo, $infoline); |
| 1179 |
|
| 1180 |
my $maxmakecabcalls = 3; |
| 1181 |
my $allmakecabcalls = $#{$localpackjobref} + 1; |
| 1182 |
|
| 1183 |
for ( my $i = 0; $i <= $#{$localpackjobref}; $i++ ) |
| 1184 |
{ |
| 1185 |
my $systemcall = ${$localpackjobref}[$i]; |
| 1186 |
|
| 1187 |
my $callscounter = $i + 1; |
| 1188 |
|
| 1189 |
installer::logger::print_message( "... makecab.exe ($callscounter/$allmakecabcalls) ... \n" ); |
| 1190 |
|
| 1191 |
for ( my $n = 1; $n <= $maxmakecabcalls; $n++ ) |
| 1192 |
{ |
| 1193 |
my @ddfoutput = (); |
| 1194 |
|
| 1195 |
$infoline = "Systemcall: $systemcall"; |
| 1196 |
push( @installer::globals::logfileinfo, $infoline); |
| 1197 |
|
| 1198 |
open (DDF, "$systemcall"); |
| 1199 |
while (<DDF>) {push(@ddfoutput, $_); } |
| 1200 |
close (DDF); |
| 1201 |
|
| 1202 |
my $returnvalue = $?; # $? contains the return value of the systemcall |
| 1203 |
|
| 1204 |
if ($returnvalue) |
| 1205 |
{ |
| 1206 |
if ( $n < $maxmakecabcalls ) |
| 1207 |
{ |
| 1208 |
installer::logger::print_message( "makecab_error (Try $n): Trying again \n" ); |
| 1209 |
$infoline = "makecab_error (Try $n): $systemcall !"; |
| 1210 |
} |
| 1211 |
else |
| 1212 |
{ |
| 1213 |
installer::logger::print_message( "ERROR (Try $n): Abort packing \n" ); |
| 1214 |
$infoline = "ERROR (Try $n): $systemcall !"; |
| 1215 |
} |
| 1216 |
|
| 1217 |
push( @installer::globals::logfileinfo, $infoline); |
| 1218 |
|
| 1219 |
for ( my $m = 0; $m <= $#ddfoutput; $m++ ) |
| 1220 |
{ |
| 1221 |
if ( $ddfoutput[$m] =~ /(ERROR\:.*?)\s*$/ ) |
| 1222 |
{ |
| 1223 |
$infoline = $1 . "\n"; |
| 1224 |
if ( $n < $maxmakecabcalls ) { $infoline =~ s/ERROR\:/makecab_error\:/i; } |
| 1225 |
installer::logger::print_message( $infoline ); |
| 1226 |
push( @installer::globals::logfileinfo, $infoline); |
| 1227 |
} |
| 1228 |
} |
| 1229 |
|
| 1230 |
if ( $n == $maxmakecabcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "execute_packaging"); } |
| 1231 |
} |
| 1232 |
else |
| 1233 |
{ |
| 1234 |
$infoline = "Success (Try $n): $systemcall"; |
| 1235 |
push( @installer::globals::logfileinfo, $infoline); |
| 1236 |
last; |
| 1237 |
} |
| 1238 |
} |
| 1239 |
} |
| 1240 |
|
| 1241 |
installer::logger::include_timestamp_into_logfile("Performance Info: Execute packaging end"); |
| 1242 |
|
| 1243 |
chdir($from); |
| 1244 |
$infoline = "chdir: $from \n"; |
| 1245 |
push( @installer::globals::logfileinfo, $infoline); |
| 1246 |
} |
| 1247 |
|
| 1248 |
############################################################### |
| 1249 |
# Setting the global variables ProductCode and the UpgradeCode |
| 1250 |
############################################################### |
| 1251 |
|
| 1252 |
sub set_global_code_variables |
| 1253 |
{ |
| 1254 |
my ( $languagesref, $languagestringref, $allvariableshashref, $alloldproperties ) = @_; |
| 1255 |
|
| 1256 |
# In the msi template directory a files "codes.txt" has to exist, in which the ProductCode |
| 1257 |
# and the UpgradeCode for the product are defined. |
| 1258 |
# The name "codes.txt" can be overwritten in Product definition with CODEFILENAME . |
| 1259 |
# Default $installer::globals::codefilename is defined in parameter.pm. |
| 1260 |
|
| 1261 |
if ( $allvariableshashref->{'CODEFILENAME'} ) |
| 1262 |
{ |
| 1263 |
$installer::globals::codefilename = $installer::globals::idttemplatepath . $installer::globals::separator . $allvariableshashref->{'CODEFILENAME'}; |
| 1264 |
installer::files::check_file($installer::globals::codefilename); |
| 1265 |
} |
| 1266 |
|
| 1267 |
my $infoline = "Using Codes file: $installer::globals::codefilename \n"; |
| 1268 |
push( @installer::globals::logfileinfo, $infoline); |
| 1269 |
|
| 1270 |
my $codefile = installer::files::read_file($installer::globals::codefilename); |
| 1271 |
|
| 1272 |
my $onelanguage = ""; |
| 1273 |
|
| 1274 |
if ( $#{$languagesref} > 0 ) # more than one language |
| 1275 |
{ |
| 1276 |
if (( $installer::globals::added_english ) && ( $#{$languagesref} == 1 )) # only multilingual because of added English |
| 1277 |
{ |
| 1278 |
$onelanguage = ${$languagesref}[1]; # setting the first language, that is not english |
| 1279 |
} |
| 1280 |
else |
| 1281 |
{ |
| 1282 |
if (( ${$languagesref}[1] =~ /jp/ ) || |
| 1283 |
( ${$languagesref}[1] =~ /ko/ ) || |
| 1284 |
( ${$languagesref}[1] =~ /zh/ )) |
| 1285 |
{ |
| 1286 |
$onelanguage = "multiasia"; |
| 1287 |
} |
| 1288 |
else |
| 1289 |
{ |
| 1290 |
$onelanguage = "multiwestern"; |
| 1291 |
} |
| 1292 |
} |
| 1293 |
} |
| 1294 |
else # only one language |
| 1295 |
{ |
| 1296 |
$onelanguage = ${$languagesref}[0]; |
| 1297 |
} |
| 1298 |
|
| 1299 |
# ProductCode must not change, if Windows patches shall be applied |
| 1300 |
if ( $installer::globals::updatedatabase ) |
| 1301 |
{ |
| 1302 |
$installer::globals::productcode = $alloldproperties->{'ProductCode'}; |
| 1303 |
} |
| 1304 |
elsif ( $installer::globals::prepare_winpatch ) |
| 1305 |
{ |
| 1306 |
# ProductCode has to be specified in each language |
| 1307 |
my $searchstring = "PRODUCTCODE"; |
| 1308 |
my $codeblock = installer::windows::idtglobal::get_language_block_from_language_file($searchstring, $codefile); |
| 1309 |
$installer::globals::productcode = installer::windows::idtglobal::get_code_from_code_block($codeblock, $onelanguage); |
| 1310 |
} else { |
| 1311 |
my $guidref = get_guid_list(1, 1); # only one GUID shall be generated |
| 1312 |
${$guidref}[0] =~ s/\s*$//; # removing ending spaces |
| 1313 |
$installer::globals::productcode = "\{" . ${$guidref}[0] . "\}"; |
| 1314 |
} |
| 1315 |
|
| 1316 |
# UpgradeCode can take english as default, if not defined in specified language |
| 1317 |
|
| 1318 |
my $searchstring = "UPGRADECODE"; # searching in the codes.txt file |
| 1319 |
my $codeblock = installer::windows::idtglobal::get_language_block_from_language_file($searchstring, $codefile); |
| 1320 |
$installer::globals::upgradecode = installer::windows::idtglobal::get_language_string_from_language_block($codeblock, $onelanguage, ""); |
| 1321 |
|
| 1322 |
if ( $installer::globals::upgradecode eq "" ) { installer::exiter::exit_program("ERROR: UpgradeCode not defined in $installer::globals::codefilename !", "set_global_code_variables"); } |
| 1323 |
|
| 1324 |
$infoline = "Setting ProductCode to: $installer::globals::productcode \n"; |
| 1325 |
push( @installer::globals::logfileinfo, $infoline); |
| 1326 |
$infoline = "Setting UpgradeCode to: $installer::globals::upgradecode \n"; |
| 1327 |
push( @installer::globals::logfileinfo, $infoline); |
| 1328 |
|
| 1329 |
# Adding both variables into the variables array |
| 1330 |
|
| 1331 |
$allvariableshashref->{'PRODUCTCODE'} = $installer::globals::productcode; |
| 1332 |
$allvariableshashref->{'UPGRADECODE'} = $installer::globals::upgradecode; |
| 1333 |
|
| 1334 |
$infoline = "Defined variable PRODUCTCODE: $installer::globals::productcode \n"; |
| 1335 |
push( @installer::globals::logfileinfo, $infoline); |
| 1336 |
|
| 1337 |
$infoline = "Defined variable UPGRADECODE: $installer::globals::upgradecode \n"; |
| 1338 |
push( @installer::globals::logfileinfo, $infoline); |
| 1339 |
|
| 1340 |
} |
| 1341 |
|
| 1342 |
############################################################### |
| 1343 |
# Setting the product version used in property table and |
| 1344 |
# upgrade table. Saving in global variable $msiproductversion |
| 1345 |
############################################################### |
| 1346 |
|
| 1347 |
sub set_msiproductversion |
| 1348 |
{ |
| 1349 |
my ( $allvariables ) = @_; |
| 1350 |
|
| 1351 |
my $productversion = $allvariables->{'PACKAGEVERSION'}; |
| 1352 |
|
| 1353 |
if ( $productversion =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ ) |
| 1354 |
{ |
| 1355 |
$productversion = $1 . "\." . $2 . "\." . $3 . "\." . $installer::globals::buildid; |
| 1356 |
} |
| 1357 |
|
| 1358 |
$installer::globals::msiproductversion = $productversion; |
| 1359 |
|
| 1360 |
# Setting $installer::globals::msimajorproductversion, to differ between old version in upgrade table |
| 1361 |
|
| 1362 |
if ( $installer::globals::msiproductversion =~ /^\s*(\d+)\./ ) |
| 1363 |
{ |
| 1364 |
my $major = $1; |
| 1365 |
$installer::globals::msimajorproductversion = $major . "\.0\.0"; |
| 1366 |
} |
| 1367 |
} |
| 1368 |
|
| 1369 |
#################################################################################### |
| 1370 |
# Updating the file Property.idt dynamically |
| 1371 |
# Content: |
| 1372 |
# Property Value |
| 1373 |
#################################################################################### |
| 1374 |
|
| 1375 |
sub update_reglocat_table |
| 1376 |
{ |
| 1377 |
my ($basedir, $allvariables) = @_; |
| 1378 |
|
| 1379 |
my $reglocatfilename = $basedir . $installer::globals::separator . "RegLocat.idt"; |
| 1380 |
|
| 1381 |
# Only do something, if this file exists |
| 1382 |
|
| 1383 |
if ( -f $reglocatfilename ) |
| 1384 |
{ |
| 1385 |
my $reglocatfile = installer::files::read_file($reglocatfilename); |
| 1386 |
|
| 1387 |
my $layername = ""; |
| 1388 |
if ( $allvariables->{'REGISTRYLAYERNAME'} ) |
| 1389 |
{ |
| 1390 |
$layername = $allvariables->{'REGISTRYLAYERNAME'}; |
| 1391 |
} |
| 1392 |
else |
| 1393 |
{ |
| 1394 |
for ( my $i = 0; $i <= $#{$reglocatfile}; $i++ ) |
| 1395 |
{ |
| 1396 |
if ( ${$reglocatfile}[$i] =~ /\bLAYERNAMETEMPLATE\b/ ) |
| 1397 |
{ |
| 1398 |
installer::exiter::exit_program("ERROR: Variable \"REGISTRYLAYERNAME\" has to be defined", "update_reglocat_table"); |
| 1399 |
} |
| 1400 |
} |
| 1401 |
} |
| 1402 |
|
| 1403 |
if ( $layername ne "" ) |
| 1404 |
{ |
| 1405 |
# Updating the layername in |
| 1406 |
|
| 1407 |
for ( my $i = 0; $i <= $#{$reglocatfile}; $i++ ) |
| 1408 |
{ |
| 1409 |
${$reglocatfile}[$i] =~ s/\bLAYERNAMETEMPLATE\b/$layername/; |
| 1410 |
} |
| 1411 |
|
| 1412 |
# Saving the file |
| 1413 |
installer::files::save_file($reglocatfilename ,$reglocatfile); |
| 1414 |
my $infoline = "Updated idt file: $reglocatfilename\n"; |
| 1415 |
push(@installer::globals::logfileinfo, $infoline); |
| 1416 |
} |
| 1417 |
} |
| 1418 |
} |
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
#################################################################################### |
| 1423 |
# Updating the file RemoveRe.idt dynamically (RemoveRegistry.idt) |
| 1424 |
# The name of the component has to be replaced. |
| 1425 |
#################################################################################### |
| 1426 |
|
| 1427 |
sub update_removere_table |
| 1428 |
{ |
| 1429 |
my ($basedir) = @_; |
| 1430 |
|
| 1431 |
my $removeregistryfilename = $basedir . $installer::globals::separator . "RemoveRe.idt"; |
| 1432 |
|
| 1433 |
# Only do something, if this file exists |
| 1434 |
|
| 1435 |
if ( -f $removeregistryfilename ) |
| 1436 |
{ |
| 1437 |
my $removeregistryfile = installer::files::read_file($removeregistryfilename); |
| 1438 |
|
| 1439 |
for ( my $i = 0; $i <= $#{$removeregistryfile}; $i++ ) |
| 1440 |
{ |
| 1441 |
for ( my $i = 0; $i <= $#{$removeregistryfile}; $i++ ) |
| 1442 |
{ |
| 1443 |
${$removeregistryfile}[$i] =~ s/\bREGISTRYROOTCOMPONENT\b/$installer::globals::registryrootcomponent/; |
| 1444 |
} |
| 1445 |
} |
| 1446 |
|
| 1447 |
# Saving the file |
| 1448 |
installer::files::save_file($removeregistryfilename ,$removeregistryfile); |
| 1449 |
my $infoline = "Updated idt file: $removeregistryfilename \n"; |
| 1450 |
push(@installer::globals::logfileinfo, $infoline); |
| 1451 |
} |
| 1452 |
} |
| 1453 |
|
| 1454 |
########################################################################## |
| 1455 |
# Reading saved mappings in Files.idt and Director.idt. |
| 1456 |
# This is required, if installation sets shall be created, |
| 1457 |
# that can be used for creation of msp files. |
| 1458 |
########################################################################## |
| 1459 |
|
| 1460 |
sub read_saved_mappings |
| 1461 |
{ |
| 1462 |
installer::logger::include_header_into_logfile("Reading saved mappings from older installation sets:"); |
| 1463 |
|
| 1464 |
installer::logger::include_timestamp_into_logfile("Performance Info: Reading saved mappings start"); |
| 1465 |
|
| 1466 |
if ( $installer::globals::previous_idt_dir ) |
| 1467 |
{ |
| 1468 |
my @errorlines = (); |
| 1469 |
my $errorstring = ""; |
| 1470 |
my $error_occurred = 0; |
| 1471 |
my $file_error_occurred = 0; |
| 1472 |
my $dir_error_occurred = 0; |
| 1473 |
|
| 1474 |
my $idtdir = $installer::globals::previous_idt_dir; |
| 1475 |
$idtdir =~ s/\Q$installer::globals::separator\E\s*$//; |
| 1476 |
|
| 1477 |
# Reading File.idt |
| 1478 |
|
| 1479 |
my $idtfile = $idtdir . $installer::globals::separator . "File.idt"; |
| 1480 |
push( @installer::globals::globallogfileinfo, "\nAnalyzing file: $idtfile\n" ); |
| 1481 |
if ( ! -f $idtfile ) { push( @installer::globals::globallogfileinfo, "Warning: File $idtfile does not exist!\n" ); } |
| 1482 |
|
| 1483 |
my $n = 0; |
| 1484 |
open (F, "<$idtfile") || installer::exiter::exit_program("ERROR: Cannot open file $idtfile for reading", "read_saved_mappings"); |
| 1485 |
<F>; <F>; <F>; |
| 1486 |
while (<F>) |
| 1487 |
{ |
| 1488 |
m/^([^\t]+)\t([^\t]+)\t((.*)\|)?([^\t]*)/; |
| 1489 |
print "OUT1: \$1: $1, \$2: $2, \$3: $3, \$4: $4, \$5: $5\n"; |
| 1490 |
next if ("$1" eq "$5") && (!defined($3)); |
| 1491 |
my $lc1 = lc($1); |
| 1492 |
|
| 1493 |
if ( exists($installer::globals::savedmapping{"$2/$5"})) |
| 1494 |
{ |
| 1495 |
if ( ! $file_error_occurred ) |
| 1496 |
{ |
| 1497 |
$errorstring = "\nErrors in $idtfile: \n"; |
| 1498 |
push(@errorlines, $errorstring); |
| 1499 |
} |
| 1500 |
$errorstring = "Duplicate savedmapping{" . "$2/$5}\n"; |
| 1501 |
push(@errorlines, $errorstring); |
| 1502 |
$error_occurred = 1; |
| 1503 |
$file_error_occurred = 1; |
| 1504 |
} |
| 1505 |
|
| 1506 |
if ( exists($installer::globals::savedrevmapping{$lc1})) |
| 1507 |
{ |
| 1508 |
if ( ! $file_error_occurred ) |
| 1509 |
{ |
| 1510 |
$errorstring = "\nErrors in $idtfile: \n"; |
| 1511 |
push(@errorlines, $errorstring); |
| 1512 |
} |
| 1513 |
$errorstring = "Duplicate savedrevmapping{" . "$lc1}\n"; |
| 1514 |
push(@errorlines, $errorstring); |
| 1515 |
$error_occurred = 1; |
| 1516 |
$file_error_occurred = 1; |
| 1517 |
} |
| 1518 |
|
| 1519 |
my $shortname = $4 || ''; |
| 1520 |
|
| 1521 |
# Don't reuse illegal 8.3 mappings that we used to generate in 2.0.4 |
| 1522 |
if (index($shortname, '.') > 8 || |
| 1523 |
(index($shortname, '.') == -1 && length($shortname) > 8)) |
| 1524 |
{ |
| 1525 |
$shortname = ''; |
| 1526 |
} |
| 1527 |
|
| 1528 |
if (( $shortname ne '' ) && ( index($shortname, '~') > 0 ) && ( exists($installer::globals::savedrev83mapping{$shortname}) )) |
| 1529 |
{ |
| 1530 |
if ( ! $file_error_occurred ) |
| 1531 |
{ |
| 1532 |
$errorstring = "\nErrors in $idtfile: \n"; |
| 1533 |
push(@errorlines, $errorstring); |
| 1534 |
} |
| 1535 |
$errorstring = "Duplicate savedrev83mapping{" . "$shortname}\n"; |
| 1536 |
push(@errorlines, $errorstring); |
| 1537 |
$error_occurred = 1; |
| 1538 |
$file_error_occurred = 1; |
| 1539 |
} |
| 1540 |
|
| 1541 |
$installer::globals::savedmapping{"$2/$5"} = "$1;$shortname"; |
| 1542 |
$installer::globals::savedrevmapping{lc($1)} = "$2/$5"; |
| 1543 |
$installer::globals::savedrev83mapping{$shortname} = "$2/$5" if $shortname ne ''; |
| 1544 |
$n++; |
| 1545 |
} |
| 1546 |
|
| 1547 |
close (F); |
| 1548 |
|
| 1549 |
push( @installer::globals::globallogfileinfo, "Read $n old file table key or 8.3 name mappings from $idtfile\n" ); |
| 1550 |
|
| 1551 |
# Reading Director.idt |
| 1552 |
|
| 1553 |
$idtfile = $idtdir . $installer::globals::separator . "Director.idt"; |
| 1554 |
push( @installer::globals::globallogfileinfo, "\nAnalyzing file $idtfile\n" ); |
| 1555 |
if ( ! -f $idtfile ) { push( @installer::globals::globallogfileinfo, "Warning: File $idtfile does not exist!\n" ); } |
| 1556 |
|
| 1557 |
$n = 0; |
| 1558 |
open (F, "<$idtfile") || installer::exiter::exit_program("ERROR: Cannot open file $idtfile for reading", "read_saved_mappings"); |
| 1559 |
<F>; <F>; <F>; |
| 1560 |
while (<F>) |
| 1561 |
{ |
| 1562 |
m/^([^\t]+)\t([^\t]+)\t(([^~]+~\d.*)\|)?([^\t]*)/; |
| 1563 |
next if (!defined($3)); |
| 1564 |
my $lc1 = lc($1); |
| 1565 |
|
| 1566 |
print "OUT2: \$1: $1, \$2: $2, \$3: $3\n"; |
| 1567 |
|
| 1568 |
if ( exists($installer::globals::saved83dirmapping{$1}) ) |
| 1569 |
{ |
| 1570 |
if ( ! $dir_error_occurred ) |
| 1571 |
{ |
| 1572 |
$errorstring = "\nErrors in $idtfile: \n"; |
| 1573 |
push(@errorlines, $errorstring); |
| 1574 |
} |
| 1575 |
$errorstring = "Duplicate saved83dirmapping{" . "$1}\n"; |
| 1576 |
push(@errorlines, $errorstring); |
| 1577 |
$error_occurred = 1; |
| 1578 |
$dir_error_occurred = 1; |
| 1579 |
} |
| 1580 |
|
| 1581 |
$installer::globals::saved83dirmapping{$1} = $4; |
| 1582 |
$n++; |
| 1583 |
} |
| 1584 |
close (F); |
| 1585 |
|
| 1586 |
push( @installer::globals::globallogfileinfo, "Read $n old directory 8.3 name mappings from $idtfile\n" ); |
| 1587 |
|
| 1588 |
# Analyzing errors |
| 1589 |
|
| 1590 |
if ( $error_occurred ) |
| 1591 |
{ |
| 1592 |
for ( my $i = 0; $i <= $#errorlines; $i++ ) |
| 1593 |
{ |
| 1594 |
print "$errorlines[$i]"; |
| 1595 |
push( @installer::globals::globallogfileinfo, "$errorlines[$i]"); |
| 1596 |
} |
| 1597 |
installer::exiter::exit_program("ERROR: Duplicate entries in saved mappings!", "read_saved_mappings"); |
| 1598 |
} |
| 1599 |
} else { |
| 1600 |
installer::exiter::exit_program("ERROR: Windows patch shall be prepared, but environment variable PREVIOUS_IDT_DIR is not set!", "read_saved_mappings"); |
| 1601 |
} |
| 1602 |
|
| 1603 |
installer::logger::include_timestamp_into_logfile("Performance Info: Reading saved mappings end"); |
| 1604 |
} |
| 1605 |
|
| 1606 |
1; |
| 1607 |
|
| 1608 |
# vim:set shiftwidth=4 softtabstop=4 expandtab: |