1*cdf0e10cSrcweir#************************************************************************* 2*cdf0e10cSrcweir# 3*cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir# 5*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir# 7*cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir# 9*cdf0e10cSrcweir# This file is part of OpenOffice.org. 10*cdf0e10cSrcweir# 11*cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir# only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir# 15*cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir# 21*cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir# version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir# <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir# for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir# 26*cdf0e10cSrcweir#************************************************************************* 27*cdf0e10cSrcweir 28*cdf0e10cSrcweirpackage installer::windows::featurecomponent; 29*cdf0e10cSrcweir 30*cdf0e10cSrcweiruse installer::converter; 31*cdf0e10cSrcweiruse installer::existence; 32*cdf0e10cSrcweiruse installer::exiter; 33*cdf0e10cSrcweiruse installer::files; 34*cdf0e10cSrcweiruse installer::globals; 35*cdf0e10cSrcweiruse installer::windows::idtglobal; 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir################################################################################# 38*cdf0e10cSrcweir# Collecting all pairs of features and components from the files collector 39*cdf0e10cSrcweir################################################################################# 40*cdf0e10cSrcweir 41*cdf0e10cSrcweirsub create_featurecomponent_table_from_files_collector 42*cdf0e10cSrcweir{ 43*cdf0e10cSrcweir my ($featurecomponenttableref, $filesref) = @_; 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$filesref}; $i++ ) 46*cdf0e10cSrcweir { 47*cdf0e10cSrcweir my $onefile = ${$filesref}[$i]; 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir my $filecomponent = $onefile->{'componentname'}; 50*cdf0e10cSrcweir my $filemodules = $onefile->{'modules'}; 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir if ( $filecomponent eq "" ) 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir installer::exiter::exit_program("ERROR: No component defined for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector"); 55*cdf0e10cSrcweir } 56*cdf0e10cSrcweir if ( $filemodules eq "" ) 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir installer::exiter::exit_program("ERROR: No modules found for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector"); 59*cdf0e10cSrcweir } 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir my $filemodulesarrayref = installer::converter::convert_stringlist_into_array(\$filemodules, ","); 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$filemodulesarrayref}; $j++ ) 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir my %featurecomponent = (); 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir my $onemodule = ${$filemodulesarrayref}[$j]; 68*cdf0e10cSrcweir $onemodule =~ s/\s*$//; 69*cdf0e10cSrcweir $featurecomponent{'Feature'} = $onemodule; 70*cdf0e10cSrcweir $featurecomponent{'Component'} = $filecomponent; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir # Attention: Features are renamed, because the maximum length is 38. 73*cdf0e10cSrcweir # But in the files collector ($filesref), the original names are saved. 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir installer::windows::idtglobal::shorten_feature_gid(\$featurecomponent{'Feature'}); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n"; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir # control of uniqueness 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir if (! installer::existence::exists_in_array($oneline, $featurecomponenttableref)) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir push(@{$featurecomponenttableref}, $oneline); 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir} 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir################################################################################# 90*cdf0e10cSrcweir# Collecting all pairs of features and components from the registry collector 91*cdf0e10cSrcweir################################################################################# 92*cdf0e10cSrcweir 93*cdf0e10cSrcweirsub create_featurecomponent_table_from_registry_collector 94*cdf0e10cSrcweir{ 95*cdf0e10cSrcweir my ($featurecomponenttableref, $registryref) = @_; 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$registryref}; $i++ ) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir my $oneregistry = ${$registryref}[$i]; 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir my $registrycomponent = $oneregistry->{'componentname'}; 102*cdf0e10cSrcweir my $registrymodule = $oneregistry->{'ModuleID'}; 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir if ( $registrycomponent eq "" ) 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir installer::exiter::exit_program("ERROR: No component defined for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector"); 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir if ( $registrymodule eq "" ) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir installer::exiter::exit_program("ERROR: No modules found for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector"); 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir my %featurecomponent = (); 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir $featurecomponent{'Feature'} = $registrymodule; 116*cdf0e10cSrcweir $featurecomponent{'Component'} = $registrycomponent; 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir # Attention: Features are renamed, because the maximum length is 38. 119*cdf0e10cSrcweir # But in the files collector ($filesref), the original names are saved. 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir installer::windows::idtglobal::shorten_feature_gid(\$featurecomponent{'Feature'}); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n"; 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir # control of uniqueness 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir if (! installer::existence::exists_in_array($oneline, $featurecomponenttableref)) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir push(@{$featurecomponenttableref}, $oneline); 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir} 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir################################################################################# 135*cdf0e10cSrcweir# Collecting all feature that are listed in the featurecomponent table. 136*cdf0e10cSrcweir################################################################################# 137*cdf0e10cSrcweir 138*cdf0e10cSrcweirsub collect_all_feature 139*cdf0e10cSrcweir{ 140*cdf0e10cSrcweir my ($featurecomponenttable) = @_; 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir my @allfeature = (); 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir for ( my $i = 3; $i <= $#{$featurecomponenttable}; $i++ ) # beginning in line 4 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir my $oneline = ${$featurecomponenttable}[$i]; 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir if ( $oneline =~ /^\s*(\S+)\s+(\S+)\s*$/ ) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir my $feature = $1; 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir if (! installer::existence::exists_in_array($feature, \@allfeature)) { push(@allfeature, $feature); } 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir return \@allfeature; 157*cdf0e10cSrcweir} 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir################################################################################# 160*cdf0e10cSrcweir# On Win98 and Win Me there seems to be the problem, that maximum 817 161*cdf0e10cSrcweir# components can be added to a feature. Even if Windows Installer 2.0 162*cdf0e10cSrcweir# is used. 163*cdf0e10cSrcweir################################################################################# 164*cdf0e10cSrcweir 165*cdf0e10cSrcweirsub check_number_of_components_at_feature 166*cdf0e10cSrcweir{ 167*cdf0e10cSrcweir my ($featurecomponenttable) = @_; 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir my $infoline = "\nChecking number of components at features. Maximum is 817 (for Win 98 and Win Me)\n"; 170*cdf0e10cSrcweir push(@installer::globals::logfileinfo, $infoline); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir my $allfeature = collect_all_feature($featurecomponenttable); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$allfeature}; $i++ ) 175*cdf0e10cSrcweir { 176*cdf0e10cSrcweir my $onefeature = ${$allfeature}[$i]; 177*cdf0e10cSrcweir my $featurecomponents = 0; 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir for ( my $j = 0; $j <= $#{$featurecomponenttable}; $j++ ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir if ( ${$featurecomponenttable}[$j] =~ /^\s*\Q$onefeature\E\s+(\S+)\s*$/ ) { $featurecomponents++; } 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir if ( $featurecomponents > 816 ) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir 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"); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir # Logging the result 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir $infoline = "Number of components at feature $onefeature : $featurecomponents\n"; 192*cdf0e10cSrcweir push(@installer::globals::logfileinfo, $infoline); 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir $infoline = "\n"; 196*cdf0e10cSrcweir push(@installer::globals::logfileinfo, $infoline); 197*cdf0e10cSrcweir} 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir################################################################################# 200*cdf0e10cSrcweir# Creating the file FeatureC.idt dynamically 201*cdf0e10cSrcweir# Content: 202*cdf0e10cSrcweir# Feature Component 203*cdf0e10cSrcweir################################################################################# 204*cdf0e10cSrcweir 205*cdf0e10cSrcweirsub create_featurecomponent_table 206*cdf0e10cSrcweir{ 207*cdf0e10cSrcweir my ($filesref, $registryref, $basedir) = @_; 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir my @featurecomponenttable = (); 210*cdf0e10cSrcweir my $infoline; 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir installer::windows::idtglobal::write_idt_header(\@featurecomponenttable, "featurecomponent"); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir # This is the first time, that features and componentes are related 215*cdf0e10cSrcweir # Problem: How about created profiles, configurationfiles, services.rdb 216*cdf0e10cSrcweir # -> simple solution: putting them all to the root module 217*cdf0e10cSrcweir # Otherwise profiles and configurationfiles cannot be created the way, they are now created 218*cdf0e10cSrcweir # -> especially a problem for the configurationfiles! # ToDo 219*cdf0e10cSrcweir # Very good: All ProfileItems belong to the root 220*cdf0e10cSrcweir # services.rdb belongs to the root anyway. 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir # At the moment only the files are related to components (and the files know their modules). 223*cdf0e10cSrcweir # The component for each file is written into the files collector $filesinproductlanguageresolvedarrayref 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir create_featurecomponent_table_from_files_collector(\@featurecomponenttable, $filesref); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir create_featurecomponent_table_from_registry_collector(\@featurecomponenttable, $registryref); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir # Additional components have to be added here 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir # Checking, whether there are more than 817 components at a feature 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir check_number_of_components_at_feature(\@featurecomponenttable); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir # Saving the file 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir my $featurecomponenttablename = $basedir . $installer::globals::separator . "FeatureC.idt"; 238*cdf0e10cSrcweir installer::files::save_file($featurecomponenttablename ,\@featurecomponenttable); 239*cdf0e10cSrcweir $infoline = "Created idt file: $featurecomponenttablename\n"; 240*cdf0e10cSrcweir push(@installer::globals::logfileinfo, $infoline); 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir} 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir1;