feature.pm (b274bc22) feature.pm (677600b0)
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

--- 349 unchanged lines hidden (view full) ---

358}
359
360#################################################################################
361# Creating the file Feature.idt dynamically
362# Content:
363# Feature Feature_Parent Title Description Display Level Directory_ Attributes
364#################################################################################
365
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

--- 349 unchanged lines hidden (view full) ---

358}
359
360#################################################################################
361# Creating the file Feature.idt dynamically
362# Content:
363# Feature Feature_Parent Title Description Display Level Directory_ Attributes
364#################################################################################
365
366sub create_feature_table
366sub prepare_feature_table ($$$)
367{
367{
368 my ($modulesref, $basedir, $languagesarrayref, $allvariableshashref) = @_;
368 my ($modules, $language, $variables) = @_;
369
369
370 for ( my $m = 0; $m <= $#{$languagesarrayref}; $m++ )
371 {
372 my $onelanguage = ${$languagesarrayref}[$m];
373
374 my $infoline;
370 my $features = [];
371
372 foreach my $onefeature (@$modules)
373 {
374 # Java and Ada only, if the correct settings are set
375 my $styles = $onefeature->{'Styles'} // "";
376 if (( $styles =~ /\bJAVAMODULE\b/ ) && ( ! ($variables->{'JAVAPRODUCT'} ))) { next; }
375
377
376 my @featuretable = ();
378 # Controlling the language!
379 # Only language independent feature or feature with the correct language will be included into the table
380
381 next if $onefeature->{'ismultilingual'} && ($onefeature->{'specificlanguage'} ne $language);
377
382
378 installer::windows::idtglobal::write_idt_header(\@featuretable, "feature");
383 my $feature_gid =get_feature_gid($onefeature);
379
384
380 for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
381 {
382 my $onefeature = ${$modulesref}[$i];
385 my $feature = {
386 'Feature' => $feature_gid,
387 'Feature_Parent' => get_feature_parent($onefeature),
388 'Title' => $onefeature->{'Name'},
389 'Description' => $onefeature->{'Description'},
390 'Display' => get_feature_display($onefeature),
391 'Level' => get_feature_level($onefeature),
392 'Directory_' => get_feature_directory($onefeature),
393 'Attributes' => get_feature_attributes($onefeature)
394 };
395 push @$features, $feature;
383
396
384 # Java and Ada only, if the correct settings are set
385 my $styles = "";
386 if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
387 if (( $styles =~ /\bJAVAMODULE\b/ ) && ( ! ($allvariableshashref->{'JAVAPRODUCT'} ))) { next; }
388 if (( $styles =~ /\bADAMODULE\b/ ) && ( ! ($allvariableshashref->{'ADAPRODUCT'} ))) { next; }
397 # collecting all feature in global feature collector (so that properties can be set in property table)
398 $installer::globals::featurecollector{$feature_gid} = 1;
399
400 # collecting all language feature in feature collector for check of language selection
401 if (( $styles =~ /\bSHOW_MULTILINGUAL_ONLY\b/ ) && $onefeature->{'ParentID'} ne $installer::globals::rootmodulegid)
402 {
403 $installer::globals::multilingual_only_modules{$feature_gid} = 1;
404 }
389
405
390 # Controlling the language!
391 # Only language independent feature or feature with the correct language will be included into the table
392
393 if (! (!(( $onefeature->{'ismultilingual'} )) || ( $onefeature->{'specificlanguage'} eq $onelanguage )) ) { next; }
406 # collecting all application feature in global feature collector for check of application selection
407 if ( $styles =~ /\bAPPLICATIONMODULE\b/ )
408 {
409 $installer::globals::application_modules{$feature_gid} = 1;
410 }
411 }
394
412
395 my %feature = ();
396
397 $feature{'feature'} = get_feature_gid($onefeature);
398 $feature{'feature_parent'} = get_feature_parent($onefeature);
399 # if ( $onefeature->{'ParentID'} eq "" ) { $feature{'feature_parent'} = ""; } # Root has no parent
400 $feature{'Title'} = $onefeature->{'Name'};
401 $feature{'Description'} = $onefeature->{'Description'};
402 $feature{'Display'} = get_feature_display($onefeature);
403 $feature{'Level'} = get_feature_level($onefeature);
404 $feature{'Directory_'} = get_feature_directory($onefeature);
405 $feature{'Attributes'} = get_feature_attributes($onefeature);
413 return $features;
414}
406
415
407 my $oneline = $feature{'feature'} . "\t" . $feature{'feature_parent'} . "\t" . $feature{'Title'} . "\t"
408 . $feature{'Description'} . "\t" . $feature{'Display'} . "\t" . $feature{'Level'} . "\t"
409 . $feature{'Directory_'} . "\t" . $feature{'Attributes'} . "\n";
410
416
411 push(@featuretable, $oneline);
412
417
413 # collecting all feature in global feature collector (so that properties can be set in property table)
414 if ( ! installer::existence::exists_in_array($feature{'feature'}, \@installer::globals::featurecollector) )
415 {
416 push(@installer::globals::featurecollector, $feature{'feature'});
417 }
418
419 # collecting all language feature in feature collector for check of language selection
420 if (( $styles =~ /\bSHOW_MULTILINGUAL_ONLY\b/ ) && ( $onefeature->{'ParentID'} ne $installer::globals::rootmodulegid ))
421 {
422 $installer::globals::multilingual_only_modules{$feature{'feature'}} = 1;
423 }
424
418
425 # collecting all application feature in global feature collector for check of application selection
426 if ( $styles =~ /\bAPPLICATIONMODULE\b/ )
427 {
428 $installer::globals::application_modules{$feature{'feature'}} = 1;
429 }
430 }
419=head add_missing_features($features)
431
420
432 # Saving the file
433
434 my $featuretablename = $basedir . $installer::globals::separator . "Feature.idt" . "." . $onelanguage;
435 installer::files::save_file($featuretablename ,\@featuretable);
436 $installer::logger::Lang->printf("Created idt file: %s\n", $featuretablename);
437 }
421 When we are building a release, then there may be features missing
422 that where present in the source release. As missing features
423 would prevent patches from being created, we add the missing
424 features.
425
426 The returned feature hash is either identical to the given
427 $features or is a copy with the missing features added.
428
429=cut
430
431sub add_missing_features ($)
432{
433 my ($features) = @_;
434
435 return $features if ! $installer::globals::is_release;
436
437 # Aquire the feature list of the source release.
438 my $source_feature_table = $installer::globals::source_msi->GetTable("Feature");
439 my $feature_column_index = $source_feature_table->GetColumnIndex("Feature");
440
441 # Prepare fast lookup of the target features.
442 my %target_feature_map = map {$_->{'Feature'} => $_} @$features;
443
444 # Find missing features.
445 my @missing_features = ();
446 foreach my $source_feature_row (@{$source_feature_table->GetAllRows()})
447 {
448 my $feature_gid = $source_feature_row->GetValue($feature_column_index);
449 if ( ! defined $target_feature_map{$feature_gid})
450 {
451 push @missing_features, $source_feature_row;
452 }
453 }
454
455 # Return when there are no missing features.
456 return $features if scalar @missing_features==0;
457
458 # Process the missing features.
459 my $extended_features = [@$features];
460 foreach my $missing_feature_row (@missing_features)
461 {
462 my %feature = map
463 {$_ => $missing_feature_row->GetValue($_)}
464 ('Feature', 'Feature_Parent', 'Title', 'Description', 'Display', 'Level', 'Directory_', 'Attributes');
465 push @$extended_features, \%feature;
466
467 $installer::logger::Lang->printf("added missing feature %s\n", $feature->{'Feature'});
468 }
469 return $extended_features;
438}
439
470}
471
472
473
474
475sub create_feature_table ($$$)
476{
477 my ($basedir, $language, $features) = @_;
478
479 my @feature_table = ();
480 installer::windows::idtglobal::write_idt_header(\@feature_table, "feature");
481
482 foreach my $feature (@$features)
483 {
484 my $line = join("\t",
485 $feature->{'Feature'},
486 $feature->{'Feature_Parent'},
487 $feature->{'Title'},
488 $feature->{'Description'},
489 $feature->{'Display'},
490 $feature->{'Level'},
491 $feature->{'Directory_'},
492 $feature->{'Attributes'}) . "\n";
493
494 push(@feature_table, $line);
495 }
496
497 my $filename = $basedir . $installer::globals::separator . "Feature.idt" . "." . $language;
498 installer::files::save_file($filename ,\@feature_table);
499 $installer::logger::Lang->printf("Created idt file: %s\n", $filename);
500}
501
4401;
5021;