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::file;
29*cdf0e10cSrcweir
30*cdf0e10cSrcweiruse Digest::MD5;
31*cdf0e10cSrcweiruse installer::existence;
32*cdf0e10cSrcweiruse installer::exiter;
33*cdf0e10cSrcweiruse installer::files;
34*cdf0e10cSrcweiruse installer::globals;
35*cdf0e10cSrcweiruse installer::logger;
36*cdf0e10cSrcweiruse installer::pathanalyzer;
37*cdf0e10cSrcweiruse installer::worker;
38*cdf0e10cSrcweiruse installer::windows::font;
39*cdf0e10cSrcweiruse installer::windows::idtglobal;
40*cdf0e10cSrcweiruse installer::windows::language;
41*cdf0e10cSrcweir
42*cdf0e10cSrcweir##########################################################################
43*cdf0e10cSrcweir# Assigning one cabinet file to each file. This is requrired,
44*cdf0e10cSrcweir# if cabinet files shall be equivalent to packages.
45*cdf0e10cSrcweir##########################################################################
46*cdf0e10cSrcweir
47*cdf0e10cSrcweirsub assign_cab_to_files
48*cdf0e10cSrcweir{
49*cdf0e10cSrcweir	my ( $filesref ) = @_;
50*cdf0e10cSrcweir
51*cdf0e10cSrcweir	my $infoline = "";
52*cdf0e10cSrcweir
53*cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesref}; $i++ )
54*cdf0e10cSrcweir	{
55*cdf0e10cSrcweir		if ( ! exists(${$filesref}[$i]->{'modules'}) ) { installer::exiter::exit_program("ERROR: No module assignment found for ${$filesref}[$i]->{'gid'} !", "assign_cab_to_files"); }
56*cdf0e10cSrcweir		my $module = ${$filesref}[$i]->{'modules'};
57*cdf0e10cSrcweir		# If modules contains a list of modules, only taking the first one.
58*cdf0e10cSrcweir		if ( $module =~ /^\s*(.*?)\,/ ) { $module = $1; }
59*cdf0e10cSrcweir
60*cdf0e10cSrcweir		if ( ! exists($installer::globals::allcabinetassigns{$module}) ) { installer::exiter::exit_program("ERROR: No cabinet file assigned to module \"$module\" (${$filesref}[$i]->{'gid'}) !", "assign_cab_to_files"); }
61*cdf0e10cSrcweir		${$filesref}[$i]->{'assignedcabinetfile'} = $installer::globals::allcabinetassigns{$module};
62*cdf0e10cSrcweir
63*cdf0e10cSrcweir		# Counting the files in each cabinet file
64*cdf0e10cSrcweir		if ( ! exists($installer::globals::cabfilecounter{${$filesref}[$i]->{'assignedcabinetfile'}}) )
65*cdf0e10cSrcweir		{
66*cdf0e10cSrcweir			$installer::globals::cabfilecounter{${$filesref}[$i]->{'assignedcabinetfile'}} = 1;
67*cdf0e10cSrcweir		}
68*cdf0e10cSrcweir		else
69*cdf0e10cSrcweir		{
70*cdf0e10cSrcweir			$installer::globals::cabfilecounter{${$filesref}[$i]->{'assignedcabinetfile'}}++;
71*cdf0e10cSrcweir		}
72*cdf0e10cSrcweir	}
73*cdf0e10cSrcweir
74*cdf0e10cSrcweir	# logging the number of files in each cabinet file
75*cdf0e10cSrcweir
76*cdf0e10cSrcweir	$infoline = "\nCabinet file content:\n";
77*cdf0e10cSrcweir	push(@installer::globals::logfileinfo, $infoline);
78*cdf0e10cSrcweir	my $cabfile;
79*cdf0e10cSrcweir	foreach $cabfile ( sort keys %installer::globals::cabfilecounter )
80*cdf0e10cSrcweir	{
81*cdf0e10cSrcweir		$infoline = "$cabfile : $installer::globals::cabfilecounter{$cabfile} files\n";
82*cdf0e10cSrcweir		push(@installer::globals::logfileinfo, $infoline);
83*cdf0e10cSrcweir	}
84*cdf0e10cSrcweir
85*cdf0e10cSrcweir	# assigning startsequencenumbers for each cab file
86*cdf0e10cSrcweir
87*cdf0e10cSrcweir	my $offset = 1;
88*cdf0e10cSrcweir	foreach $cabfile ( sort keys %installer::globals::cabfilecounter )
89*cdf0e10cSrcweir	{
90*cdf0e10cSrcweir		my $filecount = $installer::globals::cabfilecounter{$cabfile};
91*cdf0e10cSrcweir		$installer::globals::cabfilecounter{$cabfile} = $offset;
92*cdf0e10cSrcweir		$offset = $offset + $filecount;
93*cdf0e10cSrcweir
94*cdf0e10cSrcweir		$installer::globals::lastsequence{$cabfile} = $offset - 1;
95*cdf0e10cSrcweir	}
96*cdf0e10cSrcweir
97*cdf0e10cSrcweir	# logging the start sequence numbers
98*cdf0e10cSrcweir
99*cdf0e10cSrcweir	$infoline = "\nCabinet file start sequences:\n";
100*cdf0e10cSrcweir	push(@installer::globals::logfileinfo, $infoline);
101*cdf0e10cSrcweir	foreach $cabfile ( sort keys %installer::globals::cabfilecounter )
102*cdf0e10cSrcweir	{
103*cdf0e10cSrcweir		$infoline = "$cabfile : $installer::globals::cabfilecounter{$cabfile}\n";
104*cdf0e10cSrcweir		push(@installer::globals::logfileinfo, $infoline);
105*cdf0e10cSrcweir	}
106*cdf0e10cSrcweir
107*cdf0e10cSrcweir	# logging the last sequence numbers
108*cdf0e10cSrcweir
109*cdf0e10cSrcweir	$infoline = "\nCabinet file last sequences:\n";
110*cdf0e10cSrcweir	push(@installer::globals::logfileinfo, $infoline);
111*cdf0e10cSrcweir	foreach $cabfile ( sort keys %installer::globals::lastsequence )
112*cdf0e10cSrcweir	{
113*cdf0e10cSrcweir		$infoline = "$cabfile : $installer::globals::lastsequence{$cabfile}\n";
114*cdf0e10cSrcweir		push(@installer::globals::logfileinfo, $infoline);
115*cdf0e10cSrcweir	}
116*cdf0e10cSrcweir}
117*cdf0e10cSrcweir
118*cdf0e10cSrcweir##########################################################################
119*cdf0e10cSrcweir# Assigning sequencenumbers to files. This is requrired,
120*cdf0e10cSrcweir# if cabinet files shall be equivalent to packages.
121*cdf0e10cSrcweir##########################################################################
122*cdf0e10cSrcweir
123*cdf0e10cSrcweirsub assign_sequencenumbers_to_files
124*cdf0e10cSrcweir{
125*cdf0e10cSrcweir	my ( $filesref ) = @_;
126*cdf0e10cSrcweir
127*cdf0e10cSrcweir	my %directaccess = ();
128*cdf0e10cSrcweir	my %allassigns = ();
129*cdf0e10cSrcweir
130*cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesref}; $i++ )
131*cdf0e10cSrcweir	{
132*cdf0e10cSrcweir		my $onefile = ${$filesref}[$i];
133*cdf0e10cSrcweir
134*cdf0e10cSrcweir		# Keeping order in cabinet files
135*cdf0e10cSrcweir		# -> collecting all files in one cabinet file
136*cdf0e10cSrcweir		# -> sorting files and assigning numbers
137*cdf0e10cSrcweir
138*cdf0e10cSrcweir		# Saving counter $i for direct access into files array
139*cdf0e10cSrcweir		# "destination" of the file is a unique identifier ('Name' is not unique!)
140*cdf0e10cSrcweir		if ( exists($directaccess{$onefile->{'destination'}}) ) { installer::exiter::exit_program("ERROR: 'destination' at file not unique: $onefile->{'destination'}", "assign_sequencenumbers_to_files"); }
141*cdf0e10cSrcweir		$directaccess{$onefile->{'destination'}} = $i;
142*cdf0e10cSrcweir
143*cdf0e10cSrcweir		my $cabfilename = $onefile->{'assignedcabinetfile'};
144*cdf0e10cSrcweir		# collecting files in cabinet files
145*cdf0e10cSrcweir		if ( ! exists($allassigns{$cabfilename}) )
146*cdf0e10cSrcweir		{
147*cdf0e10cSrcweir			my %onecabfile = ();
148*cdf0e10cSrcweir			$onecabfile{$onefile->{'destination'}} = 1;
149*cdf0e10cSrcweir			$allassigns{$cabfilename} = \%onecabfile;
150*cdf0e10cSrcweir		}
151*cdf0e10cSrcweir		else
152*cdf0e10cSrcweir		{
153*cdf0e10cSrcweir			$allassigns{$cabfilename}->{$onefile->{'destination'}} = 1;
154*cdf0e10cSrcweir		}
155*cdf0e10cSrcweir	}
156*cdf0e10cSrcweir
157*cdf0e10cSrcweir	# Sorting each hash and assigning numbers
158*cdf0e10cSrcweir	# The destination of the file determines the sort order, not the filename!
159*cdf0e10cSrcweir	my $cabfile;
160*cdf0e10cSrcweir	foreach $cabfile ( sort keys %allassigns )
161*cdf0e10cSrcweir	{
162*cdf0e10cSrcweir		my $counter = $installer::globals::cabfilecounter{$cabfile};
163*cdf0e10cSrcweir		my $dest;
164*cdf0e10cSrcweir		foreach $dest ( sort keys %{$allassigns{$cabfile}} ) # <- sorting the destination!
165*cdf0e10cSrcweir		{
166*cdf0e10cSrcweir			my $directaccessnumber = $directaccess{$dest};
167*cdf0e10cSrcweir			${$filesref}[$directaccessnumber]->{'assignedsequencenumber'} = $counter;
168*cdf0e10cSrcweir			$counter++;
169*cdf0e10cSrcweir		}
170*cdf0e10cSrcweir	}
171*cdf0e10cSrcweir}
172*cdf0e10cSrcweir
173*cdf0e10cSrcweir#########################################################
174*cdf0e10cSrcweir# Create a shorter version of a long component name,
175*cdf0e10cSrcweir# because maximum length in msi database is 72.
176*cdf0e10cSrcweir# Attention: In multi msi installation sets, the short
177*cdf0e10cSrcweir# names have to be unique over all packages, because
178*cdf0e10cSrcweir# this string is used to create the globally unique id
179*cdf0e10cSrcweir# -> no resetting of
180*cdf0e10cSrcweir# %installer::globals::allshortcomponents
181*cdf0e10cSrcweir# after a package was created.
182*cdf0e10cSrcweir#########################################################
183*cdf0e10cSrcweir
184*cdf0e10cSrcweirsub generate_new_short_componentname
185*cdf0e10cSrcweir{
186*cdf0e10cSrcweir	my ($componentname) = @_;
187*cdf0e10cSrcweir
188*cdf0e10cSrcweir	my $shortcomponentname = "";
189*cdf0e10cSrcweir	my $counter = 1;
190*cdf0e10cSrcweir
191*cdf0e10cSrcweir	my $startversion = substr($componentname, 0, 60); # taking only the first 60 characters
192*cdf0e10cSrcweir	$startversion = $startversion . "_";
193*cdf0e10cSrcweir
194*cdf0e10cSrcweir	$shortcomponentname = $startversion . $counter;
195*cdf0e10cSrcweir
196*cdf0e10cSrcweir	while ( exists($installer::globals::allshortcomponents{$shortcomponentname}) )
197*cdf0e10cSrcweir	{
198*cdf0e10cSrcweir		$counter++;
199*cdf0e10cSrcweir		$shortcomponentname = $startversion . $counter;
200*cdf0e10cSrcweir	}
201*cdf0e10cSrcweir
202*cdf0e10cSrcweir	$installer::globals::allshortcomponents{$shortcomponentname} = 1;
203*cdf0e10cSrcweir
204*cdf0e10cSrcweir	return $shortcomponentname;
205*cdf0e10cSrcweir}
206*cdf0e10cSrcweir
207*cdf0e10cSrcweir###############################################
208*cdf0e10cSrcweir# Generating the component name from a file
209*cdf0e10cSrcweir###############################################
210*cdf0e10cSrcweir
211*cdf0e10cSrcweirsub get_file_component_name
212*cdf0e10cSrcweir{
213*cdf0e10cSrcweir	my ($fileref, $filesref) = @_;
214*cdf0e10cSrcweir
215*cdf0e10cSrcweir	my $componentname = "";
216*cdf0e10cSrcweir
217*cdf0e10cSrcweir	# Special handling for files with ASSIGNCOMPOMENT
218*cdf0e10cSrcweir
219*cdf0e10cSrcweir	my $styles = "";
220*cdf0e10cSrcweir	if ( $fileref->{'Styles'} ) { $styles = $fileref->{'Styles'}; }
221*cdf0e10cSrcweir	if ( $styles =~ /\bASSIGNCOMPOMENT\b/ )
222*cdf0e10cSrcweir	{
223*cdf0e10cSrcweir		$componentname = get_component_from_assigned_file($fileref->{'AssignComponent'}, $filesref);
224*cdf0e10cSrcweir	}
225*cdf0e10cSrcweir	else
226*cdf0e10cSrcweir	{
227*cdf0e10cSrcweir		# In this function exists the rule to create components from files
228*cdf0e10cSrcweir		# Rule:
229*cdf0e10cSrcweir		# Two files get the same componentid, if:
230*cdf0e10cSrcweir		# both have the same destination directory.
231*cdf0e10cSrcweir		# both have the same "gid" -> both were packed in the same zip file
232*cdf0e10cSrcweir		# All other files are included into different components!
233*cdf0e10cSrcweir
234*cdf0e10cSrcweir		# my $componentname = $fileref->{'gid'} . "_" . $fileref->{'Dir'};
235*cdf0e10cSrcweir
236*cdf0e10cSrcweir		# $fileref->{'Dir'} is not sufficient! All files in a zip file have the same $fileref->{'Dir'},
237*cdf0e10cSrcweir		# but can be in different subdirectories.
238*cdf0e10cSrcweir		# Solution: destination=share\Scripts\beanshell\Capitalise\capitalise.bsh
239*cdf0e10cSrcweir		# in which the filename (capitalise.bsh) has to be removed and all backslashes (slashes) are
240*cdf0e10cSrcweir		# converted into underline.
241*cdf0e10cSrcweir
242*cdf0e10cSrcweir		my $destination = $fileref->{'destination'};
243*cdf0e10cSrcweir		installer::pathanalyzer::get_path_from_fullqualifiedname(\$destination);
244*cdf0e10cSrcweir		$destination =~ s/\s//g;
245*cdf0e10cSrcweir		$destination =~ s/\\/\_/g;
246*cdf0e10cSrcweir		$destination =~ s/\//\_/g;
247*cdf0e10cSrcweir		$destination =~ s/\_\s*$//g;	# removing ending underline
248*cdf0e10cSrcweir
249*cdf0e10cSrcweir		$componentname = $fileref->{'gid'} . "__" . $destination;
250*cdf0e10cSrcweir
251*cdf0e10cSrcweir		# Files with different languages, need to be packed into different components.
252*cdf0e10cSrcweir		# Then the installation of the language specific component is determined by a language condition.
253*cdf0e10cSrcweir
254*cdf0e10cSrcweir		if ( $fileref->{'ismultilingual'} )
255*cdf0e10cSrcweir		{
256*cdf0e10cSrcweir			my $officelanguage = $fileref->{'specificlanguage'};
257*cdf0e10cSrcweir			$componentname = $componentname . "_" . $officelanguage;
258*cdf0e10cSrcweir		}
259*cdf0e10cSrcweir
260*cdf0e10cSrcweir		$componentname = lc($componentname);	# componentnames always lowercase
261*cdf0e10cSrcweir
262*cdf0e10cSrcweir		$componentname =~ s/\-/\_/g;			# converting "-" to "_"
263*cdf0e10cSrcweir		$componentname =~ s/\./\_/g;			# converting "-" to "_"
264*cdf0e10cSrcweir
265*cdf0e10cSrcweir		# Attention: Maximum length for the componentname is 72
266*cdf0e10cSrcweir		# %installer::globals::allcomponents_in_this_database : resetted for each database
267*cdf0e10cSrcweir		# %installer::globals::allcomponents : not resetted for each database
268*cdf0e10cSrcweir		# Component strings must be unique for the complete product, because they are used for
269*cdf0e10cSrcweir		# the creation of the globally unique identifier.
270*cdf0e10cSrcweir
271*cdf0e10cSrcweir		my $fullname = $componentname;  # This can be longer than 72
272*cdf0e10cSrcweir
273*cdf0e10cSrcweir		if (( exists($installer::globals::allcomponents{$fullname}) ) && ( ! exists($installer::globals::allcomponents_in_this_database{$fullname}) ))
274*cdf0e10cSrcweir		{
275*cdf0e10cSrcweir			# This is not allowed: One component cannot be installed with different packages.
276*cdf0e10cSrcweir			installer::exiter::exit_program("ERROR: Component \"$fullname\" is already included into another package. This is not allowed.", "get_file_component_name");
277*cdf0e10cSrcweir		}
278*cdf0e10cSrcweir
279*cdf0e10cSrcweir		if ( exists($installer::globals::allcomponents{$fullname}) )
280*cdf0e10cSrcweir		{
281*cdf0e10cSrcweir			$componentname = $installer::globals::allcomponents{$fullname};
282*cdf0e10cSrcweir		}
283*cdf0e10cSrcweir		else
284*cdf0e10cSrcweir		{
285*cdf0e10cSrcweir			if ( length($componentname) > 60 )
286*cdf0e10cSrcweir			{
287*cdf0e10cSrcweir				# Using md5sum needs much time
288*cdf0e10cSrcweir				# chomp(my $shorter = `echo $componentname | md5sum | sed -e "s/ .*//g"`);
289*cdf0e10cSrcweir				# $componentname = "comp_$shorter";
290*cdf0e10cSrcweir				$componentname = generate_new_short_componentname($componentname); # This has to be unique for the complete product, not only one package
291*cdf0e10cSrcweir			}
292*cdf0e10cSrcweir
293*cdf0e10cSrcweir			$installer::globals::allcomponents{$fullname} = $componentname;
294*cdf0e10cSrcweir			$installer::globals::allcomponents_in_this_database{$fullname} = 1;
295*cdf0e10cSrcweir		}
296*cdf0e10cSrcweir
297*cdf0e10cSrcweir		# $componentname =~ s/gid_file_/g_f_/g;
298*cdf0e10cSrcweir		# $componentname =~ s/_extra_/_e_/g;
299*cdf0e10cSrcweir		# $componentname =~ s/_config_/_c_/g;
300*cdf0e10cSrcweir		# $componentname =~ s/_org_openoffice_/_o_o_/g;
301*cdf0e10cSrcweir		# $componentname =~ s/_program_/_p_/g;
302*cdf0e10cSrcweir		# $componentname =~ s/_typedetection_/_td_/g;
303*cdf0e10cSrcweir		# $componentname =~ s/_linguistic_/_l_/g;
304*cdf0e10cSrcweir		# $componentname =~ s/_module_/_m_/g;
305*cdf0e10cSrcweir		# $componentname =~ s/_optional_/_opt_/g;
306*cdf0e10cSrcweir		# $componentname =~ s/_packages/_pack/g;
307*cdf0e10cSrcweir		# $componentname =~ s/_menubar/_mb/g;
308*cdf0e10cSrcweir		# $componentname =~ s/_common_/_cm_/g;
309*cdf0e10cSrcweir		# $componentname =~ s/_export_/_exp_/g;
310*cdf0e10cSrcweir		# $componentname =~ s/_table_/_tb_/g;
311*cdf0e10cSrcweir		# $componentname =~ s/_sofficecfg_/_sc_/g;
312*cdf0e10cSrcweir		# $componentname =~ s/_soffice_cfg_/_sc_/g;
313*cdf0e10cSrcweir		# $componentname =~ s/_startmodulecommands_/_smc_/g;
314*cdf0e10cSrcweir		# $componentname =~ s/_drawimpresscommands_/_dic_/g;
315*cdf0e10cSrcweir		# $componentname =~ s/_basiccommands_/_bac_/g;
316*cdf0e10cSrcweir		# $componentname =~ s/_basicidecommands_/_baic_/g;
317*cdf0e10cSrcweir		# $componentname =~ s/_genericcommands_/_genc_/g;
318*cdf0e10cSrcweir		# $componentname =~ s/_bibliographycommands_/_bibc_/g;
319*cdf0e10cSrcweir		# $componentname =~ s/_gentiumbookbasicbolditalic_/_gbbbi_/g;
320*cdf0e10cSrcweir		# $componentname =~ s/_share_/_s_/g;
321*cdf0e10cSrcweir		# $componentname =~ s/_extension_/_ext_/g;
322*cdf0e10cSrcweir		# $componentname =~ s/_extensions_/_exs_/g;
323*cdf0e10cSrcweir		# $componentname =~ s/_modules_/_ms_/g;
324*cdf0e10cSrcweir		# $componentname =~ s/_uiconfig_zip_/_ucz_/g;
325*cdf0e10cSrcweir		# $componentname =~ s/_productivity_/_pr_/g;
326*cdf0e10cSrcweir		# $componentname =~ s/_wizard_/_wz_/g;
327*cdf0e10cSrcweir		# $componentname =~ s/_import_/_im_/g;
328*cdf0e10cSrcweir		# $componentname =~ s/_javascript_/_js_/g;
329*cdf0e10cSrcweir		# $componentname =~ s/_template_/_tpl_/g;
330*cdf0e10cSrcweir		# $componentname =~ s/_tplwizletter_/_twl_/g;
331*cdf0e10cSrcweir		# $componentname =~ s/_beanshell_/_bs_/g;
332*cdf0e10cSrcweir		# $componentname =~ s/_presentation_/_bs_/g;
333*cdf0e10cSrcweir		# $componentname =~ s/_columns_/_cls_/g;
334*cdf0e10cSrcweir		# $componentname =~ s/_python_/_py_/g;
335*cdf0e10cSrcweir
336*cdf0e10cSrcweir		# $componentname =~ s/_tools/_ts/g;
337*cdf0e10cSrcweir		# $componentname =~ s/_transitions/_trs/g;
338*cdf0e10cSrcweir		# $componentname =~ s/_scriptbinding/_scrb/g;
339*cdf0e10cSrcweir		# $componentname =~ s/_spreadsheet/_ssh/g;
340*cdf0e10cSrcweir		# $componentname =~ s/_publisher/_pub/g;
341*cdf0e10cSrcweir		# $componentname =~ s/_presenter/_pre/g;
342*cdf0e10cSrcweir		# $componentname =~ s/_registry/_reg/g;
343*cdf0e10cSrcweir
344*cdf0e10cSrcweir		# $componentname =~ s/screen/sc/g;
345*cdf0e10cSrcweir		# $componentname =~ s/wordml/wm/g;
346*cdf0e10cSrcweir		# $componentname =~ s/openoffice/oo/g;
347*cdf0e10cSrcweir	}
348*cdf0e10cSrcweir
349*cdf0e10cSrcweir	return $componentname;
350*cdf0e10cSrcweir}
351*cdf0e10cSrcweir
352*cdf0e10cSrcweir####################################################################
353*cdf0e10cSrcweir# Returning the component name for a defined file gid.
354*cdf0e10cSrcweir# This is necessary for files with flag ASSIGNCOMPOMENT
355*cdf0e10cSrcweir####################################################################
356*cdf0e10cSrcweir
357*cdf0e10cSrcweirsub get_component_from_assigned_file
358*cdf0e10cSrcweir{
359*cdf0e10cSrcweir	my ($gid, $filesref) = @_;
360*cdf0e10cSrcweir
361*cdf0e10cSrcweir	my $onefile = installer::existence::get_specified_file($filesref, $gid);
362*cdf0e10cSrcweir	my $componentname = "";
363*cdf0e10cSrcweir	if ( $onefile->{'componentname'} ) { $componentname = $onefile->{'componentname'}; }
364*cdf0e10cSrcweir	else { installer::exiter::exit_program("ERROR: No component defined for file: $gid", "get_component_from_assigned_file"); }
365*cdf0e10cSrcweir
366*cdf0e10cSrcweir	return $componentname;
367*cdf0e10cSrcweir}
368*cdf0e10cSrcweir
369*cdf0e10cSrcweir####################################################################
370*cdf0e10cSrcweir# Generating the special filename for the database file File.idt
371*cdf0e10cSrcweir# Sample: CONTEXTS, CONTEXTS1
372*cdf0e10cSrcweir# This name has to be unique.
373*cdf0e10cSrcweir# In most cases this is simply the filename.
374*cdf0e10cSrcweir####################################################################
375*cdf0e10cSrcweir
376*cdf0e10cSrcweirsub generate_unique_filename_for_filetable
377*cdf0e10cSrcweir{
378*cdf0e10cSrcweir	my ($fileref, $component, $uniquefilenamehashref) = @_;
379*cdf0e10cSrcweir
380*cdf0e10cSrcweir	# This new filename has to be saved into $fileref, because this is needed to find the source.
381*cdf0e10cSrcweir	# The filename sbasic.idx/OFFSETS is changed to OFFSETS, but OFFSETS is not unique.
382*cdf0e10cSrcweir	# In this procedure names like OFFSETS5 are produced. And exactly this string has to be added to
383*cdf0e10cSrcweir	# the array of all files.
384*cdf0e10cSrcweir
385*cdf0e10cSrcweir	my $uniquefilename = "";
386*cdf0e10cSrcweir	my $counter = 0;
387*cdf0e10cSrcweir
388*cdf0e10cSrcweir	if ( $fileref->{'Name'} ) { $uniquefilename = $fileref->{'Name'}; }
389*cdf0e10cSrcweir
390*cdf0e10cSrcweir	installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$uniquefilename);	# making /registry/schema/org/openoffice/VCL.xcs to VCL.xcs
391*cdf0e10cSrcweir
392*cdf0e10cSrcweir	# Reading unique filename with help of "Component_" in File table from old database
393*cdf0e10cSrcweir	if (( $installer::globals::updatedatabase ) && ( exists($uniquefilenamehashref->{"$component/$uniquefilename"}) ))
394*cdf0e10cSrcweir	{
395*cdf0e10cSrcweir		$uniquefilename = $uniquefilenamehashref->{"$component/$uniquefilename"};  # syntax of $value: ($uniquename;$shortname)
396*cdf0e10cSrcweir		if ( $uniquefilename =~ /^\s*(.*?)\;\s*(.*?)\s*$/ ) { $uniquefilename = $1; }
397*cdf0e10cSrcweir 		$lcuniquefilename = lc($uniquefilename);
398*cdf0e10cSrcweir		$installer::globals::alluniquefilenames{$uniquefilename} = 1;
399*cdf0e10cSrcweir		$installer::globals::alllcuniquefilenames{$lcuniquefilename} = 1;
400*cdf0e10cSrcweir		return $uniquefilename;
401*cdf0e10cSrcweir	}
402*cdf0e10cSrcweir	elsif (( $installer::globals::prepare_winpatch ) && ( exists($installer::globals::savedmapping{"$component/$uniquefilename"}) ))
403*cdf0e10cSrcweir	{
404*cdf0e10cSrcweir		# If we have a FTK mapping for this component/file, use it.
405*cdf0e10cSrcweir		$installer::globals::savedmapping{"$component/$uniquefilename"} =~ m/^(.*);/;
406*cdf0e10cSrcweir		$uniquefilename = $1;
407*cdf0e10cSrcweir 		$lcuniquefilename = lc($uniquefilename);
408*cdf0e10cSrcweir		$installer::globals::alluniquefilenames{$uniquefilename} = 1;
409*cdf0e10cSrcweir		$installer::globals::alllcuniquefilenames{$lcuniquefilename} = 1;
410*cdf0e10cSrcweir		return $uniquefilename;
411*cdf0e10cSrcweir	}
412*cdf0e10cSrcweir
413*cdf0e10cSrcweir	$uniquefilename =~ s/\-/\_/g;		# no "-" allowed
414*cdf0e10cSrcweir	$uniquefilename =~ s/\@/\_/g;		# no "@" allowed
415*cdf0e10cSrcweir	$uniquefilename =~ s/\$/\_/g;		# no "$" allowed
416*cdf0e10cSrcweir	$uniquefilename =~ s/^\s*\./\_/g;		# no "." at the beginning allowed allowed
417*cdf0e10cSrcweir	$uniquefilename =~ s/^\s*\d/\_d/g;		# no number at the beginning allowed allowed (even file "0.gif", replacing to "_d.gif")
418*cdf0e10cSrcweir	$uniquefilename =~ s/org_openoffice_/ooo_/g;	# shorten the unique file name
419*cdf0e10cSrcweir
420*cdf0e10cSrcweir	my $lcuniquefilename = lc($uniquefilename);	# only lowercase names
421*cdf0e10cSrcweir
422*cdf0e10cSrcweir	my $newname = 0;
423*cdf0e10cSrcweir
424*cdf0e10cSrcweir	if ( ! exists($installer::globals::alllcuniquefilenames{$lcuniquefilename}) &&
425*cdf0e10cSrcweir	     ! exists($installer::globals::savedrevmapping{$lcuniquefilename}) )
426*cdf0e10cSrcweir	{
427*cdf0e10cSrcweir		$installer::globals::alluniquefilenames{$uniquefilename} = 1;
428*cdf0e10cSrcweir		$installer::globals::alllcuniquefilenames{$lcuniquefilename} = 1;
429*cdf0e10cSrcweir		$newname = 1;
430*cdf0e10cSrcweir	}
431*cdf0e10cSrcweir
432*cdf0e10cSrcweir	if ( ! $newname )
433*cdf0e10cSrcweir	{
434*cdf0e10cSrcweir		# adding a number until the name is really unique: OFFSETS, OFFSETS1, OFFSETS2, ...
435*cdf0e10cSrcweir		# But attention: Making "abc.xcu" to "abc1.xcu"
436*cdf0e10cSrcweir
437*cdf0e10cSrcweir		my $uniquefilenamebase = $uniquefilename;
438*cdf0e10cSrcweir
439*cdf0e10cSrcweir		do
440*cdf0e10cSrcweir		{
441*cdf0e10cSrcweir			$counter++;
442*cdf0e10cSrcweir
443*cdf0e10cSrcweir			if ( $uniquefilenamebase =~ /\./ )
444*cdf0e10cSrcweir			{
445*cdf0e10cSrcweir				$uniquefilename = $uniquefilenamebase;
446*cdf0e10cSrcweir				$uniquefilename =~ s/\./$counter\./;
447*cdf0e10cSrcweir			}
448*cdf0e10cSrcweir			else
449*cdf0e10cSrcweir			{
450*cdf0e10cSrcweir				$uniquefilename = $uniquefilenamebase . $counter;
451*cdf0e10cSrcweir			}
452*cdf0e10cSrcweir
453*cdf0e10cSrcweir			$newname = 0;
454*cdf0e10cSrcweir			$lcuniquefilename = lc($uniquefilename);	# only lowercase names
455*cdf0e10cSrcweir
456*cdf0e10cSrcweir			if ( ! exists($installer::globals::alllcuniquefilenames{$lcuniquefilename}) &&
457*cdf0e10cSrcweir			     ! exists($installer::globals::savedrevmapping{$lcuniquefilename}) )
458*cdf0e10cSrcweir			{
459*cdf0e10cSrcweir				$installer::globals::alluniquefilenames{$uniquefilename} = 1;
460*cdf0e10cSrcweir				$installer::globals::alllcuniquefilenames{$lcuniquefilename} = 1;
461*cdf0e10cSrcweir				$newname = 1;
462*cdf0e10cSrcweir			}
463*cdf0e10cSrcweir		}
464*cdf0e10cSrcweir		until ( $newname )
465*cdf0e10cSrcweir	}
466*cdf0e10cSrcweir
467*cdf0e10cSrcweir	return $uniquefilename;
468*cdf0e10cSrcweir}
469*cdf0e10cSrcweir
470*cdf0e10cSrcweir####################################################################
471*cdf0e10cSrcweir# Generating the special file column for the database file File.idt
472*cdf0e10cSrcweir# Sample: NAMETR~1.TAB|.nametranslation.table
473*cdf0e10cSrcweir# The first part has to be 8.3 conform.
474*cdf0e10cSrcweir####################################################################
475*cdf0e10cSrcweir
476*cdf0e10cSrcweirsub generate_filename_for_filetable
477*cdf0e10cSrcweir{
478*cdf0e10cSrcweir	my ($fileref, $shortnamesref, $uniquefilenamehashref) = @_;
479*cdf0e10cSrcweir
480*cdf0e10cSrcweir	my $returnstring = "";
481*cdf0e10cSrcweir
482*cdf0e10cSrcweir	my $filename = $fileref->{'Name'};
483*cdf0e10cSrcweir
484*cdf0e10cSrcweir	installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$filename);	# making /registry/schema/org/openoffice/VCL.xcs to VCL.xcs
485*cdf0e10cSrcweir
486*cdf0e10cSrcweir	my $shortstring;
487*cdf0e10cSrcweir
488*cdf0e10cSrcweir	# Reading short string with help of "FileName" in File table from old database
489*cdf0e10cSrcweir	if (( $installer::globals::updatedatabase ) && ( exists($uniquefilenamehashref->{"$fileref->{'componentname'}/$filename"}) ))
490*cdf0e10cSrcweir	{
491*cdf0e10cSrcweir		my $value = $uniquefilenamehashref->{"$fileref->{'componentname'}/$filename"};  # syntax of $value: ($uniquename;$shortname)
492*cdf0e10cSrcweir		if ( $value =~ /^\s*(.*?)\;\s*(.*?)\s*$/ ) { $shortstring = $2; } # already collected in function "collect_shortnames_from_old_database"
493*cdf0e10cSrcweir		else { $shortstring = $filename; }
494*cdf0e10cSrcweir	}
495*cdf0e10cSrcweir	elsif (( $installer::globals::prepare_winpatch ) && ( exists($installer::globals::savedmapping{"$fileref->{'componentname'}/$filename"}) ))
496*cdf0e10cSrcweir	{
497*cdf0e10cSrcweir		$installer::globals::savedmapping{"$fileref->{'componentname'}/$filename"} =~ m/.*;(.*)/;
498*cdf0e10cSrcweir		if ($1 ne '')
499*cdf0e10cSrcweir		{
500*cdf0e10cSrcweir			$shortstring = $1;
501*cdf0e10cSrcweir		}
502*cdf0e10cSrcweir		else
503*cdf0e10cSrcweir		{
504*cdf0e10cSrcweir			$shortstring = installer::windows::idtglobal::make_eight_three_conform_with_hash($filename, "file", $shortnamesref);
505*cdf0e10cSrcweir		}
506*cdf0e10cSrcweir	}
507*cdf0e10cSrcweir	else
508*cdf0e10cSrcweir	{
509*cdf0e10cSrcweir		$shortstring = installer::windows::idtglobal::make_eight_three_conform_with_hash($filename, "file", $shortnamesref);
510*cdf0e10cSrcweir	}
511*cdf0e10cSrcweir
512*cdf0e10cSrcweir	if ( $shortstring eq $filename ) { $returnstring = $filename; }	# nothing changed
513*cdf0e10cSrcweir	else {$returnstring = $shortstring . "\|" . $filename; }
514*cdf0e10cSrcweir
515*cdf0e10cSrcweir	return $returnstring;
516*cdf0e10cSrcweir}
517*cdf0e10cSrcweir
518*cdf0e10cSrcweir#########################################
519*cdf0e10cSrcweir# Returning the filesize of a file
520*cdf0e10cSrcweir#########################################
521*cdf0e10cSrcweir
522*cdf0e10cSrcweirsub get_filesize
523*cdf0e10cSrcweir{
524*cdf0e10cSrcweir	my ($fileref) = @_;
525*cdf0e10cSrcweir
526*cdf0e10cSrcweir	my $file = $fileref->{'sourcepath'};
527*cdf0e10cSrcweir
528*cdf0e10cSrcweir	my $filesize;
529*cdf0e10cSrcweir
530*cdf0e10cSrcweir	if ( -f $file )	# test of existence. For instance services.rdb does not always exist
531*cdf0e10cSrcweir	{
532*cdf0e10cSrcweir		$filesize = ( -s $file );	# file size can be "0"
533*cdf0e10cSrcweir	}
534*cdf0e10cSrcweir	else
535*cdf0e10cSrcweir	{
536*cdf0e10cSrcweir		$filesize = -1;
537*cdf0e10cSrcweir	}
538*cdf0e10cSrcweir
539*cdf0e10cSrcweir	return $filesize;
540*cdf0e10cSrcweir}
541*cdf0e10cSrcweir
542*cdf0e10cSrcweir#############################################
543*cdf0e10cSrcweir# Returning the file version, if required
544*cdf0e10cSrcweir# Sample: "8.0.1.8976";
545*cdf0e10cSrcweir#############################################
546*cdf0e10cSrcweir
547*cdf0e10cSrcweirsub get_fileversion
548*cdf0e10cSrcweir{
549*cdf0e10cSrcweir	my ($onefile, $allvariables, $styles) = @_;
550*cdf0e10cSrcweir
551*cdf0e10cSrcweir	my $fileversion = "";
552*cdf0e10cSrcweir
553*cdf0e10cSrcweir	if ( $allvariables->{'USE_FILEVERSION'} )
554*cdf0e10cSrcweir	{
555*cdf0e10cSrcweir		if ( ! $allvariables->{'LIBRARYVERSION'} ) { installer::exiter::exit_program("ERROR: USE_FILEVERSION is set, but not LIBRARYVERSION", "get_fileversion"); }
556*cdf0e10cSrcweir		my $libraryversion = $allvariables->{'LIBRARYVERSION'};
557*cdf0e10cSrcweir		if ( $libraryversion =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ )
558*cdf0e10cSrcweir		{
559*cdf0e10cSrcweir			my $major = $1;
560*cdf0e10cSrcweir			my $minor = $2;
561*cdf0e10cSrcweir			my $micro = $3;
562*cdf0e10cSrcweir			my $concat = 100 * $minor + $micro;
563*cdf0e10cSrcweir			$libraryversion = $major . "\." . $concat;
564*cdf0e10cSrcweir		}
565*cdf0e10cSrcweir		my $vendornumber = 0;
566*cdf0e10cSrcweir		if ( $allvariables->{'VENDORPATCHVERSION'} ) { $vendornumber = $allvariables->{'VENDORPATCHVERSION'}; }
567*cdf0e10cSrcweir		$fileversion = $libraryversion . "\." . $installer::globals::buildid . "\." . $vendornumber;
568*cdf0e10cSrcweir		if ( $onefile->{'FileVersion'} ) { $fileversion = $onefile->{'FileVersion'}; } # overriding FileVersion in scp
569*cdf0e10cSrcweir
570*cdf0e10cSrcweir		# if ( $styles =~ /\bFONT\b/ )
571*cdf0e10cSrcweir		# {
572*cdf0e10cSrcweir		#	my $newfileversion = installer::windows::font::get_font_version($onefile->{'sourcepath'});
573*cdf0e10cSrcweir		#	if ( $newfileversion != 0 ) { $fileversion = $newfileversion; }
574*cdf0e10cSrcweir		# }
575*cdf0e10cSrcweir	}
576*cdf0e10cSrcweir
577*cdf0e10cSrcweir	if ( $installer::globals::prepare_winpatch ) { $fileversion = ""; } # Windows patches do not allow this version # -> who says so?
578*cdf0e10cSrcweir
579*cdf0e10cSrcweir	return $fileversion;
580*cdf0e10cSrcweir}
581*cdf0e10cSrcweir
582*cdf0e10cSrcweir#############################################
583*cdf0e10cSrcweir# Returning the sequence for a file
584*cdf0e10cSrcweir#############################################
585*cdf0e10cSrcweir
586*cdf0e10cSrcweirsub get_sequence_for_file
587*cdf0e10cSrcweir{
588*cdf0e10cSrcweir	my ($number, $onefile, $fileentry, $allupdatesequenceshashref, $allupdatecomponentshashref, $allupdatefileorderhashref, $allfilecomponents) = @_;
589*cdf0e10cSrcweir
590*cdf0e10cSrcweir	my $sequence = "";
591*cdf0e10cSrcweir	my $infoline = "";
592*cdf0e10cSrcweir	my $pffcomponentname = $onefile->{'componentname'} . "_pff";
593*cdf0e10cSrcweir
594*cdf0e10cSrcweir	if ( $installer::globals::updatedatabase )
595*cdf0e10cSrcweir	{
596*cdf0e10cSrcweir		if (( exists($allupdatesequenceshashref->{$onefile->{'uniquename'}}) ) &&
597*cdf0e10cSrcweir		    (( $onefile->{'componentname'} eq $allupdatecomponentshashref->{$onefile->{'uniquename'}} ) ||
598*cdf0e10cSrcweir		     ( $pffcomponentname eq $allupdatecomponentshashref->{$onefile->{'uniquename'}} )))
599*cdf0e10cSrcweir		{
600*cdf0e10cSrcweir			# The second condition is necessary to find shifted files, that have same "uniquename", but are now
601*cdf0e10cSrcweir			# located in another directory. This can be seen at the component name.
602*cdf0e10cSrcweir			$sequence = $allupdatesequenceshashref->{$onefile->{'uniquename'}};
603*cdf0e10cSrcweir			$onefile->{'assignedsequencenumber'} = $sequence;
604*cdf0e10cSrcweir			# Collecting all used sequences, to guarantee, that no number is unused
605*cdf0e10cSrcweir			$installer::globals::allusedupdatesequences{$sequence} = 1;
606*cdf0e10cSrcweir			# Special help for files, that already have a "pff" component name (for example after ServicePack 1)
607*cdf0e10cSrcweir			if ( $pffcomponentname eq $allupdatecomponentshashref->{$onefile->{'uniquename'}} )
608*cdf0e10cSrcweir			{
609*cdf0e10cSrcweir				$infoline = "Warning: Special handling for component \"$pffcomponentname\". This file was added after the final, but before this ServicePack.\n";
610*cdf0e10cSrcweir				push(@installer::globals::logfileinfo, $infoline);
611*cdf0e10cSrcweir				$onefile->{'componentname'} = $pffcomponentname; # pff for "post final file"
612*cdf0e10cSrcweir				$fileentry->{'Component_'} = $onefile->{'componentname'};
613*cdf0e10cSrcweir				if ( ! exists($allfilecomponents->{$fileentry->{'Component_'}}) ) { $allfilecomponents->{$fileentry->{'Component_'}} = 1; }
614*cdf0e10cSrcweir			}
615*cdf0e10cSrcweir		}
616*cdf0e10cSrcweir		else
617*cdf0e10cSrcweir		{
618*cdf0e10cSrcweir			$installer::globals::updatesequencecounter++;
619*cdf0e10cSrcweir			$sequence = $installer::globals::updatesequencecounter;
620*cdf0e10cSrcweir			$onefile->{'assignedsequencenumber'} = $sequence;
621*cdf0e10cSrcweir			# $onefile->{'assignedcabinetfile'} = $installer::globals::pffcabfilename; # assigning to cabinet file for "post final files"
622*cdf0e10cSrcweir			# Collecting all new files
623*cdf0e10cSrcweir			$installer::globals::newupdatefiles{$sequence} = $onefile;
624*cdf0e10cSrcweir			# Saving in sequence hash
625*cdf0e10cSrcweir			$allupdatefileorderhashref->{$sequence} = $onefile->{'uniquename'};
626*cdf0e10cSrcweir
627*cdf0e10cSrcweir			# If the new file is part of an existing component, this must be changed now. All files
628*cdf0e10cSrcweir			# of one component have to be included in one cabinet file. But because the order must
629*cdf0e10cSrcweir			# not change, all new files have to be added to new components.
630*cdf0e10cSrcweir			# $onefile->{'componentname'} = $file{'Component_'};
631*cdf0e10cSrcweir
632*cdf0e10cSrcweir			$onefile->{'componentname'} = $onefile->{'componentname'} . "_pff"; # pff for "post final file"
633*cdf0e10cSrcweir			$fileentry->{'Component_'} = $onefile->{'componentname'};
634*cdf0e10cSrcweir			if ( ! exists($allfilecomponents->{$fileentry->{'Component_'}}) ) { $allfilecomponents->{$fileentry->{'Component_'}} = 1; }
635*cdf0e10cSrcweir			$onefile->{'PostFinalFile'} = 1;
636*cdf0e10cSrcweir			# $installer::globals::pfffileexists = 1;
637*cdf0e10cSrcweir			# The sequence for this file has changed. It has to be inserted at the end of the files collector.
638*cdf0e10cSrcweir			$installer::globals::insert_file_at_end = 1;
639*cdf0e10cSrcweir			$installer::globals::newfilescollector{$sequence} = $onefile; # Adding new files to the end of the filescollector
640*cdf0e10cSrcweir			$installer::globals::newfilesexist = 1;
641*cdf0e10cSrcweir		}
642*cdf0e10cSrcweir	}
643*cdf0e10cSrcweir	elsif (( $onefile->{'assignedsequencenumber'} ) && ( $installer::globals::use_packages_for_cabs ))
644*cdf0e10cSrcweir	{
645*cdf0e10cSrcweir		$sequence = $onefile->{'assignedsequencenumber'};
646*cdf0e10cSrcweir	}
647*cdf0e10cSrcweir	else
648*cdf0e10cSrcweir	{
649*cdf0e10cSrcweir		$sequence = $number;
650*cdf0e10cSrcweir		# my $sequence = $number + 1;
651*cdf0e10cSrcweir
652*cdf0e10cSrcweir		# Idea: Each component is packed into a cab file.
653*cdf0e10cSrcweir		# This requires that all files in one cab file have sequences directly follwing each other,
654*cdf0e10cSrcweir		# for instance from 1456 to 1466. Then in the media table the LastSequence for this cab file
655*cdf0e10cSrcweir		# is 1466.
656*cdf0e10cSrcweir		# Because all files belonging to one component are directly behind each other in the file
657*cdf0e10cSrcweir		# collector, it is possible to use simply an increasing number as sequence value.
658*cdf0e10cSrcweir		# If files belonging to one component are not directly behind each other in the files collector
659*cdf0e10cSrcweir		# this mechanism will no longer work.
660*cdf0e10cSrcweir	}
661*cdf0e10cSrcweir
662*cdf0e10cSrcweir	return $sequence;
663*cdf0e10cSrcweir}
664*cdf0e10cSrcweir
665*cdf0e10cSrcweir#############################################
666*cdf0e10cSrcweir# Returning the Windows language of a file
667*cdf0e10cSrcweir#############################################
668*cdf0e10cSrcweir
669*cdf0e10cSrcweirsub get_language_for_file
670*cdf0e10cSrcweir{
671*cdf0e10cSrcweir	my ($fileref) = @_;
672*cdf0e10cSrcweir
673*cdf0e10cSrcweir	my $language = "";
674*cdf0e10cSrcweir
675*cdf0e10cSrcweir	if ( $fileref->{'specificlanguage'} ) { $language = $fileref->{'specificlanguage'}; }
676*cdf0e10cSrcweir
677*cdf0e10cSrcweir	if ( $language eq "" )
678*cdf0e10cSrcweir	{
679*cdf0e10cSrcweir		$language = 0;  # language independent
680*cdf0e10cSrcweir		# If this is not a font, the return value should be "0" (Check ICE 60)
681*cdf0e10cSrcweir		my $styles = "";
682*cdf0e10cSrcweir		if ( $fileref->{'Styles'} ) { $styles = $fileref->{'Styles'}; }
683*cdf0e10cSrcweir		if ( $styles =~ /\bFONT\b/ ) { $language = ""; }
684*cdf0e10cSrcweir	}
685*cdf0e10cSrcweir	else
686*cdf0e10cSrcweir	{
687*cdf0e10cSrcweir		$language = installer::windows::language::get_windows_language($language);
688*cdf0e10cSrcweir	}
689*cdf0e10cSrcweir
690*cdf0e10cSrcweir	return $language;
691*cdf0e10cSrcweir}
692*cdf0e10cSrcweir
693*cdf0e10cSrcweir####################################################################
694*cdf0e10cSrcweir# Creating a new KeyPath for components in TemplatesFolder.
695*cdf0e10cSrcweir####################################################################
696*cdf0e10cSrcweir
697*cdf0e10cSrcweirsub generate_registry_keypath
698*cdf0e10cSrcweir{
699*cdf0e10cSrcweir	my ($onefile) = @_;
700*cdf0e10cSrcweir
701*cdf0e10cSrcweir	my $keypath = $onefile->{'Name'};
702*cdf0e10cSrcweir	$keypath =~ s/\.//g;
703*cdf0e10cSrcweir	$keypath = lc($keypath);
704*cdf0e10cSrcweir	$keypath = "userreg_" . $keypath;
705*cdf0e10cSrcweir
706*cdf0e10cSrcweir	return $keypath;
707*cdf0e10cSrcweir}
708*cdf0e10cSrcweir
709*cdf0e10cSrcweir####################################################################
710*cdf0e10cSrcweir# Check, if in an update process files are missing. No removal
711*cdf0e10cSrcweir# of files allowed for Windows Patch creation.
712*cdf0e10cSrcweir# Also logging all new files, that have to be included in extra
713*cdf0e10cSrcweir# components and cab files.
714*cdf0e10cSrcweir####################################################################
715*cdf0e10cSrcweir
716*cdf0e10cSrcweirsub check_file_sequences
717*cdf0e10cSrcweir{
718*cdf0e10cSrcweir	my ($allupdatefileorderhashref, $allupdatecomponentorderhashref) = @_;
719*cdf0e10cSrcweir
720*cdf0e10cSrcweir	# All used sequences stored in %installer::globals::allusedupdatesequences
721*cdf0e10cSrcweir	# Maximum sequence number of old database stored in $installer::globals::updatelastsequence
722*cdf0e10cSrcweir	# All new files stored in %installer::globals::newupdatefiles
723*cdf0e10cSrcweir
724*cdf0e10cSrcweir	my $infoline = "";
725*cdf0e10cSrcweir
726*cdf0e10cSrcweir	my @missing_sequences = ();
727*cdf0e10cSrcweir	my @really_missing_sequences = ();
728*cdf0e10cSrcweir
729*cdf0e10cSrcweir	for ( my $i = 1; $i <= $installer::globals::updatelastsequence; $i++ )
730*cdf0e10cSrcweir	{
731*cdf0e10cSrcweir		if ( ! exists($installer::globals::allusedupdatesequences{$i}) ) { push(@missing_sequences, $i); }
732*cdf0e10cSrcweir	}
733*cdf0e10cSrcweir
734*cdf0e10cSrcweir	if ( $#missing_sequences > -1 )
735*cdf0e10cSrcweir	{
736*cdf0e10cSrcweir		# Missing sequences can also be caused by files included in merge modules. This files are added later into the file table.
737*cdf0e10cSrcweir		# Therefore now it is time to check the content of the merge modules.
738*cdf0e10cSrcweir
739*cdf0e10cSrcweir		for ( my $j = 0; $j <= $#missing_sequences; $j++ )
740*cdf0e10cSrcweir		{
741*cdf0e10cSrcweir			my $filename = $allupdatefileorderhashref->{$missing_sequences[$j]};
742*cdf0e10cSrcweir
743*cdf0e10cSrcweir			# Is this a file from a merge module? Then this is no error.
744*cdf0e10cSrcweir			if ( ! exists($installer::globals::mergemodulefiles{$filename}) )
745*cdf0e10cSrcweir			{
746*cdf0e10cSrcweir				push(@really_missing_sequences, $missing_sequences[$j]);
747*cdf0e10cSrcweir			}
748*cdf0e10cSrcweir		}
749*cdf0e10cSrcweir	}
750*cdf0e10cSrcweir
751*cdf0e10cSrcweir	if ( $#really_missing_sequences > -1 )
752*cdf0e10cSrcweir	{
753*cdf0e10cSrcweir		my $errorstring = "";
754*cdf0e10cSrcweir		for ( my $j = 0; $j <= $#really_missing_sequences; $j++ )
755*cdf0e10cSrcweir		{
756*cdf0e10cSrcweir			my $filename = $allupdatefileorderhashref->{$really_missing_sequences[$j]};
757*cdf0e10cSrcweir			my $comp = $allupdatecomponentorderhashref->{$really_missing_sequences[$j]};
758*cdf0e10cSrcweir			$errorstring = "$errorstring$filename (Sequence: $really_missing_sequences[$j], Component: \"$comp\")\n";
759*cdf0e10cSrcweir		}
760*cdf0e10cSrcweir
761*cdf0e10cSrcweir		$infoline = "ERROR: Files are removed compared with update database.\nThe following files are missing:\n$errorstring";
762*cdf0e10cSrcweir		push(@installer::globals::logfileinfo, $infoline);
763*cdf0e10cSrcweir		installer::exiter::exit_program($infoline, "check_file_sequences");
764*cdf0e10cSrcweir	}
765*cdf0e10cSrcweir
766*cdf0e10cSrcweir	# Searching for new files
767*cdf0e10cSrcweir
768*cdf0e10cSrcweir	my $counter = 0;
769*cdf0e10cSrcweir
770*cdf0e10cSrcweir	foreach my $key ( keys %installer::globals::newupdatefiles )
771*cdf0e10cSrcweir	{
772*cdf0e10cSrcweir		my $onefile = $installer::globals::newupdatefiles{$key};
773*cdf0e10cSrcweir		$counter++;
774*cdf0e10cSrcweir		if ( $counter == 1 )
775*cdf0e10cSrcweir		{
776*cdf0e10cSrcweir			$infoline = "\nNew files compared to the update database:\n";
777*cdf0e10cSrcweir			push(@installer::globals::logfileinfo, $infoline);
778*cdf0e10cSrcweir		}
779*cdf0e10cSrcweir
780*cdf0e10cSrcweir		$infoline = "$onefile->{'Name'} ($onefile->{'gid'}) Sequence: $onefile->{'assignedsequencenumber'}\n";
781*cdf0e10cSrcweir		push(@installer::globals::logfileinfo, $infoline);
782*cdf0e10cSrcweir	}
783*cdf0e10cSrcweir
784*cdf0e10cSrcweir	if ( $counter == 0 )
785*cdf0e10cSrcweir	{
786*cdf0e10cSrcweir		$infoline = "Info: No new file compared with update database!\n";
787*cdf0e10cSrcweir		push(@installer::globals::logfileinfo, $infoline);
788*cdf0e10cSrcweir	}
789*cdf0e10cSrcweir
790*cdf0e10cSrcweir}
791*cdf0e10cSrcweir
792*cdf0e10cSrcweir###################################################################
793*cdf0e10cSrcweir# Collecting further conditions for the component table.
794*cdf0e10cSrcweir# This is used by multilayer products, to enable installation
795*cdf0e10cSrcweir# of separate layers.
796*cdf0e10cSrcweir###################################################################
797*cdf0e10cSrcweir
798*cdf0e10cSrcweirsub get_tree_condition_for_component
799*cdf0e10cSrcweir{
800*cdf0e10cSrcweir	my ($onefile, $componentname) = @_;
801*cdf0e10cSrcweir
802*cdf0e10cSrcweir	if ( $onefile->{'destination'} )
803*cdf0e10cSrcweir	{
804*cdf0e10cSrcweir		my $dest = $onefile->{'destination'};
805*cdf0e10cSrcweir
806*cdf0e10cSrcweir		# Comparing the destination path with
807*cdf0e10cSrcweir		# $installer::globals::hostnametreestyles{$hostname} = $treestyle;
808*cdf0e10cSrcweir		# (-> hostname is the key, the style the value!)
809*cdf0e10cSrcweir
810*cdf0e10cSrcweir		foreach my $hostname ( keys %installer::globals::hostnametreestyles )
811*cdf0e10cSrcweir		{
812*cdf0e10cSrcweir			if (( $dest eq $hostname ) || ( $dest =~ /^\s*\Q$hostname\E\\/ ))
813*cdf0e10cSrcweir			{
814*cdf0e10cSrcweir				# the value is the style
815*cdf0e10cSrcweir				my $style = $installer::globals::hostnametreestyles{$hostname};
816*cdf0e10cSrcweir				# the condition is saved in %installer::globals::treestyles
817*cdf0e10cSrcweir				my $condition = $installer::globals::treestyles{$style};
818*cdf0e10cSrcweir				# Saving condition to be added in table Property
819*cdf0e10cSrcweir				$installer::globals::usedtreeconditions{$condition} = 1;
820*cdf0e10cSrcweir				$condition = $condition . "=1";
821*cdf0e10cSrcweir				# saving this condition
822*cdf0e10cSrcweir				$installer::globals::treeconditions{$componentname} = $condition;
823*cdf0e10cSrcweir
824*cdf0e10cSrcweir				# saving also at the file, for usage in fileinfo
825*cdf0e10cSrcweir				$onefile->{'layer'} = $installer::globals::treelayername{$style};
826*cdf0e10cSrcweir			}
827*cdf0e10cSrcweir		}
828*cdf0e10cSrcweir	}
829*cdf0e10cSrcweir}
830*cdf0e10cSrcweir
831*cdf0e10cSrcweir############################################
832*cdf0e10cSrcweir# Collecting all short names, that are
833*cdf0e10cSrcweir# already used by the old database
834*cdf0e10cSrcweir############################################
835*cdf0e10cSrcweir
836*cdf0e10cSrcweirsub collect_shortnames_from_old_database
837*cdf0e10cSrcweir{
838*cdf0e10cSrcweir	my ($uniquefilenamehashref, $shortnameshashref) = @_;
839*cdf0e10cSrcweir
840*cdf0e10cSrcweir	foreach my $key ( keys %{$uniquefilenamehashref} )
841*cdf0e10cSrcweir	{
842*cdf0e10cSrcweir		my $value = $uniquefilenamehashref->{$key};  # syntax of $value: ($uniquename;$shortname)
843*cdf0e10cSrcweir
844*cdf0e10cSrcweir		if ( $value =~ /^\s*(.*?)\;\s*(.*?)\s*$/ )
845*cdf0e10cSrcweir		{
846*cdf0e10cSrcweir			my $shortstring = $2;
847*cdf0e10cSrcweir			$shortnameshashref->{$shortstring} = 1;	# adding the shortname to the array of all shortnames
848*cdf0e10cSrcweir		}
849*cdf0e10cSrcweir	}
850*cdf0e10cSrcweir}
851*cdf0e10cSrcweir
852*cdf0e10cSrcweir############################################
853*cdf0e10cSrcweir# Creating the file File.idt dynamically
854*cdf0e10cSrcweir############################################
855*cdf0e10cSrcweir
856*cdf0e10cSrcweirsub create_files_table
857*cdf0e10cSrcweir{
858*cdf0e10cSrcweir	my ($filesref, $allfilecomponentsref, $basedir, $allvariables, $uniquefilenamehashref, $allupdatesequenceshashref, $allupdatecomponentshashref, $allupdatefileorderhashref) = @_;
859*cdf0e10cSrcweir
860*cdf0e10cSrcweir	installer::logger::include_timestamp_into_logfile("Performance Info: File Table start");
861*cdf0e10cSrcweir
862*cdf0e10cSrcweir	# Structure of the files table:
863*cdf0e10cSrcweir	# File Component_ FileName FileSize Version Language Attributes Sequence
864*cdf0e10cSrcweir	# In this function, all components are created.
865*cdf0e10cSrcweir	#
866*cdf0e10cSrcweir	# $allfilecomponentsref is empty at the beginning
867*cdf0e10cSrcweir
868*cdf0e10cSrcweir	my $infoline;
869*cdf0e10cSrcweir
870*cdf0e10cSrcweir	my @allfiles = ();
871*cdf0e10cSrcweir	my @filetable = ();
872*cdf0e10cSrcweir	my @filehashtable = ();
873*cdf0e10cSrcweir	my %allfilecomponents = ();
874*cdf0e10cSrcweir	my $counter = 0;
875*cdf0e10cSrcweir
876*cdf0e10cSrcweir	if ( $^O =~ /cygwin/i ) { installer::worker::generate_cygwin_pathes($filesref); }
877*cdf0e10cSrcweir
878*cdf0e10cSrcweir	# The filenames must be collected because of uniqueness
879*cdf0e10cSrcweir	# 01-44-~1.DAT, 01-44-~2.DAT, ...
880*cdf0e10cSrcweir	# my @shortnames = ();
881*cdf0e10cSrcweir	my %shortnames = ();
882*cdf0e10cSrcweir
883*cdf0e10cSrcweir	if ( $installer::globals::updatedatabase ) { collect_shortnames_from_old_database($uniquefilenamehashref, \%shortnames); }
884*cdf0e10cSrcweir
885*cdf0e10cSrcweir	installer::windows::idtglobal::write_idt_header(\@filetable, "file");
886*cdf0e10cSrcweir	installer::windows::idtglobal::write_idt_header(\@filehashtable, "filehash");
887*cdf0e10cSrcweir
888*cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesref}; $i++ )
889*cdf0e10cSrcweir	{
890*cdf0e10cSrcweir		my %file = ();
891*cdf0e10cSrcweir
892*cdf0e10cSrcweir		my $onefile = ${$filesref}[$i];
893*cdf0e10cSrcweir
894*cdf0e10cSrcweir		my $styles = "";
895*cdf0e10cSrcweir		if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
896*cdf0e10cSrcweir		if (( $styles =~ /\bJAVAFILE\b/ ) && ( ! ($allvariables->{'JAVAPRODUCT'} ))) { next; }
897*cdf0e10cSrcweir
898*cdf0e10cSrcweir		$file{'Component_'} = get_file_component_name($onefile, $filesref);
899*cdf0e10cSrcweir		$file{'File'} = generate_unique_filename_for_filetable($onefile, $file{'Component_'}, $uniquefilenamehashref);
900*cdf0e10cSrcweir
901*cdf0e10cSrcweir		$onefile->{'uniquename'} = $file{'File'};
902*cdf0e10cSrcweir		$onefile->{'componentname'} = $file{'Component_'};
903*cdf0e10cSrcweir
904*cdf0e10cSrcweir		# Collecting all components
905*cdf0e10cSrcweir		# if (!(installer::existence::exists_in_array($file{'Component_'}, $allfilecomponentsref))) { push(@{$allfilecomponentsref}, $file{'Component_'}); }
906*cdf0e10cSrcweir
907*cdf0e10cSrcweir		if ( ! exists($allfilecomponents{$file{'Component_'}}) ) { $allfilecomponents{$file{'Component_'}} = 1; }
908*cdf0e10cSrcweir
909*cdf0e10cSrcweir		$file{'FileName'} = generate_filename_for_filetable($onefile, \%shortnames, $uniquefilenamehashref);
910*cdf0e10cSrcweir
911*cdf0e10cSrcweir		$file{'FileSize'} = get_filesize($onefile);
912*cdf0e10cSrcweir
913*cdf0e10cSrcweir		$file{'Version'} = get_fileversion($onefile, $allvariables, $styles);
914*cdf0e10cSrcweir
915*cdf0e10cSrcweir		$file{'Language'} = get_language_for_file($onefile);
916*cdf0e10cSrcweir
917*cdf0e10cSrcweir		if ( $styles =~ /\bDONT_PACK\b/ ) { $file{'Attributes'} = "8192"; }
918*cdf0e10cSrcweir		else { $file{'Attributes'} = "16384"; }
919*cdf0e10cSrcweir
920*cdf0e10cSrcweir		# $file{'Attributes'} = "16384"; 	# Sourcefile is packed
921*cdf0e10cSrcweir		# $file{'Attributes'} = "8192"; 	# Sourcefile is unpacked
922*cdf0e10cSrcweir
923*cdf0e10cSrcweir		$installer::globals::insert_file_at_end = 0;
924*cdf0e10cSrcweir		$counter++;
925*cdf0e10cSrcweir		$file{'Sequence'} = get_sequence_for_file($counter, $onefile, \%file, $allupdatesequenceshashref, $allupdatecomponentshashref, $allupdatefileorderhashref, \%allfilecomponents);
926*cdf0e10cSrcweir
927*cdf0e10cSrcweir		$onefile->{'sequencenumber'} = $file{'Sequence'};
928*cdf0e10cSrcweir
929*cdf0e10cSrcweir		my $oneline = $file{'File'} . "\t" . $file{'Component_'} . "\t" . $file{'FileName'} . "\t"
930*cdf0e10cSrcweir				. $file{'FileSize'} . "\t" . $file{'Version'} . "\t" . $file{'Language'} . "\t"
931*cdf0e10cSrcweir				. $file{'Attributes'} . "\t" . $file{'Sequence'} . "\n";
932*cdf0e10cSrcweir
933*cdf0e10cSrcweir		push(@filetable, $oneline);
934*cdf0e10cSrcweir
935*cdf0e10cSrcweir		if ( ! $installer::globals::insert_file_at_end ) { push(@allfiles, $onefile); }
936*cdf0e10cSrcweir
937*cdf0e10cSrcweir		# Collecting all component conditions
938*cdf0e10cSrcweir		if ( $onefile->{'ComponentCondition'} )
939*cdf0e10cSrcweir		{
940*cdf0e10cSrcweir			if ( ! exists($installer::globals::componentcondition{$file{'Component_'}}))
941*cdf0e10cSrcweir			{
942*cdf0e10cSrcweir				$installer::globals::componentcondition{$file{'Component_'}} = $onefile->{'ComponentCondition'};
943*cdf0e10cSrcweir			}
944*cdf0e10cSrcweir		}
945*cdf0e10cSrcweir
946*cdf0e10cSrcweir		# Collecting also all tree conditions for multilayer products
947*cdf0e10cSrcweir		get_tree_condition_for_component($onefile, $file{'Component_'});
948*cdf0e10cSrcweir
949*cdf0e10cSrcweir		# Collecting all component names, that have flag VERSION_INDEPENDENT_COMP_ID
950*cdf0e10cSrcweir		# This should be all components with constant API, for example URE
951*cdf0e10cSrcweir		if ( $styles =~ /\bVERSION_INDEPENDENT_COMP_ID\b/ )
952*cdf0e10cSrcweir		{
953*cdf0e10cSrcweir			$installer::globals::base_independent_components{$onefile->{'componentname'}} = 1;
954*cdf0e10cSrcweir		}
955*cdf0e10cSrcweir
956*cdf0e10cSrcweir		# Collecting all component ids, that are defined at files in scp project (should not be used anymore)
957*cdf0e10cSrcweir		if ( $onefile->{'CompID'} )
958*cdf0e10cSrcweir		{
959*cdf0e10cSrcweir			if ( ! exists($installer::globals::componentid{$onefile->{'componentname'}}))
960*cdf0e10cSrcweir			{
961*cdf0e10cSrcweir				$installer::globals::componentid{$onefile->{'componentname'}} = $onefile->{'CompID'};
962*cdf0e10cSrcweir			}
963*cdf0e10cSrcweir			else
964*cdf0e10cSrcweir			{
965*cdf0e10cSrcweir				if ( $installer::globals::componentid{$onefile->{'componentname'}} ne $onefile->{'CompID'} )
966*cdf0e10cSrcweir				{
967*cdf0e10cSrcweir					installer::exiter::exit_program("ERROR: There is already a ComponentID for component \"$onefile->{'componentname'}\" : \"$installer::globals::componentid{$onefile->{'componentname'}}\" . File \"$onefile->{'gid'}\" uses \"$onefile->{'CompID'}\" !", "create_files_table");
968*cdf0e10cSrcweir				}
969*cdf0e10cSrcweir			}
970*cdf0e10cSrcweir
971*cdf0e10cSrcweir			# Also checking vice versa. Is this ComponentID already used? If yes, is the componentname the same?
972*cdf0e10cSrcweir
973*cdf0e10cSrcweir			if ( ! exists($installer::globals::comparecomponentname{$onefile->{'CompID'}}))
974*cdf0e10cSrcweir			{
975*cdf0e10cSrcweir				$installer::globals::comparecomponentname{$onefile->{'CompID'}} = $onefile->{'componentname'};
976*cdf0e10cSrcweir			}
977*cdf0e10cSrcweir			else
978*cdf0e10cSrcweir			{
979*cdf0e10cSrcweir				if ( $installer::globals::comparecomponentname{$onefile->{'CompID'}} ne $onefile->{'componentname'} )
980*cdf0e10cSrcweir				{
981*cdf0e10cSrcweir					installer::exiter::exit_program("ERROR: There is already a component for ComponentID \"$onefile->{'CompID'}\" : \"$installer::globals::comparecomponentname{$onefile->{'CompID'}}\" . File \"$onefile->{'gid'}\" has same component id but is included in component \"$onefile->{'componentname'}\" !", "create_files_table");
982*cdf0e10cSrcweir				}
983*cdf0e10cSrcweir			}
984*cdf0e10cSrcweir		}
985*cdf0e10cSrcweir
986*cdf0e10cSrcweir		# Collecting all language specific conditions
987*cdf0e10cSrcweir		# if ( $onefile->{'haslanguagemodule'} )
988*cdf0e10cSrcweir		if ( $onefile->{'ismultilingual'} )
989*cdf0e10cSrcweir		{
990*cdf0e10cSrcweir			if ( $onefile->{'ComponentCondition'} ) { installer::exiter::exit_program("ERROR: Cannot set language condition. There is already another component condition for file $onefile->{'gid'}: \"$onefile->{'ComponentCondition'}\" !", "create_files_table"); }
991*cdf0e10cSrcweir
992*cdf0e10cSrcweir			if ( $onefile->{'specificlanguage'} eq "" ) { installer::exiter::exit_program("ERROR: There is no specific language for file at language module: $onefile->{'gid'} !", "create_files_table"); }
993*cdf0e10cSrcweir			my $locallanguage = $onefile->{'specificlanguage'};
994*cdf0e10cSrcweir			my $property = "IS" . $file{'Language'};
995*cdf0e10cSrcweir			my $value = 1;
996*cdf0e10cSrcweir			my $condition = $property . "=" . $value;
997*cdf0e10cSrcweir
998*cdf0e10cSrcweir			$onefile->{'ComponentCondition'} = $condition;
999*cdf0e10cSrcweir
1000*cdf0e10cSrcweir			if ( exists($installer::globals::componentcondition{$file{'Component_'}}))
1001*cdf0e10cSrcweir			{
1002*cdf0e10cSrcweir				if ( $installer::globals::componentcondition{$file{'Component_'}} ne $condition ) { installer::exiter::exit_program("ERROR: There is already another component condition for file $onefile->{'gid'}: \"$installer::globals::componentcondition{$file{'Component_'}}\" and \"$condition\" !", "create_files_table"); }
1003*cdf0e10cSrcweir			}
1004*cdf0e10cSrcweir			else
1005*cdf0e10cSrcweir			{
1006*cdf0e10cSrcweir				$installer::globals::componentcondition{$file{'Component_'}} = $condition;
1007*cdf0e10cSrcweir			}
1008*cdf0e10cSrcweir
1009*cdf0e10cSrcweir			# collecting all properties for table Property
1010*cdf0e10cSrcweir			if ( ! exists($installer::globals::languageproperties{$property}) ) { $installer::globals::languageproperties{$property} = $value; }
1011*cdf0e10cSrcweir		}
1012*cdf0e10cSrcweir
1013*cdf0e10cSrcweir		if ( $installer::globals::prepare_winpatch )
1014*cdf0e10cSrcweir		{
1015*cdf0e10cSrcweir			my $path = $onefile->{'sourcepath'};
1016*cdf0e10cSrcweir			if ( $^O =~ /cygwin/i ) { $path = $onefile->{'cyg_sourcepath'}; }
1017*cdf0e10cSrcweir
1018*cdf0e10cSrcweir			open(FILE, $path) or die "ERROR: Can't open $path for creating file hash";
1019*cdf0e10cSrcweir			binmode(FILE);
1020*cdf0e10cSrcweir			my $hashinfo = pack("l", 20);
1021*cdf0e10cSrcweir			$hashinfo .= Digest::MD5->new->addfile(*FILE)->digest;
1022*cdf0e10cSrcweir
1023*cdf0e10cSrcweir			my @i = unpack ('x[l]l4', $hashinfo);
1024*cdf0e10cSrcweir			$oneline = $file{'File'} . "\t" .
1025*cdf0e10cSrcweir				"0" . "\t" .
1026*cdf0e10cSrcweir				$i[0] . "\t" .
1027*cdf0e10cSrcweir				$i[1] . "\t" .
1028*cdf0e10cSrcweir				$i[2] . "\t" .
1029*cdf0e10cSrcweir				$i[3] . "\n";
1030*cdf0e10cSrcweir			push (@filehashtable, $oneline);
1031*cdf0e10cSrcweir		}
1032*cdf0e10cSrcweir
1033*cdf0e10cSrcweir		# Saving the sequence number in a hash with uniquefilename as key.
1034*cdf0e10cSrcweir		# This is used for better performance in "save_packorder"
1035*cdf0e10cSrcweir		$installer::globals::uniquefilenamesequence{$onefile->{'uniquename'}} = $onefile->{'sequencenumber'};
1036*cdf0e10cSrcweir
1037*cdf0e10cSrcweir		# Special handling for files in PREDEFINED_OSSHELLNEWDIR. These components
1038*cdf0e10cSrcweir		# need as KeyPath a RegistryItem in HKCU
1039*cdf0e10cSrcweir		my $destdir = "";
1040*cdf0e10cSrcweir		if ( $onefile->{'Dir'} ) { $destdir = $onefile->{'Dir'}; }
1041*cdf0e10cSrcweir
1042*cdf0e10cSrcweir		if (( $destdir =~ /\bPREDEFINED_OSSHELLNEWDIR\b/ ) || ( $onefile->{'needs_user_registry_key'} ))
1043*cdf0e10cSrcweir		{
1044*cdf0e10cSrcweir			my $keypath = generate_registry_keypath($onefile);
1045*cdf0e10cSrcweir			$onefile->{'userregkeypath'} = $keypath;
1046*cdf0e10cSrcweir			push(@installer::globals::userregistrycollector, $onefile);
1047*cdf0e10cSrcweir			$installer::globals::addeduserregitrykeys = 1;
1048*cdf0e10cSrcweir		}
1049*cdf0e10cSrcweir	}
1050*cdf0e10cSrcweir
1051*cdf0e10cSrcweir	# putting content from %allfilecomponents to $allfilecomponentsref for later usage
1052*cdf0e10cSrcweir	foreach $localkey (keys %allfilecomponents ) { push( @{$allfilecomponentsref}, $localkey); }
1053*cdf0e10cSrcweir
1054*cdf0e10cSrcweir	my $filetablename = $basedir . $installer::globals::separator . "File.idt";
1055*cdf0e10cSrcweir	installer::files::save_file($filetablename ,\@filetable);
1056*cdf0e10cSrcweir	$infoline = "\nCreated idt file: $filetablename\n";
1057*cdf0e10cSrcweir	push(@installer::globals::logfileinfo, $infoline);
1058*cdf0e10cSrcweir
1059*cdf0e10cSrcweir	installer::logger::include_timestamp_into_logfile("Performance Info: File Table end");
1060*cdf0e10cSrcweir
1061*cdf0e10cSrcweir	my $filehashtablename = $basedir . $installer::globals::separator . "MsiFileHash.idt";
1062*cdf0e10cSrcweir	installer::files::save_file($filehashtablename ,\@filehashtable);
1063*cdf0e10cSrcweir	$infoline = "\nCreated idt file: $filehashtablename\n";
1064*cdf0e10cSrcweir	push(@installer::globals::logfileinfo, $infoline);
1065*cdf0e10cSrcweir
1066*cdf0e10cSrcweir	# Now the new files can be added to the files collector (only in update packaging processes)
1067*cdf0e10cSrcweir	if ( $installer::globals::newfilesexist )
1068*cdf0e10cSrcweir	{
1069*cdf0e10cSrcweir		foreach my $seq (sort keys %installer::globals::newfilescollector) { push(@allfiles, $installer::globals::newfilescollector{$seq}) }
1070*cdf0e10cSrcweir	}
1071*cdf0e10cSrcweir
1072*cdf0e10cSrcweir	return \@allfiles;
1073*cdf0e10cSrcweir}
1074*cdf0e10cSrcweir
1075*cdf0e10cSrcweir1;
1076