registry.pm (1ba1fd99) | registry.pm (9f91b7e3) |
---|---|
1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance --- 15 unchanged lines hidden (view full) --- 24package installer::windows::registry; 25 26use installer::files; 27use installer::globals; 28use installer::worker; 29use installer::windows::msiglobal; 30use installer::windows::idtglobal; 31 | 1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance --- 15 unchanged lines hidden (view full) --- 24package installer::windows::registry; 25 26use installer::files; 27use installer::globals; 28use installer::worker; 29use installer::windows::msiglobal; 30use installer::windows::idtglobal; 31 |
32use strict; 33 |
|
32##################################################### 33# Generating the component name from a registryitem 34##################################################### 35 36sub get_registry_component_name 37{ 38 my ($registryref, $allvariables) = @_; 39 --- 239 unchanged lines hidden (view full) --- 279 $value =~ s/\<progpath\>/\[INSTALLLOCATION\]/; 280 $value =~ s/\[INSTALLLOCATION\]\\/\[INSTALLLOCATION\]/; # removing "\" after "[INSTALLLOCATION]" 281 282 if ( $value =~ /\%/ ) { $value = installer::worker::replace_variables_in_string($value, $allvariableshashref); } 283 284 return $value; 285} 286 | 34##################################################### 35# Generating the component name from a registryitem 36##################################################### 37 38sub get_registry_component_name 39{ 40 my ($registryref, $allvariables) = @_; 41 --- 239 unchanged lines hidden (view full) --- 281 $value =~ s/\<progpath\>/\[INSTALLLOCATION\]/; 282 $value =~ s/\[INSTALLLOCATION\]\\/\[INSTALLLOCATION\]/; # removing "\" after "[INSTALLLOCATION]" 283 284 if ( $value =~ /\%/ ) { $value = installer::worker::replace_variables_in_string($value, $allvariableshashref); } 285 286 return $value; 287} 288 |
287############################################################## 288# Returning component for registry table. 289############################################################## | |
290 | 289 |
291sub get_registry_component 292{ 293 my ($registry, $allvariables) = @_; 294 295 # All registry items belonging to one module can 296 # be included into one component 297 298 my $componentname = get_registry_component_name($registry, $allvariables); 299 300 # saving componentname in the registryitem collector 301 302 $registry->{'componentname'} = $componentname; 303 304 return $componentname; 305} 306 | |
307###################################################### 308# Adding the content of 309# @installer::globals::userregistrycollector 310# to the registry table. The content was collected 311# in create_files_table() in file.pm. 312###################################################### 313 314sub add_userregs_to_registry_table --- 25 unchanged lines hidden (view full) --- 340 } 341} 342 343###################################################### 344# Creating the file Registry.idt dynamically 345# Content: 346# Registry Root Key Name Value Component_ 347###################################################### | 290###################################################### 291# Adding the content of 292# @installer::globals::userregistrycollector 293# to the registry table. The content was collected 294# in create_files_table() in file.pm. 295###################################################### 296 297sub add_userregs_to_registry_table --- 25 unchanged lines hidden (view full) --- 323 } 324} 325 326###################################################### 327# Creating the file Registry.idt dynamically 328# Content: 329# Registry Root Key Name Value Component_ 330###################################################### |
348 349sub create_registry_table | 331sub prepare_registry_table ($$$) |
350{ | 332{ |
351 my ($registryref, $allregistrycomponentsref, $basedir, $languagesarrayref, $allvariableshashref) = @_; | 333 my ($registryref, $languagesarrayref, $allvariableshashref) = @_; |
352 353 my %table_data = (); 354 foreach my $onelanguage (@$languagesarrayref) 355 { | 334 335 my %table_data = (); 336 foreach my $onelanguage (@$languagesarrayref) 337 { |
356 357 my @registrytable = (); 358 my @reg64table = (); 359 360 installer::windows::idtglobal::write_idt_header(\@registrytable, "registry"); 361 installer::windows::idtglobal::write_idt_header(\@reg64table, "reg64"); | |
362 my $table_items = []; 363 foreach my $oneregistry (@$registryref) 364 { 365 # Controlling the language! 366 # Only language independent folderitems or folderitems with the correct language 367 # will be included into the table 368 369 next if $oneregistry->{'ismultilingual'} --- 6 unchanged lines hidden (view full) --- 376 $registry{'Key'} = get_registry_key($oneregistry, $allvariableshashref); 377 $registry{'Name'} = get_registry_name($oneregistry, $allvariableshashref); 378 $registry{'Value'} = get_registry_value($oneregistry, $allvariableshashref); 379 $registry{'Val64'} = get_registry_val64($oneregistry, $allvariableshashref); 380 my $component_name = get_registry_component_name($oneregistry, $allvariableshashref); 381 $oneregistry->{'componentname'} = $component_name; 382 $registry{'Component_'} = $component_name; 383 | 338 my $table_items = []; 339 foreach my $oneregistry (@$registryref) 340 { 341 # Controlling the language! 342 # Only language independent folderitems or folderitems with the correct language 343 # will be included into the table 344 345 next if $oneregistry->{'ismultilingual'} --- 6 unchanged lines hidden (view full) --- 352 $registry{'Key'} = get_registry_key($oneregistry, $allvariableshashref); 353 $registry{'Name'} = get_registry_name($oneregistry, $allvariableshashref); 354 $registry{'Value'} = get_registry_value($oneregistry, $allvariableshashref); 355 $registry{'Val64'} = get_registry_val64($oneregistry, $allvariableshashref); 356 my $component_name = get_registry_component_name($oneregistry, $allvariableshashref); 357 $oneregistry->{'componentname'} = $component_name; 358 $registry{'Component_'} = $component_name; 359 |
384 # Collecting all components 385 if (!(installer::existence::exists_in_array($registry{'Component_'}, $allregistrycomponentsref))) 386 { 387 push(@{$allregistrycomponentsref}, $registry{'Component_'}); 388 } 389 | |
390 # Collecting all components with DONT_DELETE style 391 my $style = $oneregistry->{'Styles'} // ""; 392 $registry{'styles'} = $style; 393 394 if ( $style =~ /\bDONT_DELETE\b/ ) 395 { 396 $installer::globals::dontdeletecomponents{$component_name} = 1; 397 } --- 17 unchanged lines hidden (view full) --- 415 if ( $oneregistry->{'ComponentCondition'} ) 416 { 417 if ( ! exists($installer::globals::componentcondition{$registry{'Component_'}})) 418 { 419 $installer::globals::componentcondition{$registry{'Component_'}} = $oneregistry->{'ComponentCondition'}; 420 } 421 } 422 | 360 # Collecting all components with DONT_DELETE style 361 my $style = $oneregistry->{'Styles'} // ""; 362 $registry{'styles'} = $style; 363 364 if ( $style =~ /\bDONT_DELETE\b/ ) 365 { 366 $installer::globals::dontdeletecomponents{$component_name} = 1; 367 } --- 17 unchanged lines hidden (view full) --- 385 if ( $oneregistry->{'ComponentCondition'} ) 386 { 387 if ( ! exists($installer::globals::componentcondition{$registry{'Component_'}})) 388 { 389 $installer::globals::componentcondition{$registry{'Component_'}} = $oneregistry->{'ComponentCondition'}; 390 } 391 } 392 |
423 my $oneline = $registry{'Registry'} . "\t" . $registry{'Root'} . "\t" . $registry{'Key'} . "\t" 424 . $registry{'Name'} . "\t" . $registry{'Value'} . "\t" . $registry{'Component_'} . "\n"; | 393 push @$table_items, \%registry; 394 } 395 $table_data{$onelanguage} = $table_items; 396 } |
425 | 397 |
426 my $oneline64 = $registry{'Registry'} . "\t" . $registry{'Root'} . "\t" . $registry{'Key'} . "\t" 427 . $registry{'Name'} . "\t" . $registry{'Val64'} . "\t" . $registry{'Component_'} . "\n"; | 398 return \%table_data; 399} |
428 | 400 |
429 if ( ! ( $style =~ /\bX64_ONLY\b/ )) { push(@registrytable, $oneline); } # standard registry table for 32 Bit 430 if (( $style =~ /\bX64\b/ ) || ( $style =~ /\bX64_ONLY\b/ )) { push(@reg64table , $oneline64); } | 401 402 403 404sub collect_registry_components ($) 405{ 406 my ($table_data) = @_; 407 408 my %components = (); 409 foreach my $language_data (values %$table_data) 410 { 411 foreach my $item (@$language_data) 412 { 413 $components{$item->{'Component_'}} = 1; 414 } 415 } 416 return keys %components; 417} 418 419 420 421 422sub translate_component_names ($$$) 423{ 424 my ($translation_map, $registry_items, $table_data) = @_; 425 426 my $replacement_count = 0; 427 foreach my $item (@$registry_items) 428 { 429 my $translated_name = $translation_map->{$item->{'componentname'}}; 430 if (defined $translated_name) 431 { 432 $item->{'componentname'} = $translated_name; 433 ++$replacement_count; 434 } 435 } 436 $installer::logger::Lang->printf("replaced %d component names in registry items\n", $replacement_count); 437 438 $replacement_count = 0; 439 foreach my $language_data (values %$table_data) 440 { 441 foreach my $item (@$language_data) 442 { 443 my $translated_name = $translation_map->{$item->{'Component_'}}; 444 if (defined $translated_name) 445 { 446 $item->{'Component_'} = $translated_name; 447 ++$replacement_count; 448 } 449 } 450 } 451 $installer::logger::Lang->printf("replaced %d component names in registry table\n", $replacement_count); 452} 453 454 455 456 457sub create_registry_table_32 ($$$$) 458{ 459 my ($basedir, $languagesarrayref, $allvariableshashref, $table_data) = @_; 460 461 foreach my $onelanguage (@$languagesarrayref) 462 { 463 my @registrytable = (); 464 installer::windows::idtglobal::write_idt_header(\@registrytable, "registry"); 465 466 foreach my $item (@{$table_data->{$onelanguage}}) 467 { 468 next if $item->{'styles'} =~ /\bX64_ONLY\b/; 469 470 my $oneline = join("\t", 471 $item->{'Registry'}, 472 $item->{'Root'}, 473 $item->{'Key'}, 474 $item->{'Name'}, 475 $item->{'Value'}, 476 $item->{'Component_'}) 477 . "\n"; 478 479 push(@registrytable, $oneline); |
431 } 432 433 # If there are added user registry keys for files collected in 434 # @installer::globals::userregistrycollector (file.pm), then 435 # this registry keys have to be added now. This is necessary for 436 # files in PREDEFINED_OSSHELLNEWDIR, because their component 437 # needs as KeyPath a RegistryItem in HKCU. 438 | 480 } 481 482 # If there are added user registry keys for files collected in 483 # @installer::globals::userregistrycollector (file.pm), then 484 # this registry keys have to be added now. This is necessary for 485 # files in PREDEFINED_OSSHELLNEWDIR, because their component 486 # needs as KeyPath a RegistryItem in HKCU. 487 |
439 if ( $installer::globals::addeduserregitrykeys ) { add_userregs_to_registry_table(\@registrytable, $allvariableshashref); } | 488 if ( $installer::globals::addeduserregitrykeys ) 489 { 490 add_userregs_to_registry_table(\@registrytable, $allvariableshashref); 491 } |
440 | 492 |
441 # Saving the file 442 | 493 # Save the database file. |
443 my $registrytablename = $basedir . $installer::globals::separator . "Registry.idt" . "." . $onelanguage; 444 installer::files::save_file($registrytablename ,\@registrytable); 445 $installer::logger::Lang->printf("Created idt file: %s\n", $registrytablename); | 494 my $registrytablename = $basedir . $installer::globals::separator . "Registry.idt" . "." . $onelanguage; 495 installer::files::save_file($registrytablename ,\@registrytable); 496 $installer::logger::Lang->printf("Created idt file: %s\n", $registrytablename); |
497 } 498} |
|
446 | 499 |
447 $registrytablename = $basedir . $installer::globals::separator . "Reg64.idt" . "." . $onelanguage; | 500 501 502 503sub create_registry_table_64 ($$$$) 504{ 505 my ($basedir, $languagesarrayref, $allvariableshashref, $table_data) = @_; 506 507 foreach my $onelanguage (@$languagesarrayref) 508 { 509 my @reg64table = (); 510 installer::windows::idtglobal::write_idt_header(\@reg64table, "reg64"); 511 foreach my $item (@{$table_data->{$onelanguage}}) 512 { 513 next unless $item->{'styles'} =~ /\b(X64|X64_ONLY)\b/; 514 515 my $oneline64 = join("\t", 516 $item->{'Registry'}, 517 $item->{'Root'}, 518 $item->{'Key'}, 519 $item->{'Name'}, 520 $item->{'Val64'}, 521 $item->{'Component_'}) 522 . "\n"; 523 524 push(@reg64table , $oneline64); 525 } 526 527 # Save the database file. 528 my $registrytablename = $basedir . $installer::globals::separator . "Reg64.idt" . "." . $onelanguage; |
448 installer::files::save_file($registrytablename ,\@reg64table ); 449 $installer::logger::Lang->printf("Created idt file: %s\n", $registrytablename); 450 } 451} 452 4531; | 529 installer::files::save_file($registrytablename ,\@reg64table ); 530 $installer::logger::Lang->printf("Created idt file: %s\n", $registrytablename); 531 } 532} 533 5341; |