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 329f91b7e3SAndre Fischeruse strict; 339f91b7e3SAndre Fischer 34cdf0e10cSrcweir##################################################### 35cdf0e10cSrcweir# Generating the component name from a registryitem 36cdf0e10cSrcweir##################################################### 37cdf0e10cSrcweir 38cdf0e10cSrcweirsub get_registry_component_name 39cdf0e10cSrcweir{ 40cdf0e10cSrcweir my ($registryref, $allvariables) = @_; 41cdf0e10cSrcweir 42cdf0e10cSrcweir # In this function exists the rule to create components from registryitems 43cdf0e10cSrcweir # Rule: 44cdf0e10cSrcweir # The componentname can be directly taken from the ModuleID. 45cdf0e10cSrcweir # All registryitems belonging to one module can get the same component. 46cdf0e10cSrcweir 47cdf0e10cSrcweir my $componentname = ""; 48cdf0e10cSrcweir my $isrootmodule = 0; 49cdf0e10cSrcweir 50677600b0SAndre Fischer if ($registryref->{'ModuleID'}) 51677600b0SAndre Fischer { 52677600b0SAndre Fischer $componentname = $registryref->{'ModuleID'}; 53677600b0SAndre Fischer } 54cdf0e10cSrcweir 55cdf0e10cSrcweir $componentname =~ s/\\/\_/g; 56cdf0e10cSrcweir $componentname =~ s/\//\_/g; 57cdf0e10cSrcweir $componentname =~ s/\-/\_/g; 58cdf0e10cSrcweir $componentname =~ s/\_\s*$//g; 59cdf0e10cSrcweir 60cdf0e10cSrcweir $componentname = lc($componentname); # componentnames always lowercase 61cdf0e10cSrcweir 62677600b0SAndre Fischer if ( $componentname eq "gid_module_root" ) 63677600b0SAndre Fischer { 64677600b0SAndre Fischer $isrootmodule = 1; 65677600b0SAndre Fischer } 66cdf0e10cSrcweir 67cdf0e10cSrcweir # Attention: Maximum length for the componentname is 72 68cdf0e10cSrcweir 69cdf0e10cSrcweir # identifying this component as registryitem component 70cdf0e10cSrcweir $componentname = "registry_" . $componentname; 71cdf0e10cSrcweir 72cdf0e10cSrcweir $componentname =~ s/gid_module_/g_m_/g; 73cdf0e10cSrcweir $componentname =~ s/_optional_/_o_/g; 74cdf0e10cSrcweir $componentname =~ s/_javafilter_/_jf_/g; 75cdf0e10cSrcweir 76cdf0e10cSrcweir # This componentname must be more specific 77cdf0e10cSrcweir my $addon = "_"; 78677600b0SAndre Fischer if ($allvariables->{'PRODUCTNAME'}) 79677600b0SAndre Fischer { 80677600b0SAndre Fischer $addon .= $allvariables->{'PRODUCTNAME'}; 81677600b0SAndre Fischer } 82677600b0SAndre Fischer 83677600b0SAndre Fischer # Append the version number. 84677600b0SAndre Fischer # Previously that was the full version number as provided by 'PRODUCTVERSION'. 85677600b0SAndre Fischer # But MSI patches introduce the restriction that component names must not change. 86677600b0SAndre Fischer # Use just the major version number. 87*d62abd1aSAndre Fischer my $version = $allvariables->{"BRANDPACKAGEVERSION"}; 88*d62abd1aSAndre Fischer $version = "" unless defined $version; 89677600b0SAndre Fischer $addon .= $version; 90cdf0e10cSrcweir $addon = lc($addon); 91cdf0e10cSrcweir $addon =~ s/ //g; 92cdf0e10cSrcweir $addon =~ s/-//g; 93cdf0e10cSrcweir $addon =~ s/\.//g; 94cdf0e10cSrcweir 95cdf0e10cSrcweir $componentname = $componentname . $addon; 96cdf0e10cSrcweir 97677600b0SAndre Fischer my $styles = $registryref->{'Styles'}; 98677600b0SAndre Fischer if (defined $styles) 99677600b0SAndre Fischer { 100677600b0SAndre Fischer if (($styles =~ /\bLANGUAGEPACK\b/) && $installer::globals::languagepack) 101677600b0SAndre Fischer { 102677600b0SAndre Fischer $componentname .= "_lang"; 103677600b0SAndre Fischer } 104677600b0SAndre Fischer if ($styles =~ /\bALWAYS_REQUIRED\b/) 105677600b0SAndre Fischer { 106677600b0SAndre Fischer $componentname .= "_forced"; 107677600b0SAndre Fischer } 108677600b0SAndre Fischer } 109cdf0e10cSrcweir 110cdf0e10cSrcweir # Attention: Maximum length for the componentname is 72 111cdf0e10cSrcweir # %installer::globals::allregistrycomponents_in_this_database_ : resetted for each database 112cdf0e10cSrcweir # %installer::globals::allregistrycomponents_ : not resetted for each database 113cdf0e10cSrcweir # Component strings must be unique for the complete product, because they are used for 114cdf0e10cSrcweir # the creation of the globally unique identifier. 115cdf0e10cSrcweir 116cdf0e10cSrcweir my $fullname = $componentname; # This can be longer than 72 117cdf0e10cSrcweir 118677600b0SAndre Fischer if (exists($installer::globals::allregistrycomponents_{$fullname}) 119677600b0SAndre Fischer && ! exists($installer::globals::allregistrycomponents_in_this_database_{$fullname})) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir # This is not allowed: One component cannot be installed with different packages. 122677600b0SAndre Fischer installer::exiter::exit_program( 123677600b0SAndre Fischer "ERROR: Windows registry component \"$fullname\" is already included into another package. This is not allowed.", 124677600b0SAndre Fischer "get_registry_component_name"); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir if ( exists($installer::globals::allregistrycomponents_{$fullname}) ) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir $componentname = $installer::globals::allregistrycomponents_{$fullname}; 130cdf0e10cSrcweir } 131cdf0e10cSrcweir else 132cdf0e10cSrcweir { 13319d58b3aSEike Rathke if ( length($componentname) > 70 ) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir $componentname = generate_new_short_registrycomponentname($componentname); # This has to be unique for the complete product, not only one package 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir $installer::globals::allregistrycomponents_{$fullname} = $componentname; 139cdf0e10cSrcweir $installer::globals::allregistrycomponents_in_this_database_{$fullname} = 1; 140cdf0e10cSrcweir } 141cdf0e10cSrcweir 142677600b0SAndre Fischer if ( $isrootmodule ) 143677600b0SAndre Fischer { 144677600b0SAndre Fischer $installer::globals::registryrootcomponent = $componentname; 145677600b0SAndre Fischer } 146cdf0e10cSrcweir 147cdf0e10cSrcweir return $componentname; 148cdf0e10cSrcweir} 149cdf0e10cSrcweir 150cdf0e10cSrcweir######################################################### 151cdf0e10cSrcweir# Create a shorter version of a long component name, 152cdf0e10cSrcweir# because maximum length in msi database is 72. 153cdf0e10cSrcweir# Attention: In multi msi installation sets, the short 154cdf0e10cSrcweir# names have to be unique over all packages, because 155cdf0e10cSrcweir# this string is used to create the globally unique id 156cdf0e10cSrcweir# -> no resetting of 157cdf0e10cSrcweir# %installer::globals::allshortregistrycomponents 158cdf0e10cSrcweir# after a package was created. 159cdf0e10cSrcweir######################################################### 160cdf0e10cSrcweir 161cdf0e10cSrcweirsub generate_new_short_registrycomponentname 162cdf0e10cSrcweir{ 163cdf0e10cSrcweir my ($componentname) = @_; 16419d58b3aSEike Rathke 165cdf0e10cSrcweir my $startversion = substr($componentname, 0, 60); # taking only the first 60 characters 16619d58b3aSEike Rathke my $subid = installer::windows::msiglobal::calculate_id($componentname, 9); # taking only the first 9 digits 16719d58b3aSEike Rathke my $shortcomponentname = $startversion . "_" . $subid; 168cdf0e10cSrcweir 16919d58b3aSEike Rathke if ( exists($installer::globals::allshortregistrycomponents{$shortcomponentname}) ) { installer::exiter::exit_program("Failed to create unique component name: \"$shortcomponentname\"", "generate_new_short_registrycomponentname"); } 170cdf0e10cSrcweir 171cdf0e10cSrcweir $installer::globals::allshortregistrycomponents{$shortcomponentname} = 1; 172cdf0e10cSrcweir 173cdf0e10cSrcweir return $shortcomponentname; 174cdf0e10cSrcweir} 175cdf0e10cSrcweir 176cdf0e10cSrcweir############################################################## 177cdf0e10cSrcweir# Returning identifier for registry table. 178cdf0e10cSrcweir############################################################## 179cdf0e10cSrcweir 180cdf0e10cSrcweirsub get_registry_identifier 181cdf0e10cSrcweir{ 182cdf0e10cSrcweir my ($registry) = @_; 183cdf0e10cSrcweir 184cdf0e10cSrcweir my $identifier = ""; 185cdf0e10cSrcweir 186cdf0e10cSrcweir if ( $registry->{'gid'} ) { $identifier = $registry->{'gid'}; } 187cdf0e10cSrcweir 188cdf0e10cSrcweir $identifier = lc($identifier); # always lower case 189cdf0e10cSrcweir 190cdf0e10cSrcweir # Attention: Maximum length is 72 191cdf0e10cSrcweir 192cdf0e10cSrcweir $identifier =~ s/gid_regitem_/g_r_/; 193cdf0e10cSrcweir $identifier =~ s/_soffice_/_s_/; 194cdf0e10cSrcweir $identifier =~ s/_clsid_/_c_/; 195cdf0e10cSrcweir $identifier =~ s/_currentversion_/_cv_/; 196cdf0e10cSrcweir $identifier =~ s/_microsoft_/_ms_/; 197cdf0e10cSrcweir $identifier =~ s/_manufacturer_/_mf_/; 198cdf0e10cSrcweir $identifier =~ s/_productname_/_pn_/; 199cdf0e10cSrcweir $identifier =~ s/_productversion_/_pv_/; 200cdf0e10cSrcweir $identifier =~ s/_staroffice_/_so_/; 201cdf0e10cSrcweir $identifier =~ s/_software_/_sw_/; 202cdf0e10cSrcweir $identifier =~ s/_capabilities_/_cap_/; 203cdf0e10cSrcweir $identifier =~ s/_classpath_/_cp_/; 204cdf0e10cSrcweir $identifier =~ s/_extension_/_ex_/; 205cdf0e10cSrcweir $identifier =~ s/_fileassociations_/_fa_/; 206cdf0e10cSrcweir $identifier =~ s/_propertysheethandlers_/_psh_/; 207cdf0e10cSrcweir $identifier =~ s/__/_/g; 208cdf0e10cSrcweir 209cdf0e10cSrcweir # Saving this in the registry collector 210cdf0e10cSrcweir 211cdf0e10cSrcweir $registry->{'uniquename'} = $identifier; 212cdf0e10cSrcweir 213cdf0e10cSrcweir return $identifier; 214cdf0e10cSrcweir} 215cdf0e10cSrcweir 216cdf0e10cSrcweir################################################################## 217cdf0e10cSrcweir# Returning root value for registry table. 218cdf0e10cSrcweir################################################################## 219cdf0e10cSrcweir 220cdf0e10cSrcweirsub get_registry_root 221cdf0e10cSrcweir{ 222cdf0e10cSrcweir my ($registry) = @_; 223cdf0e10cSrcweir 224cdf0e10cSrcweir my $rootvalue = 0; # Default: Parent is KKEY_CLASSES_ROOT 225cdf0e10cSrcweir my $scproot = ""; 226cdf0e10cSrcweir 227cdf0e10cSrcweir if ( $registry->{'ParentID'} ) { $scproot = $registry->{'ParentID'}; } 228cdf0e10cSrcweir 229cdf0e10cSrcweir if ( $scproot eq "PREDEFINED_HKEY_LOCAL_MACHINE" ) { $rootvalue = -1; } 230cdf0e10cSrcweir 231cdf0e10cSrcweir if ( $scproot eq "PREDEFINED_HKEY_CLASSES_ROOT" ) { $rootvalue = 0; } 232cdf0e10cSrcweir 233cdf0e10cSrcweir if ( $scproot eq "PREDEFINED_HKEY_CURRENT_USER_ONLY" ) { $rootvalue = 1; } 234cdf0e10cSrcweir 235cdf0e10cSrcweir if ( $scproot eq "PREDEFINED_HKEY_LOCAL_MACHINE_ONLY" ) { $rootvalue = 2; } 236cdf0e10cSrcweir 237cdf0e10cSrcweir return $rootvalue; 238cdf0e10cSrcweir} 239cdf0e10cSrcweir 240cdf0e10cSrcweir############################################################## 241cdf0e10cSrcweir# Returning key for registry table. 242cdf0e10cSrcweir############################################################## 243cdf0e10cSrcweir 244cdf0e10cSrcweirsub get_registry_key 245cdf0e10cSrcweir{ 246cdf0e10cSrcweir my ($registry, $allvariableshashref) = @_; 247cdf0e10cSrcweir 248cdf0e10cSrcweir my $key = ""; 249cdf0e10cSrcweir 250cdf0e10cSrcweir if ( $registry->{'Subkey'} ) { $key = $registry->{'Subkey'}; } 251cdf0e10cSrcweir 252cdf0e10cSrcweir if ( $key =~ /\%/ ) { $key = installer::worker::replace_variables_in_string($key, $allvariableshashref); } 253cdf0e10cSrcweir 254cdf0e10cSrcweir return $key; 255cdf0e10cSrcweir} 256cdf0e10cSrcweir 257cdf0e10cSrcweir############################################################## 258cdf0e10cSrcweir# Returning name for registry table. 259cdf0e10cSrcweir############################################################## 260cdf0e10cSrcweir 261cdf0e10cSrcweirsub get_registry_name 262cdf0e10cSrcweir{ 263cdf0e10cSrcweir my ($registry, $allvariableshashref) = @_; 264cdf0e10cSrcweir 265cdf0e10cSrcweir my $name = ""; 266cdf0e10cSrcweir 267cdf0e10cSrcweir if ( $registry->{'Name'} ) { $name = $registry->{'Name'}; } 268cdf0e10cSrcweir 269cdf0e10cSrcweir if ( $name =~ /\%/ ) { $name = installer::worker::replace_variables_in_string($name, $allvariableshashref); } 270cdf0e10cSrcweir 271cdf0e10cSrcweir return $name; 272cdf0e10cSrcweir} 273cdf0e10cSrcweir 274cdf0e10cSrcweir############################################################## 275cdf0e10cSrcweir# Returning value for registry table. 276cdf0e10cSrcweir############################################################## 277cdf0e10cSrcweir 278cdf0e10cSrcweirsub get_registry_value 279cdf0e10cSrcweir{ 280cdf0e10cSrcweir my ($registry, $allvariableshashref) = @_; 281cdf0e10cSrcweir 282cdf0e10cSrcweir my $value = ""; 283cdf0e10cSrcweir 284cdf0e10cSrcweir if ( $registry->{'Value'} ) { $value = $registry->{'Value'}; } 285cdf0e10cSrcweir 286cdf0e10cSrcweir $value =~ s/\\\"/\"/g; # no more masquerading of '"' 287cdf0e10cSrcweir $value =~ s/\\\\\s*$/\\/g; # making "\\" at end of value to "\" 288cdf0e10cSrcweir $value =~ s/\<progpath\>/\[INSTALLLOCATION\]/; 289cdf0e10cSrcweir $value =~ s/\[INSTALLLOCATION\]\\/\[INSTALLLOCATION\]/; # removing "\" after "[INSTALLLOCATION]" 290cdf0e10cSrcweir 291cdf0e10cSrcweir if ( $value =~ /\%/ ) { $value = installer::worker::replace_variables_in_string($value, $allvariableshashref); } 292cdf0e10cSrcweir 293cdf0e10cSrcweir return $value; 294cdf0e10cSrcweir} 295cdf0e10cSrcweir 296cdf0e10cSrcweir############################################################## 297cdf0e10cSrcweir# Returning 64 bit value for registry table. 298cdf0e10cSrcweir############################################################## 299cdf0e10cSrcweir 300cdf0e10cSrcweirsub get_registry_val64 301cdf0e10cSrcweir{ 302cdf0e10cSrcweir my ($registry, $allvariableshashref) = @_; 303cdf0e10cSrcweir 304cdf0e10cSrcweir my $value = ""; 305cdf0e10cSrcweir 306cdf0e10cSrcweir if ( $registry->{'Val64'} ) { $value = $registry->{'Val64'}; } 307cdf0e10cSrcweir 308cdf0e10cSrcweir $value =~ s/\\\"/\"/g; # no more masquerading of '"' 309cdf0e10cSrcweir $value =~ s/\\\\\s*$/\\/g; # making "\\" at end of value to "\" 310cdf0e10cSrcweir $value =~ s/\<progpath\>/\[INSTALLLOCATION\]/; 311cdf0e10cSrcweir $value =~ s/\[INSTALLLOCATION\]\\/\[INSTALLLOCATION\]/; # removing "\" after "[INSTALLLOCATION]" 312cdf0e10cSrcweir 313cdf0e10cSrcweir if ( $value =~ /\%/ ) { $value = installer::worker::replace_variables_in_string($value, $allvariableshashref); } 314cdf0e10cSrcweir 315cdf0e10cSrcweir return $value; 316cdf0e10cSrcweir} 317cdf0e10cSrcweir 318cdf0e10cSrcweir 319cdf0e10cSrcweir###################################################### 320cdf0e10cSrcweir# Adding the content of 321cdf0e10cSrcweir# @installer::globals::userregistrycollector 322cdf0e10cSrcweir# to the registry table. The content was collected 323cdf0e10cSrcweir# in create_files_table() in file.pm. 324cdf0e10cSrcweir###################################################### 325cdf0e10cSrcweir 326cdf0e10cSrcweirsub add_userregs_to_registry_table 327cdf0e10cSrcweir{ 328cdf0e10cSrcweir my ( $registrytable, $allvariables ) = @_; 329cdf0e10cSrcweir 330cdf0e10cSrcweir for ( my $i = 0; $i <= $#installer::globals::userregistrycollector; $i++ ) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir my $onefile = $installer::globals::userregistrycollector[$i]; 333cdf0e10cSrcweir 334cdf0e10cSrcweir my $styles = ""; 335cdf0e10cSrcweir if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; } 336cdf0e10cSrcweir 337cdf0e10cSrcweir my %registry = (); 338cdf0e10cSrcweir 339cdf0e10cSrcweir $registry{'Registry'} = $onefile->{'userregkeypath'}; 340cdf0e10cSrcweir $registry{'Root'} = "1"; # always HKCU 341cdf0e10cSrcweir $registry{'Key'} = "Software\\$allvariables->{'MANUFACTURER'}\\$allvariables->{'PRODUCTNAME'} $allvariables->{'PRODUCTVERSION'}\\"; 342cdf0e10cSrcweir if ( $onefile->{'needs_user_registry_key'} ) { $registry{'Key'} = $registry{'Key'} . "StartMenu"; } 343cdf0e10cSrcweir else { $registry{'Key'} = $registry{'Key'} . "ShellNew"; } 344cdf0e10cSrcweir $registry{'Name'} = $onefile->{'Name'}; 345cdf0e10cSrcweir $registry{'Value'} = "1"; 346cdf0e10cSrcweir $registry{'Component_'} = $onefile->{'componentname'}; 347cdf0e10cSrcweir 348cdf0e10cSrcweir my $oneline = $registry{'Registry'} . "\t" . $registry{'Root'} . "\t" . $registry{'Key'} . "\t" 349cdf0e10cSrcweir . $registry{'Name'} . "\t" . $registry{'Value'} . "\t" . $registry{'Component_'} . "\n"; 350cdf0e10cSrcweir 351cdf0e10cSrcweir push(@{$registrytable}, $oneline); 352cdf0e10cSrcweir } 353cdf0e10cSrcweir} 354cdf0e10cSrcweir 355cdf0e10cSrcweir###################################################### 356cdf0e10cSrcweir# Creating the file Registry.idt dynamically 357cdf0e10cSrcweir# Content: 358cdf0e10cSrcweir# Registry Root Key Name Value Component_ 359cdf0e10cSrcweir###################################################### 3609f91b7e3SAndre Fischersub prepare_registry_table ($$$) 361cdf0e10cSrcweir{ 3629f91b7e3SAndre Fischer my ($registryref, $languagesarrayref, $allvariableshashref) = @_; 363cdf0e10cSrcweir 3641ba1fd99SAndre Fischer my %table_data = (); 3651ba1fd99SAndre Fischer foreach my $onelanguage (@$languagesarrayref) 366cdf0e10cSrcweir { 3671ba1fd99SAndre Fischer my $table_items = []; 3681ba1fd99SAndre Fischer foreach my $oneregistry (@$registryref) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir # Controlling the language! 371cdf0e10cSrcweir # Only language independent folderitems or folderitems with the correct language 372cdf0e10cSrcweir # will be included into the table 373cdf0e10cSrcweir 3741ba1fd99SAndre Fischer next if $oneregistry->{'ismultilingual'} 3751ba1fd99SAndre Fischer && $oneregistry->{'specificlanguage'} ne $onelanguage; 376cdf0e10cSrcweir 377cdf0e10cSrcweir my %registry = (); 378cdf0e10cSrcweir 379cdf0e10cSrcweir $registry{'Registry'} = get_registry_identifier($oneregistry); 380cdf0e10cSrcweir $registry{'Root'} = get_registry_root($oneregistry); 381cdf0e10cSrcweir $registry{'Key'} = get_registry_key($oneregistry, $allvariableshashref); 382cdf0e10cSrcweir $registry{'Name'} = get_registry_name($oneregistry, $allvariableshashref); 383cdf0e10cSrcweir $registry{'Value'} = get_registry_value($oneregistry, $allvariableshashref); 384cdf0e10cSrcweir $registry{'Val64'} = get_registry_val64($oneregistry, $allvariableshashref); 3851ba1fd99SAndre Fischer my $component_name = get_registry_component_name($oneregistry, $allvariableshashref); 3861ba1fd99SAndre Fischer $oneregistry->{'componentname'} = $component_name; 3871ba1fd99SAndre Fischer $registry{'Component_'} = $component_name; 388cdf0e10cSrcweir 389cdf0e10cSrcweir # Collecting all components with DONT_DELETE style 390*d62abd1aSAndre Fischer my $style = $oneregistry->{'Styles'}; 391*d62abd1aSAndre Fischer $style = "" unless defined $style; 3921ba1fd99SAndre Fischer $registry{'styles'} = $style; 3931ba1fd99SAndre Fischer 3941ba1fd99SAndre Fischer if ( $style =~ /\bDONT_DELETE\b/ ) 3951ba1fd99SAndre Fischer { 3961ba1fd99SAndre Fischer $installer::globals::dontdeletecomponents{$component_name} = 1; 3971ba1fd99SAndre Fischer } 398cdf0e10cSrcweir 399cdf0e10cSrcweir # Saving upgradekey to write this into setup.ini for minor upgrades 4001ba1fd99SAndre Fischer if ( $style =~ /\bUPGRADEKEY\b/ ) 4011ba1fd99SAndre Fischer { 4021ba1fd99SAndre Fischer $installer::globals::minorupgradekey = $registry{'Key'}; 4031ba1fd99SAndre 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 4239f91b7e3SAndre Fischer push @$table_items, \%registry; 4249f91b7e3SAndre Fischer } 4259f91b7e3SAndre Fischer $table_data{$onelanguage} = $table_items; 4269f91b7e3SAndre Fischer } 4279f91b7e3SAndre Fischer 4289f91b7e3SAndre Fischer return \%table_data; 4299f91b7e3SAndre Fischer} 4309f91b7e3SAndre Fischer 4319f91b7e3SAndre Fischer 4329f91b7e3SAndre Fischer 4339f91b7e3SAndre Fischer 4349f91b7e3SAndre Fischersub collect_registry_components ($) 4359f91b7e3SAndre Fischer{ 4369f91b7e3SAndre Fischer my ($table_data) = @_; 4379f91b7e3SAndre Fischer 4389f91b7e3SAndre Fischer my %components = (); 4399f91b7e3SAndre Fischer foreach my $language_data (values %$table_data) 4409f91b7e3SAndre Fischer { 4419f91b7e3SAndre Fischer foreach my $item (@$language_data) 4429f91b7e3SAndre Fischer { 4439f91b7e3SAndre Fischer $components{$item->{'Component_'}} = 1; 4449f91b7e3SAndre Fischer } 4459f91b7e3SAndre Fischer } 4469f91b7e3SAndre Fischer return keys %components; 4479f91b7e3SAndre Fischer} 4489f91b7e3SAndre Fischer 4499f91b7e3SAndre Fischer 4509f91b7e3SAndre Fischer 4519f91b7e3SAndre Fischer 4529f91b7e3SAndre Fischersub translate_component_names ($$$) 4539f91b7e3SAndre Fischer{ 4549f91b7e3SAndre Fischer my ($translation_map, $registry_items, $table_data) = @_; 4559f91b7e3SAndre Fischer 4569f91b7e3SAndre Fischer my $replacement_count = 0; 4579f91b7e3SAndre Fischer foreach my $item (@$registry_items) 4589f91b7e3SAndre Fischer { 4599f91b7e3SAndre Fischer my $translated_name = $translation_map->{$item->{'componentname'}}; 4609f91b7e3SAndre Fischer if (defined $translated_name) 4619f91b7e3SAndre Fischer { 4629f91b7e3SAndre Fischer $item->{'componentname'} = $translated_name; 4639f91b7e3SAndre Fischer ++$replacement_count; 4649f91b7e3SAndre Fischer } 4659f91b7e3SAndre Fischer } 4669f91b7e3SAndre Fischer $installer::logger::Lang->printf("replaced %d component names in registry items\n", $replacement_count); 4679f91b7e3SAndre Fischer 4689f91b7e3SAndre Fischer $replacement_count = 0; 4699f91b7e3SAndre Fischer foreach my $language_data (values %$table_data) 4709f91b7e3SAndre Fischer { 4719f91b7e3SAndre Fischer foreach my $item (@$language_data) 4729f91b7e3SAndre Fischer { 4739f91b7e3SAndre Fischer my $translated_name = $translation_map->{$item->{'Component_'}}; 4749f91b7e3SAndre Fischer if (defined $translated_name) 4759f91b7e3SAndre Fischer { 4769f91b7e3SAndre Fischer $item->{'Component_'} = $translated_name; 4779f91b7e3SAndre Fischer ++$replacement_count; 4789f91b7e3SAndre Fischer } 4799f91b7e3SAndre Fischer } 4809f91b7e3SAndre Fischer } 4819f91b7e3SAndre Fischer $installer::logger::Lang->printf("replaced %d component names in registry table\n", $replacement_count); 4829f91b7e3SAndre Fischer} 4839f91b7e3SAndre Fischer 4849f91b7e3SAndre Fischer 4859f91b7e3SAndre Fischer 486cdf0e10cSrcweir 4879f91b7e3SAndre Fischersub create_registry_table_32 ($$$$) 4889f91b7e3SAndre Fischer{ 4899f91b7e3SAndre Fischer my ($basedir, $languagesarrayref, $allvariableshashref, $table_data) = @_; 4909f91b7e3SAndre Fischer 4919f91b7e3SAndre Fischer foreach my $onelanguage (@$languagesarrayref) 4929f91b7e3SAndre Fischer { 4939f91b7e3SAndre Fischer my @registrytable = (); 4949f91b7e3SAndre Fischer installer::windows::idtglobal::write_idt_header(\@registrytable, "registry"); 495cdf0e10cSrcweir 4969f91b7e3SAndre Fischer foreach my $item (@{$table_data->{$onelanguage}}) 4979f91b7e3SAndre Fischer { 4989f91b7e3SAndre Fischer next if $item->{'styles'} =~ /\bX64_ONLY\b/; 4999f91b7e3SAndre Fischer 5009f91b7e3SAndre Fischer my $oneline = join("\t", 5019f91b7e3SAndre Fischer $item->{'Registry'}, 5029f91b7e3SAndre Fischer $item->{'Root'}, 5039f91b7e3SAndre Fischer $item->{'Key'}, 5049f91b7e3SAndre Fischer $item->{'Name'}, 5059f91b7e3SAndre Fischer $item->{'Value'}, 5069f91b7e3SAndre Fischer $item->{'Component_'}) 5079f91b7e3SAndre Fischer . "\n"; 5089f91b7e3SAndre Fischer 5099f91b7e3SAndre Fischer push(@registrytable, $oneline); 510cdf0e10cSrcweir } 511cdf0e10cSrcweir 512cdf0e10cSrcweir # If there are added user registry keys for files collected in 513cdf0e10cSrcweir # @installer::globals::userregistrycollector (file.pm), then 514cdf0e10cSrcweir # this registry keys have to be added now. This is necessary for 515cdf0e10cSrcweir # files in PREDEFINED_OSSHELLNEWDIR, because their component 516cdf0e10cSrcweir # needs as KeyPath a RegistryItem in HKCU. 517cdf0e10cSrcweir 5189f91b7e3SAndre Fischer if ( $installer::globals::addeduserregitrykeys ) 5199f91b7e3SAndre Fischer { 5209f91b7e3SAndre Fischer add_userregs_to_registry_table(\@registrytable, $allvariableshashref); 5219f91b7e3SAndre Fischer } 522cdf0e10cSrcweir 5239f91b7e3SAndre Fischer # Save the database file. 524cdf0e10cSrcweir my $registrytablename = $basedir . $installer::globals::separator . "Registry.idt" . "." . $onelanguage; 525cdf0e10cSrcweir installer::files::save_file($registrytablename ,\@registrytable); 526b274bc22SAndre Fischer $installer::logger::Lang->printf("Created idt file: %s\n", $registrytablename); 5279f91b7e3SAndre Fischer } 5289f91b7e3SAndre Fischer} 5299f91b7e3SAndre Fischer 530cdf0e10cSrcweir 5319f91b7e3SAndre Fischer 5329f91b7e3SAndre Fischer 5339f91b7e3SAndre Fischersub create_registry_table_64 ($$$$) 5349f91b7e3SAndre Fischer{ 5359f91b7e3SAndre Fischer my ($basedir, $languagesarrayref, $allvariableshashref, $table_data) = @_; 5369f91b7e3SAndre Fischer 5379f91b7e3SAndre Fischer foreach my $onelanguage (@$languagesarrayref) 5389f91b7e3SAndre Fischer { 5399f91b7e3SAndre Fischer my @reg64table = (); 5409f91b7e3SAndre Fischer installer::windows::idtglobal::write_idt_header(\@reg64table, "reg64"); 5419f91b7e3SAndre Fischer foreach my $item (@{$table_data->{$onelanguage}}) 5429f91b7e3SAndre Fischer { 5439f91b7e3SAndre Fischer next unless $item->{'styles'} =~ /\b(X64|X64_ONLY)\b/; 5449f91b7e3SAndre Fischer 5459f91b7e3SAndre Fischer my $oneline64 = join("\t", 5469f91b7e3SAndre Fischer $item->{'Registry'}, 5479f91b7e3SAndre Fischer $item->{'Root'}, 5489f91b7e3SAndre Fischer $item->{'Key'}, 5499f91b7e3SAndre Fischer $item->{'Name'}, 5509f91b7e3SAndre Fischer $item->{'Val64'}, 5519f91b7e3SAndre Fischer $item->{'Component_'}) 5529f91b7e3SAndre Fischer . "\n"; 5539f91b7e3SAndre Fischer 5549f91b7e3SAndre Fischer push(@reg64table , $oneline64); 5559f91b7e3SAndre Fischer } 5569f91b7e3SAndre Fischer 5579f91b7e3SAndre Fischer # Save the database file. 5589f91b7e3SAndre Fischer my $registrytablename = $basedir . $installer::globals::separator . "Reg64.idt" . "." . $onelanguage; 559cdf0e10cSrcweir installer::files::save_file($registrytablename ,\@reg64table ); 560b274bc22SAndre Fischer $installer::logger::Lang->printf("Created idt file: %s\n", $registrytablename); 561cdf0e10cSrcweir } 562cdf0e10cSrcweir} 563cdf0e10cSrcweir 564cdf0e10cSrcweir1; 565