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::scriptitems;
25cdf0e10cSrcweir
26cdf0e10cSrcweiruse installer::converter;
27cdf0e10cSrcweiruse installer::existence;
28cdf0e10cSrcweiruse installer::exiter;
29cdf0e10cSrcweiruse installer::globals;
30cdf0e10cSrcweiruse installer::languages;
31cdf0e10cSrcweiruse installer::logger;
32cdf0e10cSrcweiruse installer::pathanalyzer;
33cdf0e10cSrcweiruse installer::remover;
34cdf0e10cSrcweiruse installer::systemactions;
35cdf0e10cSrcweir
368bd5297cSJürgen Schmidtuse File::Spec;
378bd5297cSJürgen Schmidtuse SvnRevision;
38c6dedb65SAndre Fischeruse ExtensionsLst;
398bd5297cSJürgen Schmidt
40cdf0e10cSrcweir################################################################
41cdf0e10cSrcweir# Resolving the GID for the directories defined in setup script
42cdf0e10cSrcweir################################################################
43cdf0e10cSrcweir
44cdf0e10cSrcweirsub resolve_all_directory_names
45cdf0e10cSrcweir{
46cdf0e10cSrcweir	my ($directoryarrayref) = @_;
47cdf0e10cSrcweir
48cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::resolve_all_directory_names : $#{$directoryarrayref}"); }
49cdf0e10cSrcweir
50cdf0e10cSrcweir	# After this procedure the hash shall contain the complete language
51cdf0e10cSrcweir	# dependent path, not only the language dependent HostName.
52cdf0e10cSrcweir
53cdf0e10cSrcweir	my ($key, $value, $parentvalue, $parentgid, $parentdirectoryhashref);
54cdf0e10cSrcweir
55cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$directoryarrayref}; $i++ )
56cdf0e10cSrcweir	{
57cdf0e10cSrcweir		my $directoryhashref = ${$directoryarrayref}[$i];
58cdf0e10cSrcweir		my $gid = $directoryhashref-> {'gid'};
59cdf0e10cSrcweir		my $parentid = $directoryhashref-> {'ParentID'};
60cdf0e10cSrcweir
61cdf0e10cSrcweir		if ( $parentid ne "PREDEFINED_PROGDIR" )
62cdf0e10cSrcweir		{
63cdf0e10cSrcweir			# find the array of the parentid, which has to be defined before in setup script
64cdf0e10cSrcweir			# and is therefore listed before in this array
65cdf0e10cSrcweir
66cdf0e10cSrcweir			for ( my $j = 0; $j <= $i; $j++ )
67cdf0e10cSrcweir			{
68cdf0e10cSrcweir				$parentdirectoryhashref = ${$directoryarrayref}[$j];
69cdf0e10cSrcweir				$parentgid = $parentdirectoryhashref->{'gid'};
70cdf0e10cSrcweir
71cdf0e10cSrcweir				if ( $parentid eq $parentgid)
72cdf0e10cSrcweir				{
73cdf0e10cSrcweir					last;
74cdf0e10cSrcweir				}
75cdf0e10cSrcweir			}
76cdf0e10cSrcweir
77cdf0e10cSrcweir			# and now we can put the path together
78cdf0e10cSrcweir			# But take care of the languages!
79cdf0e10cSrcweir
80cdf0e10cSrcweir			my $dirismultilingual = $directoryhashref->{'ismultilingual'};
81cdf0e10cSrcweir			my $parentismultilingual = $parentdirectoryhashref->{'ismultilingual'};
82cdf0e10cSrcweir
83cdf0e10cSrcweir			# First: Both directories are language independent or both directories are language dependent
84cdf0e10cSrcweir
85cdf0e10cSrcweir			if ((( ! $dirismultilingual ) && ( ! $parentismultilingual )) ||
86cdf0e10cSrcweir				(( $dirismultilingual ) && ( $parentismultilingual )))
87cdf0e10cSrcweir			{
88cdf0e10cSrcweir				foreach $key (keys %{$directoryhashref})
89cdf0e10cSrcweir				{
90cdf0e10cSrcweir					# the key ("HostName (en-US)") must be usable for both hashes
91cdf0e10cSrcweir
92cdf0e10cSrcweir					if ( $key =~ /\bHostName\b/ )
93cdf0e10cSrcweir					{
94cdf0e10cSrcweir						$parentvalue = "";
95cdf0e10cSrcweir						$value = $directoryhashref->{$key};
96cdf0e10cSrcweir						if ( $parentdirectoryhashref->{$key} ) { $parentvalue = $parentdirectoryhashref->{$key}; }
97cdf0e10cSrcweir
98cdf0e10cSrcweir						# It is possible, that in scp project, a directory is defined in more languages than
99cdf0e10cSrcweir						# the directory parent (happened after automatic generation of macros.inc).
100cdf0e10cSrcweir						# Therefore this is checked now and written with a warning into the logfile.
101cdf0e10cSrcweir						# This is no error, because (in most cases) the concerned language is not build.
102cdf0e10cSrcweir
103cdf0e10cSrcweir						if ($parentvalue eq "")
104cdf0e10cSrcweir						{
105cdf0e10cSrcweir							$directoryhashref->{$key} = "FAILURE";
106cdf0e10cSrcweir							my $infoline = "WARNING: No hostname for $parentid with \"$key\". Needed by child directory $gid !\n";
107cdf0e10cSrcweir							push( @installer::globals::globallogfileinfo, $infoline);
108cdf0e10cSrcweir						}
109cdf0e10cSrcweir						else
110cdf0e10cSrcweir						{
111cdf0e10cSrcweir							$directoryhashref->{$key} = $parentvalue . $installer::globals::separator . $value;
112cdf0e10cSrcweir						}
113cdf0e10cSrcweir					}
114cdf0e10cSrcweir				}
115cdf0e10cSrcweir			}
116cdf0e10cSrcweir
117cdf0e10cSrcweir			# Second: The directory is language dependent, the parent not
118cdf0e10cSrcweir
119cdf0e10cSrcweir			if (( $dirismultilingual ) && ( ! $parentismultilingual ))
120cdf0e10cSrcweir			{
121cdf0e10cSrcweir				$parentvalue = $parentdirectoryhashref->{'HostName'};		# there is only one
122cdf0e10cSrcweir
123cdf0e10cSrcweir				foreach $key (keys %{$directoryhashref})		# the current directory
124cdf0e10cSrcweir				{
125cdf0e10cSrcweir					if ( $key =~ /\bHostName\b/ )
126cdf0e10cSrcweir					{
127cdf0e10cSrcweir						$value = $directoryhashref->{$key};
128cdf0e10cSrcweir						$directoryhashref->{$key} = $parentvalue . $installer::globals::separator . $value;
129cdf0e10cSrcweir					}
130cdf0e10cSrcweir				}
131cdf0e10cSrcweir			}
132cdf0e10cSrcweir
133cdf0e10cSrcweir			# Third: The directory is not language dependent, the parent is language dependent
134cdf0e10cSrcweir
135cdf0e10cSrcweir			if (( ! $dirismultilingual ) && ( $parentismultilingual ))
136cdf0e10cSrcweir			{
137cdf0e10cSrcweir				$value = $directoryhashref->{'HostName'};		# there is only one
138cdf0e10cSrcweir				delete($directoryhashref->{'HostName'});
139cdf0e10cSrcweir
140cdf0e10cSrcweir				foreach $key (keys %{$parentdirectoryhashref})		# the parent directory
141cdf0e10cSrcweir				{
142cdf0e10cSrcweir					if ( $key =~ /\bHostName\b/ )
143cdf0e10cSrcweir					{
144cdf0e10cSrcweir						$parentvalue = $parentdirectoryhashref->{$key};		# there is only one
145cdf0e10cSrcweir						$directoryhashref->{$key} = $parentvalue . $installer::globals::separator . $value;
146cdf0e10cSrcweir					}
147cdf0e10cSrcweir				}
148cdf0e10cSrcweir
149cdf0e10cSrcweir				$directoryhashref->{'ismultilingual'} = 1;	# now this directory is also language dependent
150cdf0e10cSrcweir			}
151cdf0e10cSrcweir		}
152cdf0e10cSrcweir	}
153cdf0e10cSrcweir}
154cdf0e10cSrcweir
155cdf0e10cSrcweir#############################################################################
156cdf0e10cSrcweir# Files with flag DELETE_ONLY do not need to be packed into installation set
157cdf0e10cSrcweir#############################################################################
158cdf0e10cSrcweir
159cdf0e10cSrcweirsub remove_delete_only_files_from_productlists
160cdf0e10cSrcweir{
161cdf0e10cSrcweir	my ($productarrayref) = @_;
162cdf0e10cSrcweir
163cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::remove_delete_only_files_from_productlists : $#{$productarrayref}"); }
164cdf0e10cSrcweir
165cdf0e10cSrcweir	my @newitems = ();
166cdf0e10cSrcweir
167cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$productarrayref}; $i++ )
168cdf0e10cSrcweir	{
169cdf0e10cSrcweir		my $oneitem = ${$productarrayref}[$i];
170cdf0e10cSrcweir		my $styles = "";
171cdf0e10cSrcweir
172cdf0e10cSrcweir		if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
173cdf0e10cSrcweir
174cdf0e10cSrcweir		if (!($styles =~ /\bDELETE_ONLY\b/))
175cdf0e10cSrcweir		{
176cdf0e10cSrcweir			push(@newitems, $oneitem);
177cdf0e10cSrcweir		}
178cdf0e10cSrcweir	}
179cdf0e10cSrcweir
180cdf0e10cSrcweir	return \@newitems;
181cdf0e10cSrcweir}
182cdf0e10cSrcweir
183cdf0e10cSrcweir#############################################################################
184cdf0e10cSrcweir# Files with flag NOT_IN_SUITE do not need to be packed into
185cdf0e10cSrcweir# Suite installation sets
186cdf0e10cSrcweir#############################################################################
187cdf0e10cSrcweir
188cdf0e10cSrcweirsub remove_notinsuite_files_from_productlists
189cdf0e10cSrcweir{
190cdf0e10cSrcweir	my ($productarrayref) = @_;
191cdf0e10cSrcweir
192cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::remove_notinsuite_files_from_productlists : $#{$productarrayref}"); }
193cdf0e10cSrcweir
194cdf0e10cSrcweir	my @newitems = ();
195cdf0e10cSrcweir
196cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$productarrayref}; $i++ )
197cdf0e10cSrcweir	{
198cdf0e10cSrcweir		my $oneitem = ${$productarrayref}[$i];
199cdf0e10cSrcweir		my $styles = "";
200cdf0e10cSrcweir
201cdf0e10cSrcweir		if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
202cdf0e10cSrcweir
203cdf0e10cSrcweir		if (!($styles =~ /\bNOT_IN_SUITE\b/))
204cdf0e10cSrcweir		{
205cdf0e10cSrcweir			push(@newitems, $oneitem);
206cdf0e10cSrcweir		}
207cdf0e10cSrcweir		else
208cdf0e10cSrcweir		{
209cdf0e10cSrcweir			my $infoline = "INFO: Flag NOT_IN_SUITE \-\> Removing $oneitem->{'gid'} from file list.\n";
210cdf0e10cSrcweir			push( @installer::globals::globallogfileinfo, $infoline);
211cdf0e10cSrcweir		}
212cdf0e10cSrcweir	}
213cdf0e10cSrcweir
214cdf0e10cSrcweir	return \@newitems;
215cdf0e10cSrcweir}
216cdf0e10cSrcweir
217cdf0e10cSrcweir#############################################################################
218cdf0e10cSrcweir# Files with flag NOT_IN_SUITE do not need to be packed into
219cdf0e10cSrcweir# Suite installation sets
220cdf0e10cSrcweir#############################################################################
221cdf0e10cSrcweir
222cdf0e10cSrcweirsub remove_office_start_language_files
223cdf0e10cSrcweir{
224cdf0e10cSrcweir	my ($productarrayref) = @_;
225cdf0e10cSrcweir
226cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::remove_notinsuite_files_from_productlists : $#{$productarrayref}"); }
227cdf0e10cSrcweir
228cdf0e10cSrcweir	my @newitems = ();
229cdf0e10cSrcweir
230cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$productarrayref}; $i++ )
231cdf0e10cSrcweir	{
232cdf0e10cSrcweir		my $oneitem = ${$productarrayref}[$i];
233cdf0e10cSrcweir		my $styles = "";
234cdf0e10cSrcweir
235cdf0e10cSrcweir		if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
236cdf0e10cSrcweir
237cdf0e10cSrcweir		if (!($styles =~ /\bSET_OFFICE_LANGUAGE\b/))
238cdf0e10cSrcweir		{
239cdf0e10cSrcweir			push(@newitems, $oneitem);
240cdf0e10cSrcweir		}
241cdf0e10cSrcweir		else
242cdf0e10cSrcweir		{
243cdf0e10cSrcweir			my $infoline = "INFO: Flag SET_OFFICE_LANGUAGE \-\> Removing $oneitem->{'gid'} from file list.\n";
244cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
245cdf0e10cSrcweir		}
246cdf0e10cSrcweir	}
247cdf0e10cSrcweir
248cdf0e10cSrcweir	return \@newitems;
249cdf0e10cSrcweir}
250cdf0e10cSrcweir
251cdf0e10cSrcweir#############################################################################
252cdf0e10cSrcweir# Registryitems for Uninstall have to be removed
253cdf0e10cSrcweir#############################################################################
254cdf0e10cSrcweir
255cdf0e10cSrcweirsub remove_uninstall_regitems_from_script
256cdf0e10cSrcweir{
257cdf0e10cSrcweir	my ($registryarrayref) = @_;
258cdf0e10cSrcweir
259cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::remove_uninstall_regitems_from_script : $#{$registryarrayref}"); }
260cdf0e10cSrcweir
261cdf0e10cSrcweir	my @newitems = ();
262cdf0e10cSrcweir
263cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$registryarrayref}; $i++ )
264cdf0e10cSrcweir	{
265cdf0e10cSrcweir		my $oneitem = ${$registryarrayref}[$i];
266cdf0e10cSrcweir		my $subkey = "";
267cdf0e10cSrcweir
268cdf0e10cSrcweir		if ( $oneitem->{'Subkey'} ) { $subkey = $oneitem->{'Subkey'}; }
269cdf0e10cSrcweir
270cdf0e10cSrcweir		if ( $subkey =~ /Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall/ ) { next; }
271cdf0e10cSrcweir
272cdf0e10cSrcweir		push(@newitems, $oneitem);
273cdf0e10cSrcweir	}
274cdf0e10cSrcweir
275cdf0e10cSrcweir	return \@newitems;
276cdf0e10cSrcweir}
277cdf0e10cSrcweir
278cdf0e10cSrcweir##############################################################################
279cdf0e10cSrcweir# Searching the language module for a specified language
280cdf0e10cSrcweir##############################################################################
281cdf0e10cSrcweir
282cdf0e10cSrcweirsub get_languagespecific_module
283cdf0e10cSrcweir{
284cdf0e10cSrcweir	my ( $lang, $modulestring ) = @_;
285cdf0e10cSrcweir
286cdf0e10cSrcweir	my $langmodulestring = "";
287cdf0e10cSrcweir
288cdf0e10cSrcweir	my $module;
289cdf0e10cSrcweir	foreach	$module ( keys %installer::globals::alllangmodules )
290cdf0e10cSrcweir	{
291cdf0e10cSrcweir		if (( $installer::globals::alllangmodules{$module} eq $lang ) && ( $modulestring =~ /\b$module\b/ ))
292cdf0e10cSrcweir		{
293cdf0e10cSrcweir			$langmodulestring = "$langmodulestring,$module";
294cdf0e10cSrcweir		}
295cdf0e10cSrcweir	}
296cdf0e10cSrcweir
297cdf0e10cSrcweir	$langmodulestring =~ s/^\s*,//;
298cdf0e10cSrcweir
299cdf0e10cSrcweir	if ( $langmodulestring eq "" ) { installer::exiter::exit_program("ERROR: No language pack module found for language $lang in string \"$modulestring\"!", "get_languagespecific_module");  }
300cdf0e10cSrcweir
301cdf0e10cSrcweir	return $langmodulestring;
302cdf0e10cSrcweir}
303cdf0e10cSrcweir
304cdf0e10cSrcweir##############################################################################
305cdf0e10cSrcweir# Removing all items in product lists which do not have the correct languages
306cdf0e10cSrcweir##############################################################################
307cdf0e10cSrcweir
308cdf0e10cSrcweirsub resolving_all_languages_in_productlists
309cdf0e10cSrcweir{
310cdf0e10cSrcweir	my ($productarrayref, $languagesarrayref) = @_;
311cdf0e10cSrcweir
312cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::resolving_all_languages_in_productlists : $#{$productarrayref} : $#{$languagesarrayref}"); }
313cdf0e10cSrcweir
314cdf0e10cSrcweir	my @itemsinalllanguages = ();
315cdf0e10cSrcweir
316cdf0e10cSrcweir	my ($key, $value);
317cdf0e10cSrcweir
318cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$productarrayref}; $i++ )
319cdf0e10cSrcweir	{
320cdf0e10cSrcweir		my $oneitem = ${$productarrayref}[$i];
321cdf0e10cSrcweir
322cdf0e10cSrcweir		my $ismultilingual = $oneitem->{'ismultilingual'};
323cdf0e10cSrcweir
324cdf0e10cSrcweir		if (!($ismultilingual))	# nothing to do with single language items
325cdf0e10cSrcweir		{
326cdf0e10cSrcweir			$oneitem->{'specificlanguage'} = "";
327cdf0e10cSrcweir			push(@itemsinalllanguages, $oneitem);
328cdf0e10cSrcweir		}
329cdf0e10cSrcweir		else	#all language dependent files
330cdf0e10cSrcweir		{
331cdf0e10cSrcweir			for ( my $j = 0; $j <= $#{$languagesarrayref}; $j++ )	# iterating over all languages
332cdf0e10cSrcweir			{
333cdf0e10cSrcweir				my $onelanguage = ${$languagesarrayref}[$j];
334cdf0e10cSrcweir
335cdf0e10cSrcweir				my %oneitemhash = ();
336cdf0e10cSrcweir
337cdf0e10cSrcweir				foreach $key (keys %{$oneitem})
338cdf0e10cSrcweir				{
339cdf0e10cSrcweir					if ( $key =~ /\(\S+\)/ )	# this are the language dependent keys
340cdf0e10cSrcweir					{
341cdf0e10cSrcweir						if ( $key =~ /\(\Q$onelanguage\E\)/ )
342cdf0e10cSrcweir						{
343cdf0e10cSrcweir							$value = $oneitem->{$key};
344cdf0e10cSrcweir							$oneitemhash{$key} = $value;
345cdf0e10cSrcweir						}
346cdf0e10cSrcweir					}
347cdf0e10cSrcweir					else
348cdf0e10cSrcweir					{
349cdf0e10cSrcweir						$value = $oneitem->{$key};
350cdf0e10cSrcweir						$oneitemhash{$key} = $value;
351cdf0e10cSrcweir					}
352cdf0e10cSrcweir				}
353cdf0e10cSrcweir
354cdf0e10cSrcweir				$oneitemhash{'specificlanguage'} = $onelanguage;
355cdf0e10cSrcweir
356cdf0e10cSrcweir				if ( $oneitemhash{'haslanguagemodule'} )
357cdf0e10cSrcweir				{
358cdf0e10cSrcweir					my $langmodulestring = get_languagespecific_module($onelanguage, $oneitemhash{'modules'});
359cdf0e10cSrcweir					$oneitemhash{'modules'} = $langmodulestring;
360cdf0e10cSrcweir				}
361cdf0e10cSrcweir
362cdf0e10cSrcweir				push(@itemsinalllanguages, \%oneitemhash);
363cdf0e10cSrcweir			}
364cdf0e10cSrcweir		}
365cdf0e10cSrcweir	}
366cdf0e10cSrcweir
367cdf0e10cSrcweir	return \@itemsinalllanguages;
368cdf0e10cSrcweir}
369cdf0e10cSrcweir
370cdf0e10cSrcweir################################################################################
371cdf0e10cSrcweir# Removing all modules, that have the flag LANGUAGEMODULE, but do not
372cdf0e10cSrcweir# have the correct language
373cdf0e10cSrcweir################################################################################
374cdf0e10cSrcweir
375cdf0e10cSrcweirsub remove_not_required_language_modules
376cdf0e10cSrcweir{
377cdf0e10cSrcweir	my ($modulesarrayref, $languagesarrayref) = @_;
378cdf0e10cSrcweir
379cdf0e10cSrcweir	my @allmodules = ();
380cdf0e10cSrcweir
381cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
382cdf0e10cSrcweir	{
383cdf0e10cSrcweir		my $module = ${$modulesarrayref}[$i];
384cdf0e10cSrcweir		my $styles = "";
385cdf0e10cSrcweir		if ( $module->{'Styles'} ) { $styles = $module->{'Styles'}; }
386cdf0e10cSrcweir
387cdf0e10cSrcweir		if ( $styles =~ /\bLANGUAGEMODULE\b/ )
388cdf0e10cSrcweir		{
389cdf0e10cSrcweir			if ( ! exists($module->{'Language'}) ) { installer::exiter::exit_program("ERROR: \"$module->{'gid'}\" has flag LANGUAGEMODULE, but does not know its language!", "remove_not_required_language_modules"); }
390cdf0e10cSrcweir			my $modulelanguage = $module->{'Language'};
391cdf0e10cSrcweir			# checking, if language is required
392cdf0e10cSrcweir			my $doinclude = 0;
393cdf0e10cSrcweir			for ( my $j = 0; $j <= $#{$languagesarrayref}; $j++ )
394cdf0e10cSrcweir			{
395cdf0e10cSrcweir				my $onelanguage = ${$languagesarrayref}[$j];
396cdf0e10cSrcweir				if ( $onelanguage eq $modulelanguage )
397cdf0e10cSrcweir				{
398cdf0e10cSrcweir					$doinclude = 1;
399cdf0e10cSrcweir					last;
400cdf0e10cSrcweir				}
401cdf0e10cSrcweir			}
402cdf0e10cSrcweir
403cdf0e10cSrcweir			if ( $doinclude ) { push(@allmodules, $module); }
404cdf0e10cSrcweir		}
405cdf0e10cSrcweir		else
406cdf0e10cSrcweir		{
407cdf0e10cSrcweir			push(@allmodules, $module);
408cdf0e10cSrcweir		}
409cdf0e10cSrcweir	}
410cdf0e10cSrcweir
411cdf0e10cSrcweir	return \@allmodules;
412cdf0e10cSrcweir}
413cdf0e10cSrcweir
414cdf0e10cSrcweir################################################################################
415cdf0e10cSrcweir# Removing all modules, that have a spellchecker language that is not
416cdf0e10cSrcweir# required for this product (spellchecker selection).
417cdf0e10cSrcweir# All required spellchecker languages are stored in
418cdf0e10cSrcweir# %installer::globals::spellcheckerlanguagehash
419cdf0e10cSrcweir################################################################################
420cdf0e10cSrcweir
421cdf0e10cSrcweirsub remove_not_required_spellcheckerlanguage_modules
422cdf0e10cSrcweir{
423cdf0e10cSrcweir	my ($modulesarrayref) = @_;
424cdf0e10cSrcweir
425cdf0e10cSrcweir	my $infoline = "";
426cdf0e10cSrcweir	my @allmodules = ();
427cdf0e10cSrcweir
428cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
429cdf0e10cSrcweir	{
430cdf0e10cSrcweir		my $module = ${$modulesarrayref}[$i];
431cdf0e10cSrcweir		if ( $module->{'Spellcheckerlanguage'} )	# selecting modules with Spellcheckerlanguage
432cdf0e10cSrcweir		{
433cdf0e10cSrcweir			if ( exists($installer::globals::spellcheckerlanguagehash{$module->{'Spellcheckerlanguage'}}) )
434cdf0e10cSrcweir			{
435cdf0e10cSrcweir				push(@allmodules, $module);
436cdf0e10cSrcweir			}
437cdf0e10cSrcweir			else
438cdf0e10cSrcweir			{
439cdf0e10cSrcweir				$infoline = "Spellchecker selection: Removing module $module->{'gid'}\n";
440cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
441cdf0e10cSrcweir
442cdf0e10cSrcweir				# Collecting all files at modules that are removed
443cdf0e10cSrcweir
444cdf0e10cSrcweir				if ( $module->{'Files'} )
445cdf0e10cSrcweir				{
446cdf0e10cSrcweir					if ( $module->{'Files'} =~ /^\s*\((.*?)\)\s*$/ )
447cdf0e10cSrcweir					{
448cdf0e10cSrcweir						my $filelist = $1;
449cdf0e10cSrcweir
450cdf0e10cSrcweir						my $filelisthash = installer::converter::convert_stringlist_into_hash(\$filelist, ",");
451cdf0e10cSrcweir						foreach my $onefile ( keys %{$filelisthash} ) { $installer::globals::spellcheckerfilehash{$onefile} = 1; }
452cdf0e10cSrcweir					}
453cdf0e10cSrcweir				}
454cdf0e10cSrcweir			}
455cdf0e10cSrcweir		}
456cdf0e10cSrcweir		else
457cdf0e10cSrcweir		{
458cdf0e10cSrcweir			push(@allmodules, $module);
459cdf0e10cSrcweir		}
460cdf0e10cSrcweir	}
461cdf0e10cSrcweir
462cdf0e10cSrcweir	return \@allmodules;
463cdf0e10cSrcweir}
464cdf0e10cSrcweir
465cdf0e10cSrcweir################################################################################
466cdf0e10cSrcweir# Removing all modules, that belong to a module that was removed
467cdf0e10cSrcweir# in "remove_not_required_spellcheckerlanguage_modules" because of the
468cdf0e10cSrcweir# spellchecker language. The files belonging to the modules are collected
469cdf0e10cSrcweir# in %installer::globals::spellcheckerfilehash.
470cdf0e10cSrcweir################################################################################
471cdf0e10cSrcweir
472cdf0e10cSrcweirsub remove_not_required_spellcheckerlanguage_files
473cdf0e10cSrcweir{
474cdf0e10cSrcweir	my ($filesarrayref) = @_;
475cdf0e10cSrcweir
476cdf0e10cSrcweir	my @filesarray = ();
477cdf0e10cSrcweir	my $infoline = "";
478cdf0e10cSrcweir
479cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
480cdf0e10cSrcweir	{
481cdf0e10cSrcweir		my $onefile = ${$filesarrayref}[$i];
482cdf0e10cSrcweir		if ( exists($installer::globals::spellcheckerfilehash{$onefile->{'gid'}}) )
483cdf0e10cSrcweir		{
484cdf0e10cSrcweir			$infoline = "Spellchecker selection: Removing file $onefile->{'gid'}\n";
485cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
486cdf0e10cSrcweir			next;
487cdf0e10cSrcweir		}
488cdf0e10cSrcweir		push(@filesarray, $onefile);
489cdf0e10cSrcweir	}
490cdf0e10cSrcweir
491cdf0e10cSrcweir	return \@filesarray;
492cdf0e10cSrcweir}
493cdf0e10cSrcweir
494*9568fc44SAndre Fischer=head3 add_bundled_extension_blobs(@filelist)
495*9568fc44SAndre Fischer
496c6dedb65SAndre Fischer    Add entries for extension blobs to the global file list.
497c6dedb65SAndre Fischer    Extension blobs, unlike preregistered extensions, are not
498c6dedb65SAndre Fischer    extracted before included into a pack set.
499c6dedb65SAndre Fischer
500c6dedb65SAndre Fischer    The set of extensions to include is taken from the BUNDLED_EXTENSION_BLOBS
501c6dedb65SAndre Fischer    environment variable (typically set in configure.)
502c6dedb65SAndre Fischer
503c6dedb65SAndre Fischer    If that variable is not defined then the content of main/extensions.lst defines
504c6dedb65SAndre Fischer    the default set.
505c6dedb65SAndre Fischer
506c6dedb65SAndre Fischer    Extension blobs are placed in gid_Brand_Dir_Share_Extensions_Install.
507*9568fc44SAndre Fischer
508c6dedb65SAndre Fischer=cut
509010ec03aSHerbert Dürrsub add_bundled_extension_blobs
510010ec03aSHerbert Dürr{
511010ec03aSHerbert Dürr	my @filelist = @{$_[0]};
512010ec03aSHerbert Dürr
513c6dedb65SAndre Fischer    my @bundle_files = ();
514c6dedb65SAndre Fischer    my $bundleenv = $ENV{'BUNDLED_EXTENSION_BLOBS'};
515*9568fc44SAndre Fischer    my $bundlehttpsrc = $ENV{'TARFILE_LOCATION'} . $installer::globals::separator;
516*9568fc44SAndre Fischer    my $bundlefilesrc = $ENV{SOLARVERSION}
517*9568fc44SAndre Fischer        . $installer::globals::separator . $ENV{INPATH}
518*9568fc44SAndre Fischer        . $installer::globals::separator . "bin"
519*9568fc44SAndre Fischer        . $installer::globals::separator;
520c6dedb65SAndre Fischer
521c6dedb65SAndre Fischer    if ($installer::globals::product =~ /(SDK|URE)/i )
522c6dedb65SAndre Fischer    {
523c6dedb65SAndre Fischer        # No extensions for the SDK.
524c6dedb65SAndre Fischer    }
525c6dedb65SAndre Fischer    elsif (defined $bundleenv)
526c6dedb65SAndre Fischer    {
527c6dedb65SAndre Fischer        # Use the list of extensions that was explicitly given to configure.
528*9568fc44SAndre Fischer        for my $name (split(/\s+/, $bundleenv, -1))
529*9568fc44SAndre Fischer        {
530*9568fc44SAndre Fischer            push @bundle_files, $bundlehttpsrc . $name;
531*9568fc44SAndre Fischer        }
532c6dedb65SAndre Fischer    }
533c6dedb65SAndre Fischer    else
534c6dedb65SAndre Fischer    {
535*9568fc44SAndre Fischer        # Add the default extensions for the current language set.
536*9568fc44SAndre Fischer        # http:// extensions are taken from ext_sources/.
537*9568fc44SAndre Fischer        for my $name (ExtensionsLst::GetExtensionList("http|https", @installer::globals::languageproducts))
538*9568fc44SAndre Fischer        {
539*9568fc44SAndre Fischer            push @bundle_files, $bundlehttpsrc . $name;
540*9568fc44SAndre Fischer        }
541*9568fc44SAndre Fischer        # file:// extensions are taken from the solver bin/ directory.
542*9568fc44SAndre Fischer        for my $name (ExtensionsLst::GetExtensionList("file", @installer::globals::languageproducts))
543*9568fc44SAndre Fischer        {
544*9568fc44SAndre Fischer            push @bundle_files, $bundlefilesrc . $name;
545*9568fc44SAndre Fischer        }
546c6dedb65SAndre Fischer    }
547c6dedb65SAndre Fischer
548c6dedb65SAndre Fischer    installer::logger::print_message(
549*9568fc44SAndre Fischer        sprintf("preparing %d extension blob%s for language%s %s:\n",
550c6dedb65SAndre Fischer           $#bundle_files + 1,
551c6dedb65SAndre Fischer           $#bundle_files!=0 ? "s" : "",
552c6dedb65SAndre Fischer           $#installer::globals::languageproducts!=0 ? "s" : "",
553c6dedb65SAndre Fischer           join(" ", @installer::globals::languageproducts),
554c6dedb65SAndre Fischer           join("\n    ", @bundle_files)));
555c6dedb65SAndre Fischer
556c6dedb65SAndre Fischer    foreach my $filename ( @bundle_files)
557c6dedb65SAndre Fischer    {
558c6dedb65SAndre Fischer        my $basename = File::Basename::basename( $filename);
559c6dedb65SAndre Fischer        my $onefile = {
560c6dedb65SAndre Fischer            'Dir' => 'gid_Brand_Dir_Share_Extensions_Install',
561c6dedb65SAndre Fischer            'Name' => $basename,
562c6dedb65SAndre Fischer            'Styles' => '(PACKED)',
563c6dedb65SAndre Fischer            'UnixRights' => '444',
564*9568fc44SAndre Fischer            'sourcepath' => $filename,
565c6dedb65SAndre Fischer            'modules' => "gid_Module_Dictionaries",
566c6dedb65SAndre Fischer            'gid' => "gid_File_Extension_".$basename
567c6dedb65SAndre Fischer        };
568c6dedb65SAndre Fischer        push( @filelist, $onefile);
569c6dedb65SAndre Fischer        push( @installer::globals::logfileinfo, "\tbundling \"$filename\" extension\n");
570*9568fc44SAndre Fischer
571*9568fc44SAndre Fischer        installer::logger::print_message("    " . $basename . "\n");
572c6dedb65SAndre Fischer    }
573c6dedb65SAndre Fischer
574010ec03aSHerbert Dürr	return \@filelist;
575010ec03aSHerbert Dürr}
576010ec03aSHerbert Dürr
577*9568fc44SAndre Fischer=head3 add_bundled_prereg_extensions(@filelist)
578*9568fc44SAndre Fischer
579c6dedb65SAndre Fischer    Add entries for preregistered extensions to the global file list.
580*9568fc44SAndre Fischer
581c6dedb65SAndre Fischer    The set of extensions to include is taken from the BUNDLED_PREREG_EXTENSIONS
582c6dedb65SAndre Fischer    environment variable (typically set in configure.)
583c6dedb65SAndre Fischer
584c6dedb65SAndre Fischer    If that variable is not defined then the content of main/extensions.lst defines
585c6dedb65SAndre Fischer    the default set.
586c6dedb65SAndre Fischer
587c6dedb65SAndre Fischer    Preregistered extensions are placed in subdirectories of gid_Brand_Dir_Share_Prereg_Bundled.
588*9568fc44SAndre Fischer
589c6dedb65SAndre Fischer=cut
590010ec03aSHerbert Dürrsub add_bundled_prereg_extensions
591010ec03aSHerbert Dürr{
592010ec03aSHerbert Dürr	my @filelist = @{$_[0]};
593c6dedb65SAndre Fischer    my $dirsref = $_[1];
594c6dedb65SAndre Fischer
595c6dedb65SAndre Fischer    my @bundle_files = ();
596c6dedb65SAndre Fischer    my $bundleenv = $ENV{'BUNDLED_PREREG_EXTENSIONS'};
597c6dedb65SAndre Fischer
598c6dedb65SAndre Fischer    if ($installer::globals::product =~ /(SDK|URE)/i )
599c6dedb65SAndre Fischer    {
600c6dedb65SAndre Fischer        # No extensions for the SDK.
601c6dedb65SAndre Fischer    }
602c6dedb65SAndre Fischer    elsif (defined $bundleenv)
603c6dedb65SAndre Fischer    {
604c6dedb65SAndre Fischer        # Use the list of extensions that was explicitly given to configure.
605c6dedb65SAndre Fischer        @bundle_files = split(/\s+/, $bundleenv, -1);
606c6dedb65SAndre Fischer    }
607c6dedb65SAndre Fischer    else
608c6dedb65SAndre Fischer    {
609c6dedb65SAndre Fischer        # Add the default rextensions for the current language set.
610*9568fc44SAndre Fischer
611*9568fc44SAndre Fischer        # file:// URLs are currently handled by add_bundled_extension_blobs(@), therefore
612*9568fc44SAndre Fischer        # we may not their handling here anmore.
613*9568fc44SAndre Fischer        # @bundle_files = ExtensionsLst::GetExtensionList("file", @installer::globals::languageproducts);
614c6dedb65SAndre Fischer    }
615c6dedb65SAndre Fischer
616c6dedb65SAndre Fischer    installer::logger::print_message(
617c6dedb65SAndre Fischer        sprintf("preparing %d bundled extension%s for language%s %s:\n    %s\n",
618c6dedb65SAndre Fischer           $#bundle_files + 1,
619c6dedb65SAndre Fischer           $#bundle_files!=0 ? "s" : "",
620c6dedb65SAndre Fischer           $#installer::globals::languageproducts!=0 ? "s" : "",
621c6dedb65SAndre Fischer           join(" ", @installer::globals::languageproducts),
622c6dedb65SAndre Fischer           join("\n    ", @bundle_files)));
623c6dedb65SAndre Fischer
624c6dedb65SAndre Fischer    # Find the prereg directory entry so that we can create a new sub-directory.
625c6dedb65SAndre Fischer    my $parentdir_gid = "gid_Brand_Dir_Share_Prereg_Bundled";
626c6dedb65SAndre Fischer    my $parentdir = undef;
627c6dedb65SAndre Fischer    foreach my $dir (@{$dirsref})
628c6dedb65SAndre Fischer    {
629c6dedb65SAndre Fischer        if ($dir->{'gid'} eq $parentdir_gid)
630c6dedb65SAndre Fischer        {
631c6dedb65SAndre Fischer            $parentdir = $dir;
632c6dedb65SAndre Fischer            last;
633c6dedb65SAndre Fischer        }
634c6dedb65SAndre Fischer    }
635c6dedb65SAndre Fischer
636c6dedb65SAndre Fischer    foreach my $filename ( @bundle_files)
637c6dedb65SAndre Fischer    {
638c6dedb65SAndre Fischer        my $basename = File::Basename::basename( $filename);
639c6dedb65SAndre Fischer
640c6dedb65SAndre Fischer        # Create a new directory into which the extension will be installed.
641c6dedb65SAndre Fischer        my $dirgid =  $parentdir_gid . "_" . $basename;
642c6dedb65SAndre Fischer        my $onedir = {
643c6dedb65SAndre Fischer            'modules' => 'gid_Module_Root_Brand',
644c6dedb65SAndre Fischer            'ismultilingual' => 0,
645c6dedb65SAndre Fischer            'Styles' => '(CREATE)',
646c6dedb65SAndre Fischer            'ParentID' => $parentdir_gid,
647c6dedb65SAndre Fischer            'specificlanguage' => "",
648c6dedb65SAndre Fischer            'haslanguagemodule' => 0,
649c6dedb65SAndre Fischer            'gid' => $dirgid,
650c6dedb65SAndre Fischer            'HostName' => $parentdir->{'HostName'} . $installer::globals::separator . $basename
651c6dedb65SAndre Fischer        };
652c6dedb65SAndre Fischer        push (@{$dirsref}, $onedir);
653c6dedb65SAndre Fischer
654c6dedb65SAndre Fischer        # Create a new file entry for the extension.
655c6dedb65SAndre Fischer        my $onefile = {
656c6dedb65SAndre Fischer            'Dir' => $dirgid,
657c6dedb65SAndre Fischer            'Name' => $basename,
658c6dedb65SAndre Fischer            'Styles' => '(PACKED,ARCHIVE)',
659c6dedb65SAndre Fischer            'UnixRights' => '444',
660c6dedb65SAndre Fischer            'sourcepath' => File::Spec->catfile($ENV{'OUTDIR'}, "bin", $filename),
661c6dedb65SAndre Fischer            'specificlanguage' => "",
662c6dedb65SAndre Fischer            'modules' => "gid_Module_Dictionaries",
663c6dedb65SAndre Fischer            'gid' => "gid_File_Extension_".$basename
664c6dedb65SAndre Fischer        };
665c6dedb65SAndre Fischer        push( @filelist, $onefile);
666c6dedb65SAndre Fischer        push( @installer::globals::logfileinfo, "\tbundling \"$filename\" extension\n");
667c6dedb65SAndre Fischer    }
668c6dedb65SAndre Fischer
669c6dedb65SAndre Fischer    return (\@filelist, $dirsref);
670010ec03aSHerbert Dürr}
671010ec03aSHerbert Dürr
672cdf0e10cSrcweir################################################################################
673cdf0e10cSrcweir# Looking for directories without correct HostName
674cdf0e10cSrcweir################################################################################
675cdf0e10cSrcweir
676cdf0e10cSrcweirsub checking_directories_with_corrupt_hostname
677cdf0e10cSrcweir{
678cdf0e10cSrcweir	my ($dirsref, $languagesarrayref) = @_;
679cdf0e10cSrcweir
680cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
681cdf0e10cSrcweir	{
682cdf0e10cSrcweir		my $onedir = ${$dirsref}[$i];
683cdf0e10cSrcweir
684cdf0e10cSrcweir		my $hostname = "";
685cdf0e10cSrcweir
686cdf0e10cSrcweir		if ( $onedir->{'HostName'} ) { $hostname = $onedir->{'HostName'}; }
687cdf0e10cSrcweir
688cdf0e10cSrcweir		if ( $hostname eq "" )
689cdf0e10cSrcweir		{
690cdf0e10cSrcweir			my $langstring = "";
691cdf0e10cSrcweir			for ( my $j = 0; $j <= $#{$languagesarrayref}; $j++ ) { $langstring .= ${$languagesarrayref}[$j] . " "; }
692cdf0e10cSrcweir			installer::exiter::exit_program("ERROR: HostName not defined for $onedir->{'gid'} for specified language. Probably you wanted to create an installation set, in a language not defined in scp2 project. You selected the following language(s): $langstring", "checking_directories_with_corrupt_hostname");
693cdf0e10cSrcweir		}
694cdf0e10cSrcweir
695cdf0e10cSrcweir		if ( $hostname eq "FAILURE" )
696cdf0e10cSrcweir		{
697cdf0e10cSrcweir			installer::exiter::exit_program("ERROR: Could not create HostName for $onedir->{'gid'} (missing language at parent). See logfile warning for more info!", "checking_directories_with_corrupt_hostname");
698cdf0e10cSrcweir		}
699cdf0e10cSrcweir	}
700cdf0e10cSrcweir}
701cdf0e10cSrcweir
702cdf0e10cSrcweir################################################################################
703cdf0e10cSrcweir# Setting global properties
704cdf0e10cSrcweir################################################################################
705cdf0e10cSrcweir
706cdf0e10cSrcweirsub set_global_directory_hostnames
707cdf0e10cSrcweir{
708cdf0e10cSrcweir	my ($dirsref, $allvariables) = @_;
709cdf0e10cSrcweir
710cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
711cdf0e10cSrcweir	{
712cdf0e10cSrcweir		my $onedir = ${$dirsref}[$i];
713cdf0e10cSrcweir		my $styles = "";
714cdf0e10cSrcweir		if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
715cdf0e10cSrcweir
716cdf0e10cSrcweir		if ( $styles =~ /\bOFFICEDIRECTORY\b/ )
717cdf0e10cSrcweir		{
718cdf0e10cSrcweir			$installer::globals::officedirhostname = $onedir->{'HostName'};
719cdf0e10cSrcweir			$installer::globals::officedirgid = $onedir->{'gid'};
720cdf0e10cSrcweir			$allvariables->{'OFFICEDIRECTORYHOSTNAME'} = $installer::globals::officedirhostname;
721cdf0e10cSrcweir		}
722cdf0e10cSrcweir		if ( $styles =~ /\bSUNDIRECTORY\b/ )
723cdf0e10cSrcweir		{
724cdf0e10cSrcweir			$installer::globals::sundirhostname = $onedir->{'HostName'};
725cdf0e10cSrcweir			$installer::globals::sundirgid = $onedir->{'gid'};
726cdf0e10cSrcweir			$allvariables->{'SUNDIRECTORYHOSTNAME'} = $installer::globals::sundirhostname;
727cdf0e10cSrcweir		}
728cdf0e10cSrcweir	}
729cdf0e10cSrcweir}
730cdf0e10cSrcweir
731cdf0e10cSrcweir########################################################
732cdf0e10cSrcweir# Recursively defined procedure to order
733cdf0e10cSrcweir# modules and directories
734cdf0e10cSrcweir########################################################
735cdf0e10cSrcweir
736cdf0e10cSrcweirsub get_children
737cdf0e10cSrcweir{
738cdf0e10cSrcweir	my ($allitems, $startparent, $newitemorder) = @_;
739cdf0e10cSrcweir
740cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$allitems}; $i++ )
741cdf0e10cSrcweir	{
742cdf0e10cSrcweir		my $gid = ${$allitems}[$i]->{'gid'};
743cdf0e10cSrcweir		my $parent = "";
744cdf0e10cSrcweir		if ( ${$allitems}[$i]->{'ParentID'} ) { $parent = ${$allitems}[$i]->{'ParentID'}; }
745cdf0e10cSrcweir
746cdf0e10cSrcweir		if ( $parent eq $startparent )
747cdf0e10cSrcweir		{
748cdf0e10cSrcweir			push(@{$newitemorder}, ${$allitems}[$i]);
749cdf0e10cSrcweir			my $parent = $gid;
750cdf0e10cSrcweir			get_children($allitems, $parent, $newitemorder);	# recursive!
751cdf0e10cSrcweir		}
752cdf0e10cSrcweir	}
753cdf0e10cSrcweir}
754cdf0e10cSrcweir
755cdf0e10cSrcweir################################################################################
756cdf0e10cSrcweir# Using different HostName for language packs
757cdf0e10cSrcweir################################################################################
758cdf0e10cSrcweir
759cdf0e10cSrcweirsub use_langpack_hostname
760cdf0e10cSrcweir{
761cdf0e10cSrcweir	my ($dirsref) = @_;
762cdf0e10cSrcweir
763cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
764cdf0e10cSrcweir	{
765cdf0e10cSrcweir		my $onedir = ${$dirsref}[$i];
766cdf0e10cSrcweir		if (( $onedir->{'LangPackHostName'} ) && ( $onedir->{'LangPackHostName'} ne "" )) { $onedir->{'HostName'} = $onedir->{'LangPackHostName'}; }
767cdf0e10cSrcweir	}
768cdf0e10cSrcweir}
769cdf0e10cSrcweir
770cdf0e10cSrcweir################################################################################
771cdf0e10cSrcweir# Using different HostName for language packs
772cdf0e10cSrcweir################################################################################
773cdf0e10cSrcweir
774cdf0e10cSrcweirsub use_patch_hostname
775cdf0e10cSrcweir{
776cdf0e10cSrcweir	my ($dirsref) = @_;
777cdf0e10cSrcweir
778cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
779cdf0e10cSrcweir	{
780cdf0e10cSrcweir		my $onedir = ${$dirsref}[$i];
781cdf0e10cSrcweir		if (( $onedir->{'PatchHostName'} ) && ( $onedir->{'PatchHostName'} ne "" )) { $onedir->{'HostName'} = $onedir->{'PatchHostName'}; }
782cdf0e10cSrcweir	}
783cdf0e10cSrcweir}
784cdf0e10cSrcweir
785cdf0e10cSrcweir################################################################################
7861ed5bd48SJürgen Schmidt# Using langpack copy action for language packs
787cdf0e10cSrcweir################################################################################
788cdf0e10cSrcweir
789cdf0e10cSrcweirsub use_langpack_copy_scpaction
790cdf0e10cSrcweir{
791cdf0e10cSrcweir	my ($scpactionsref) = @_;
792cdf0e10cSrcweir
793cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$scpactionsref}; $i++ )
794cdf0e10cSrcweir	{
795cdf0e10cSrcweir		my $onescpaction = ${$scpactionsref}[$i];
796cdf0e10cSrcweir		if (( $onescpaction->{'LangPackCopy'} ) && ( $onescpaction->{'LangPackCopy'} ne "" )) { $onescpaction->{'Copy'} = $onescpaction->{'LangPackCopy'}; }
797cdf0e10cSrcweir	}
798cdf0e10cSrcweir}
799cdf0e10cSrcweir
800cdf0e10cSrcweir################################################################################
8011ed5bd48SJürgen Schmidt# Using copy patch action
802cdf0e10cSrcweir################################################################################
803cdf0e10cSrcweir
804cdf0e10cSrcweirsub use_patch_copy_scpaction
805cdf0e10cSrcweir{
806cdf0e10cSrcweir	my ($scpactionsref) = @_;
807cdf0e10cSrcweir
808cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$scpactionsref}; $i++ )
809cdf0e10cSrcweir	{
810cdf0e10cSrcweir		my $onescpaction = ${$scpactionsref}[$i];
811cdf0e10cSrcweir		if (( $onescpaction->{'PatchCopy'} ) && ( $onescpaction->{'PatchCopy'} ne "" )) { $onescpaction->{'Copy'} = $onescpaction->{'PatchCopy'}; }
812cdf0e10cSrcweir	}
813cdf0e10cSrcweir}
814cdf0e10cSrcweir
8151ed5bd48SJürgen Schmidt################################################################################
8161ed5bd48SJürgen Schmidt# Using dev copy patch action for developer snapshot builds
8171ed5bd48SJürgen Schmidt################################################################################
8181ed5bd48SJürgen Schmidt
8191ed5bd48SJürgen Schmidtsub use_dev_copy_scpaction
8201ed5bd48SJürgen Schmidt{
8211ed5bd48SJürgen Schmidt	my ($scpactionsref) = @_;
8221ed5bd48SJürgen Schmidt
8231ed5bd48SJürgen Schmidt	for ( my $i = 0; $i <= $#{$scpactionsref}; $i++ )
8241ed5bd48SJürgen Schmidt	{
8251ed5bd48SJürgen Schmidt		my $onescpaction = ${$scpactionsref}[$i];
8261ed5bd48SJürgen Schmidt		if (( $onescpaction->{'DevCopy'} ) && ( $onescpaction->{'DevCopy'} ne "" )) { $onescpaction->{'Copy'} = $onescpaction->{'DevCopy'}; }
8271ed5bd48SJürgen Schmidt	}
8281ed5bd48SJürgen Schmidt}
8291ed5bd48SJürgen Schmidt
830cdf0e10cSrcweir################################################################################
831cdf0e10cSrcweir# Shifting parent directories of URE and Basis layer, so that
832cdf0e10cSrcweir# these directories are located below the Brand layer.
833cdf0e10cSrcweir# Style: SHIFT_BASIS_INTO_BRAND_LAYER
834cdf0e10cSrcweir################################################################################
835cdf0e10cSrcweir
836cdf0e10cSrcweirsub shift_basis_directory_parents
837cdf0e10cSrcweir{
838cdf0e10cSrcweir	my ($dirsref) = @_;
839cdf0e10cSrcweir
840cdf0e10cSrcweir	my @alldirs = ();
841cdf0e10cSrcweir	my @savedirs = ();
842cdf0e10cSrcweir	my @shifteddirs = ();
843cdf0e10cSrcweir
844cdf0e10cSrcweir	my $officedirgid = "";
845cdf0e10cSrcweir
846cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
847cdf0e10cSrcweir	{
848cdf0e10cSrcweir		my $onedir = ${$dirsref}[$i];
849cdf0e10cSrcweir		my $styles = "";
850cdf0e10cSrcweir		if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
851cdf0e10cSrcweir
852cdf0e10cSrcweir		if ( $styles =~ /\bOFFICEDIRECTORY\b/ ) { $officedirgid = $onedir->{'gid'}; }
853cdf0e10cSrcweir	}
854cdf0e10cSrcweir
855cdf0e10cSrcweir	if ( $officedirgid ne "" )
856cdf0e10cSrcweir	{
857cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
858cdf0e10cSrcweir		{
859cdf0e10cSrcweir			my $onedir = ${$dirsref}[$i];
860cdf0e10cSrcweir			my $styles = "";
861cdf0e10cSrcweir			if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
862cdf0e10cSrcweir
863cdf0e10cSrcweir			if (( $styles =~ /\bBASISDIRECTORY\b/ ) || ( $styles =~ /\bUREDIRECTORY\b/ ))
864cdf0e10cSrcweir			{
865cdf0e10cSrcweir				$onedir->{'ParentID'} = $officedirgid;
866cdf0e10cSrcweir			}
867cdf0e10cSrcweir		}
868cdf0e10cSrcweir
869cdf0e10cSrcweir		# Sorting directories
870cdf0e10cSrcweir		my $startgid = "PREDEFINED_PROGDIR";
871cdf0e10cSrcweir		get_children($dirsref, $startgid, \@alldirs);
872cdf0e10cSrcweir	}
873cdf0e10cSrcweir
874cdf0e10cSrcweir	return \@alldirs;
875cdf0e10cSrcweir}
876cdf0e10cSrcweir
877cdf0e10cSrcweir################################################################################
878cdf0e10cSrcweir# Setting the name of the directory with style OFFICEDIRECTORY.
879cdf0e10cSrcweir# The name can be defined in property OFFICEDIRECTORYNAME.
880cdf0e10cSrcweir################################################################################
881cdf0e10cSrcweir
882cdf0e10cSrcweirsub set_officedirectory_name
883cdf0e10cSrcweir{
884cdf0e10cSrcweir	my ($dirsref, $officedirname) = @_;
885cdf0e10cSrcweir
886cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
887cdf0e10cSrcweir	{
888cdf0e10cSrcweir		my $onedir = ${$dirsref}[$i];
889cdf0e10cSrcweir		my $styles = "";
890cdf0e10cSrcweir		if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
891cdf0e10cSrcweir		if ( $styles =~ /\bOFFICEDIRECTORY\b/ )
892cdf0e10cSrcweir		{
893cdf0e10cSrcweir			$onedir->{'HostName'} = $officedirname;
894cdf0e10cSrcweir			last;
895cdf0e10cSrcweir		}
896cdf0e10cSrcweir	}
897cdf0e10cSrcweir}
898cdf0e10cSrcweir
899cdf0e10cSrcweir################################################################################
900cdf0e10cSrcweir# Simplifying the name for language dependent items from "Name (xy)" to "Name"
901cdf0e10cSrcweir################################################################################
902cdf0e10cSrcweir
903cdf0e10cSrcweirsub changing_name_of_language_dependent_keys
904cdf0e10cSrcweir{
905cdf0e10cSrcweir	my ($itemsarrayref) = @_;
906cdf0e10cSrcweir
907cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::changing_name_of_language_dependent_keys : $#{$itemsarrayref}"); }
908cdf0e10cSrcweir
909cdf0e10cSrcweir	# Changing key for multilingual items from "Name ( )" to "Name" or "HostName ( )" to "HostName"
910cdf0e10cSrcweir
911cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
912cdf0e10cSrcweir	{
913cdf0e10cSrcweir		my $oneitem = ${$itemsarrayref}[$i];
914cdf0e10cSrcweir		my $onelanguage = $oneitem->{'specificlanguage'};
915cdf0e10cSrcweir
916cdf0e10cSrcweir		if (!($onelanguage eq "" )) 				# language dependent item
917cdf0e10cSrcweir		{
918cdf0e10cSrcweir			my $itemkey;
919cdf0e10cSrcweir
920cdf0e10cSrcweir			foreach $itemkey (keys %{$oneitem})
921cdf0e10cSrcweir			{
922cdf0e10cSrcweir				if ( $itemkey =~ /^\s*(\S+?)\s+\(\S+\)\s*$/ )
923cdf0e10cSrcweir				{
924cdf0e10cSrcweir					my $newitemkey = $1;
925cdf0e10cSrcweir					my $itemvalue = $oneitem->{$itemkey};
926cdf0e10cSrcweir					$oneitem->{$newitemkey} = $itemvalue;
927cdf0e10cSrcweir					delete($oneitem->{$itemkey});
928cdf0e10cSrcweir				}
929cdf0e10cSrcweir			}
930cdf0e10cSrcweir		}
931cdf0e10cSrcweir	}
932cdf0e10cSrcweir}
933cdf0e10cSrcweir
934cdf0e10cSrcweir################################################################################
935cdf0e10cSrcweir# Collecting language specific names for language packs
936cdf0e10cSrcweir################################################################################
937cdf0e10cSrcweir
938cdf0e10cSrcweirsub collect_language_specific_names
939cdf0e10cSrcweir{
940cdf0e10cSrcweir	my ($itemsarrayref) = @_;
941cdf0e10cSrcweir
942cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
943cdf0e10cSrcweir	{
944cdf0e10cSrcweir		my $oneitem = ${$itemsarrayref}[$i];
945cdf0e10cSrcweir		my $styles = "";
946cdf0e10cSrcweir		if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
947cdf0e10cSrcweir
948cdf0e10cSrcweir		if ( $styles =~ /\bUSELANGUAGENAME\b/ )
949cdf0e10cSrcweir		{
950cdf0e10cSrcweir			my $language = "";
951cdf0e10cSrcweir			if ( $oneitem->{'Language'} ) { $language = $oneitem->{'Language'}; }
952cdf0e10cSrcweir			my $specificlanguage = "";
953cdf0e10cSrcweir			if ( $oneitem->{'specificlanguage'} ) { $specificlanguage = $oneitem->{'specificlanguage'}; }
954cdf0e10cSrcweir
955cdf0e10cSrcweir			if (( $language ne "" ) && ( $language eq $specificlanguage ))
956cdf0e10cSrcweir			{
957cdf0e10cSrcweir				if (! installer::existence::exists_in_array($oneitem->{'Name'}, \@installer::globals::languagenames ))
958cdf0e10cSrcweir				{
959cdf0e10cSrcweir					push(@installer::globals::languagenames, $oneitem->{'Name'});
960cdf0e10cSrcweir				}
961cdf0e10cSrcweir			}
962cdf0e10cSrcweir		}
963cdf0e10cSrcweir	}
964cdf0e10cSrcweir}
965cdf0e10cSrcweir
966cdf0e10cSrcweir################################################################################
967cdf0e10cSrcweir# Replacement of setup variables in ConfigurationItems and ProfileItems
968cdf0e10cSrcweir# <productkey>, <buildid>, <sequence_languages>, <productcode>, <upgradecode>, <productupdate>
969cdf0e10cSrcweir################################################################################
970cdf0e10cSrcweir
971cdf0e10cSrcweirsub replace_setup_variables
972cdf0e10cSrcweir{
973cdf0e10cSrcweir	my ($itemsarrayref, $languagestringref, $hashref) = @_;
974cdf0e10cSrcweir
975cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::replace_setup_variables : $#{$itemsarrayref} : $$languagestringref : $hashref->{'PRODUCTNAME'}"); }
976cdf0e10cSrcweir
977cdf0e10cSrcweir	my $languagesstring = $$languagestringref;
978cdf0e10cSrcweir	$languagesstring =~ s/\_/ /g;	# replacing underscore with whitespace
979cdf0e10cSrcweir	# $languagesstring is "01 49" instead of "en-US de"
980cdf0e10cSrcweir	installer::languages::fake_languagesstring(\$languagesstring);
981cdf0e10cSrcweir
982cdf0e10cSrcweir	my $productname = $hashref->{'PRODUCTNAME'};
983cdf0e10cSrcweir	my $productversion = $hashref->{'PRODUCTVERSION'};
984cdf0e10cSrcweir	my $userdirproductversion = "";
985cdf0e10cSrcweir	if ( $hashref->{'USERDIRPRODUCTVERSION'} ) { $userdirproductversion = $hashref->{'USERDIRPRODUCTVERSION'}; }
986cdf0e10cSrcweir	my $productkey = $productname . " " . $productversion;
987cdf0e10cSrcweir
9888bd5297cSJürgen Schmidt	my $scsrevision = SvnRevision::DetectRevisionId(File::Spec->catfile($ENV{'SRC_ROOT'}, File::Spec->updir()));
9898bd5297cSJürgen Schmidt
990cdf0e10cSrcweir	# string $buildid, which is used to replace the setup variable <buildid>
991cdf0e10cSrcweir
992cdf0e10cSrcweir	my $localminor = "flat";
993cdf0e10cSrcweir	if ( $installer::globals::minor ne "" ) { $localminor = $installer::globals::minor; }
994cdf0e10cSrcweir	else { $localminor = $installer::globals::lastminor; }
995cdf0e10cSrcweir
996cdf0e10cSrcweir	my $localbuild = $installer::globals::build;
997cdf0e10cSrcweir
998cdf0e10cSrcweir	if ( $localbuild =~ /^\s*(\w+?)(\d+)\s*$/ ) { $localbuild = $2; }	# using "680" instead of "src680"
999cdf0e10cSrcweir
1000cdf0e10cSrcweir	my $buildidstring = $localbuild . $localminor . "(Build:" . $installer::globals::buildid . ")";
1001cdf0e10cSrcweir
1002cdf0e10cSrcweir	# the environment variable CWS_WORK_STAMP is set only in CWS
1003cdf0e10cSrcweir	if ( $ENV{'CWS_WORK_STAMP'} ) { $buildidstring = $buildidstring . "\[CWS\:" . $ENV{'CWS_WORK_STAMP'} . "\]"; }
1004cdf0e10cSrcweir
1005cdf0e10cSrcweir	if ( $localminor =~ /^\s*\w(\d+)\w*\s*$/ ) { $localminor = $1; }
1006cdf0e10cSrcweir
1007cdf0e10cSrcweir	# $updateid
1008cdf0e10cSrcweir	my $updateid = $productname . "_" . $userdirproductversion . "_" . $$languagestringref;
1009cdf0e10cSrcweir	$updateid =~ s/ /_/g;
1010cdf0e10cSrcweir
1011cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1012cdf0e10cSrcweir	{
1013cdf0e10cSrcweir		my $oneitem = ${$itemsarrayref}[$i];
1014cdf0e10cSrcweir		my $value = $oneitem->{'Value'};
1015cdf0e10cSrcweir
1016cdf0e10cSrcweir		$value =~ s/\<buildid\>/$buildidstring/;
10178bd5297cSJürgen Schmidt		$value =~ s/\<scsrevision\>/$scsrevision/;
1018cdf0e10cSrcweir		$value =~ s/\<sequence_languages\>/$languagesstring/;
1019cdf0e10cSrcweir		$value =~ s/\<productkey\>/$productkey/;
1020cdf0e10cSrcweir		$value =~ s/\<productcode\>/$installer::globals::productcode/;
1021cdf0e10cSrcweir		$value =~ s/\<upgradecode\>/$installer::globals::upgradecode/;
1022cdf0e10cSrcweir		$value =~ s/\<alllanguages\>/$languagesstring/;
1023cdf0e10cSrcweir		$value =~ s/\<productmajor\>/$localbuild/;
1024cdf0e10cSrcweir		$value =~ s/\<productminor\>/$localminor/;
1025cdf0e10cSrcweir		$value =~ s/\<productbuildid\>/$installer::globals::buildid/;
1026cdf0e10cSrcweir		$value =~ s/\<sourceid\>/$installer::globals::build/;
1027cdf0e10cSrcweir		$value =~ s/\<updateid\>/$updateid/;
1028cdf0e10cSrcweir		$value =~ s/\<pkgformat\>/$installer::globals::packageformat/;
1029cdf0e10cSrcweir
1030cdf0e10cSrcweir		$oneitem->{'Value'} = $value;
1031cdf0e10cSrcweir	}
1032cdf0e10cSrcweir}
1033cdf0e10cSrcweir
1034cdf0e10cSrcweir################################################################################
1035cdf0e10cSrcweir# By defining variable LOCALUSERDIR in *.lst it is possible to change
1036cdf0e10cSrcweir# the standard destination of user directory defined in scp2 ($SYSUSERCONFIG).
1037cdf0e10cSrcweir################################################################################
1038cdf0e10cSrcweir
1039cdf0e10cSrcweirsub replace_userdir_variable
1040cdf0e10cSrcweir{
1041cdf0e10cSrcweir	my ($itemsarrayref) = @_;
1042cdf0e10cSrcweir
1043cdf0e10cSrcweir	my $userdir = "";
1044cdf0e10cSrcweir	if ( $allvariableshashref->{'LOCALUSERDIR'} ) { $userdir = $allvariableshashref->{'LOCALUSERDIR'}; }
1045cdf0e10cSrcweir	else { $userdir = $installer::globals::simpledefaultuserdir; }
1046cdf0e10cSrcweir
1047cdf0e10cSrcweir	if ( $userdir ne "" )
1048cdf0e10cSrcweir	{
1049cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1050cdf0e10cSrcweir		{
1051cdf0e10cSrcweir			my $oneitem = ${$itemsarrayref}[$i];
1052cdf0e10cSrcweir			$oneitem->{'Value'} =~ s/\$SYSUSERCONFIG/$userdir/;
1053cdf0e10cSrcweir		}
1054cdf0e10cSrcweir	}
1055cdf0e10cSrcweir}
1056cdf0e10cSrcweir
1057cdf0e10cSrcweir#####################################################################################
1058cdf0e10cSrcweir# Files and ConfigurationItems are not included for all languages.
1059cdf0e10cSrcweir# For instance asian fonts. These can be removed, if no "Name" is found.
1060cdf0e10cSrcweir# ConfigurationItems are not always defined in the linguistic configuration file.
1061cdf0e10cSrcweir# The "Key" cannot be found for them.
1062cdf0e10cSrcweir#####################################################################################
1063cdf0e10cSrcweir
1064cdf0e10cSrcweirsub remove_non_existent_languages_in_productlists
1065cdf0e10cSrcweir{
1066cdf0e10cSrcweir	my ($itemsarrayref, $languagestringref, $searchkey, $itemtype) = @_;
1067cdf0e10cSrcweir
1068cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::remove_non_existent_languages_in_productlists : $#{$itemsarrayref} : $$languagestringref : $searchkey : $itemtype"); }
1069cdf0e10cSrcweir
1070cdf0e10cSrcweir	# Removing of all non existent files, for instance asian fonts
1071cdf0e10cSrcweir
1072cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Removing for this language $$languagestringref:");
1073cdf0e10cSrcweir
1074cdf0e10cSrcweir	my @allexistentitems = ();
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir	my $infoline;
1077cdf0e10cSrcweir
1078cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1079cdf0e10cSrcweir	{
1080cdf0e10cSrcweir		my $oneitem = ${$itemsarrayref}[$i];
1081cdf0e10cSrcweir		my $oneitemname = "";		# $searchkey is "Name" for files and "Key" for ConfigurationItems
1082cdf0e10cSrcweir
1083cdf0e10cSrcweir		if ( $oneitem->{$searchkey} ) { $oneitemname = $oneitem->{$searchkey} }
1084cdf0e10cSrcweir
1085cdf0e10cSrcweir		my $itemtoberemoved = 0;
1086cdf0e10cSrcweir
1087cdf0e10cSrcweir		if ($oneitemname eq "") 					# for instance asian font in english installation set
1088cdf0e10cSrcweir		{
1089cdf0e10cSrcweir			$itemtoberemoved = 1;
1090cdf0e10cSrcweir		}
1091cdf0e10cSrcweir
1092cdf0e10cSrcweir		if ($itemtoberemoved)
1093cdf0e10cSrcweir		{
1094cdf0e10cSrcweir			$infoline = "WARNING: Language $$languagestringref: No $itemtype packed for $oneitem->{'gid'}!\n";
1095cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1096cdf0e10cSrcweir		}
1097cdf0e10cSrcweir		else
1098cdf0e10cSrcweir		{
1099cdf0e10cSrcweir			push(@allexistentitems, $oneitem);
1100cdf0e10cSrcweir		}
1101cdf0e10cSrcweir	}
1102cdf0e10cSrcweir
1103cdf0e10cSrcweir	$infoline = "\n";
1104cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
1105cdf0e10cSrcweir
1106cdf0e10cSrcweir	return \@allexistentitems;
1107cdf0e10cSrcweir}
1108cdf0e10cSrcweir
1109cdf0e10cSrcweir########################################################################
1110cdf0e10cSrcweir# Input is the directory gid, output the "HostName" of the directory
1111cdf0e10cSrcweir########################################################################
1112cdf0e10cSrcweir
1113cdf0e10cSrcweirsub get_Directoryname_From_Directorygid
1114cdf0e10cSrcweir{
1115cdf0e10cSrcweir	my ($dirsarrayref ,$searchgid, $onelanguage, $oneitemgid) = @_;
1116cdf0e10cSrcweir
1117cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::get_Directoryname_From_Directorygid : $#{$dirsarrayref} : $searchgid : $onelanguage"); }
1118cdf0e10cSrcweir
1119cdf0e10cSrcweir	my $directoryname = "";
1120cdf0e10cSrcweir	my $onedirectory;
1121cdf0e10cSrcweir	my $foundgid = 0;
1122cdf0e10cSrcweir
1123cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$dirsarrayref}; $i++ )
1124cdf0e10cSrcweir	{
1125cdf0e10cSrcweir		$onedirectory = ${$dirsarrayref}[$i];
1126cdf0e10cSrcweir		my $directorygid = $onedirectory->{'gid'};
1127cdf0e10cSrcweir
1128cdf0e10cSrcweir		if ($directorygid eq $searchgid)
1129cdf0e10cSrcweir		{
1130cdf0e10cSrcweir			$foundgid = 1;
1131cdf0e10cSrcweir			last;
1132cdf0e10cSrcweir		}
1133cdf0e10cSrcweir	}
1134cdf0e10cSrcweir
1135cdf0e10cSrcweir	if (!($foundgid))
1136cdf0e10cSrcweir	{
1137cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: Gid $searchgid not defined in $installer::globals::setupscriptname", "get_Directoryname_From_Directorygid");
1138cdf0e10cSrcweir	}
1139cdf0e10cSrcweir
1140cdf0e10cSrcweir	if ( ! ( $onedirectory->{'ismultilingual'} ))	# the directory is not language dependent
1141cdf0e10cSrcweir	{
1142cdf0e10cSrcweir 		$directoryname = $onedirectory->{'HostName'};
1143cdf0e10cSrcweir	}
1144cdf0e10cSrcweir	else
1145cdf0e10cSrcweir	{
1146cdf0e10cSrcweir		$directoryname = $onedirectory->{"HostName ($onelanguage)"};
1147cdf0e10cSrcweir	}
1148cdf0e10cSrcweir
1149cdf0e10cSrcweir	# gid_Dir_Template_Wizard_Letter is defined as language dependent directory, but the file gid_Dir_Template_Wizard_Letter
1150cdf0e10cSrcweir	# is not language dependent. Therefore $onelanguage is not defined. But which language is the correct language for the
1151cdf0e10cSrcweir	# directory?
1152cdf0e10cSrcweir	# Perhaps better solution: In scp it must be forbidden to have a language independent file in a language dependent directory.
1153cdf0e10cSrcweir
1154cdf0e10cSrcweir	if (( ! $directoryname ) && ( $onelanguage eq "" ))
1155cdf0e10cSrcweir	{
1156cdf0e10cSrcweir		installer::exiter::exit_program("ERROR (in scp): Directory $searchgid is language dependent, but not $oneitemgid inside this directory", "get_Directoryname_From_Directorygid");
1157cdf0e10cSrcweir	}
1158cdf0e10cSrcweir
1159cdf0e10cSrcweir	return \$directoryname;
1160cdf0e10cSrcweir}
1161cdf0e10cSrcweir
1162cdf0e10cSrcweir##################################################################
1163010ec03aSHerbert Dürr# Getting destination directory for links, files and profiles
1164cdf0e10cSrcweir##################################################################
1165cdf0e10cSrcweir
1166cdf0e10cSrcweirsub get_Destination_Directory_For_Item_From_Directorylist		# this is used for Files, Profiles and Links
1167cdf0e10cSrcweir{
1168cdf0e10cSrcweir	my ($itemarrayref, $dirsarrayref) = @_;
1169cdf0e10cSrcweir
1170cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::get_Destination_Directory_For_Item_From_Directorylist : $#{$itemarrayref} : $#{$dirsarrayref}"); }
1171cdf0e10cSrcweir
1172cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$itemarrayref}; $i++ )
1173cdf0e10cSrcweir	{
1174cdf0e10cSrcweir		my $oneitem = ${$itemarrayref}[$i];
1175cdf0e10cSrcweir		my $oneitemgid = $oneitem->{'gid'};
1176cdf0e10cSrcweir		my $directorygid = $oneitem->{'Dir'};		# for instance gid_Dir_Program
1177cdf0e10cSrcweir		my $netdirectorygid = "";
1178cdf0e10cSrcweir		my $onelanguage = $oneitem->{'specificlanguage'};
1179cdf0e10cSrcweir		my $ispredefinedprogdir = 0;
1180cdf0e10cSrcweir		my $ispredefinedconfigdir = 0;
1181cdf0e10cSrcweir
1182cdf0e10cSrcweir		my $oneitemname = $oneitem->{'Name'};
1183cdf0e10cSrcweir
1184cdf0e10cSrcweir		if ( $oneitem->{'NetDir'} ) { $netdirectorygid = $oneitem->{'NetDir'}; }
1185cdf0e10cSrcweir
1186cdf0e10cSrcweir		installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$oneitemname);	# making /registry/schema/org/openoffice/VCL.xcs to VCL.xcs
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir		my $searchdirgid;
1189cdf0e10cSrcweir
1190cdf0e10cSrcweir		if ( $netdirectorygid eq "" )	# if NetDir is defined, it is privileged
1191cdf0e10cSrcweir		{
1192cdf0e10cSrcweir			$searchdirgid = $directorygid
1193cdf0e10cSrcweir		}
1194cdf0e10cSrcweir		else
1195cdf0e10cSrcweir		{
1196cdf0e10cSrcweir			$searchdirgid = $netdirectorygid
1197cdf0e10cSrcweir		}
1198cdf0e10cSrcweir
1199cdf0e10cSrcweir		if ($searchdirgid =~ /PREDEFINED_PROGDIR/)	# the root directory is not defined in setup script
1200cdf0e10cSrcweir		{
1201cdf0e10cSrcweir			$ispredefinedprogdir = 1;
1202cdf0e10cSrcweir		}
1203cdf0e10cSrcweir
1204cdf0e10cSrcweir		if ($searchdirgid =~ /PREDEFINED_CONFIGDIR/)	# the root directory is not defined in setup script
1205cdf0e10cSrcweir		{
1206cdf0e10cSrcweir			$ispredefinedconfigdir = 1;
1207cdf0e10cSrcweir		}
1208cdf0e10cSrcweir
1209cdf0e10cSrcweir		my $destfilename;
1210cdf0e10cSrcweir
1211cdf0e10cSrcweir		if ((!( $ispredefinedprogdir )) && (!( $ispredefinedconfigdir )))
1212cdf0e10cSrcweir		{
1213cdf0e10cSrcweir			my $directorynameref = get_Directoryname_From_Directorygid($dirsarrayref, $searchdirgid, $onelanguage, $oneitemgid);
1214cdf0e10cSrcweir			$destfilename = $$directorynameref . $installer::globals::separator . $oneitemname;
1215cdf0e10cSrcweir		}
1216cdf0e10cSrcweir		else
1217cdf0e10cSrcweir		{
1218cdf0e10cSrcweir			$destfilename = $oneitemname;
1219cdf0e10cSrcweir		}
1220cdf0e10cSrcweir
1221cdf0e10cSrcweir		$oneitem->{'destination'} = $destfilename;
1222cdf0e10cSrcweir	}
1223cdf0e10cSrcweir}
1224cdf0e10cSrcweir
1225cdf0e10cSrcweir##########################################################################
1226cdf0e10cSrcweir# Searching a file in a list of pathes
1227cdf0e10cSrcweir##########################################################################
1228cdf0e10cSrcweir
1229cdf0e10cSrcweirsub get_sourcepath_from_filename_and_includepath_classic
1230cdf0e10cSrcweir{
1231cdf0e10cSrcweir	my ($searchfilenameref, $includepatharrayref, $write_logfile) = @_;
1232cdf0e10cSrcweir
1233cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::get_sourcepath_from_filename_and_includepath_classic : $$searchfilenameref : $#{$includepatharrayref} : $write_logfile"); }
1234cdf0e10cSrcweir
1235cdf0e10cSrcweir	my ($onefile, $includepath, $infoline);
1236cdf0e10cSrcweir
1237cdf0e10cSrcweir	my $foundsourcefile = 0;
1238cdf0e10cSrcweir
1239cdf0e10cSrcweir	for ( my $j = 0; $j <= $#{$includepatharrayref}; $j++ )
1240cdf0e10cSrcweir	{
1241cdf0e10cSrcweir		$includepath = ${$includepatharrayref}[$j];
1242cdf0e10cSrcweir		installer::remover::remove_leading_and_ending_whitespaces(\$includepath);
1243cdf0e10cSrcweir
1244cdf0e10cSrcweir		$onefile = $includepath . $installer::globals::separator . $$searchfilenameref;
1245cdf0e10cSrcweir
1246cdf0e10cSrcweir		if ( -f $onefile )
1247cdf0e10cSrcweir		{
1248cdf0e10cSrcweir			$foundsourcefile = 1;
1249cdf0e10cSrcweir			last;
1250cdf0e10cSrcweir		}
1251cdf0e10cSrcweir	}
1252cdf0e10cSrcweir
1253cdf0e10cSrcweir	if (!($foundsourcefile))
1254cdf0e10cSrcweir	{
1255cdf0e10cSrcweir		$onefile = "";	# the sourcepath has to be empty
1256cdf0e10cSrcweir		if ( $write_logfile)
1257cdf0e10cSrcweir		{
1258cdf0e10cSrcweir			if ( $ENV{'DEFAULT_TO_ENGLISH_FOR_PACKING'} )
1259cdf0e10cSrcweir			{
1260cdf0e10cSrcweir				$infoline = "WARNING: Source for $$searchfilenameref not found!\n";	 # Important message in log file
1261cdf0e10cSrcweir			}
1262cdf0e10cSrcweir			else
1263cdf0e10cSrcweir			{
1264cdf0e10cSrcweir				$infoline = "ERROR: Source for $$searchfilenameref not found!\n";	 # Important message in log file
1265cdf0e10cSrcweir			}
1266cdf0e10cSrcweir
1267cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1268cdf0e10cSrcweir		}
1269cdf0e10cSrcweir	}
1270cdf0e10cSrcweir	else
1271cdf0e10cSrcweir	{
1272cdf0e10cSrcweir		if ( $write_logfile)
1273cdf0e10cSrcweir		{
1274cdf0e10cSrcweir			$infoline = "SUCCESS: Source for $$searchfilenameref: $onefile\n";
1275cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1276cdf0e10cSrcweir		}
1277cdf0e10cSrcweir	}
1278cdf0e10cSrcweir
1279cdf0e10cSrcweir	return \$onefile;
1280cdf0e10cSrcweir}
1281cdf0e10cSrcweir
1282cdf0e10cSrcweir##########################################################################
1283cdf0e10cSrcweir# Input is one file name, output the complete absolute path of this file
1284cdf0e10cSrcweir##########################################################################
1285cdf0e10cSrcweir
1286cdf0e10cSrcweirsub get_sourcepath_from_filename_and_includepath
1287cdf0e10cSrcweir{
1288cdf0e10cSrcweir	my ($searchfilenameref, $unused, $write_logfile) = @_;
1289cdf0e10cSrcweir
1290cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::get_sourcepath_from_filename_and_includepath : $$searchfilenameref : $#{$includepatharrayref} : $write_logfile"); }
1291cdf0e10cSrcweir
1292cdf0e10cSrcweir	my ($onefile, $includepath, $infoline);
1293cdf0e10cSrcweir
1294cdf0e10cSrcweir	my $foundsourcefile = 0;
1295cdf0e10cSrcweir	my $foundnewname = 0;
1296cdf0e10cSrcweir
1297cdf0e10cSrcweir	for ( my $j = 0; $j <= $#installer::globals::allincludepathes; $j++ )
1298cdf0e10cSrcweir	{
1299cdf0e10cSrcweir		my $allfiles = $installer::globals::allincludepathes[$j];
1300cdf0e10cSrcweir
1301cdf0e10cSrcweir		if ( exists( $allfiles->{$$searchfilenameref} ))
1302cdf0e10cSrcweir		{
1303cdf0e10cSrcweir			$onefile = $allfiles->{'includepath'} . $installer::globals::separator . $$searchfilenameref;
1304cdf0e10cSrcweir			$foundsourcefile = 1;
1305cdf0e10cSrcweir			last;
1306cdf0e10cSrcweir		}
1307cdf0e10cSrcweir	}
1308cdf0e10cSrcweir
1309cdf0e10cSrcweir	if (!($foundsourcefile))	# testing with lowercase filename
1310cdf0e10cSrcweir	{
1311cdf0e10cSrcweir		# Attention: README01.html is copied for Windows to readme01.html, not case sensitive
1312cdf0e10cSrcweir
1313cdf0e10cSrcweir		for ( my $j = 0; $j <= $#installer::globals::allincludepathes; $j++ )
1314cdf0e10cSrcweir		{
1315cdf0e10cSrcweir			my $allfiles = $installer::globals::allincludepathes[$j];
1316cdf0e10cSrcweir
1317cdf0e10cSrcweir			my $newfilename = $$searchfilenameref;
1318cdf0e10cSrcweir			$newfilename =~ s/readme/README/;		# special handling for readme files
1319cdf0e10cSrcweir			$newfilename =~ s/license/LICENSE/;		# special handling for license files
1320cdf0e10cSrcweir
1321cdf0e10cSrcweir			if ( exists( $allfiles->{$newfilename} ))
1322cdf0e10cSrcweir			{
1323cdf0e10cSrcweir				$onefile = $allfiles->{'includepath'} . $installer::globals::separator . $newfilename;
1324cdf0e10cSrcweir				$foundsourcefile = 1;
1325cdf0e10cSrcweir				$foundnewname = 1;
1326cdf0e10cSrcweir				last;
1327cdf0e10cSrcweir			}
1328cdf0e10cSrcweir		}
1329cdf0e10cSrcweir	}
1330cdf0e10cSrcweir
1331cdf0e10cSrcweir	if (!($foundsourcefile))
1332cdf0e10cSrcweir	{
1333cdf0e10cSrcweir		$onefile = "";	# the sourcepath has to be empty
1334cdf0e10cSrcweir		if ( $write_logfile)
1335cdf0e10cSrcweir		{
1336cdf0e10cSrcweir			if ( $ENV{'DEFAULT_TO_ENGLISH_FOR_PACKING'} )
1337cdf0e10cSrcweir			{
1338cdf0e10cSrcweir				$infoline = "WARNING: Source for $$searchfilenameref not found!\n";	 # Important message in log file
1339cdf0e10cSrcweir			}
1340cdf0e10cSrcweir			else
1341cdf0e10cSrcweir			{
1342cdf0e10cSrcweir				$infoline = "ERROR: Source for $$searchfilenameref not found!\n";	 # Important message in log file
1343cdf0e10cSrcweir			}
1344cdf0e10cSrcweir
1345cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1346cdf0e10cSrcweir		}
1347cdf0e10cSrcweir	}
1348cdf0e10cSrcweir	else
1349cdf0e10cSrcweir	{
1350cdf0e10cSrcweir		if ( $write_logfile)
1351cdf0e10cSrcweir		{
1352cdf0e10cSrcweir			if (!($foundnewname))
1353cdf0e10cSrcweir			{
1354cdf0e10cSrcweir				$infoline = "SUCCESS: Source for $$searchfilenameref: $onefile\n";
1355cdf0e10cSrcweir			}
1356cdf0e10cSrcweir			else
1357cdf0e10cSrcweir			{
1358cdf0e10cSrcweir				$infoline = "SUCCESS/WARNING: Special handling for $$searchfilenameref: $onefile\n";
1359cdf0e10cSrcweir			}
1360cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1361cdf0e10cSrcweir		}
1362cdf0e10cSrcweir	}
1363cdf0e10cSrcweir
1364cdf0e10cSrcweir	return \$onefile;
1365cdf0e10cSrcweir}
1366cdf0e10cSrcweir
1367cdf0e10cSrcweir##############################################################
1368cdf0e10cSrcweir# Determining, whether a specified directory is language
1369cdf0e10cSrcweir# dependent
1370cdf0e10cSrcweir##############################################################
1371cdf0e10cSrcweir
1372cdf0e10cSrcweirsub determine_directory_language_dependency
1373cdf0e10cSrcweir{
1374cdf0e10cSrcweir	my($directorygid, $dirsref) = @_;
1375cdf0e10cSrcweir
1376cdf0e10cSrcweir	my $is_multilingual = 0;
1377cdf0e10cSrcweir
1378cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
1379cdf0e10cSrcweir	{
1380cdf0e10cSrcweir		my $onedir = ${$dirsref}[$i];
1381cdf0e10cSrcweir		my $gid = $onedir->{'gid'};
1382cdf0e10cSrcweir
1383cdf0e10cSrcweir		if ( $gid eq $directorygid )
1384cdf0e10cSrcweir		{
1385cdf0e10cSrcweir			$is_multilingual = $onedir->{'ismultilingual'};
1386cdf0e10cSrcweir			last;
1387cdf0e10cSrcweir		}
1388cdf0e10cSrcweir	}
1389cdf0e10cSrcweir
1390cdf0e10cSrcweir	return $is_multilingual;
1391cdf0e10cSrcweir}
1392cdf0e10cSrcweir
1393cdf0e10cSrcweir##############################################################
1394cdf0e10cSrcweir# Getting all source pathes for all files to be packed
1395cdf0e10cSrcweir# $item can be "Files" or "ScpActions"
1396cdf0e10cSrcweir##############################################################
1397cdf0e10cSrcweir
1398cdf0e10cSrcweirsub get_Source_Directory_For_Files_From_Includepathlist
1399cdf0e10cSrcweir{
1400cdf0e10cSrcweir	my ($filesarrayref, $includepatharrayref, $dirsref, $item) = @_;
1401cdf0e10cSrcweir
1402cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::get_Source_Directory_For_Files_From_Includepathlist : $#{$filesarrayref} : $#{$includepatharrayref} : $item"); }
1403cdf0e10cSrcweir
1404cdf0e10cSrcweir	installer::logger::include_header_into_logfile("$item:");
1405cdf0e10cSrcweir
1406cdf0e10cSrcweir	my $infoline = "";
1407cdf0e10cSrcweir
1408cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1409cdf0e10cSrcweir	{
1410cdf0e10cSrcweir		my $onefile = ${$filesarrayref}[$i];
1411cdf0e10cSrcweir		my $onelanguage = $onefile->{'specificlanguage'};
1412cdf0e10cSrcweir
1413cdf0e10cSrcweir		if ( ! $onefile->{'Name'} ) { installer::exiter::exit_program("ERROR: $item without name ! GID: $onefile->{'gid'} ! Language: $onelanguage", "get_Source_Directory_For_Files_From_Includepathlist"); }
1414cdf0e10cSrcweir
1415cdf0e10cSrcweir		my $onefilename = $onefile->{'Name'};
1416cdf0e10cSrcweir		if ( $item eq "ScpActions" ) { $onefilename =~ s/\//$installer::globals::separator/g; }
1417cdf0e10cSrcweir		$onefilename =~ s/^\s*\Q$installer::globals::separator\E//;		# filename begins with a slash, for instance /registry/schema/org/openoffice/VCL.xcs
1418cdf0e10cSrcweir
1419cdf0e10cSrcweir		my $styles = "";
1420cdf0e10cSrcweir		my $file_can_miss = 0;
1421cdf0e10cSrcweir		if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1422cdf0e10cSrcweir		if ( $styles =~ /\bFILE_CAN_MISS\b/ ) { $file_can_miss = 1; }
1423cdf0e10cSrcweir
1424cdf0e10cSrcweir		if (( $installer::globals::languagepack ) && ( ! $onefile->{'ismultilingual'} ) && ( ! ( $styles =~ /\bFORCELANGUAGEPACK\b/ ))) { $file_can_miss = 1; }
1425cdf0e10cSrcweir
1426cdf0e10cSrcweir		my $sourcepathref = "";
1427cdf0e10cSrcweir
1428cdf0e10cSrcweir		if ( $file_can_miss ) { $sourcepathref = get_sourcepath_from_filename_and_includepath(\$onefilename, $includepatharrayref, 0); }
1429cdf0e10cSrcweir		else { $sourcepathref = get_sourcepath_from_filename_and_includepath(\$onefilename, $includepatharrayref, 1); }
1430cdf0e10cSrcweir
1431cdf0e10cSrcweir		$onefile->{'sourcepath'} = $$sourcepathref;	# This $$sourcepathref is empty, if no source was found
1432cdf0e10cSrcweir
1433cdf0e10cSrcweir		# defaulting to english for multilingual files if DEFAULT_TO_ENGLISH_FOR_PACKING is set
1434cdf0e10cSrcweir
1435cdf0e10cSrcweir		if ( $ENV{'DEFAULT_TO_ENGLISH_FOR_PACKING'} )
1436cdf0e10cSrcweir		{
1437cdf0e10cSrcweir			if (( ! $onefile->{'sourcepath'} ) && ( $onefile->{'ismultilingual'} ))
1438cdf0e10cSrcweir			{
1439cdf0e10cSrcweir				my $oldname = $onefile->{'Name'};
1440cdf0e10cSrcweir				my $oldlanguage = $onefile->{'specificlanguage'};
1441cdf0e10cSrcweir				my $newlanguage = "en-US";
1442cdf0e10cSrcweir				# $onefile->{'Name'} =~ s/$oldlanguage\./$newlanguage\./;	# Example: tplwizfax_it.zip -> tplwizfax_en-US.zip
1443cdf0e10cSrcweir				$onefilename = $onefile->{'Name'};
1444cdf0e10cSrcweir				$onefilename =~ s/$oldlanguage\./$newlanguage\./;	# Example: tplwizfax_it.zip -> tplwizfax_en-US.zip
1445cdf0e10cSrcweir				$onefilename =~ s/^\s*\Q$installer::globals::separator\E//;		# filename begins with a slash, for instance /registry/schema/org/openoffice/VCL.xcs
1446cdf0e10cSrcweir				$sourcepathref = get_sourcepath_from_filename_and_includepath(\$onefilename, $includepatharrayref, 1);
1447cdf0e10cSrcweir				$onefile->{'sourcepath'} = $$sourcepathref;						# This $$sourcepathref is empty, if no source was found
1448cdf0e10cSrcweir
1449cdf0e10cSrcweir				if ($onefile->{'sourcepath'})	# defaulting to english was successful
1450cdf0e10cSrcweir				{
1451cdf0e10cSrcweir					$infoline = "WARNING: Using $onefilename instead of $oldname\n";
1452cdf0e10cSrcweir					push( @installer::globals::logfileinfo, $infoline);
1453cdf0e10cSrcweir					print "    $infoline";
1454cdf0e10cSrcweir					# if ( $onefile->{'destination'} ) { $onefile->{'destination'} =~ s/\Q$oldname\E/$onefile->{'Name'}/; }
1455cdf0e10cSrcweir
1456cdf0e10cSrcweir					# If the directory, in which the new file is installed, is not language dependent,
1457cdf0e10cSrcweir					# the filename has to be changed to avoid installation conflicts
1458cdf0e10cSrcweir					# No mechanism for resource files!
1459cdf0e10cSrcweir					# -> implementing for the content of ARCHIVE files
1460cdf0e10cSrcweir
1461cdf0e10cSrcweir					if ( $onefile->{'Styles'} =~ /\bARCHIVE\b/ )
1462cdf0e10cSrcweir					{
1463cdf0e10cSrcweir						my $directorygid = $onefile->{'Dir'};
1464cdf0e10cSrcweir						my $islanguagedependent = determine_directory_language_dependency($directorygid, $dirsref);
1465cdf0e10cSrcweir
1466cdf0e10cSrcweir						if ( ! $islanguagedependent )
1467cdf0e10cSrcweir						{
1468cdf0e10cSrcweir							$onefile->{'Styles'} =~ s/\bARCHIVE\b/ARCHIVE, RENAME_TO_LANGUAGE/;	# Setting new flag RENAME_TO_LANGUAGE
1469cdf0e10cSrcweir							$infoline = "Setting flag RENAME_TO_LANGUAGE: File $onefile->{'Name'} in directory: $directorygid\n";
1470cdf0e10cSrcweir							push( @installer::globals::logfileinfo, $infoline);
1471cdf0e10cSrcweir						}
1472cdf0e10cSrcweir					}
1473cdf0e10cSrcweir				}
1474cdf0e10cSrcweir				else
1475cdf0e10cSrcweir				{
1476cdf0e10cSrcweir					$infoline = "WARNING: Using $onefile->{'Name'} instead of $oldname was not successful\n";
1477cdf0e10cSrcweir					push( @installer::globals::logfileinfo, $infoline);
1478cdf0e10cSrcweir					$onefile->{'Name'} = $oldname;	# Switching back to old file name
1479cdf0e10cSrcweir				}
1480cdf0e10cSrcweir			}
1481cdf0e10cSrcweir		}
1482cdf0e10cSrcweir	}
1483cdf0e10cSrcweir
1484cdf0e10cSrcweir	$infoline = "\n";	# empty line after listing of all files
1485cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
1486cdf0e10cSrcweir}
1487cdf0e10cSrcweir
1488cdf0e10cSrcweir#################################################################################
1489cdf0e10cSrcweir# Removing files, that shall not be included into languagepacks
1490cdf0e10cSrcweir# (because of rpm conflicts)
1491cdf0e10cSrcweir#################################################################################
1492cdf0e10cSrcweir
1493cdf0e10cSrcweirsub remove_Files_For_Languagepacks
1494cdf0e10cSrcweir{
1495cdf0e10cSrcweir	my ($itemsarrayref) = @_;
1496cdf0e10cSrcweir
1497cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::remove_Files_For_Languagepacks : $#{$filesarrayref}"); }
1498cdf0e10cSrcweir
1499cdf0e10cSrcweir	my $infoline;
1500cdf0e10cSrcweir
1501cdf0e10cSrcweir	my @newitemsarray = ();
1502cdf0e10cSrcweir
1503cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1504cdf0e10cSrcweir	{
1505cdf0e10cSrcweir		my $oneitem = ${$itemsarrayref}[$i];
1506cdf0e10cSrcweir		my $gid = $oneitem->{'gid'};
1507cdf0e10cSrcweir
1508cdf0e10cSrcweir		# scp Todo: Remove asap after removal of old setup
1509cdf0e10cSrcweir
1510cdf0e10cSrcweir		if (( $gid eq "gid_File_Extra_Fontunxpsprint" ) ||
1511cdf0e10cSrcweir			( $gid eq "gid_File_Extra_Migration_Lang" ))
1512cdf0e10cSrcweir		{
1513cdf0e10cSrcweir			$infoline = "ATTENTION: Removing item $oneitem->{'gid'} from the installation set.\n";
1514cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1515cdf0e10cSrcweir
1516cdf0e10cSrcweir			next;
1517cdf0e10cSrcweir		}
1518cdf0e10cSrcweir
1519cdf0e10cSrcweir		push(@newitemsarray, $oneitem);
1520cdf0e10cSrcweir	}
1521cdf0e10cSrcweir
1522cdf0e10cSrcweir	return \@newitemsarray;
1523cdf0e10cSrcweir}
1524cdf0e10cSrcweir
1525cdf0e10cSrcweir#################################################################################
1526cdf0e10cSrcweir# Files, whose source directory is not found, are removed now (this is an ERROR)
1527cdf0e10cSrcweir#################################################################################
1528cdf0e10cSrcweir
1529cdf0e10cSrcweirsub remove_Files_Without_Sourcedirectory
1530cdf0e10cSrcweir{
1531cdf0e10cSrcweir	my ($filesarrayref) = @_;
1532cdf0e10cSrcweir
1533cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::remove_Files_Without_Sourcedirectory : $#{$filesarrayref}"); }
1534cdf0e10cSrcweir
1535cdf0e10cSrcweir	my $infoline;
1536cdf0e10cSrcweir
1537cdf0e10cSrcweir	my $error_occured = 0;
1538cdf0e10cSrcweir	my @missingfiles = ();
1539cdf0e10cSrcweir	push(@missingfiles, "ERROR: The following files could not be found: \n");
1540cdf0e10cSrcweir
1541cdf0e10cSrcweir	my @newfilesarray = ();
1542cdf0e10cSrcweir
1543cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1544cdf0e10cSrcweir	{
1545cdf0e10cSrcweir		my $onefile = ${$filesarrayref}[$i];
1546cdf0e10cSrcweir		my $sourcepath = $onefile->{'sourcepath'};
1547cdf0e10cSrcweir
1548cdf0e10cSrcweir		if ($sourcepath eq "")
1549cdf0e10cSrcweir		{
1550cdf0e10cSrcweir			my $styles = $onefile->{'Styles'};
1551cdf0e10cSrcweir			my $filename = $onefile->{'Name'};
1552cdf0e10cSrcweir
1553cdf0e10cSrcweir			if ( ! $installer::globals::languagepack )
1554cdf0e10cSrcweir			{
1555010ec03aSHerbert Dürr				$infoline = "ERROR: No sourcepath -> Removing file $filename from file list.\n";
1556cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
1557cdf0e10cSrcweir
1558cdf0e10cSrcweir				push(@missingfiles, "ERROR: File not found: $filename\n");
1559cdf0e10cSrcweir				$error_occured = 1;
1560cdf0e10cSrcweir
1561cdf0e10cSrcweir				next;	# removing this file from list, if sourcepath is empty
1562cdf0e10cSrcweir			}
1563cdf0e10cSrcweir			else # special case for language packs
1564cdf0e10cSrcweir			{
1565cdf0e10cSrcweir				if (( $onefile->{'ismultilingual'} ) || ( $styles =~ /\bFORCELANGUAGEPACK\b/ ))
1566cdf0e10cSrcweir				{
1567cdf0e10cSrcweir					$infoline = "ERROR: Removing file $filename from file list.\n";
1568cdf0e10cSrcweir					push( @installer::globals::logfileinfo, $infoline);
1569cdf0e10cSrcweir
1570cdf0e10cSrcweir					push(@missingfiles, "ERROR: File not found: $filename\n");
1571cdf0e10cSrcweir					$error_occured = 1;
1572cdf0e10cSrcweir
1573cdf0e10cSrcweir					next;	# removing this file from list, if sourcepath is empty
1574cdf0e10cSrcweir				}
1575cdf0e10cSrcweir				else
1576cdf0e10cSrcweir				{
1577cdf0e10cSrcweir					$infoline = "INFO: Removing file $filename from file list. It is not language dependent.\n";
1578cdf0e10cSrcweir					push( @installer::globals::logfileinfo, $infoline);
1579cdf0e10cSrcweir					$infoline = "INFO: It is not language dependent and can be ignored in language packs.\n";
1580cdf0e10cSrcweir					push( @installer::globals::logfileinfo, $infoline);
1581cdf0e10cSrcweir
1582cdf0e10cSrcweir					next;	# removing this file from list, if sourcepath is empty
1583cdf0e10cSrcweir				}
1584cdf0e10cSrcweir			}
1585cdf0e10cSrcweir		}
1586cdf0e10cSrcweir
1587cdf0e10cSrcweir		push(@newfilesarray, $onefile);
1588cdf0e10cSrcweir	}
1589cdf0e10cSrcweir
1590cdf0e10cSrcweir	$infoline = "\n";
1591cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
1592cdf0e10cSrcweir
1593cdf0e10cSrcweir	if ( $error_occured )
1594cdf0e10cSrcweir	{
1595cdf0e10cSrcweir		for ( my $i = 0; $i <= $#missingfiles; $i++ ) { print "$missingfiles[$i]"; }
1596cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: Missing files", "remove_Files_Without_Sourcedirectory");
1597cdf0e10cSrcweir	}
1598cdf0e10cSrcweir
1599cdf0e10cSrcweir	return \@newfilesarray;
1600cdf0e10cSrcweir}
1601cdf0e10cSrcweir
1602cdf0e10cSrcweir############################################################################
1603cdf0e10cSrcweir# License and Readme files in the default language have to be installed
1604cdf0e10cSrcweir# in the directory with flag OFFICEDIRECTORY. If this is not defined
1605cdf0e10cSrcweir# they have to be installed in the installation root.
1606cdf0e10cSrcweir############################################################################
1607cdf0e10cSrcweir
1608cdf0e10cSrcweirsub get_office_directory_gid_and_hostname
1609cdf0e10cSrcweir{
1610cdf0e10cSrcweir	my ($dirsarrayref) = @_;
1611cdf0e10cSrcweir
1612cdf0e10cSrcweir	my $foundofficedir = 0;
1613cdf0e10cSrcweir	my $gid = "";
1614cdf0e10cSrcweir	my $hostname = "";
1615cdf0e10cSrcweir
1616cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$dirsarrayref}; $i++ )
1617cdf0e10cSrcweir	{
1618cdf0e10cSrcweir		my $onedir = ${$dirsarrayref}[$i];
1619cdf0e10cSrcweir		if ( $onedir->{'Styles'} )
1620cdf0e10cSrcweir		{
1621cdf0e10cSrcweir			my $styles = $onedir->{'Styles'};
1622cdf0e10cSrcweir
1623cdf0e10cSrcweir			if ( $styles =~ /\bOFFICEDIRECTORY\b/ )
1624cdf0e10cSrcweir			{
1625cdf0e10cSrcweir				$foundofficedir = 1;
1626cdf0e10cSrcweir				$gid = $onedir->{'gid'};
1627cdf0e10cSrcweir				$hostname = $onedir->{'HostName'};
1628cdf0e10cSrcweir				last;
1629cdf0e10cSrcweir			}
1630cdf0e10cSrcweir		}
1631cdf0e10cSrcweir	}
1632cdf0e10cSrcweir
1633cdf0e10cSrcweir	return ($foundofficedir, $gid, $hostname);
1634cdf0e10cSrcweir}
1635cdf0e10cSrcweir
1636cdf0e10cSrcweir############################################################################
1637cdf0e10cSrcweir# License and Readme files in the default language have to be installed
1638cdf0e10cSrcweir# in the installation root (next to the program dir). This is in scp
1639cdf0e10cSrcweir# project done by a post install basic script
1640cdf0e10cSrcweir############################################################################
1641cdf0e10cSrcweir
1642cdf0e10cSrcweirsub add_License_Files_into_Installdir
1643cdf0e10cSrcweir{
1644cdf0e10cSrcweir	my ($filesarrayref, $dirsarrayref, $languagesarrayref) = @_;
1645cdf0e10cSrcweir
1646cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::add_License_Files_into_Installdir : $#{$filesarrayref} : $#{$languagesarrayref}"); }
1647cdf0e10cSrcweir
1648cdf0e10cSrcweir	my $infoline;
1649cdf0e10cSrcweir
1650cdf0e10cSrcweir	my @newfilesarray = ();
1651cdf0e10cSrcweir
1652cdf0e10cSrcweir	my $defaultlanguage = installer::languages::get_default_language($languagesarrayref);
1653cdf0e10cSrcweir
1654cdf0e10cSrcweir	my ($foundofficedir, $officedirectorygid, $officedirectoryhostname) = get_office_directory_gid_and_hostname($dirsarrayref);
1655cdf0e10cSrcweir
1656cdf0e10cSrcweir	# copy all files from directory share/readme, that contain the default language in their name
1657cdf0e10cSrcweir	# without default language into the installation root. This makes the settings of the correct
1658cdf0e10cSrcweir	# file names superfluous. On the other hand this requires a dependency to the directory
1659cdf0e10cSrcweir	# share/readme
1660cdf0e10cSrcweir
1661cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1662cdf0e10cSrcweir	{
1663cdf0e10cSrcweir		my $onefile = ${$filesarrayref}[$i];
1664cdf0e10cSrcweir		my $destination = $onefile->{'destination'};
1665cdf0e10cSrcweir		my $styles = "";
1666cdf0e10cSrcweir		if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1667cdf0e10cSrcweir
1668cdf0e10cSrcweir		if ( ( $destination =~ /share\Q$installer::globals::separator\Ereadme\Q$installer::globals::separator\E(\w+?)_?$defaultlanguage\.?(\w*)\s*/ )
1669cdf0e10cSrcweir			|| (( $styles =~ /\bROOTLICENSEFILE\b/ ) && ( $destination =~ /\Q$installer::globals::separator\E?(\w+?)_?$defaultlanguage\.?(\w*?)\s*$/ )) )
1670cdf0e10cSrcweir		{
1671cdf0e10cSrcweir			my $filename = $1;
1672cdf0e10cSrcweir			my $extension = $2;
1673cdf0e10cSrcweir
1674cdf0e10cSrcweir			my $newfilename;
1675cdf0e10cSrcweir
1676cdf0e10cSrcweir			if ( $extension eq "" ) { $newfilename = $filename; }
1677cdf0e10cSrcweir			else { $newfilename = $filename . "\." . $extension; }
1678cdf0e10cSrcweir
1679cdf0e10cSrcweir			my %newfile = ();
1680cdf0e10cSrcweir			my $newfile = \%newfile;
1681cdf0e10cSrcweir
1682cdf0e10cSrcweir			installer::converter::copy_item_object($onefile, $newfile);
1683cdf0e10cSrcweir
1684cdf0e10cSrcweir			$newfile->{'gid'} = $onefile->{'gid'} . "_Copy";
1685cdf0e10cSrcweir			$newfile->{'Name'} = $newfilename;
1686cdf0e10cSrcweir			$newfile->{'ismultilingual'} = "0";
1687cdf0e10cSrcweir			$newfile->{'specificlanguage'} = "";
1688cdf0e10cSrcweir			$newfile->{'haslanguagemodule'} = "0";
1689cdf0e10cSrcweir
1690cdf0e10cSrcweir			if ( defined $newfile->{'InstallName'} )
1691cdf0e10cSrcweir			{
1692cdf0e10cSrcweir				if ( $newfile->{'InstallName'} =~ /^\s*(.*?)_$defaultlanguage\.?(\w*?)\s*$/ )
1693cdf0e10cSrcweir				{
1694cdf0e10cSrcweir					my $localfilename = $1;
1695cdf0e10cSrcweir					my $localextension = $2;
1696cdf0e10cSrcweir
1697cdf0e10cSrcweir					if ( $localextension eq "" ) { $newfile->{'InstallName'} = $localfilename; }
1698cdf0e10cSrcweir					else { $newfile->{'InstallName'} = $localfilename . "\." . $localextension; }
1699cdf0e10cSrcweir				}
1700cdf0e10cSrcweir			}
1701cdf0e10cSrcweir
1702cdf0e10cSrcweir			$newfile->{'removelangfromfile'} = "1"; # Important for files with an InstallName, because language also has to be removed there.
1703cdf0e10cSrcweir
1704cdf0e10cSrcweir			if ( $foundofficedir )
1705cdf0e10cSrcweir			{
1706cdf0e10cSrcweir				$newfile->{'Dir'} = $officedirectorygid;
1707cdf0e10cSrcweir				$newfile->{'destination'} = $officedirectoryhostname . $installer::globals::separator . $newfilename;
1708cdf0e10cSrcweir			}
1709cdf0e10cSrcweir			else
1710cdf0e10cSrcweir			{
1711cdf0e10cSrcweir				$newfile->{'Dir'} = "PREDEFINED_PROGDIR";
1712cdf0e10cSrcweir				$newfile->{'destination'} = $newfilename;
1713cdf0e10cSrcweir			}
1714cdf0e10cSrcweir
1715cdf0e10cSrcweir			# Also setting "modules=gid_Module_Root_Brand" (module with style: ROOT_BRAND_PACKAGE)
1716cdf0e10cSrcweir			if ( $installer::globals::rootbrandpackageset )
1717cdf0e10cSrcweir			{
1718cdf0e10cSrcweir				$newfile->{'modules'} = $installer::globals::rootbrandpackage;
1719cdf0e10cSrcweir			}
1720cdf0e10cSrcweir
1721cdf0e10cSrcweir			push(@newfilesarray, $newfile);
1722cdf0e10cSrcweir
1723cdf0e10cSrcweir			$infoline = "New files: Adding file $newfilename for the installation root to the file list. Language: $defaultlanguage\n";
1724cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1725cdf0e10cSrcweir
1726cdf0e10cSrcweir			if ( defined $newfile->{'InstallName'} )
1727cdf0e10cSrcweir			{
1728cdf0e10cSrcweir				$infoline = "New files: Using installation name: $newfile->{'InstallName'}\n";
1729cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
1730cdf0e10cSrcweir			}
1731cdf0e10cSrcweir
1732cdf0e10cSrcweir			# Collecting license and readme file for the installation set
1733cdf0e10cSrcweir
1734cdf0e10cSrcweir			push(@installer::globals::installsetfiles, $newfile);
1735cdf0e10cSrcweir			$infoline = "New files: Adding file $newfilename to the file collector for the installation set. Language: $defaultlanguage\n";
1736cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1737cdf0e10cSrcweir		}
1738cdf0e10cSrcweir
1739cdf0e10cSrcweir		push(@newfilesarray, $onefile);
1740cdf0e10cSrcweir	}
1741cdf0e10cSrcweir
1742cdf0e10cSrcweir	return \@newfilesarray;
1743cdf0e10cSrcweir}
1744cdf0e10cSrcweir
1745cdf0e10cSrcweir############################################################################
1746cdf0e10cSrcweir# Removing files with flag ONLY_ASIA_LANGUAGE, only if no asian
1747cdf0e10cSrcweir# language is part of the product.
1748cdf0e10cSrcweir# This special files are connected to the root module and are not
1749cdf0e10cSrcweir# included into a language pack (would lead to conflicts!).
1750cdf0e10cSrcweir# But this files shall only be included into the product, if the
1751cdf0e10cSrcweir# product contains at least one asian language.
1752cdf0e10cSrcweir############################################################################
1753cdf0e10cSrcweir
1754cdf0e10cSrcweirsub remove_onlyasialanguage_files_from_productlists
1755cdf0e10cSrcweir{
1756cdf0e10cSrcweir	my ($filesarrayref) = @_;
1757cdf0e10cSrcweir
1758cdf0e10cSrcweir	my $infoline;
1759cdf0e10cSrcweir
1760cdf0e10cSrcweir	my @newfilesarray = ();
1761cdf0e10cSrcweir	my $returnfilesarrayref;
1762cdf0e10cSrcweir
1763cdf0e10cSrcweir	my $containsasianlanguage = installer::languages::detect_asian_language($installer::globals::alllanguagesinproductarrayref);
1764cdf0e10cSrcweir
1765cdf0e10cSrcweir	my $alllangstring = installer::converter::convert_array_to_comma_separated_string($installer::globals::alllanguagesinproductarrayref);
1766cdf0e10cSrcweir	$infoline = "\nLanguages in complete product: $alllangstring\n";
1767cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
1768cdf0e10cSrcweir
1769cdf0e10cSrcweir	if ( ! $containsasianlanguage )
1770cdf0e10cSrcweir	{
1771cdf0e10cSrcweir		$infoline = "Product does not contain asian language -> removing files\n";
1772cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
1773cdf0e10cSrcweir
1774cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1775cdf0e10cSrcweir		{
1776cdf0e10cSrcweir			my $onefile = ${$filesarrayref}[$i];
1777cdf0e10cSrcweir			my $styles = "";
1778cdf0e10cSrcweir			if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1779cdf0e10cSrcweir			if ( $styles =~ /\bONLY_ASIA_LANGUAGE\b/ )
1780cdf0e10cSrcweir			{
1781cdf0e10cSrcweir				$infoline = "Flag ONLY_ASIA_LANGUAGE: Removing file $onefile->{'Name'} from files collector!\n";
1782cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
1783cdf0e10cSrcweir				next;
1784cdf0e10cSrcweir			}
1785cdf0e10cSrcweir
1786cdf0e10cSrcweir			push(@newfilesarray, $onefile);
1787cdf0e10cSrcweir		}
1788cdf0e10cSrcweir
1789cdf0e10cSrcweir		$returnfilesarrayref = \@newfilesarray;
1790cdf0e10cSrcweir	}
1791cdf0e10cSrcweir	else
1792cdf0e10cSrcweir	{
1793cdf0e10cSrcweir		$returnfilesarrayref = $filesarrayref;
1794cdf0e10cSrcweir
1795cdf0e10cSrcweir		$infoline = "Product contains asian language -> Nothing to do\n";
1796cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
1797cdf0e10cSrcweir
1798cdf0e10cSrcweir	}
1799cdf0e10cSrcweir
1800cdf0e10cSrcweir	return $returnfilesarrayref;
1801cdf0e10cSrcweir}
1802cdf0e10cSrcweir
1803cdf0e10cSrcweir############################################################################
1804cdf0e10cSrcweir# Removing files with flag ONLY_WESTERN_LANGUAGE, only if no western
1805cdf0e10cSrcweir# language is part of the product.
1806cdf0e10cSrcweir# This special files are connected to the root module and are not
1807cdf0e10cSrcweir# included into a language pack (would lead to conflicts!).
1808cdf0e10cSrcweir# But this files shall only be included into the product, if the
1809cdf0e10cSrcweir# product contains at least one western language.
1810cdf0e10cSrcweir############################################################################
1811cdf0e10cSrcweir
1812cdf0e10cSrcweirsub remove_onlywesternlanguage_files_from_productlists
1813cdf0e10cSrcweir{
1814cdf0e10cSrcweir	my ($filesarrayref) = @_;
1815cdf0e10cSrcweir
1816cdf0e10cSrcweir	my $infoline;
1817cdf0e10cSrcweir
1818cdf0e10cSrcweir	my @newfilesarray = ();
1819cdf0e10cSrcweir	my $returnfilesarrayref;
1820cdf0e10cSrcweir
1821cdf0e10cSrcweir	my $containswesternlanguage = installer::languages::detect_western_language($installer::globals::alllanguagesinproductarrayref);
1822cdf0e10cSrcweir
1823cdf0e10cSrcweir	my $alllangstring = installer::converter::convert_array_to_comma_separated_string($installer::globals::alllanguagesinproductarrayref);
1824cdf0e10cSrcweir	$infoline = "\nLanguages in complete product: $alllangstring\n";
1825cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
1826cdf0e10cSrcweir
1827cdf0e10cSrcweir	if ( ! $containswesternlanguage )
1828cdf0e10cSrcweir	{
1829cdf0e10cSrcweir		$infoline = "Product does not contain western language -> removing files\n";
1830cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
1831cdf0e10cSrcweir
1832cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1833cdf0e10cSrcweir		{
1834cdf0e10cSrcweir			my $onefile = ${$filesarrayref}[$i];
1835cdf0e10cSrcweir			my $styles = "";
1836cdf0e10cSrcweir			if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1837cdf0e10cSrcweir			if ( $styles =~ /\bONLY_WESTERN_LANGUAGE\b/ )
1838cdf0e10cSrcweir			{
1839cdf0e10cSrcweir				$infoline = "Flag ONLY_WESTERN_LANGUAGE: Removing file $onefile->{'Name'} from files collector!\n";
1840cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
1841cdf0e10cSrcweir				next;
1842cdf0e10cSrcweir			}
1843cdf0e10cSrcweir
1844cdf0e10cSrcweir			push(@newfilesarray, $onefile);
1845cdf0e10cSrcweir		}
1846cdf0e10cSrcweir
1847cdf0e10cSrcweir		$returnfilesarrayref = \@newfilesarray;
1848cdf0e10cSrcweir	}
1849cdf0e10cSrcweir	else
1850cdf0e10cSrcweir	{
1851cdf0e10cSrcweir		$returnfilesarrayref = $filesarrayref;
1852cdf0e10cSrcweir
1853cdf0e10cSrcweir		$infoline = "Product contains western language -> Nothing to do\n";
1854cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
1855cdf0e10cSrcweir
1856cdf0e10cSrcweir	}
1857cdf0e10cSrcweir
1858cdf0e10cSrcweir	return $returnfilesarrayref;
1859cdf0e10cSrcweir}
1860cdf0e10cSrcweir
1861cdf0e10cSrcweir############################################################################
1862cdf0e10cSrcweir# Some files are included for more than one language and have the same
1863cdf0e10cSrcweir# name and the same destination directory for all languages. This would
1864cdf0e10cSrcweir# lead to conflicts, if the filenames are not changed.
1865cdf0e10cSrcweir# In scp project this files must have the flag MAKE_LANG_SPECIFIC
1866cdf0e10cSrcweir# For this files, the language is included into the filename.
1867cdf0e10cSrcweir############################################################################
1868cdf0e10cSrcweir
1869cdf0e10cSrcweirsub make_filename_language_specific
1870cdf0e10cSrcweir{
1871cdf0e10cSrcweir	my ($filesarrayref) = @_;
1872cdf0e10cSrcweir
1873cdf0e10cSrcweir	my $infoline = "";
1874cdf0e10cSrcweir
1875cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
1876cdf0e10cSrcweir	{
1877cdf0e10cSrcweir		my $onefile = ${$filesarrayref}[$i];
1878cdf0e10cSrcweir
1879cdf0e10cSrcweir		if ( $onefile->{'ismultilingual'} )
1880cdf0e10cSrcweir		{
1881cdf0e10cSrcweir			my $styles = "";
1882cdf0e10cSrcweir			if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1883cdf0e10cSrcweir			if ( $styles =~ /\bMAKE_LANG_SPECIFIC\b/ )
1884cdf0e10cSrcweir			{
1885cdf0e10cSrcweir				my $language = $onefile->{'specificlanguage'};
1886cdf0e10cSrcweir				my $olddestination = $onefile->{'destination'};
1887cdf0e10cSrcweir				my $oldname = $onefile->{'Name'};
1888cdf0e10cSrcweir
1889cdf0e10cSrcweir				# Including the language into the file name.
1890cdf0e10cSrcweir				# But be sure, to include the language before the file extension.
1891cdf0e10cSrcweir
1892cdf0e10cSrcweir				my $fileextension = "";
1893cdf0e10cSrcweir
1894cdf0e10cSrcweir				if ( $onefile->{'Name'} =~ /(\.\w+?)\s*$/ ) { $fileextension = $1; }
1895cdf0e10cSrcweir				if ( $fileextension ne "" )
1896cdf0e10cSrcweir				{
1897cdf0e10cSrcweir					$onefile->{'Name'} =~ s/\Q$fileextension\E\s*$/_$language$fileextension/;
1898cdf0e10cSrcweir					$onefile->{'destination'} =~ s/\Q$fileextension\E\s*$/_$language$fileextension/;
1899cdf0e10cSrcweir				}
1900cdf0e10cSrcweir
1901cdf0e10cSrcweir				$infoline = "Flag MAKE_LANG_SPECIFIC:\n";
1902cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
1903cdf0e10cSrcweir				$infoline = "Changing name from $oldname to $onefile->{'Name'} !\n";
1904cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
1905cdf0e10cSrcweir				$infoline = "Changing destination from $olddestination to $onefile->{'destination'} !\n";
1906cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
1907cdf0e10cSrcweir			}
1908cdf0e10cSrcweir		}
1909cdf0e10cSrcweir	}
1910cdf0e10cSrcweir}
1911cdf0e10cSrcweir
1912cdf0e10cSrcweir############################################################################
1913cdf0e10cSrcweir# Removing all scpactions, that have no name.
1914cdf0e10cSrcweir# See: FlatLoaderZip
1915cdf0e10cSrcweir############################################################################
1916cdf0e10cSrcweir
1917cdf0e10cSrcweirsub remove_scpactions_without_name
1918cdf0e10cSrcweir{
1919cdf0e10cSrcweir	my ($itemsarrayref) = @_;
1920cdf0e10cSrcweir
1921cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::remove_scpactions_without_name : $#{$itemsarrayref}"); }
1922cdf0e10cSrcweir
1923cdf0e10cSrcweir	my $infoline;
1924cdf0e10cSrcweir
1925cdf0e10cSrcweir	my @newitemsarray = ();
1926cdf0e10cSrcweir
1927cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1928cdf0e10cSrcweir	{
1929cdf0e10cSrcweir		my $oneitem = ${$itemsarrayref}[$i];
1930cdf0e10cSrcweir		my $name = "";
1931cdf0e10cSrcweir
1932cdf0e10cSrcweir		if ( $oneitem->{'Name'} ) { $name = $oneitem->{'Name'}; }
1933cdf0e10cSrcweir
1934cdf0e10cSrcweir		if  ( $name eq "" )
1935cdf0e10cSrcweir		{
1936cdf0e10cSrcweir			$infoline = "ATTENTION: Removing scpaction $oneitem->{'gid'} from the installation set.\n";
1937cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1938cdf0e10cSrcweir			next;
1939cdf0e10cSrcweir		}
1940cdf0e10cSrcweir
1941cdf0e10cSrcweir		push(@newitemsarray, $oneitem);
1942cdf0e10cSrcweir	}
1943cdf0e10cSrcweir
1944cdf0e10cSrcweir	return \@newitemsarray;
1945cdf0e10cSrcweir}
1946cdf0e10cSrcweir
1947cdf0e10cSrcweir############################################################################
1948cdf0e10cSrcweir# Because of the item "File" the source name must be "Name". Therefore
1949cdf0e10cSrcweir# "Copy" is changed to "Name" and "Name" is changed to "DestinationName".
1950cdf0e10cSrcweir############################################################################
1951cdf0e10cSrcweir
1952cdf0e10cSrcweirsub change_keys_of_scpactions
1953cdf0e10cSrcweir{
1954cdf0e10cSrcweir	my ($itemsarrayref) = @_;
1955cdf0e10cSrcweir
1956cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::change_keys_of_scpactions : $#{$itemsarrayref}"); }
1957cdf0e10cSrcweir
1958cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
1959cdf0e10cSrcweir	{
1960cdf0e10cSrcweir		my $oneitem = ${$itemsarrayref}[$i];
1961cdf0e10cSrcweir
1962cdf0e10cSrcweir		my $key;
1963cdf0e10cSrcweir
1964cdf0e10cSrcweir		# First Name to DestinationName, then deleting Name
1965cdf0e10cSrcweir		foreach $key (keys %{$oneitem})
1966cdf0e10cSrcweir		{
1967cdf0e10cSrcweir			if ( $key =~ /\bName\b/ )
1968cdf0e10cSrcweir			{
1969cdf0e10cSrcweir				my $value = $oneitem->{$key};
1970cdf0e10cSrcweir				my $oldkey = $key;
1971cdf0e10cSrcweir				$key =~ s/Name/DestinationName/;
1972cdf0e10cSrcweir				$oneitem->{$key} = $value;
1973cdf0e10cSrcweir				delete($oneitem->{$oldkey});
1974cdf0e10cSrcweir			}
1975cdf0e10cSrcweir		}
1976cdf0e10cSrcweir
1977cdf0e10cSrcweir		# Second Copy to Name, then deleting Copy
1978cdf0e10cSrcweir		foreach $key (keys %{$oneitem})
1979cdf0e10cSrcweir		{
1980cdf0e10cSrcweir			if ( $key =~ /\bCopy\b/ )
1981cdf0e10cSrcweir			{
1982cdf0e10cSrcweir				my $value = $oneitem->{$key};
1983cdf0e10cSrcweir				my $oldkey = $key;
1984cdf0e10cSrcweir				$key =~ s/Copy/Name/;
1985cdf0e10cSrcweir				$oneitem->{$key} = $value;
1986cdf0e10cSrcweir				delete($oneitem->{$oldkey});
1987cdf0e10cSrcweir			}
1988cdf0e10cSrcweir		}
1989cdf0e10cSrcweir	}
1990cdf0e10cSrcweir}
1991cdf0e10cSrcweir
1992cdf0e10cSrcweir############################################################################
1993cdf0e10cSrcweir# Removing all xpd only items from installation set (scpactions with
1994cdf0e10cSrcweir# the style XPD_ONLY), except an xpd installation set is created
1995cdf0e10cSrcweir############################################################################
1996cdf0e10cSrcweir
1997cdf0e10cSrcweirsub remove_Xpdonly_Items
1998cdf0e10cSrcweir{
1999cdf0e10cSrcweir	my ($itemsarrayref) = @_;
2000cdf0e10cSrcweir
2001cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::remove_Xpdonly_Items : $#{$itemsarrayref}"); }
2002cdf0e10cSrcweir
2003cdf0e10cSrcweir	my $infoline;
2004cdf0e10cSrcweir
2005cdf0e10cSrcweir	my @newitemsarray = ();
2006cdf0e10cSrcweir
2007cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
2008cdf0e10cSrcweir	{
2009cdf0e10cSrcweir		my $oneitem = ${$itemsarrayref}[$i];
2010cdf0e10cSrcweir		my $styles = "";
2011cdf0e10cSrcweir		if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
2012cdf0e10cSrcweir
2013cdf0e10cSrcweir		if ( $styles =~ /\bXPD_ONLY\b/ )
2014cdf0e10cSrcweir		{
2015cdf0e10cSrcweir			$infoline = "Removing \"xpd only\" item $oneitem->{'gid'} from the installation set.\n";
2016cdf0e10cSrcweir			push( @installer::globals::globallogfileinfo, $infoline);
2017cdf0e10cSrcweir
2018cdf0e10cSrcweir			next;
2019cdf0e10cSrcweir		}
2020cdf0e10cSrcweir
2021cdf0e10cSrcweir		push(@newitemsarray, $oneitem);
2022cdf0e10cSrcweir	}
2023cdf0e10cSrcweir
2024cdf0e10cSrcweir	$infoline = "\n";
2025cdf0e10cSrcweir	push( @installer::globals::globallogfileinfo, $infoline);
2026cdf0e10cSrcweir
2027cdf0e10cSrcweir	return \@newitemsarray;
2028cdf0e10cSrcweir}
2029cdf0e10cSrcweir
2030cdf0e10cSrcweir############################################################################
2031cdf0e10cSrcweir# Removing all language pack files from installation set (files with
2032cdf0e10cSrcweir# the style LANGUAGEPACK), except this is a language pack.
2033cdf0e10cSrcweir############################################################################
2034cdf0e10cSrcweir
2035cdf0e10cSrcweirsub remove_Languagepacklibraries_from_Installset
2036cdf0e10cSrcweir{
2037cdf0e10cSrcweir	my ($itemsarrayref) = @_;
2038cdf0e10cSrcweir
2039cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::remove_Languagepacklibraries_from_Installset : $#{$itemsarrayref}"); }
2040cdf0e10cSrcweir
2041cdf0e10cSrcweir	my $infoline;
2042cdf0e10cSrcweir
2043cdf0e10cSrcweir	my @newitemsarray = ();
2044cdf0e10cSrcweir
2045cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
2046cdf0e10cSrcweir	{
2047cdf0e10cSrcweir		my $oneitem = ${$itemsarrayref}[$i];
2048cdf0e10cSrcweir		my $styles = "";
2049cdf0e10cSrcweir		if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
2050cdf0e10cSrcweir
2051cdf0e10cSrcweir		if ( $styles =~ /\bLANGUAGEPACK\b/ )
2052cdf0e10cSrcweir		{
2053cdf0e10cSrcweir			$infoline = "Removing language pack file $oneitem->{'gid'} from the installation set.\n";
2054cdf0e10cSrcweir			push( @installer::globals::globallogfileinfo, $infoline);
2055cdf0e10cSrcweir
2056cdf0e10cSrcweir			next;
2057cdf0e10cSrcweir		}
2058cdf0e10cSrcweir
2059cdf0e10cSrcweir		push(@newitemsarray, $oneitem);
2060cdf0e10cSrcweir	}
2061cdf0e10cSrcweir
2062cdf0e10cSrcweir	$infoline = "\n";
2063cdf0e10cSrcweir	push( @installer::globals::globallogfileinfo, $infoline);
2064cdf0e10cSrcweir
2065cdf0e10cSrcweir	return \@newitemsarray;
2066cdf0e10cSrcweir}
2067cdf0e10cSrcweir
2068cdf0e10cSrcweir############################################################################
2069cdf0e10cSrcweir# Removing all files with flag PATCH_ONLY from installation set.
2070cdf0e10cSrcweir# This function is not called during patch creation.
2071cdf0e10cSrcweir############################################################################
2072cdf0e10cSrcweir
2073cdf0e10cSrcweirsub remove_patchonlyfiles_from_Installset
2074cdf0e10cSrcweir{
2075cdf0e10cSrcweir	my ($itemsarrayref) = @_;
2076cdf0e10cSrcweir
2077cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::remove_patchonlyfiles_from_Installset : $#{$itemsarrayref}"); }
2078cdf0e10cSrcweir
2079cdf0e10cSrcweir	my $infoline;
2080cdf0e10cSrcweir
2081cdf0e10cSrcweir	my @newitemsarray = ();
2082cdf0e10cSrcweir
2083cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
2084cdf0e10cSrcweir	{
2085cdf0e10cSrcweir		my $oneitem = ${$itemsarrayref}[$i];
2086cdf0e10cSrcweir		my $styles = "";
2087cdf0e10cSrcweir		if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
2088cdf0e10cSrcweir
2089cdf0e10cSrcweir		if ( $styles =~ /\bPATCH_ONLY\b/ )
2090cdf0e10cSrcweir		{
2091cdf0e10cSrcweir			$infoline = "Removing file with flag PATCH_ONLY $oneitem->{'gid'} from the installation set.\n";
2092cdf0e10cSrcweir			push( @installer::globals::globallogfileinfo, $infoline);
2093cdf0e10cSrcweir
2094cdf0e10cSrcweir			next;
2095cdf0e10cSrcweir		}
2096cdf0e10cSrcweir
2097cdf0e10cSrcweir		push(@newitemsarray, $oneitem);
2098cdf0e10cSrcweir	}
2099cdf0e10cSrcweir
2100cdf0e10cSrcweir	$infoline = "\n";
2101cdf0e10cSrcweir	push( @installer::globals::globallogfileinfo, $infoline);
2102cdf0e10cSrcweir
2103cdf0e10cSrcweir	return \@newitemsarray;
2104cdf0e10cSrcweir}
2105cdf0e10cSrcweir
2106cdf0e10cSrcweir############################################################################
2107cdf0e10cSrcweir# Removing all files with flag TAB_ONLY from installation set.
2108cdf0e10cSrcweir# This function is not called during tab creation.
2109cdf0e10cSrcweir############################################################################
2110cdf0e10cSrcweir
2111cdf0e10cSrcweirsub remove_tabonlyfiles_from_Installset
2112cdf0e10cSrcweir{
2113cdf0e10cSrcweir	my ($itemsarrayref) = @_;
2114cdf0e10cSrcweir
2115cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::remove_tabonlyfiles_from_Installset : $#{$itemsarrayref}"); }
2116cdf0e10cSrcweir
2117cdf0e10cSrcweir	my $infoline;
2118cdf0e10cSrcweir
2119cdf0e10cSrcweir	my @newitemsarray = ();
2120cdf0e10cSrcweir
2121cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
2122cdf0e10cSrcweir	{
2123cdf0e10cSrcweir		my $oneitem = ${$itemsarrayref}[$i];
2124cdf0e10cSrcweir		my $styles = "";
2125cdf0e10cSrcweir		if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
2126cdf0e10cSrcweir
2127cdf0e10cSrcweir		if ( $styles =~ /\bTAB_ONLY\b/ )
2128cdf0e10cSrcweir		{
2129cdf0e10cSrcweir			$infoline = "Removing tab only file $oneitem->{'gid'} from the installation set.\n";
2130cdf0e10cSrcweir			push( @installer::globals::globallogfileinfo, $infoline);
2131cdf0e10cSrcweir
2132cdf0e10cSrcweir			next;
2133cdf0e10cSrcweir		}
2134cdf0e10cSrcweir
2135cdf0e10cSrcweir		push(@newitemsarray, $oneitem);
2136cdf0e10cSrcweir	}
2137cdf0e10cSrcweir
2138cdf0e10cSrcweir	$infoline = "\n";
2139cdf0e10cSrcweir	push( @installer::globals::globallogfileinfo, $infoline);
2140cdf0e10cSrcweir
2141cdf0e10cSrcweir	return \@newitemsarray;
2142cdf0e10cSrcweir}
2143cdf0e10cSrcweir
2144cdf0e10cSrcweir###############################################################################
2145cdf0e10cSrcweir# Removing all files with flag ONLY_INSTALLED_PRODUCT from installation set.
2146cdf0e10cSrcweir# This function is not called for PKGFORMAT installed and archive.
2147cdf0e10cSrcweir###############################################################################
2148cdf0e10cSrcweir
2149cdf0e10cSrcweirsub remove_installedproductonlyfiles_from_Installset
2150cdf0e10cSrcweir{
2151cdf0e10cSrcweir	my ($itemsarrayref) = @_;
2152cdf0e10cSrcweir
2153cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::remove_installedproductonlyfiles_from_Installset : $#{$itemsarrayref}"); }
2154cdf0e10cSrcweir
2155cdf0e10cSrcweir	my $infoline;
2156cdf0e10cSrcweir
2157cdf0e10cSrcweir	my @newitemsarray = ();
2158cdf0e10cSrcweir
2159cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$itemsarrayref}; $i++ )
2160cdf0e10cSrcweir	{
2161cdf0e10cSrcweir		my $oneitem = ${$itemsarrayref}[$i];
2162cdf0e10cSrcweir		my $styles = "";
2163cdf0e10cSrcweir		if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
2164cdf0e10cSrcweir
2165cdf0e10cSrcweir		if ( $styles =~ /\bONLY_INSTALLED_PRODUCT\b/ )
2166cdf0e10cSrcweir		{
2167cdf0e10cSrcweir			$infoline = "Removing file $oneitem->{'gid'} from the installation set. This file is only required for PKGFORMAT archive or installed).\n";
2168cdf0e10cSrcweir			push( @installer::globals::globallogfileinfo, $infoline);
2169cdf0e10cSrcweir			next;
2170cdf0e10cSrcweir		}
2171cdf0e10cSrcweir
2172cdf0e10cSrcweir		push(@newitemsarray, $oneitem);
2173cdf0e10cSrcweir	}
2174cdf0e10cSrcweir
2175cdf0e10cSrcweir	$infoline = "\n";
2176cdf0e10cSrcweir	push( @installer::globals::globallogfileinfo, $infoline);
2177cdf0e10cSrcweir
2178cdf0e10cSrcweir	return \@newitemsarray;
2179cdf0e10cSrcweir}
2180cdf0e10cSrcweir
2181cdf0e10cSrcweir############################################################################
2182cdf0e10cSrcweir# Some files cotain a $ in their name. epm conflicts with such files.
2183cdf0e10cSrcweir# Solution: Renaming this files, converting "$" to "$$"
2184cdf0e10cSrcweir############################################################################
2185cdf0e10cSrcweir
2186cdf0e10cSrcweirsub quoting_illegal_filenames
2187cdf0e10cSrcweir{
2188cdf0e10cSrcweir	my ($filesarrayref) = @_;
2189cdf0e10cSrcweir
2190cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::rename_illegal_filenames : $#{$filesarrayref}"); }
2191cdf0e10cSrcweir
2192cdf0e10cSrcweir	# This function has to be removed as soon as possible!
2193cdf0e10cSrcweir
2194cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Renaming illegal filenames:");
2195cdf0e10cSrcweir
2196cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
2197cdf0e10cSrcweir	{
2198cdf0e10cSrcweir		my $onefile = ${$filesarrayref}[$i];
2199cdf0e10cSrcweir		my $filename = $onefile->{'Name'};
2200cdf0e10cSrcweir
2201cdf0e10cSrcweir		if ( $filename =~ /\$/ )
2202cdf0e10cSrcweir		{
2203cdf0e10cSrcweir			my $sourcepath = $onefile->{'sourcepath'};
2204cdf0e10cSrcweir			my $destpath = $onefile->{'destination'};
2205cdf0e10cSrcweir
2206cdf0e10cSrcweir			# sourcepath and destination have to be quoted for epm list file
2207cdf0e10cSrcweir
2208cdf0e10cSrcweir			# $filename =~ s/\$/\$\$/g;
2209cdf0e10cSrcweir			$destpath =~ s/\$/\$\$/g;
2210cdf0e10cSrcweir			$sourcepath =~ s/\$/\$\$/g;
2211cdf0e10cSrcweir
2212cdf0e10cSrcweir			# my $infoline = "ATTENTION: Files: Renaming $onefile->{'Name'} to $filename\n";
2213cdf0e10cSrcweir			# push( @installer::globals::logfileinfo, $infoline);
2214cdf0e10cSrcweir			my $infoline = "ATTENTION: Files: Quoting sourcepath $onefile->{'sourcepath'} to $sourcepath\n";
2215cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
2216cdf0e10cSrcweir			$infoline = "ATTENTION: Files: Quoting destination path $onefile->{'destination'} to $destpath\n";
2217cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
2218cdf0e10cSrcweir
2219cdf0e10cSrcweir			# $onefile->{'Name'} = $filename;
2220cdf0e10cSrcweir			$onefile->{'sourcepath'} = $sourcepath;
2221cdf0e10cSrcweir			$onefile->{'destination'} = $destpath;
2222cdf0e10cSrcweir		}
2223cdf0e10cSrcweir	}
2224cdf0e10cSrcweir}
2225cdf0e10cSrcweir
2226cdf0e10cSrcweir############################################################################
2227cdf0e10cSrcweir# Removing multiple occurences of same module.
2228cdf0e10cSrcweir############################################################################
2229cdf0e10cSrcweir
2230cdf0e10cSrcweirsub optimize_list
2231cdf0e10cSrcweir{
2232cdf0e10cSrcweir	my ( $longlist ) = @_;
2233cdf0e10cSrcweir
2234cdf0e10cSrcweir	my $shortlist = "";
2235cdf0e10cSrcweir	my $hashref = installer::converter::convert_stringlist_into_hash(\$longlist, ",");
2236cdf0e10cSrcweir	foreach my $key (sort keys %{$hashref} ) { $shortlist = "$shortlist,$key"; }
2237cdf0e10cSrcweir	$shortlist =~ s/^\s*\,//;
2238cdf0e10cSrcweir
2239cdf0e10cSrcweir	return $shortlist;
2240cdf0e10cSrcweir}
2241cdf0e10cSrcweir
2242cdf0e10cSrcweir#######################################################################
2243cdf0e10cSrcweir# Collecting all directories needed for the epm list
2244cdf0e10cSrcweir# 1. Looking for all destination paths in the files array
2245cdf0e10cSrcweir# 2. Looking for directories with CREATE flag in the directory array
2246cdf0e10cSrcweir#######################################################################
2247cdf0e10cSrcweir
2248cdf0e10cSrcweir##################################
2249cdf0e10cSrcweir# Collecting directories: Part 1
2250cdf0e10cSrcweir##################################
2251cdf0e10cSrcweir
2252cdf0e10cSrcweirsub collect_directories_from_filesarray
2253cdf0e10cSrcweir{
2254cdf0e10cSrcweir	my ($filesarrayref) = @_;
2255cdf0e10cSrcweir
2256cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::collect_directories_from_filesarray : $#{$filesarrayref}"); }
2257cdf0e10cSrcweir
2258cdf0e10cSrcweir	my @alldirectories = ();
2259cdf0e10cSrcweir	my %alldirectoryhash = ();
2260cdf0e10cSrcweir
2261cdf0e10cSrcweir	my $predefinedprogdir_added = 0;
2262cdf0e10cSrcweir	my $alreadyincluded = 0;
2263cdf0e10cSrcweir
2264cdf0e10cSrcweir	# Preparing this already as hash, although the only needed value at the moment is the HostName
2265cdf0e10cSrcweir	# But also adding: "specificlanguage" and "Dir" (for instance gid_Dir_Program)
2266cdf0e10cSrcweir
2267cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ )
2268cdf0e10cSrcweir	{
2269cdf0e10cSrcweir		my $onefile = ${$filesarrayref}[$i];
2270cdf0e10cSrcweir		my $destinationpath = $onefile->{'destination'};
2271cdf0e10cSrcweir		installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationpath);
2272cdf0e10cSrcweir		$destinationpath =~ s/\Q$installer::globals::separator\E\s*$//;		# removing ending slashes or backslashes
2273cdf0e10cSrcweir
2274cdf0e10cSrcweir		$alreadyincluded = 0;
2275cdf0e10cSrcweir		if  ( exists($alldirectoryhash{$destinationpath}) ) { $alreadyincluded = 1; }
2276cdf0e10cSrcweir
2277cdf0e10cSrcweir		if (!($alreadyincluded))
2278cdf0e10cSrcweir		{
2279cdf0e10cSrcweir			my %directoryhash = ();
2280cdf0e10cSrcweir			$directoryhash{'HostName'} = $destinationpath;
2281cdf0e10cSrcweir			$directoryhash{'specificlanguage'} = $onefile->{'specificlanguage'};
2282cdf0e10cSrcweir			$directoryhash{'Dir'} = $onefile->{'Dir'};
2283cdf0e10cSrcweir			$directoryhash{'modules'} = $onefile->{'modules'}; # NEW, saving modules
2284cdf0e10cSrcweir			# NEVER!!!	if ( ! $installer::globals::iswindowsbuild ) { $directoryhash{'Styles'} = "(CREATE)"; }	# this directories must be created
2285cdf0e10cSrcweir
2286cdf0e10cSrcweir			if ( $onefile->{'Dir'} eq "PREDEFINED_PROGDIR" ) { $predefinedprogdir_added = 1; }
2287cdf0e10cSrcweir
2288cdf0e10cSrcweir			$alldirectoryhash{$destinationpath} = \%directoryhash;
2289cdf0e10cSrcweir
2290cdf0e10cSrcweir			# Problem: The $destinationpath can be share/registry/schema/org/openoffice
2291cdf0e10cSrcweir			# but not all directories contain files and will be added to this list.
2292cdf0e10cSrcweir			# Therefore the path has to be analyzed.
2293cdf0e10cSrcweir
2294cdf0e10cSrcweir			while ( $destinationpath =~ /(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/ )	# as long as the path contains slashes
2295cdf0e10cSrcweir			{
2296cdf0e10cSrcweir				$destinationpath = $1;
2297cdf0e10cSrcweir
2298cdf0e10cSrcweir				$alreadyincluded = 0;
2299cdf0e10cSrcweir				if  ( exists($alldirectoryhash{$destinationpath}) ) { $alreadyincluded = 1; }
2300cdf0e10cSrcweir
2301cdf0e10cSrcweir				if (!($alreadyincluded))
2302cdf0e10cSrcweir				{
2303cdf0e10cSrcweir					my %directoryhash = ();
2304cdf0e10cSrcweir
2305cdf0e10cSrcweir					$directoryhash{'HostName'} = $destinationpath;
2306cdf0e10cSrcweir					$directoryhash{'specificlanguage'} = $onefile->{'specificlanguage'};
2307cdf0e10cSrcweir					$directoryhash{'Dir'} = $onefile->{'Dir'};
2308cdf0e10cSrcweir					$directoryhash{'modules'} = $onefile->{'modules'}; # NEW, saving modules
2309cdf0e10cSrcweir					# NEVER!!! if ( ! $installer::globals::iswindowsbuild ) { $directoryhash{'Styles'} = "(CREATE)"; }	# this directories must be created
2310cdf0e10cSrcweir
2311cdf0e10cSrcweir					$alldirectoryhash{$destinationpath} = \%directoryhash;
2312cdf0e10cSrcweir				}
2313cdf0e10cSrcweir				else
2314cdf0e10cSrcweir				{
2315c6dedb65SAndre Fischer					# Adding the modules to the module list!
2316cdf0e10cSrcweir					$alldirectoryhash{$destinationpath}->{'modules'} = $alldirectoryhash{$destinationpath}->{'modules'} . "," . $onefile->{'modules'};
2317cdf0e10cSrcweir				}
2318cdf0e10cSrcweir			}
2319cdf0e10cSrcweir		}
2320cdf0e10cSrcweir		else
2321cdf0e10cSrcweir		{
2322cdf0e10cSrcweir			# Adding the modules to the module list!
2323cdf0e10cSrcweir			$alldirectoryhash{$destinationpath}->{'modules'} = $alldirectoryhash{$destinationpath}->{'modules'} . "," . $onefile->{'modules'};
2324cdf0e10cSrcweir
2325cdf0e10cSrcweir			# Also adding the module to all parents
2326cdf0e10cSrcweir			while ( $destinationpath =~ /(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/ )	# as long as the path contains slashes
2327cdf0e10cSrcweir			{
2328cdf0e10cSrcweir				$destinationpath = $1;
2329cdf0e10cSrcweir				$alldirectoryhash{$destinationpath}->{'modules'} = $alldirectoryhash{$destinationpath}->{'modules'} . "," . $onefile->{'modules'};
2330cdf0e10cSrcweir			}
2331cdf0e10cSrcweir		}
2332cdf0e10cSrcweir	}
2333cdf0e10cSrcweir
2334cdf0e10cSrcweir	# if there is no file in the root directory PREDEFINED_PROGDIR, it has to be included into the directory array now
2335cdf0e10cSrcweir	# HostName=	specificlanguage=	Dir=PREDEFINED_PROGDIR
2336cdf0e10cSrcweir
2337cdf0e10cSrcweir	if (! $predefinedprogdir_added )
2338cdf0e10cSrcweir	{
2339cdf0e10cSrcweir		my %directoryhash = ();
2340cdf0e10cSrcweir		$directoryhash{'HostName'} = "";
2341cdf0e10cSrcweir		$directoryhash{'specificlanguage'} = "";
2342cdf0e10cSrcweir		$directoryhash{'modules'} = "";	# ToDo?
2343cdf0e10cSrcweir		$directoryhash{'Dir'} = "PREDEFINED_PROGDIR";
2344cdf0e10cSrcweir
2345cdf0e10cSrcweir		push(@alldirectories, \%directoryhash);
2346cdf0e10cSrcweir	}
2347cdf0e10cSrcweir
2348cdf0e10cSrcweir	# Creating directory array
2349cdf0e10cSrcweir	foreach my $destdir ( sort keys %alldirectoryhash )
2350cdf0e10cSrcweir	{
2351cdf0e10cSrcweir		$alldirectoryhash{$destdir}->{'modules'} = optimize_list($alldirectoryhash{$destdir}->{'modules'});
2352cdf0e10cSrcweir		push(@alldirectories, $alldirectoryhash{$destdir});
2353cdf0e10cSrcweir	}
2354cdf0e10cSrcweir
2355cdf0e10cSrcweir	return (\@alldirectories, \%alldirectoryhash);
2356cdf0e10cSrcweir}
2357cdf0e10cSrcweir
2358cdf0e10cSrcweir##################################
2359cdf0e10cSrcweir# Collecting directories: Part 2
2360cdf0e10cSrcweir##################################
2361cdf0e10cSrcweir
2362cdf0e10cSrcweirsub collect_directories_with_create_flag_from_directoryarray
2363cdf0e10cSrcweir{
2364cdf0e10cSrcweir	my ($directoryarrayref, $alldirectoryhash) = @_;
2365cdf0e10cSrcweir
2366cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::collect_directories_with_create_flag_from_directoryarray : $#{$directoryarrayref}"); }
2367cdf0e10cSrcweir
2368cdf0e10cSrcweir	my $alreadyincluded = 0;
2369cdf0e10cSrcweir	my @alldirectories = ();
2370cdf0e10cSrcweir
2371cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$directoryarrayref}; $i++ )
2372cdf0e10cSrcweir	{
2373cdf0e10cSrcweir		my $onedir = ${$directoryarrayref}[$i];
2374cdf0e10cSrcweir		my $styles = "";
2375cdf0e10cSrcweir		$newdirincluded = 0;
2376cdf0e10cSrcweir
2377cdf0e10cSrcweir		if ( $onedir->{'Styles'} ) { $styles = $onedir->{'Styles'}; }
2378cdf0e10cSrcweir
2379cdf0e10cSrcweir		if ( $styles =~ /\bCREATE\b/ )
2380cdf0e10cSrcweir		{
2381cdf0e10cSrcweir			my $directoryname = "";
2382cdf0e10cSrcweir
2383cdf0e10cSrcweir			if ( $onedir->{'HostName'} ) { $directoryname = $onedir->{'HostName'}; }
2384cdf0e10cSrcweir			else { installer::exiter::exit_program("ERROR: No directory name (HostName) set for specified language in gid $onedir->{'gid'}", "collect_directories_with_create_flag_from_directoryarray"); }
2385cdf0e10cSrcweir
2386cdf0e10cSrcweir			$alreadyincluded = 0;
2387cdf0e10cSrcweir			if ( exists($alldirectoryhash->{$directoryname}) ) { $alreadyincluded = 1; }
2388cdf0e10cSrcweir
2389cdf0e10cSrcweir			if (!($alreadyincluded))
2390cdf0e10cSrcweir			{
2391cdf0e10cSrcweir				my %directoryhash = ();
2392cdf0e10cSrcweir				$directoryhash{'HostName'} = $directoryname;
2393cdf0e10cSrcweir				$directoryhash{'specificlanguage'} = $onedir->{'specificlanguage'};
2394cdf0e10cSrcweir				# $directoryhash{'gid'} = $onedir->{'gid'};
2395cdf0e10cSrcweir				$directoryhash{'Dir'} = $onedir->{'gid'};
2396cdf0e10cSrcweir				$directoryhash{'Styles'} = $onedir->{'Styles'};
2397cdf0e10cSrcweir
2398cdf0e10cSrcweir				# saving also the modules
2399cdf0e10cSrcweir				if ( ! $onedir->{'modules'} ) { installer::exiter::exit_program("ERROR: No assigned modules found for directory $onedir->{'gid'}", "collect_directories_with_create_flag_from_directoryarray"); }
2400cdf0e10cSrcweir				$directoryhash{'modules'} = $onedir->{'modules'};
2401cdf0e10cSrcweir
2402cdf0e10cSrcweir				$alldirectoryhash->{$directoryname} = \%directoryhash;
2403cdf0e10cSrcweir				$newdirincluded = 1;
2404cdf0e10cSrcweir
2405cdf0e10cSrcweir				# Problem: The $destinationpath can be share/registry/schema/org/openoffice
2406cdf0e10cSrcweir				# but not all directories contain files and will be added to this list.
2407cdf0e10cSrcweir				# Therefore the path has to be analyzed.
2408cdf0e10cSrcweir
2409cdf0e10cSrcweir				while ( $directoryname =~ /(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/ )	# as long as the path contains slashes
2410cdf0e10cSrcweir				{
2411cdf0e10cSrcweir					$directoryname = $1;
2412cdf0e10cSrcweir
2413cdf0e10cSrcweir					$alreadyincluded = 0;
2414cdf0e10cSrcweir					if ( exists($alldirectoryhash->{$directoryname}) ) { $alreadyincluded = 1; }
2415cdf0e10cSrcweir
2416cdf0e10cSrcweir					if (!($alreadyincluded))
2417cdf0e10cSrcweir					{
2418cdf0e10cSrcweir						my %directoryhash = ();
2419cdf0e10cSrcweir
2420cdf0e10cSrcweir						$directoryhash{'HostName'} = $directoryname;
2421cdf0e10cSrcweir						$directoryhash{'specificlanguage'} = $onedir->{'specificlanguage'};
2422cdf0e10cSrcweir						$directoryhash{'Dir'} = $onedir->{'gid'};
2423cdf0e10cSrcweir						if ( ! $installer::globals::iswindowsbuild ) { $directoryhash{'Styles'} = "(CREATE)"; } # Exeception for Windows?
2424cdf0e10cSrcweir
2425cdf0e10cSrcweir						# saving also the modules
2426cdf0e10cSrcweir						$directoryhash{'modules'} = $onedir->{'modules'};
2427cdf0e10cSrcweir
2428cdf0e10cSrcweir						$alldirectoryhash->{$directoryname} = \%directoryhash;
2429cdf0e10cSrcweir						$newdirincluded = 1;
2430cdf0e10cSrcweir					}
2431cdf0e10cSrcweir					else
2432cdf0e10cSrcweir					{
2433cdf0e10cSrcweir						# Adding the modules to the module list!
2434cdf0e10cSrcweir						$alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $onedir->{'modules'};
2435cdf0e10cSrcweir					}
2436cdf0e10cSrcweir				}
2437cdf0e10cSrcweir			}
2438cdf0e10cSrcweir			else
2439cdf0e10cSrcweir			{
2440cdf0e10cSrcweir				# Adding the modules to the module list!
2441cdf0e10cSrcweir				$alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $onedir->{'modules'};
2442cdf0e10cSrcweir
2443cdf0e10cSrcweir				while ( $directoryname =~ /(^.*\S)\Q$installer::globals::separator\E(\S.*?)\s*$/ )	# as long as the path contains slashes
2444cdf0e10cSrcweir				{
2445cdf0e10cSrcweir					$directoryname = $1;
2446cdf0e10cSrcweir					# Adding the modules to the module list!
2447cdf0e10cSrcweir					$alldirectoryhash->{$directoryname}->{'modules'} = $alldirectoryhash->{$directoryname}->{'modules'} . "," . $onedir->{'modules'};
2448cdf0e10cSrcweir				}
2449cdf0e10cSrcweir			}
2450cdf0e10cSrcweir		}
2451cdf0e10cSrcweir
2452cdf0e10cSrcweir		# Saving the styles for already added directories in function collect_directories_from_filesarray
2453cdf0e10cSrcweir
2454cdf0e10cSrcweir		if (( ! $newdirincluded ) && ( $styles ne "" ))
2455cdf0e10cSrcweir		{
2456cdf0e10cSrcweir			$styles =~ s/\bWORKSTATION\b//;
2457cdf0e10cSrcweir			$styles =~ s/\bCREATE\b//;
2458cdf0e10cSrcweir
2459cdf0e10cSrcweir			if (( ! ( $styles =~ /^\s*\(\s*\)\s*$/ )) && ( ! ( $styles =~ /^\s*\(\s*\,\s*\)\s*$/ )) && ( ! ( $styles =~ /^\s*$/ ))) # checking, if there are styles left
2460cdf0e10cSrcweir			{
2461cdf0e10cSrcweir				my $directoryname = "";
2462cdf0e10cSrcweir				if ( $onedir->{'HostName'} ) { $directoryname = $onedir->{'HostName'}; }
2463cdf0e10cSrcweir				else { installer::exiter::exit_program("ERROR: No directory name (HostName) set for specified language in gid $onedir->{'gid'}", "collect_directories_with_create_flag_from_directoryarray"); }
2464cdf0e10cSrcweir
2465cdf0e10cSrcweir				if ( exists($alldirectoryhash->{$directoryname}) )
2466cdf0e10cSrcweir				{
2467cdf0e10cSrcweir					$alldirectoryhash->{$directoryname}->{'Styles'} = $styles;
2468cdf0e10cSrcweir				}
2469cdf0e10cSrcweir			}
2470cdf0e10cSrcweir		}
2471cdf0e10cSrcweir	}
2472cdf0e10cSrcweir
2473cdf0e10cSrcweir	# Creating directory array
2474cdf0e10cSrcweir	foreach my $destdir ( sort keys %{$alldirectoryhash} )
2475cdf0e10cSrcweir	{
2476cdf0e10cSrcweir		$alldirectoryhash->{$destdir}->{'modules'} = optimize_list($alldirectoryhash->{$destdir}->{'modules'});
2477cdf0e10cSrcweir		push(@alldirectories, $alldirectoryhash->{$destdir});
2478cdf0e10cSrcweir	}
2479cdf0e10cSrcweir
2480cdf0e10cSrcweir	return (\@alldirectories, \%alldirectoryhash);
2481cdf0e10cSrcweir}
2482cdf0e10cSrcweir
2483cdf0e10cSrcweir#################################################
2484cdf0e10cSrcweir# Determining the destination file of a link
2485cdf0e10cSrcweir#################################################
2486cdf0e10cSrcweir
2487cdf0e10cSrcweirsub get_destination_file_path_for_links
2488cdf0e10cSrcweir{
2489cdf0e10cSrcweir	my ($linksarrayref, $filesarrayref) = @_;
2490cdf0e10cSrcweir
2491cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::get_destination_file_path_for_links : $#{$linksarrayref} : $#{$filesarrayref}"); }
2492cdf0e10cSrcweir
2493cdf0e10cSrcweir	my $infoline;
2494cdf0e10cSrcweir
2495cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ )
2496cdf0e10cSrcweir	{
2497cdf0e10cSrcweir		my $fileid = "";
2498cdf0e10cSrcweir		my $onelink = ${$linksarrayref}[$i];
2499cdf0e10cSrcweir		if ( $onelink->{'FileID'} ) { $fileid = $onelink->{'FileID'}; }
2500cdf0e10cSrcweir
2501cdf0e10cSrcweir		if (!( $fileid eq "" ))
2502cdf0e10cSrcweir		{
2503cdf0e10cSrcweir			my $foundfile = 0;
2504cdf0e10cSrcweir
2505cdf0e10cSrcweir			for ( my $j = 0; $j <= $#{$filesarrayref}; $j++ )
2506cdf0e10cSrcweir			{
2507cdf0e10cSrcweir				my $onefile = ${$filesarrayref}[$j];
2508cdf0e10cSrcweir				my $filegid = $onefile->{'gid'};
2509cdf0e10cSrcweir
2510cdf0e10cSrcweir				if ( $filegid eq $fileid )
2511cdf0e10cSrcweir				{
2512cdf0e10cSrcweir					$foundfile = 1;
2513cdf0e10cSrcweir					$onelink->{'destinationfile'} = $onefile->{'destination'};
2514cdf0e10cSrcweir					last;
2515cdf0e10cSrcweir				}
2516cdf0e10cSrcweir			}
2517cdf0e10cSrcweir
2518cdf0e10cSrcweir			if (!($foundfile))
2519cdf0e10cSrcweir			{
2520cdf0e10cSrcweir				$infoline = "Warning: FileID $fileid for Link $onelink->{'gid'} not found!\n";
2521cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
2522cdf0e10cSrcweir			}
2523cdf0e10cSrcweir		}
2524cdf0e10cSrcweir	}
2525cdf0e10cSrcweir
2526cdf0e10cSrcweir	$infoline = "\n";
2527cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
2528cdf0e10cSrcweir}
2529cdf0e10cSrcweir
2530cdf0e10cSrcweir#################################################
2531cdf0e10cSrcweir# Determining the destination link of a link
2532cdf0e10cSrcweir#################################################
2533cdf0e10cSrcweir
2534cdf0e10cSrcweirsub get_destination_link_path_for_links
2535cdf0e10cSrcweir{
2536cdf0e10cSrcweir	my ($linksarrayref) = @_;
2537cdf0e10cSrcweir
2538cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::get_destination_link_path_for_links : $#{$linksarrayref}"); }
2539cdf0e10cSrcweir
2540cdf0e10cSrcweir	my $infoline;
2541cdf0e10cSrcweir
2542cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ )
2543cdf0e10cSrcweir	{
2544cdf0e10cSrcweir		my $shortcutid = "";
2545cdf0e10cSrcweir		my $onelink = ${$linksarrayref}[$i];
2546cdf0e10cSrcweir		if ( $onelink->{'ShortcutID'} ) { $shortcutid = $onelink->{'ShortcutID'}; }
2547cdf0e10cSrcweir
2548cdf0e10cSrcweir		if (!( $shortcutid eq "" ))
2549cdf0e10cSrcweir		{
2550cdf0e10cSrcweir			my $foundlink = 0;
2551cdf0e10cSrcweir
2552cdf0e10cSrcweir			for ( my $j = 0; $j <= $#{$linksarrayref}; $j++ )
2553cdf0e10cSrcweir			{
2554cdf0e10cSrcweir				my $destlink = ${$linksarrayref}[$j];
2555cdf0e10cSrcweir				$shortcutgid = $destlink->{'gid'};
2556cdf0e10cSrcweir
2557cdf0e10cSrcweir				if ( $shortcutgid eq $shortcutid )
2558cdf0e10cSrcweir				{
2559cdf0e10cSrcweir					$foundlink = 1;
2560cdf0e10cSrcweir					$onelink->{'destinationfile'} = $destlink->{'destination'};		# making key 'destinationfile'
2561cdf0e10cSrcweir					last;
2562cdf0e10cSrcweir				}
2563cdf0e10cSrcweir			}
2564cdf0e10cSrcweir
2565cdf0e10cSrcweir			if (!($foundlink))
2566cdf0e10cSrcweir			{
2567cdf0e10cSrcweir				$infoline = "Warning: ShortcutID $shortcutid for Link $onelink->{'gid'} not found!\n";
2568cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
2569cdf0e10cSrcweir			}
2570cdf0e10cSrcweir		}
2571cdf0e10cSrcweir	}
2572cdf0e10cSrcweir
2573cdf0e10cSrcweir	$infoline = "\n";
2574cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
2575cdf0e10cSrcweir}
2576cdf0e10cSrcweir
2577cdf0e10cSrcweir###################################################################################
2578cdf0e10cSrcweir# Items with flag WORKSTATION are not needed (here: links and configurationitems)
2579cdf0e10cSrcweir###################################################################################
2580cdf0e10cSrcweir
2581cdf0e10cSrcweirsub remove_workstation_only_items
2582cdf0e10cSrcweir{
2583cdf0e10cSrcweir	my ($itemarrayref) = @_;
2584cdf0e10cSrcweir
2585cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::remove_workstation_only_items : $#{$itemarrayref}"); }
2586cdf0e10cSrcweir
2587cdf0e10cSrcweir	my @newitemarray = ();
2588cdf0e10cSrcweir
2589cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$itemarrayref}; $i++ )
2590cdf0e10cSrcweir	{
2591cdf0e10cSrcweir		my $oneitem = ${$itemarrayref}[$i];
2592cdf0e10cSrcweir		my $styles = $oneitem->{'Styles'};
2593cdf0e10cSrcweir
2594cdf0e10cSrcweir		if (( $styles =~ /\bWORKSTATION\b/ ) &&
2595cdf0e10cSrcweir			(!( $styles =~ /\bNETWORK\b/ )) &&
2596cdf0e10cSrcweir			(!( $styles =~ /\bSTANDALONE\b/ )))
2597cdf0e10cSrcweir		{
2598cdf0e10cSrcweir			next;	# removing this link, it is only needed for a workstation installation
2599cdf0e10cSrcweir		}
2600cdf0e10cSrcweir
2601cdf0e10cSrcweir		push(@newitemarray, $oneitem);
2602cdf0e10cSrcweir	}
2603cdf0e10cSrcweir
2604cdf0e10cSrcweir	return \@newitemarray;
2605cdf0e10cSrcweir}
2606cdf0e10cSrcweir
2607cdf0e10cSrcweir################################################
2608cdf0e10cSrcweir# Resolving relative path in links
2609cdf0e10cSrcweir################################################
2610cdf0e10cSrcweir
2611cdf0e10cSrcweirsub resolve_links_with_flag_relative
2612cdf0e10cSrcweir{
2613cdf0e10cSrcweir	my ($linksarrayref) = @_;
2614cdf0e10cSrcweir
2615cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::resolve_links_with_flag_relative : $#{$linksarrayref}"); }
2616cdf0e10cSrcweir
2617cdf0e10cSrcweir	# Before this step is:
2618cdf0e10cSrcweir	# destination=program/libsalhelperC52.so.3, this will be the name of the link
2619cdf0e10cSrcweir	# destinationfile=program/libsalhelperC52.so.3, this will be the linked file or name
2620cdf0e10cSrcweir	# If the flag RELATIVE is set, the pathes have to be analyzed. If the flag is not set
2621cdf0e10cSrcweir	# (this will not occur in the future?) destinationfile has to be an absolute path name
2622cdf0e10cSrcweir
2623cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$linksarrayref}; $i++ )
2624cdf0e10cSrcweir	{
2625cdf0e10cSrcweir		my $onelink = ${$linksarrayref}[$i];
2626cdf0e10cSrcweir		my $styles = $onelink->{'Styles'};
2627cdf0e10cSrcweir
2628cdf0e10cSrcweir		if ( $styles =~ /\bRELATIVE\b/ )
2629cdf0e10cSrcweir		{
2630cdf0e10cSrcweir			# ToDo: This is only a simple not sufficient mechanism
2631cdf0e10cSrcweir
2632cdf0e10cSrcweir			my $destination = $onelink->{'destination'};
2633cdf0e10cSrcweir			my $destinationfile = $onelink->{'destinationfile'};
2634cdf0e10cSrcweir
2635cdf0e10cSrcweir			my $destinationpath = $destination;
2636cdf0e10cSrcweir
2637cdf0e10cSrcweir			installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationpath);
2638cdf0e10cSrcweir
2639cdf0e10cSrcweir			my $destinationfilepath = $destinationfile;
2640cdf0e10cSrcweir
2641cdf0e10cSrcweir			# it is possible, that the destinationfile is no longer part of the files collector
2642cdf0e10cSrcweir			if ($destinationfilepath) { installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationfilepath); }
2643cdf0e10cSrcweir			else { $destinationfilepath = ""; }
2644cdf0e10cSrcweir
2645cdf0e10cSrcweir			if ( $destinationpath eq $destinationfilepath )
2646cdf0e10cSrcweir			{
2647cdf0e10cSrcweir				# link and file are in the same directory
2648cdf0e10cSrcweir				# Therefore the path of the file can be removed
2649cdf0e10cSrcweir
2650cdf0e10cSrcweir				my $newdestinationfile = $destinationfile;
2651cdf0e10cSrcweir				installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$newdestinationfile);
2652cdf0e10cSrcweir
2653cdf0e10cSrcweir				$onelink->{'destinationfile'} = $newdestinationfile;
2654cdf0e10cSrcweir			}
2655cdf0e10cSrcweir		}
2656cdf0e10cSrcweir	}
2657cdf0e10cSrcweir}
2658cdf0e10cSrcweir
2659cdf0e10cSrcweir########################################################################
2660cdf0e10cSrcweir# This function is a helper of function "assigning_modules_to_items"
2661cdf0e10cSrcweir########################################################################
2662cdf0e10cSrcweir
2663cdf0e10cSrcweirsub insert_for_item ($$$)
2664cdf0e10cSrcweir{
2665cdf0e10cSrcweir	my ($hash, $item, $id) = @_;
2666cdf0e10cSrcweir
2667cdf0e10cSrcweir	# print STDERR "insert '$id' for '$item'\n";
2668cdf0e10cSrcweir	if (!defined $hash->{$item})
2669cdf0e10cSrcweir	{
2670cdf0e10cSrcweir		my @gids = ();
2671cdf0e10cSrcweir		$hash->{$item} = \@gids;
2672cdf0e10cSrcweir	}
2673cdf0e10cSrcweir	my $gid_list = $hash->{$item};
2674cdf0e10cSrcweir	push @{$gid_list}, $id;
2675cdf0e10cSrcweir	$hash->{$item} = $gid_list;
2676cdf0e10cSrcweir}
2677cdf0e10cSrcweir
2678cdf0e10cSrcweirsub build_modulegids_table
2679cdf0e10cSrcweir{
2680cdf0e10cSrcweir	my ($modulesref, $itemname) = @_;
2681cdf0e10cSrcweir
2682cdf0e10cSrcweir	my %module_lookup_table = ();
2683cdf0e10cSrcweir
2684cdf0e10cSrcweir	# build map of item names to list of respective module gids
2685cdf0e10cSrcweir	# containing these items
2686cdf0e10cSrcweir	for my $onemodule (@{$modulesref})
2687cdf0e10cSrcweir	{
2688cdf0e10cSrcweir		next if ( ! defined $onemodule->{$itemname} );
2689cdf0e10cSrcweir		# these are the items contained in this module
2690cdf0e10cSrcweir		# eg. Files = (gid_a_b_c,gid_d_e_f)
2691cdf0e10cSrcweir		my $module_gids = $onemodule->{$itemname};
2692cdf0e10cSrcweir
2693cdf0e10cSrcweir		# prune outer brackets
2694cdf0e10cSrcweir		$module_gids =~ s|^\s*\(||g;
2695cdf0e10cSrcweir		$module_gids =~ s|\)\s*$||g;
2696cdf0e10cSrcweir		for my $id (split (/,/, $module_gids))
2697cdf0e10cSrcweir		{
2698cdf0e10cSrcweir			chomp $id;
2699cdf0e10cSrcweir			insert_for_item(\%module_lookup_table, lc ($id), $onemodule->{'gid'});
2700cdf0e10cSrcweir		}
2701cdf0e10cSrcweir	}
2702cdf0e10cSrcweir
2703cdf0e10cSrcweir	return \%module_lookup_table;
2704cdf0e10cSrcweir}
2705cdf0e10cSrcweir
2706cdf0e10cSrcweir########################################################################
2707cdf0e10cSrcweir# Items like files do not know their modules
2708cdf0e10cSrcweir# This function is a helper of function "assigning_modules_to_items"
2709cdf0e10cSrcweir########################################################################
2710cdf0e10cSrcweir
2711cdf0e10cSrcweirsub get_string_of_modulegids_for_itemgid
2712cdf0e10cSrcweir{
2713cdf0e10cSrcweir	my ($module_lookup_table, $modulesref, $itemgid, $itemname) = @_;
2714cdf0e10cSrcweir
2715cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::get_string_of_modulegids_for_itemgid : $#{$modulesref} : $itemgid : $itemname"); }
2716cdf0e10cSrcweir
2717cdf0e10cSrcweir	my $allmodules = "";
2718cdf0e10cSrcweir	my $haslanguagemodule = 0;
2719cdf0e10cSrcweir	my %foundmodules = ();
2720cdf0e10cSrcweir
2721cdf0e10cSrcweir	# print STDERR "lookup '" . lc($itemgid) . "'\n";
2722cdf0e10cSrcweir	my $gid_list = $module_lookup_table->{lc($itemgid)};
2723cdf0e10cSrcweir
2724cdf0e10cSrcweir	for my $gid (@{$gid_list})
2725cdf0e10cSrcweir	{
2726cdf0e10cSrcweir		$foundmodules{$gid} = 1;
2727cdf0e10cSrcweir		$allmodules = $allmodules . "," . $gid;
2728cdf0e10cSrcweir		# Is this module a language module? This info should be stored at the file.
2729cdf0e10cSrcweir		if ( exists($installer::globals::alllangmodules{$gid}) ) { $haslanguagemodule = 1; }
2730cdf0e10cSrcweir 	}
2731cdf0e10cSrcweir
2732cdf0e10cSrcweir	$allmodules =~ s/^\s*\,//;	# removing leading comma
2733cdf0e10cSrcweir
2734cdf0e10cSrcweir	# Check: All modules or no module must have flag LANGUAGEMODULE
2735cdf0e10cSrcweir	if ( $haslanguagemodule )
2736cdf0e10cSrcweir	{
2737cdf0e10cSrcweir		my $isreallylanguagemodule = installer::worker::key_in_a_is_also_key_in_b(\%foundmodules, \%installer::globals::alllangmodules);
2738cdf0e10cSrcweir		if ( ! $isreallylanguagemodule ) { installer::exiter::exit_program("ERROR: \"$itemgid\" is assigned to modules with flag \"LANGUAGEMODULE\" and also to modules without this flag! Modules: $allmodules", "get_string_of_modulegids_for_itemgid");  }
2739cdf0e10cSrcweir	}
2740cdf0e10cSrcweir
2741cdf0e10cSrcweir	# print STDERR "get_string_for_itemgid ($itemgid, $itemname) => $allmodules, $haslanguagemodule\n";
2742cdf0e10cSrcweir
2743cdf0e10cSrcweir	return ($allmodules, $haslanguagemodule);
2744cdf0e10cSrcweir}
2745cdf0e10cSrcweir
2746cdf0e10cSrcweir########################################################
2747cdf0e10cSrcweir# Items like files do not know their modules
2748cdf0e10cSrcweir# This function add the {'modules'} to these items
2749cdf0e10cSrcweir########################################################
2750cdf0e10cSrcweir
2751cdf0e10cSrcweirsub assigning_modules_to_items
2752cdf0e10cSrcweir{
2753cdf0e10cSrcweir	my ($modulesref, $itemsref, $itemname) = @_;
2754cdf0e10cSrcweir
2755cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::assigning_modules_to_items : $#{$modulesref} : $#{$itemsref} : $itemname"); }
2756cdf0e10cSrcweir
2757cdf0e10cSrcweir	my $infoline = "";
2758cdf0e10cSrcweir	my $languageassignmenterror = 0;
2759cdf0e10cSrcweir	my @languageassignmenterrors = ();
2760cdf0e10cSrcweir
2761cdf0e10cSrcweir	my $module_lookup_table = build_modulegids_table($modulesref, $itemname);
2762cdf0e10cSrcweir
2763cdf0e10cSrcweir	for my $oneitem (@{$itemsref})
2764cdf0e10cSrcweir	{
2765cdf0e10cSrcweir		my $itemgid = $oneitem->{'gid'};
2766cdf0e10cSrcweir
2767cdf0e10cSrcweir		my $styles = "";
2768cdf0e10cSrcweir		if ( $oneitem->{'Styles'} ) { $styles = $oneitem->{'Styles'}; }
2769cdf0e10cSrcweir		if (( $itemname eq "Dirs" ) && ( ! ( $styles =~ /\bCREATE\b/ ))) { next; }
2770cdf0e10cSrcweir
2771cdf0e10cSrcweir		if ( $itemgid eq "" )
2772cdf0e10cSrcweir		{
2773cdf0e10cSrcweir			installer::exiter::exit_program("ERROR in item collection: No gid for item $oneitem->{'Name'}", "assigning_modules_to_items");
2774cdf0e10cSrcweir		}
2775cdf0e10cSrcweir
2776cdf0e10cSrcweir		# every item can belong to many modules
2777cdf0e10cSrcweir
2778cdf0e10cSrcweir		my ($modulegids, $haslanguagemodule) = get_string_of_modulegids_for_itemgid($module_lookup_table, $modulesref, $itemgid, $itemname);
2779cdf0e10cSrcweir
2780cdf0e10cSrcweir		if ($modulegids eq "")
2781cdf0e10cSrcweir		{
2782cdf0e10cSrcweir			installer::exiter::exit_program("ERROR in file collection: No module found for $itemname $itemgid", "assigning_modules_to_items");
2783cdf0e10cSrcweir		}
2784cdf0e10cSrcweir
2785cdf0e10cSrcweir		$oneitem->{'modules'} = $modulegids;
2786cdf0e10cSrcweir		$oneitem->{'haslanguagemodule'} = $haslanguagemodule;
2787cdf0e10cSrcweir
2788cdf0e10cSrcweir		# Important check: "ismultilingual" and "haslanguagemodule" must have the same value !
2789cdf0e10cSrcweir		if (( $oneitem->{'ismultilingual'} ) && ( ! $oneitem->{'haslanguagemodule'} ))
2790cdf0e10cSrcweir		{
2791cdf0e10cSrcweir			$infoline = "Error: \"$oneitem->{'gid'}\" is multi lingual, but not in language pack (Assigned module: $modulegids)!\n";
2792cdf0e10cSrcweir			push( @installer::globals::globallogfileinfo, $infoline);
2793cdf0e10cSrcweir			push( @languageassignmenterrors, $infoline );
2794cdf0e10cSrcweir			$languageassignmenterror = 1;
2795cdf0e10cSrcweir		}
2796cdf0e10cSrcweir		if (( $oneitem->{'haslanguagemodule'} ) && ( ! $oneitem->{'ismultilingual'} ))
2797cdf0e10cSrcweir		{
2798cdf0e10cSrcweir			$infoline = "Error: \"$oneitem->{'gid'}\" is in language pack, but not multi lingual (Assigned module: $modulegids)!\n";
2799cdf0e10cSrcweir			push( @installer::globals::globallogfileinfo, $infoline);
2800cdf0e10cSrcweir			push( @languageassignmenterrors, $infoline );
2801cdf0e10cSrcweir			$languageassignmenterror = 1;
2802cdf0e10cSrcweir		}
2803cdf0e10cSrcweir	}
2804cdf0e10cSrcweir
2805cdf0e10cSrcweir	if ($languageassignmenterror)
2806cdf0e10cSrcweir	{
2807cdf0e10cSrcweir		for ( my $i = 0; $i <= $#languageassignmenterrors; $i++ ) { print "$languageassignmenterrors[$i]"; }
2808cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: Incorrect assignments for language packs.", "assigning_modules_to_items");
2809cdf0e10cSrcweir	}
2810cdf0e10cSrcweir
2811cdf0e10cSrcweir}
2812cdf0e10cSrcweir
2813cdf0e10cSrcweir#################################################################################################
2814cdf0e10cSrcweir# Root path (for instance /opt/openofficeorg20) needs to be added to directories, files and links
2815cdf0e10cSrcweir#################################################################################################
2816cdf0e10cSrcweir
2817cdf0e10cSrcweirsub add_rootpath_to_directories
2818cdf0e10cSrcweir{
2819cdf0e10cSrcweir	my ($dirsref, $rootpath) = @_;
2820cdf0e10cSrcweir
2821cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::add_rootpath_to_directories : $#{$dirsref} : $rootpath"); }
2822cdf0e10cSrcweir
2823cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$dirsref}; $i++ )
2824cdf0e10cSrcweir	{
2825cdf0e10cSrcweir		my $onedir = ${$dirsref}[$i];
2826cdf0e10cSrcweir		my $dir = "";
2827cdf0e10cSrcweir
2828cdf0e10cSrcweir		if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; }
2829cdf0e10cSrcweir
2830cdf0e10cSrcweir		if (!($dir =~ /\bPREDEFINED_/ ))
2831cdf0e10cSrcweir		{
2832cdf0e10cSrcweir			my $hostname = $onedir->{'HostName'};
2833cdf0e10cSrcweir			$hostname = $rootpath . $installer::globals::separator . $hostname;
2834cdf0e10cSrcweir			$onedir->{'HostName'} = $hostname;
2835cdf0e10cSrcweir		}
2836cdf0e10cSrcweir
2837cdf0e10cSrcweir		# added
2838cdf0e10cSrcweir
2839cdf0e10cSrcweir		if ( $dir =~ /\bPREDEFINED_PROGDIR\b/ )
2840cdf0e10cSrcweir		{
2841cdf0e10cSrcweir			my $hostname = $onedir->{'HostName'};
2842cdf0e10cSrcweir			if ( $hostname eq "" ) { $onedir->{'HostName'} = $rootpath; }
2843cdf0e10cSrcweir			else { $onedir->{'HostName'} = $rootpath . $installer::globals::separator . $hostname; }
2844cdf0e10cSrcweir		}
2845cdf0e10cSrcweir	}
2846cdf0e10cSrcweir}
2847cdf0e10cSrcweir
2848cdf0e10cSrcweirsub add_rootpath_to_files
2849cdf0e10cSrcweir{
2850cdf0e10cSrcweir	my ($filesref, $rootpath) = @_;
2851cdf0e10cSrcweir
2852cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::add_rootpath_to_files : $#{$filesref} : $rootpath"); }
2853cdf0e10cSrcweir
2854cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesref}; $i++ )
2855cdf0e10cSrcweir	{
2856cdf0e10cSrcweir		my $onefile = ${$filesref}[$i];
2857cdf0e10cSrcweir		my $destination = $onefile->{'destination'};
2858cdf0e10cSrcweir		$destination = $rootpath . $installer::globals::separator . $destination;
2859cdf0e10cSrcweir		$onefile->{'destination'} = $destination;
2860cdf0e10cSrcweir	}
2861cdf0e10cSrcweir}
2862cdf0e10cSrcweir
2863cdf0e10cSrcweirsub add_rootpath_to_links
2864cdf0e10cSrcweir{
2865cdf0e10cSrcweir	my ($linksref, $rootpath) = @_;
2866cdf0e10cSrcweir
2867cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::scriptitems::add_rootpath_to_links : $#{$linksref} : $rootpath"); }
2868cdf0e10cSrcweir
2869cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$linksref}; $i++ )
2870cdf0e10cSrcweir	{
2871cdf0e10cSrcweir		my $onelink = ${$linksref}[$i];
2872cdf0e10cSrcweir		my $styles = $onelink->{'Styles'};
2873cdf0e10cSrcweir
2874cdf0e10cSrcweir		my $destination = $onelink->{'destination'};
2875cdf0e10cSrcweir		$destination = $rootpath . $installer::globals::separator . $destination;
2876cdf0e10cSrcweir		$onelink->{'destination'} = $destination;
2877cdf0e10cSrcweir
2878cdf0e10cSrcweir		if (!($styles =~ /\bRELATIVE\b/ )) # for absolute links
2879cdf0e10cSrcweir		{
2880cdf0e10cSrcweir			my $destinationfile = $onelink->{'destinationfile'};
2881cdf0e10cSrcweir			$destinationfile = $rootpath . $installer::globals::separator . $destinationfile;
2882cdf0e10cSrcweir			$onelink->{'destinationfile'} = $destinationfile;
2883cdf0e10cSrcweir		}
2884cdf0e10cSrcweir	}
2885cdf0e10cSrcweir}
2886cdf0e10cSrcweir
2887cdf0e10cSrcweir#################################################################################
2888cdf0e10cSrcweir# Collecting all parent gids
2889cdf0e10cSrcweir#################################################################################
2890cdf0e10cSrcweir
2891cdf0e10cSrcweirsub collect_all_parent_feature
2892cdf0e10cSrcweir{
2893cdf0e10cSrcweir	my ($modulesref) = @_;
2894cdf0e10cSrcweir
2895cdf0e10cSrcweir	my @allparents = ();
2896cdf0e10cSrcweir
2897cdf0e10cSrcweir	my $found_root_module = 0;
2898cdf0e10cSrcweir
2899cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2900cdf0e10cSrcweir	{
2901cdf0e10cSrcweir		my $onefeature = ${$modulesref}[$i];
2902cdf0e10cSrcweir
2903cdf0e10cSrcweir		my $parentgid = "";
2904cdf0e10cSrcweir		if ( $onefeature->{'ParentID'} )
2905cdf0e10cSrcweir		{
2906cdf0e10cSrcweir			$parentgid = $onefeature->{'ParentID'};
2907cdf0e10cSrcweir		}
2908cdf0e10cSrcweir
2909cdf0e10cSrcweir		if ( $parentgid ne "" )
2910cdf0e10cSrcweir		{
2911cdf0e10cSrcweir			if (! installer::existence::exists_in_array($parentgid, \@allparents))
2912cdf0e10cSrcweir			{
2913cdf0e10cSrcweir				push(@allparents, $parentgid);
2914cdf0e10cSrcweir			}
2915cdf0e10cSrcweir		}
2916cdf0e10cSrcweir
2917cdf0e10cSrcweir		# Setting the global root module
2918cdf0e10cSrcweir
2919cdf0e10cSrcweir		if ( $parentgid eq "" )
2920cdf0e10cSrcweir		{
2921cdf0e10cSrcweir			if ( $found_root_module ) { installer::exiter::exit_program("ERROR: Only one module without ParentID or with empty ParentID allowed ($installer::globals::rootmodulegid, $onefeature->{'gid'}).", "collect_all_parent_feature"); }
2922cdf0e10cSrcweir			$installer::globals::rootmodulegid = $onefeature->{'gid'};
2923cdf0e10cSrcweir			$found_root_module = 1;
2924cdf0e10cSrcweir			$infoline = "Setting Root Module: $installer::globals::rootmodulegid\n";
2925cdf0e10cSrcweir			push( @installer::globals::globallogfileinfo, $infoline);
2926cdf0e10cSrcweir		}
2927cdf0e10cSrcweir
2928cdf0e10cSrcweir		if ( ! $found_root_module ) { installer::exiter::exit_program("ERROR: Could not define root module. No module without ParentID or with empty ParentID exists.", "collect_all_parent_feature"); }
2929cdf0e10cSrcweir
2930cdf0e10cSrcweir	}
2931cdf0e10cSrcweir
2932cdf0e10cSrcweir	return \@allparents;
2933cdf0e10cSrcweir}
2934cdf0e10cSrcweir
2935cdf0e10cSrcweir#################################################################################
2936cdf0e10cSrcweir# Checking for every feature, whether it has children
2937cdf0e10cSrcweir#################################################################################
2938cdf0e10cSrcweir
2939cdf0e10cSrcweirsub set_children_flag
2940cdf0e10cSrcweir{
2941cdf0e10cSrcweir	my ($modulesref) = @_;
2942cdf0e10cSrcweir
2943cdf0e10cSrcweir	my $allparents = collect_all_parent_feature($modulesref);
2944cdf0e10cSrcweir
2945cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2946cdf0e10cSrcweir	{
2947cdf0e10cSrcweir		my $onefeature = ${$modulesref}[$i];
2948cdf0e10cSrcweir		my $gid = $onefeature->{'gid'};
2949cdf0e10cSrcweir
2950cdf0e10cSrcweir		# is this gid a parent?
2951cdf0e10cSrcweir
2952cdf0e10cSrcweir		if ( installer::existence::exists_in_array($gid, $allparents) )
2953cdf0e10cSrcweir		{
2954cdf0e10cSrcweir			$onefeature->{'has_children'} = 1;
2955cdf0e10cSrcweir		}
2956cdf0e10cSrcweir		else
2957cdf0e10cSrcweir		{
2958cdf0e10cSrcweir			$onefeature->{'has_children'} = 0;
2959cdf0e10cSrcweir		}
2960cdf0e10cSrcweir	}
2961cdf0e10cSrcweir}
2962cdf0e10cSrcweir
2963cdf0e10cSrcweir#################################################################################
2964cdf0e10cSrcweir# All modules, that use a template module, do now get the assignments of
2965cdf0e10cSrcweir# the template module.
2966cdf0e10cSrcweir#################################################################################
2967cdf0e10cSrcweir
2968cdf0e10cSrcweirsub resolve_assigned_modules
2969cdf0e10cSrcweir{
2970cdf0e10cSrcweir	my ($modulesref) = @_;
2971cdf0e10cSrcweir
2972cdf0e10cSrcweir	# collecting all template modules
2973cdf0e10cSrcweir
2974cdf0e10cSrcweir	my %directaccess = ();
2975cdf0e10cSrcweir
2976cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2977cdf0e10cSrcweir	{
2978cdf0e10cSrcweir		my $onefeature = ${$modulesref}[$i];
2979cdf0e10cSrcweir		my $styles = "";
2980cdf0e10cSrcweir		if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
2981cdf0e10cSrcweir		if ( $styles =~ /\bTEMPLATEMODULE\b/ ) { $directaccess{$onefeature->{'gid'}} = $onefeature; }
2982cdf0e10cSrcweir
2983cdf0e10cSrcweir		# also looking for module with flag ROOT_BRAND_PACKAGE, to save is for further usage
2984cdf0e10cSrcweir		if ( $styles =~ /\bROOT_BRAND_PACKAGE\b/ )
2985cdf0e10cSrcweir		{
2986cdf0e10cSrcweir			$installer::globals::rootbrandpackage = $onefeature->{'gid'};
2987cdf0e10cSrcweir			$installer::globals::rootbrandpackageset = 1;
2988cdf0e10cSrcweir		}
2989cdf0e10cSrcweir	}
2990cdf0e10cSrcweir
2991cdf0e10cSrcweir	# looking, where template modules are assigned
2992cdf0e10cSrcweir
2993cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
2994cdf0e10cSrcweir	{
2995cdf0e10cSrcweir		my $onefeature = ${$modulesref}[$i];
2996cdf0e10cSrcweir		if ( $onefeature->{'Assigns'} )
2997cdf0e10cSrcweir		{
2998cdf0e10cSrcweir			my $templategid = $onefeature->{'Assigns'};
2999cdf0e10cSrcweir
3000cdf0e10cSrcweir			if ( ! exists($directaccess{$templategid}) )
3001cdf0e10cSrcweir			{
3002cdf0e10cSrcweir				installer::exiter::exit_program("ERROR: Did not find definition of assigned template module \"$templategid\"", "resolve_assigned_modules");
3003cdf0e10cSrcweir			}
3004cdf0e10cSrcweir
3005cdf0e10cSrcweir			# Currently no merging of Files, Dirs, ...
3006cdf0e10cSrcweir			# This has to be included here, if it is required
3007cdf0e10cSrcweir			my $item;
3008cdf0e10cSrcweir			foreach $item (@installer::globals::items_at_modules)
3009cdf0e10cSrcweir			{
3010cdf0e10cSrcweir				if ( exists($directaccess{$templategid}->{$item}) ) { $onefeature->{$item} = $directaccess{$templategid}->{$item}; }
3011cdf0e10cSrcweir			}
3012cdf0e10cSrcweir		}
3013cdf0e10cSrcweir	}
3014cdf0e10cSrcweir}
3015cdf0e10cSrcweir
3016cdf0e10cSrcweir#################################################################################
3017cdf0e10cSrcweir# Removing the template modules from the list, after all
3018cdf0e10cSrcweir# assignments are transferred to the "real" modules.
3019cdf0e10cSrcweir#################################################################################
3020cdf0e10cSrcweir
3021cdf0e10cSrcweirsub remove_template_modules
3022cdf0e10cSrcweir{
3023cdf0e10cSrcweir	my ($modulesref) = @_;
3024cdf0e10cSrcweir
3025cdf0e10cSrcweir	my @modules = ();
3026cdf0e10cSrcweir
3027cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
3028cdf0e10cSrcweir	{
3029cdf0e10cSrcweir		my $onefeature = ${$modulesref}[$i];
3030cdf0e10cSrcweir		my $styles = "";
3031cdf0e10cSrcweir		if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
3032cdf0e10cSrcweir		if ( $styles =~ /\bTEMPLATEMODULE\b/ ) { next; }
3033cdf0e10cSrcweir
3034cdf0e10cSrcweir		push(@modules, $onefeature);
3035cdf0e10cSrcweir	}
3036cdf0e10cSrcweir
3037cdf0e10cSrcweir	return \@modules;
3038cdf0e10cSrcweir}
3039cdf0e10cSrcweir
3040cdf0e10cSrcweir#################################################################################
3041cdf0e10cSrcweir# Collecting all modules with flag LANGUAGEMODULE in a global
3042cdf0e10cSrcweir# collector.
3043cdf0e10cSrcweir#################################################################################
3044cdf0e10cSrcweir
3045cdf0e10cSrcweirsub collect_all_languagemodules
3046cdf0e10cSrcweir{
3047cdf0e10cSrcweir	my ($modulesref) = @_;
3048cdf0e10cSrcweir
3049cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
3050cdf0e10cSrcweir	{
3051cdf0e10cSrcweir		my $onefeature = ${$modulesref}[$i];
3052cdf0e10cSrcweir		my $styles = "";
3053cdf0e10cSrcweir		if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
3054cdf0e10cSrcweir		if ( $styles =~ /\bLANGUAGEMODULE\b/ )
3055cdf0e10cSrcweir		{
3056cdf0e10cSrcweir			if ( ! exists($onefeature->{'Language'}) ) { installer::exiter::exit_program("ERROR: \"$onefeature->{'gid'}\" has flag LANGUAGEMODULE, but does not know its language!", "collect_all_languagemodules"); }
3057cdf0e10cSrcweir			$installer::globals::alllangmodules{$onefeature->{'gid'}} = $onefeature->{'Language'};
3058cdf0e10cSrcweir			# Collecting also the english names, that are used for nsis unpack directory for language packs
3059cdf0e10cSrcweir			my $lang = $onefeature->{'Language'};
3060cdf0e10cSrcweir			my $name = "";
3061cdf0e10cSrcweir			foreach my $localkey ( keys %{$onefeature} )
3062cdf0e10cSrcweir			{
3063cdf0e10cSrcweir				if ( $localkey =~ /^\s*Name\s*\(\s*en-US\s*\)\s*$/ )
3064cdf0e10cSrcweir				{
3065cdf0e10cSrcweir					$installer::globals::all_english_languagestrings{$lang} = $onefeature->{$localkey};
3066cdf0e10cSrcweir				}
3067cdf0e10cSrcweir			}
3068cdf0e10cSrcweir		}
3069cdf0e10cSrcweir	}
3070cdf0e10cSrcweir}
3071cdf0e10cSrcweir
3072cdf0e10cSrcweir#################################################################################
3073cdf0e10cSrcweir# Selecting from all collected english language strings those, that are really
3074cdf0e10cSrcweir# required in this installation set.
3075cdf0e10cSrcweir#################################################################################
3076cdf0e10cSrcweir
3077cdf0e10cSrcweirsub select_required_language_strings
3078cdf0e10cSrcweir{
3079cdf0e10cSrcweir	my ($modulesref) = @_;
3080cdf0e10cSrcweir
3081cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$modulesref}; $i++ )
3082cdf0e10cSrcweir	{
3083cdf0e10cSrcweir		my $onefeature = ${$modulesref}[$i];
3084cdf0e10cSrcweir		my $styles = "";
3085cdf0e10cSrcweir		if ( $onefeature->{'Styles'} ) { $styles = $onefeature->{'Styles'}; }
3086cdf0e10cSrcweir		if ( $styles =~ /\bLANGUAGEMODULE\b/ )
3087cdf0e10cSrcweir		{
3088cdf0e10cSrcweir			if ( ! exists($onefeature->{'Language'}) ) { installer::exiter::exit_program("ERROR: \"$onefeature->{'gid'}\" has flag LANGUAGEMODULE, but does not know its language!", "select_required_language_strings"); }
3089cdf0e10cSrcweir			my $lang = $onefeature->{'Language'};
3090cdf0e10cSrcweir
3091cdf0e10cSrcweir			if (( exists($installer::globals::all_english_languagestrings{$lang}) ) && ( ! exists($installer::globals::all_required_english_languagestrings{$lang}) ))
3092cdf0e10cSrcweir			{
3093cdf0e10cSrcweir				$installer::globals::all_required_english_languagestrings{$lang} = $installer::globals::all_english_languagestrings{$lang};
3094cdf0e10cSrcweir			}
3095cdf0e10cSrcweir		}
3096cdf0e10cSrcweir	}
3097cdf0e10cSrcweir}
3098cdf0e10cSrcweir
3099cdf0e10cSrcweir#####################################################################################
3100cdf0e10cSrcweir# Unixlinks are not always required. For Linux RPMs and Solaris Packages they are
3101cdf0e10cSrcweir# created dynamically. Exception: For package formats "installed" or "archive".
3102cdf0e10cSrcweir# In scp2 this unixlinks have the flag LAYERLINK.
3103cdf0e10cSrcweir#####################################################################################
3104cdf0e10cSrcweir
3105cdf0e10cSrcweirsub filter_layerlinks_from_unixlinks
3106cdf0e10cSrcweir{
3107cdf0e10cSrcweir	my ( $unixlinksref ) = @_;
3108cdf0e10cSrcweir
3109cdf0e10cSrcweir	my @alllinks = ();
3110cdf0e10cSrcweir
3111cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$unixlinksref}; $i++ )
3112cdf0e10cSrcweir	{
3113cdf0e10cSrcweir		my $isrequired = 1;
3114cdf0e10cSrcweir
3115cdf0e10cSrcweir		my $onelink = ${$unixlinksref}[$i];
3116cdf0e10cSrcweir		my $styles = "";
3117cdf0e10cSrcweir		if ( $onelink->{'Styles'} ) { $styles = $onelink->{'Styles'}; }
3118cdf0e10cSrcweir
3119cdf0e10cSrcweir		if ( $styles =~ /\bLAYERLINK\b/ )
3120cdf0e10cSrcweir		{
3121cdf0e10cSrcweir			# Platforms, that do not need the layer links
3122cdf0e10cSrcweir			if (( $installer::globals::islinuxrpmbuild ) || ( $installer::globals::issolarispkgbuild ))
3123cdf0e10cSrcweir			{
3124cdf0e10cSrcweir				$isrequired = 0;
3125cdf0e10cSrcweir			}
3126cdf0e10cSrcweir
3127cdf0e10cSrcweir			# Package formats, that need the layer link (platform independent)
3128cdf0e10cSrcweir			if (( $installer::globals::packageformat eq "installed" ) || ( $installer::globals::packageformat eq "archive" ))
3129cdf0e10cSrcweir			{
3130cdf0e10cSrcweir				$isrequired = 1;
3131cdf0e10cSrcweir			}
3132cdf0e10cSrcweir		}
3133cdf0e10cSrcweir
3134cdf0e10cSrcweir		if ( $isrequired ) { push(@alllinks, $onelink); }
3135cdf0e10cSrcweir	}
3136cdf0e10cSrcweir
3137cdf0e10cSrcweir	return \@alllinks;
3138cdf0e10cSrcweir}
3139cdf0e10cSrcweir
3140cdf0e10cSrcweir1;
3141