19780544fSAndrew Rist#**************************************************************
29780544fSAndrew Rist#
39780544fSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
49780544fSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
59780544fSAndrew Rist#  distributed with this work for additional information
69780544fSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
79780544fSAndrew Rist#  to you under the Apache License, Version 2.0 (the
89780544fSAndrew Rist#  "License"); you may not use this file except in compliance
99780544fSAndrew Rist#  with the License.  You may obtain a copy of the License at
109780544fSAndrew Rist#
119780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
129780544fSAndrew Rist#
139780544fSAndrew Rist#  Unless required by applicable law or agreed to in writing,
149780544fSAndrew Rist#  software distributed under the License is distributed on an
159780544fSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169780544fSAndrew Rist#  KIND, either express or implied.  See the License for the
179780544fSAndrew Rist#  specific language governing permissions and limitations
189780544fSAndrew Rist#  under the License.
199780544fSAndrew Rist#
209780544fSAndrew Rist#**************************************************************
219780544fSAndrew Rist
229780544fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweirpackage installer::windows::registry;
25cdf0e10cSrcweir
26cdf0e10cSrcweiruse installer::files;
27cdf0e10cSrcweiruse installer::globals;
28cdf0e10cSrcweiruse installer::worker;
2919d58b3aSEike Rathkeuse installer::windows::msiglobal;
30cdf0e10cSrcweiruse installer::windows::idtglobal;
31cdf0e10cSrcweir
32cdf0e10cSrcweir#####################################################
33cdf0e10cSrcweir# Generating the component name from a registryitem
34cdf0e10cSrcweir#####################################################
35cdf0e10cSrcweir
36cdf0e10cSrcweirsub get_registry_component_name
37cdf0e10cSrcweir{
38cdf0e10cSrcweir	my ($registryref, $allvariables) = @_;
39cdf0e10cSrcweir
40cdf0e10cSrcweir	# In this function exists the rule to create components from registryitems
41cdf0e10cSrcweir	# Rule:
42cdf0e10cSrcweir	# The componentname can be directly taken from the ModuleID.
43cdf0e10cSrcweir	# All registryitems belonging to one module can get the same component.
44cdf0e10cSrcweir
45cdf0e10cSrcweir	my $componentname = "";
46cdf0e10cSrcweir	my $isrootmodule = 0;
47cdf0e10cSrcweir
48cdf0e10cSrcweir	if ( $registryref->{'ModuleID'} ) { $componentname = $registryref->{'ModuleID'}; }
49cdf0e10cSrcweir
50cdf0e10cSrcweir	$componentname =~ s/\\/\_/g;
51cdf0e10cSrcweir	$componentname =~ s/\//\_/g;
52cdf0e10cSrcweir	$componentname =~ s/\-/\_/g;
53cdf0e10cSrcweir	$componentname =~ s/\_\s*$//g;
54cdf0e10cSrcweir
55cdf0e10cSrcweir	$componentname = lc($componentname);	# componentnames always lowercase
56cdf0e10cSrcweir
57cdf0e10cSrcweir	if ( $componentname eq "gid_module_root" ) { $isrootmodule = 1; }
58cdf0e10cSrcweir
59cdf0e10cSrcweir	# Attention: Maximum length for the componentname is 72
60cdf0e10cSrcweir
61cdf0e10cSrcweir	# identifying this component as registryitem component
62cdf0e10cSrcweir	$componentname = "registry_" . $componentname;
63cdf0e10cSrcweir
64cdf0e10cSrcweir	$componentname =~ s/gid_module_/g_m_/g;
65cdf0e10cSrcweir	$componentname =~ s/_optional_/_o_/g;
66cdf0e10cSrcweir	$componentname =~ s/_javafilter_/_jf_/g;
67cdf0e10cSrcweir
68cdf0e10cSrcweir	# This componentname must be more specific
69cdf0e10cSrcweir	my $addon = "_";
70cdf0e10cSrcweir	if ( $allvariables->{'PRODUCTNAME'} ) { $addon = $addon . $allvariables->{'PRODUCTNAME'}; }
71cdf0e10cSrcweir	if ( $allvariables->{'PRODUCTVERSION'} ) { $addon = $addon . $allvariables->{'PRODUCTVERSION'}; }
72cdf0e10cSrcweir	$addon = lc($addon);
73cdf0e10cSrcweir	$addon =~ s/ //g;
74cdf0e10cSrcweir	$addon =~ s/-//g;
75cdf0e10cSrcweir	$addon =~ s/\.//g;
76cdf0e10cSrcweir
77cdf0e10cSrcweir	my $styles = "";
78cdf0e10cSrcweir	if ( $registryref->{'Styles'} ) { $styles = $registryref->{'Styles'}; }
79cdf0e10cSrcweir
80cdf0e10cSrcweir	$componentname = $componentname . $addon;
81cdf0e10cSrcweir
82cdf0e10cSrcweir	if (( $styles =~ /\bLANGUAGEPACK\b/ ) && ( $installer::globals::languagepack )) { $componentname = $componentname . "_lang"; }
83cdf0e10cSrcweir	if ( $styles =~ /\bALWAYS_REQUIRED\b/ ) { $componentname = $componentname . "_forced"; }
84cdf0e10cSrcweir
85cdf0e10cSrcweir	# Attention: Maximum length for the componentname is 72
86cdf0e10cSrcweir	# %installer::globals::allregistrycomponents_in_this_database_ : resetted for each database
87cdf0e10cSrcweir	# %installer::globals::allregistrycomponents_ : not resetted for each database
88cdf0e10cSrcweir	# Component strings must be unique for the complete product, because they are used for
89cdf0e10cSrcweir	# the creation of the globally unique identifier.
90cdf0e10cSrcweir
91cdf0e10cSrcweir	my $fullname = $componentname;  # This can be longer than 72
92cdf0e10cSrcweir
93cdf0e10cSrcweir	if (( exists($installer::globals::allregistrycomponents_{$fullname}) ) && ( ! exists($installer::globals::allregistrycomponents_in_this_database_{$fullname}) ))
94cdf0e10cSrcweir	{
95cdf0e10cSrcweir		# This is not allowed: One component cannot be installed with different packages.
96cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: Windows registry component \"$fullname\" is already included into another package. This is not allowed.", "get_registry_component_name");
97cdf0e10cSrcweir	}
98cdf0e10cSrcweir
99cdf0e10cSrcweir	if ( exists($installer::globals::allregistrycomponents_{$fullname}) )
100cdf0e10cSrcweir	{
101cdf0e10cSrcweir		$componentname = $installer::globals::allregistrycomponents_{$fullname};
102cdf0e10cSrcweir	}
103cdf0e10cSrcweir	else
104cdf0e10cSrcweir	{
10519d58b3aSEike Rathke		if ( length($componentname) > 70 )
106cdf0e10cSrcweir		{
107cdf0e10cSrcweir			$componentname = generate_new_short_registrycomponentname($componentname); # This has to be unique for the complete product, not only one package
108cdf0e10cSrcweir		}
109cdf0e10cSrcweir
110cdf0e10cSrcweir		$installer::globals::allregistrycomponents_{$fullname} = $componentname;
111cdf0e10cSrcweir		$installer::globals::allregistrycomponents_in_this_database_{$fullname} = 1;
112cdf0e10cSrcweir	}
113cdf0e10cSrcweir
114cdf0e10cSrcweir	if ( $isrootmodule ) { $installer::globals::registryrootcomponent = $componentname; }
115cdf0e10cSrcweir
116cdf0e10cSrcweir	return $componentname;
117cdf0e10cSrcweir}
118cdf0e10cSrcweir
119cdf0e10cSrcweir#########################################################
120cdf0e10cSrcweir# Create a shorter version of a long component name,
121cdf0e10cSrcweir# because maximum length in msi database is 72.
122cdf0e10cSrcweir# Attention: In multi msi installation sets, the short
123cdf0e10cSrcweir# names have to be unique over all packages, because
124cdf0e10cSrcweir# this string is used to create the globally unique id
125cdf0e10cSrcweir# -> no resetting of
126cdf0e10cSrcweir# %installer::globals::allshortregistrycomponents
127cdf0e10cSrcweir# after a package was created.
128cdf0e10cSrcweir#########################################################
129cdf0e10cSrcweir
130cdf0e10cSrcweirsub generate_new_short_registrycomponentname
131cdf0e10cSrcweir{
132cdf0e10cSrcweir	my ($componentname) = @_;
13319d58b3aSEike Rathke
134cdf0e10cSrcweir	my $startversion = substr($componentname, 0, 60); # taking only the first 60 characters
13519d58b3aSEike Rathke	my $subid = installer::windows::msiglobal::calculate_id($componentname, 9); # taking only the first 9 digits
13619d58b3aSEike Rathke	my $shortcomponentname = $startversion . "_" . $subid;
137cdf0e10cSrcweir
13819d58b3aSEike Rathke	if ( exists($installer::globals::allshortregistrycomponents{$shortcomponentname}) ) { installer::exiter::exit_program("Failed to create unique component name: \"$shortcomponentname\"", "generate_new_short_registrycomponentname"); }
139cdf0e10cSrcweir
140cdf0e10cSrcweir	$installer::globals::allshortregistrycomponents{$shortcomponentname} = 1;
141cdf0e10cSrcweir
142cdf0e10cSrcweir	return $shortcomponentname;
143cdf0e10cSrcweir}
144cdf0e10cSrcweir
145cdf0e10cSrcweir##############################################################
146cdf0e10cSrcweir# Returning identifier for registry table.
147cdf0e10cSrcweir##############################################################
148cdf0e10cSrcweir
149cdf0e10cSrcweirsub get_registry_identifier
150cdf0e10cSrcweir{
151cdf0e10cSrcweir	my ($registry) = @_;
152cdf0e10cSrcweir
153cdf0e10cSrcweir	my $identifier = "";
154cdf0e10cSrcweir
155cdf0e10cSrcweir	if ( $registry->{'gid'} ) { $identifier = $registry->{'gid'}; }
156cdf0e10cSrcweir
157cdf0e10cSrcweir	$identifier = lc($identifier);	# always lower case
158cdf0e10cSrcweir
159cdf0e10cSrcweir	# Attention: Maximum length is 72
160cdf0e10cSrcweir
161cdf0e10cSrcweir	$identifier =~ s/gid_regitem_/g_r_/;
162cdf0e10cSrcweir	$identifier =~ s/_soffice_/_s_/;
163cdf0e10cSrcweir	$identifier =~ s/_clsid_/_c_/;
164cdf0e10cSrcweir	$identifier =~ s/_currentversion_/_cv_/;
165cdf0e10cSrcweir	$identifier =~ s/_microsoft_/_ms_/;
166cdf0e10cSrcweir	$identifier =~ s/_manufacturer_/_mf_/;
167cdf0e10cSrcweir	$identifier =~ s/_productname_/_pn_/;
168cdf0e10cSrcweir	$identifier =~ s/_productversion_/_pv_/;
169cdf0e10cSrcweir	$identifier =~ s/_staroffice_/_so_/;
170cdf0e10cSrcweir	$identifier =~ s/_software_/_sw_/;
171cdf0e10cSrcweir	$identifier =~ s/_capabilities_/_cap_/;
172cdf0e10cSrcweir	$identifier =~ s/_classpath_/_cp_/;
173cdf0e10cSrcweir	$identifier =~ s/_extension_/_ex_/;
174cdf0e10cSrcweir	$identifier =~ s/_fileassociations_/_fa_/;
175cdf0e10cSrcweir	$identifier =~ s/_propertysheethandlers_/_psh_/;
176cdf0e10cSrcweir	$identifier =~ s/__/_/g;
177cdf0e10cSrcweir
178cdf0e10cSrcweir	# Saving this in the registry collector
179cdf0e10cSrcweir
180cdf0e10cSrcweir	$registry->{'uniquename'} = $identifier;
181cdf0e10cSrcweir
182cdf0e10cSrcweir	return $identifier;
183cdf0e10cSrcweir}
184cdf0e10cSrcweir
185cdf0e10cSrcweir##################################################################
186cdf0e10cSrcweir# Returning root value for registry table.
187cdf0e10cSrcweir##################################################################
188cdf0e10cSrcweir
189cdf0e10cSrcweirsub get_registry_root
190cdf0e10cSrcweir{
191cdf0e10cSrcweir	my ($registry) = @_;
192cdf0e10cSrcweir
193cdf0e10cSrcweir	my $rootvalue = 0;	# Default: Parent is KKEY_CLASSES_ROOT
194cdf0e10cSrcweir	my $scproot = "";
195cdf0e10cSrcweir
196cdf0e10cSrcweir	if ( $registry->{'ParentID'} ) { $scproot = $registry->{'ParentID'}; }
197cdf0e10cSrcweir
198cdf0e10cSrcweir	if ( $scproot eq "PREDEFINED_HKEY_LOCAL_MACHINE" ) { $rootvalue = -1; }
199cdf0e10cSrcweir
200cdf0e10cSrcweir	if ( $scproot eq "PREDEFINED_HKEY_CLASSES_ROOT" ) { $rootvalue = 0; }
201cdf0e10cSrcweir
202cdf0e10cSrcweir	if ( $scproot eq "PREDEFINED_HKEY_CURRENT_USER_ONLY" ) { $rootvalue = 1; }
203cdf0e10cSrcweir
204cdf0e10cSrcweir	if ( $scproot eq "PREDEFINED_HKEY_LOCAL_MACHINE_ONLY" ) { $rootvalue = 2; }
205cdf0e10cSrcweir
206cdf0e10cSrcweir	return $rootvalue;
207cdf0e10cSrcweir}
208cdf0e10cSrcweir
209cdf0e10cSrcweir##############################################################
210cdf0e10cSrcweir# Returning key for registry table.
211cdf0e10cSrcweir##############################################################
212cdf0e10cSrcweir
213cdf0e10cSrcweirsub get_registry_key
214cdf0e10cSrcweir{
215cdf0e10cSrcweir	my ($registry, $allvariableshashref) = @_;
216cdf0e10cSrcweir
217cdf0e10cSrcweir	my $key = "";
218cdf0e10cSrcweir
219cdf0e10cSrcweir	if ( $registry->{'Subkey'} ) { $key = $registry->{'Subkey'}; }
220cdf0e10cSrcweir
221cdf0e10cSrcweir	if ( $key =~ /\%/ ) { $key = installer::worker::replace_variables_in_string($key, $allvariableshashref); }
222cdf0e10cSrcweir
223cdf0e10cSrcweir	return $key;
224cdf0e10cSrcweir}
225cdf0e10cSrcweir
226cdf0e10cSrcweir##############################################################
227cdf0e10cSrcweir# Returning name for registry table.
228cdf0e10cSrcweir##############################################################
229cdf0e10cSrcweir
230cdf0e10cSrcweirsub get_registry_name
231cdf0e10cSrcweir{
232cdf0e10cSrcweir	my ($registry, $allvariableshashref) = @_;
233cdf0e10cSrcweir
234cdf0e10cSrcweir	my $name = "";
235cdf0e10cSrcweir
236cdf0e10cSrcweir	if ( $registry->{'Name'} ) { $name = $registry->{'Name'}; }
237cdf0e10cSrcweir
238cdf0e10cSrcweir	if ( $name =~ /\%/ ) { $name = installer::worker::replace_variables_in_string($name, $allvariableshashref); }
239cdf0e10cSrcweir
240cdf0e10cSrcweir	return $name;
241cdf0e10cSrcweir}
242cdf0e10cSrcweir
243cdf0e10cSrcweir##############################################################
244cdf0e10cSrcweir# Returning value for registry table.
245cdf0e10cSrcweir##############################################################
246cdf0e10cSrcweir
247cdf0e10cSrcweirsub get_registry_value
248cdf0e10cSrcweir{
249cdf0e10cSrcweir	my ($registry, $allvariableshashref) = @_;
250cdf0e10cSrcweir
251cdf0e10cSrcweir	my $value = "";
252cdf0e10cSrcweir
253cdf0e10cSrcweir	if ( $registry->{'Value'} ) { $value = $registry->{'Value'}; }
254cdf0e10cSrcweir
255cdf0e10cSrcweir	$value =~ s/\\\"/\"/g;	# no more masquerading of '"'
256cdf0e10cSrcweir	$value =~ s/\\\\\s*$/\\/g;	# making "\\" at end of value to "\"
257cdf0e10cSrcweir	$value =~ s/\<progpath\>/\[INSTALLLOCATION\]/;
258cdf0e10cSrcweir	$value =~ s/\[INSTALLLOCATION\]\\/\[INSTALLLOCATION\]/;	# removing "\" after "[INSTALLLOCATION]"
259cdf0e10cSrcweir
260cdf0e10cSrcweir	if ( $value =~ /\%/ ) { $value = installer::worker::replace_variables_in_string($value, $allvariableshashref); }
261cdf0e10cSrcweir
262cdf0e10cSrcweir	return $value;
263cdf0e10cSrcweir}
264cdf0e10cSrcweir
265cdf0e10cSrcweir##############################################################
266cdf0e10cSrcweir# Returning 64 bit value for registry table.
267cdf0e10cSrcweir##############################################################
268cdf0e10cSrcweir
269cdf0e10cSrcweirsub get_registry_val64
270cdf0e10cSrcweir{
271cdf0e10cSrcweir	my ($registry, $allvariableshashref) = @_;
272cdf0e10cSrcweir
273cdf0e10cSrcweir	my $value = "";
274cdf0e10cSrcweir
275cdf0e10cSrcweir	if ( $registry->{'Val64'} ) { $value = $registry->{'Val64'}; }
276cdf0e10cSrcweir
277cdf0e10cSrcweir	$value =~ s/\\\"/\"/g;	# no more masquerading of '"'
278cdf0e10cSrcweir	$value =~ s/\\\\\s*$/\\/g;	# making "\\" at end of value to "\"
279cdf0e10cSrcweir	$value =~ s/\<progpath\>/\[INSTALLLOCATION\]/;
280cdf0e10cSrcweir	$value =~ s/\[INSTALLLOCATION\]\\/\[INSTALLLOCATION\]/;	# removing "\" after "[INSTALLLOCATION]"
281cdf0e10cSrcweir
282cdf0e10cSrcweir	if ( $value =~ /\%/ ) { $value = installer::worker::replace_variables_in_string($value, $allvariableshashref); }
283cdf0e10cSrcweir
284cdf0e10cSrcweir	return $value;
285cdf0e10cSrcweir}
286cdf0e10cSrcweir
287cdf0e10cSrcweir##############################################################
288cdf0e10cSrcweir# Returning component for registry table.
289cdf0e10cSrcweir##############################################################
290cdf0e10cSrcweir
291cdf0e10cSrcweirsub get_registry_component
292cdf0e10cSrcweir{
293cdf0e10cSrcweir	my ($registry, $allvariables) = @_;
294cdf0e10cSrcweir
295cdf0e10cSrcweir	# All registry items belonging to one module can
296cdf0e10cSrcweir	# be included into one component
297cdf0e10cSrcweir
298cdf0e10cSrcweir	my $componentname = get_registry_component_name($registry, $allvariables);
299cdf0e10cSrcweir
300cdf0e10cSrcweir	# saving componentname in the registryitem collector
301cdf0e10cSrcweir
302cdf0e10cSrcweir	$registry->{'componentname'} = $componentname;
303cdf0e10cSrcweir
304cdf0e10cSrcweir	return $componentname;
305cdf0e10cSrcweir}
306cdf0e10cSrcweir
307cdf0e10cSrcweir######################################################
308cdf0e10cSrcweir# Adding the content of
309cdf0e10cSrcweir# @installer::globals::userregistrycollector
310cdf0e10cSrcweir# to the registry table. The content was collected
311cdf0e10cSrcweir# in create_files_table() in file.pm.
312cdf0e10cSrcweir######################################################
313cdf0e10cSrcweir
314cdf0e10cSrcweirsub add_userregs_to_registry_table
315cdf0e10cSrcweir{
316cdf0e10cSrcweir	my ( $registrytable, $allvariables ) = @_;
317cdf0e10cSrcweir
318cdf0e10cSrcweir	for ( my $i = 0; $i <= $#installer::globals::userregistrycollector; $i++ )
319cdf0e10cSrcweir	{
320cdf0e10cSrcweir		my $onefile = $installer::globals::userregistrycollector[$i];
321cdf0e10cSrcweir
322cdf0e10cSrcweir		my $styles = "";
323cdf0e10cSrcweir		if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
324cdf0e10cSrcweir
325cdf0e10cSrcweir		my %registry = ();
326cdf0e10cSrcweir
327cdf0e10cSrcweir		$registry{'Registry'} = $onefile->{'userregkeypath'};
328cdf0e10cSrcweir		$registry{'Root'} = "1";  # always HKCU
329cdf0e10cSrcweir		$registry{'Key'} = "Software\\$allvariables->{'MANUFACTURER'}\\$allvariables->{'PRODUCTNAME'} $allvariables->{'PRODUCTVERSION'}\\";
330cdf0e10cSrcweir		if ( $onefile->{'needs_user_registry_key'} ) { $registry{'Key'} = $registry{'Key'} . "StartMenu"; }
331cdf0e10cSrcweir		else { $registry{'Key'} = $registry{'Key'} . "ShellNew"; }
332cdf0e10cSrcweir		$registry{'Name'} = $onefile->{'Name'};
333cdf0e10cSrcweir		$registry{'Value'} = "1";
334cdf0e10cSrcweir		$registry{'Component_'} = $onefile->{'componentname'};
335cdf0e10cSrcweir
336cdf0e10cSrcweir		my $oneline = $registry{'Registry'} . "\t" . $registry{'Root'} . "\t" . $registry{'Key'} . "\t"
337cdf0e10cSrcweir					. $registry{'Name'} . "\t" . $registry{'Value'} . "\t" . $registry{'Component_'} . "\n";
338cdf0e10cSrcweir
339cdf0e10cSrcweir		push(@{$registrytable}, $oneline);
340cdf0e10cSrcweir	}
341cdf0e10cSrcweir}
342cdf0e10cSrcweir
343cdf0e10cSrcweir######################################################
344cdf0e10cSrcweir# Creating the file Registry.idt dynamically
345cdf0e10cSrcweir# Content:
346cdf0e10cSrcweir# Registry Root Key Name Value Component_
347cdf0e10cSrcweir######################################################
348cdf0e10cSrcweir
349cdf0e10cSrcweirsub create_registry_table
350cdf0e10cSrcweir{
351cdf0e10cSrcweir	my ($registryref, $allregistrycomponentsref, $basedir, $languagesarrayref, $allvariableshashref) = @_;
352cdf0e10cSrcweir
353*1ba1fd99SAndre Fischer    my %table_data = ();
354*1ba1fd99SAndre Fischer	foreach my $onelanguage (@$languagesarrayref)
355cdf0e10cSrcweir	{
356cdf0e10cSrcweir
357cdf0e10cSrcweir		my @registrytable = ();
358cdf0e10cSrcweir		my @reg64table = ();
359cdf0e10cSrcweir
360cdf0e10cSrcweir		installer::windows::idtglobal::write_idt_header(\@registrytable, "registry");
361cdf0e10cSrcweir		installer::windows::idtglobal::write_idt_header(\@reg64table, "reg64");
362*1ba1fd99SAndre Fischer        my $table_items = [];
363*1ba1fd99SAndre Fischer		foreach my $oneregistry (@$registryref)
364cdf0e10cSrcweir		{
365cdf0e10cSrcweir			# Controlling the language!
366cdf0e10cSrcweir			# Only language independent folderitems or folderitems with the correct language
367cdf0e10cSrcweir			# will be included into the table
368cdf0e10cSrcweir
369*1ba1fd99SAndre Fischer			next if $oneregistry->{'ismultilingual'}
370*1ba1fd99SAndre Fischer                && $oneregistry->{'specificlanguage'} ne $onelanguage;
371cdf0e10cSrcweir
372cdf0e10cSrcweir			my %registry = ();
373cdf0e10cSrcweir
374cdf0e10cSrcweir			$registry{'Registry'} = get_registry_identifier($oneregistry);
375cdf0e10cSrcweir			$registry{'Root'} = get_registry_root($oneregistry);
376cdf0e10cSrcweir			$registry{'Key'} = get_registry_key($oneregistry, $allvariableshashref);
377cdf0e10cSrcweir			$registry{'Name'} = get_registry_name($oneregistry, $allvariableshashref);
378cdf0e10cSrcweir			$registry{'Value'} = get_registry_value($oneregistry, $allvariableshashref);
379cdf0e10cSrcweir			$registry{'Val64'} = get_registry_val64($oneregistry, $allvariableshashref);
380*1ba1fd99SAndre Fischer            my $component_name = get_registry_component_name($oneregistry, $allvariableshashref);
381*1ba1fd99SAndre Fischer            $oneregistry->{'componentname'} = $component_name;
382*1ba1fd99SAndre Fischer			$registry{'Component_'} = $component_name;
383cdf0e10cSrcweir
384cdf0e10cSrcweir			# Collecting all components
385cdf0e10cSrcweir			if (!(installer::existence::exists_in_array($registry{'Component_'}, $allregistrycomponentsref)))
386cdf0e10cSrcweir			{
387cdf0e10cSrcweir				push(@{$allregistrycomponentsref}, $registry{'Component_'});
388cdf0e10cSrcweir			}
389cdf0e10cSrcweir
390cdf0e10cSrcweir			# Collecting all components with DONT_DELETE style
391*1ba1fd99SAndre Fischer			my $style = $oneregistry->{'Styles'} // "";
392*1ba1fd99SAndre Fischer            $registry{'styles'} = $style;
393*1ba1fd99SAndre Fischer
394*1ba1fd99SAndre Fischer			if ( $style =~ /\bDONT_DELETE\b/ )
395*1ba1fd99SAndre Fischer            {
396*1ba1fd99SAndre Fischer                $installer::globals::dontdeletecomponents{$component_name} = 1;
397*1ba1fd99SAndre Fischer            }
398cdf0e10cSrcweir
399cdf0e10cSrcweir			# Saving upgradekey to write this into setup.ini for minor upgrades
400*1ba1fd99SAndre Fischer			if ( $style =~ /\bUPGRADEKEY\b/ )
401*1ba1fd99SAndre Fischer            {
402*1ba1fd99SAndre Fischer                $installer::globals::minorupgradekey = $registry{'Key'};
403*1ba1fd99SAndre Fischer            }
404cdf0e10cSrcweir
405cdf0e10cSrcweir			# Collecting all registry components with ALWAYS_REQUIRED style
406cdf0e10cSrcweir			if ( ! ( $style =~ /\bALWAYS_REQUIRED\b/ ))
407cdf0e10cSrcweir			{
408cdf0e10cSrcweir				# Setting a component condition for unforced registry components!
409cdf0e10cSrcweir				# Only write into registry, if WRITE_REGISTRY is set.
410cdf0e10cSrcweir				if ( $oneregistry->{'ComponentCondition'} ) { $oneregistry->{'ComponentCondition'} = "(" . $oneregistry->{'ComponentCondition'} . ") AND (WRITE_REGISTRY=1)"; }
411cdf0e10cSrcweir				else { $oneregistry->{'ComponentCondition'} = "WRITE_REGISTRY=1"; }
412cdf0e10cSrcweir			}
413cdf0e10cSrcweir
414cdf0e10cSrcweir			# Collecting all component conditions
415cdf0e10cSrcweir			if ( $oneregistry->{'ComponentCondition'} )
416cdf0e10cSrcweir			{
417cdf0e10cSrcweir				if ( ! exists($installer::globals::componentcondition{$registry{'Component_'}}))
418cdf0e10cSrcweir				{
419cdf0e10cSrcweir					$installer::globals::componentcondition{$registry{'Component_'}} = $oneregistry->{'ComponentCondition'};
420cdf0e10cSrcweir				}
421cdf0e10cSrcweir			}
422cdf0e10cSrcweir
423cdf0e10cSrcweir			my $oneline = $registry{'Registry'} . "\t" . $registry{'Root'} . "\t" . $registry{'Key'} . "\t"
424cdf0e10cSrcweir						. $registry{'Name'} . "\t" . $registry{'Value'} . "\t" . $registry{'Component_'} . "\n";
425cdf0e10cSrcweir
426cdf0e10cSrcweir			my $oneline64 = $registry{'Registry'} . "\t" . $registry{'Root'} . "\t" . $registry{'Key'} . "\t"
427cdf0e10cSrcweir						. $registry{'Name'} . "\t" . $registry{'Val64'} . "\t" . $registry{'Component_'} . "\n";
428cdf0e10cSrcweir
429cdf0e10cSrcweir			if ( ! ( $style =~ /\bX64_ONLY\b/ )) { push(@registrytable, $oneline); }	# standard registry table for 32 Bit
430cdf0e10cSrcweir			if (( $style =~ /\bX64\b/ ) || ( $style =~ /\bX64_ONLY\b/ )) { push(@reg64table , $oneline64); }
431cdf0e10cSrcweir		}
432cdf0e10cSrcweir
433cdf0e10cSrcweir		# If there are added user registry keys for files collected in
434cdf0e10cSrcweir		# @installer::globals::userregistrycollector (file.pm), then
435cdf0e10cSrcweir		# this registry keys have to be added now. This is necessary for
436cdf0e10cSrcweir		# files in PREDEFINED_OSSHELLNEWDIR, because their component
437cdf0e10cSrcweir		# needs as KeyPath a RegistryItem in HKCU.
438cdf0e10cSrcweir
439cdf0e10cSrcweir		if ( $installer::globals::addeduserregitrykeys ) { add_userregs_to_registry_table(\@registrytable, $allvariableshashref); }
440cdf0e10cSrcweir
441cdf0e10cSrcweir		# Saving the file
442cdf0e10cSrcweir
443cdf0e10cSrcweir		my $registrytablename = $basedir . $installer::globals::separator . "Registry.idt" . "." . $onelanguage;
444cdf0e10cSrcweir		installer::files::save_file($registrytablename ,\@registrytable);
445b274bc22SAndre Fischer        $installer::logger::Lang->printf("Created idt file: %s\n", $registrytablename);
446cdf0e10cSrcweir
447cdf0e10cSrcweir		$registrytablename = $basedir . $installer::globals::separator . "Reg64.idt" . "." . $onelanguage;
448cdf0e10cSrcweir		installer::files::save_file($registrytablename ,\@reg64table );
449b274bc22SAndre Fischer        $installer::logger::Lang->printf("Created idt file: %s\n", $registrytablename);
450cdf0e10cSrcweir	}
451cdf0e10cSrcweir}
452cdf0e10cSrcweir
453cdf0e10cSrcweir1;
454