featurecomponent.pm (b274bc22) featurecomponent.pm (1ba1fd99)
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

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

25
26use installer::converter;
27use installer::existence;
28use installer::exiter;
29use installer::files;
30use installer::globals;
31use installer::windows::idtglobal;
32
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

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

25
26use installer::converter;
27use installer::existence;
28use installer::exiter;
29use installer::files;
30use installer::globals;
31use installer::windows::idtglobal;
32
33use strict;
34
35
33#################################################################################
34# Collecting all pairs of features and components from the files collector
35#################################################################################
36
36#################################################################################
37# Collecting all pairs of features and components from the files collector
38#################################################################################
39
37sub create_featurecomponent_table_from_files_collector
40sub create_featurecomponent_table_from_files_collector ($$)
38{
39 my ($featurecomponenttableref, $filesref) = @_;
40
41{
42 my ($featurecomponenttableref, $filesref) = @_;
43
41 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
44 foreach my $onefile (@$filesref)
42 {
45 {
43 my $onefile = ${$filesref}[$i];
44
45 my $filecomponent = $onefile->{'componentname'};
46 my $filemodules = $onefile->{'modules'};
47
48 if ( $filecomponent eq "" )
49 {
46 my $filecomponent = $onefile->{'componentname'};
47 my $filemodules = $onefile->{'modules'};
48
49 if ( $filecomponent eq "" )
50 {
50 installer::exiter::exit_program("ERROR: No component defined for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector");
51 installer::exiter::exit_program(
52 sprintf("ERROR: No component defined for file %s", $onefile->{'Name'}),
53 "create_featurecomponent_table_from_files_collector");
51 }
54 }
52 if ( $filemodules eq "" )
55 if ( ! defined $filemodules)
56 {
57 # Temporary for files created from source installation set.
58 die;
59 }
60 if ($filemodules eq "")
53 {
61 {
54 installer::exiter::exit_program("ERROR: No modules found for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector");
62 installer::exiter::exit_program(
63 sprintf("ERROR: No modules found for file %s", $onefile->{'Name'}),
64 "create_featurecomponent_table_from_files_collector");
55 }
56
57 my $filemodulesarrayref = installer::converter::convert_stringlist_into_array(\$filemodules, ",");
58
65 }
66
67 my $filemodulesarrayref = installer::converter::convert_stringlist_into_array(\$filemodules, ",");
68
59 for ( my $j = 0; $j <= $#{$filemodulesarrayref}; $j++ )
69 foreach my $onemodule (@$filemodulesarrayref)
60 {
61 my %featurecomponent = ();
62
70 {
71 my %featurecomponent = ();
72
63 my $onemodule = ${$filemodulesarrayref}[$j];
64 $onemodule =~ s/\s*$//;
65 $featurecomponent{'Feature'} = $onemodule;
66 $featurecomponent{'Component'} = $filecomponent;
67
68 # Attention: Features are renamed, because the maximum length is 38.
69 # But in the files collector ($filesref), the original names are saved.
70
71 installer::windows::idtglobal::shorten_feature_gid(\$featurecomponent{'Feature'});
72
73 $onemodule =~ s/\s*$//;
74 $featurecomponent{'Feature'} = $onemodule;
75 $featurecomponent{'Component'} = $filecomponent;
76
77 # Attention: Features are renamed, because the maximum length is 38.
78 # But in the files collector ($filesref), the original names are saved.
79
80 installer::windows::idtglobal::shorten_feature_gid(\$featurecomponent{'Feature'});
81
73 $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n";
82 my $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n";
74
75 # control of uniqueness
76
77 if (! installer::existence::exists_in_array($oneline, $featurecomponenttableref))
78 {
79 push(@{$featurecomponenttableref}, $oneline);
80 }
81 }
82 }
83}
84
83
84 # control of uniqueness
85
86 if (! installer::existence::exists_in_array($oneline, $featurecomponenttableref))
87 {
88 push(@{$featurecomponenttableref}, $oneline);
89 }
90 }
91 }
92}
93
85#################################################################################
86# Collecting all pairs of features and components from the registry collector
87#################################################################################
88
94
89sub create_featurecomponent_table_from_registry_collector
95
96
97=head2 create_featurecomponent_table_from_registry_collector ($featurecomponenttableref, $registryref)
98
99 Add entries for the FeatureComponent table for components that contain registry entries.
100
101=cut
102sub create_featurecomponent_table_from_registry_collector ($$)
90{
91 my ($featurecomponenttableref, $registryref) = @_;
92
103{
104 my ($featurecomponenttableref, $registryref) = @_;
105
93 for ( my $i = 0; $i <= $#{$registryref}; $i++ )
106 my $replacement_count = 0;
107 my $unique_count = 0;
108 foreach my $oneregistry (@$registryref)
94 {
109 {
95 my $oneregistry = ${$registryref}[$i];
96
97 my $registrycomponent = $oneregistry->{'componentname'};
98 my $registrymodule = $oneregistry->{'ModuleID'};
99
100 if ( $registrycomponent eq "" )
110 my $component_name = $oneregistry->{'componentname'};
111 if ($component_name eq "")
101 {
112 {
102 installer::exiter::exit_program("ERROR: No component defined for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector");
113 installer::exiter::exit_program(
114 sprintf("ERROR: No component defined for registry %s", $oneregistry->{'gid'}),
115 "create_featurecomponent_table_from_registry_collector");
103 }
116 }
104 if ( $registrymodule eq "" )
117
118 my $feature_name = $oneregistry->{'ModuleID'};
119 if ($feature_name eq "")
105 {
120 {
106 installer::exiter::exit_program("ERROR: No modules found for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector");
121 installer::exiter::exit_program(
122 sprintf("ERROR: No modules found for registry %s", $oneregistry->{'gid'}),
123 "create_featurecomponent_table_from_registry_collector");
107 }
108
124 }
125
109 my %featurecomponent = ();
110
111 $featurecomponent{'Feature'} = $registrymodule;
112 $featurecomponent{'Component'} = $registrycomponent;
113
114 # Attention: Features are renamed, because the maximum length is 38.
115 # But in the files collector ($filesref), the original names are saved.
116
126 # Attention: Features are renamed, because the maximum length is 38.
127 # But in the files collector ($filesref), the original names are saved.
128
117 installer::windows::idtglobal::shorten_feature_gid(\$featurecomponent{'Feature'});
118
119 $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n";
120
121 # control of uniqueness
122
123 if (! installer::existence::exists_in_array($oneline, $featurecomponenttableref))
129 $feature_name = installer::windows::idtglobal::create_shortend_feature_gid($feature_name);
130
131 my $oneline = sprintf("%s\t%s\n", $feature_name, $component_name);
132 if ( ! installer::existence::exists_in_array($oneline, $featurecomponenttableref))
124 {
133 {
125 push(@{$featurecomponenttableref}, $oneline);
126 }
127 }
134 push(@$featurecomponenttableref, $oneline);
135 ++$unique_count;
136 }
137 else
138 {
139 $installer::logger::Lang->printf("feature component pair already exists\n");
140 }
141 }
142 $installer::logger::Lang->printf(
143 "replaced %d (%d) of %d component names in FeatureComponent table\n",
144 $unique_count,
145 $replacement_count,
146 scalar @$registryref);
128}
129
130#################################################################################
131# Collecting all feature that are listed in the featurecomponent table.
132#################################################################################
133
147}
148
149#################################################################################
150# Collecting all feature that are listed in the featurecomponent table.
151#################################################################################
152
134sub collect_all_feature
153sub collect_all_features
135{
136 my ($featurecomponenttable) = @_;
137
138 my @allfeature = ();
139
140 for ( my $i = 3; $i <= $#{$featurecomponenttable}; $i++ ) # beginning in line 4
141 {
142 my $oneline = ${$featurecomponenttable}[$i];
143
144 if ( $oneline =~ /^\s*(\S+)\s+(\S+)\s*$/ )
145 {
146 my $feature = $1;
147
154{
155 my ($featurecomponenttable) = @_;
156
157 my @allfeature = ();
158
159 for ( my $i = 3; $i <= $#{$featurecomponenttable}; $i++ ) # beginning in line 4
160 {
161 my $oneline = ${$featurecomponenttable}[$i];
162
163 if ( $oneline =~ /^\s*(\S+)\s+(\S+)\s*$/ )
164 {
165 my $feature = $1;
166
148 if (! installer::existence::exists_in_array($feature, \@allfeature)) { push(@allfeature, $feature); }
167 if (! installer::existence::exists_in_array($feature, \@allfeature))
168 {
169 push(@allfeature, $feature);
170 }
149 }
150 }
151
152 return \@allfeature;
153}
154
155#################################################################################
156# On Win98 and Win Me there seems to be the problem, that maximum 817
157# components can be added to a feature. Even if Windows Installer 2.0
158# is used.
159#################################################################################
160
161sub check_number_of_components_at_feature
162{
163 my ($featurecomponenttable) = @_;
164
165 $installer::logger::Lang->print("\n");
166 $installer::logger::Lang->print("Checking number of components at features. Maximum is 817 (for Win 98 and Win Me)\n");
167
171 }
172 }
173
174 return \@allfeature;
175}
176
177#################################################################################
178# On Win98 and Win Me there seems to be the problem, that maximum 817
179# components can be added to a feature. Even if Windows Installer 2.0
180# is used.
181#################################################################################
182
183sub check_number_of_components_at_feature
184{
185 my ($featurecomponenttable) = @_;
186
187 $installer::logger::Lang->print("\n");
188 $installer::logger::Lang->print("Checking number of components at features. Maximum is 817 (for Win 98 and Win Me)\n");
189
168 my $allfeature = collect_all_feature($featurecomponenttable);
190 my $allfeature = collect_all_features($featurecomponenttable);
169
170 for ( my $i = 0; $i <= $#{$allfeature}; $i++ )
171 {
172 my $onefeature = ${$allfeature}[$i];
173 my $featurecomponents = 0;
174
175 for ( my $j = 0; $j <= $#{$featurecomponenttable}; $j++ )
176 {

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

191}
192
193#################################################################################
194# Creating the file FeatureC.idt dynamically
195# Content:
196# Feature Component
197#################################################################################
198
191
192 for ( my $i = 0; $i <= $#{$allfeature}; $i++ )
193 {
194 my $onefeature = ${$allfeature}[$i];
195 my $featurecomponents = 0;
196
197 for ( my $j = 0; $j <= $#{$featurecomponenttable}; $j++ )
198 {

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

213}
214
215#################################################################################
216# Creating the file FeatureC.idt dynamically
217# Content:
218# Feature Component
219#################################################################################
220
199sub create_featurecomponent_table
221sub create_featurecomponent_table ($$$)
200{
201 my ($filesref, $registryref, $basedir) = @_;
202
203 my @featurecomponenttable = ();
204 my $infoline;
205
206 installer::windows::idtglobal::write_idt_header(\@featurecomponenttable, "featurecomponent");
207
208 # This is the first time, that features and componentes are related
209 # Problem: How about created profiles, configurationfiles, services.rdb
210 # -> simple solution: putting them all to the root module
211 # Otherwise profiles and configurationfiles cannot be created the way, they are now created
212 # -> especially a problem for the configurationfiles! # ToDo
213 # Very good: All ProfileItems belong to the root
214 # services.rdb belongs to the root anyway.
215
216 # At the moment only the files are related to components (and the files know their modules).
217 # The component for each file is written into the files collector $filesinproductlanguageresolvedarrayref
218
222{
223 my ($filesref, $registryref, $basedir) = @_;
224
225 my @featurecomponenttable = ();
226 my $infoline;
227
228 installer::windows::idtglobal::write_idt_header(\@featurecomponenttable, "featurecomponent");
229
230 # This is the first time, that features and componentes are related
231 # Problem: How about created profiles, configurationfiles, services.rdb
232 # -> simple solution: putting them all to the root module
233 # Otherwise profiles and configurationfiles cannot be created the way, they are now created
234 # -> especially a problem for the configurationfiles! # ToDo
235 # Very good: All ProfileItems belong to the root
236 # services.rdb belongs to the root anyway.
237
238 # At the moment only the files are related to components (and the files know their modules).
239 # The component for each file is written into the files collector $filesinproductlanguageresolvedarrayref
240
219 create_featurecomponent_table_from_files_collector(\@featurecomponenttable, $filesref);
241 create_featurecomponent_table_from_files_collector(
242 \@featurecomponenttable,
243 $filesref);
220
244
221 create_featurecomponent_table_from_registry_collector(\@featurecomponenttable, $registryref);
245 create_featurecomponent_table_from_registry_collector(
246 \@featurecomponenttable,
247 $registryref);
222
223 # Additional components have to be added here
224
225 # Checking, whether there are more than 817 components at a feature
226
227 check_number_of_components_at_feature(\@featurecomponenttable);
228
229 # Saving the file
230
231 my $featurecomponenttablename = $basedir . $installer::globals::separator . "FeatureC.idt";
232 installer::files::save_file($featurecomponenttablename ,\@featurecomponenttable);
233 $installer::logger::Lang->printf("Created idt file: %s\n", $featurecomponenttablename);
234}
235
2361;
248
249 # Additional components have to be added here
250
251 # Checking, whether there are more than 817 components at a feature
252
253 check_number_of_components_at_feature(\@featurecomponenttable);
254
255 # Saving the file
256
257 my $featurecomponenttablename = $basedir . $installer::globals::separator . "FeatureC.idt";
258 installer::files::save_file($featurecomponenttablename ,\@featurecomponenttable);
259 $installer::logger::Lang->printf("Created idt file: %s\n", $featurecomponenttablename);
260}
261
2621;