1*9780544fSAndrew Rist#**************************************************************
2*9780544fSAndrew Rist#
3*9780544fSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
4*9780544fSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
5*9780544fSAndrew Rist#  distributed with this work for additional information
6*9780544fSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
7*9780544fSAndrew Rist#  to you under the Apache License, Version 2.0 (the
8*9780544fSAndrew Rist#  "License"); you may not use this file except in compliance
9*9780544fSAndrew Rist#  with the License.  You may obtain a copy of the License at
10*9780544fSAndrew Rist#
11*9780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
12*9780544fSAndrew Rist#
13*9780544fSAndrew Rist#  Unless required by applicable law or agreed to in writing,
14*9780544fSAndrew Rist#  software distributed under the License is distributed on an
15*9780544fSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9780544fSAndrew Rist#  KIND, either express or implied.  See the License for the
17*9780544fSAndrew Rist#  specific language governing permissions and limitations
18*9780544fSAndrew Rist#  under the License.
19*9780544fSAndrew Rist#
20*9780544fSAndrew Rist#**************************************************************
21*9780544fSAndrew Rist
22*9780544fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweirpackage installer::packagelist;
25cdf0e10cSrcweir
26cdf0e10cSrcweiruse installer::converter;
27cdf0e10cSrcweiruse installer::exiter;
28cdf0e10cSrcweiruse installer::globals;
29cdf0e10cSrcweiruse installer::remover;
30cdf0e10cSrcweiruse installer::scriptitems;
31cdf0e10cSrcweir
32cdf0e10cSrcweir########################################
33cdf0e10cSrcweir# Check existence of module
34cdf0e10cSrcweir########################################
35cdf0e10cSrcweir
36cdf0e10cSrcweirsub check_module_existence
37cdf0e10cSrcweir{
38cdf0e10cSrcweir	my ($onegid, $moduleslist) = @_;
39cdf0e10cSrcweir
40cdf0e10cSrcweir	my $foundgid = 0;
41cdf0e10cSrcweir
42cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$moduleslist}; $i++ )
43cdf0e10cSrcweir	{
44cdf0e10cSrcweir		my $gid = ${$moduleslist}[$i]->{'gid'};
45cdf0e10cSrcweir
46cdf0e10cSrcweir		if ( $gid eq $onegid )
47cdf0e10cSrcweir		{
48cdf0e10cSrcweir			$foundgid = 1;
49cdf0e10cSrcweir			last;
50cdf0e10cSrcweir		}
51cdf0e10cSrcweir	}
52cdf0e10cSrcweir
53cdf0e10cSrcweir	return $foundgid;
54cdf0e10cSrcweir}
55cdf0e10cSrcweir
56cdf0e10cSrcweir###################################################
57cdf0e10cSrcweir# Analyzing the gids, defined in the packagelist
58cdf0e10cSrcweir###################################################
59cdf0e10cSrcweir
60cdf0e10cSrcweirsub analyze_list
61cdf0e10cSrcweir{
62cdf0e10cSrcweir	my ($packagelist, $moduleslist) = @_;
63cdf0e10cSrcweir
64cdf0e10cSrcweir	@allpackages = ();
65cdf0e10cSrcweir
66cdf0e10cSrcweir	my $moduleshash = get_module_hash($moduleslist);
67cdf0e10cSrcweir
68cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$packagelist}; $i++ )
69cdf0e10cSrcweir	{
70cdf0e10cSrcweir		my $onepackage = ${$packagelist}[$i];
71cdf0e10cSrcweir
72cdf0e10cSrcweir		my $onegid = $onepackage->{'module'};
73cdf0e10cSrcweir
74cdf0e10cSrcweir		installer::remover::remove_leading_and_ending_whitespaces(\$onegid);
75cdf0e10cSrcweir
76cdf0e10cSrcweir		my $moduleexists = check_module_existence($onegid, $moduleslist);
77cdf0e10cSrcweir
78cdf0e10cSrcweir		if ( ! $moduleexists ) { next; }
79cdf0e10cSrcweir
80cdf0e10cSrcweir		my @allmodules = ();
81cdf0e10cSrcweir
82cdf0e10cSrcweir		push(@allmodules, $onegid);
83cdf0e10cSrcweir
84cdf0e10cSrcweir		# get_children($moduleslist, $onegid, \@allmodules);
85cdf0e10cSrcweir		get_children_with_hash($moduleshash, $onegid, \@allmodules);
86cdf0e10cSrcweir
87cdf0e10cSrcweir		$onepackage->{'allmodules'} = \@allmodules;
88cdf0e10cSrcweir
89cdf0e10cSrcweir		push(@allpackages, $onepackage);
90cdf0e10cSrcweir	}
91cdf0e10cSrcweir
92cdf0e10cSrcweir	return \@allpackages;
93cdf0e10cSrcweir}
94cdf0e10cSrcweir
95cdf0e10cSrcweir###################################################
96cdf0e10cSrcweir# Creating a hash, that contains the module gids
97cdf0e10cSrcweir# as keys and the parentids as values
98cdf0e10cSrcweir###################################################
99cdf0e10cSrcweir
100cdf0e10cSrcweirsub get_module_hash
101cdf0e10cSrcweir{
102cdf0e10cSrcweir	my ($moduleslist) = @_;
103cdf0e10cSrcweir
104cdf0e10cSrcweir	my %modulehash = ();
105cdf0e10cSrcweir
106cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$moduleslist}; $i++ )
107cdf0e10cSrcweir	{
108cdf0e10cSrcweir		my $gid = ${$moduleslist}[$i]->{'gid'};
109cdf0e10cSrcweir		# Containing only modules with parent. Root modules can be ignored.
110cdf0e10cSrcweir		if ( ${$moduleslist}[$i]->{'ParentID'} ) { $modulehash{$gid} = ${$moduleslist}[$i]->{'ParentID'}; }
111cdf0e10cSrcweir	}
112cdf0e10cSrcweir
113cdf0e10cSrcweir	return \%modulehash;
114cdf0e10cSrcweir}
115cdf0e10cSrcweir
116cdf0e10cSrcweir########################################################
117cdf0e10cSrcweir# Recursively defined procedure to order
118cdf0e10cSrcweir# modules and directories
119cdf0e10cSrcweir########################################################
120cdf0e10cSrcweir
121cdf0e10cSrcweirsub get_children_with_hash
122cdf0e10cSrcweir{
123cdf0e10cSrcweir	my ($modulehash, $parentgid, $newitemorder) = @_;
124cdf0e10cSrcweir
125cdf0e10cSrcweir	foreach my $gid ( keys %{$modulehash} )
126cdf0e10cSrcweir	{
127cdf0e10cSrcweir		my $parent = $modulehash->{$gid};
128cdf0e10cSrcweir
129cdf0e10cSrcweir		if ( $parent eq $parentgid )
130cdf0e10cSrcweir		{
131cdf0e10cSrcweir			push(@{$newitemorder}, $gid);
132cdf0e10cSrcweir			my $parent = $gid;
133cdf0e10cSrcweir			get_children_with_hash($modulehash, $parent, $newitemorder);	# recursive!
134cdf0e10cSrcweir		}
135cdf0e10cSrcweir	}
136cdf0e10cSrcweir}
137cdf0e10cSrcweir
138cdf0e10cSrcweir########################################################
139cdf0e10cSrcweir# Recursively defined procedure to order
140cdf0e10cSrcweir# modules and directories
141cdf0e10cSrcweir########################################################
142cdf0e10cSrcweir
143cdf0e10cSrcweirsub get_children
144cdf0e10cSrcweir{
145cdf0e10cSrcweir	my ($allitems, $startparent, $newitemorder) = @_;
146cdf0e10cSrcweir
147cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$allitems}; $i++ )
148cdf0e10cSrcweir	{
149cdf0e10cSrcweir		my $gid = ${$allitems}[$i]->{'gid'};
150cdf0e10cSrcweir		my $parent = "";
151cdf0e10cSrcweir		if ( ${$allitems}[$i]->{'ParentID'} ) { $parent = ${$allitems}[$i]->{'ParentID'}; }
152cdf0e10cSrcweir
153cdf0e10cSrcweir		if ( $parent eq $startparent )
154cdf0e10cSrcweir		{
155cdf0e10cSrcweir			push(@{$newitemorder}, $gid);
156cdf0e10cSrcweir			my $parent = $gid;
157cdf0e10cSrcweir			get_children($allitems, $parent, $newitemorder);	# recursive!
158cdf0e10cSrcweir		}
159cdf0e10cSrcweir	}
160cdf0e10cSrcweir}
161cdf0e10cSrcweir
162cdf0e10cSrcweir#####################################################################
163cdf0e10cSrcweir# All modules below a defined gid_Module_A are collected now for
164cdf0e10cSrcweir# each modules defined in the packagelist. Now the modules have
165cdf0e10cSrcweir# to be removed, that are part of more than one package.
166cdf0e10cSrcweir#####################################################################
167cdf0e10cSrcweir
168cdf0e10cSrcweirsub remove_multiple_modules_packages
169cdf0e10cSrcweir{
170cdf0e10cSrcweir	my ($allpackagemodules) = @_;
171cdf0e10cSrcweir
172cdf0e10cSrcweir	# iterating over all packages
173cdf0e10cSrcweir
174cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$allpackagemodules}; $i++ )
175cdf0e10cSrcweir	{
176cdf0e10cSrcweir		my $onepackage = ${$allpackagemodules}[$i];
177cdf0e10cSrcweir		my $allmodules = $onepackage->{'allmodules'};
178cdf0e10cSrcweir
179cdf0e10cSrcweir		# print "Modules below $onepackage->{'module'}: $#{$allmodules}\n";
180cdf0e10cSrcweir
181cdf0e10cSrcweir		# Comparing each package, with all following packages. If a
182cdf0e10cSrcweir		# gid for the module is part of more than one package, it is
183cdf0e10cSrcweir		# removed if the number of modules in the package is greater
184cdf0e10cSrcweir		# in the current package than in the compare package.
185cdf0e10cSrcweir
186cdf0e10cSrcweir		# Taking all modules from package $i
187cdf0e10cSrcweir
188cdf0e10cSrcweir		my $packagecount = $#{$allmodules};
189cdf0e10cSrcweir
190cdf0e10cSrcweir		my @optimizedpackage = ();
191cdf0e10cSrcweir
192cdf0e10cSrcweir		# iterating over all modules of this package
193cdf0e10cSrcweir
194cdf0e10cSrcweir		for ( my $j = 0; $j <= $#{$allmodules}; $j++ )
195cdf0e10cSrcweir		{
196cdf0e10cSrcweir			my $onemodule = ${$allmodules}[$j];	# this is the module, that shall be removed or not
197cdf0e10cSrcweir
198cdf0e10cSrcweir			my $put_module_into_new_package = 1;
199cdf0e10cSrcweir
200cdf0e10cSrcweir			# iterating over all other packages
201cdf0e10cSrcweir
202cdf0e10cSrcweir			for ( my $k = 0; $k <= $#{$allpackagemodules}; $k++ )
203cdf0e10cSrcweir			{
204cdf0e10cSrcweir				if ( $k == $i ) { next; }	# not comparing equal module
205cdf0e10cSrcweir
206cdf0e10cSrcweir				if (! $put_module_into_new_package) { next; } # do not compare, if already found
207cdf0e10cSrcweir
208cdf0e10cSrcweir				my $comparepackage = ${$allpackagemodules}[$k];
209cdf0e10cSrcweir				my $allcomparemodules = $comparepackage->{'allmodules'};
210cdf0e10cSrcweir
211cdf0e10cSrcweir				my $comparepackagecount = $#{$allcomparemodules};
212cdf0e10cSrcweir
213cdf0e10cSrcweir				# modules will only be removed from packages, that have more modules
214cdf0e10cSrcweir				# than the compare package
215cdf0e10cSrcweir
216cdf0e10cSrcweir				if ( $packagecount <= $comparepackagecount ) { next; }	# nothing to do, take next package
217cdf0e10cSrcweir
218cdf0e10cSrcweir				# iterating over all modules of this package
219cdf0e10cSrcweir
220cdf0e10cSrcweir				for ( my $m = 0; $m <= $#{$allcomparemodules}; $m++ )
221cdf0e10cSrcweir				{
222cdf0e10cSrcweir					my $onecomparemodule = ${$allcomparemodules}[$m];
223cdf0e10cSrcweir
224cdf0e10cSrcweir					if ( $onemodule eq $onecomparemodule )	# this $onemodule has to be removed
225cdf0e10cSrcweir					{
226cdf0e10cSrcweir						$put_module_into_new_package = 0;
227cdf0e10cSrcweir					}
228cdf0e10cSrcweir				}
229cdf0e10cSrcweir			}
230cdf0e10cSrcweir
231cdf0e10cSrcweir			if ( $put_module_into_new_package )
232cdf0e10cSrcweir			{
233cdf0e10cSrcweir				push(@optimizedpackage, $onemodule)
234cdf0e10cSrcweir			}
235cdf0e10cSrcweir		}
236cdf0e10cSrcweir
237cdf0e10cSrcweir		$onepackage->{'allmodules'} = \@optimizedpackage;
238cdf0e10cSrcweir	}
239cdf0e10cSrcweir
240cdf0e10cSrcweir	# for ( my $i = 0; $i <= $#{$allpackagemodules}; $i++ )
241cdf0e10cSrcweir	# {
242cdf0e10cSrcweir	#	my $onepackage = ${$allpackagemodules}[$i];
243cdf0e10cSrcweir	#	my $allmodules = $onepackage->{'allmodules'};
244cdf0e10cSrcweir	#	print "New: Modules below $onepackage->{'module'}: $#{$allmodules}\n";
245cdf0e10cSrcweir	# }
246cdf0e10cSrcweir
247cdf0e10cSrcweir}
248cdf0e10cSrcweir
249cdf0e10cSrcweir#####################################################################
250cdf0e10cSrcweir# Analyzing all files if they belong to a special package.
251cdf0e10cSrcweir# A package is described by a list of modules.
252cdf0e10cSrcweir#####################################################################
253cdf0e10cSrcweir
254cdf0e10cSrcweirsub find_files_for_package
255cdf0e10cSrcweir{
256cdf0e10cSrcweir	my ($filelist, $onepackage) = @_;
257cdf0e10cSrcweir
258cdf0e10cSrcweir	my @newfilelist = ();
259cdf0e10cSrcweir
260cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filelist}; $i++ )
261cdf0e10cSrcweir	{
262cdf0e10cSrcweir		my $onefile = ${$filelist}[$i];
263cdf0e10cSrcweir		my $modulesstring = $onefile->{'modules'};	 # comma separated modules list
264cdf0e10cSrcweir		my $moduleslist = installer::converter::convert_stringlist_into_array(\$modulesstring, ",");
265cdf0e10cSrcweir
266cdf0e10cSrcweir		my $includefile = 0;
267cdf0e10cSrcweir
268cdf0e10cSrcweir		# iterating over all modules of this file
269cdf0e10cSrcweir
270cdf0e10cSrcweir		for ( my $j = 0; $j <= $#{$moduleslist}; $j++ )
271cdf0e10cSrcweir		{
272cdf0e10cSrcweir			if ( $includefile ) { next; }
273cdf0e10cSrcweir			my $filemodule = ${$moduleslist}[$j];
274cdf0e10cSrcweir			installer::remover::remove_leading_and_ending_whitespaces(\$filemodule);
275cdf0e10cSrcweir
276cdf0e10cSrcweir			# iterating over all modules of the package
277cdf0e10cSrcweir
278cdf0e10cSrcweir			my $packagemodules = $onepackage->{'allmodules'};
279cdf0e10cSrcweir
280cdf0e10cSrcweir			for ( my $k = 0; $k <= $#{$packagemodules}; $k++ )
281cdf0e10cSrcweir			{
282cdf0e10cSrcweir				if ( $includefile ) { next; }
283cdf0e10cSrcweir				my $packagemodule = ${$packagemodules}[$k];
284cdf0e10cSrcweir
285cdf0e10cSrcweir				if ( $filemodule eq $packagemodule )
286cdf0e10cSrcweir				{
287cdf0e10cSrcweir					$includefile = 1;
288cdf0e10cSrcweir					last;
289cdf0e10cSrcweir				}
290cdf0e10cSrcweir			}
291cdf0e10cSrcweir		}
292cdf0e10cSrcweir
293cdf0e10cSrcweir		if ( $includefile )
294cdf0e10cSrcweir		{
295cdf0e10cSrcweir			push(@newfilelist, $onefile);
296cdf0e10cSrcweir		}
297cdf0e10cSrcweir	}
298cdf0e10cSrcweir
299cdf0e10cSrcweir	return \@newfilelist;
300cdf0e10cSrcweir}
301cdf0e10cSrcweir
302cdf0e10cSrcweir#####################################################################
303cdf0e10cSrcweir# Analyzing all links if they belong to a special package.
304cdf0e10cSrcweir# A package is described by a list of modules.
305cdf0e10cSrcweir# A link is inserted into the package, if the corresponding
306cdf0e10cSrcweir# file is also inserted.
307cdf0e10cSrcweir#####################################################################
308cdf0e10cSrcweir
309cdf0e10cSrcweirsub find_links_for_package
310cdf0e10cSrcweir{
311cdf0e10cSrcweir	my ($linklist, $filelist) = @_;
312cdf0e10cSrcweir
313cdf0e10cSrcweir	# First looking for all links with a FileID.
314cdf0e10cSrcweir	# Then looking for all links with a ShortcutID.
315cdf0e10cSrcweir
316cdf0e10cSrcweir	my @newlinklist = ();
317cdf0e10cSrcweir
318cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$linklist}; $i++ )
319cdf0e10cSrcweir	{
320cdf0e10cSrcweir		my $includelink = 0;
321cdf0e10cSrcweir
322cdf0e10cSrcweir		my $onelink = ${$linklist}[$i];
323cdf0e10cSrcweir
324cdf0e10cSrcweir		my $fileid = "";
325cdf0e10cSrcweir		if ( $onelink->{'FileID'} ) { $fileid = $onelink->{'FileID'}; }
326cdf0e10cSrcweir
327cdf0e10cSrcweir		if ( $fileid eq "" ) { next; }	 # A link with a ShortcutID
328cdf0e10cSrcweir
329cdf0e10cSrcweir		for ( my $j = 0; $j <= $#{$filelist}; $j++ )	 # iterating over file list
330cdf0e10cSrcweir		{
331cdf0e10cSrcweir			my $onefile = ${$filelist}[$j];
332cdf0e10cSrcweir			my $gid = $onefile->{'gid'};
333cdf0e10cSrcweir
334cdf0e10cSrcweir			if ( $gid eq $fileid )
335cdf0e10cSrcweir			{
336cdf0e10cSrcweir				$includelink = 1;
337cdf0e10cSrcweir				last;
338cdf0e10cSrcweir			}
339cdf0e10cSrcweir		}
340cdf0e10cSrcweir
341cdf0e10cSrcweir		if ( $includelink )
342cdf0e10cSrcweir		{
343cdf0e10cSrcweir			push(@newlinklist, $onelink);
344cdf0e10cSrcweir		}
345cdf0e10cSrcweir	}
346cdf0e10cSrcweir
347cdf0e10cSrcweir	# iterating over the new list, because of all links with a ShortcutID
348cdf0e10cSrcweir
349cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$linklist}; $i++ )
350cdf0e10cSrcweir	{
351cdf0e10cSrcweir		my $includelink = 0;
352cdf0e10cSrcweir
353cdf0e10cSrcweir		my $onelink = ${$linklist}[$i];
354cdf0e10cSrcweir
355cdf0e10cSrcweir		my $shortcutid = "";
356cdf0e10cSrcweir		if ( $onelink->{'ShortcutID'} ) { $shortcutid = $onelink->{'ShortcutID'}; }
357cdf0e10cSrcweir
358cdf0e10cSrcweir		if ( $shortcutid eq "" ) { next; }	 # A link with a ShortcutID
359cdf0e10cSrcweir
360cdf0e10cSrcweir		for ( my $j = 0; $j <= $#newlinklist; $j++ )	 # iterating over newly created link list
361cdf0e10cSrcweir		{
362cdf0e10cSrcweir			my $onefilelink = $newlinklist[$j];
363cdf0e10cSrcweir			my $gid = $onefilelink->{'gid'};
364cdf0e10cSrcweir
365cdf0e10cSrcweir			if ( $gid eq $shortcutid )
366cdf0e10cSrcweir			{
367cdf0e10cSrcweir				$includelink = 1;
368cdf0e10cSrcweir				last;
369cdf0e10cSrcweir			}
370cdf0e10cSrcweir		}
371cdf0e10cSrcweir
372cdf0e10cSrcweir		if ( $includelink )
373cdf0e10cSrcweir		{
374cdf0e10cSrcweir			push(@newlinklist, $onelink);
375cdf0e10cSrcweir		}
376cdf0e10cSrcweir	}
377cdf0e10cSrcweir
378cdf0e10cSrcweir	return \@newlinklist;
379cdf0e10cSrcweir}
380cdf0e10cSrcweir
381cdf0e10cSrcweir#####################################################################
382cdf0e10cSrcweir# Analyzing all directories if they belong to a special package.
383cdf0e10cSrcweir# A package is described by a list of modules.
384cdf0e10cSrcweir# Directories are included into the package, if they are needed
385cdf0e10cSrcweir# by a file or a link included into the package.
386cdf0e10cSrcweir# Attention: A directory with the flag CREATE, is only included
387cdf0e10cSrcweir# into the root module:
388cdf0e10cSrcweir# ($packagename eq $installer::globals::rootmodulegid)
389cdf0e10cSrcweir#####################################################################
390cdf0e10cSrcweir
391cdf0e10cSrcweirsub find_dirs_for_package
392cdf0e10cSrcweir{
393cdf0e10cSrcweir	my ($dirlist, $onepackage) = @_;
394cdf0e10cSrcweir
395cdf0e10cSrcweir	my @newdirlist = ();
396cdf0e10cSrcweir
397cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$dirlist}; $i++ )
398cdf0e10cSrcweir	{
399cdf0e10cSrcweir		my $onedir = ${$dirlist}[$i];
400cdf0e10cSrcweir		my $modulesstring = $onedir->{'modules'};	 # comma separated modules list
401cdf0e10cSrcweir		my $moduleslist = installer::converter::convert_stringlist_into_array(\$modulesstring, ",");
402cdf0e10cSrcweir
403cdf0e10cSrcweir		my $includedir = 0;
404cdf0e10cSrcweir
405cdf0e10cSrcweir		# iterating over all modules of this dir
406cdf0e10cSrcweir
407cdf0e10cSrcweir		for ( my $j = 0; $j <= $#{$moduleslist}; $j++ )
408cdf0e10cSrcweir		{
409cdf0e10cSrcweir			if ( $includedir ) { last; }
410cdf0e10cSrcweir			my $dirmodule = ${$moduleslist}[$j];
411cdf0e10cSrcweir			installer::remover::remove_leading_and_ending_whitespaces(\$dirmodule);
412cdf0e10cSrcweir
413cdf0e10cSrcweir			# iterating over all modules of the package
414cdf0e10cSrcweir
415cdf0e10cSrcweir			my $packagemodules = $onepackage->{'allmodules'};
416cdf0e10cSrcweir
417cdf0e10cSrcweir			for ( my $k = 0; $k <= $#{$packagemodules}; $k++ )
418cdf0e10cSrcweir			{
419cdf0e10cSrcweir				my $packagemodule = ${$packagemodules}[$k];
420cdf0e10cSrcweir
421cdf0e10cSrcweir				if ( $dirmodule eq $packagemodule )
422cdf0e10cSrcweir				{
423cdf0e10cSrcweir					$includedir = 1;
424cdf0e10cSrcweir					last;
425cdf0e10cSrcweir				}
426cdf0e10cSrcweir			}
427cdf0e10cSrcweir		}
428cdf0e10cSrcweir
429cdf0e10cSrcweir		if ( $includedir )
430cdf0e10cSrcweir		{
431cdf0e10cSrcweir			push(@newdirlist, $onedir);
432cdf0e10cSrcweir		}
433cdf0e10cSrcweir	}
434cdf0e10cSrcweir
435cdf0e10cSrcweir	return \@newdirlist;
436cdf0e10cSrcweir}
437cdf0e10cSrcweir
438cdf0e10cSrcweir#####################################################################
439cdf0e10cSrcweir# Resolving all variables in the packagename.
440cdf0e10cSrcweir#####################################################################
441cdf0e10cSrcweir
442cdf0e10cSrcweirsub resolve_packagevariables
443cdf0e10cSrcweir{
444cdf0e10cSrcweir	my ($packagenameref, $variableshashref, $make_lowercase) = @_;
445cdf0e10cSrcweir
446cdf0e10cSrcweir	my $key;
447cdf0e10cSrcweir
448cdf0e10cSrcweir	# Special handling for dictionaries
449cdf0e10cSrcweir	if ( $$packagenameref =~ /-dict-/ )
450cdf0e10cSrcweir	{
451cdf0e10cSrcweir		if (exists($variableshashref->{'DICTIONARYUNIXPRODUCTNAME'}) ) { $$packagenameref =~ s/\%UNIXPRODUCTNAME/$variableshashref->{'DICTIONARYUNIXPRODUCTNAME'}/g; }
452cdf0e10cSrcweir		if (exists($variableshashref->{'DICTIONARYBRANDPACKAGEVERSION'}) ) { $$packagenameref =~ s/\%BRANDPACKAGEVERSION/$variableshashref->{'DICTIONARYBRANDPACKAGEVERSION'}/g; }
453cdf0e10cSrcweir	}
454cdf0e10cSrcweir
455cdf0e10cSrcweir	foreach $key (keys %{$variableshashref})
456cdf0e10cSrcweir	{
457cdf0e10cSrcweir		my $value = $variableshashref->{$key};
458cdf0e10cSrcweir		if ( $make_lowercase ) { $value = lc($value); }
459cdf0e10cSrcweir		$$packagenameref =~ s/\%$key/$value/g;
460cdf0e10cSrcweir	}
461cdf0e10cSrcweir}
462cdf0e10cSrcweir
463cdf0e10cSrcweir#####################################################################
464cdf0e10cSrcweir# Resolving all variables in the packagename.
465cdf0e10cSrcweir#####################################################################
466cdf0e10cSrcweir
467cdf0e10cSrcweirsub resolve_packagevariables2
468cdf0e10cSrcweir{
469cdf0e10cSrcweir	my ($packagenameref, $variableshashref, $make_lowercase, $isdict ) = @_;
470cdf0e10cSrcweir
471cdf0e10cSrcweir	my $key;
472cdf0e10cSrcweir
473cdf0e10cSrcweir	# Special handling for dictionaries
474cdf0e10cSrcweir	if ( $isdict )
475cdf0e10cSrcweir	{
476cdf0e10cSrcweir		if (exists($variableshashref->{'DICTIONARYUNIXPRODUCTNAME'}) ) { $$packagenameref =~ s/\%UNIXPRODUCTNAME/$variableshashref->{'DICTIONARYUNIXPRODUCTNAME'}/g; }
477cdf0e10cSrcweir		if (exists($variableshashref->{'DICTIONARYBRANDPACKAGEVERSION'}) ) { $$packagenameref =~ s/\%BRANDPACKAGEVERSION/$variableshashref->{'DICTIONARYBRANDPACKAGEVERSION'}/g; }
478cdf0e10cSrcweir	}
479cdf0e10cSrcweir
480cdf0e10cSrcweir	foreach $key (keys %{$variableshashref})
481cdf0e10cSrcweir	{
482cdf0e10cSrcweir		my $value = $variableshashref->{$key};
483cdf0e10cSrcweir		if ( $make_lowercase ) { $value = lc($value); }
484cdf0e10cSrcweir		$$packagenameref =~ s/\%$key/$value/g;
485cdf0e10cSrcweir	}
486cdf0e10cSrcweir}
487cdf0e10cSrcweir
488cdf0e10cSrcweir#####################################################################
489cdf0e10cSrcweir# New packages system.
490cdf0e10cSrcweir#####################################################################
491cdf0e10cSrcweir
492cdf0e10cSrcweir##################################################################
493cdf0e10cSrcweir# Controlling the content of the packagelist
494cdf0e10cSrcweir# 1. Items in @installer::globals::packagelistitems must exist
495cdf0e10cSrcweir# 2. If a shellscript file is defined, it must exist
496cdf0e10cSrcweir##################################################################
497cdf0e10cSrcweir
498cdf0e10cSrcweirsub check_packagelist
499cdf0e10cSrcweir{
500cdf0e10cSrcweir	my ($packages) = @_;
501cdf0e10cSrcweir
502cdf0e10cSrcweir	if ( ! ( $#{$packages} > -1 )) { installer::exiter::exit_program("ERROR: No packages defined!", "check_packagelist"); }
503cdf0e10cSrcweir
504cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$packages}; $i++ )
505cdf0e10cSrcweir	{
506cdf0e10cSrcweir		my $onepackage = ${$packages}[$i];
507cdf0e10cSrcweir
508cdf0e10cSrcweir		my $element;
509cdf0e10cSrcweir
510cdf0e10cSrcweir		# checking all items that must be defined
511cdf0e10cSrcweir
512cdf0e10cSrcweir		foreach $element (@installer::globals::packagelistitems)
513cdf0e10cSrcweir		{
514cdf0e10cSrcweir			if ( ! exists($onepackage->{$element}) )
515cdf0e10cSrcweir			{
516cdf0e10cSrcweir				installer::exiter::exit_program("ERROR in package list: No value for $element !", "check_packagelist");
517cdf0e10cSrcweir			}
518cdf0e10cSrcweir		}
519cdf0e10cSrcweir
520cdf0e10cSrcweir		# checking the existence of the script file, if defined
521cdf0e10cSrcweir
522cdf0e10cSrcweir		if ( $onepackage->{'script'} )
523cdf0e10cSrcweir		{
524cdf0e10cSrcweir			my $scriptfile = $onepackage->{'script'};
525cdf0e10cSrcweir			my $gid =  $onepackage->{'module'};
526cdf0e10cSrcweir			my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptfile, "" , 0);
527cdf0e10cSrcweir
528cdf0e10cSrcweir			if ( $$fileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find script file $scriptfile for module $gid!", "check_packagelist"); }
529cdf0e10cSrcweir
530cdf0e10cSrcweir			my $infoline = "$gid: Using script file: \"$$fileref\"!\n";
531cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
532cdf0e10cSrcweir
533cdf0e10cSrcweir			$onepackage->{'script'} = $$fileref;
534cdf0e10cSrcweir		}
535cdf0e10cSrcweir	}
536cdf0e10cSrcweir}
537cdf0e10cSrcweir
538cdf0e10cSrcweir#####################################################################
539cdf0e10cSrcweir# Reading pack info for one module from packinfo file.
540cdf0e10cSrcweir#####################################################################
541cdf0e10cSrcweir
542cdf0e10cSrcweirsub get_packinfo
543cdf0e10cSrcweir{
544cdf0e10cSrcweir	my ($gid, $filename, $packages, $onelanguage, $islanguagemodule) = @_;
545cdf0e10cSrcweir
546cdf0e10cSrcweir	my $packagelist	= installer::files::read_file($filename);
547cdf0e10cSrcweir
548cdf0e10cSrcweir	my @allpackages = ();
549cdf0e10cSrcweir
550cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$packagelist}; $i++ )
551cdf0e10cSrcweir	{
552cdf0e10cSrcweir		my $line = ${$packagelist}[$i];
553cdf0e10cSrcweir
554cdf0e10cSrcweir		if ( $line =~ /^\s*\#/ ) { next; }	# this is a comment line
555cdf0e10cSrcweir
556cdf0e10cSrcweir		if ( $line =~ /^\s*Start\s*$/i ) 	# a new package definition
557cdf0e10cSrcweir		{
558cdf0e10cSrcweir			my %onepackage = ();
559cdf0e10cSrcweir
560cdf0e10cSrcweir			my $counter = $i + 1;
561cdf0e10cSrcweir
562cdf0e10cSrcweir			while (!( ${$packagelist}[$counter] =~ /^\s*End\s*$/i ))
563cdf0e10cSrcweir			{
564cdf0e10cSrcweir				if ( ${$packagelist}[$counter] =~ /^\s*(\S+)\s*\=\s*\"(.*)\"/ )
565cdf0e10cSrcweir				{
566cdf0e10cSrcweir					my $key = $1;
567cdf0e10cSrcweir					my $value = $2;
568cdf0e10cSrcweir					$onepackage{$key} = $value;
569cdf0e10cSrcweir				}
570cdf0e10cSrcweir
571cdf0e10cSrcweir				$counter++;
572cdf0e10cSrcweir			}
573cdf0e10cSrcweir
574cdf0e10cSrcweir			$onepackage{'islanguagemodule'} = $islanguagemodule;
575cdf0e10cSrcweir			if ( $islanguagemodule )
576cdf0e10cSrcweir			{
577cdf0e10cSrcweir				$saveonelanguage = $onelanguage;
578cdf0e10cSrcweir				$saveonelanguage =~ s/_/-/g;
579cdf0e10cSrcweir				$onepackage{'language'} = $saveonelanguage;
580cdf0e10cSrcweir			}
581cdf0e10cSrcweir
582cdf0e10cSrcweir			push(@allpackages, \%onepackage);
583cdf0e10cSrcweir		}
584cdf0e10cSrcweir	}
585cdf0e10cSrcweir
586cdf0e10cSrcweir	# looking for the packinfo with the correct gid
587cdf0e10cSrcweir
588cdf0e10cSrcweir	my $foundgid = 0;
589cdf0e10cSrcweir	my $onepackage;
590cdf0e10cSrcweir	foreach $onepackage (@allpackages)
591cdf0e10cSrcweir	{
592cdf0e10cSrcweir		# Adding the language to the module gid for LanguagePacks !
593cdf0e10cSrcweir		# Making the module gid language specific: gid_Module_Root -> gir_Module_Root_pt_BR (as defined in scp2)
594cdf0e10cSrcweir		if ( $onelanguage ne "" ) { $onepackage->{'module'} = $onepackage->{'module'} . "_$onelanguage"; }
595cdf0e10cSrcweir
596cdf0e10cSrcweir		if ( $onepackage->{'module'} eq $gid )
597cdf0e10cSrcweir		{
598cdf0e10cSrcweir			# Resolving the language identifier
599cdf0e10cSrcweir			my $onekey;
600cdf0e10cSrcweir			foreach $onekey ( keys %{$onepackage} )
601cdf0e10cSrcweir			{
602cdf0e10cSrcweir				# Some keys require "-" instead of "_" for example in "en-US". All package names do not use underlines.
603cdf0e10cSrcweir				my $locallang = $onelanguage;
604cdf0e10cSrcweir				if (( $onekey eq "solarispackagename" ) ||
605cdf0e10cSrcweir				   ( $onekey eq "solarisrequires" ) ||
606cdf0e10cSrcweir				   ( $onekey eq "packagename" ) ||
607cdf0e10cSrcweir				   ( $onekey eq "requires" )) { $locallang =~ s/_/-/g; } # avoiding illegal package abbreviation
608cdf0e10cSrcweir				$onepackage->{$onekey} =~ s/\%LANGUAGESTRING/$locallang/g;
609cdf0e10cSrcweir			}
610cdf0e10cSrcweir
611cdf0e10cSrcweir			# Saving the language for the package
612cdf0e10cSrcweir			my $lang = $onelanguage;
613cdf0e10cSrcweir			$lang =~ s/_/-/g;
614cdf0e10cSrcweir			$onepackage->{'specificlanguage'} = $lang;
615cdf0e10cSrcweir
616cdf0e10cSrcweir			push(@{$packages}, $onepackage);
617cdf0e10cSrcweir			$foundgid = 1;
618cdf0e10cSrcweir			last;
619cdf0e10cSrcweir		}
620cdf0e10cSrcweir	}
621cdf0e10cSrcweir
622cdf0e10cSrcweir	if ( ! $foundgid )
623cdf0e10cSrcweir	{
624cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: Could not find package info for module $gid in file \"$filename\"!", "get_packinfo");
625cdf0e10cSrcweir	}
626cdf0e10cSrcweir}
627cdf0e10cSrcweir
628cdf0e10cSrcweir#####################################################################
629cdf0e10cSrcweir# Collecting all packages from scp project.
630cdf0e10cSrcweir#####################################################################
631cdf0e10cSrcweir
632cdf0e10cSrcweirsub collectpackages
633cdf0e10cSrcweir{
634cdf0e10cSrcweir	my ( $allmodules, $languagesarrayref ) = @_;
635cdf0e10cSrcweir
636cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Collecting packages:");
637cdf0e10cSrcweir
638cdf0e10cSrcweir	my @packages = ();
639cdf0e10cSrcweir	my %gid_analyzed = ();
640cdf0e10cSrcweir
641cdf0e10cSrcweir	my $onemodule;
642cdf0e10cSrcweir	foreach $onemodule ( @{$allmodules} )
643cdf0e10cSrcweir	{
644cdf0e10cSrcweir		my $packageinfo = "PackageInfo";
645cdf0e10cSrcweir		if (( $installer::globals::tab ) && ( $onemodule->{"TabPackageInfo"} )) { $packageinfo = "TabPackageInfo" }
646cdf0e10cSrcweir
647cdf0e10cSrcweir		if ( $onemodule->{$packageinfo} )	# this is a package module!
648cdf0e10cSrcweir		{
649cdf0e10cSrcweir			my $modulegid = $onemodule->{'gid'};
650cdf0e10cSrcweir
651cdf0e10cSrcweir			# Only collecting modules with correct language for language packs
652cdf0e10cSrcweir#			if ( $installer::globals::languagepack ) { if ( ! ( $modulegid =~ /_$onelanguage\s*$/ )) { next; } }
653cdf0e10cSrcweir			# Resetting language, if this is no language pack
654cdf0e10cSrcweir#			if ( ! $installer::globals::languagepack ) { $onelanguage = ""; }
655cdf0e10cSrcweir
656cdf0e10cSrcweir			my $styles = "";
657cdf0e10cSrcweir			if ( $onemodule->{'Styles'} ) { $styles = $onemodule->{'Styles'}; }
658cdf0e10cSrcweir
659cdf0e10cSrcweir			# checking modules with style LANGUAGEMODULE
660cdf0e10cSrcweir			my $islanguagemodule = 0;
661cdf0e10cSrcweir			my $onelanguage = "";
662cdf0e10cSrcweir			if ( $styles =~ /\bLANGUAGEMODULE\b/ )
663cdf0e10cSrcweir			{
664cdf0e10cSrcweir				$islanguagemodule = 1;
665cdf0e10cSrcweir				$onelanguage = $onemodule->{'Language'}; # already checked, that it is set.
666cdf0e10cSrcweir				$onelanguage =~ s/-/_/g; # pt-BR -> pt_BR in scp
667cdf0e10cSrcweir			}
668cdf0e10cSrcweir
669cdf0e10cSrcweir			# Modules in different languages are listed more than once in multilingual installation sets
670cdf0e10cSrcweir			if ( exists($gid_analyzed{$modulegid}) ) { next; }
671cdf0e10cSrcweir			$gid_analyzed{$modulegid} = 1;
672cdf0e10cSrcweir
673cdf0e10cSrcweir			my $packinfofile = $onemodule->{$packageinfo};
674cdf0e10cSrcweir
675cdf0e10cSrcweir			# The file with package information has to be found in path list
676cdf0e10cSrcweir			my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packinfofile, "" , 0);
677cdf0e10cSrcweir
678cdf0e10cSrcweir			if ( $$fileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find file $packinfofile for module $modulegid!", "collectpackages"); }
679cdf0e10cSrcweir
680cdf0e10cSrcweir			my $infoline = "$modulegid: Using packinfo: \"$$fileref\"!\n";
681cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
682cdf0e10cSrcweir
683cdf0e10cSrcweir			get_packinfo($modulegid, $$fileref, \@packages, $onelanguage, $islanguagemodule);
684cdf0e10cSrcweir		}
685cdf0e10cSrcweir	}
686cdf0e10cSrcweir
687cdf0e10cSrcweir	return \@packages;
688cdf0e10cSrcweir}
689cdf0e10cSrcweir
690cdf0e10cSrcweir#####################################################################
691cdf0e10cSrcweir# Printing packages content for debugging purposes
692cdf0e10cSrcweir#####################################################################
693cdf0e10cSrcweir
694cdf0e10cSrcweirsub log_packages_content
695cdf0e10cSrcweir{
696cdf0e10cSrcweir	my ($packages) = @_;
697cdf0e10cSrcweir
698cdf0e10cSrcweir	if ( ! ( $#{$packages} > -1 )) { installer::exiter::exit_program("ERROR: No packages defined!", "print_content"); }
699cdf0e10cSrcweir
700cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Logging packages content:");
701cdf0e10cSrcweir
702cdf0e10cSrcweir	my $infoline = "";
703cdf0e10cSrcweir
704cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$packages}; $i++ )
705cdf0e10cSrcweir	{
706cdf0e10cSrcweir		my $onepackage = ${$packages}[$i];
707cdf0e10cSrcweir
708cdf0e10cSrcweir		# checking all items that must be defined
709cdf0e10cSrcweir
710cdf0e10cSrcweir		$infoline = "Package $onepackage->{'module'}\n";
711cdf0e10cSrcweir		push(@installer::globals::logfileinfo, $infoline);
712cdf0e10cSrcweir
713cdf0e10cSrcweir		my $key;
714cdf0e10cSrcweir		foreach $key (sort keys %{$onepackage})
715cdf0e10cSrcweir		{
716cdf0e10cSrcweir			if ( $key =~ /^\s*\;/ ) { next; }
717cdf0e10cSrcweir
718cdf0e10cSrcweir			if ( $key eq "allmodules" )
719cdf0e10cSrcweir			{
720cdf0e10cSrcweir				$infoline = "\t$key:\n";
721cdf0e10cSrcweir				push(@installer::globals::logfileinfo, $infoline);
722cdf0e10cSrcweir				my $onemodule;
723cdf0e10cSrcweir				foreach $onemodule ( @{$onepackage->{$key}} )
724cdf0e10cSrcweir				{
725cdf0e10cSrcweir					$infoline = "\t\t$onemodule\n";
726cdf0e10cSrcweir					push(@installer::globals::logfileinfo, $infoline);
727cdf0e10cSrcweir				}
728cdf0e10cSrcweir			}
729cdf0e10cSrcweir			else
730cdf0e10cSrcweir			{
731cdf0e10cSrcweir				$infoline = "\t$key: $onepackage->{$key}\n";
732cdf0e10cSrcweir				push(@installer::globals::logfileinfo, $infoline);
733cdf0e10cSrcweir			}
734cdf0e10cSrcweir		}
735cdf0e10cSrcweir
736cdf0e10cSrcweir		$infoline = "\n";
737cdf0e10cSrcweir		push(@installer::globals::logfileinfo, $infoline);
738cdf0e10cSrcweir
739cdf0e10cSrcweir	}
740cdf0e10cSrcweir}
741cdf0e10cSrcweir
742cdf0e10cSrcweir#####################################################################
743cdf0e10cSrcweir# Creating assignments from modules to destination pathes.
744cdf0e10cSrcweir# This is required for logging in fileinfo file. Otherwise
745cdf0e10cSrcweir# the complete destination file would not be known in file list.
746cdf0e10cSrcweir# Saved in %installer::globals::moduledestination
747cdf0e10cSrcweir#####################################################################
748cdf0e10cSrcweir
749cdf0e10cSrcweirsub create_module_destination_hash
750cdf0e10cSrcweir{
751cdf0e10cSrcweir	my ($packages, $allvariables) = @_;
752cdf0e10cSrcweir
753cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$packages}; $i++ )
754cdf0e10cSrcweir	{
755cdf0e10cSrcweir		my $onepackage = ${$packages}[$i];
756cdf0e10cSrcweir
757cdf0e10cSrcweir		my $defaultdestination = $onepackage->{'destpath'};
758cdf0e10cSrcweir		resolve_packagevariables(\$defaultdestination, $allvariables, 1);
759cdf0e10cSrcweir		if ( $^O =~ /darwin/i ) { $defaultdestination =~ s/\/opt\//\/Applications\//; }
760cdf0e10cSrcweir
761cdf0e10cSrcweir		foreach my $onemodule ( @{$onepackage->{'allmodules'}} )
762cdf0e10cSrcweir		{
763cdf0e10cSrcweir			$installer::globals::moduledestination{$onemodule} = $defaultdestination;
764cdf0e10cSrcweir		}
765cdf0e10cSrcweir	}
766cdf0e10cSrcweir}
767cdf0e10cSrcweir
768cdf0e10cSrcweir#####################################################################
769cdf0e10cSrcweir# Adding the default pathes into the files collector for Unixes.
770cdf0e10cSrcweir# This is necessary to know the complete destination path in
771cdf0e10cSrcweir# fileinfo log file.
772cdf0e10cSrcweir#####################################################################
773cdf0e10cSrcweir
774cdf0e10cSrcweirsub add_defaultpathes_into_filescollector
775cdf0e10cSrcweir{
776cdf0e10cSrcweir	my ($allfiles) = @_;
777cdf0e10cSrcweir
778cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$allfiles}; $i++ )
779cdf0e10cSrcweir	{
780cdf0e10cSrcweir		my $onefile = ${$allfiles}[$i];
781cdf0e10cSrcweir
782cdf0e10cSrcweir		if ( ! $onefile->{'destination'} ) { installer::exiter::exit_program("ERROR: No destination found at file $onefile->{'gid'}!", "add_defaultpathes_into_filescollector"); }
783cdf0e10cSrcweir		my $destination = $onefile->{'destination'};
784cdf0e10cSrcweir
785cdf0e10cSrcweir		if ( ! $onefile->{'modules'} ) { installer::exiter::exit_program("ERROR: No modules found at file $onefile->{'gid'}!", "add_defaultpathes_into_filescollector"); }
786cdf0e10cSrcweir		my $module = $onefile->{'modules'};
787cdf0e10cSrcweir		# If modules contains a list of modules, only taking the first one.
788cdf0e10cSrcweir		if ( $module =~ /^\s*(.*?)\,/ ) { $module = $1; }
789cdf0e10cSrcweir
790cdf0e10cSrcweir		if ( ! exists($installer::globals::moduledestination{$module}) ) { installer::exiter::exit_program("ERROR: No default destination path found for module $module!", "add_defaultpathes_into_filescollector"); }
791cdf0e10cSrcweir		my $defaultpath = $installer::globals::moduledestination{$module};
792cdf0e10cSrcweir		$defaultpath =~ s/\/\s*$//; # removing ending slashes
793cdf0e10cSrcweir		my $fulldestpath = $defaultpath . $installer::globals::separator . $destination;
794cdf0e10cSrcweir
795cdf0e10cSrcweir		$onefile->{'fulldestpath'} = $fulldestpath;
796cdf0e10cSrcweir	}
797cdf0e10cSrcweir}
798cdf0e10cSrcweir
799cdf0e10cSrcweir#####################################################################
800cdf0e10cSrcweir# Creating list of cabinet files from packages
801cdf0e10cSrcweir#####################################################################
802cdf0e10cSrcweir
803cdf0e10cSrcweirsub prepare_cabinet_files
804cdf0e10cSrcweir{
805cdf0e10cSrcweir	my ($packages, $allvariables) = @_;
806cdf0e10cSrcweir
807cdf0e10cSrcweir	if ( ! ( $#{$packages} > -1 )) { installer::exiter::exit_program("ERROR: No packages defined!", "print_content"); }
808cdf0e10cSrcweir
809cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Preparing cabinet files:");
810cdf0e10cSrcweir
811cdf0e10cSrcweir	my $infoline = "";
812cdf0e10cSrcweir
813cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$packages}; $i++ )
814cdf0e10cSrcweir	{
815cdf0e10cSrcweir		my $onepackage = ${$packages}[$i];
816cdf0e10cSrcweir
817cdf0e10cSrcweir		my $cabinetfile = "$onepackage->{'packagename'}\.cab";
818cdf0e10cSrcweir
819cdf0e10cSrcweir		resolve_packagevariables(\$cabinetfile, $allvariables, 0);
820cdf0e10cSrcweir
821cdf0e10cSrcweir		$installer::globals::allcabinets{$cabinetfile} = 1;
822cdf0e10cSrcweir
823cdf0e10cSrcweir		# checking all items that must be defined
824cdf0e10cSrcweir
825cdf0e10cSrcweir		$infoline = "Package $onepackage->{'module'}\n";
826cdf0e10cSrcweir		push(@installer::globals::logfileinfo, $infoline);
827cdf0e10cSrcweir
828cdf0e10cSrcweir		# Assigning the cab file to the module and also to all corresponding sub modules
829cdf0e10cSrcweir
830cdf0e10cSrcweir		my $onemodule;
831cdf0e10cSrcweir		foreach $onemodule ( @{$onepackage->{'allmodules'}} )
832cdf0e10cSrcweir		{
833cdf0e10cSrcweir			if ( ! exists($installer::globals::allcabinetassigns{$onemodule}) )
834cdf0e10cSrcweir			{
835cdf0e10cSrcweir				$installer::globals::allcabinetassigns{$onemodule} = $cabinetfile;
836cdf0e10cSrcweir			}
837cdf0e10cSrcweir			else
838cdf0e10cSrcweir			{
839cdf0e10cSrcweir				my $infoline = "Warning: Already existing assignment: $onemodule : $installer::globals::allcabinetassigns{$onemodule}\n";
840cdf0e10cSrcweir				push(@installer::globals::logfileinfo, $infoline);
841cdf0e10cSrcweir				$infoline = "Ignoring further assignment: $onemodule : $cabinetfile\n";
842cdf0e10cSrcweir				push(@installer::globals::logfileinfo, $infoline);
843cdf0e10cSrcweir			}
844cdf0e10cSrcweir		}
845cdf0e10cSrcweir	}
846cdf0e10cSrcweir}
847cdf0e10cSrcweir
848cdf0e10cSrcweir#####################################################################
849cdf0e10cSrcweir# Logging assignments of cabinet files
850cdf0e10cSrcweir#####################################################################
851cdf0e10cSrcweir
852cdf0e10cSrcweirsub log_cabinet_assignments
853cdf0e10cSrcweir{
854cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Logging cabinet files:");
855cdf0e10cSrcweir
856cdf0e10cSrcweir	my $infoline = "List of cabinet files:\n";
857cdf0e10cSrcweir	push(@installer::globals::logfileinfo, $infoline);
858cdf0e10cSrcweir
859cdf0e10cSrcweir	my $key;
860cdf0e10cSrcweir	foreach $key ( sort keys %installer::globals::allcabinets ) { push(@installer::globals::logfileinfo, "\t$key\n"); }
861cdf0e10cSrcweir
862cdf0e10cSrcweir	$infoline = "\nList of assignments from modules to cabinet files:\n";
863cdf0e10cSrcweir	push(@installer::globals::logfileinfo, $infoline);
864cdf0e10cSrcweir
865cdf0e10cSrcweir	foreach $key ( sort keys %installer::globals::allcabinetassigns ) { push(@installer::globals::logfileinfo, "\t$key : $installer::globals::allcabinetassigns{$key}\n"); }
866cdf0e10cSrcweir}
867cdf0e10cSrcweir
868cdf0e10cSrcweir1;
869