Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / bin / modules / installer / windows / inifile.pm
blobb26e41836d1fdf53b54aaba21b32c38be7d2db1f
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package installer::windows::inifile;
21 use installer::exiter;
22 use installer::files;
23 use installer::globals;
24 use installer::windows::idtglobal;
26 ####################################################
27 # Setting the profile for a special profileitem
28 ####################################################
30 sub get_profile_for_profileitem
32 my ($profileid, $filesref) = @_;
34 my ($profile) = grep {$_->{gid} eq $profileid} @{$filesref};
35 if (! defined $profile) {
36 installer::exiter::exit_program("ERROR: Could not find file $profileid in list of files!", "get_profile_for_profileitem");
39 return $profile;
42 ####################################################
43 # Checking whether profile is part of product
44 ####################################################
46 sub file_is_part_of_product
48 my ($profilegid, $filesref) = @_;
50 my $part_of_product = 0;
52 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
54 $onefile = ${$filesref}[$i];
55 my $filegid = $onefile->{'gid'};
57 if ( $filegid eq $profilegid )
59 $part_of_product = 1;
60 last;
64 return $part_of_product;
67 ###########################################################################################################
68 # Creating the file IniFile.idt dynamically
69 # Content:
70 # IniFile\tFileName\tDirProperty\tSection\tKey\tValue\tAction\tComponent_
71 ###########################################################################################################
73 sub create_inifile_table
75 my ($inifiletableentries, $filesref, $basedir) = @_;
77 my @inifiletable = ();
79 installer::windows::idtglobal::write_idt_header(\@inifiletable, "inifile");
81 for ( my $i = 0; $i <= $#{$inifiletableentries}; $i++ )
83 my $profileitem = ${$inifiletableentries}[$i];
85 my $profileid = $profileitem->{'ProfileID'};
87 # Is this profile part of the product? This is not sure, for example in patch process.
88 # If the profile is not part of the product, this ProfileItem must be ignored.
90 if ( ! file_is_part_of_product($profileid, $filesref) ) { next; }
92 my $profile = get_profile_for_profileitem($profileid, $filesref);
94 my %inifile = ();
96 $inifile{'IniFile'} = $profileitem->{'Inifiletablekey'};
97 $inifile{'FileName'} = $profile->{'Name'};
98 $inifile{'DirProperty'} = $profile->{'uniquedirname'};
99 $inifile{'Section'} = $profileitem->{'Section'};
100 $inifile{'Key'} = $profileitem->{'Key'};
101 $inifile{'Value'} = $profileitem->{'Value'};
102 $inifile{'Action'} = $profileitem->{'Inifiletableaction'};
103 $inifile{'Component_'} = $profile->{'componentname'};
105 my $oneline = $inifile{'IniFile'} . "\t" . $inifile{'FileName'} . "\t" . $inifile{'DirProperty'} . "\t"
106 . $inifile{'Section'} . "\t" . $inifile{'Key'} . "\t" . $inifile{'Value'} . "\t"
107 . $inifile{'Action'} . "\t" . $inifile{'Component_'} . "\n";
109 push(@inifiletable, $oneline);
112 # Saving the file
114 my $inifiletablename = $basedir . $installer::globals::separator . "IniFile.idt";
115 installer::files::save_file($inifiletablename ,\@inifiletable);
116 my $infoline = "Created idt file: $inifiletablename\n";
117 push(@installer::globals::logfileinfo, $infoline);