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