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 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23 24package installer::windows::featurecomponent; 25 26use installer::converter; 27use installer::existence; 28use installer::exiter; 29use installer::files; 30use installer::globals; 31use installer::windows::idtglobal; 32 33################################################################################# 34# Collecting all pairs of features and components from the files collector 35################################################################################# 36 37sub create_featurecomponent_table_from_files_collector 38{ 39 my ($featurecomponenttableref, $filesref) = @_; 40 41 for ( my $i = 0; $i <= $#{$filesref}; $i++ ) 42 { 43 my $onefile = ${$filesref}[$i]; 44 45 my $filecomponent = $onefile->{'componentname'}; 46 my $filemodules = $onefile->{'modules'}; 47 48 if ( $filecomponent eq "" ) 49 { 50 installer::exiter::exit_program("ERROR: No component defined for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector"); 51 } 52 if ( $filemodules eq "" ) 53 { 54 installer::exiter::exit_program("ERROR: No modules found for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector"); 55 } 56 57 my $filemodulesarrayref = installer::converter::convert_stringlist_into_array(\$filemodules, ","); 58 59 for ( my $j = 0; $j <= $#{$filemodulesarrayref}; $j++ ) 60 { 61 my %featurecomponent = (); 62 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 $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 85################################################################################# 86# Collecting all pairs of features and components from the registry collector 87################################################################################# 88 89sub create_featurecomponent_table_from_registry_collector 90{ 91 my ($featurecomponenttableref, $registryref) = @_; 92 93 for ( my $i = 0; $i <= $#{$registryref}; $i++ ) 94 { 95 my $oneregistry = ${$registryref}[$i]; 96 97 my $registrycomponent = $oneregistry->{'componentname'}; 98 my $registrymodule = $oneregistry->{'ModuleID'}; 99 100 if ( $registrycomponent eq "" ) 101 { 102 installer::exiter::exit_program("ERROR: No component defined for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector"); 103 } 104 if ( $registrymodule eq "" ) 105 { 106 installer::exiter::exit_program("ERROR: No modules found for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector"); 107 } 108 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 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)) 124 { 125 push(@{$featurecomponenttableref}, $oneline); 126 } 127 } 128} 129 130################################################################################# 131# Collecting all feature that are listed in the featurecomponent table. 132################################################################################# 133 134sub collect_all_feature 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 148 if (! installer::existence::exists_in_array($feature, \@allfeature)) { push(@allfeature, $feature); } 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 168 my $allfeature = collect_all_feature($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 { 177 if ( ${$featurecomponenttable}[$j] =~ /^\s*\Q$onefeature\E\s+(\S+)\s*$/ ) { $featurecomponents++; } 178 } 179 180 if ( $featurecomponents > 816 ) 181 { 182 installer::exiter::exit_program("ERROR: More than 816 components ($featurecomponents) at feature $onefeature. This causes problems on Win 98 and Win Me!", "check_number_of_components_at_feature"); 183 } 184 185 # Logging the result 186 187 $installer::logger::Lang->printf("Number of components at feature $onefeature : %s\n", $featurecomponents); 188 } 189 190 $installer::logger::Lang->print("\n"); 191} 192 193################################################################################# 194# Creating the file FeatureC.idt dynamically 195# Content: 196# Feature Component 197################################################################################# 198 199sub 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 219 create_featurecomponent_table_from_files_collector(\@featurecomponenttable, $filesref); 220 221 create_featurecomponent_table_from_registry_collector(\@featurecomponenttable, $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; 237