19780544fSAndrew Rist#************************************************************** 29780544fSAndrew Rist# 39780544fSAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 49780544fSAndrew Rist# or more contributor license agreements. See the NOTICE file 59780544fSAndrew Rist# distributed with this work for additional information 69780544fSAndrew Rist# regarding copyright ownership. The ASF licenses this file 79780544fSAndrew Rist# to you under the Apache License, Version 2.0 (the 89780544fSAndrew Rist# "License"); you may not use this file except in compliance 99780544fSAndrew Rist# with the License. You may obtain a copy of the License at 109780544fSAndrew Rist# 119780544fSAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 129780544fSAndrew Rist# 139780544fSAndrew Rist# Unless required by applicable law or agreed to in writing, 149780544fSAndrew Rist# software distributed under the License is distributed on an 159780544fSAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169780544fSAndrew Rist# KIND, either express or implied. See the License for the 179780544fSAndrew Rist# specific language governing permissions and limitations 189780544fSAndrew Rist# under the License. 199780544fSAndrew Rist# 209780544fSAndrew Rist#************************************************************** 219780544fSAndrew Rist 229780544fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweirpackage installer::windows::directory; 25cdf0e10cSrcweir 26cdf0e10cSrcweiruse installer::exiter; 27cdf0e10cSrcweiruse installer::files; 28cdf0e10cSrcweiruse installer::globals; 29cdf0e10cSrcweiruse installer::pathanalyzer; 30cdf0e10cSrcweiruse installer::windows::idtglobal; 3119d58b3aSEike Rathkeuse installer::windows::msiglobal; 32*9f91b7e3SAndre Fischeruse installer::scriptitems; 33cdf0e10cSrcweir 341ba1fd99SAndre Fischeruse strict; 351ba1fd99SAndre Fischer 36cdf0e10cSrcweir############################################################## 37cdf0e10cSrcweir# Collecting all directory trees in global hash 38cdf0e10cSrcweir############################################################## 39cdf0e10cSrcweir 40cdf0e10cSrcweirsub collectdirectorytrees 41cdf0e10cSrcweir{ 42cdf0e10cSrcweir my ( $directoryref ) = @_; 43cdf0e10cSrcweir 44cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$directoryref}; $i++ ) 45cdf0e10cSrcweir { 46cdf0e10cSrcweir my $onedir = ${$directoryref}[$i]; 47cdf0e10cSrcweir my $styles = ""; 48cdf0e10cSrcweir if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; } 49cdf0e10cSrcweir 50cdf0e10cSrcweir if ( $styles ne "" ) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir foreach my $treestyle ( keys %installer::globals::treestyles ) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir if ( $styles =~ /\b$treestyle\b/ ) 55cdf0e10cSrcweir { 56cdf0e10cSrcweir my $hostname = $onedir->{'HostName'}; 57cdf0e10cSrcweir # -> hostname is the key, the style the value! 58cdf0e10cSrcweir $installer::globals::hostnametreestyles{$hostname} = $treestyle; 59cdf0e10cSrcweir } 60cdf0e10cSrcweir } 61cdf0e10cSrcweir } 62cdf0e10cSrcweir } 63cdf0e10cSrcweir} 64cdf0e10cSrcweir 65cdf0e10cSrcweir############################################################## 66cdf0e10cSrcweir# Overwriting global programfilesfolder, if required 67cdf0e10cSrcweir############################################################## 68cdf0e10cSrcweir 69cdf0e10cSrcweirsub overwrite_programfilesfolder 70cdf0e10cSrcweir{ 71cdf0e10cSrcweir my ( $allvariables ) = @_; 72cdf0e10cSrcweir 73cdf0e10cSrcweir if ( $allvariables->{'PROGRAMFILESFOLDERNAME'} ) 74cdf0e10cSrcweir { 75cdf0e10cSrcweir $installer::globals::programfilesfolder = $allvariables->{'PROGRAMFILESFOLDERNAME'}; 76cdf0e10cSrcweir } 77cdf0e10cSrcweir} 78cdf0e10cSrcweir 79cdf0e10cSrcweir 801ba1fd99SAndre Fischer 811ba1fd99SAndre Fischer 821ba1fd99SAndre Fischer=head2 make_short_dir_version($longstring) 831ba1fd99SAndre Fischer 841ba1fd99SAndre Fischer Transform the given string into one that is at most 70 characters long. 851ba1fd99SAndre Fischer That is done in two steps: 861ba1fd99SAndre Fischer - Cut all parts separated by '_' or '-' down to a length of 5. 871ba1fd99SAndre Fischer - Cut down the result to a length of 60 and fill it up to length 70 881ba1fd99SAndre Fischer with the MD5 checksum. 891ba1fd99SAndre Fischer 901ba1fd99SAndre Fischer This transform always returns the same result for the same string. 911ba1fd99SAndre Fischer There is no counter and reference to a global set of names to make the string unique. 921ba1fd99SAndre Fischer 931ba1fd99SAndre Fischer=cut 941ba1fd99SAndre Fischersub make_short_dir_version ($) 95cdf0e10cSrcweir{ 9619d58b3aSEike Rathke my ($longstring) = @_; 97cdf0e10cSrcweir 98cdf0e10cSrcweir my $shortstring = ""; 9919d58b3aSEike Rathke my $cutlength = 60; 10019d58b3aSEike Rathke my $length = 5; # So the directory can still be recognized 10119d58b3aSEike Rathke my $longstring_save = $longstring; 102cdf0e10cSrcweir 103cdf0e10cSrcweir # Splitting the string at each "underline" and allowing only $length characters per directory name. 104cdf0e10cSrcweir # Checking also uniqueness and length. 105cdf0e10cSrcweir 1061ba1fd99SAndre Fischer my @outer_parts = split(/_/, $longstring); 1071ba1fd99SAndre Fischer foreach my $onestring (@outer_parts) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir my $partstring = ""; 110cdf0e10cSrcweir 111cdf0e10cSrcweir if ( $onestring =~ /\-/ ) 112cdf0e10cSrcweir { 1131ba1fd99SAndre Fischer my @inner_parts = split(/-/, $onestring); 1141ba1fd99SAndre Fischer @inner_parts = map {substr($_,0,$length)} @inner_parts; 1151ba1fd99SAndre Fischer $partstring = join("-", @inner_parts); 116cdf0e10cSrcweir $partstring =~ s/^\s*\-//; 117cdf0e10cSrcweir } 118cdf0e10cSrcweir else 119cdf0e10cSrcweir { 1201ba1fd99SAndre Fischer $partstring = substr($onestring, 0, $length); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 1231ba1fd99SAndre Fischer $shortstring .= "_" . $partstring; 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir $shortstring =~ s/^\s*\_//; 127cdf0e10cSrcweir 12819d58b3aSEike Rathke # Setting unique ID to each directory 12919d58b3aSEike Rathke # No counter allowed, process must be absolute reproducable due to patch creation process. 13019d58b3aSEike Rathke 13119d58b3aSEike Rathke my $subid = installer::windows::msiglobal::calculate_id($longstring_save, 9); # taking only the first 9 digits 1321ba1fd99SAndre Fischer $shortstring = substr($shortstring, 0, $cutlength) . "_" . $subid; 133cdf0e10cSrcweir 134cdf0e10cSrcweir return $shortstring; 135cdf0e10cSrcweir} 136cdf0e10cSrcweir 137cdf0e10cSrcweir 138*9f91b7e3SAndre Fischer 139*9f91b7e3SAndre Fischer 140*9f91b7e3SAndre Fischer=head2 get_unique_name ($hostname, $unique_map, $shortdirhash, $shortdirhashreverse) 141*9f91b7e3SAndre Fischer 142*9f91b7e3SAndre Fischer Return a long and a short unique name for the given $hostname. 143*9f91b7e3SAndre Fischer Despite the function name and unlike the generation of unique 144*9f91b7e3SAndre Fischer names for files, the returned names are not really unique. Quite 145*9f91b7e3SAndre Fischer the opposite. The returned names are quaranteed to return the 146*9f91b7e3SAndre Fischer same result for the same input. 147*9f91b7e3SAndre Fischer 148*9f91b7e3SAndre Fischer The returned short name has at most length 70. 149*9f91b7e3SAndre Fischer 150*9f91b7e3SAndre Fischer=cut 151*9f91b7e3SAndre Fischersub get_unique_name ($$) 152cdf0e10cSrcweir{ 153*9f91b7e3SAndre Fischer my ($hostname, $hostnamehash) = @_; 154*9f91b7e3SAndre Fischer 155*9f91b7e3SAndre Fischer # Make sure that we where not called for this hostname before. Otherwise the other test would be triggered. 156*9f91b7e3SAndre Fischer if (defined $hostnamehash->{$hostname}) 157*9f91b7e3SAndre Fischer { 158*9f91b7e3SAndre Fischer installer::exiter::exit_program( 159*9f91b7e3SAndre Fischer "ERROR: get_unique_name was already called for hostname ".$hostname, 160*9f91b7e3SAndre Fischer "get_unique_name"); 161*9f91b7e3SAndre Fischer } 162*9f91b7e3SAndre Fischer $hostnamehash->{$hostname} = 1; 163*9f91b7e3SAndre Fischer 164*9f91b7e3SAndre Fischer my $uniquename = $hostname; 165*9f91b7e3SAndre Fischer 166*9f91b7e3SAndre Fischer $uniquename =~ s/^\s*//g; # removing beginning white spaces 167*9f91b7e3SAndre Fischer $uniquename =~ s/\s*$//g; # removing ending white spaces 168*9f91b7e3SAndre Fischer $uniquename =~ s/\s//g; # removing white spaces 169*9f91b7e3SAndre Fischer $uniquename =~ s/\_//g; # removing existing underlines 170*9f91b7e3SAndre Fischer $uniquename =~ s/\.//g; # removing dots in directoryname 171*9f91b7e3SAndre Fischer $uniquename =~ s/OpenOffice/OO/g; 172*9f91b7e3SAndre Fischer 173*9f91b7e3SAndre Fischer $uniquename =~ s/\Q$installer::globals::separator\E/\_/g; # replacing slash and backslash with underline 174*9f91b7e3SAndre Fischer 175*9f91b7e3SAndre Fischer $uniquename =~ s/_registry/_rgy/g; 176*9f91b7e3SAndre Fischer $uniquename =~ s/_registration/_rgn/g; 177*9f91b7e3SAndre Fischer $uniquename =~ s/_extension/_ext/g; 178*9f91b7e3SAndre Fischer $uniquename =~ s/_frame/_frm/g; 179*9f91b7e3SAndre Fischer $uniquename =~ s/_table/_tbl/g; 180*9f91b7e3SAndre Fischer $uniquename =~ s/_chart/_crt/g; 181cdf0e10cSrcweir 182*9f91b7e3SAndre Fischer my $short_uniquename = make_short_dir_version($uniquename); 183*9f91b7e3SAndre Fischer 184*9f91b7e3SAndre Fischer return ($uniquename, $short_uniquename); 185*9f91b7e3SAndre Fischer} 18619d58b3aSEike Rathke 187cdf0e10cSrcweir 188cdf0e10cSrcweir 189cdf0e10cSrcweir 190*9f91b7e3SAndre Fischer=head2 check_unique_directorynames($directories) 191*9f91b7e3SAndre Fischer 192*9f91b7e3SAndre Fischer The one really important check is made in get_unique_name(). It 193*9f91b7e3SAndre Fischer checks that get_unique_name() is not called twice for the same 194*9f91b7e3SAndre Fischer directory host name. The tests in this function contain the 195*9f91b7e3SAndre Fischer legacy tests that basically only check if there where a collision 196*9f91b7e3SAndre Fischer of the partial MD5 sum that is used to make the short unique names 197*9f91b7e3SAndre Fischer unique. 198*9f91b7e3SAndre Fischer 199*9f91b7e3SAndre Fischer The maps $unique_map, $shortdirhash, $shortdirhashreverse are used 200*9f91b7e3SAndre Fischer only to check that _different_ input names are mapped to different 201*9f91b7e3SAndre Fischer results. They are not used to influence the result. That assumes 202*9f91b7e3SAndre Fischer that this function is called only once for every directory 203*9f91b7e3SAndre Fischer hostname. 204*9f91b7e3SAndre Fischer=cut 205*9f91b7e3SAndre Fischersub check_unique_directorynames ($) 206*9f91b7e3SAndre Fischer{ 207*9f91b7e3SAndre Fischer my ($directories) = @_; 208*9f91b7e3SAndre Fischer 209*9f91b7e3SAndre Fischer my %completedirhashstep1 = (); 210*9f91b7e3SAndre Fischer my %shortdirhash = (); 211*9f91b7e3SAndre Fischer my %shortdirhashreverse = (); 21219d58b3aSEike Rathke 213*9f91b7e3SAndre Fischer # Check unique name of directories. 214*9f91b7e3SAndre Fischer foreach my $directory (@$directories) 215*9f91b7e3SAndre Fischer { 216*9f91b7e3SAndre Fischer my ($long_uniquename, $short_uniquename) = ($directory->{'long_uniquename'}, $directory->{'uniquename'}); 217*9f91b7e3SAndre Fischer 218*9f91b7e3SAndre Fischer # The names after this small changes must still be unique! 219*9f91b7e3SAndre Fischer if (exists($completedirhashstep1{$long_uniquename})) 220*9f91b7e3SAndre Fischer { 221*9f91b7e3SAndre Fischer installer::exiter::exit_program( 222*9f91b7e3SAndre Fischer sprintf("ERROR: Unallowed modification of directory name, not unique (step 1): \"%s\".", 223*9f91b7e3SAndre Fischer $short_uniquename), 224*9f91b7e3SAndre Fischer "check_unique_directorynames"); 225*9f91b7e3SAndre Fischer } 226*9f91b7e3SAndre Fischer $completedirhashstep1{$long_uniquename} = 1; 227*9f91b7e3SAndre Fischer 228*9f91b7e3SAndre Fischer 229*9f91b7e3SAndre Fischer # Checking if the same directory already exists, but has another short version. 230*9f91b7e3SAndre Fischer if (exists($shortdirhash{$long_uniquename}) 231*9f91b7e3SAndre Fischer && ( $shortdirhash{$long_uniquename} ne $short_uniquename )) 232*9f91b7e3SAndre Fischer { 233*9f91b7e3SAndre Fischer installer::exiter::exit_program( 234*9f91b7e3SAndre Fischer sprintf( 235*9f91b7e3SAndre Fischer "ERROR: Unallowed modification of directory name, not unique (step 2A): \"%s\".", 236*9f91b7e3SAndre Fischer $short_uniquename), 237*9f91b7e3SAndre Fischer "check_unique_directorynames"); 238*9f91b7e3SAndre Fischer } 239*9f91b7e3SAndre Fischer $shortdirhash{$long_uniquename} = $short_uniquename; 240*9f91b7e3SAndre Fischer 241*9f91b7e3SAndre Fischer # Also checking vice versa 242*9f91b7e3SAndre Fischer # Checking if the same short directory already exists, but has another long version. 243*9f91b7e3SAndre Fischer if (exists($shortdirhashreverse{$short_uniquename}) 244*9f91b7e3SAndre Fischer && ( $shortdirhashreverse{$short_uniquename} ne $long_uniquename )) 245*9f91b7e3SAndre Fischer { 246*9f91b7e3SAndre Fischer installer::exiter::exit_program( 247*9f91b7e3SAndre Fischer sprintf( 248*9f91b7e3SAndre Fischer "ERROR: Unallowed modification of directory name, not unique (step 2B): \"%s\".", 249*9f91b7e3SAndre Fischer $short_uniquename), 250*9f91b7e3SAndre Fischer "check_unique_directorynames"); 251*9f91b7e3SAndre Fischer } 252*9f91b7e3SAndre Fischer $shortdirhashreverse{$short_uniquename} = $long_uniquename; 253*9f91b7e3SAndre Fischer } 254*9f91b7e3SAndre Fischer 255*9f91b7e3SAndre Fischer # Check unique name of parents 256*9f91b7e3SAndre Fischer foreach my $directory (@$directories) 257*9f91b7e3SAndre Fischer { 258*9f91b7e3SAndre Fischer my ($long_uniquename, $short_uniquename) 259*9f91b7e3SAndre Fischer = ($directory->{'long_uniqueparentname'}, $directory->{'uniqueparentname'}); 260*9f91b7e3SAndre Fischer 261*9f91b7e3SAndre Fischer # Again checking if the same directory already exists, but has another short version. 262*9f91b7e3SAndre Fischer if (exists($shortdirhash{$long_uniquename}) 263*9f91b7e3SAndre Fischer && ( $shortdirhash{$long_uniquename} ne $short_uniquename )) 264*9f91b7e3SAndre Fischer { 265*9f91b7e3SAndre Fischer installer::exiter::exit_program( 266*9f91b7e3SAndre Fischer sprintf( 267*9f91b7e3SAndre Fischer "ERROR: Unallowed modification of directory name, not unique (step 3A): \"%s\".", 268*9f91b7e3SAndre Fischer $short_uniquename), 269*9f91b7e3SAndre Fischer "check_unique_directorynames"); 270*9f91b7e3SAndre Fischer } 271*9f91b7e3SAndre Fischer $shortdirhash{$long_uniquename} = $short_uniquename; 272*9f91b7e3SAndre Fischer 273*9f91b7e3SAndre Fischer # Also checking vice versa 274*9f91b7e3SAndre Fischer # Checking if the same short directory already exists, but has another long version. 275*9f91b7e3SAndre Fischer if (exists($shortdirhashreverse{$short_uniquename}) 276*9f91b7e3SAndre Fischer && ( $shortdirhashreverse{$short_uniquename} ne $long_uniquename )) 277*9f91b7e3SAndre Fischer { 278*9f91b7e3SAndre Fischer installer::exiter::exit_program( 279*9f91b7e3SAndre Fischer sprintf( 280*9f91b7e3SAndre Fischer "ERROR: Unallowed modification of directory name, not unique (step 3B): \"%s\".", 281*9f91b7e3SAndre Fischer $short_uniquename), 282*9f91b7e3SAndre Fischer "check_unique_directorynames"); 283*9f91b7e3SAndre Fischer } 284*9f91b7e3SAndre Fischer $shortdirhashreverse{$short_uniquename} = $long_uniquename; 285*9f91b7e3SAndre Fischer } 286*9f91b7e3SAndre Fischer} 28719d58b3aSEike Rathke 288cdf0e10cSrcweir 289cdf0e10cSrcweir 29019d58b3aSEike Rathke 291*9f91b7e3SAndre Fischersub get_unique_parent_name ($$) 292*9f91b7e3SAndre Fischer{ 293*9f91b7e3SAndre Fischer my ($uniqueparentname, $styles) = @_; 294*9f91b7e3SAndre Fischer 295*9f91b7e3SAndre Fischer my $keepparent = 1; 296*9f91b7e3SAndre Fischer 297*9f91b7e3SAndre Fischer if ( $uniqueparentname =~ /^\s*(.*)\_(.*?)\s*$/ ) # the underline is now the separator 298*9f91b7e3SAndre Fischer { 299*9f91b7e3SAndre Fischer $uniqueparentname = $1; 300*9f91b7e3SAndre Fischer $keepparent = 0; 301*9f91b7e3SAndre Fischer } 302*9f91b7e3SAndre Fischer else 303*9f91b7e3SAndre Fischer { 304*9f91b7e3SAndre Fischer $uniqueparentname = $installer::globals::programfilesfolder; 305*9f91b7e3SAndre Fischer $keepparent = 1; 306*9f91b7e3SAndre Fischer } 307*9f91b7e3SAndre Fischer 308*9f91b7e3SAndre Fischer if ( $styles =~ /\bPROGRAMFILESFOLDER\b/ ) 309*9f91b7e3SAndre Fischer { 310*9f91b7e3SAndre Fischer $uniqueparentname = $installer::globals::programfilesfolder; 311*9f91b7e3SAndre Fischer $keepparent = 1; 312*9f91b7e3SAndre Fischer } 313*9f91b7e3SAndre Fischer if ( $styles =~ /\bCOMMONFILESFOLDER\b/ ) 314*9f91b7e3SAndre Fischer { 315*9f91b7e3SAndre Fischer $uniqueparentname = $installer::globals::commonfilesfolder; 316*9f91b7e3SAndre Fischer $keepparent = 1; 317*9f91b7e3SAndre Fischer } 318*9f91b7e3SAndre Fischer if ( $styles =~ /\bCOMMONAPPDATAFOLDER\b/ ) 319*9f91b7e3SAndre Fischer { 320*9f91b7e3SAndre Fischer $uniqueparentname = $installer::globals::commonappdatafolder; 321*9f91b7e3SAndre Fischer $keepparent = 1; 322*9f91b7e3SAndre Fischer } 323*9f91b7e3SAndre Fischer if ( $styles =~ /\bLOCALAPPDATAFOLDER\b/ ) 324*9f91b7e3SAndre Fischer { 325*9f91b7e3SAndre Fischer $uniqueparentname = $installer::globals::localappdatafolder; 326*9f91b7e3SAndre Fischer $keepparent = 1; 327*9f91b7e3SAndre Fischer } 328*9f91b7e3SAndre Fischer 329*9f91b7e3SAndre Fischer if ( $styles =~ /\bSHAREPOINTPATH\b/ ) 330*9f91b7e3SAndre Fischer { 331*9f91b7e3SAndre Fischer $uniqueparentname = "SHAREPOINTPATH"; 332*9f91b7e3SAndre Fischer $installer::globals::usesharepointpath = 1; 333*9f91b7e3SAndre Fischer $keepparent = 1; 334*9f91b7e3SAndre Fischer } 335*9f91b7e3SAndre Fischer 336*9f91b7e3SAndre Fischer # also setting short directory name for the parent 337*9f91b7e3SAndre Fischer 338*9f91b7e3SAndre Fischer my $originaluniqueparentname = $uniqueparentname; 33919d58b3aSEike Rathke 340*9f91b7e3SAndre Fischer if ( ! $keepparent ) 341*9f91b7e3SAndre Fischer { 342*9f91b7e3SAndre Fischer $uniqueparentname = make_short_dir_version($uniqueparentname); 343*9f91b7e3SAndre Fischer } 34419d58b3aSEike Rathke 345*9f91b7e3SAndre Fischer return ($originaluniqueparentname, $uniqueparentname); 346*9f91b7e3SAndre Fischer} 347cdf0e10cSrcweir 348cdf0e10cSrcweir 349cdf0e10cSrcweir 350cdf0e10cSrcweir 351*9f91b7e3SAndre Fischer############################################################## 352*9f91b7e3SAndre Fischer# Adding unique directory names to the directory collection 353*9f91b7e3SAndre Fischer############################################################## 354cdf0e10cSrcweir 355*9f91b7e3SAndre Fischersub create_unique_directorynames ($) 356*9f91b7e3SAndre Fischer{ 357*9f91b7e3SAndre Fischer my ($directories) = @_; 358cdf0e10cSrcweir 359*9f91b7e3SAndre Fischer $installer::globals::officeinstalldirectoryset = 0; 360cdf0e10cSrcweir 361*9f91b7e3SAndre Fischer my %hostnamehash = (); 362*9f91b7e3SAndre Fischer my $infoline = ""; 363*9f91b7e3SAndre Fischer my $errorcount = 0; 36419d58b3aSEike Rathke 365*9f91b7e3SAndre Fischer foreach my $directory (@$directories) 366*9f91b7e3SAndre Fischer { 367*9f91b7e3SAndre Fischer next if defined $directory->{'uniquename'}; 36819d58b3aSEike Rathke 369*9f91b7e3SAndre Fischer my $styles = $directory->{'Styles'} // ""; 37019d58b3aSEike Rathke 371*9f91b7e3SAndre Fischer my ($originaluniquename, $uniquename) = get_unique_name( 372*9f91b7e3SAndre Fischer $directory->{'HostName'}, 373*9f91b7e3SAndre Fischer \%hostnamehash); 374*9f91b7e3SAndre Fischer 375*9f91b7e3SAndre Fischer my ($originaluniqueparentname, $uniqueparentname) = get_unique_parent_name( 376*9f91b7e3SAndre Fischer $originaluniquename, 377*9f91b7e3SAndre Fischer $styles); 37819d58b3aSEike Rathke 37919d58b3aSEike Rathke 38019d58b3aSEike Rathke # Hyphen not allowed in database 381cdf0e10cSrcweir $uniquename =~ s/\-/\_/g; # making "-" to "_" 382cdf0e10cSrcweir $uniqueparentname =~ s/\-/\_/g; # making "-" to "_" 383cdf0e10cSrcweir 38419d58b3aSEike Rathke # And finally setting the values for the directories 385*9f91b7e3SAndre Fischer $directory->{'uniquename'} = $uniquename; 386*9f91b7e3SAndre Fischer $directory->{'uniqueparentname'} = $uniqueparentname; 387*9f91b7e3SAndre Fischer $directory->{'long_uniquename'} = $originaluniquename; 388*9f91b7e3SAndre Fischer $directory->{'long_uniqueparentname'} = $originaluniqueparentname; 389*9f91b7e3SAndre Fischer } 390*9f91b7e3SAndre Fischer 391*9f91b7e3SAndre Fischer # Find the installation directory. 392*9f91b7e3SAndre Fischer foreach my $directory (@$directories) 393*9f91b7e3SAndre Fischer { 394*9f91b7e3SAndre Fischer next unless defined $directory->{'Styles'}; 395*9f91b7e3SAndre Fischer 396cdf0e10cSrcweir # setting the installlocation directory 397*9f91b7e3SAndre Fischer next unless $directory->{'Styles'} =~ /\bISINSTALLLOCATION\b/; 398*9f91b7e3SAndre Fischer 399*9f91b7e3SAndre Fischer if ( $installer::globals::installlocationdirectoryset ) 400*9f91b7e3SAndre Fischer { 401*9f91b7e3SAndre Fischer installer::exiter::exit_program( 402*9f91b7e3SAndre Fischer sprintf( 403*9f91b7e3SAndre Fischer "ERROR: Directory with flag ISINSTALLLOCATION alread set: \"%s\".", 404*9f91b7e3SAndre Fischer $installer::globals::installlocationdirectory), 405*9f91b7e3SAndre Fischer "create_unique_directorynames"); 406*9f91b7e3SAndre Fischer } 407*9f91b7e3SAndre Fischer 408*9f91b7e3SAndre Fischer $installer::globals::installlocationdirectory = $directory->{'uniquename'}; 409*9f91b7e3SAndre Fischer $installer::globals::installlocationdirectoryset = 1; 410*9f91b7e3SAndre Fischer } 411cdf0e10cSrcweir} 412cdf0e10cSrcweir 413*9f91b7e3SAndre Fischer 414*9f91b7e3SAndre Fischer 415*9f91b7e3SAndre Fischer 416cdf0e10cSrcweir##################################################### 417cdf0e10cSrcweir# Adding ":." to selected default directory names 418cdf0e10cSrcweir##################################################### 419cdf0e10cSrcweir 420*9f91b7e3SAndre Fischersub update_defaultdir ($$) 421cdf0e10cSrcweir{ 422cdf0e10cSrcweir my ( $onedir, $allvariableshashref ) = @_; 423cdf0e10cSrcweir 424*9f91b7e3SAndre Fischer if ($installer::globals::addchildprojects 425*9f91b7e3SAndre Fischer || $installer::globals::patch 426*9f91b7e3SAndre Fischer || $installer::globals::languagepack 427*9f91b7e3SAndre Fischer || $allvariableshashref->{'CHANGETARGETDIR'}) 428cdf0e10cSrcweir { 429cdf0e10cSrcweir my $sourcediraddon = "\:\."; 430*9f91b7e3SAndre Fischer return $onedir->{'defaultdir'} . $sourcediraddon; 431cdf0e10cSrcweir } 432*9f91b7e3SAndre Fischer else 433*9f91b7e3SAndre Fischer { 434*9f91b7e3SAndre Fischer return $onedir->{'defaultdir'}; 435*9f91b7e3SAndre Fischer } 436cdf0e10cSrcweir} 437cdf0e10cSrcweir 438cdf0e10cSrcweir##################################################### 439cdf0e10cSrcweir# The directory with the style ISINSTALLLOCATION 440cdf0e10cSrcweir# will be replaced by INSTALLLOCATION 441cdf0e10cSrcweir##################################################### 442cdf0e10cSrcweir 443cdf0e10cSrcweirsub set_installlocation_directory 444cdf0e10cSrcweir{ 445cdf0e10cSrcweir my ( $directoryref, $allvariableshashref ) = @_; 446cdf0e10cSrcweir 447*9f91b7e3SAndre Fischer if ( ! $installer::globals::installlocationdirectoryset ) 448*9f91b7e3SAndre Fischer { 449*9f91b7e3SAndre Fischer installer::exiter::exit_program( 450*9f91b7e3SAndre Fischer "ERROR: Directory with flag ISINSTALLLOCATION not set!", 451*9f91b7e3SAndre Fischer "set_installlocation_directory"); 452*9f91b7e3SAndre Fischer } 453cdf0e10cSrcweir 454cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$directoryref}; $i++ ) 455cdf0e10cSrcweir { 456cdf0e10cSrcweir my $onedir = ${$directoryref}[$i]; 457cdf0e10cSrcweir 458cdf0e10cSrcweir if ( $onedir->{'uniquename'} eq $installer::globals::installlocationdirectory ) 459cdf0e10cSrcweir { 460cdf0e10cSrcweir $onedir->{'uniquename'} = "INSTALLLOCATION"; 461*9f91b7e3SAndre Fischer $onedir->{'defaultdir'} = update_defaultdir($onedir, $allvariableshashref); 462cdf0e10cSrcweir } 463cdf0e10cSrcweir 464cdf0e10cSrcweir if ( $onedir->{'uniquename'} eq $installer::globals::vendordirectory ) 465cdf0e10cSrcweir { 466*9f91b7e3SAndre Fischer $onedir->{'defaultdir'} = update_defaultdir($onedir, $allvariableshashref); 467cdf0e10cSrcweir } 468cdf0e10cSrcweir 469cdf0e10cSrcweir if ( $onedir->{'uniqueparentname'} eq $installer::globals::installlocationdirectory ) 470cdf0e10cSrcweir { 471cdf0e10cSrcweir $onedir->{'uniqueparentname'} = "INSTALLLOCATION"; 472cdf0e10cSrcweir } 473cdf0e10cSrcweir } 474cdf0e10cSrcweir} 475cdf0e10cSrcweir 476cdf0e10cSrcweir##################################################### 477cdf0e10cSrcweir# Getting the name of the top level directory. This 478cdf0e10cSrcweir# can have only one letter 479cdf0e10cSrcweir##################################################### 480cdf0e10cSrcweir 481cdf0e10cSrcweirsub get_last_directory_name 482cdf0e10cSrcweir{ 483cdf0e10cSrcweir my ($completepathref) = @_; 484cdf0e10cSrcweir 485cdf0e10cSrcweir if ( $$completepathref =~ /^.*[\/\\](.+?)\s*$/ ) 486cdf0e10cSrcweir { 487cdf0e10cSrcweir $$completepathref = $1; 488cdf0e10cSrcweir } 489cdf0e10cSrcweir} 490cdf0e10cSrcweir 491*9f91b7e3SAndre Fischersub setup_global_font_directory_name ($) 492*9f91b7e3SAndre Fischer{ 493*9f91b7e3SAndre Fischer my ($directories) = @_; 494*9f91b7e3SAndre Fischer 495*9f91b7e3SAndre Fischer foreach my $directory (@$directories) 496*9f91b7e3SAndre Fischer { 497*9f91b7e3SAndre Fischer next unless defined $directory->{'Dir'}; 498*9f91b7e3SAndre Fischer next unless defined $directory->{'defaultdir'}; 499*9f91b7e3SAndre Fischer 500*9f91b7e3SAndre Fischer next if $directory->{'Dir'} ne "PREDEFINED_OSSYSTEMFONTDIR"; 501*9f91b7e3SAndre Fischer next if $directory->{'defaultdir'} ne $installer::globals::fontsdirhostname; 502*9f91b7e3SAndre Fischer 503*9f91b7e3SAndre Fischer $installer::globals::fontsdirname = $installer::globals::fontsdirhostname; 504*9f91b7e3SAndre Fischer $installer::globals::fontsdirparent = $directory->{'uniqueparentname'}; 505*9f91b7e3SAndre Fischer 506*9f91b7e3SAndre Fischer $installer::logger::Info->printf("%s, fdhn %s, dd %s, ipn %s, HN %s\n", 507*9f91b7e3SAndre Fischer "PREDEFINED_OSSYSTEMFONTDIR", 508*9f91b7e3SAndre Fischer $installer::globals::fontsdirhostname, 509*9f91b7e3SAndre Fischer $directory->{'defaultdir'}, 510*9f91b7e3SAndre Fischer $directory->{'uniqueparentname'}, 511*9f91b7e3SAndre Fischer $directory->{'HostName'}); 512*9f91b7e3SAndre Fischer installer::scriptitems::print_script_item($directory); 513*9f91b7e3SAndre Fischer } 514*9f91b7e3SAndre Fischer} 515*9f91b7e3SAndre Fischer 516cdf0e10cSrcweir##################################################### 517cdf0e10cSrcweir# Creating the defaultdir for the file Director.idt 518cdf0e10cSrcweir##################################################### 519cdf0e10cSrcweir 520dca4887fSAndre Fischersub create_defaultdir_directorynames ($) 521cdf0e10cSrcweir{ 522dca4887fSAndre Fischer my ($directoryref) = @_; 523cdf0e10cSrcweir 524cdf0e10cSrcweir my @shortnames = (); 525f30bf281SAndre Fischer if ( $installer::globals::prepare_winpatch ) { @shortnames = values(%installer::globals::saved83dirmapping); } 526cdf0e10cSrcweir 527cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$directoryref}; $i++ ) 528cdf0e10cSrcweir { 529cdf0e10cSrcweir my $onedir = ${$directoryref}[$i]; 530cdf0e10cSrcweir my $hostname = $onedir->{'HostName'}; 531cdf0e10cSrcweir 532cdf0e10cSrcweir $hostname =~ s/\Q$installer::globals::separator\E\s*$//; 533cdf0e10cSrcweir get_last_directory_name(\$hostname); 534cdf0e10cSrcweir # installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$hostname); # making program/classes to classes 535cdf0e10cSrcweir my $uniquename = $onedir->{'uniquename'}; 536cdf0e10cSrcweir my $shortstring; 537f30bf281SAndre Fischer if (( $installer::globals::prepare_winpatch ) && ( exists($installer::globals::saved83dirmapping{$uniquename}) )) 538cdf0e10cSrcweir { 539cdf0e10cSrcweir $shortstring = $installer::globals::saved83dirmapping{$uniquename}; 540cdf0e10cSrcweir } 541cdf0e10cSrcweir else 542cdf0e10cSrcweir { 543cdf0e10cSrcweir $shortstring = installer::windows::idtglobal::make_eight_three_conform($hostname, "dir", \@shortnames); 544cdf0e10cSrcweir } 545cdf0e10cSrcweir 546cdf0e10cSrcweir my $defaultdir; 547cdf0e10cSrcweir 548cdf0e10cSrcweir if ( $shortstring eq $hostname ) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir $defaultdir = $hostname; 551cdf0e10cSrcweir } 552cdf0e10cSrcweir else 553cdf0e10cSrcweir { 554cdf0e10cSrcweir $defaultdir = $shortstring . "|" . $hostname; 555cdf0e10cSrcweir } 556cdf0e10cSrcweir 557cdf0e10cSrcweir $onedir->{'defaultdir'} = $defaultdir; 558cdf0e10cSrcweir } 559cdf0e10cSrcweir} 560cdf0e10cSrcweir 561cdf0e10cSrcweir############################################### 562cdf0e10cSrcweir# Fill content into the directory table 563cdf0e10cSrcweir############################################### 564cdf0e10cSrcweir 565*9f91b7e3SAndre Fischersub create_directorytable_from_collection ($$) 566cdf0e10cSrcweir{ 567cdf0e10cSrcweir my ($directorytableref, $directoryref) = @_; 568cdf0e10cSrcweir 569*9f91b7e3SAndre Fischer foreach my $onedir (@$directoryref) 570cdf0e10cSrcweir { 571*9f91b7e3SAndre Fischer # Remove entries for special directories. 572*9f91b7e3SAndre Fischer if (defined $onedir->{'HostName'} 573*9f91b7e3SAndre Fischer && $onedir->{'HostName'} eq "" 574*9f91b7e3SAndre Fischer && defined $onedir->{'Dir'} 575*9f91b7e3SAndre Fischer && $onedir->{'Dir'} eq "PREDEFINED_PROGDIR") 576*9f91b7e3SAndre Fischer { 577*9f91b7e3SAndre Fischer next; 578*9f91b7e3SAndre Fischer } 579*9f91b7e3SAndre Fischer 580*9f91b7e3SAndre Fischer my $oneline = sprintf( 581*9f91b7e3SAndre Fischer "%s\t%s\t%s\n", 582*9f91b7e3SAndre Fischer $onedir->{'uniquename'}, 583*9f91b7e3SAndre Fischer $onedir->{'uniqueparentname'}, 584*9f91b7e3SAndre Fischer $onedir->{'defaultdir'}); 585*9f91b7e3SAndre Fischer 586*9f91b7e3SAndre Fischer push @{$directorytableref}, $oneline; 587cdf0e10cSrcweir } 588cdf0e10cSrcweir} 589cdf0e10cSrcweir 590cdf0e10cSrcweir############################################### 591cdf0e10cSrcweir# Defining the root installation structure 592cdf0e10cSrcweir############################################### 593cdf0e10cSrcweir 594*9f91b7e3SAndre Fischersub process_root_directories ($$) 595cdf0e10cSrcweir{ 596*9f91b7e3SAndre Fischer my ($allvariableshashref, $functor) = @_; 597cdf0e10cSrcweir 598cdf0e10cSrcweir my $oneline = ""; 599cdf0e10cSrcweir 600cdf0e10cSrcweir if (( ! $installer::globals::patch ) && ( ! $installer::globals::languagepack ) && ( ! $allvariableshashref->{'DONTUSESTARTMENUFOLDER'} )) 601cdf0e10cSrcweir { 602cdf0e10cSrcweir my $productname = $allvariableshashref->{'PRODUCTNAME'}; 603cdf0e10cSrcweir my $productversion = $allvariableshashref->{'PRODUCTVERSION'}; 604cdf0e10cSrcweir my $baseproductversion = $productversion; 605cdf0e10cSrcweir 606cdf0e10cSrcweir if (( $installer::globals::prepare_winpatch ) && ( $allvariableshashref->{'BASEPRODUCTVERSION'} )) 607cdf0e10cSrcweir { 608cdf0e10cSrcweir $baseproductversion = $allvariableshashref->{'BASEPRODUCTVERSION'}; # for example "2.0" for OOo 609cdf0e10cSrcweir } 610cdf0e10cSrcweir 611cdf0e10cSrcweir my $realproductkey = $productname . " " . $productversion; 612cdf0e10cSrcweir my $productkey = $productname . " " . $baseproductversion; 613cdf0e10cSrcweir 614cdf0e10cSrcweir if (( $allvariableshashref->{'POSTVERSIONEXTENSION'} ) && ( ! $allvariableshashref->{'DONTUSEEXTENSIONINDEFAULTDIR'} )) 615cdf0e10cSrcweir { 616cdf0e10cSrcweir $productkey = $productkey . " " . $allvariableshashref->{'POSTVERSIONEXTENSION'}; 617cdf0e10cSrcweir $realproductkey = $realproductkey . " " . $allvariableshashref->{'POSTVERSIONEXTENSION'}; 618cdf0e10cSrcweir } 619cdf0e10cSrcweir if ( $allvariableshashref->{'NOSPACEINDIRECTORYNAME'} ) 620cdf0e10cSrcweir { 621cdf0e10cSrcweir $productkey =~ s/\ /\_/g; 622cdf0e10cSrcweir $realproductkey =~ s/\ /\_/g; 623cdf0e10cSrcweir } 624cdf0e10cSrcweir 625*9f91b7e3SAndre Fischer my $shortproductkey = installer::windows::idtglobal::make_eight_three_conform($productkey, "dir", undef); 626cdf0e10cSrcweir $shortproductkey =~ s/\s/\_/g; # changing empty space to underline 627cdf0e10cSrcweir 628*9f91b7e3SAndre Fischer &$functor( 629*9f91b7e3SAndre Fischer $installer::globals::officemenufolder, 630*9f91b7e3SAndre Fischer $installer::globals::programmenufolder, 631*9f91b7e3SAndre Fischer $shortproductkey . "|". $realproductkey); 632*9f91b7e3SAndre Fischer } 633cdf0e10cSrcweir 634*9f91b7e3SAndre Fischer &$functor("TARGETDIR", "", "SourceDir"); 635*9f91b7e3SAndre Fischer &$functor($installer::globals::programfilesfolder, "TARGETDIR", "."); 636*9f91b7e3SAndre Fischer &$functor($installer::globals::programmenufolder, "TARGETDIR", "."); 637*9f91b7e3SAndre Fischer &$functor($installer::globals::startupfolder, "TARGETDIR", "."); 638*9f91b7e3SAndre Fischer &$functor($installer::globals::desktopfolder, "TARGETDIR", "."); 639*9f91b7e3SAndre Fischer &$functor($installer::globals::startmenufolder, "TARGETDIR", "."); 640*9f91b7e3SAndre Fischer &$functor($installer::globals::commonfilesfolder, "TARGETDIR", "."); 641*9f91b7e3SAndre Fischer &$functor($installer::globals::commonappdatafolder, "TARGETDIR", "."); 642*9f91b7e3SAndre Fischer &$functor($installer::globals::localappdatafolder, "TARGETDIR", "."); 643cdf0e10cSrcweir 644cdf0e10cSrcweir if ( $installer::globals::usesharepointpath ) 645cdf0e10cSrcweir { 646*9f91b7e3SAndre Fischer &$functor("SHAREPOINTPATH", "TARGETDIR", "."); 647cdf0e10cSrcweir } 648cdf0e10cSrcweir 649*9f91b7e3SAndre Fischer &$functor($installer::globals::systemfolder, "TARGETDIR", "."); 650cdf0e10cSrcweir 651cdf0e10cSrcweir my $localtemplatefoldername = $installer::globals::templatefoldername; 652cdf0e10cSrcweir my $directorytableentry = $localtemplatefoldername; 653cdf0e10cSrcweir my $shorttemplatefoldername = installer::windows::idtglobal::make_eight_three_conform($localtemplatefoldername, "dir"); 654*9f91b7e3SAndre Fischer if ( $shorttemplatefoldername ne $localtemplatefoldername ) 655*9f91b7e3SAndre Fischer { 656*9f91b7e3SAndre Fischer $directorytableentry = $shorttemplatefoldername . "|" . $localtemplatefoldername; 657*9f91b7e3SAndre Fischer } 658*9f91b7e3SAndre Fischer &$functor($installer::globals::templatefolder, "TARGETDIR", $directorytableentry); 659cdf0e10cSrcweir 660cdf0e10cSrcweir if ( $installer::globals::fontsdirname ) 661cdf0e10cSrcweir { 662*9f91b7e3SAndre Fischer &$functor( 663*9f91b7e3SAndre Fischer $installer::globals::fontsfolder, 664*9f91b7e3SAndre Fischer $installer::globals::fontsdirparent, 665*9f91b7e3SAndre Fischer $installer::globals::fontsfoldername . ":" . $installer::globals::fontsdirname); 666cdf0e10cSrcweir } 667cdf0e10cSrcweir else 668cdf0e10cSrcweir { 669*9f91b7e3SAndre Fischer &$functor( 670*9f91b7e3SAndre Fischer $installer::globals::fontsfolder, 671*9f91b7e3SAndre Fischer "TARGETDIR", 672*9f91b7e3SAndre Fischer $installer::globals::fontsfoldername); 673cdf0e10cSrcweir } 674*9f91b7e3SAndre Fischer} 675*9f91b7e3SAndre Fischer 676*9f91b7e3SAndre Fischer 677*9f91b7e3SAndre Fischer 678*9f91b7e3SAndre Fischer 679*9f91b7e3SAndre Fischersub find_missing_directories ($$) 680*9f91b7e3SAndre Fischer{ 681*9f91b7e3SAndre Fischer my ($directories, $allvariableshashref) = @_; 682*9f91b7e3SAndre Fischer 683*9f91b7e3SAndre Fischer # Set up the list of target directories. 684*9f91b7e3SAndre Fischer my %target_directories = map {$_->{'uniquename'} => 1} @$directories; 685*9f91b7e3SAndre Fischer # Add special directories. 686*9f91b7e3SAndre Fischer process_root_directories( 687*9f91b7e3SAndre Fischer $allvariableshashref, 688*9f91b7e3SAndre Fischer sub($$$){ 689*9f91b7e3SAndre Fischer my ($uniquename, $parentname, $defaultdir) = @_; 690*9f91b7e3SAndre Fischer $target_directories{$uniquename} = 1; 691*9f91b7e3SAndre Fischer } 692*9f91b7e3SAndre Fischer ); 693*9f91b7e3SAndre Fischer 694*9f91b7e3SAndre Fischer # Set up the list of source directories. 695*9f91b7e3SAndre Fischer my $source_directory_map = $installer::globals::source_msi->GetDirectoryMap(); 696*9f91b7e3SAndre Fischer my $source_file_map = $installer::globals::source_msi->GetFileMap(); 697*9f91b7e3SAndre Fischer my %source_directories = map {$_->{'unique_name'} => $_} values %$source_directory_map; 698*9f91b7e3SAndre Fischer 699*9f91b7e3SAndre Fischer # Find the missing source directories. 700*9f91b7e3SAndre Fischer my @missing_directories = (); 701*9f91b7e3SAndre Fischer foreach my $source_uniquename (keys %source_directories) 702*9f91b7e3SAndre Fischer { 703*9f91b7e3SAndre Fischer if ( ! $target_directories{$source_uniquename}) 704*9f91b7e3SAndre Fischer { 705*9f91b7e3SAndre Fischer push @missing_directories, $source_directories{$source_uniquename}; 706*9f91b7e3SAndre Fischer } 707*9f91b7e3SAndre Fischer } 708*9f91b7e3SAndre Fischer 709*9f91b7e3SAndre Fischer # Report the missing directories. 710*9f91b7e3SAndre Fischer $installer::logger::Info->printf("found %d missing directories\n", scalar @missing_directories); 711*9f91b7e3SAndre Fischer my $index = 0; 712*9f91b7e3SAndre Fischer foreach my $directory_item (@missing_directories) 713*9f91b7e3SAndre Fischer { 714*9f91b7e3SAndre Fischer # Print information about the directory. 715*9f91b7e3SAndre Fischer $installer::logger::Info->printf("missing directory %d: %s\n", 716*9f91b7e3SAndre Fischer ++$index, 717*9f91b7e3SAndre Fischer $directory_item->{'full_target_long_name'}); 718*9f91b7e3SAndre Fischer while (my($key,$value) = each %$directory_item) 719*9f91b7e3SAndre Fischer { 720*9f91b7e3SAndre Fischer $installer::logger::Info->printf(" %s -> %s\n", $key, $value); 721*9f91b7e3SAndre Fischer } 722*9f91b7e3SAndre Fischer 723*9f91b7e3SAndre Fischer # Print the referencing files. 724*9f91b7e3SAndre Fischer my @filenames = (); 725*9f91b7e3SAndre Fischer while (my ($key,$value) = each %$source_file_map) 726*9f91b7e3SAndre Fischer { 727*9f91b7e3SAndre Fischer if ($value->{'directory'}->{'unique_name'} eq $directory_item->{'unique_name'}) 728*9f91b7e3SAndre Fischer { 729*9f91b7e3SAndre Fischer push @filenames, $key; 730*9f91b7e3SAndre Fischer } 731*9f91b7e3SAndre Fischer } 732*9f91b7e3SAndre Fischer $installer::logger::Info->printf(" referencing files are %s\n", join(", ", @filenames)); 733*9f91b7e3SAndre Fischer } 734*9f91b7e3SAndre Fischer 735*9f91b7e3SAndre Fischer foreach my $directory (@$directories) 736*9f91b7e3SAndre Fischer { 737*9f91b7e3SAndre Fischer $installer::logger::Lang->printf("target directory %s -> HN %s\n", 738*9f91b7e3SAndre Fischer $directory->{'uniquename'}, 739*9f91b7e3SAndre Fischer $directory->{'HostName'}); 740*9f91b7e3SAndre Fischer installer::scriptitems::print_script_item($directory); 741*9f91b7e3SAndre Fischer } 742*9f91b7e3SAndre Fischer 743*9f91b7e3SAndre Fischer # Setup a map of directory uniquenames to verify that the new 744*9f91b7e3SAndre Fischer # entries don't use unique names that are already in use. 745*9f91b7e3SAndre Fischer my %unique_names = map {$_->{'uniquename'} => $_} @$directories; 746*9f91b7e3SAndre Fischer 747*9f91b7e3SAndre Fischer # Create script items for the missing directories. 748*9f91b7e3SAndre Fischer my @new_source_directories = (); 749*9f91b7e3SAndre Fischer foreach my $source_directory_item (@missing_directories) 750*9f91b7e3SAndre Fischer { 751*9f91b7e3SAndre Fischer my $new_directory_item = { 752*9f91b7e3SAndre Fischer 'uniquename' => $source_directory_item->{'unique_name'}, 753*9f91b7e3SAndre Fischer 'uniqueparentname' => $source_directory_item->{'parent'}, 754*9f91b7e3SAndre Fischer 'defaultdir' => $source_directory_item->{'default_dir'}, 755*9f91b7e3SAndre Fischer 'HostName' => $source_directory_item->{'full_target_long_name'}, 756*9f91b7e3SAndre Fischer 'componentname' => $source_directory_item->{'component_name'}, 757*9f91b7e3SAndre Fischer }; 758*9f91b7e3SAndre Fischer 759*9f91b7e3SAndre Fischer if (defined $unique_names{$new_directory_item->{'uniquename'}}) 760*9f91b7e3SAndre Fischer { 761*9f91b7e3SAndre Fischer installer::logger::PrintError("newly created directory entry collides with existing directory"); 762*9f91b7e3SAndre Fischer last; 763*9f91b7e3SAndre Fischer } 764*9f91b7e3SAndre Fischer 765*9f91b7e3SAndre Fischer push @new_source_directories, $new_directory_item; 766*9f91b7e3SAndre Fischer } 767*9f91b7e3SAndre Fischer 768*9f91b7e3SAndre Fischer return @new_source_directories; 769*9f91b7e3SAndre Fischer} 770*9f91b7e3SAndre Fischer 771*9f91b7e3SAndre Fischer 772*9f91b7e3SAndre Fischer 773cdf0e10cSrcweir 774*9f91b7e3SAndre Fischersub prepare_directory_table_creation ($$) 775*9f91b7e3SAndre Fischer{ 776*9f91b7e3SAndre Fischer my ($directories, $allvariableshashref) = @_; 777*9f91b7e3SAndre Fischer 778*9f91b7e3SAndre Fischer foreach my $directory (@$directories) 779*9f91b7e3SAndre Fischer { 780*9f91b7e3SAndre Fischer delete $directory->{'uniquename'}; 781*9f91b7e3SAndre Fischer } 782cdf0e10cSrcweir 783*9f91b7e3SAndre Fischer overwrite_programfilesfolder($allvariableshashref); 784*9f91b7e3SAndre Fischer create_unique_directorynames($directories); 785*9f91b7e3SAndre Fischer check_unique_directorynames($directories); 786*9f91b7e3SAndre Fischer create_defaultdir_directorynames($directories); # only destdir! 787*9f91b7e3SAndre Fischer setup_global_font_directory_name($directories); 788*9f91b7e3SAndre Fischer set_installlocation_directory($directories, $allvariableshashref); 789*9f91b7e3SAndre Fischer 790*9f91b7e3SAndre Fischer if ($installer::globals::is_release) 791*9f91b7e3SAndre Fischer { 792*9f91b7e3SAndre Fischer my @new_directories = find_missing_directories($directories, $allvariableshashref); 793*9f91b7e3SAndre Fischer push @$directories, @new_directories; 794*9f91b7e3SAndre Fischer } 795cdf0e10cSrcweir} 796cdf0e10cSrcweir 797*9f91b7e3SAndre Fischer 798*9f91b7e3SAndre Fischer 799*9f91b7e3SAndre Fischer 800cdf0e10cSrcweir############################################### 801cdf0e10cSrcweir# Creating the file Director.idt dynamically 802cdf0e10cSrcweir############################################### 803cdf0e10cSrcweir 804*9f91b7e3SAndre Fischersub create_directory_table ($$$) 805cdf0e10cSrcweir{ 806*9f91b7e3SAndre Fischer my ($directoryref, $basedir, $allvariableshashref) = @_; 807cdf0e10cSrcweir 808cdf0e10cSrcweir # Structure of the directory table: 809cdf0e10cSrcweir # Directory Directory_Parent DefaultDir 810cdf0e10cSrcweir # Directory is a unique identifier 811cdf0e10cSrcweir # Directory_Parent is the unique identifier of the parent 812cdf0e10cSrcweir # DefaultDir is .:APPLIC~1|Application Data with 813cdf0e10cSrcweir # Before ":" : [sourcedir]:[destdir] (not programmed yet) 814cdf0e10cSrcweir # After ":" : 8+3 and not 8+3 the destination directory name 81519d58b3aSEike Rathke 816b274bc22SAndre Fischer $installer::logger::Lang->add_timestamp("Performance Info: Directory Table start"); 817cdf0e10cSrcweir 818cdf0e10cSrcweir my @directorytable = (); 819cdf0e10cSrcweir installer::windows::idtglobal::write_idt_header(\@directorytable, "directory"); 820*9f91b7e3SAndre Fischer 821*9f91b7e3SAndre Fischer # Add entries for the root directories (and a few special directories like that for fonts). 822*9f91b7e3SAndre Fischer process_root_directories( 823*9f91b7e3SAndre Fischer $allvariableshashref, 824*9f91b7e3SAndre Fischer sub($$$){ 825*9f91b7e3SAndre Fischer push(@directorytable, join("\t", @_)."\n"); 826*9f91b7e3SAndre Fischer } 827*9f91b7e3SAndre Fischer ); 828*9f91b7e3SAndre Fischer 829*9f91b7e3SAndre Fischer # Add entries for the non-root directories. 830cdf0e10cSrcweir create_directorytable_from_collection(\@directorytable, $directoryref); 831cdf0e10cSrcweir 832cdf0e10cSrcweir # Saving the file 833cdf0e10cSrcweir 834cdf0e10cSrcweir my $directorytablename = $basedir . $installer::globals::separator . "Director.idt"; 835cdf0e10cSrcweir installer::files::save_file($directorytablename ,\@directorytable); 836b274bc22SAndre Fischer $installer::logger::Lang->printf("Created idt file: %s\n", $directorytablename); 83719d58b3aSEike Rathke 838b274bc22SAndre Fischer $installer::logger::Lang->add_timestamp("Performance Info: Directory Table end"); 839cdf0e10cSrcweir} 840cdf0e10cSrcweir 841*9f91b7e3SAndre Fischer 842cdf0e10cSrcweir1; 843