component.pm (1ba1fd99) | component.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 --- 344 unchanged lines hidden (view full) --- 353 } 354 } 355 356 installer::exiter::exit_program( 357 "ERROR: Did not find component in file/registry collection, function get_component_keypath", 358 "get_component_keypath"); 359} 360 | 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 --- 344 unchanged lines hidden (view full) --- 353 } 354 } 355 356 installer::exiter::exit_program( 357 "ERROR: Did not find component in file/registry collection, function get_component_keypath", 358 "get_component_keypath"); 359} 360 |
361################################################################### 362# Creating the file Componen.idt dynamically 363# Content: 364# Component ComponentId Directory_ Attributes Condition KeyPath 365################################################################### | |
366 | 361 |
367sub create_component_table ($$$$$$$) | 362 363 364sub remove_ooversion_from_component_name($) |
368{ | 365{ |
369 my ($filesref, 370 $registryref, 371 $dirref, 372 $allfilecomponentsref, 373 $allregistrycomponents, 374 $basedir, 375 $allvariables) 376 = @_; | 366 my ($component_name) = @_; |
377 | 367 |
378 my @componenttable = (); | 368 $component_name =~ s/_openoffice\d+//; |
379 | 369 |
380 my ($oneline, $infoline); | 370 return $component_name; 371} |
381 | 372 |
382 installer::windows::idtglobal::write_idt_header(\@componenttable, "component"); | |
383 | 373 |
384 # collect_layer_conditions(); | |
385 386 | 374 375 |
387 # File components | 376sub prepare_component_table_creation ($$$) 377{ 378 my ($file_components, $registry_components, $variables) = @_; |
388 | 379 |
389 for ( my $i = 0; $i <= $#{$allfilecomponentsref}; $i++ ) | 380 if ($installer::globals::is_release) 381 { 382 my %source_component_data = (); 383 384 # Collect the components that are used in the source release. 385 my $component_table = $installer::globals::source_msi->GetTable("Component"); 386 foreach my $row (@{$component_table->GetAllRows()}) 387 { 388 $source_component_data{$row->GetValue("Component")} = $row; 389 } 390 391 # Find source components that do not exist in the target components, ie have been removed. 392 393 # Process file components. 394 my @missing_source_component_names = (); 395 my %file_component_hash = map {$_ => 1} @$file_components; 396 foreach my $source_component_name (keys %source_component_data) 397 { 398 # In this loop we only process components for files and ignore those for registry entries. 399 next if $source_component_name =~ /^registry_/; 400 401 if ( ! defined $file_component_hash{$source_component_name}) 402 { 403 push @missing_source_component_names, [$source_component_name, $source_component_name]; 404 $installer::logger::Info->printf("missing file component %s\n", $source_component_name); 405 } 406 } 407 408 # Process registry components. 409 my %registry_component_hash = map {$_ => 1} @$registry_components; 410 my %registry_component_hash_normalized = map {remove_ooversion_from_component_name($_) => $_} @$registry_components; 411 my %target_registry_component_translation = (); 412 foreach my $source_component_name (keys %source_component_data) 413 { 414 # In this loop we only process components for registry entries and ignore those for files. 415 next if $source_component_name !~ /^registry_/; 416 417 if (defined $registry_component_hash{$source_component_name}) 418 { 419 # Found the non-normalized name. 420 } 421 elsif (defined $registry_component_hash_normalized{ 422 remove_ooversion_from_component_name($source_component_name)}) 423 { 424 # Found the normalized name. 425 my $target_component_name = $registry_component_hash_normalized{ 426 remove_ooversion_from_component_name($source_component_name)}; 427 $target_registry_component_translation{$target_component_name} = $source_component_name; 428 $installer::logger::Info->printf("found normalized component name %s\n", $source_component_name); 429 $installer::logger::Info->printf(" %s -> %s\n", $target_component_name, $source_component_name); 430 } 431 else 432 { 433 # Source component was not found. 434 push @missing_source_component_names, $source_component_name; 435 $installer::logger::Info->printf("missing component %s\n", $source_component_name); 436 } 437 } 438 439 if (scalar @missing_source_component_names > 0) 440 { 441 $installer::logger::Info->printf("Error: there are %d missing components\n", 442 scalar @missing_source_component_names); 443 return {}; 444 } 445 else 446 { 447 return \%target_registry_component_translation; 448 } 449 } 450 451 return {}; 452} 453 454 455 456 457sub get_component_data ($$$$) 458{ 459 my ($file_component_names, 460 $registry_component_names, 461 $files, 462 $registry_entries) = @_; 463 464 # When we are building a release then prepare building a patch by looking up some data 465 # from the previous release. 466 my %source_data = (); 467 if ($installer::globals::is_release) 468 { 469 my $source_component_table = $installer::globals::source_msi->GetTable("Component"); 470 my $component_column_index = $source_component_table->GetColumnIndex("Component"); 471 my $component_id_column_index = $source_component_table->GetColumnIndex("ComponentId"); 472 my $key_path_column_index = $source_component_table->GetColumnIndex("KeyPath"); 473 foreach my $source_row (@{$source_component_table->GetAllRows()}) 474 { 475 my $component_name = $source_row->GetValue($component_column_index); 476 my $component_id = $source_row->GetValue($component_id_column_index); 477 my $key_path = $source_row->GetValue($key_path_column_index); 478 479 $source_data{$component_name} = { 480 'component_id' => $component_id, 481 'key_path' => $key_path 482 }; 483 } 484 } 485 486 # Set up data for the target release. 487 # Use data from the source version where possible. 488 # Create missind data where necessary. 489 490 # Set up the target data with flags that remember whether a 491 # component contains files or registry entries. 492 my %target_data = (); 493 foreach my $name (@$file_component_names) 494 { 495 $target_data{$name} = {'is_file' => 1}; 496 } 497 foreach my $name (@$registry_component_names) 498 { 499 $target_data{$name} = {'is_file' => 0}; 500 } 501 502 # Add values for the ComponentId column. 503 $installer::logger::Lang->printf("preparing Component->ComponentId values\n"); 504 foreach my $name (@$file_component_names,@$registry_component_names) 505 { 506 # Determine the component id. 507 my $guid = $installer::globals::is_release 508 ? $source_data{$name}->{'component_id'} 509 : undef; 510 if (defined $guid) 511 { 512 $installer::logger::Lang->printf(" reusing guid %s\n", $guid); 513 } 514 else 515 { 516 $guid = installer::windows::msiglobal::create_guid(); 517 $installer::logger::Lang->printf(" creating new guid %s\n", $guid); 518 } 519 $target_data{$name}->{'component_id'} = $guid; 520 } 521 522 # Add values for the KeyPath column. 523 $installer::logger::Lang->printf("preparing Component->KeyPath values\n"); 524 foreach my $name (@$file_component_names,@$registry_component_names) 525 { 526 # Determine the key path. 527 my $key_path = $installer::globals::is_release 528 ? $source_data{$name}->{'key_path'} 529 : undef; 530 if (defined $key_path) 531 { 532 $installer::logger::Lang->printf(" reusing key path %s\n", $key_path); 533 } 534 else 535 { 536 if ($target_data{$name}->{'is_file'}) 537 { 538 $key_path = get_component_keypath($name, $files); 539 } 540 else 541 { 542 $key_path = get_component_keypath($name, $registry_entries); 543 } 544 } 545 $target_data{$name}->{'key_path'} = $key_path; 546 } 547 548 return \%target_data; 549} 550 551 552 553 554sub create_component_table_data ($$$$$$) 555{ 556 my ($filesref, $registryref, $dirref, $allfilecomponentsref, $allregistrycomponents, $allvariables) = @_; 557 558 my $target_data = get_component_data($allfilecomponentsref, $allregistrycomponents, $filesref, $registryref); 559 560 my @table_data = (); 561 562 # File components 563 foreach my $name (@$allfilecomponentsref) |
390 { 391 my %onecomponent = (); 392 | 564 { 565 my %onecomponent = (); 566 |
393 $onecomponent{'name'} = ${$allfilecomponentsref}[$i]; 394 $onecomponent{'guid'} = get_component_guid($onecomponent{'name'}); 395 $onecomponent{'directory'} = get_file_component_directory($onecomponent{'name'}, $filesref, $dirref); | 567 $onecomponent{'name'} = $name; 568 $onecomponent{'guid'} = $target_data->{$name}->{'component_id'}; 569 $onecomponent{'directory'} = get_file_component_directory($name, $filesref, $dirref); |
396 if ( $onecomponent{'directory'} eq "IGNORE_COMP" ) { next; } | 570 if ( $onecomponent{'directory'} eq "IGNORE_COMP" ) { next; } |
397 $onecomponent{'attributes'} = get_file_component_attributes($onecomponent{'name'}, $filesref, $allvariables); 398 $onecomponent{'condition'} = get_file_component_condition($onecomponent{'name'}, $filesref); 399 $onecomponent{'keypath'} = get_component_keypath($onecomponent{'name'}, $filesref); | 571 $onecomponent{'attributes'} = get_file_component_attributes($name, $filesref, $allvariables); 572 $onecomponent{'condition'} = get_file_component_condition($name, $filesref); 573 $onecomponent{'keypath'} = $target_data->{$name}->{'key_path'}; |
400 | 574 |
401 $oneline = $onecomponent{'name'} . "\t" . $onecomponent{'guid'} . "\t" . $onecomponent{'directory'} . "\t" 402 . $onecomponent{'attributes'} . "\t" . $onecomponent{'condition'} . "\t" . $onecomponent{'keypath'} . "\n"; 403 404 push(@componenttable, $oneline); | 575 push @table_data, \%onecomponent; |
405 } 406 407 # Registry components | 576 } 577 578 # Registry components |
408 409 for ( my $i = 0; $i <= $#{$allregistrycomponents}; $i++ ) | 579 foreach my $name (@$allregistrycomponents) |
410 { 411 my %onecomponent = (); | 580 { 581 my %onecomponent = (); |
412 413 $onecomponent{'name'} = ${$allregistrycomponents}[$i]; 414 $onecomponent{'guid'} = get_component_guid($onecomponent{'name'}); | 582 583 $onecomponent{'name'} = $name; 584 $onecomponent{'guid'} = $target_data->{$name}->{'component_id'}; |
415 $onecomponent{'directory'} = get_registry_component_directory(); | 585 $onecomponent{'directory'} = get_registry_component_directory(); |
416 $onecomponent{'attributes'} = get_registry_component_attributes($onecomponent{'name'}, $allvariables); 417 $onecomponent{'condition'} = get_component_condition($onecomponent{'name'}); 418 $onecomponent{'keypath'} = get_component_keypath($onecomponent{'name'}, $registryref); | 586 $onecomponent{'attributes'} = get_registry_component_attributes($name, $allvariables); 587 $onecomponent{'condition'} = get_component_condition($name); 588 $onecomponent{'keypath'} = $target_data->{$name}->{'key_path'}; |
419 | 589 |
420 $oneline = $onecomponent{'name'} . "\t" . $onecomponent{'guid'} . "\t" . $onecomponent{'directory'} . "\t" 421 . $onecomponent{'attributes'} . "\t" . $onecomponent{'condition'} . "\t" . $onecomponent{'keypath'} . "\n"; | 590 push(@table_data, \%onecomponent); 591 } |
422 | 592 |
593 return \@table_data; 594} 595 596 597 598 599################################################################### 600# Creating the file Componen.idt dynamically 601# Content: 602# Component ComponentId Directory_ Attributes Condition KeyPath 603################################################################### 604 605 606sub create_component_table ($$) 607{ 608 my ($table_data, $basedir) = @_; 609 610 my @componenttable = (); 611 612 my ($oneline, $infoline); 613 614 installer::windows::idtglobal::write_idt_header(\@componenttable, "component"); 615 616 foreach my $item (@$table_data) 617 { 618 $oneline = sprintf("%s\t%s\t%s\t%s\t%s\t%s\n", 619 $item->{'name'}, 620 $item->{'guid'}, 621 $item->{'directory'}, 622 $item->{'attributes'}, 623 $item->{'condition'}, 624 $item->{'keypath'}); |
|
423 push(@componenttable, $oneline); | 625 push(@componenttable, $oneline); |
424 } | 626 } |
425 426 # Saving the file 427 428 my $componenttablename = $basedir . $installer::globals::separator . "Componen.idt"; 429 installer::files::save_file($componenttablename ,\@componenttable); 430 $infoline = "Created idt file: $componenttablename\n"; 431 $installer::logger::Lang->print($infoline); 432} 433 | 627 628 # Saving the file 629 630 my $componenttablename = $basedir . $installer::globals::separator . "Componen.idt"; 631 installer::files::save_file($componenttablename ,\@componenttable); 632 $infoline = "Created idt file: $componenttablename\n"; 633 $installer::logger::Lang->print($infoline); 634} 635 |
636 637 638 |
|
434#################################################################################### 435# Returning a component for a scp module gid. 436# Pairs are saved in the files collector. 437#################################################################################### 438 439sub get_component_name_from_modulegid 440{ 441 my ($modulegid, $filesref) = @_; --- 66 unchanged lines hidden (view full) --- 508 509 installer::files::save_file($environmentfilename ,$environmentfile); 510 $infoline = "Updated idt file: $environmentfilename\n"; 511 $installer::logger::Lang->print($infoline); 512 513 } 514} 515 | 639#################################################################################### 640# Returning a component for a scp module gid. 641# Pairs are saved in the files collector. 642#################################################################################### 643 644sub get_component_name_from_modulegid 645{ 646 my ($modulegid, $filesref) = @_; --- 66 unchanged lines hidden (view full) --- 713 714 installer::files::save_file($environmentfilename ,$environmentfile); 715 $infoline = "Updated idt file: $environmentfilename\n"; 716 $installer::logger::Lang->print($infoline); 717 718 } 719} 720 |
721 722 723 724sub apply_component_translation ($@) 725{ 726 my ($translation_map, @component_names) = @_; 727 728 my @translated_names = (); 729 foreach my $component_name (@component_names) 730 { 731 my $translated_name = $translation_map->{$component_name}; 732 if (defined $translated_name) 733 { 734 push @translated_names, $translated_name; 735 } 736 else 737 { 738 push @translated_names, $component_name; 739 } 740 } 741 742 return @translated_names; 743} 744 745 |
|
5161; | 7461; |