1*9780544fSAndrew Rist#**************************************************************
2*9780544fSAndrew Rist#
3*9780544fSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
4*9780544fSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
5*9780544fSAndrew Rist#  distributed with this work for additional information
6*9780544fSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
7*9780544fSAndrew Rist#  to you under the Apache License, Version 2.0 (the
8*9780544fSAndrew Rist#  "License"); you may not use this file except in compliance
9*9780544fSAndrew Rist#  with the License.  You may obtain a copy of the License at
10*9780544fSAndrew Rist#
11*9780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
12*9780544fSAndrew Rist#
13*9780544fSAndrew Rist#  Unless required by applicable law or agreed to in writing,
14*9780544fSAndrew Rist#  software distributed under the License is distributed on an
15*9780544fSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9780544fSAndrew Rist#  KIND, either express or implied.  See the License for the
17*9780544fSAndrew Rist#  specific language governing permissions and limitations
18*9780544fSAndrew Rist#  under the License.
19*9780544fSAndrew Rist#
20*9780544fSAndrew Rist#**************************************************************
21*9780544fSAndrew Rist
22*9780544fSAndrew 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;
32cdf0e10cSrcweir
33cdf0e10cSrcweir##############################################################
34cdf0e10cSrcweir# Collecting all directory trees in global hash
35cdf0e10cSrcweir##############################################################
36cdf0e10cSrcweir
37cdf0e10cSrcweirsub collectdirectorytrees
38cdf0e10cSrcweir{
39cdf0e10cSrcweir	my ( $directoryref ) = @_;
40cdf0e10cSrcweir
41cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$directoryref}; $i++ )
42cdf0e10cSrcweir	{
43cdf0e10cSrcweir		my $onedir = ${$directoryref}[$i];
44cdf0e10cSrcweir		my $styles = "";
45cdf0e10cSrcweir		if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
46cdf0e10cSrcweir
47cdf0e10cSrcweir		if ( $styles ne "" )
48cdf0e10cSrcweir		{
49cdf0e10cSrcweir			foreach my $treestyle ( keys %installer::globals::treestyles )
50cdf0e10cSrcweir			{
51cdf0e10cSrcweir				if ( $styles =~ /\b$treestyle\b/ )
52cdf0e10cSrcweir				{
53cdf0e10cSrcweir					my $hostname = $onedir->{'HostName'};
54cdf0e10cSrcweir					# -> hostname is the key, the style the value!
55cdf0e10cSrcweir					$installer::globals::hostnametreestyles{$hostname} = $treestyle;
56cdf0e10cSrcweir				}
57cdf0e10cSrcweir			}
58cdf0e10cSrcweir		}
59cdf0e10cSrcweir	}
60cdf0e10cSrcweir}
61cdf0e10cSrcweir
62cdf0e10cSrcweir##############################################################
63cdf0e10cSrcweir# Overwriting global programfilesfolder, if required
64cdf0e10cSrcweir##############################################################
65cdf0e10cSrcweir
66cdf0e10cSrcweirsub overwrite_programfilesfolder
67cdf0e10cSrcweir{
68cdf0e10cSrcweir	my ( $allvariables ) = @_;
69cdf0e10cSrcweir
70cdf0e10cSrcweir	if ( $allvariables->{'PROGRAMFILESFOLDERNAME'} )
71cdf0e10cSrcweir	{
72cdf0e10cSrcweir		$installer::globals::programfilesfolder = $allvariables->{'PROGRAMFILESFOLDERNAME'};
73cdf0e10cSrcweir	}
74cdf0e10cSrcweir}
75cdf0e10cSrcweir
76cdf0e10cSrcweir##############################################################
77cdf0e10cSrcweir# Maximum length of directory name is 72.
78cdf0e10cSrcweir# Taking care of underlines, which are the separator.
79cdf0e10cSrcweir##############################################################
80cdf0e10cSrcweir
81cdf0e10cSrcweirsub make_short_dir_version
82cdf0e10cSrcweir{
8319d58b3aSEike Rathke	my ($longstring) = @_;
84cdf0e10cSrcweir
85cdf0e10cSrcweir	my $shortstring = "";
8619d58b3aSEike Rathke	my $cutlength = 60;
8719d58b3aSEike Rathke	my $length = 5; # So the directory can still be recognized
8819d58b3aSEike Rathke	my $longstring_save = $longstring;
89cdf0e10cSrcweir
90cdf0e10cSrcweir	# Splitting the string at each "underline" and allowing only $length characters per directory name.
91cdf0e10cSrcweir	# Checking also uniqueness and length.
92cdf0e10cSrcweir
93cdf0e10cSrcweir	my $stringarray = installer::converter::convert_stringlist_into_array_without_newline(\$longstring, "_");
94cdf0e10cSrcweir
95cdf0e10cSrcweir	foreach my $onestring ( @{$stringarray} )
96cdf0e10cSrcweir	{
97cdf0e10cSrcweir		my $partstring = "";
98cdf0e10cSrcweir
99cdf0e10cSrcweir		if ( $onestring =~ /\-/ )
100cdf0e10cSrcweir		{
101cdf0e10cSrcweir			my $localstringarray = installer::converter::convert_stringlist_into_array_without_newline(\$onestring, "-");
102cdf0e10cSrcweir			foreach my $onelocalstring ( @{$localstringarray} )
103cdf0e10cSrcweir			{
104cdf0e10cSrcweir				if ( length($onelocalstring) > $length ) { $onelocalstring = substr($onelocalstring, 0, $length); }
105cdf0e10cSrcweir				$partstring = $partstring . "-" . $onelocalstring;
106cdf0e10cSrcweir			}
107cdf0e10cSrcweir			$partstring =~ s/^\s*\-//;
108cdf0e10cSrcweir		}
109cdf0e10cSrcweir		else
110cdf0e10cSrcweir		{
111cdf0e10cSrcweir			if ( length($onestring) > $length ) { $partstring = substr($onestring, 0, $length); }
112cdf0e10cSrcweir			else { $partstring = $onestring; }
113cdf0e10cSrcweir		}
114cdf0e10cSrcweir
115cdf0e10cSrcweir		$shortstring = $shortstring . "_" . $partstring;
116cdf0e10cSrcweir	}
117cdf0e10cSrcweir
118cdf0e10cSrcweir	$shortstring =~ s/^\s*\_//;
119cdf0e10cSrcweir
12019d58b3aSEike Rathke	# Setting unique ID to each directory
12119d58b3aSEike Rathke	# No counter allowed, process must be absolute reproducable due to patch creation process.
12219d58b3aSEike Rathke
12319d58b3aSEike Rathke	# chomp(my $id = `echo $longstring_save | md5sum | sed -e "s/ .*//g"`);  # Very, very slow
12419d58b3aSEike Rathke	# my $subid = substr($id, 0, 9); # taking only the first 9 digits
12519d58b3aSEike Rathke
12619d58b3aSEike Rathke	my $subid = installer::windows::msiglobal::calculate_id($longstring_save, 9); # taking only the first 9 digits
12719d58b3aSEike Rathke
12819d58b3aSEike Rathke	if ( length($shortstring) > $cutlength ) { $shortstring = substr($shortstring, 0, $cutlength); }
12919d58b3aSEike Rathke
13019d58b3aSEike Rathke	$shortstring = $shortstring . "_" . $subid;
131cdf0e10cSrcweir
132cdf0e10cSrcweir	return $shortstring;
133cdf0e10cSrcweir}
134cdf0e10cSrcweir
135cdf0e10cSrcweir##############################################################
136cdf0e10cSrcweir# Adding unique directory names to the directory collection
137cdf0e10cSrcweir##############################################################
138cdf0e10cSrcweir
139cdf0e10cSrcweirsub create_unique_directorynames
140cdf0e10cSrcweir{
141cdf0e10cSrcweir	my ($directoryref, $allvariables) = @_;
142cdf0e10cSrcweir
143cdf0e10cSrcweir	$installer::globals::officeinstalldirectoryset = 0;
14419d58b3aSEike Rathke
14519d58b3aSEike Rathke	my %completedirhashstep1 = ();
14619d58b3aSEike Rathke	my %shortdirhash = ();
14719d58b3aSEike Rathke	my %shortdirhashreverse = ();
148cdf0e10cSrcweir	my $infoline = "";
149cdf0e10cSrcweir	my $errorcount = 0;
150cdf0e10cSrcweir
151cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$directoryref}; $i++ )
152cdf0e10cSrcweir	{
153cdf0e10cSrcweir		my $onedir = ${$directoryref}[$i];
15419d58b3aSEike Rathke		my $uniquename = $onedir->{'HostName'};
155cdf0e10cSrcweir
156cdf0e10cSrcweir		my $styles = "";
157cdf0e10cSrcweir		if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
158cdf0e10cSrcweir
159cdf0e10cSrcweir		$uniquename =~ s/^\s*//g;				# removing beginning white spaces
160cdf0e10cSrcweir		$uniquename =~ s/\s*$//g;				# removing ending white spaces
161cdf0e10cSrcweir		$uniquename =~ s/\s//g;					# removing white spaces
162cdf0e10cSrcweir		$uniquename =~ s/\_//g;					# removing existing underlines
163cdf0e10cSrcweir		$uniquename =~ s/\.//g;					# removing dots in directoryname
164cdf0e10cSrcweir		$uniquename =~ s/OpenOffice/OO/g;
16519d58b3aSEike Rathke
16619d58b3aSEike Rathke		$uniquename =~ s/\Q$installer::globals::separator\E/\_/g;	# replacing slash and backslash with underline
16719d58b3aSEike Rathke
168cdf0e10cSrcweir		$uniquename =~ s/_registry/_rgy/g;
169cdf0e10cSrcweir		$uniquename =~ s/_registration/_rgn/g;
170cdf0e10cSrcweir		$uniquename =~ s/_extension/_ext/g;
171cdf0e10cSrcweir		$uniquename =~ s/_frame/_frm/g;
172cdf0e10cSrcweir		$uniquename =~ s/_table/_tbl/g;
173cdf0e10cSrcweir		$uniquename =~ s/_chart/_crt/g;
174cdf0e10cSrcweir
17519d58b3aSEike Rathke		# The names after this small changes must still be unique!
17619d58b3aSEike 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"); }
17719d58b3aSEike Rathke		$completedirhashstep1{$uniquename} = 1;
178cdf0e10cSrcweir
17919d58b3aSEike Rathke		# Starting to make unique name for the parent and its directory
18019d58b3aSEike Rathke		my $originaluniquename = $uniquename;
18119d58b3aSEike Rathke
18219d58b3aSEike Rathke		$uniquename = make_short_dir_version($uniquename);
18319d58b3aSEike Rathke
18419d58b3aSEike Rathke		# Checking if the same directory already exists, but has another short version.
18519d58b3aSEike 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"); }
18619d58b3aSEike Rathke
18719d58b3aSEike Rathke		# Also checking vice versa
18819d58b3aSEike Rathke		# Checking if the same short directory already exists, but has another long version.
18919d58b3aSEike 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"); }
190cdf0e10cSrcweir
19119d58b3aSEike Rathke		# Creating assignment from long to short directory names
19219d58b3aSEike Rathke		$shortdirhash{$originaluniquename} = $uniquename;
19319d58b3aSEike Rathke		$shortdirhashreverse{$uniquename} = $originaluniquename;
194cdf0e10cSrcweir
19519d58b3aSEike Rathke		# Important: The unique parent is generated from the string $originaluniquename (with the use of underlines).
196cdf0e10cSrcweir
19719d58b3aSEike Rathke		my $uniqueparentname = $originaluniquename;
19819d58b3aSEike Rathke		my $keepparent = 1;
199cdf0e10cSrcweir
200cdf0e10cSrcweir		if ( $uniqueparentname =~ /^\s*(.*)\_(.*?)\s*$/ )	# the underline is now the separator
201cdf0e10cSrcweir		{
202cdf0e10cSrcweir			$uniqueparentname = $1;
20319d58b3aSEike Rathke			$keepparent = 0;
204cdf0e10cSrcweir		}
205cdf0e10cSrcweir		else
206cdf0e10cSrcweir		{
207cdf0e10cSrcweir			$uniqueparentname = $installer::globals::programfilesfolder;
20819d58b3aSEike Rathke			$keepparent = 1;
209cdf0e10cSrcweir		}
210cdf0e10cSrcweir
21119d58b3aSEike Rathke		if ( $styles =~ /\bPROGRAMFILESFOLDER\b/ )
21219d58b3aSEike Rathke		{
21319d58b3aSEike Rathke			$uniqueparentname = $installer::globals::programfilesfolder;
21419d58b3aSEike Rathke			$keepparent = 1;
21519d58b3aSEike Rathke		}
21619d58b3aSEike Rathke		if ( $styles =~ /\bCOMMONFILESFOLDER\b/ )
21719d58b3aSEike Rathke		{
21819d58b3aSEike Rathke			$uniqueparentname = $installer::globals::commonfilesfolder;
21919d58b3aSEike Rathke			$keepparent = 1;
22019d58b3aSEike Rathke		}
22119d58b3aSEike Rathke		if ( $styles =~ /\bCOMMONAPPDATAFOLDER\b/ )
22219d58b3aSEike Rathke		{
22319d58b3aSEike Rathke			$uniqueparentname = $installer::globals::commonappdatafolder;
22419d58b3aSEike Rathke			$keepparent = 1;
22519d58b3aSEike Rathke		}
22619d58b3aSEike Rathke		if ( $styles =~ /\bLOCALAPPDATAFOLDER\b/ )
22719d58b3aSEike Rathke		{
22819d58b3aSEike Rathke			$uniqueparentname = $installer::globals::localappdatafolder;
22919d58b3aSEike Rathke			$keepparent = 1;
23019d58b3aSEike Rathke		}
231cdf0e10cSrcweir
232cdf0e10cSrcweir		if ( $styles =~ /\bSHAREPOINTPATH\b/ )
233cdf0e10cSrcweir		{
234cdf0e10cSrcweir			$uniqueparentname = "SHAREPOINTPATH";
235cdf0e10cSrcweir			$installer::globals::usesharepointpath = 1;
23619d58b3aSEike Rathke			$keepparent = 1;
237cdf0e10cSrcweir		}
238cdf0e10cSrcweir
23919d58b3aSEike Rathke		# also setting short directory name for the parent
24019d58b3aSEike Rathke
24119d58b3aSEike Rathke		my $originaluniqueparentname = $uniqueparentname;
24219d58b3aSEike Rathke
24319d58b3aSEike Rathke		if ( ! $keepparent )
24419d58b3aSEike Rathke		{
24519d58b3aSEike Rathke			$uniqueparentname = make_short_dir_version($uniqueparentname);
24619d58b3aSEike Rathke		}
24719d58b3aSEike Rathke
24819d58b3aSEike Rathke		# Again checking if the same directory already exists, but has another short version.
24919d58b3aSEike 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"); }
25019d58b3aSEike Rathke
25119d58b3aSEike Rathke		# Also checking vice versa
25219d58b3aSEike Rathke		# Checking if the same short directory already exists, but has another long version.
25319d58b3aSEike 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"); }
25419d58b3aSEike Rathke
25519d58b3aSEike Rathke		$shortdirhash{$originaluniqueparentname} = $uniqueparentname;
25619d58b3aSEike Rathke		$shortdirhashreverse{$uniqueparentname} = $originaluniqueparentname;
25719d58b3aSEike Rathke
25819d58b3aSEike Rathke		# Hyphen not allowed in database
259cdf0e10cSrcweir		$uniquename =~ s/\-/\_/g;			# making "-" to "_"
260cdf0e10cSrcweir		$uniqueparentname =~ s/\-/\_/g;		# making "-" to "_"
261cdf0e10cSrcweir
26219d58b3aSEike Rathke		# And finally setting the values for the directories
263cdf0e10cSrcweir		$onedir->{'uniquename'} = $uniquename;
264cdf0e10cSrcweir		$onedir->{'uniqueparentname'} = $uniqueparentname;
265cdf0e10cSrcweir
266cdf0e10cSrcweir		# setting the installlocation directory
267cdf0e10cSrcweir		if ( $styles =~ /\bISINSTALLLOCATION\b/ )
268cdf0e10cSrcweir		{
269cdf0e10cSrcweir			if ( $installer::globals::installlocationdirectoryset ) { installer::exiter::exit_program("ERROR: Directory with flag ISINSTALLLOCATION alread set: \"$installer::globals::installlocationdirectory\".", "create_unique_directorynames"); }
270cdf0e10cSrcweir			$installer::globals::installlocationdirectory = $uniquename;
271cdf0e10cSrcweir			$installer::globals::installlocationdirectoryset = 1;
272cdf0e10cSrcweir			if ( $installer::globals::installlocationdirectory =~ /oracle_/i ) { $installer::globals::sundirexists = 1; }
273cdf0e10cSrcweir		}
274cdf0e10cSrcweir
275cdf0e10cSrcweir		# setting the sundirectory
276cdf0e10cSrcweir		if ( $styles =~ /\bSUNDIRECTORY\b/ )
277cdf0e10cSrcweir		{
278cdf0e10cSrcweir			if ( $installer::globals::vendordirectoryset ) { installer::exiter::exit_program("ERROR: Directory with flag SUNDIRECTORY alread set: \"$installer::globals::vendordirectory\".", "create_unique_directorynames"); }
279cdf0e10cSrcweir			$installer::globals::vendordirectory = $uniquename;
280cdf0e10cSrcweir			$installer::globals::vendordirectoryset = 1;
281cdf0e10cSrcweir		}
28219d58b3aSEike Rathke	}
283cdf0e10cSrcweir}
284cdf0e10cSrcweir
285cdf0e10cSrcweir#####################################################
286cdf0e10cSrcweir# Adding ":." to selected default directory names
287cdf0e10cSrcweir#####################################################
288cdf0e10cSrcweir
289cdf0e10cSrcweirsub check_sourcedir_addon
290cdf0e10cSrcweir{
291cdf0e10cSrcweir	my ( $onedir, $allvariableshashref ) = @_;
292cdf0e10cSrcweir
293cdf0e10cSrcweir	if (($installer::globals::addchildprojects) ||
294cdf0e10cSrcweir		($installer::globals::patch) ||
295cdf0e10cSrcweir		($installer::globals::languagepack) ||
296cdf0e10cSrcweir		($allvariableshashref->{'CHANGETARGETDIR'}))
297cdf0e10cSrcweir	{
298cdf0e10cSrcweir		my $sourcediraddon = "\:\.";
299cdf0e10cSrcweir		$onedir->{'defaultdir'} = $onedir->{'defaultdir'} . $sourcediraddon;
300cdf0e10cSrcweir	}
301cdf0e10cSrcweir
302cdf0e10cSrcweir}
303cdf0e10cSrcweir
304cdf0e10cSrcweir#####################################################
305cdf0e10cSrcweir# The directory with the style ISINSTALLLOCATION
306cdf0e10cSrcweir# will be replaced by INSTALLLOCATION
307cdf0e10cSrcweir#####################################################
308cdf0e10cSrcweir
309cdf0e10cSrcweirsub set_installlocation_directory
310cdf0e10cSrcweir{
311cdf0e10cSrcweir	my ( $directoryref, $allvariableshashref ) = @_;
312cdf0e10cSrcweir
313cdf0e10cSrcweir	if ( ! $installer::globals::installlocationdirectoryset ) { installer::exiter::exit_program("ERROR: Directory with flag ISINSTALLLOCATION not set!", "set_installlocation_directory"); }
314cdf0e10cSrcweir
315cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$directoryref}; $i++ )
316cdf0e10cSrcweir	{
317cdf0e10cSrcweir		my $onedir = ${$directoryref}[$i];
318cdf0e10cSrcweir
319cdf0e10cSrcweir		if ( $onedir->{'uniquename'} eq $installer::globals::installlocationdirectory )
320cdf0e10cSrcweir		{
321cdf0e10cSrcweir			$onedir->{'uniquename'} = "INSTALLLOCATION";
322cdf0e10cSrcweir			check_sourcedir_addon($onedir, $allvariableshashref);
323cdf0e10cSrcweir		}
324cdf0e10cSrcweir
325cdf0e10cSrcweir		if ( $onedir->{'uniquename'} eq $installer::globals::vendordirectory )
326cdf0e10cSrcweir		{
327cdf0e10cSrcweir			check_sourcedir_addon($onedir, $allvariableshashref);
328cdf0e10cSrcweir		}
329cdf0e10cSrcweir
330cdf0e10cSrcweir		if ( $onedir->{'uniqueparentname'} eq $installer::globals::installlocationdirectory )
331cdf0e10cSrcweir		{
332cdf0e10cSrcweir			$onedir->{'uniqueparentname'} = "INSTALLLOCATION";
333cdf0e10cSrcweir		}
334cdf0e10cSrcweir	}
335cdf0e10cSrcweir}
336cdf0e10cSrcweir
337cdf0e10cSrcweir#####################################################
338cdf0e10cSrcweir# Getting the name of the top level directory. This
339cdf0e10cSrcweir# can have only one letter
340cdf0e10cSrcweir#####################################################
341cdf0e10cSrcweir
342cdf0e10cSrcweirsub get_last_directory_name
343cdf0e10cSrcweir{
344cdf0e10cSrcweir	my ($completepathref) = @_;
345cdf0e10cSrcweir
346cdf0e10cSrcweir	if ( $$completepathref =~ /^.*[\/\\](.+?)\s*$/ )
347cdf0e10cSrcweir	{
348cdf0e10cSrcweir		$$completepathref = $1;
349cdf0e10cSrcweir	}
350cdf0e10cSrcweir}
351cdf0e10cSrcweir
352cdf0e10cSrcweir#####################################################
353cdf0e10cSrcweir# Creating the defaultdir for the file Director.idt
354cdf0e10cSrcweir#####################################################
355cdf0e10cSrcweir
356cdf0e10cSrcweirsub create_defaultdir_directorynames
357cdf0e10cSrcweir{
358cdf0e10cSrcweir	my ($directoryref, $shortdirnamehashref) = @_;
359cdf0e10cSrcweir
360cdf0e10cSrcweir	my @shortnames = ();
361cdf0e10cSrcweir	if ( $installer::globals::updatedatabase ) { @shortnames = values(%{$shortdirnamehashref}); }
362cdf0e10cSrcweir	elsif ( $installer::globals::prepare_winpatch ) { @shortnames = values(%installer::globals::saved83dirmapping); }
363cdf0e10cSrcweir
364cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$directoryref}; $i++ )
365cdf0e10cSrcweir	{
366cdf0e10cSrcweir		my $onedir = ${$directoryref}[$i];
367cdf0e10cSrcweir		my $hostname = $onedir->{'HostName'};
368cdf0e10cSrcweir
369cdf0e10cSrcweir		$hostname =~ s/\Q$installer::globals::separator\E\s*$//;
370cdf0e10cSrcweir		get_last_directory_name(\$hostname);
371cdf0e10cSrcweir		# installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$hostname);	# making program/classes to classes
372cdf0e10cSrcweir		my $uniquename = $onedir->{'uniquename'};
373cdf0e10cSrcweir		my $shortstring;
374cdf0e10cSrcweir		if (( $installer::globals::updatedatabase ) && ( exists($shortdirnamehashref->{$uniquename}) ))
375cdf0e10cSrcweir		{
376cdf0e10cSrcweir			$shortstring = $shortdirnamehashref->{$uniquename};
377cdf0e10cSrcweir		}
378cdf0e10cSrcweir		elsif (( $installer::globals::prepare_winpatch ) && ( exists($installer::globals::saved83dirmapping{$uniquename}) ))
379cdf0e10cSrcweir		{
380cdf0e10cSrcweir			$shortstring = $installer::globals::saved83dirmapping{$uniquename};
381cdf0e10cSrcweir		}
382cdf0e10cSrcweir		else
383cdf0e10cSrcweir		{
384cdf0e10cSrcweir			$shortstring = installer::windows::idtglobal::make_eight_three_conform($hostname, "dir", \@shortnames);
385cdf0e10cSrcweir		}
386cdf0e10cSrcweir
387cdf0e10cSrcweir		my $defaultdir;
388cdf0e10cSrcweir
389cdf0e10cSrcweir		if ( $shortstring eq $hostname )
390cdf0e10cSrcweir		{
391cdf0e10cSrcweir			$defaultdir = $hostname;
392cdf0e10cSrcweir		}
393cdf0e10cSrcweir		else
394cdf0e10cSrcweir		{
395cdf0e10cSrcweir			$defaultdir = $shortstring . "|" . $hostname;
396cdf0e10cSrcweir		}
397cdf0e10cSrcweir
398cdf0e10cSrcweir		$onedir->{'defaultdir'} = $defaultdir;
399cdf0e10cSrcweir
400cdf0e10cSrcweir		my $fontdir = "";
401cdf0e10cSrcweir		if ( $onedir->{'Dir'} ) { $fontdir = $onedir->{'Dir'}; }
402cdf0e10cSrcweir
403cdf0e10cSrcweir		my $fontdefaultdir = "";
404cdf0e10cSrcweir		if ( $onedir->{'defaultdir'} ) { $fontdefaultdir = $onedir->{'defaultdir'}; }
405cdf0e10cSrcweir
406cdf0e10cSrcweir		if (( $fontdir eq "PREDEFINED_OSSYSTEMFONTDIR" ) && ( $fontdefaultdir eq $installer::globals::fontsdirhostname ))
407cdf0e10cSrcweir		{
408cdf0e10cSrcweir			$installer::globals::fontsdirname = $onedir->{'defaultdir'};
409cdf0e10cSrcweir			$installer::globals::fontsdirparent = $onedir->{'uniqueparentname'};
410cdf0e10cSrcweir		}
411cdf0e10cSrcweir	}
412cdf0e10cSrcweir}
413cdf0e10cSrcweir
414cdf0e10cSrcweir###############################################
415cdf0e10cSrcweir# Fill content into the directory table
416cdf0e10cSrcweir###############################################
417cdf0e10cSrcweir
418cdf0e10cSrcweirsub create_directorytable_from_collection
419cdf0e10cSrcweir{
420cdf0e10cSrcweir	my ($directorytableref, $directoryref) = @_;
421cdf0e10cSrcweir
422cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$directoryref}; $i++ )
423cdf0e10cSrcweir	{
424cdf0e10cSrcweir		my $onedir = ${$directoryref}[$i];
425cdf0e10cSrcweir		my $hostname = $onedir->{'HostName'};
426cdf0e10cSrcweir		my $dir = "";
427cdf0e10cSrcweir
428cdf0e10cSrcweir		if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; }
429cdf0e10cSrcweir
430cdf0e10cSrcweir		if (( $dir eq "PREDEFINED_PROGDIR" ) && ( $hostname eq "" )) { next; }	# removing files from root directory
431cdf0e10cSrcweir
432cdf0e10cSrcweir		my $oneline = $onedir->{'uniquename'} . "\t" . $onedir->{'uniqueparentname'} . "\t" . $onedir->{'defaultdir'} . "\n";
433cdf0e10cSrcweir
434cdf0e10cSrcweir		push(@{$directorytableref}, $oneline);
435cdf0e10cSrcweir	}
436cdf0e10cSrcweir}
437cdf0e10cSrcweir
438cdf0e10cSrcweir###############################################
439cdf0e10cSrcweir# Defining the root installation structure
440cdf0e10cSrcweir###############################################
441cdf0e10cSrcweir
442cdf0e10cSrcweirsub add_root_directories
443cdf0e10cSrcweir{
444cdf0e10cSrcweir	my ($directorytableref, $allvariableshashref) = @_;
445cdf0e10cSrcweir
446cdf0e10cSrcweir#	my $sourcediraddon = "";
447cdf0e10cSrcweir#	if (($installer::globals::addchildprojects) ||
448cdf0e10cSrcweir#		($installer::globals::patch) ||
449cdf0e10cSrcweir#		($installer::globals::languagepack) ||
450cdf0e10cSrcweir#		($allvariableshashref->{'CHANGETARGETDIR'}))
451cdf0e10cSrcweir#	{
452cdf0e10cSrcweir#		$sourcediraddon = "\:\.";
453cdf0e10cSrcweir#	}
454cdf0e10cSrcweir
455cdf0e10cSrcweir	my $oneline = "";
456cdf0e10cSrcweir
457cdf0e10cSrcweir	if (( ! $installer::globals::patch ) && ( ! $installer::globals::languagepack ) && ( ! $allvariableshashref->{'DONTUSESTARTMENUFOLDER'} ))
458cdf0e10cSrcweir	{
459cdf0e10cSrcweir		my $productname = $allvariableshashref->{'PRODUCTNAME'};
460cdf0e10cSrcweir		my $productversion = $allvariableshashref->{'PRODUCTVERSION'};
461cdf0e10cSrcweir		my $baseproductversion = $productversion;
462cdf0e10cSrcweir
463cdf0e10cSrcweir		if (( $installer::globals::prepare_winpatch ) && ( $allvariableshashref->{'BASEPRODUCTVERSION'} ))
464cdf0e10cSrcweir		{
465cdf0e10cSrcweir			$baseproductversion = $allvariableshashref->{'BASEPRODUCTVERSION'};  # for example "2.0" for OOo
466cdf0e10cSrcweir		}
467cdf0e10cSrcweir
468cdf0e10cSrcweir		my $realproductkey = $productname . " " . $productversion;
469cdf0e10cSrcweir		my $productkey = $productname . " " . $baseproductversion;
470cdf0e10cSrcweir
471cdf0e10cSrcweir		if (( $allvariableshashref->{'POSTVERSIONEXTENSION'} ) && ( ! $allvariableshashref->{'DONTUSEEXTENSIONINDEFAULTDIR'} ))
472cdf0e10cSrcweir		{
473cdf0e10cSrcweir			$productkey = $productkey . " " . $allvariableshashref->{'POSTVERSIONEXTENSION'};
474cdf0e10cSrcweir			$realproductkey = $realproductkey . " " . $allvariableshashref->{'POSTVERSIONEXTENSION'};
475cdf0e10cSrcweir		}
476cdf0e10cSrcweir		if ( $allvariableshashref->{'NOVERSIONINDIRNAME'} )
477cdf0e10cSrcweir		{
478cdf0e10cSrcweir			$productkey = $productname;
479cdf0e10cSrcweir			$realproductkey = $realproductname;
480cdf0e10cSrcweir		}
481cdf0e10cSrcweir		if ( $allvariableshashref->{'NOSPACEINDIRECTORYNAME'} )
482cdf0e10cSrcweir		{
483cdf0e10cSrcweir			$productkey =~ s/\ /\_/g;
484cdf0e10cSrcweir			$realproductkey =~ s/\ /\_/g;
485cdf0e10cSrcweir		}
486cdf0e10cSrcweir
487cdf0e10cSrcweir		my $shortproductkey = installer::windows::idtglobal::make_eight_three_conform($productkey, "dir");		# third parameter not used
488cdf0e10cSrcweir		$shortproductkey =~ s/\s/\_/g;									# changing empty space to underline
489cdf0e10cSrcweir
490cdf0e10cSrcweir		$oneline = "$installer::globals::officemenufolder\t$installer::globals::programmenufolder\t$shortproductkey|$realproductkey\n";
491cdf0e10cSrcweir		push(@{$directorytableref}, $oneline);
492cdf0e10cSrcweir	}
493cdf0e10cSrcweir
494cdf0e10cSrcweir	$oneline = "TARGETDIR\t\tSourceDir\n";
495cdf0e10cSrcweir	push(@{$directorytableref}, $oneline);
496cdf0e10cSrcweir
497cdf0e10cSrcweir	$oneline = "$installer::globals::programfilesfolder\tTARGETDIR\t.\n";
498cdf0e10cSrcweir	push(@{$directorytableref}, $oneline);
499cdf0e10cSrcweir
500cdf0e10cSrcweir	$oneline = "$installer::globals::programmenufolder\tTARGETDIR\t.\n";
501cdf0e10cSrcweir	push(@{$directorytableref}, $oneline);
502cdf0e10cSrcweir
503cdf0e10cSrcweir	$oneline = "$installer::globals::startupfolder\tTARGETDIR\t.\n";
504cdf0e10cSrcweir	push(@{$directorytableref}, $oneline);
505cdf0e10cSrcweir
506cdf0e10cSrcweir	$oneline = "$installer::globals::desktopfolder\tTARGETDIR\t.\n";
507cdf0e10cSrcweir	push(@{$directorytableref}, $oneline);
508cdf0e10cSrcweir
509cdf0e10cSrcweir	$oneline = "$installer::globals::startmenufolder\tTARGETDIR\t.\n";
510cdf0e10cSrcweir	push(@{$directorytableref}, $oneline);
511cdf0e10cSrcweir
512cdf0e10cSrcweir	$oneline = "$installer::globals::commonfilesfolder\tTARGETDIR\t.\n";
513cdf0e10cSrcweir	push(@{$directorytableref}, $oneline);
514cdf0e10cSrcweir
515cdf0e10cSrcweir	$oneline = "$installer::globals::commonappdatafolder\tTARGETDIR\t.\n";
516cdf0e10cSrcweir	push(@{$directorytableref}, $oneline);
517cdf0e10cSrcweir
518cdf0e10cSrcweir	$oneline = "$installer::globals::localappdatafolder\tTARGETDIR\t.\n";
519cdf0e10cSrcweir	push(@{$directorytableref}, $oneline);
520cdf0e10cSrcweir
521cdf0e10cSrcweir	if ( $installer::globals::usesharepointpath )
522cdf0e10cSrcweir	{
523cdf0e10cSrcweir		$oneline = "SHAREPOINTPATH\tTARGETDIR\t.\n";
524cdf0e10cSrcweir		push(@{$directorytableref}, $oneline);
525cdf0e10cSrcweir	}
526cdf0e10cSrcweir
527cdf0e10cSrcweir	$oneline = "$installer::globals::systemfolder\tTARGETDIR\t.\n";
528cdf0e10cSrcweir	push(@{$directorytableref}, $oneline);
529cdf0e10cSrcweir
530cdf0e10cSrcweir	my $localtemplatefoldername = $installer::globals::templatefoldername;
531cdf0e10cSrcweir	my $directorytableentry = $localtemplatefoldername;
532cdf0e10cSrcweir	my $shorttemplatefoldername = installer::windows::idtglobal::make_eight_three_conform($localtemplatefoldername, "dir");
533cdf0e10cSrcweir	if ( $shorttemplatefoldername ne $localtemplatefoldername ) { $directorytableentry = "$shorttemplatefoldername|$localtemplatefoldername"; }
534cdf0e10cSrcweir	$oneline = "$installer::globals::templatefolder\tTARGETDIR\t$directorytableentry\n";
535cdf0e10cSrcweir	push(@{$directorytableref}, $oneline);
536cdf0e10cSrcweir
537cdf0e10cSrcweir	if ( $installer::globals::fontsdirname )
538cdf0e10cSrcweir	{
539cdf0e10cSrcweir		$oneline = "$installer::globals::fontsfolder\t$installer::globals::fontsdirparent\t$installer::globals::fontsfoldername\:$installer::globals::fontsdirname\n";
540cdf0e10cSrcweir	}
541cdf0e10cSrcweir	else
542cdf0e10cSrcweir	{
543cdf0e10cSrcweir		$oneline = "$installer::globals::fontsfolder\tTARGETDIR\t$installer::globals::fontsfoldername\n";
544cdf0e10cSrcweir	}
545cdf0e10cSrcweir
546cdf0e10cSrcweir	push(@{$directorytableref}, $oneline);
547cdf0e10cSrcweir
548cdf0e10cSrcweir}
549cdf0e10cSrcweir
550cdf0e10cSrcweir###############################################
551cdf0e10cSrcweir# Creating the file Director.idt dynamically
552cdf0e10cSrcweir###############################################
553cdf0e10cSrcweir
554cdf0e10cSrcweirsub create_directory_table
555cdf0e10cSrcweir{
556cdf0e10cSrcweir	my ($directoryref, $basedir, $allvariableshashref, $shortdirnamehashref, $loggingdir) = @_;
557cdf0e10cSrcweir
558cdf0e10cSrcweir	# Structure of the directory table:
559cdf0e10cSrcweir	# Directory Directory_Parent DefaultDir
560cdf0e10cSrcweir	# Directory is a unique identifier
561cdf0e10cSrcweir	# Directory_Parent is the unique identifier of the parent
562cdf0e10cSrcweir	# DefaultDir is .:APPLIC~1|Application Data with
563cdf0e10cSrcweir	# Before ":" : [sourcedir]:[destdir] (not programmed yet)
564cdf0e10cSrcweir	# After ":" : 8+3 and not 8+3 the destination directory name
56519d58b3aSEike Rathke
56619d58b3aSEike Rathke	installer::logger::include_timestamp_into_logfile("Performance Info: Directory Table start");
567cdf0e10cSrcweir
568cdf0e10cSrcweir	my @directorytable = ();
569cdf0e10cSrcweir	my $infoline;
570cdf0e10cSrcweir
571cdf0e10cSrcweir	overwrite_programfilesfolder($allvariableshashref);
572cdf0e10cSrcweir	if ( $installer::globals::globallogging ) { installer::files::save_array_of_hashes($loggingdir . "directoriesforidt_local_1.log", $directoryref); }
573cdf0e10cSrcweir	create_unique_directorynames($directoryref, $allvariableshashref);
574cdf0e10cSrcweir	if ( $installer::globals::globallogging ) { installer::files::save_array_of_hashes($loggingdir . "directoriesforidt_local_1a.log", $directoryref); }
575cdf0e10cSrcweir	create_defaultdir_directorynames($directoryref, $shortdirnamehashref);	# only destdir!
576cdf0e10cSrcweir	if ( $installer::globals::globallogging ) { installer::files::save_array_of_hashes($loggingdir . "directoriesforidt_local_2.log", $directoryref); }
577cdf0e10cSrcweir	set_installlocation_directory($directoryref, $allvariableshashref);
578cdf0e10cSrcweir	if ( $installer::globals::globallogging ) { installer::files::save_array_of_hashes($loggingdir . "directoriesforidt_local_3.log", $directoryref); }
579cdf0e10cSrcweir	installer::windows::idtglobal::write_idt_header(\@directorytable, "directory");
580cdf0e10cSrcweir	add_root_directories(\@directorytable, $allvariableshashref);
581cdf0e10cSrcweir	create_directorytable_from_collection(\@directorytable, $directoryref);
582cdf0e10cSrcweir
583cdf0e10cSrcweir	# Saving the file
584cdf0e10cSrcweir
585cdf0e10cSrcweir	my $directorytablename = $basedir . $installer::globals::separator . "Director.idt";
586cdf0e10cSrcweir	installer::files::save_file($directorytablename ,\@directorytable);
587cdf0e10cSrcweir	$infoline = "Created idt file: $directorytablename\n";
588cdf0e10cSrcweir	push(@installer::globals::logfileinfo, $infoline);
589cdf0e10cSrcweir
59019d58b3aSEike Rathke	installer::logger::include_timestamp_into_logfile("Performance Info: Directory Table end");
59119d58b3aSEike Rathke
592cdf0e10cSrcweir}
593cdf0e10cSrcweir
594cdf0e10cSrcweir1;
595