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