Debian Codegraph @

solenv/bin/modules/installer/windows/featurecomponent.pm

raw
1 #
2 # This file is part of the LibreOffice project.
3 #
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/.
7 #
8 # This file incorporates work covered by the following license notice:
9 #
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 .
17 #
18
19 package installer::windows::featurecomponent;
20
21 use strict;
22 use warnings;
23
24 use installer::converter;
25 use installer::exiter;
26 use installer::files;
27 use installer::globals;
28 use installer::windows::idtglobal;
29
30 #################################################################################
31 # Collecting all pairs of features and components from the files collector
32 #################################################################################
33
34 sub create_featurecomponent_table_from_files_collector
35 {
36 my ($featurecomponenttableref, $filesref) = @_;
37
38 for ( my $i = 0; $i <= $#{$filesref}; $i++ )
39 {
40 my $onefile = ${$filesref}[$i];
41
42 my $filecomponent = $onefile->{'componentname'};
43 my $filemodules = $onefile->{'modules'};
44
45 if ( $filecomponent eq "" )
46 {
47 installer::exiter::exit_program("ERROR: No component defined for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector");
48 }
49 if ( $filemodules eq "" )
50 {
51 installer::exiter::exit_program("ERROR: No modules found for file $onefile->{'Name'}", "create_featurecomponent_table_from_files_collector");
52 }
53
54 my $filemodulesarrayref = installer::converter::convert_stringlist_into_array(\$filemodules, ",");
55
56 for ( my $j = 0; $j <= $#{$filemodulesarrayref}; $j++ )
57 {
58 my %featurecomponent = ();
59
60 my $onemodule = ${$filemodulesarrayref}[$j];
61 $onemodule =~ s/\s*$//;
62 $featurecomponent{'Feature'} = $onemodule;
63 $featurecomponent{'Component'} = $filecomponent;
64
65 # Attention: Features are renamed, because the maximum length is 38.
66 # But in the files collector ($filesref), the original names are saved.
67
68 installer::windows::idtglobal::shorten_feature_gid(\$featurecomponent{'Feature'});
69
70 my $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n";
71
72 # control of uniqueness
73
74 if (! grep {$_ eq $oneline} @{$featurecomponenttableref})
75 {
76 push(@{$featurecomponenttableref}, $oneline);
77 }
78 }
79 }
80 }
81
82 #################################################################################
83 # Collecting all pairs of features and components from the registry collector
84 #################################################################################
85
86 sub create_featurecomponent_table_from_registry_collector
87 {
88 my ($featurecomponenttableref, $registryref) = @_;
89
90 for ( my $i = 0; $i <= $#{$registryref}; $i++ )
91 {
92 my $oneregistry = ${$registryref}[$i];
93
94 my $registrycomponent = $oneregistry->{'componentname'};
95 my $registrymodule = $oneregistry->{'ModuleID'};
96
97 if ( $registrycomponent eq "" )
98 {
99 installer::exiter::exit_program("ERROR: No component defined for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector");
100 }
101 if ( $registrymodule eq "" )
102 {
103 installer::exiter::exit_program("ERROR: No modules found for registry $oneregistry->{'gid'}", "create_featurecomponent_table_from_registry_collector");
104 }
105
106 my %featurecomponent = ();
107
108 $featurecomponent{'Feature'} = $registrymodule;
109 $featurecomponent{'Component'} = $registrycomponent;
110
111 # Attention: Features are renamed, because the maximum length is 38.
112 # But in the files collector ($filesref), the original names are saved.
113
114 installer::windows::idtglobal::shorten_feature_gid(\$featurecomponent{'Feature'});
115
116 my $oneline = "$featurecomponent{'Feature'}\t$featurecomponent{'Component'}\n";
117
118 # control of uniqueness
119
120 if (! grep {$_ eq $oneline} @{$featurecomponenttableref})
121 {
122 push(@{$featurecomponenttableref}, $oneline);
123 }
124 }
125 }
126
127 #################################################################################
128 # Creating the file FeatureC.idt dynamically
129 # Content:
130 # Feature Component
131 #################################################################################
132
133 sub create_featurecomponent_table
134 {
135 my ($filesref, $registryref, $basedir) = @_;
136
137 my @featurecomponenttable = ();
138 my $infoline;
139
140 installer::windows::idtglobal::write_idt_header(\@featurecomponenttable, "featurecomponent");
141
142 # This is the first time, that features and components are related
143 # Problem: How about created profiles, configurationfiles, services.rdb
144 # -> simple solution: putting them all to the root module
145 # Otherwise profiles and configurationfiles cannot be created the way, they are now created
146 # -> especially a problem for the configurationfiles! # ToDo
147 # Very good: All ProfileItems belong to the root
148 # services.rdb belongs to the root anyway.
149
150 # At the moment only the files are related to components (and the files know their modules).
151 # The component for each file is written into the files collector $filesinproductlanguageresolvedarrayref
152
153 create_featurecomponent_table_from_files_collector(\@featurecomponenttable, $filesref);
154
155 create_featurecomponent_table_from_registry_collector(\@featurecomponenttable, $registryref);
156
157 # Additional components have to be added here
158
159 # Saving the file
160
161 my $featurecomponenttablename = $basedir . $installer::globals::separator . "FeatureC.idt";
162 installer::files::save_file($featurecomponenttablename ,\@featurecomponenttable);
163 $infoline = "Created idt file: $featurecomponenttablename\n";
164 push(@installer::globals::logfileinfo, $infoline);
165
166 }
167
168 1;