1cdf0e10cSrcweir#************************************************************************* 2cdf0e10cSrcweir# 3cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4cdf0e10cSrcweir# 5cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates. 6cdf0e10cSrcweir# 7cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite 8cdf0e10cSrcweir# 9cdf0e10cSrcweir# This file is part of OpenOffice.org. 10cdf0e10cSrcweir# 11cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify 12cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3 13cdf0e10cSrcweir# only, as published by the Free Software Foundation. 14cdf0e10cSrcweir# 15cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful, 16cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of 17cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details 19cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code). 20cdf0e10cSrcweir# 21cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License 22cdf0e10cSrcweir# version 3 along with OpenOffice.org. If not, see 23cdf0e10cSrcweir# <http://www.openoffice.org/license.html> 24cdf0e10cSrcweir# for a copy of the LGPLv3 License. 25cdf0e10cSrcweir# 26cdf0e10cSrcweir#************************************************************************* 27cdf0e10cSrcweir 28cdf0e10cSrcweirpackage installer::windows::directory; 29cdf0e10cSrcweir 30cdf0e10cSrcweiruse installer::exiter; 31cdf0e10cSrcweiruse installer::files; 32cdf0e10cSrcweiruse installer::globals; 33cdf0e10cSrcweiruse installer::pathanalyzer; 34cdf0e10cSrcweiruse installer::windows::idtglobal; 35*19d58b3aSEike Rathkeuse installer::windows::msiglobal; 36cdf0e10cSrcweir 37cdf0e10cSrcweir############################################################## 38cdf0e10cSrcweir# Collecting all directory trees in global hash 39cdf0e10cSrcweir############################################################## 40cdf0e10cSrcweir 41cdf0e10cSrcweirsub collectdirectorytrees 42cdf0e10cSrcweir{ 43cdf0e10cSrcweir my ( $directoryref ) = @_; 44cdf0e10cSrcweir 45cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$directoryref}; $i++ ) 46cdf0e10cSrcweir { 47cdf0e10cSrcweir my $onedir = ${$directoryref}[$i]; 48cdf0e10cSrcweir my $styles = ""; 49cdf0e10cSrcweir if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; } 50cdf0e10cSrcweir 51cdf0e10cSrcweir if ( $styles ne "" ) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir foreach my $treestyle ( keys %installer::globals::treestyles ) 54cdf0e10cSrcweir { 55cdf0e10cSrcweir if ( $styles =~ /\b$treestyle\b/ ) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir my $hostname = $onedir->{'HostName'}; 58cdf0e10cSrcweir # -> hostname is the key, the style the value! 59cdf0e10cSrcweir $installer::globals::hostnametreestyles{$hostname} = $treestyle; 60cdf0e10cSrcweir } 61cdf0e10cSrcweir } 62cdf0e10cSrcweir } 63cdf0e10cSrcweir } 64cdf0e10cSrcweir} 65cdf0e10cSrcweir 66cdf0e10cSrcweir############################################################## 67cdf0e10cSrcweir# Overwriting global programfilesfolder, if required 68cdf0e10cSrcweir############################################################## 69cdf0e10cSrcweir 70cdf0e10cSrcweirsub overwrite_programfilesfolder 71cdf0e10cSrcweir{ 72cdf0e10cSrcweir my ( $allvariables ) = @_; 73cdf0e10cSrcweir 74cdf0e10cSrcweir if ( $allvariables->{'PROGRAMFILESFOLDERNAME'} ) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir $installer::globals::programfilesfolder = $allvariables->{'PROGRAMFILESFOLDERNAME'}; 77cdf0e10cSrcweir } 78cdf0e10cSrcweir} 79cdf0e10cSrcweir 80cdf0e10cSrcweir############################################################## 81cdf0e10cSrcweir# Maximum length of directory name is 72. 82cdf0e10cSrcweir# Taking care of underlines, which are the separator. 83cdf0e10cSrcweir############################################################## 84cdf0e10cSrcweir 85cdf0e10cSrcweirsub make_short_dir_version 86cdf0e10cSrcweir{ 87*19d58b3aSEike Rathke my ($longstring) = @_; 88cdf0e10cSrcweir 89cdf0e10cSrcweir my $shortstring = ""; 90*19d58b3aSEike Rathke my $cutlength = 60; 91*19d58b3aSEike Rathke my $length = 5; # So the directory can still be recognized 92*19d58b3aSEike Rathke my $longstring_save = $longstring; 93cdf0e10cSrcweir 94cdf0e10cSrcweir # Splitting the string at each "underline" and allowing only $length characters per directory name. 95cdf0e10cSrcweir # Checking also uniqueness and length. 96cdf0e10cSrcweir 97cdf0e10cSrcweir my $stringarray = installer::converter::convert_stringlist_into_array_without_newline(\$longstring, "_"); 98cdf0e10cSrcweir 99cdf0e10cSrcweir foreach my $onestring ( @{$stringarray} ) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir my $partstring = ""; 102cdf0e10cSrcweir 103cdf0e10cSrcweir if ( $onestring =~ /\-/ ) 104cdf0e10cSrcweir { 105cdf0e10cSrcweir my $localstringarray = installer::converter::convert_stringlist_into_array_without_newline(\$onestring, "-"); 106cdf0e10cSrcweir foreach my $onelocalstring ( @{$localstringarray} ) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir if ( length($onelocalstring) > $length ) { $onelocalstring = substr($onelocalstring, 0, $length); } 109cdf0e10cSrcweir $partstring = $partstring . "-" . $onelocalstring; 110cdf0e10cSrcweir } 111cdf0e10cSrcweir $partstring =~ s/^\s*\-//; 112cdf0e10cSrcweir } 113cdf0e10cSrcweir else 114cdf0e10cSrcweir { 115cdf0e10cSrcweir if ( length($onestring) > $length ) { $partstring = substr($onestring, 0, $length); } 116cdf0e10cSrcweir else { $partstring = $onestring; } 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir $shortstring = $shortstring . "_" . $partstring; 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir $shortstring =~ s/^\s*\_//; 123cdf0e10cSrcweir 124*19d58b3aSEike Rathke # Setting unique ID to each directory 125*19d58b3aSEike Rathke # No counter allowed, process must be absolute reproducable due to patch creation process. 126*19d58b3aSEike Rathke 127*19d58b3aSEike Rathke # chomp(my $id = `echo $longstring_save | md5sum | sed -e "s/ .*//g"`); # Very, very slow 128*19d58b3aSEike Rathke # my $subid = substr($id, 0, 9); # taking only the first 9 digits 129*19d58b3aSEike Rathke 130*19d58b3aSEike Rathke my $subid = installer::windows::msiglobal::calculate_id($longstring_save, 9); # taking only the first 9 digits 131*19d58b3aSEike Rathke 132*19d58b3aSEike Rathke if ( length($shortstring) > $cutlength ) { $shortstring = substr($shortstring, 0, $cutlength); } 133*19d58b3aSEike Rathke 134*19d58b3aSEike Rathke $shortstring = $shortstring . "_" . $subid; 135cdf0e10cSrcweir 136cdf0e10cSrcweir return $shortstring; 137cdf0e10cSrcweir} 138cdf0e10cSrcweir 139cdf0e10cSrcweir############################################################## 140cdf0e10cSrcweir# Adding unique directory names to the directory collection 141cdf0e10cSrcweir############################################################## 142cdf0e10cSrcweir 143cdf0e10cSrcweirsub create_unique_directorynames 144cdf0e10cSrcweir{ 145cdf0e10cSrcweir my ($directoryref, $allvariables) = @_; 146cdf0e10cSrcweir 147cdf0e10cSrcweir $installer::globals::officeinstalldirectoryset = 0; 148cdf0e10cSrcweir 149*19d58b3aSEike Rathke my %completedirhashstep1 = (); 150*19d58b3aSEike Rathke my %shortdirhash = (); 151*19d58b3aSEike Rathke my %shortdirhashreverse = (); 152cdf0e10cSrcweir my $infoline = ""; 153cdf0e10cSrcweir my $errorcount = 0; 154cdf0e10cSrcweir 155cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$directoryref}; $i++ ) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir my $onedir = ${$directoryref}[$i]; 158*19d58b3aSEike Rathke my $uniquename = $onedir->{'HostName'}; 159cdf0e10cSrcweir 160cdf0e10cSrcweir my $styles = ""; 161cdf0e10cSrcweir if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; } 162cdf0e10cSrcweir 163cdf0e10cSrcweir $uniquename =~ s/^\s*//g; # removing beginning white spaces 164cdf0e10cSrcweir $uniquename =~ s/\s*$//g; # removing ending white spaces 165cdf0e10cSrcweir $uniquename =~ s/\s//g; # removing white spaces 166cdf0e10cSrcweir $uniquename =~ s/\_//g; # removing existing underlines 167cdf0e10cSrcweir $uniquename =~ s/\.//g; # removing dots in directoryname 168cdf0e10cSrcweir $uniquename =~ s/OpenOffice/OO/g; 169*19d58b3aSEike Rathke 170*19d58b3aSEike Rathke $uniquename =~ s/\Q$installer::globals::separator\E/\_/g; # replacing slash and backslash with underline 171*19d58b3aSEike Rathke 172cdf0e10cSrcweir $uniquename =~ s/_registry/_rgy/g; 173cdf0e10cSrcweir $uniquename =~ s/_registration/_rgn/g; 174cdf0e10cSrcweir $uniquename =~ s/_extension/_ext/g; 175cdf0e10cSrcweir $uniquename =~ s/_frame/_frm/g; 176cdf0e10cSrcweir $uniquename =~ s/_table/_tbl/g; 177cdf0e10cSrcweir $uniquename =~ s/_chart/_crt/g; 178cdf0e10cSrcweir 179*19d58b3aSEike Rathke # The names after this small changes must still be unique! 180*19d58b3aSEike Rathke if ( exists($completedirhashstep1{$uniquename}) ) { installer::exiter::exit_program("ERROR: Error in packaging process. Unallowed modification of directory name, not unique (step 1): \"$uniquename\".", "create_unique_directorynames"); } 181*19d58b3aSEike Rathke $completedirhashstep1{$uniquename} = 1; 182cdf0e10cSrcweir 183*19d58b3aSEike Rathke # Starting to make unique name for the parent and its directory 184*19d58b3aSEike Rathke my $originaluniquename = $uniquename; 185cdf0e10cSrcweir 186*19d58b3aSEike Rathke $uniquename = make_short_dir_version($uniquename); 187cdf0e10cSrcweir 188*19d58b3aSEike Rathke # Checking if the same directory already exists, but has another short version. 189*19d58b3aSEike Rathke if (( exists($shortdirhash{$originaluniquename}) ) && ( $shortdirhash{$originaluniquename} ne $uniquename )) { installer::exiter::exit_program("ERROR: Error in packaging process. Unallowed modification of directory name, not unique (step 2A): \"$uniquename\".", "create_unique_directorynames"); } 190cdf0e10cSrcweir 191*19d58b3aSEike Rathke # Also checking vice versa 192*19d58b3aSEike Rathke # Checking if the same short directory already exists, but has another long version. 193*19d58b3aSEike Rathke if (( exists($shortdirhashreverse{$uniquename}) ) && ( $shortdirhashreverse{$uniquename} ne $originaluniquename )) { installer::exiter::exit_program("ERROR: Error in packaging process. Unallowed modification of directory name, not unique (step 2B): \"$uniquename\".", "create_unique_directorynames"); } 194cdf0e10cSrcweir 195*19d58b3aSEike Rathke # Creating assignment from long to short directory names 196*19d58b3aSEike Rathke $shortdirhash{$originaluniquename} = $uniquename; 197*19d58b3aSEike Rathke $shortdirhashreverse{$uniquename} = $originaluniquename; 198cdf0e10cSrcweir 199*19d58b3aSEike Rathke # Important: The unique parent is generated from the string $originaluniquename (with the use of underlines). 200cdf0e10cSrcweir 201*19d58b3aSEike Rathke my $uniqueparentname = $originaluniquename; 202*19d58b3aSEike Rathke my $keepparent = 1; 203cdf0e10cSrcweir 204cdf0e10cSrcweir if ( $uniqueparentname =~ /^\s*(.*)\_(.*?)\s*$/ ) # the underline is now the separator 205cdf0e10cSrcweir { 206cdf0e10cSrcweir $uniqueparentname = $1; 207*19d58b3aSEike Rathke $keepparent = 0; 208cdf0e10cSrcweir } 209cdf0e10cSrcweir else 210cdf0e10cSrcweir { 211cdf0e10cSrcweir $uniqueparentname = $installer::globals::programfilesfolder; 212*19d58b3aSEike Rathke $keepparent = 1; 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215*19d58b3aSEike Rathke if ( $styles =~ /\bPROGRAMFILESFOLDER\b/ ) 216*19d58b3aSEike Rathke { 217*19d58b3aSEike Rathke $uniqueparentname = $installer::globals::programfilesfolder; 218*19d58b3aSEike Rathke $keepparent = 1; 219*19d58b3aSEike Rathke } 220*19d58b3aSEike Rathke if ( $styles =~ /\bCOMMONFILESFOLDER\b/ ) 221*19d58b3aSEike Rathke { 222*19d58b3aSEike Rathke $uniqueparentname = $installer::globals::commonfilesfolder; 223*19d58b3aSEike Rathke $keepparent = 1; 224*19d58b3aSEike Rathke } 225*19d58b3aSEike Rathke if ( $styles =~ /\bCOMMONAPPDATAFOLDER\b/ ) 226*19d58b3aSEike Rathke { 227*19d58b3aSEike Rathke $uniqueparentname = $installer::globals::commonappdatafolder; 228*19d58b3aSEike Rathke $keepparent = 1; 229*19d58b3aSEike Rathke } 230*19d58b3aSEike Rathke if ( $styles =~ /\bLOCALAPPDATAFOLDER\b/ ) 231*19d58b3aSEike Rathke { 232*19d58b3aSEike Rathke $uniqueparentname = $installer::globals::localappdatafolder; 233*19d58b3aSEike Rathke $keepparent = 1; 234*19d58b3aSEike Rathke } 235cdf0e10cSrcweir 236cdf0e10cSrcweir if ( $styles =~ /\bSHAREPOINTPATH\b/ ) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir $uniqueparentname = "SHAREPOINTPATH"; 239cdf0e10cSrcweir $installer::globals::usesharepointpath = 1; 240*19d58b3aSEike Rathke $keepparent = 1; 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243*19d58b3aSEike Rathke # also setting short directory name for the parent 244*19d58b3aSEike Rathke 245*19d58b3aSEike Rathke my $originaluniqueparentname = $uniqueparentname; 246*19d58b3aSEike Rathke 247*19d58b3aSEike Rathke if ( ! $keepparent ) 248*19d58b3aSEike Rathke { 249*19d58b3aSEike Rathke $uniqueparentname = make_short_dir_version($uniqueparentname); 250*19d58b3aSEike Rathke } 251*19d58b3aSEike Rathke 252*19d58b3aSEike Rathke # Again checking if the same directory already exists, but has another short version. 253*19d58b3aSEike Rathke if (( exists($shortdirhash{$originaluniqueparentname}) ) && ( $shortdirhash{$originaluniqueparentname} ne $uniqueparentname )) { installer::exiter::exit_program("ERROR: Error in packaging process. Unallowed modification of directory name, not unique (step 3A): \"$uniqueparentname\".", "create_unique_directorynames"); } 254*19d58b3aSEike Rathke 255*19d58b3aSEike Rathke # Also checking vice versa 256*19d58b3aSEike Rathke # Checking if the same short directory already exists, but has another long version. 257*19d58b3aSEike Rathke if (( exists($shortdirhashreverse{$uniqueparentname}) ) && ( $shortdirhashreverse{$uniqueparentname} ne $originaluniqueparentname )) { installer::exiter::exit_program("ERROR: Error in packaging process. Unallowed modification of directory name, not unique (step 3B): \"$uniqueparentname\".", "create_unique_directorynames"); } 258*19d58b3aSEike Rathke 259*19d58b3aSEike Rathke $shortdirhash{$originaluniqueparentname} = $uniqueparentname; 260*19d58b3aSEike Rathke $shortdirhashreverse{$uniqueparentname} = $originaluniqueparentname; 261*19d58b3aSEike Rathke 262*19d58b3aSEike Rathke # Hyphen not allowed in database 263cdf0e10cSrcweir $uniquename =~ s/\-/\_/g; # making "-" to "_" 264cdf0e10cSrcweir $uniqueparentname =~ s/\-/\_/g; # making "-" to "_" 265cdf0e10cSrcweir 266*19d58b3aSEike Rathke # And finally setting the values for the directories 267cdf0e10cSrcweir $onedir->{'uniquename'} = $uniquename; 268cdf0e10cSrcweir $onedir->{'uniqueparentname'} = $uniqueparentname; 269cdf0e10cSrcweir 270cdf0e10cSrcweir # setting the installlocation directory 271cdf0e10cSrcweir if ( $styles =~ /\bISINSTALLLOCATION\b/ ) 272cdf0e10cSrcweir { 273cdf0e10cSrcweir if ( $installer::globals::installlocationdirectoryset ) { installer::exiter::exit_program("ERROR: Directory with flag ISINSTALLLOCATION alread set: \"$installer::globals::installlocationdirectory\".", "create_unique_directorynames"); } 274cdf0e10cSrcweir $installer::globals::installlocationdirectory = $uniquename; 275cdf0e10cSrcweir $installer::globals::installlocationdirectoryset = 1; 276cdf0e10cSrcweir if ( $installer::globals::installlocationdirectory =~ /oracle_/i ) { $installer::globals::sundirexists = 1; } 277cdf0e10cSrcweir } 278cdf0e10cSrcweir 279cdf0e10cSrcweir # setting the sundirectory 280cdf0e10cSrcweir if ( $styles =~ /\bSUNDIRECTORY\b/ ) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir if ( $installer::globals::vendordirectoryset ) { installer::exiter::exit_program("ERROR: Directory with flag SUNDIRECTORY alread set: \"$installer::globals::vendordirectory\".", "create_unique_directorynames"); } 283cdf0e10cSrcweir $installer::globals::vendordirectory = $uniquename; 284cdf0e10cSrcweir $installer::globals::vendordirectoryset = 1; 285cdf0e10cSrcweir } 286cdf0e10cSrcweir } 287cdf0e10cSrcweir} 288cdf0e10cSrcweir 289cdf0e10cSrcweir##################################################### 290cdf0e10cSrcweir# Adding ":." to selected default directory names 291cdf0e10cSrcweir##################################################### 292cdf0e10cSrcweir 293cdf0e10cSrcweirsub check_sourcedir_addon 294cdf0e10cSrcweir{ 295cdf0e10cSrcweir my ( $onedir, $allvariableshashref ) = @_; 296cdf0e10cSrcweir 297cdf0e10cSrcweir if (($installer::globals::addchildprojects) || 298cdf0e10cSrcweir ($installer::globals::patch) || 299cdf0e10cSrcweir ($installer::globals::languagepack) || 300cdf0e10cSrcweir ($allvariableshashref->{'CHANGETARGETDIR'})) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir my $sourcediraddon = "\:\."; 303cdf0e10cSrcweir $onedir->{'defaultdir'} = $onedir->{'defaultdir'} . $sourcediraddon; 304cdf0e10cSrcweir } 305cdf0e10cSrcweir 306cdf0e10cSrcweir} 307cdf0e10cSrcweir 308cdf0e10cSrcweir##################################################### 309cdf0e10cSrcweir# The directory with the style ISINSTALLLOCATION 310cdf0e10cSrcweir# will be replaced by INSTALLLOCATION 311cdf0e10cSrcweir##################################################### 312cdf0e10cSrcweir 313cdf0e10cSrcweirsub set_installlocation_directory 314cdf0e10cSrcweir{ 315cdf0e10cSrcweir my ( $directoryref, $allvariableshashref ) = @_; 316cdf0e10cSrcweir 317cdf0e10cSrcweir if ( ! $installer::globals::installlocationdirectoryset ) { installer::exiter::exit_program("ERROR: Directory with flag ISINSTALLLOCATION not set!", "set_installlocation_directory"); } 318cdf0e10cSrcweir 319cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$directoryref}; $i++ ) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir my $onedir = ${$directoryref}[$i]; 322cdf0e10cSrcweir 323cdf0e10cSrcweir if ( $onedir->{'uniquename'} eq $installer::globals::installlocationdirectory ) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir $onedir->{'uniquename'} = "INSTALLLOCATION"; 326cdf0e10cSrcweir check_sourcedir_addon($onedir, $allvariableshashref); 327cdf0e10cSrcweir } 328cdf0e10cSrcweir 329cdf0e10cSrcweir if ( $onedir->{'uniquename'} eq $installer::globals::vendordirectory ) 330cdf0e10cSrcweir { 331cdf0e10cSrcweir check_sourcedir_addon($onedir, $allvariableshashref); 332cdf0e10cSrcweir } 333cdf0e10cSrcweir 334cdf0e10cSrcweir if ( $onedir->{'uniqueparentname'} eq $installer::globals::installlocationdirectory ) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir $onedir->{'uniqueparentname'} = "INSTALLLOCATION"; 337cdf0e10cSrcweir } 338cdf0e10cSrcweir } 339cdf0e10cSrcweir} 340cdf0e10cSrcweir 341cdf0e10cSrcweir##################################################### 342cdf0e10cSrcweir# Getting the name of the top level directory. This 343cdf0e10cSrcweir# can have only one letter 344cdf0e10cSrcweir##################################################### 345cdf0e10cSrcweir 346cdf0e10cSrcweirsub get_last_directory_name 347cdf0e10cSrcweir{ 348cdf0e10cSrcweir my ($completepathref) = @_; 349cdf0e10cSrcweir 350cdf0e10cSrcweir if ( $$completepathref =~ /^.*[\/\\](.+?)\s*$/ ) 351cdf0e10cSrcweir { 352cdf0e10cSrcweir $$completepathref = $1; 353cdf0e10cSrcweir } 354cdf0e10cSrcweir} 355cdf0e10cSrcweir 356cdf0e10cSrcweir##################################################### 357cdf0e10cSrcweir# Creating the defaultdir for the file Director.idt 358cdf0e10cSrcweir##################################################### 359cdf0e10cSrcweir 360cdf0e10cSrcweirsub create_defaultdir_directorynames 361cdf0e10cSrcweir{ 362cdf0e10cSrcweir my ($directoryref, $shortdirnamehashref) = @_; 363cdf0e10cSrcweir 364cdf0e10cSrcweir my @shortnames = (); 365cdf0e10cSrcweir if ( $installer::globals::updatedatabase ) { @shortnames = values(%{$shortdirnamehashref}); } 366cdf0e10cSrcweir elsif ( $installer::globals::prepare_winpatch ) { @shortnames = values(%installer::globals::saved83dirmapping); } 367cdf0e10cSrcweir 368cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$directoryref}; $i++ ) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir my $onedir = ${$directoryref}[$i]; 371cdf0e10cSrcweir my $hostname = $onedir->{'HostName'}; 372cdf0e10cSrcweir 373cdf0e10cSrcweir $hostname =~ s/\Q$installer::globals::separator\E\s*$//; 374cdf0e10cSrcweir get_last_directory_name(\$hostname); 375cdf0e10cSrcweir # installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$hostname); # making program/classes to classes 376cdf0e10cSrcweir my $uniquename = $onedir->{'uniquename'}; 377cdf0e10cSrcweir my $shortstring; 378cdf0e10cSrcweir if (( $installer::globals::updatedatabase ) && ( exists($shortdirnamehashref->{$uniquename}) )) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir $shortstring = $shortdirnamehashref->{$uniquename}; 381cdf0e10cSrcweir } 382cdf0e10cSrcweir elsif (( $installer::globals::prepare_winpatch ) && ( exists($installer::globals::saved83dirmapping{$uniquename}) )) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir $shortstring = $installer::globals::saved83dirmapping{$uniquename}; 385cdf0e10cSrcweir } 386cdf0e10cSrcweir else 387cdf0e10cSrcweir { 388cdf0e10cSrcweir $shortstring = installer::windows::idtglobal::make_eight_three_conform($hostname, "dir", \@shortnames); 389cdf0e10cSrcweir } 390cdf0e10cSrcweir 391cdf0e10cSrcweir my $defaultdir; 392cdf0e10cSrcweir 393cdf0e10cSrcweir if ( $shortstring eq $hostname ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir $defaultdir = $hostname; 396cdf0e10cSrcweir } 397cdf0e10cSrcweir else 398cdf0e10cSrcweir { 399cdf0e10cSrcweir $defaultdir = $shortstring . "|" . $hostname; 400cdf0e10cSrcweir } 401cdf0e10cSrcweir 402cdf0e10cSrcweir $onedir->{'defaultdir'} = $defaultdir; 403cdf0e10cSrcweir 404cdf0e10cSrcweir my $fontdir = ""; 405cdf0e10cSrcweir if ( $onedir->{'Dir'} ) { $fontdir = $onedir->{'Dir'}; } 406cdf0e10cSrcweir 407cdf0e10cSrcweir my $fontdefaultdir = ""; 408cdf0e10cSrcweir if ( $onedir->{'defaultdir'} ) { $fontdefaultdir = $onedir->{'defaultdir'}; } 409cdf0e10cSrcweir 410cdf0e10cSrcweir if (( $fontdir eq "PREDEFINED_OSSYSTEMFONTDIR" ) && ( $fontdefaultdir eq $installer::globals::fontsdirhostname )) 411cdf0e10cSrcweir { 412cdf0e10cSrcweir $installer::globals::fontsdirname = $onedir->{'defaultdir'}; 413cdf0e10cSrcweir $installer::globals::fontsdirparent = $onedir->{'uniqueparentname'}; 414cdf0e10cSrcweir } 415cdf0e10cSrcweir } 416cdf0e10cSrcweir} 417cdf0e10cSrcweir 418cdf0e10cSrcweir############################################### 419cdf0e10cSrcweir# Fill content into the directory table 420cdf0e10cSrcweir############################################### 421cdf0e10cSrcweir 422cdf0e10cSrcweirsub create_directorytable_from_collection 423cdf0e10cSrcweir{ 424cdf0e10cSrcweir my ($directorytableref, $directoryref) = @_; 425cdf0e10cSrcweir 426cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$directoryref}; $i++ ) 427cdf0e10cSrcweir { 428cdf0e10cSrcweir my $onedir = ${$directoryref}[$i]; 429cdf0e10cSrcweir my $hostname = $onedir->{'HostName'}; 430cdf0e10cSrcweir my $dir = ""; 431cdf0e10cSrcweir 432cdf0e10cSrcweir if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; } 433cdf0e10cSrcweir 434cdf0e10cSrcweir if (( $dir eq "PREDEFINED_PROGDIR" ) && ( $hostname eq "" )) { next; } # removing files from root directory 435cdf0e10cSrcweir 436cdf0e10cSrcweir my $oneline = $onedir->{'uniquename'} . "\t" . $onedir->{'uniqueparentname'} . "\t" . $onedir->{'defaultdir'} . "\n"; 437cdf0e10cSrcweir 438cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 439cdf0e10cSrcweir } 440cdf0e10cSrcweir} 441cdf0e10cSrcweir 442cdf0e10cSrcweir############################################### 443cdf0e10cSrcweir# Defining the root installation structure 444cdf0e10cSrcweir############################################### 445cdf0e10cSrcweir 446cdf0e10cSrcweirsub add_root_directories 447cdf0e10cSrcweir{ 448cdf0e10cSrcweir my ($directorytableref, $allvariableshashref) = @_; 449cdf0e10cSrcweir 450cdf0e10cSrcweir# my $sourcediraddon = ""; 451cdf0e10cSrcweir# if (($installer::globals::addchildprojects) || 452cdf0e10cSrcweir# ($installer::globals::patch) || 453cdf0e10cSrcweir# ($installer::globals::languagepack) || 454cdf0e10cSrcweir# ($allvariableshashref->{'CHANGETARGETDIR'})) 455cdf0e10cSrcweir# { 456cdf0e10cSrcweir# $sourcediraddon = "\:\."; 457cdf0e10cSrcweir# } 458cdf0e10cSrcweir 459cdf0e10cSrcweir my $oneline = ""; 460cdf0e10cSrcweir 461cdf0e10cSrcweir if (( ! $installer::globals::patch ) && ( ! $installer::globals::languagepack ) && ( ! $allvariableshashref->{'DONTUSESTARTMENUFOLDER'} )) 462cdf0e10cSrcweir { 463cdf0e10cSrcweir my $productname = $allvariableshashref->{'PRODUCTNAME'}; 464cdf0e10cSrcweir my $productversion = $allvariableshashref->{'PRODUCTVERSION'}; 465cdf0e10cSrcweir my $baseproductversion = $productversion; 466cdf0e10cSrcweir 467cdf0e10cSrcweir if (( $installer::globals::prepare_winpatch ) && ( $allvariableshashref->{'BASEPRODUCTVERSION'} )) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir $baseproductversion = $allvariableshashref->{'BASEPRODUCTVERSION'}; # for example "2.0" for OOo 470cdf0e10cSrcweir } 471cdf0e10cSrcweir 472cdf0e10cSrcweir my $realproductkey = $productname . " " . $productversion; 473cdf0e10cSrcweir my $productkey = $productname . " " . $baseproductversion; 474cdf0e10cSrcweir 475cdf0e10cSrcweir if (( $allvariableshashref->{'POSTVERSIONEXTENSION'} ) && ( ! $allvariableshashref->{'DONTUSEEXTENSIONINDEFAULTDIR'} )) 476cdf0e10cSrcweir { 477cdf0e10cSrcweir $productkey = $productkey . " " . $allvariableshashref->{'POSTVERSIONEXTENSION'}; 478cdf0e10cSrcweir $realproductkey = $realproductkey . " " . $allvariableshashref->{'POSTVERSIONEXTENSION'}; 479cdf0e10cSrcweir } 480cdf0e10cSrcweir if ( $allvariableshashref->{'NOVERSIONINDIRNAME'} ) 481cdf0e10cSrcweir { 482cdf0e10cSrcweir $productkey = $productname; 483cdf0e10cSrcweir $realproductkey = $realproductname; 484cdf0e10cSrcweir } 485cdf0e10cSrcweir if ( $allvariableshashref->{'NOSPACEINDIRECTORYNAME'} ) 486cdf0e10cSrcweir { 487cdf0e10cSrcweir $productkey =~ s/\ /\_/g; 488cdf0e10cSrcweir $realproductkey =~ s/\ /\_/g; 489cdf0e10cSrcweir } 490cdf0e10cSrcweir 491cdf0e10cSrcweir my $shortproductkey = installer::windows::idtglobal::make_eight_three_conform($productkey, "dir"); # third parameter not used 492cdf0e10cSrcweir $shortproductkey =~ s/\s/\_/g; # changing empty space to underline 493cdf0e10cSrcweir 494cdf0e10cSrcweir $oneline = "$installer::globals::officemenufolder\t$installer::globals::programmenufolder\t$shortproductkey|$realproductkey\n"; 495cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 496cdf0e10cSrcweir } 497cdf0e10cSrcweir 498cdf0e10cSrcweir $oneline = "TARGETDIR\t\tSourceDir\n"; 499cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 500cdf0e10cSrcweir 501cdf0e10cSrcweir $oneline = "$installer::globals::programfilesfolder\tTARGETDIR\t.\n"; 502cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 503cdf0e10cSrcweir 504cdf0e10cSrcweir $oneline = "$installer::globals::programmenufolder\tTARGETDIR\t.\n"; 505cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 506cdf0e10cSrcweir 507cdf0e10cSrcweir $oneline = "$installer::globals::startupfolder\tTARGETDIR\t.\n"; 508cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 509cdf0e10cSrcweir 510cdf0e10cSrcweir $oneline = "$installer::globals::desktopfolder\tTARGETDIR\t.\n"; 511cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 512cdf0e10cSrcweir 513cdf0e10cSrcweir $oneline = "$installer::globals::startmenufolder\tTARGETDIR\t.\n"; 514cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 515cdf0e10cSrcweir 516cdf0e10cSrcweir $oneline = "$installer::globals::commonfilesfolder\tTARGETDIR\t.\n"; 517cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 518cdf0e10cSrcweir 519cdf0e10cSrcweir $oneline = "$installer::globals::commonappdatafolder\tTARGETDIR\t.\n"; 520cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 521cdf0e10cSrcweir 522cdf0e10cSrcweir $oneline = "$installer::globals::localappdatafolder\tTARGETDIR\t.\n"; 523cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 524cdf0e10cSrcweir 525cdf0e10cSrcweir if ( $installer::globals::usesharepointpath ) 526cdf0e10cSrcweir { 527cdf0e10cSrcweir $oneline = "SHAREPOINTPATH\tTARGETDIR\t.\n"; 528cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 529cdf0e10cSrcweir } 530cdf0e10cSrcweir 531cdf0e10cSrcweir $oneline = "$installer::globals::systemfolder\tTARGETDIR\t.\n"; 532cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 533cdf0e10cSrcweir 534cdf0e10cSrcweir my $localtemplatefoldername = $installer::globals::templatefoldername; 535cdf0e10cSrcweir my $directorytableentry = $localtemplatefoldername; 536cdf0e10cSrcweir my $shorttemplatefoldername = installer::windows::idtglobal::make_eight_three_conform($localtemplatefoldername, "dir"); 537cdf0e10cSrcweir if ( $shorttemplatefoldername ne $localtemplatefoldername ) { $directorytableentry = "$shorttemplatefoldername|$localtemplatefoldername"; } 538cdf0e10cSrcweir $oneline = "$installer::globals::templatefolder\tTARGETDIR\t$directorytableentry\n"; 539cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 540cdf0e10cSrcweir 541cdf0e10cSrcweir if ( $installer::globals::fontsdirname ) 542cdf0e10cSrcweir { 543cdf0e10cSrcweir $oneline = "$installer::globals::fontsfolder\t$installer::globals::fontsdirparent\t$installer::globals::fontsfoldername\:$installer::globals::fontsdirname\n"; 544cdf0e10cSrcweir } 545cdf0e10cSrcweir else 546cdf0e10cSrcweir { 547cdf0e10cSrcweir $oneline = "$installer::globals::fontsfolder\tTARGETDIR\t$installer::globals::fontsfoldername\n"; 548cdf0e10cSrcweir } 549cdf0e10cSrcweir 550cdf0e10cSrcweir push(@{$directorytableref}, $oneline); 551cdf0e10cSrcweir 552cdf0e10cSrcweir} 553cdf0e10cSrcweir 554cdf0e10cSrcweir############################################### 555cdf0e10cSrcweir# Creating the file Director.idt dynamically 556cdf0e10cSrcweir############################################### 557cdf0e10cSrcweir 558cdf0e10cSrcweirsub create_directory_table 559cdf0e10cSrcweir{ 560cdf0e10cSrcweir my ($directoryref, $basedir, $allvariableshashref, $shortdirnamehashref, $loggingdir) = @_; 561cdf0e10cSrcweir 562cdf0e10cSrcweir # Structure of the directory table: 563cdf0e10cSrcweir # Directory Directory_Parent DefaultDir 564cdf0e10cSrcweir # Directory is a unique identifier 565cdf0e10cSrcweir # Directory_Parent is the unique identifier of the parent 566cdf0e10cSrcweir # DefaultDir is .:APPLIC~1|Application Data with 567cdf0e10cSrcweir # Before ":" : [sourcedir]:[destdir] (not programmed yet) 568cdf0e10cSrcweir # After ":" : 8+3 and not 8+3 the destination directory name 569cdf0e10cSrcweir 570*19d58b3aSEike Rathke installer::logger::include_timestamp_into_logfile("Performance Info: Directory Table start"); 571*19d58b3aSEike Rathke 572cdf0e10cSrcweir my @directorytable = (); 573cdf0e10cSrcweir my $infoline; 574cdf0e10cSrcweir 575cdf0e10cSrcweir overwrite_programfilesfolder($allvariableshashref); 576cdf0e10cSrcweir if ( $installer::globals::globallogging ) { installer::files::save_array_of_hashes($loggingdir . "directoriesforidt_local_1.log", $directoryref); } 577cdf0e10cSrcweir create_unique_directorynames($directoryref, $allvariableshashref); 578cdf0e10cSrcweir if ( $installer::globals::globallogging ) { installer::files::save_array_of_hashes($loggingdir . "directoriesforidt_local_1a.log", $directoryref); } 579cdf0e10cSrcweir create_defaultdir_directorynames($directoryref, $shortdirnamehashref); # only destdir! 580cdf0e10cSrcweir if ( $installer::globals::globallogging ) { installer::files::save_array_of_hashes($loggingdir . "directoriesforidt_local_2.log", $directoryref); } 581cdf0e10cSrcweir set_installlocation_directory($directoryref, $allvariableshashref); 582cdf0e10cSrcweir if ( $installer::globals::globallogging ) { installer::files::save_array_of_hashes($loggingdir . "directoriesforidt_local_3.log", $directoryref); } 583cdf0e10cSrcweir installer::windows::idtglobal::write_idt_header(\@directorytable, "directory"); 584cdf0e10cSrcweir add_root_directories(\@directorytable, $allvariableshashref); 585cdf0e10cSrcweir create_directorytable_from_collection(\@directorytable, $directoryref); 586cdf0e10cSrcweir 587cdf0e10cSrcweir # Saving the file 588cdf0e10cSrcweir 589cdf0e10cSrcweir my $directorytablename = $basedir . $installer::globals::separator . "Director.idt"; 590cdf0e10cSrcweir installer::files::save_file($directorytablename ,\@directorytable); 591cdf0e10cSrcweir $infoline = "Created idt file: $directorytablename\n"; 592cdf0e10cSrcweir push(@installer::globals::logfileinfo, $infoline); 593cdf0e10cSrcweir 594*19d58b3aSEike Rathke installer::logger::include_timestamp_into_logfile("Performance Info: Directory Table end"); 595*19d58b3aSEike Rathke 596cdf0e10cSrcweir} 597cdf0e10cSrcweir 598cdf0e10cSrcweir1; 599