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::inifile; 25cdf0e10cSrcweir 26cdf0e10cSrcweiruse installer::existence; 27cdf0e10cSrcweiruse installer::files; 28cdf0e10cSrcweiruse installer::globals; 29cdf0e10cSrcweiruse installer::windows::idtglobal; 30cdf0e10cSrcweir 31*1ba1fd99SAndre Fischeruse strict; 32*1ba1fd99SAndre Fischer 33cdf0e10cSrcweir#################################################### 34cdf0e10cSrcweir# Setting the profile for a special profileitem 35cdf0e10cSrcweir#################################################### 36cdf0e10cSrcweir 37cdf0e10cSrcweirsub get_profile_for_profileitem 38cdf0e10cSrcweir{ 39cdf0e10cSrcweir my ($profileid, $filesref) = @_; 40cdf0e10cSrcweir 41cdf0e10cSrcweir my $profile = installer::existence::get_specified_file($filesref, $profileid); 42cdf0e10cSrcweir 43cdf0e10cSrcweir return $profile; 44cdf0e10cSrcweir} 45cdf0e10cSrcweir 46cdf0e10cSrcweir#################################################### 47cdf0e10cSrcweir# Checking whether profile is included in patch 48cdf0e10cSrcweir#################################################### 49cdf0e10cSrcweir 50cdf0e10cSrcweirsub profile_has_patch_flag 51cdf0e10cSrcweir{ 52cdf0e10cSrcweir my ($profile) = @_; 53cdf0e10cSrcweir 54cdf0e10cSrcweir my $in_patch = 0; 55cdf0e10cSrcweir 56cdf0e10cSrcweir my $styles = ""; 57cdf0e10cSrcweir if ( $profile->{'Styles'} ) { $styles = $profile->{'Styles'}; } 58cdf0e10cSrcweir if ( $styles =~ /\bPATCH\b/ ) { $in_patch = 1; } 59cdf0e10cSrcweir 60cdf0e10cSrcweir return $in_patch; 61cdf0e10cSrcweir} 62cdf0e10cSrcweir 63cdf0e10cSrcweir#################################################### 64cdf0e10cSrcweir# Checking whether profile is part of product 65cdf0e10cSrcweir#################################################### 66cdf0e10cSrcweir 67cdf0e10cSrcweirsub file_is_part_of_product 68cdf0e10cSrcweir{ 69cdf0e10cSrcweir my ($profilegid, $filesref) = @_; 70cdf0e10cSrcweir 71*1ba1fd99SAndre Fischer foreach my $file (@$filesref) 72cdf0e10cSrcweir { 73*1ba1fd99SAndre Fischer my $filegid = $file->{'gid'}; 74*1ba1fd99SAndre Fischer next unless defined $filegid; 75cdf0e10cSrcweir 76cdf0e10cSrcweir if ( $filegid eq $profilegid ) 77cdf0e10cSrcweir { 78*1ba1fd99SAndre Fischer return 1; 79cdf0e10cSrcweir } 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82*1ba1fd99SAndre Fischer return 0; 83cdf0e10cSrcweir} 84cdf0e10cSrcweir 85cdf0e10cSrcweir########################################################################################################### 86cdf0e10cSrcweir# Creating the file IniFile.idt dynamically 87cdf0e10cSrcweir# Content: 88cdf0e10cSrcweir# IniFile\tFileName\tDirProperty\tSection\tKey\tValue\tAction\tComponent_ 89cdf0e10cSrcweir########################################################################################################### 90cdf0e10cSrcweir 91cdf0e10cSrcweirsub create_inifile_table 92cdf0e10cSrcweir{ 93cdf0e10cSrcweir my ($inifiletableentries, $filesref, $basedir) = @_; 94cdf0e10cSrcweir 95cdf0e10cSrcweir my @inifiletable = (); 96cdf0e10cSrcweir 97cdf0e10cSrcweir installer::windows::idtglobal::write_idt_header(\@inifiletable, "inifile"); 98cdf0e10cSrcweir 99cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$inifiletableentries}; $i++ ) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir my $profileitem = ${$inifiletableentries}[$i]; 102cdf0e10cSrcweir 103cdf0e10cSrcweir my $profileid = $profileitem->{'ProfileID'}; 104cdf0e10cSrcweir 105cdf0e10cSrcweir # Is this profile part of the product? This is not sure, for example in patch process. 106cdf0e10cSrcweir # If the profile is not part of the product, this ProfileItem must be ignored. 107cdf0e10cSrcweir 108cdf0e10cSrcweir if ( ! file_is_part_of_product($profileid, $filesref) ) { next; } 109cdf0e10cSrcweir 110cdf0e10cSrcweir my $profile = get_profile_for_profileitem($profileid, $filesref); 111cdf0e10cSrcweir 112cdf0e10cSrcweir if (( $installer::globals::patch ) && ( ! profile_has_patch_flag($profile) )) { next; } 113cdf0e10cSrcweir 114cdf0e10cSrcweir my %inifile = (); 115cdf0e10cSrcweir 116cdf0e10cSrcweir $inifile{'IniFile'} = $profileitem->{'Inifiletablekey'}; 117cdf0e10cSrcweir $inifile{'FileName'} = $profile->{'Name'}; 118cdf0e10cSrcweir $inifile{'DirProperty'} = $profile->{'uniquedirname'}; 119cdf0e10cSrcweir $inifile{'Section'} = $profileitem->{'Section'}; 120cdf0e10cSrcweir $inifile{'Key'} = $profileitem->{'Key'}; 121cdf0e10cSrcweir $inifile{'Value'} = $profileitem->{'Value'}; 122cdf0e10cSrcweir $inifile{'Action'} = $profileitem->{'Inifiletableaction'}; 123cdf0e10cSrcweir $inifile{'Component_'} = $profile->{'componentname'}; 124cdf0e10cSrcweir 125cdf0e10cSrcweir my $oneline = $inifile{'IniFile'} . "\t" . $inifile{'FileName'} . "\t" . $inifile{'DirProperty'} . "\t" 126cdf0e10cSrcweir . $inifile{'Section'} . "\t" . $inifile{'Key'} . "\t" . $inifile{'Value'} . "\t" 127cdf0e10cSrcweir . $inifile{'Action'} . "\t" . $inifile{'Component_'} . "\n"; 128cdf0e10cSrcweir 129cdf0e10cSrcweir push(@inifiletable, $oneline); 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir # Saving the file 133cdf0e10cSrcweir 134cdf0e10cSrcweir my $inifiletablename = $basedir . $installer::globals::separator . "IniFile.idt"; 135cdf0e10cSrcweir installer::files::save_file($inifiletablename ,\@inifiletable); 136b274bc22SAndre Fischer $installer::logger::Lang->printf("Created idt file: %s\n", $inifiletablename); 137cdf0e10cSrcweir} 138cdf0e10cSrcweir 139cdf0e10cSrcweir1; 140