19780544fSAndrew Rist#************************************************************** 29780544fSAndrew Rist# 39780544fSAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 49780544fSAndrew Rist# or more contributor license agreements. See the NOTICE file 59780544fSAndrew Rist# distributed with this work for additional information 69780544fSAndrew Rist# regarding copyright ownership. The ASF licenses this file 79780544fSAndrew Rist# to you under the Apache License, Version 2.0 (the 89780544fSAndrew Rist# "License"); you may not use this file except in compliance 99780544fSAndrew Rist# with the License. You may obtain a copy of the License at 109780544fSAndrew Rist# 119780544fSAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 129780544fSAndrew Rist# 139780544fSAndrew Rist# Unless required by applicable law or agreed to in writing, 149780544fSAndrew Rist# software distributed under the License is distributed on an 159780544fSAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169780544fSAndrew Rist# KIND, either express or implied. See the License for the 179780544fSAndrew Rist# specific language governing permissions and limitations 189780544fSAndrew Rist# under the License. 199780544fSAndrew Rist# 209780544fSAndrew Rist#************************************************************** 219780544fSAndrew Rist 229780544fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweirpackage installer::windows::featurecomponent; 25cdf0e10cSrcweir 26cdf0e10cSrcweiruse installer::converter; 27cdf0e10cSrcweiruse installer::existence; 28cdf0e10cSrcweiruse installer::exiter; 29cdf0e10cSrcweiruse installer::files; 30cdf0e10cSrcweiruse installer::globals; 31cdf0e10cSrcweiruse installer::windows::idtglobal; 32cdf0e10cSrcweir 33cdf0e10cSrcweir################################################################################# 34cdf0e10cSrcweir# Collecting all pairs of features and components from the files collector 35cdf0e10cSrcweir################################################################################# 36cdf0e10cSrcweir 37cdf0e10cSrcweirsub create_featurecomponent_table_from_files_collector 38cdf0e10cSrcweir{ 39cdf0e10cSrcweir my ($featurecomponenttableref, $filesref) = @_; 40cdf0e10cSrcweir 41cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$filesref}; $i++ ) 42cdf0e10cSrcweir { 43cdf0e10cSrcweir my $onefile = ${$filesref}[$i]; 44cdf0e10cSrcweir 45cdf0e10cSrcweir my $filecomponent = $onefile->{'componentname'}; 46cdf0e10cSrcweir my $filemodules = $onefile->{'modules'}; 47cdf0e10cSrcweir 48cdf0e10cSrcweir if ( $filecomponent eq "" ) 49cdf0e10cSrcweir { 50cdf0e10cSrcweir installer::exiter::exit_program("ERROR: No component defined for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector"); 51cdf0e10cSrcweir } 52cdf0e10cSrcweir if ( $filemodules eq "" ) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir installer::exiter::exit_program("ERROR: No modules found for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector"); 55cdf0e10cSrcweir } 56cdf0e10cSrcweir 57cdf0e10cSrcweir my $filemodulesarrayref = installer::converter::convert_stringlist_into_array(\$filemodules, ","); 58cdf0e10cSrcweir 59cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$filemodulesarrayref}; $j++ ) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir my %featurecomponent = (); 62cdf0e10cSrcweir 63cdf0e10cSrcweir my $onemodule = ${$filemodulesarrayref}[$j]; 64cdf0e10cSrcweir $onemodule =~ s/\s*$//; 65cdf0e10cSrcweir $featurecomponent{'Feature'} = $onemodule; 66cdf0e10cSrcweir $featurecomponent{'Component'} = $filecomponent; 67cdf0e10cSrcweir 68cdf0e10cSrcweir # Attention: Features are renamed, because the maximum length is 38. 69cdf0e10cSrcweir # But in the files collector ($filesref), the original names are saved. 70cdf0e10cSrcweir 71cdf0e10cSrcweir installer::windows::idtglobal::shorten_feature_gid(\$featurecomponent{'Feature'}); 72cdf0e10cSrcweir 73cdf0e10cSrcweir $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n"; 74cdf0e10cSrcweir 75cdf0e10cSrcweir # control of uniqueness 76cdf0e10cSrcweir 77cdf0e10cSrcweir if (! installer::existence::exists_in_array($oneline, $featurecomponenttableref)) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir push(@{$featurecomponenttableref}, $oneline); 80cdf0e10cSrcweir } 81cdf0e10cSrcweir } 82cdf0e10cSrcweir } 83cdf0e10cSrcweir} 84cdf0e10cSrcweir 85cdf0e10cSrcweir################################################################################# 86cdf0e10cSrcweir# Collecting all pairs of features and components from the registry collector 87cdf0e10cSrcweir################################################################################# 88cdf0e10cSrcweir 89cdf0e10cSrcweirsub create_featurecomponent_table_from_registry_collector 90cdf0e10cSrcweir{ 91cdf0e10cSrcweir my ($featurecomponenttableref, $registryref) = @_; 92cdf0e10cSrcweir 93cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$registryref}; $i++ ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir my $oneregistry = ${$registryref}[$i]; 96cdf0e10cSrcweir 97cdf0e10cSrcweir my $registrycomponent = $oneregistry->{'componentname'}; 98cdf0e10cSrcweir my $registrymodule = $oneregistry->{'ModuleID'}; 99cdf0e10cSrcweir 100cdf0e10cSrcweir if ( $registrycomponent eq "" ) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir installer::exiter::exit_program("ERROR: No component defined for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector"); 103cdf0e10cSrcweir } 104cdf0e10cSrcweir if ( $registrymodule eq "" ) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir installer::exiter::exit_program("ERROR: No modules found for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector"); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir my %featurecomponent = (); 110cdf0e10cSrcweir 111cdf0e10cSrcweir $featurecomponent{'Feature'} = $registrymodule; 112cdf0e10cSrcweir $featurecomponent{'Component'} = $registrycomponent; 113cdf0e10cSrcweir 114cdf0e10cSrcweir # Attention: Features are renamed, because the maximum length is 38. 115cdf0e10cSrcweir # But in the files collector ($filesref), the original names are saved. 116cdf0e10cSrcweir 117cdf0e10cSrcweir installer::windows::idtglobal::shorten_feature_gid(\$featurecomponent{'Feature'}); 118cdf0e10cSrcweir 119cdf0e10cSrcweir $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n"; 120cdf0e10cSrcweir 121cdf0e10cSrcweir # control of uniqueness 122cdf0e10cSrcweir 123cdf0e10cSrcweir if (! installer::existence::exists_in_array($oneline, $featurecomponenttableref)) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir push(@{$featurecomponenttableref}, $oneline); 126cdf0e10cSrcweir } 127cdf0e10cSrcweir } 128cdf0e10cSrcweir} 129cdf0e10cSrcweir 130cdf0e10cSrcweir################################################################################# 131cdf0e10cSrcweir# Collecting all feature that are listed in the featurecomponent table. 132cdf0e10cSrcweir################################################################################# 133cdf0e10cSrcweir 134cdf0e10cSrcweirsub collect_all_feature 135cdf0e10cSrcweir{ 136cdf0e10cSrcweir my ($featurecomponenttable) = @_; 137cdf0e10cSrcweir 138cdf0e10cSrcweir my @allfeature = (); 139cdf0e10cSrcweir 140cdf0e10cSrcweir for ( my $i = 3; $i <= $#{$featurecomponenttable}; $i++ ) # beginning in line 4 141cdf0e10cSrcweir { 142cdf0e10cSrcweir my $oneline = ${$featurecomponenttable}[$i]; 143cdf0e10cSrcweir 144cdf0e10cSrcweir if ( $oneline =~ /^\s*(\S+)\s+(\S+)\s*$/ ) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir my $feature = $1; 147cdf0e10cSrcweir 148cdf0e10cSrcweir if (! installer::existence::exists_in_array($feature, \@allfeature)) { push(@allfeature, $feature); } 149cdf0e10cSrcweir } 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir return \@allfeature; 153cdf0e10cSrcweir} 154cdf0e10cSrcweir 155cdf0e10cSrcweir################################################################################# 156cdf0e10cSrcweir# On Win98 and Win Me there seems to be the problem, that maximum 817 157cdf0e10cSrcweir# components can be added to a feature. Even if Windows Installer 2.0 158cdf0e10cSrcweir# is used. 159cdf0e10cSrcweir################################################################################# 160cdf0e10cSrcweir 161cdf0e10cSrcweirsub check_number_of_components_at_feature 162cdf0e10cSrcweir{ 163cdf0e10cSrcweir my ($featurecomponenttable) = @_; 164cdf0e10cSrcweir 165*b274bc22SAndre Fischer $installer::logger::Lang->print("\n"); 166*b274bc22SAndre Fischer $installer::logger::Lang->print("Checking number of components at features. Maximum is 817 (for Win 98 and Win Me)\n"); 167cdf0e10cSrcweir 168cdf0e10cSrcweir my $allfeature = collect_all_feature($featurecomponenttable); 169cdf0e10cSrcweir 170cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$allfeature}; $i++ ) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir my $onefeature = ${$allfeature}[$i]; 173cdf0e10cSrcweir my $featurecomponents = 0; 174cdf0e10cSrcweir 175cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$featurecomponenttable}; $j++ ) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir if ( ${$featurecomponenttable}[$j] =~ /^\s*\Q$onefeature\E\s+(\S+)\s*$/ ) { $featurecomponents++; } 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir if ( $featurecomponents > 816 ) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir 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"); 183cdf0e10cSrcweir } 184cdf0e10cSrcweir 185cdf0e10cSrcweir # Logging the result 186cdf0e10cSrcweir 187*b274bc22SAndre Fischer $installer::logger::Lang->printf("Number of components at feature $onefeature : %s\n", $featurecomponents); 188cdf0e10cSrcweir } 189cdf0e10cSrcweir 190*b274bc22SAndre Fischer $installer::logger::Lang->print("\n"); 191cdf0e10cSrcweir} 192cdf0e10cSrcweir 193cdf0e10cSrcweir################################################################################# 194cdf0e10cSrcweir# Creating the file FeatureC.idt dynamically 195cdf0e10cSrcweir# Content: 196cdf0e10cSrcweir# Feature Component 197cdf0e10cSrcweir################################################################################# 198cdf0e10cSrcweir 199cdf0e10cSrcweirsub create_featurecomponent_table 200cdf0e10cSrcweir{ 201cdf0e10cSrcweir my ($filesref, $registryref, $basedir) = @_; 202cdf0e10cSrcweir 203cdf0e10cSrcweir my @featurecomponenttable = (); 204cdf0e10cSrcweir my $infoline; 205cdf0e10cSrcweir 206cdf0e10cSrcweir installer::windows::idtglobal::write_idt_header(\@featurecomponenttable, "featurecomponent"); 207cdf0e10cSrcweir 208cdf0e10cSrcweir # This is the first time, that features and componentes are related 209cdf0e10cSrcweir # Problem: How about created profiles, configurationfiles, services.rdb 210cdf0e10cSrcweir # -> simple solution: putting them all to the root module 211cdf0e10cSrcweir # Otherwise profiles and configurationfiles cannot be created the way, they are now created 212cdf0e10cSrcweir # -> especially a problem for the configurationfiles! # ToDo 213cdf0e10cSrcweir # Very good: All ProfileItems belong to the root 214cdf0e10cSrcweir # services.rdb belongs to the root anyway. 215cdf0e10cSrcweir 216cdf0e10cSrcweir # At the moment only the files are related to components (and the files know their modules). 217cdf0e10cSrcweir # The component for each file is written into the files collector $filesinproductlanguageresolvedarrayref 218cdf0e10cSrcweir 219cdf0e10cSrcweir create_featurecomponent_table_from_files_collector(\@featurecomponenttable, $filesref); 220cdf0e10cSrcweir 221cdf0e10cSrcweir create_featurecomponent_table_from_registry_collector(\@featurecomponenttable, $registryref); 222cdf0e10cSrcweir 223cdf0e10cSrcweir # Additional components have to be added here 224cdf0e10cSrcweir 225cdf0e10cSrcweir # Checking, whether there are more than 817 components at a feature 226cdf0e10cSrcweir 227cdf0e10cSrcweir check_number_of_components_at_feature(\@featurecomponenttable); 228cdf0e10cSrcweir 229cdf0e10cSrcweir # Saving the file 230cdf0e10cSrcweir 231cdf0e10cSrcweir my $featurecomponenttablename = $basedir . $installer::globals::separator . "FeatureC.idt"; 232cdf0e10cSrcweir installer::files::save_file($featurecomponenttablename ,\@featurecomponenttable); 233*b274bc22SAndre Fischer $installer::logger::Lang->printf("Created idt file: %s\n", $featurecomponenttablename); 234cdf0e10cSrcweir} 235cdf0e10cSrcweir 236*b274bc22SAndre Fischer1; 237