Update ooo320-m1
[ooovba.git] / solenv / bin / modules / installer / windows / inifile.pm
blob0ed1047236c3bae342ca8f410669443c35c723f1
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: inifile.pm,v $
11 # $Revision: 1.4 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 package installer::windows::inifile;
34 use installer::existence;
35 use installer::files;
36 use installer::globals;
37 use installer::windows::idtglobal;
39 ####################################################
40 # Setting the profile for a special profileitem
41 ####################################################
43 sub get_profile_for_profileitem
45 my ($profileid, $filesref) = @_;
47 my $profile = installer::existence::get_specified_file($filesref, $profileid);
49 return $profile;
52 ####################################################
53 # Checking whether profile is included in patch
54 ####################################################
56 sub profile_has_patch_flag
58 my ($profile) = @_;
60 my $in_patch = 0;
62 my $styles = "";
63 if ( $profile->{'Styles'} ) { $styles = $profile->{'Styles'}; }
64 if ( $styles =~ /\bPATCH\b/ ) { $in_patch = 1; }
66 return $in_patch;
69 ####################################################
70 # Checking whether profile is part of product
71 ####################################################
73 sub file_is_part_of_product
75 my ($profilegid, $filesref) = @_;
77 my $part_of_product = 0;
79 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
81 $onefile = ${$filesref}[$i];
82 my $filegid = $onefile->{'gid'};
84 if ( $filegid eq $profilegid )
86 $part_of_product = 1;
87 last;
91 return $part_of_product;
94 ###########################################################################################################
95 # Creating the file IniFile.idt dynamically
96 # Content:
97 # IniFile\tFileName\tDirProperty\tSection\tKey\tValue\tAction\tComponent_
98 ###########################################################################################################
100 sub create_inifile_table
102 my ($inifiletableentries, $filesref, $basedir) = @_;
104 my @inifiletable = ();
106 installer::windows::idtglobal::write_idt_header(\@inifiletable, "inifile");
108 for ( my $i = 0; $i <= $#{$inifiletableentries}; $i++ )
110 my $profileitem = ${$inifiletableentries}[$i];
112 my $profileid = $profileitem->{'ProfileID'};
114 # Is this profile part of the product? This is not sure, for example in patch process.
115 # If the profile is not part of the product, this ProfileItem must be ignored.
117 if ( ! file_is_part_of_product($profileid, $filesref) ) { next; }
119 my $profile = get_profile_for_profileitem($profileid, $filesref);
121 if (( $installer::globals::patch ) && ( ! profile_has_patch_flag($profile) )) { next; }
123 my %inifile = ();
125 $inifile{'IniFile'} = $profileitem->{'Inifiletablekey'};
126 $inifile{'FileName'} = $profile->{'Name'};
127 $inifile{'DirProperty'} = $profile->{'uniquedirname'};
128 $inifile{'Section'} = $profileitem->{'Section'};
129 $inifile{'Key'} = $profileitem->{'Key'};
130 $inifile{'Value'} = $profileitem->{'Value'};
131 $inifile{'Action'} = $profileitem->{'Inifiletableaction'};
132 $inifile{'Component_'} = $profile->{'componentname'};
134 my $oneline = $inifile{'IniFile'} . "\t" . $inifile{'FileName'} . "\t" . $inifile{'DirProperty'} . "\t"
135 . $inifile{'Section'} . "\t" . $inifile{'Key'} . "\t" . $inifile{'Value'} . "\t"
136 . $inifile{'Action'} . "\t" . $inifile{'Component_'} . "\n";
138 push(@inifiletable, $oneline);
141 # Saving the file
143 my $inifiletablename = $basedir . $installer::globals::separator . "IniFile.idt";
144 installer::files::save_file($inifiletablename ,\@inifiletable);
145 my $infoline = "Created idt file: $inifiletablename\n";
146 push(@installer::globals::logfileinfo, $infoline);