1cdf0e10cSrcweir#*************************************************************************
2cdf0e10cSrcweir#
3cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4cdf0e10cSrcweir#
5cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates.
6cdf0e10cSrcweir#
7cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite
8cdf0e10cSrcweir#
9cdf0e10cSrcweir# This file is part of OpenOffice.org.
10cdf0e10cSrcweir#
11cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify
12cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3
13cdf0e10cSrcweir# only, as published by the Free Software Foundation.
14cdf0e10cSrcweir#
15cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful,
16cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of
17cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details
19cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code).
20cdf0e10cSrcweir#
21cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License
22cdf0e10cSrcweir# version 3 along with OpenOffice.org.  If not, see
23cdf0e10cSrcweir# <http://www.openoffice.org/license.html>
24cdf0e10cSrcweir# for a copy of the LGPLv3 License.
25cdf0e10cSrcweir#
26cdf0e10cSrcweir#*************************************************************************
27cdf0e10cSrcweir
28cdf0e10cSrcweirpackage installer::epmfile;
29cdf0e10cSrcweir
30cdf0e10cSrcweiruse Cwd;
31cdf0e10cSrcweiruse installer::converter;
32cdf0e10cSrcweiruse installer::existence;
33cdf0e10cSrcweiruse installer::exiter;
34cdf0e10cSrcweiruse installer::files;
35cdf0e10cSrcweiruse installer::globals;
36cdf0e10cSrcweiruse installer::logger;
37cdf0e10cSrcweiruse installer::packagelist;
38cdf0e10cSrcweiruse installer::pathanalyzer;
39cdf0e10cSrcweiruse installer::remover;
40cdf0e10cSrcweiruse installer::scriptitems;
41cdf0e10cSrcweiruse installer::systemactions;
42cdf0e10cSrcweiruse installer::worker;
43cdf0e10cSrcweiruse POSIX;
44cdf0e10cSrcweir
45cdf0e10cSrcweir############################################################################
46cdf0e10cSrcweir# Reading the package map to find Solaris package names for
47cdf0e10cSrcweir# the corresponding abbreviations
48cdf0e10cSrcweir############################################################################
49cdf0e10cSrcweir
50cdf0e10cSrcweirsub read_packagemap
51cdf0e10cSrcweir{
52cdf0e10cSrcweir	my ($allvariables, $includepatharrayref, $languagesarrayref) = @_;
53cdf0e10cSrcweir
54cdf0e10cSrcweir	my $packagemapname = "";
55cdf0e10cSrcweir	if ( $allvariables->{'PACKAGEMAP'} ) { $packagemapname = $allvariables->{'PACKAGEMAP'}; }
56cdf0e10cSrcweir	if ( $packagemapname eq "" ) { installer::exiter::exit_program("ERROR: Property PACKAGEMAP must be defined!", "read_packagemap"); }
57cdf0e10cSrcweir
58cdf0e10cSrcweir	my $infoline = "\n\nCollected abbreviations and package names:\n";
59cdf0e10cSrcweir	push(@installer::globals::logfileinfo, $infoline);
60cdf0e10cSrcweir
61cdf0e10cSrcweir	# Can be a comma separated list. All files have to be found in include pathes
62cdf0e10cSrcweir	my $allpackagemapnames = installer::converter::convert_stringlist_into_hash(\$packagemapname, ",");
63cdf0e10cSrcweir	foreach my $onepackagemapname ( keys %{$allpackagemapnames} )
64cdf0e10cSrcweir	{
65cdf0e10cSrcweir		my $packagemapref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$onepackagemapname, $includepatharrayref, 0);
66cdf0e10cSrcweir
67cdf0e10cSrcweir		if ( $$packagemapref eq "" ) { installer::exiter::exit_program("ERROR: Could not find package map file \"$onepackagemapname\" (propery PACKAGEMAP)!", "read_packagemap"); }
68cdf0e10cSrcweir
69cdf0e10cSrcweir		my $packagemapcontent = installer::files::read_file($$packagemapref);
70cdf0e10cSrcweir
71cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$packagemapcontent}; $i++ )
72cdf0e10cSrcweir		{
73cdf0e10cSrcweir			my $line = ${$packagemapcontent}[$i];
74cdf0e10cSrcweir
75cdf0e10cSrcweir			if ( $line =~ /^\s*\#/ ) { next; }  # comment line
76cdf0e10cSrcweir			if ( $line =~ /^\s*$/ ) { next; }  # empty line
77cdf0e10cSrcweir
78cdf0e10cSrcweir			if ( $line =~ /^\s*(.*?)\t(.*?)\s*$/ )
79cdf0e10cSrcweir			{
80cdf0e10cSrcweir				my $abbreviation = $1;
81cdf0e10cSrcweir				my $packagename = $2;
82cdf0e10cSrcweir				installer::packagelist::resolve_packagevariables(\$abbreviation, $allvariables, 0);
83cdf0e10cSrcweir				installer::packagelist::resolve_packagevariables(\$packagename, $allvariables, 0);
84cdf0e10cSrcweir
85cdf0e10cSrcweir				# Special handling for language strings %LANGUAGESTRING
86cdf0e10cSrcweir
87cdf0e10cSrcweir				if (( $abbreviation =~ /\%LANGUAGESTRING/ ) || ( $packagename =~ /\%LANGUAGESTRING/ ))
88cdf0e10cSrcweir				{
89cdf0e10cSrcweir					foreach my $onelang ( @{$languagesarrayref} )
90cdf0e10cSrcweir					{
91cdf0e10cSrcweir                        my $local_abbreviation = $abbreviation;
92cdf0e10cSrcweir                        my $local_packagename = $packagename;
93cdf0e10cSrcweir						$local_abbreviation =~ s/\%LANGUAGESTRING/$onelang/g;
94cdf0e10cSrcweir						$local_packagename =~ s/\%LANGUAGESTRING/$onelang/g;
95cdf0e10cSrcweir
96cdf0e10cSrcweir                        # Logging all abbreviations and packagenames
97cdf0e10cSrcweir                        $infoline = "$onelang : $local_abbreviation : $local_packagename\n";
98cdf0e10cSrcweir                        push(@installer::globals::logfileinfo, $infoline);
99cdf0e10cSrcweir
100cdf0e10cSrcweir						if ( exists($installer::globals::dependfilenames{$local_abbreviation}) )
101cdf0e10cSrcweir						{
102cdf0e10cSrcweir							installer::exiter::exit_program("ERROR: Packagename for  Solaris package $local_abbreviation already defined ($installer::globals::dependfilenames{$local_abbreviation})!", "read_packagemap");
103cdf0e10cSrcweir						}
104cdf0e10cSrcweir						else
105cdf0e10cSrcweir						{
106cdf0e10cSrcweir							$installer::globals::dependfilenames{$local_abbreviation} = $local_packagename;
107cdf0e10cSrcweir						}
108cdf0e10cSrcweir					}
109cdf0e10cSrcweir				}
110cdf0e10cSrcweir				else
111cdf0e10cSrcweir				{
112cdf0e10cSrcweir                    # Logging all abbreviations and packagenames
113cdf0e10cSrcweir                    $infoline = "$abbreviation : $packagename\n";
114cdf0e10cSrcweir                    push(@installer::globals::logfileinfo, $infoline);
115cdf0e10cSrcweir
116cdf0e10cSrcweir					if ( exists($installer::globals::dependfilenames{$abbreviation}) )
117cdf0e10cSrcweir					{
118cdf0e10cSrcweir						installer::exiter::exit_program("ERROR: Packagename for  Solaris package $abbreviation already defined ($installer::globals::dependfilenames{$abbreviation})!", "read_packagemap");
119cdf0e10cSrcweir					}
120cdf0e10cSrcweir					else
121cdf0e10cSrcweir					{
122cdf0e10cSrcweir						$installer::globals::dependfilenames{$abbreviation} = $packagename;
123cdf0e10cSrcweir					}
124cdf0e10cSrcweir				}
125cdf0e10cSrcweir			}
126cdf0e10cSrcweir			else
127cdf0e10cSrcweir			{
128cdf0e10cSrcweir				my $errorline = $i + 1;
129cdf0e10cSrcweir				installer::exiter::exit_program("ERROR: Wrong syntax in file \"$onepackagemapname\" (line $errorline)!", "read_packagemap");
130cdf0e10cSrcweir			}
131cdf0e10cSrcweir		}
132cdf0e10cSrcweir	}
133cdf0e10cSrcweir
134cdf0e10cSrcweir	$infoline = "\n\n";
135cdf0e10cSrcweir	push(@installer::globals::logfileinfo, $infoline);
136cdf0e10cSrcweir
137cdf0e10cSrcweir}
138cdf0e10cSrcweir
139cdf0e10cSrcweir############################################################################
140cdf0e10cSrcweir# The header file contains the strings for the epm header in all languages
141cdf0e10cSrcweir############################################################################
142cdf0e10cSrcweir
143cdf0e10cSrcweirsub get_string_from_headerfile
144cdf0e10cSrcweir{
145cdf0e10cSrcweir	my ($searchstring, $language, $fileref) = @_;
146cdf0e10cSrcweir
147cdf0e10cSrcweir	my $returnstring  = "";
148cdf0e10cSrcweir	my $onestring  = "";
149cdf0e10cSrcweir	my $englishstring  = "";
150cdf0e10cSrcweir	my $foundblock = 0;
151cdf0e10cSrcweir	my $foundstring = 0;
152cdf0e10cSrcweir	my $foundenglishstring = 0;
153cdf0e10cSrcweir	my $englishidentifier = "01";
154cdf0e10cSrcweir
155cdf0e10cSrcweir	$searchstring = "[" . $searchstring . "]";
156cdf0e10cSrcweir
157cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$fileref}; $i++ )
158cdf0e10cSrcweir	{
159cdf0e10cSrcweir		my $line = ${$fileref}[$i];
160cdf0e10cSrcweir
161cdf0e10cSrcweir		if ( $line =~ /^\s*\Q$searchstring\E\s*$/ )
162cdf0e10cSrcweir		{
163cdf0e10cSrcweir			$foundblock = 1;
164cdf0e10cSrcweir			my $counter = $i + 1;
165cdf0e10cSrcweir
166cdf0e10cSrcweir			$line = ${$fileref}[$counter];
167cdf0e10cSrcweir
168cdf0e10cSrcweir			# Beginning of the next block oder Dateiende
169cdf0e10cSrcweir
170cdf0e10cSrcweir			while ((!($line =~ /^\s*\[\s*\w+\s*\]\s*$/ )) && ( $counter <= $#{$fileref} ))
171cdf0e10cSrcweir			{
172cdf0e10cSrcweir				if ( $line =~ /^\s*\Q$language\E\s+\=\s*\"(.*)\"\s*$/ )
173cdf0e10cSrcweir				{
174cdf0e10cSrcweir					$onestring = $1;
175cdf0e10cSrcweir					$foundstring = 1;
176cdf0e10cSrcweir					last;
177cdf0e10cSrcweir				}
178cdf0e10cSrcweir
179cdf0e10cSrcweir				if ( $line =~ /^\s*\Q$englishidentifier\E\s+\=\s*\"(.*)\"\s*$/ )
180cdf0e10cSrcweir				{
181cdf0e10cSrcweir					$englishstring = $1;
182cdf0e10cSrcweir					$foundenglishstring = 1;
183cdf0e10cSrcweir				}
184cdf0e10cSrcweir
185cdf0e10cSrcweir				$counter++;
186cdf0e10cSrcweir				$line = ${$fileref}[$counter];
187cdf0e10cSrcweir			}
188cdf0e10cSrcweir		}
189cdf0e10cSrcweir	}
190cdf0e10cSrcweir
191cdf0e10cSrcweir	if ( $foundstring )
192cdf0e10cSrcweir	{
193cdf0e10cSrcweir		$returnstring = $onestring;
194cdf0e10cSrcweir	}
195cdf0e10cSrcweir	else
196cdf0e10cSrcweir	{
197cdf0e10cSrcweir		if ( $foundenglishstring )
198cdf0e10cSrcweir		{
199cdf0e10cSrcweir			$returnstring = $englishstring;
200cdf0e10cSrcweir		}
201cdf0e10cSrcweir		else
202cdf0e10cSrcweir		{
203cdf0e10cSrcweir			installer::exiter::exit_program("ERROR: No string found for $searchstring in epm header file (-h)", "get_string_from_headerfile");
204cdf0e10cSrcweir		}
205cdf0e10cSrcweir	}
206cdf0e10cSrcweir
207cdf0e10cSrcweir	return \$returnstring;
208cdf0e10cSrcweir}
209cdf0e10cSrcweir
210cdf0e10cSrcweir##########################################################
211cdf0e10cSrcweir# Filling the epm file with directories, files and links
212cdf0e10cSrcweir##########################################################
213cdf0e10cSrcweir
214cdf0e10cSrcweirsub put_directories_into_epmfile
215cdf0e10cSrcweir{
216cdf0e10cSrcweir	my ($directoriesarrayref, $epmfileref, $allvariables, $packagerootpath) = @_;
217cdf0e10cSrcweir	my $group = "bin";
218cdf0e10cSrcweir
219cdf0e10cSrcweir	if ( $installer::globals::islinuxbuild )
220cdf0e10cSrcweir	{
221cdf0e10cSrcweir		$group = "root";
222cdf0e10cSrcweir	}
223cdf0e10cSrcweir
224cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$directoriesarrayref}; $i++ )
225cdf0e10cSrcweir	{
226cdf0e10cSrcweir		my $onedir = ${$directoriesarrayref}[$i];
227cdf0e10cSrcweir		my $dir = "";
228cdf0e10cSrcweir
229cdf0e10cSrcweir		if ( $onedir->{'Dir'} ) { $dir = $onedir->{'Dir'}; }
230cdf0e10cSrcweir
231cdf0e10cSrcweir		# if (!($dir =~ /\bPREDEFINED_/ ))
232cdf0e10cSrcweir		if ((!($dir =~ /\bPREDEFINED_/ )) || ( $dir =~ /\bPREDEFINED_PROGDIR\b/ ))
233cdf0e10cSrcweir		{
234cdf0e10cSrcweir			my $hostname = $onedir->{'HostName'};
235cdf0e10cSrcweir
236cdf0e10cSrcweir			# not including simple directory "/opt"
237cdf0e10cSrcweir			# if (( $allvariables->{'SETSTATICPATH'} ) && ( $hostname eq $packagerootpath )) { next; }
238cdf0e10cSrcweir
239cdf0e10cSrcweir			my $line = "d 755 root $group $hostname -\n";
240cdf0e10cSrcweir
241cdf0e10cSrcweir			push(@{$epmfileref}, $line)
242cdf0e10cSrcweir		}
243cdf0e10cSrcweir	}
244cdf0e10cSrcweir}
245cdf0e10cSrcweir
246cdf0e10cSrcweirsub put_files_into_epmfile
247cdf0e10cSrcweir{
248cdf0e10cSrcweir	my ($filesinproductarrayref, $epmfileref) = @_;
249cdf0e10cSrcweir
250cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesinproductarrayref}; $i++ )
251cdf0e10cSrcweir	{
252cdf0e10cSrcweir		my $onefile = ${$filesinproductarrayref}[$i];
253cdf0e10cSrcweir
254cdf0e10cSrcweir		my $unixrights = $onefile->{'UnixRights'};
255cdf0e10cSrcweir		my $destination = $onefile->{'destination'};
256cdf0e10cSrcweir		my $sourcepath = $onefile->{'sourcepath'};
257cdf0e10cSrcweir
258cdf0e10cSrcweir		my $filetype = "f";
259cdf0e10cSrcweir		my $styles = "";
260cdf0e10cSrcweir		if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
261cdf0e10cSrcweir		if ( $styles =~ /\bCONFIGFILE\b/ ) { $filetype = "c"; }
262cdf0e10cSrcweir
263cdf0e10cSrcweir		my $group = "bin";
264cdf0e10cSrcweir		if ( $installer::globals::islinuxbuild ) { $group = "root"; }
265cdf0e10cSrcweir		if (( $installer::globals::issolarisbuild ) && ( $onefile->{'SolarisGroup'} )) { $group = $onefile->{'SolarisGroup'}; }
266cdf0e10cSrcweir
267cdf0e10cSrcweir		my $line = "$filetype $unixrights root $group $destination $sourcepath\n";
268cdf0e10cSrcweir
269cdf0e10cSrcweir		push(@{$epmfileref}, $line);
270cdf0e10cSrcweir	}
271cdf0e10cSrcweir}
272cdf0e10cSrcweir
273cdf0e10cSrcweirsub put_links_into_epmfile
274cdf0e10cSrcweir{
275cdf0e10cSrcweir	my ($linksinproductarrayref, $epmfileref) = @_;
276cdf0e10cSrcweir	my $group = "bin";
277cdf0e10cSrcweir
278cdf0e10cSrcweir	if ( $installer::globals::islinuxbuild )
279cdf0e10cSrcweir	{
280cdf0e10cSrcweir		$group = "root";
281cdf0e10cSrcweir	}
282cdf0e10cSrcweir
283cdf0e10cSrcweir
284cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$linksinproductarrayref}; $i++ )
285cdf0e10cSrcweir	{
286cdf0e10cSrcweir		my $onelink = ${$linksinproductarrayref}[$i];
287cdf0e10cSrcweir		my $destination = $onelink->{'destination'};
288cdf0e10cSrcweir		my $destinationfile = $onelink->{'destinationfile'};
289cdf0e10cSrcweir
290cdf0e10cSrcweir		my $line = "l 000 root $group $destination $destinationfile\n";
291cdf0e10cSrcweir
292cdf0e10cSrcweir		push(@{$epmfileref}, $line)
293cdf0e10cSrcweir	}
294cdf0e10cSrcweir}
295cdf0e10cSrcweir
296cdf0e10cSrcweirsub put_unixlinks_into_epmfile
297cdf0e10cSrcweir{
298cdf0e10cSrcweir	my ($unixlinksinproductarrayref, $epmfileref) = @_;
299cdf0e10cSrcweir	my $group = "bin";
300cdf0e10cSrcweir
301cdf0e10cSrcweir	if ( $installer::globals::islinuxbuild ) { $group = "root";	}
302cdf0e10cSrcweir
303cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$unixlinksinproductarrayref}; $i++ )
304cdf0e10cSrcweir	{
305cdf0e10cSrcweir		my $onelink = ${$unixlinksinproductarrayref}[$i];
306cdf0e10cSrcweir		my $destination = $onelink->{'destination'};
307cdf0e10cSrcweir		my $target = $onelink->{'Target'};
308cdf0e10cSrcweir
309cdf0e10cSrcweir		my $line = "l 000 root $group $destination $target\n";
310cdf0e10cSrcweir
311cdf0e10cSrcweir		push(@{$epmfileref}, $line)
312cdf0e10cSrcweir	}
313cdf0e10cSrcweir}
314cdf0e10cSrcweir
315cdf0e10cSrcweir###############################################
316cdf0e10cSrcweir# Creating epm header file
317cdf0e10cSrcweir###############################################
318cdf0e10cSrcweir
319cdf0e10cSrcweirsub create_epm_header
320cdf0e10cSrcweir{
321cdf0e10cSrcweir	my ($variableshashref, $filesinproduct, $languagesref, $onepackage) = @_;
322cdf0e10cSrcweir
323cdf0e10cSrcweir	my @epmheader = ();
324cdf0e10cSrcweir
325cdf0e10cSrcweir	my ($licensefilename, $readmefilename);
326cdf0e10cSrcweir
327cdf0e10cSrcweir	my $foundlicensefile = 0;
328cdf0e10cSrcweir	my $foundreadmefile = 0;
329cdf0e10cSrcweir
330cdf0e10cSrcweir	my $line = "";
331cdf0e10cSrcweir	my $infoline = "";
332cdf0e10cSrcweir
333cdf0e10cSrcweir	# %product OpenOffice.org Software
334cdf0e10cSrcweir	# %version 2.0
335cdf0e10cSrcweir	# %description A really great software
336cdf0e10cSrcweir	# %copyright 1999-2003 by OOo
337cdf0e10cSrcweir	# %vendor OpenOffice.org
338cdf0e10cSrcweir	# %license /test/replace/01/LICENSE01
339cdf0e10cSrcweir	# %readme /test/replace/01/README01
340cdf0e10cSrcweir	# %requires foo
341cdf0e10cSrcweir	# %provides bar
342cdf0e10cSrcweir
343cdf0e10cSrcweir	# The first language in the languages array determines the language of license and readme file
344cdf0e10cSrcweir
345cdf0e10cSrcweir	my $searchlanguage = ${$languagesref}[0];
346cdf0e10cSrcweir
347cdf0e10cSrcweir	# using the description for the %product line in the epm list file
348cdf0e10cSrcweir
349cdf0e10cSrcweir	my $productnamestring = $onepackage->{'description'};
350cdf0e10cSrcweir	installer::packagelist::resolve_packagevariables(\$productnamestring, $variableshashref, 0);
351cdf0e10cSrcweir	if ( $variableshashref->{'PRODUCTEXTENSION'} ) { $productnamestring = $productnamestring . " " . $variableshashref->{'PRODUCTEXTENSION'}; }
352cdf0e10cSrcweir
353cdf0e10cSrcweir	$line = "%product" . " " . $productnamestring . "\n";
354cdf0e10cSrcweir	push(@epmheader, $line);
355cdf0e10cSrcweir
356cdf0e10cSrcweir	# Determining the release version
357cdf0e10cSrcweir	# This release version has to be listed in the line %version : %version versionnumber releasenumber
358cdf0e10cSrcweir
359cdf0e10cSrcweir	# if ( $variableshashref->{'PACKAGEVERSION'} ) { $installer::globals::packageversion = $variableshashref->{'PACKAGEVERSION'}; }
360cdf0e10cSrcweir	if ( ! $onepackage->{'packageversion'} ) { installer::exiter::exit_program("ERROR: No packageversion defined for package: $onepackage->{'module'}!", "create_epm_header"); }
361cdf0e10cSrcweir	$installer::globals::packageversion = $onepackage->{'packageversion'};
362cdf0e10cSrcweir	installer::packagelist::resolve_packagevariables(\$installer::globals::packageversion, $variableshashref, 0);
363cdf0e10cSrcweir	if ( $variableshashref->{'PACKAGEREVISION'} ) { $installer::globals::packagerevision = $variableshashref->{'PACKAGEREVISION'}; }
364cdf0e10cSrcweir
365cdf0e10cSrcweir	$line = "%version" . " " . $installer::globals::packageversion . "\n";
366cdf0e10cSrcweir	push(@epmheader, $line);
367cdf0e10cSrcweir
368cdf0e10cSrcweir	$line = "%release" . " " . $installer::globals::packagerevision . "\n";
369cdf0e10cSrcweir	if ( $installer::globals::islinuxrpmbuild ) { $line = "%release" . " " . $installer::globals::buildid . "\n"; }
370cdf0e10cSrcweir	push(@epmheader, $line);
371cdf0e10cSrcweir
372cdf0e10cSrcweir	# Description, Copyright and Vendor are multilingual and are defined in
373cdf0e10cSrcweir	# the string file for the header file ($headerfileref)
374cdf0e10cSrcweir
375cdf0e10cSrcweir	my $descriptionstring = $onepackage->{'description'};
376cdf0e10cSrcweir	installer::packagelist::resolve_packagevariables(\$descriptionstring, $variableshashref, 0);
377cdf0e10cSrcweir	$line = "%description" . " " . $descriptionstring . "\n";
378cdf0e10cSrcweir	push(@epmheader, $line);
379cdf0e10cSrcweir
380cdf0e10cSrcweir	my $copyrightstring = $onepackage->{'copyright'};
381cdf0e10cSrcweir	installer::packagelist::resolve_packagevariables(\$copyrightstring, $variableshashref, 0);
382cdf0e10cSrcweir	$line = "%copyright" . " " . $copyrightstring . "\n";
383cdf0e10cSrcweir	push(@epmheader, $line);
384cdf0e10cSrcweir
385cdf0e10cSrcweir	my $vendorstring = $onepackage->{'vendor'};
386cdf0e10cSrcweir	installer::packagelist::resolve_packagevariables(\$vendorstring, $variableshashref, 0);
387cdf0e10cSrcweir	$line = "%vendor" . " " . $vendorstring . "\n";
388cdf0e10cSrcweir	push(@epmheader, $line);
389cdf0e10cSrcweir
390cdf0e10cSrcweir	# License and Readme file can be included automatically from the file list
391cdf0e10cSrcweir
392cdf0e10cSrcweir	if ( $installer::globals::iswindowsbuild )
393cdf0e10cSrcweir	{
394cdf0e10cSrcweir		$licensefilename = "license.txt";
395cdf0e10cSrcweir		$readmefilename = "readme.txt";
396cdf0e10cSrcweir	}
397cdf0e10cSrcweir	else
398cdf0e10cSrcweir	{
399cdf0e10cSrcweir		$licensefilename = "LICENSE";
400cdf0e10cSrcweir		$readmefilename = "README";
401cdf0e10cSrcweir	}
402cdf0e10cSrcweir
403cdf0e10cSrcweir	if (( $installer::globals::languagepack )	# in language packs the files LICENSE and README are removed, because they are not language specific
404cdf0e10cSrcweir		|| ( $variableshashref->{'NO_README_IN_ROOTDIR'} ))
405cdf0e10cSrcweir	{
406cdf0e10cSrcweir		if ( $installer::globals::iswindowsbuild )
407cdf0e10cSrcweir		{
408cdf0e10cSrcweir			$licensefilename = "license_$searchlanguage.txt";
409cdf0e10cSrcweir			$readmefilename = "readme_$searchlanguage.txt";
410cdf0e10cSrcweir		}
411cdf0e10cSrcweir		else
412cdf0e10cSrcweir		{
413cdf0e10cSrcweir			$licensefilename = "LICENSE_$searchlanguage";
414cdf0e10cSrcweir			$readmefilename = "README_$searchlanguage";
415cdf0e10cSrcweir		}
416cdf0e10cSrcweir	}
417cdf0e10cSrcweir
418cdf0e10cSrcweir	my $license_in_package_defined = 0;
419cdf0e10cSrcweir
420cdf0e10cSrcweir	if ( $installer::globals::issolarisbuild )
421cdf0e10cSrcweir	{
422cdf0e10cSrcweir		if ( $onepackage->{'solariscopyright'} )
423cdf0e10cSrcweir		{
424cdf0e10cSrcweir			$licensefilename = $onepackage->{'solariscopyright'};
425cdf0e10cSrcweir			$license_in_package_defined = 1;
426cdf0e10cSrcweir		}
427cdf0e10cSrcweir	}
428cdf0e10cSrcweir
429cdf0e10cSrcweir	# Process for Linux packages, in which only a very basic license file is
430cdf0e10cSrcweir	# included into the package.
431cdf0e10cSrcweir
432cdf0e10cSrcweir	if ( $installer::globals::islinuxbuild )
433cdf0e10cSrcweir	{
434cdf0e10cSrcweir		if ( $variableshashref->{'COPYRIGHT_INTO_LINUXPACKAGE'} )
435cdf0e10cSrcweir		{
436cdf0e10cSrcweir			$licensefilename = "linuxcopyrightfile";
437cdf0e10cSrcweir			$license_in_package_defined = 1;
438cdf0e10cSrcweir		}
439cdf0e10cSrcweir	}
440cdf0e10cSrcweir	# searching for and readme file
441cdf0e10cSrcweir
442cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesinproduct}; $i++ )
443cdf0e10cSrcweir	{
444cdf0e10cSrcweir		my $onefile = ${$filesinproduct}[$i];
445cdf0e10cSrcweir		my $filename = $onefile->{'Name'};
446cdf0e10cSrcweir		if ( $filename eq $readmefilename )
447cdf0e10cSrcweir		{
448cdf0e10cSrcweir			$foundreadmefile = 1;
449cdf0e10cSrcweir			$line = "%readme" . " " . $onefile->{'sourcepath'} . "\n";
450cdf0e10cSrcweir			push(@epmheader, $line);
451cdf0e10cSrcweir			last;
452cdf0e10cSrcweir		}
453cdf0e10cSrcweir	}
454cdf0e10cSrcweir
455cdf0e10cSrcweir	# searching for and license file
456cdf0e10cSrcweir
457cdf0e10cSrcweir	if ( $license_in_package_defined )
458cdf0e10cSrcweir	{
459cdf0e10cSrcweir		my $fileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$licensefilename, "" , 0);
460cdf0e10cSrcweir
461cdf0e10cSrcweir		if ( $$fileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find license file $licensefilename (A)!", "create_epm_header"); }
462cdf0e10cSrcweir
463cdf0e10cSrcweir		# Special handling to add the content of the file "license_en-US" to the solaris copyrightfile. But not for all products
464cdf0e10cSrcweir
465cdf0e10cSrcweir		if (( $installer::globals::issolarispkgbuild ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} ))
466cdf0e10cSrcweir		{
467cdf0e10cSrcweir			if ( ! $installer::globals::englishlicenseset ) { installer::worker::set_english_license() }
468cdf0e10cSrcweir
469cdf0e10cSrcweir			# The location for the new file
470cdf0e10cSrcweir			my $languagestring = "";
471cdf0e10cSrcweir			for ( my $i = 0; $i <= $#{$languagesref}; $i++ ) { $languagestring = $languagestring . "_" . ${$languagesref}[$i]; }
472cdf0e10cSrcweir			$languagestring =~ s/^\s*_//;
473cdf0e10cSrcweir
474cdf0e10cSrcweir			my $copyrightdir = installer::systemactions::create_directories("copyright", \$languagestring);
475cdf0e10cSrcweir
476cdf0e10cSrcweir			my $copyrightfile = installer::files::read_file($$fileref);
477cdf0e10cSrcweir
478cdf0e10cSrcweir			# Adding license content to copyright file
479cdf0e10cSrcweir			push(@{$copyrightfile}, "\n");
480cdf0e10cSrcweir			for ( my $i = 0; $i <= $#{$installer::globals::englishlicense}; $i++ ) { push(@{$copyrightfile}, ${$installer::globals::englishlicense}[$i]); }
481cdf0e10cSrcweir
482cdf0e10cSrcweir			# New destination for $$fileref
483cdf0e10cSrcweir			$$fileref = $copyrightdir . $installer::globals::separator . "solariscopyrightfile_" . $onepackage->{'module'};
484cdf0e10cSrcweir			if ( -f $$fileref ) { unlink $$fileref; }
485cdf0e10cSrcweir			installer::files::save_file($$fileref, $copyrightfile);
486cdf0e10cSrcweir		}
487cdf0e10cSrcweir
488cdf0e10cSrcweir		$infoline = "Using license file: \"$$fileref\"!\n";
489cdf0e10cSrcweir		push(@installer::globals::logfileinfo, $infoline);
490cdf0e10cSrcweir
491cdf0e10cSrcweir		$foundlicensefile = 1;
492cdf0e10cSrcweir		$line = "%license" . " " . $$fileref . "\n";
493cdf0e10cSrcweir		push(@epmheader, $line);
494cdf0e10cSrcweir	}
495cdf0e10cSrcweir	else
496cdf0e10cSrcweir	{
497cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$filesinproduct}; $i++ )
498cdf0e10cSrcweir		{
499cdf0e10cSrcweir			my $onefile = ${$filesinproduct}[$i];
500cdf0e10cSrcweir			my $filename = $onefile->{'Name'};
501cdf0e10cSrcweir
502cdf0e10cSrcweir			if ( $filename eq $licensefilename )
503cdf0e10cSrcweir			{
504cdf0e10cSrcweir				$foundlicensefile = 1;
505cdf0e10cSrcweir				$line = "%license" . " " . $onefile->{'sourcepath'} . "\n";
506cdf0e10cSrcweir				push(@epmheader, $line);
507cdf0e10cSrcweir				last;
508cdf0e10cSrcweir			}
509cdf0e10cSrcweir		}
510cdf0e10cSrcweir	}
511cdf0e10cSrcweir
512cdf0e10cSrcweir	if (!($foundlicensefile))
513cdf0e10cSrcweir	{
514cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: Could not find license file $licensefilename (B)", "create_epm_header");
515cdf0e10cSrcweir	}
516cdf0e10cSrcweir
517cdf0e10cSrcweir	if (!($foundreadmefile))
518cdf0e10cSrcweir	{
519cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: Could not find readme file $readmefilename (C)", "create_epm_header");
520cdf0e10cSrcweir	}
521cdf0e10cSrcweir
522cdf0e10cSrcweir	# including %replaces
523cdf0e10cSrcweir
524cdf0e10cSrcweir	my $replaces = "";
525cdf0e10cSrcweir
526cdf0e10cSrcweir	if (( $installer::globals::issolarispkgbuild ) && ( ! $installer::globals::patch ))
527cdf0e10cSrcweir	{
528cdf0e10cSrcweir		$replaces = "solarisreplaces";	 # the name in the packagelist
529cdf0e10cSrcweir	}
530cdf0e10cSrcweir	elsif (( $installer::globals::islinuxbuild ) && ( ! $installer::globals::patch ))
531cdf0e10cSrcweir	{
532cdf0e10cSrcweir		$replaces = "linuxreplaces";	# the name in the packagelist
533cdf0e10cSrcweir	}
534cdf0e10cSrcweir
535cdf0e10cSrcweir	if (( $replaces ) && ( ! $installer::globals::patch ))
536cdf0e10cSrcweir	{
537cdf0e10cSrcweir		if ( $onepackage->{$replaces} )
538cdf0e10cSrcweir		{
539cdf0e10cSrcweir			my $replacesstring = $onepackage->{$replaces};
540cdf0e10cSrcweir
541cdf0e10cSrcweir			my $allreplaces = installer::converter::convert_stringlist_into_array(\$replacesstring, ",");
542cdf0e10cSrcweir
543cdf0e10cSrcweir			for ( my $i = 0; $i <= $#{$allreplaces}; $i++ )
544cdf0e10cSrcweir			{
545cdf0e10cSrcweir				my $onereplaces = ${$allreplaces}[$i];
546cdf0e10cSrcweir				$onereplaces =~ s/\s*$//;
547cdf0e10cSrcweir				installer::packagelist::resolve_packagevariables(\$onereplaces, $variableshashref, 1);
548cdf0e10cSrcweir				if ( $installer::globals::linuxlinkrpmprocess ) { $onereplaces = $onereplaces . "u"; }
54978f2b93dSEike Rathke				if ( $installer::globals::debian ) { $onereplaces =~ s/_/-/g; } # Debian allows no underline in package name
550cdf0e10cSrcweir				$line = "%replaces" . " " . $onereplaces . "\n";
551cdf0e10cSrcweir				push(@epmheader, $line);
552cdf0e10cSrcweir
553cdf0e10cSrcweir				# Force the openofficeorg packages to get removed,
554cdf0e10cSrcweir				# see http://www.debian.org/doc/debian-policy/ch-relationships.html
555cdf0e10cSrcweir				# 7.5.2 Replacing whole packages, forcing their removal
556cdf0e10cSrcweir
557cdf0e10cSrcweir				if ( $installer::globals::debian )
558cdf0e10cSrcweir				{
559cdf0e10cSrcweir					$line = "%incompat" . " " . $onereplaces . "\n";
560cdf0e10cSrcweir					push(@epmheader, $line);
561cdf0e10cSrcweir				}
562cdf0e10cSrcweir			}
563cdf0e10cSrcweir
564cdf0e10cSrcweir			if ( $installer::globals::debian && $variableshashref->{'UNIXPRODUCTNAME'} eq 'openoffice.org' )
565cdf0e10cSrcweir			{
566cdf0e10cSrcweir				$line = "%provides" . " openoffice.org-unbundled\n";
567cdf0e10cSrcweir				push(@epmheader, $line);
568cdf0e10cSrcweir				$line = "%incompat" . " openoffice.org-bundled\n";
569cdf0e10cSrcweir				push(@epmheader, $line);
570cdf0e10cSrcweir			}
571cdf0e10cSrcweir		}
572cdf0e10cSrcweir	}
573cdf0e10cSrcweir
574cdf0e10cSrcweir	# including the directives for %requires and %provides
575cdf0e10cSrcweir
576cdf0e10cSrcweir	my $provides = "";
577cdf0e10cSrcweir	my $requires = "";
578cdf0e10cSrcweir
579cdf0e10cSrcweir	if ( $installer::globals::issolarispkgbuild )
580cdf0e10cSrcweir	{
581cdf0e10cSrcweir		$provides = "solarisprovides";	 # the name in the packagelist
582cdf0e10cSrcweir		$requires = "solarisrequires";	 # the name in the packagelist
583cdf0e10cSrcweir	}
584cdf0e10cSrcweir	elsif ( $installer::globals::isfreebsdpkgbuild )
585cdf0e10cSrcweir	{
586cdf0e10cSrcweir		$provides = "freebsdprovides";	 # the name in the packagelist
587cdf0e10cSrcweir		$requires = "freebsdrequires";	 # the name in the packagelist
588cdf0e10cSrcweir	}
589cdf0e10cSrcweir	elsif (( $installer::globals::islinuxrpmbuild ) &&
590cdf0e10cSrcweir			( $installer::globals::patch ) &&
591cdf0e10cSrcweir			( exists($onepackage->{'linuxpatchrequires'}) ))
592cdf0e10cSrcweir	{
593cdf0e10cSrcweir		$provides = "provides";	 # the name in the packagelist
594cdf0e10cSrcweir		$requires = "linuxpatchrequires";	 # the name in the packagelist
595cdf0e10cSrcweir	}
596cdf0e10cSrcweir	else
597cdf0e10cSrcweir	{
598cdf0e10cSrcweir		$provides = "provides";	 		# the name in the packagelist
599cdf0e10cSrcweir		$requires = "requires";	 		# the name in the packagelist
600cdf0e10cSrcweir	}
601cdf0e10cSrcweir
602cdf0e10cSrcweir	# if ( $installer::globals::patch )
603cdf0e10cSrcweir	# {
604cdf0e10cSrcweir	#	$onepackage->{$provides} = "";
605cdf0e10cSrcweir		my $isdict = 0;
606cdf0e10cSrcweir		if ( $onepackage->{'packagename'} =~ /-dict-/ ) { $isdict = 1;  }
607cdf0e10cSrcweir
608cdf0e10cSrcweir	#	$onepackage->{$requires} = "";
609cdf0e10cSrcweir	# }
610cdf0e10cSrcweir
611cdf0e10cSrcweir	if ( $onepackage->{$provides} )
612cdf0e10cSrcweir	{
613cdf0e10cSrcweir		my $providesstring = $onepackage->{$provides};
614cdf0e10cSrcweir
615cdf0e10cSrcweir		my $allprovides = installer::converter::convert_stringlist_into_array(\$providesstring, ",");
616cdf0e10cSrcweir
617cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$allprovides}; $i++ )
618cdf0e10cSrcweir		{
619cdf0e10cSrcweir			my $oneprovides = ${$allprovides}[$i];
620cdf0e10cSrcweir			$oneprovides =~ s/\s*$//;
621cdf0e10cSrcweir			installer::packagelist::resolve_packagevariables(\$oneprovides, $variableshashref, 1);
622cdf0e10cSrcweir			if ( $installer::globals::linuxlinkrpmprocess ) { $oneprovides = $oneprovides . "u"; }
62378f2b93dSEike Rathke			if ( $installer::globals::debian ) { $oneprovides =~ s/_/-/g; } # Debian allows no underline in package name
624cdf0e10cSrcweir			$line = "%provides" . " " . $oneprovides . "\n";
625cdf0e10cSrcweir			push(@epmheader, $line);
626cdf0e10cSrcweir		}
627cdf0e10cSrcweir	}
628cdf0e10cSrcweir
629cdf0e10cSrcweir	if ( $onepackage->{$requires} )
630cdf0e10cSrcweir	{
631cdf0e10cSrcweir		my $requiresstring = $onepackage->{$requires};
632cdf0e10cSrcweir
633cdf0e10cSrcweir		if ( $installer::globals::add_required_package ) { $requiresstring = $requiresstring . "," . $installer::globals::add_required_package; }
634cdf0e10cSrcweir
635cdf0e10cSrcweir		# The requires string can contain the separator "," in the names (descriptions) of the packages
636cdf0e10cSrcweir		# (that are required for Solaris depend files). Therefore "," inside such a description has to
637cdf0e10cSrcweir		# masked with a backslash.
638cdf0e10cSrcweir		# This masked separator need to be found and replaced, before the stringlist is converted into an array.
639cdf0e10cSrcweir		# This replacement has to be turned back after the array is created.
640cdf0e10cSrcweir
641cdf0e10cSrcweir		my $replacementstring = "COMMAREPLACEMENT";
642cdf0e10cSrcweir		$requiresstring = installer::converter::replace_masked_separator($requiresstring, ",", "$replacementstring");
643cdf0e10cSrcweir
644cdf0e10cSrcweir		my $allrequires = installer::converter::convert_stringlist_into_array(\$requiresstring, ",");
645cdf0e10cSrcweir
646cdf0e10cSrcweir		installer::converter::resolve_masked_separator($allrequires, ",", $replacementstring);
647cdf0e10cSrcweir
648cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$allrequires}; $i++ )
649cdf0e10cSrcweir		{
650cdf0e10cSrcweir			my $onerequires = ${$allrequires}[$i];
651cdf0e10cSrcweir			$onerequires =~ s/\s*$//;
652cdf0e10cSrcweir			installer::packagelist::resolve_packagevariables2(\$onerequires, $variableshashref, 0, $isdict);
65378f2b93dSEike Rathke			if ( $installer::globals::debian ) { $onerequires =~ s/_/-/g; } # Debian allows no underline in package name
654cdf0e10cSrcweir
655cdf0e10cSrcweir			# Special handling for Solaris. In depend files, the names of the packages are required, not
656cdf0e10cSrcweir			# only the abbreviation. Therefore there is a special syntax for names in packagelist:
657cdf0e10cSrcweir			# solarisrequires = "SUNWcar (Name="Package name of SUNWcar"),SUNWkvm (Name="Package name of SUNWcar"), ...
658cdf0e10cSrcweir			# if ( $installer::globals::issolarispkgbuild )
659cdf0e10cSrcweir			# {
660cdf0e10cSrcweir			#	if ( $onerequires =~ /^\s*(.*?)\s+\(\s*Name\s*=\s*\"(.*?)\"\s*\)\s*$/ )
661cdf0e10cSrcweir			#	{
662cdf0e10cSrcweir			#		$onerequires = $1;
663cdf0e10cSrcweir			#		$packagename = $2;
664cdf0e10cSrcweir			#		$installer::globals::dependfilenames{$onerequires} = $packagename;
665cdf0e10cSrcweir			#	}
666cdf0e10cSrcweir			# }
667cdf0e10cSrcweir
668cdf0e10cSrcweir			$line = "%requires" . " " . $onerequires . "\n";
669cdf0e10cSrcweir			push(@epmheader, $line);
670cdf0e10cSrcweir		}
671cdf0e10cSrcweir	}
672cdf0e10cSrcweir	else
673cdf0e10cSrcweir	{
674cdf0e10cSrcweir		if ( $installer::globals::add_required_package )
675cdf0e10cSrcweir		{
676cdf0e10cSrcweir			my $requiresstring = $installer::globals::add_required_package;
677cdf0e10cSrcweir
678cdf0e10cSrcweir			my $replacementstring = "COMMAREPLACEMENT";
679cdf0e10cSrcweir			$requiresstring = installer::converter::replace_masked_separator($requiresstring, ",", "$replacementstring");
680cdf0e10cSrcweir			my $allrequires = installer::converter::convert_stringlist_into_array(\$requiresstring, ",");
681cdf0e10cSrcweir			installer::converter::resolve_masked_separator($allrequires, ",", $replacementstring);
682cdf0e10cSrcweir
683cdf0e10cSrcweir			for ( my $i = 0; $i <= $#{$allrequires}; $i++ )
684cdf0e10cSrcweir			{
685cdf0e10cSrcweir				my $onerequires = ${$allrequires}[$i];
686cdf0e10cSrcweir				$onerequires =~ s/\s*$//;
687cdf0e10cSrcweir				installer::packagelist::resolve_packagevariables(\$onerequires, $variableshashref, 0);
68878f2b93dSEike Rathke				if ( $installer::globals::debian ) { $onerequires =~ s/_/-/g; } # Debian allows no underline in package name
689cdf0e10cSrcweir
690cdf0e10cSrcweir				# Special handling for Solaris. In depend files, the names of the packages are required, not
691cdf0e10cSrcweir				# only the abbreviation. Therefore there is a special syntax for names in packagelist:
692cdf0e10cSrcweir				# solarisrequires = "SUNWcar (Name="Package name of SUNWcar"),SUNWkvm (Name="Package name of SUNWcar"), ...
693cdf0e10cSrcweir				# if ( $installer::globals::issolarispkgbuild )
694cdf0e10cSrcweir				# {
695cdf0e10cSrcweir				#	if ( $onerequires =~ /^\s*(.*?)\s+\(\s*Name\s*=\s*\"(.*?)\"\s*\)\s*$/ )
696cdf0e10cSrcweir				#	{
697cdf0e10cSrcweir				#		$onerequires = $1;
698cdf0e10cSrcweir				#		$packagename = $2;
699cdf0e10cSrcweir				#		$installer::globals::dependfilenames{$onerequires} = $packagename;
700cdf0e10cSrcweir				#	}
701cdf0e10cSrcweir				# }
702cdf0e10cSrcweir
703cdf0e10cSrcweir				$line = "%requires" . " " . $onerequires . "\n";
704cdf0e10cSrcweir				push(@epmheader, $line);
705cdf0e10cSrcweir			}
706cdf0e10cSrcweir		}
707cdf0e10cSrcweir	}
708cdf0e10cSrcweir
709cdf0e10cSrcweir	return \@epmheader;
710cdf0e10cSrcweir}
711cdf0e10cSrcweir
712cdf0e10cSrcweir#######################################
713cdf0e10cSrcweir# Adding header to epm file
714cdf0e10cSrcweir#######################################
715cdf0e10cSrcweir
716cdf0e10cSrcweirsub adding_header_to_epm_file
717cdf0e10cSrcweir{
718cdf0e10cSrcweir	my ($epmfileref, $epmheaderref) = @_;
719cdf0e10cSrcweir
720cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$epmheaderref}; $i++ )
721cdf0e10cSrcweir	{
722cdf0e10cSrcweir		push( @{$epmfileref}, ${$epmheaderref}[$i] );
723cdf0e10cSrcweir	}
724cdf0e10cSrcweir
725cdf0e10cSrcweir	push( @{$epmfileref}, "\n\n" );
726cdf0e10cSrcweir}
727cdf0e10cSrcweir
728cdf0e10cSrcweir#####################################################
729cdf0e10cSrcweir# Replace one in shell scripts ( ${VARIABLENAME} )
730cdf0e10cSrcweir#####################################################
731cdf0e10cSrcweir
732cdf0e10cSrcweirsub replace_variable_in_shellscripts
733cdf0e10cSrcweir{
734cdf0e10cSrcweir	my ($scriptref, $variable, $searchstring) = @_;
735cdf0e10cSrcweir
736cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$scriptref}; $i++ )
737cdf0e10cSrcweir	{
738cdf0e10cSrcweir		${$scriptref}[$i] =~ s/\$\{$searchstring\}/$variable/g;
739cdf0e10cSrcweir	}
740cdf0e10cSrcweir}
741cdf0e10cSrcweir
742cdf0e10cSrcweir###################################################
743cdf0e10cSrcweir# Replace one in shell scripts ( %VARIABLENAME )
744cdf0e10cSrcweir###################################################
745cdf0e10cSrcweir
746cdf0e10cSrcweirsub replace_percent_variable_in_shellscripts
747cdf0e10cSrcweir{
748cdf0e10cSrcweir	my ($scriptref, $variable, $searchstring) = @_;
749cdf0e10cSrcweir
750cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$scriptref}; $i++ )
751cdf0e10cSrcweir	{
752cdf0e10cSrcweir		${$scriptref}[$i] =~ s/\%$searchstring/$variable/g;
753cdf0e10cSrcweir	}
754cdf0e10cSrcweir}
755cdf0e10cSrcweir
756cdf0e10cSrcweir################################################
757cdf0e10cSrcweir# Replacing many variables in shell scripts
758cdf0e10cSrcweir################################################
759cdf0e10cSrcweir
760cdf0e10cSrcweirsub replace_many_variables_in_shellscripts
761cdf0e10cSrcweir{
762cdf0e10cSrcweir	my ($scriptref, $variableshashref) = @_;
763cdf0e10cSrcweir
764cdf0e10cSrcweir	my $key;
765cdf0e10cSrcweir
766cdf0e10cSrcweir	foreach $key (keys %{$variableshashref})
767cdf0e10cSrcweir	{
768cdf0e10cSrcweir		my $value = $variableshashref->{$key};
769cdf0e10cSrcweir		# $value = lc($value); 	# lowercase !
770cdf0e10cSrcweir		# if ( $installer::globals::issolarisbuild) { $value =~ s/\.org/org/g; }	# openofficeorg instead of openoffice.org
771cdf0e10cSrcweir		replace_variable_in_shellscripts($scriptref, $value, $key);
772cdf0e10cSrcweir	}
773cdf0e10cSrcweir}
774cdf0e10cSrcweir
775cdf0e10cSrcweir#######################################
776cdf0e10cSrcweir# Adding shell scripts to epm file
777cdf0e10cSrcweir#######################################
778cdf0e10cSrcweir
779cdf0e10cSrcweirsub adding_shellscripts_to_epm_file
780cdf0e10cSrcweir{
781cdf0e10cSrcweir	my ($epmfileref, $shellscriptsfilename, $localrootpath, $allvariableshashref, $filesinpackage) = @_;
782cdf0e10cSrcweir
783cdf0e10cSrcweir	# $installer::globals::shellscriptsfilename
784cdf0e10cSrcweir
785cdf0e10cSrcweir	push( @{$epmfileref}, "\n\n" );
786cdf0e10cSrcweir
787cdf0e10cSrcweir	my $shellscriptsfileref = installer::files::read_file($shellscriptsfilename);
788cdf0e10cSrcweir
789cdf0e10cSrcweir	replace_variable_in_shellscripts($shellscriptsfileref, $localrootpath, "rootpath");
790cdf0e10cSrcweir
791cdf0e10cSrcweir	replace_many_variables_in_shellscripts($shellscriptsfileref, $allvariableshashref);
792cdf0e10cSrcweir
793cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$shellscriptsfileref}; $i++ )
794cdf0e10cSrcweir	{
795cdf0e10cSrcweir		push( @{$epmfileref}, ${$shellscriptsfileref}[$i] );
796cdf0e10cSrcweir	}
797cdf0e10cSrcweir
798cdf0e10cSrcweir	push( @{$epmfileref}, "\n" );
799cdf0e10cSrcweir}
800cdf0e10cSrcweir
801cdf0e10cSrcweir#################################################
802cdf0e10cSrcweir# Determining the epm on the system
803cdf0e10cSrcweir#################################################
804cdf0e10cSrcweir
805cdf0e10cSrcweirsub find_epm_on_system
806cdf0e10cSrcweir{
807cdf0e10cSrcweir	my ($includepatharrayref) = @_;
808cdf0e10cSrcweir
809cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Check epm on system");
810cdf0e10cSrcweir
811cdf0e10cSrcweir	my $epmname = "epm";
812cdf0e10cSrcweir
813cdf0e10cSrcweir	# epm should be defined through the configure script but we need to
814cdf0e10cSrcweir	# check for it to be defined because of the Sun environment.
815cdf0e10cSrcweir	# Check the environment variable first and if it is not defined,
816cdf0e10cSrcweir	# or if it is but the location is not executable, search further.
817cdf0e10cSrcweir	# It has to be found in the solver or it has to be in the path
818cdf0e10cSrcweir	# (saved in $installer::globals::epm_in_path) or we get the specified
819cdf0e10cSrcweir	# one through the environment (i.e. when --with-epm=... is specified)
820cdf0e10cSrcweir
821cdf0e10cSrcweir	if ($ENV{'EPM'})
822cdf0e10cSrcweir	{
823cdf0e10cSrcweir		if (($ENV{'EPM'} ne "") && (-x "$ENV{'EPM'}"))
824cdf0e10cSrcweir		{
825cdf0e10cSrcweir			$epmname = $ENV{'EPM'};
826cdf0e10cSrcweir		}
827cdf0e10cSrcweir		elsif ( ($ENV{'EPM'} eq "no") || ($ENV{'EPM'} eq "internal") )
828cdf0e10cSrcweir		{
829cdf0e10cSrcweir			$epmname = "epm";
830cdf0e10cSrcweir			my $epmref = installer::scriptitems::get_sourcepath_from_filename_and_includepath( \$epmname, $includepatharrayref, 0);
831cdf0e10cSrcweir			if ($$epmref eq "") { installer::exiter::exit_program("ERROR: Could not find program $epmname (EPM set to \"internal\" or \"no\")!", "find_epm_on_system"); }
832cdf0e10cSrcweir			$epmname = $$epmref;
833cdf0e10cSrcweir		}
834cdf0e10cSrcweir		else
835cdf0e10cSrcweir		{
836cdf0e10cSrcweir			installer::exiter::exit_program("Environment variable EPM set (\"$ENV{'EPM'}\"), but file does not exist or is not executable!", "find_epm_on_system");
837cdf0e10cSrcweir		}
838cdf0e10cSrcweir	}
839cdf0e10cSrcweir	else
840cdf0e10cSrcweir	{
841cdf0e10cSrcweir		my $epmfileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$epmname, $includepatharrayref, 0);
842cdf0e10cSrcweir
843cdf0e10cSrcweir		if (($$epmfileref eq "") && (!($installer::globals::epm_in_path))) { installer::exiter::exit_program("ERROR: Could not find program $epmname!", "find_epm_on_system"); }
844cdf0e10cSrcweir		if (($$epmfileref eq "") && ($installer::globals::epm_in_path)) { $epmname = $installer::globals::epm_path; }
845cdf0e10cSrcweir		if (!($$epmfileref eq "")) { $epmname = $$epmfileref; }
846cdf0e10cSrcweir	}
847cdf0e10cSrcweir
848cdf0e10cSrcweir	my $infoline = "Using epmfile: $epmname\n";
849cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
850cdf0e10cSrcweir
851cdf0e10cSrcweir	return $epmname;
852cdf0e10cSrcweir}
853cdf0e10cSrcweir
854cdf0e10cSrcweir#################################################
855cdf0e10cSrcweir# Determining the epm patch state
856cdf0e10cSrcweir# saved in $installer::globals::is_special_epm
857cdf0e10cSrcweir#################################################
858cdf0e10cSrcweir
859cdf0e10cSrcweirsub set_patch_state
860cdf0e10cSrcweir{
861cdf0e10cSrcweir	my ($epmexecutable) = @_;
862cdf0e10cSrcweir
863cdf0e10cSrcweir	my $infoline = "";
864cdf0e10cSrcweir
865cdf0e10cSrcweir	my $systemcall = "$epmexecutable |";
866cdf0e10cSrcweir	open (EPMPATCH, "$systemcall");
867cdf0e10cSrcweir
868cdf0e10cSrcweir	while (<EPMPATCH>)
869cdf0e10cSrcweir	{
870cdf0e10cSrcweir		chop;
871cdf0e10cSrcweir		if ( $_ =~ /Patched for OpenOffice.org/ ) { $installer::globals::is_special_epm = 1; }
872cdf0e10cSrcweir	}
873cdf0e10cSrcweir
874cdf0e10cSrcweir	close (EPMPATCH);
875cdf0e10cSrcweir
876cdf0e10cSrcweir	if ( $installer::globals::is_special_epm )
877cdf0e10cSrcweir	{
878cdf0e10cSrcweir		$infoline = "\nPatch state: This is a patched version of epm!\n\n";
879cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
880cdf0e10cSrcweir	}
881cdf0e10cSrcweir	else
882cdf0e10cSrcweir	{
883cdf0e10cSrcweir		$infoline = "\nPatch state: This is an unpatched version of epm!\n\n";
884cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
885cdf0e10cSrcweir	}
886cdf0e10cSrcweir
887cdf0e10cSrcweir	if ( ( $installer::globals::is_special_epm ) && (($installer::globals::islinuxrpmbuild) || ($installer::globals::issolarispkgbuild)) )
888cdf0e10cSrcweir	{
889cdf0e10cSrcweir		# Special postprocess handling only for Linux RPM and Solaris packages
890cdf0e10cSrcweir		$installer::globals::postprocess_specialepm = 1;
891cdf0e10cSrcweir		$installer::globals::postprocess_standardepm = 0;
892cdf0e10cSrcweir	}
893cdf0e10cSrcweir	else
894cdf0e10cSrcweir	{
895cdf0e10cSrcweir		$installer::globals::postprocess_specialepm = 0;
896cdf0e10cSrcweir		$installer::globals::postprocess_standardepm = 1;
897cdf0e10cSrcweir	}
898cdf0e10cSrcweir}
899cdf0e10cSrcweir
900cdf0e10cSrcweir#################################################
901cdf0e10cSrcweir# LD_PRELOAD string for Debian packages
902cdf0e10cSrcweir#################################################
903cdf0e10cSrcweir
904cdf0e10cSrcweirsub get_ld_preload_string
905cdf0e10cSrcweir{
906cdf0e10cSrcweir	my ($includepatharrayref) = @_;
907cdf0e10cSrcweir
908cdf0e10cSrcweir	my $getuidlibraryname = "getuid.so";
909cdf0e10cSrcweir
910cdf0e10cSrcweir	my $getuidlibraryref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$getuidlibraryname, $includepatharrayref, 0);
911cdf0e10cSrcweir	if ($$getuidlibraryref eq "") { installer::exiter::exit_program("ERROR: Could not find $getuidlibraryname!", "get_ld_preload_string"); }
912cdf0e10cSrcweir
913cdf0e10cSrcweir	my $ldpreloadstring = "LD_PRELOAD=" . $$getuidlibraryref;
914cdf0e10cSrcweir
915cdf0e10cSrcweir	return $ldpreloadstring;
916cdf0e10cSrcweir}
917cdf0e10cSrcweir
918cdf0e10cSrcweir#################################################
919cdf0e10cSrcweir# Calling epm to create the installation sets
920cdf0e10cSrcweir#################################################
921cdf0e10cSrcweir
922cdf0e10cSrcweirsub call_epm
923cdf0e10cSrcweir{
924cdf0e10cSrcweir	my ($epmname, $epmlistfilename, $packagename, $includepatharrayref) = @_;
925cdf0e10cSrcweir
926cdf0e10cSrcweir	installer::logger::include_header_into_logfile("epm call for $packagename");
927cdf0e10cSrcweir
928cdf0e10cSrcweir	my $packageformat = $installer::globals::packageformat;
929cdf0e10cSrcweir
930cdf0e10cSrcweir	my $localpackagename = $packagename;
931cdf0e10cSrcweir	# Debian allows only lowercase letters in package name
932cdf0e10cSrcweir	if ( $installer::globals::debian ) { $localpackagename = lc($localpackagename); }
933cdf0e10cSrcweir
934cdf0e10cSrcweir	my $outdirstring = "";
935cdf0e10cSrcweir	if ( $installer::globals::epmoutpath ne "" ) { $outdirstring = " --output-dir $installer::globals::epmoutpath"; }
936cdf0e10cSrcweir
937cdf0e10cSrcweir	# Debian package build needs a LD_PRELOAD for correct rights
938cdf0e10cSrcweir
939cdf0e10cSrcweir	my $ldpreloadstring = "";
940cdf0e10cSrcweir
941cdf0e10cSrcweir	if ( $installer::globals::debian ) { $ldpreloadstring = get_ld_preload_string($includepatharrayref) . " "; }
942cdf0e10cSrcweir
943cdf0e10cSrcweir	my $extraflags = "";
944cdf0e10cSrcweir        if ($ENV{'EPM_FLAGS'}) { $extraflags = $ENV{'EPM_FLAGS'}; }
945*0d88aef9SAriel Constenla-Haile
946*0d88aef9SAriel Constenla-Haile    my $verboseflag = "-v";
947*0d88aef9SAriel Constenla-Haile    if ( ! $installer::globals::quiet ) { $verboseflag = "-v2"; };
948cdf0e10cSrcweir
949*0d88aef9SAriel Constenla-Haile	my $systemcall = $ldpreloadstring . $epmname . " -f " . $packageformat . " " . $extraflags . " " . $localpackagename . " " . $epmlistfilename . $outdirstring . " " . $verboseflag . " " . " 2\>\&1 |";
950cdf0e10cSrcweir
951cdf0e10cSrcweir	installer::logger::print_message( "... $systemcall ...\n" );
952cdf0e10cSrcweir
953cdf0e10cSrcweir	my $maxepmcalls = 3;
954cdf0e10cSrcweir
955cdf0e10cSrcweir	for ( my $i = 1; $i <= $maxepmcalls; $i++ )
956cdf0e10cSrcweir	{
957cdf0e10cSrcweir		my @epmoutput = ();
958cdf0e10cSrcweir
959cdf0e10cSrcweir		open (EPM, "$systemcall");
960cdf0e10cSrcweir		while (<EPM>) {push(@epmoutput, $_); }
961cdf0e10cSrcweir		close (EPM);
962cdf0e10cSrcweir
963cdf0e10cSrcweir		my $returnvalue = $?;	# $? contains the return value of the systemcall
964cdf0e10cSrcweir
965cdf0e10cSrcweir		my $infoline = "Systemcall  (Try $i): $systemcall\n";
966cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
967cdf0e10cSrcweir
968cdf0e10cSrcweir		for ( my $j = 0; $j <= $#epmoutput; $j++ )
969cdf0e10cSrcweir		{
970cdf0e10cSrcweir			if ( $i < $maxepmcalls ) { $epmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
971cdf0e10cSrcweir			push( @installer::globals::logfileinfo, "$epmoutput[$j]");
972cdf0e10cSrcweir		}
973cdf0e10cSrcweir
974cdf0e10cSrcweir		if ($returnvalue)
975cdf0e10cSrcweir		{
976cdf0e10cSrcweir			$infoline = "Try $i : Could not execute \"$systemcall\"!\n";
977cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
978cdf0e10cSrcweir			if ( $i == $maxepmcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "call_epm"); }
979cdf0e10cSrcweir		}
980cdf0e10cSrcweir		else
981cdf0e10cSrcweir		{
982cdf0e10cSrcweir			installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
983cdf0e10cSrcweir			$infoline = "Success: Executed \"$systemcall\" successfully!\n";
984cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
985cdf0e10cSrcweir			last;
986cdf0e10cSrcweir		}
987cdf0e10cSrcweir	}
988cdf0e10cSrcweir}
989cdf0e10cSrcweir
990cdf0e10cSrcweir#####################################################################
991cdf0e10cSrcweir# Adding the new line for relocatables into pkginfo file (Solaris)
992cdf0e10cSrcweir# or spec file (Linux) created by epm
993cdf0e10cSrcweir#####################################################################
994cdf0e10cSrcweir
995cdf0e10cSrcweirsub add_one_line_into_file
996cdf0e10cSrcweir{
997cdf0e10cSrcweir	my ($file, $insertline, $filename) = @_;
998cdf0e10cSrcweir
999cdf0e10cSrcweir	if ( $installer::globals::issolarispkgbuild )
1000cdf0e10cSrcweir	{
1001cdf0e10cSrcweir		push(@{$file}, $insertline);		# simply adding at the end of pkginfo file
1002cdf0e10cSrcweir	}
1003cdf0e10cSrcweir
1004cdf0e10cSrcweir	if ( $installer::globals::islinuxrpmbuild )
1005cdf0e10cSrcweir	{
1006cdf0e10cSrcweir		# Adding behind the line beginning with: Group:
1007cdf0e10cSrcweir
1008cdf0e10cSrcweir		my $inserted_line = 0;
1009cdf0e10cSrcweir
1010cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$file}; $i++ )
1011cdf0e10cSrcweir		{
1012cdf0e10cSrcweir			if ( ${$file}[$i] =~ /^\s*Group\:\s*/ )
1013cdf0e10cSrcweir			{
1014cdf0e10cSrcweir				splice(@{$file},$i+1,0,$insertline);
1015cdf0e10cSrcweir				$inserted_line = 1;
1016cdf0e10cSrcweir				last;
1017cdf0e10cSrcweir			}
1018cdf0e10cSrcweir		}
1019cdf0e10cSrcweir
1020cdf0e10cSrcweir		if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "add_one_line_into_file"); }
1021cdf0e10cSrcweir	}
1022cdf0e10cSrcweir
1023cdf0e10cSrcweir	$insertline =~ s/\s*$//;	# removing line end for correct logging
1024cdf0e10cSrcweir	my $infoline = "Success: Added line $insertline into file $filename!\n";
1025cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
1026cdf0e10cSrcweir}
1027cdf0e10cSrcweir
1028cdf0e10cSrcweir#####################################################################
1029cdf0e10cSrcweir# Setting the revision VERSION=1.9,REV=66  .
1030cdf0e10cSrcweir# Also adding the new line: "AutoReqProv: no"
1031cdf0e10cSrcweir#####################################################################
1032cdf0e10cSrcweir
1033cdf0e10cSrcweirsub set_revision_in_pkginfo
1034cdf0e10cSrcweir{
1035cdf0e10cSrcweir	my ($file, $filename, $variables, $packagename) = @_;
1036cdf0e10cSrcweir
1037cdf0e10cSrcweir	my $revisionstring = "\,REV\=" . $installer::globals::packagerevision;
1038cdf0e10cSrcweir
1039cdf0e10cSrcweir	# Adding also a time string to the revision. Syntax: VERSION=8.0.0,REV=66.2005.01.24
1040cdf0e10cSrcweir
1041cdf0e10cSrcweir	my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
1042cdf0e10cSrcweir
1043cdf0e10cSrcweir	$mday = $mday;
1044cdf0e10cSrcweir	$mon = $mon + 1;
1045cdf0e10cSrcweir	$year = $year + 1900;
1046cdf0e10cSrcweir
1047cdf0e10cSrcweir	if ( $mday < 10 ) { $mday = "0" . $mday; }
1048cdf0e10cSrcweir	if ( $mon < 10 ) { $mon = "0" . $mon; }
1049cdf0e10cSrcweir	$datestring = $year . "." . $mon . "." . $mday;
1050cdf0e10cSrcweir	$revisionstring = $revisionstring . "." . $datestring;
1051cdf0e10cSrcweir
1052cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$file}; $i++ )
1053cdf0e10cSrcweir	{
1054cdf0e10cSrcweir		if ( ${$file}[$i] =~ /^\s*(VERSION\=.*?)\s*$/ )
1055cdf0e10cSrcweir		{
1056cdf0e10cSrcweir			my $oldstring = $1;
1057cdf0e10cSrcweir			my $newstring = $oldstring . $revisionstring;	# also adding the date string
1058cdf0e10cSrcweir			${$file}[$i] =~ s/$oldstring/$newstring/;
1059cdf0e10cSrcweir			my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
1060cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1061cdf0e10cSrcweir			last;
1062cdf0e10cSrcweir		}
1063cdf0e10cSrcweir	}
1064cdf0e10cSrcweir
1065cdf0e10cSrcweir	# For Update and Patch reasons, this string can also be kept constant
1066cdf0e10cSrcweir
1067cdf0e10cSrcweir	my $pkgversion = "SOLSPARCPKGVERSION";
1068cdf0e10cSrcweir	if ( $installer::globals::issolarisx86build ) { $pkgversion = "SOLIAPKGVERSION"; }
1069cdf0e10cSrcweir
1070cdf0e10cSrcweir	if (( $variables->{$pkgversion} ) && ( $variables->{$pkgversion} ne "" ))
1071cdf0e10cSrcweir	{
1072cdf0e10cSrcweir		if ( $variables->{$pkgversion} ne "FINALVERSION" )
1073cdf0e10cSrcweir		{
1074cdf0e10cSrcweir			# In OOo 3.x timeframe, this string is no longer unique for all packages, because of the three layer.
1075cdf0e10cSrcweir			# In the string: "3.0.0,REV=9.2008.09.30" only the part "REV=9.2008.09.30" can be unique for all packages
1076cdf0e10cSrcweir			# and therefore be set as $pkgversion.
1077cdf0e10cSrcweir			# The first part "3.0.0" has to be derived from the
1078cdf0e10cSrcweir
1079cdf0e10cSrcweir			my $version = $installer::globals::packageversion;
1080cdf0e10cSrcweir			if ( $version =~ /^\s*(\d+)\.(\d+)\.(\d+)\s*$/ )
1081cdf0e10cSrcweir			{
1082cdf0e10cSrcweir				my $major = $1;
1083cdf0e10cSrcweir				my $minor = $2;
1084cdf0e10cSrcweir				my $micro = $3;
1085cdf0e10cSrcweir
1086cdf0e10cSrcweir				my $finalmajor = $major;
1087cdf0e10cSrcweir				my $finalminor = $minor;
1088cdf0e10cSrcweir				my $finalmicro = 0;
1089cdf0e10cSrcweir
1090cdf0e10cSrcweir				# if (( $packagename =~ /-ure\s*$/ ) && ( $finalmajor == 1 )) { $finalminor = 4; }
1091cdf0e10cSrcweir
1092cdf0e10cSrcweir				$version = "$finalmajor.$finalminor.$finalmicro";
1093cdf0e10cSrcweir			}
1094cdf0e10cSrcweir
1095cdf0e10cSrcweir			my $datestring = $variables->{$pkgversion};
1096cdf0e10cSrcweir
1097cdf0e10cSrcweir			# Allowing some packages to have another date of creation.
1098cdf0e10cSrcweir			# They can be defined in product definition using a key like "SOLSPARCPKGVERSION_$packagename"
1099cdf0e10cSrcweir
1100cdf0e10cSrcweir			my $additionalkey = $pkgversion . "_" . $packagename;
1101cdf0e10cSrcweir			if (( $variables->{$additionalkey} ) && ( $variables->{$additionalkey} ne "" )) { $datestring = $variables->{$additionalkey}; }
1102cdf0e10cSrcweir
1103cdf0e10cSrcweir			my $versionstring = "$version,$datestring";
1104cdf0e10cSrcweir
1105cdf0e10cSrcweir			for ( my $i = 0; $i <= $#{$file}; $i++ )
1106cdf0e10cSrcweir			{
1107cdf0e10cSrcweir				if ( ${$file}[$i] =~ /^\s*(VERSION\=).*?\s*$/ )
1108cdf0e10cSrcweir				{
1109cdf0e10cSrcweir					my $start = $1;
1110cdf0e10cSrcweir					my $newstring = $start . $versionstring . "\n";	# setting the complete new string
1111cdf0e10cSrcweir					my $oldstring = ${$file}[$i];
1112cdf0e10cSrcweir					${$file}[$i] = $newstring;
1113cdf0e10cSrcweir					$oldstring =~ s/\s*$//;
1114cdf0e10cSrcweir					$newstring =~ s/\s*$//;
1115cdf0e10cSrcweir					my $infoline = "Info: Changed in $filename file: \"$oldstring\" to \"$newstring\"!\n";
1116cdf0e10cSrcweir					push( @installer::globals::logfileinfo, $infoline);
1117cdf0e10cSrcweir					last;
1118cdf0e10cSrcweir				}
1119cdf0e10cSrcweir			}
1120cdf0e10cSrcweir		}
1121cdf0e10cSrcweir	}
1122cdf0e10cSrcweir}
1123cdf0e10cSrcweir
1124cdf0e10cSrcweir########################################################
1125cdf0e10cSrcweir# Setting Patch information for Respin versions
1126cdf0e10cSrcweir# into pkginfo file. This prevents Respin versions
1127cdf0e10cSrcweir# from patching.
1128cdf0e10cSrcweir########################################################
1129cdf0e10cSrcweir
1130cdf0e10cSrcweirsub set_patchlist_in_pkginfo_for_respin
1131cdf0e10cSrcweir{
1132cdf0e10cSrcweir	my ($changefile, $filename, $allvariables, $packagename) = @_;
1133cdf0e10cSrcweir
1134cdf0e10cSrcweir	my $patchlistname = "SOLSPARCPATCHLISTFORRESPIN";
1135cdf0e10cSrcweir	if ( $installer::globals::issolarisx86build ) { $patchlistname = "SOLIAPATCHLISTFORRESPIN"; }
1136cdf0e10cSrcweir
1137cdf0e10cSrcweir	if ( $allvariables->{$patchlistname} )
1138cdf0e10cSrcweir	{
1139cdf0e10cSrcweir		# patchlist separator is a blank
1140cdf0e10cSrcweir		my $allpatchesstring = $allvariables->{$patchlistname};
1141cdf0e10cSrcweir		my @usedpatches = ();
1142cdf0e10cSrcweir
1143cdf0e10cSrcweir		# Analyzing the patchlist
1144cdf0e10cSrcweir		# Syntax: 120186-10 126411-01(+core-01) -> use 126411-01 only for core-01
1145cdf0e10cSrcweir		# Syntax: 120186-10 126411-01(-core-01) -> use 126411-01 for all packages except for core-01
1146cdf0e10cSrcweir		my $allpatches = installer::converter::convert_whitespace_stringlist_into_array(\$allpatchesstring);
1147cdf0e10cSrcweir
1148cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$allpatches}; $i++ )
1149cdf0e10cSrcweir		{
1150cdf0e10cSrcweir			my $patchdefinition = ${$allpatches}[$i];
1151cdf0e10cSrcweir
1152cdf0e10cSrcweir			my $patchid = "";
1153cdf0e10cSrcweir			my $symbol = "";
1154cdf0e10cSrcweir			my $constraint = "";
1155cdf0e10cSrcweir			my $isusedpatch = 0;
1156cdf0e10cSrcweir
1157cdf0e10cSrcweir			if ( $patchdefinition =~ /^\s*(.+)\(([+-])(.+)\)\s*$/ )
1158cdf0e10cSrcweir			{
1159cdf0e10cSrcweir				$patchid = $1;
1160cdf0e10cSrcweir				$symbol = $2;
1161cdf0e10cSrcweir				$constraint = $3;
1162cdf0e10cSrcweir			}
1163cdf0e10cSrcweir			elsif (( $patchdefinition =~ /\(/ ) || ( $patchdefinition =~ /\)/ ))	# small syntax check
1164cdf0e10cSrcweir			{
1165cdf0e10cSrcweir				# if there is a bracket in the $patchdefinition, but it does not
1166cdf0e10cSrcweir				# match the if-condition, this is an erroneous definition.
1167cdf0e10cSrcweir				installer::exiter::exit_program("ERROR: Unknown patch string: $patchdefinition", "set_patchlist_in_pkginfo_for_respin");
1168cdf0e10cSrcweir			}
1169cdf0e10cSrcweir			else
1170cdf0e10cSrcweir			{
1171cdf0e10cSrcweir				$patchid = $patchdefinition;
1172cdf0e10cSrcweir				$isusedpatch = 1; # patches without constraint are always included
1173cdf0e10cSrcweir			}
1174cdf0e10cSrcweir
1175cdf0e10cSrcweir			if ( $symbol ne "" )
1176cdf0e10cSrcweir			{
1177cdf0e10cSrcweir				if ( $symbol eq "+" )
1178cdf0e10cSrcweir				{
1179cdf0e10cSrcweir					if ( $packagename =~ /^.*\Q$constraint\E\s*$/ ) { $isusedpatch = 1; }
1180cdf0e10cSrcweir				}
1181cdf0e10cSrcweir
1182cdf0e10cSrcweir				if ( $symbol eq "-" )
1183cdf0e10cSrcweir				{
1184cdf0e10cSrcweir					if ( ! ( $packagename =~ /^.*\Q$constraint\E\s*$/ )) { $isusedpatch = 1; }
1185cdf0e10cSrcweir				}
1186cdf0e10cSrcweir			}
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir			if ( $isusedpatch ) { push(@usedpatches, $patchid); }
1189cdf0e10cSrcweir		}
1190cdf0e10cSrcweir
1191cdf0e10cSrcweir		if ( $#usedpatches > -1 )
1192cdf0e10cSrcweir		{
1193cdf0e10cSrcweir			my $patchstring = installer::converter::convert_array_to_space_separated_string(\@usedpatches);
1194cdf0e10cSrcweir
1195cdf0e10cSrcweir			my $newline = "PATCHLIST=" . $patchstring . "\n";
1196cdf0e10cSrcweir			add_one_line_into_file($changefile, $newline, $filename);
1197cdf0e10cSrcweir
1198cdf0e10cSrcweir			# Adding patch info for each used patch in the patchlist
1199cdf0e10cSrcweir
1200cdf0e10cSrcweir			for ( my $i = 0; $i <= $#usedpatches; $i++ )
1201cdf0e10cSrcweir			{
1202cdf0e10cSrcweir				my $patchid = $usedpatches[$i];
1203cdf0e10cSrcweir				my $key = "PATCH_INFO_" . $patchid;
1204cdf0e10cSrcweir				$key =~ s/\s*$//;
1205cdf0e10cSrcweir
1206cdf0e10cSrcweir				if ( ! $allvariables->{$key} ) { installer::exiter::exit_program("ERROR: No Patch info available in zip list file for $key", "set_patchlist_in_pkginfo"); }
1207cdf0e10cSrcweir				my $value = set_timestamp_in_patchinfo($allvariables->{$key});
1208cdf0e10cSrcweir				$newline = $key . "=" . $value . "\n";
1209cdf0e10cSrcweir
1210cdf0e10cSrcweir				add_one_line_into_file($changefile, $newline, $filename);
1211cdf0e10cSrcweir			}
1212cdf0e10cSrcweir		}
1213cdf0e10cSrcweir	}
1214cdf0e10cSrcweir}
1215cdf0e10cSrcweir
1216cdf0e10cSrcweir########################################################
1217cdf0e10cSrcweir# Solaris requires, that the time of patch installation
1218cdf0e10cSrcweir# must not be empty.
1219cdf0e10cSrcweir# Format: Mon Mar 24 11:20:56 PDT 2008
1220cdf0e10cSrcweir# Log file: Tue Apr 29 23:26:19 2008 (04:31 min.)
1221cdf0e10cSrcweir# Replace string: ${TIMESTAMP}
1222cdf0e10cSrcweir########################################################
1223cdf0e10cSrcweir
1224cdf0e10cSrcweirsub set_timestamp_in_patchinfo
1225cdf0e10cSrcweir{
1226cdf0e10cSrcweir	my ($value) = @_;
1227cdf0e10cSrcweir
1228cdf0e10cSrcweir	my $currenttime = localtime();
1229cdf0e10cSrcweir
1230cdf0e10cSrcweir	if ( $currenttime =~ /^\s*(.+?)(\d\d\d\d)\s*$/ )
1231cdf0e10cSrcweir	{
1232cdf0e10cSrcweir		my $start = $1;
1233cdf0e10cSrcweir		my $year = $2;
1234cdf0e10cSrcweir		$currenttime = $start . "CET " . $year;
1235cdf0e10cSrcweir	}
1236cdf0e10cSrcweir
1237cdf0e10cSrcweir	$value =~ s/\$\{TIMESTAMP\}/$currenttime/;
1238cdf0e10cSrcweir
1239cdf0e10cSrcweir	return $value;
1240cdf0e10cSrcweir}
1241cdf0e10cSrcweir
1242cdf0e10cSrcweir########################################################
1243cdf0e10cSrcweir# Setting MAXINST=1000 into the pkginfo file.
1244cdf0e10cSrcweir########################################################
1245cdf0e10cSrcweir
1246cdf0e10cSrcweirsub set_maxinst_in_pkginfo
1247cdf0e10cSrcweir{
1248cdf0e10cSrcweir	my ($changefile, $filename) = @_;
1249cdf0e10cSrcweir
1250cdf0e10cSrcweir	my $newline = "MAXINST\=1000\n";
1251cdf0e10cSrcweir
1252cdf0e10cSrcweir	add_one_line_into_file($changefile, $newline, $filename);
1253cdf0e10cSrcweir}
1254cdf0e10cSrcweir
1255cdf0e10cSrcweir#############################################################
1256cdf0e10cSrcweir# Setting several Solaris variables into the pkginfo file.
1257cdf0e10cSrcweir#############################################################
1258cdf0e10cSrcweir
1259cdf0e10cSrcweirsub set_solaris_parameter_in_pkginfo
1260cdf0e10cSrcweir{
1261cdf0e10cSrcweir	my ($changefile, $filename, $allvariables) = @_;
1262cdf0e10cSrcweir
1263cdf0e10cSrcweir	my $newline = "";
1264cdf0e10cSrcweir
1265cdf0e10cSrcweir	# SUNW_PRODNAME
1266cdf0e10cSrcweir	# SUNW_PRODVERS
1267cdf0e10cSrcweir	# SUNW_PKGVERS
1268cdf0e10cSrcweir	# Not: SUNW_PKGTYPE
1269cdf0e10cSrcweir	# HOTLINE
1270cdf0e10cSrcweir	# EMAIL
1271cdf0e10cSrcweir
1272cdf0e10cSrcweir	my $productname = $allvariables->{'PRODUCTNAME'};
1273cdf0e10cSrcweir	$newline = "SUNW_PRODNAME=$productname\n";
1274cdf0e10cSrcweir	add_one_line_into_file($changefile, $newline, $filename);
1275cdf0e10cSrcweir
1276cdf0e10cSrcweir	my $productversion = "";
1277cdf0e10cSrcweir	if ( $allvariables->{'PRODUCTVERSION'} )
1278cdf0e10cSrcweir	{
1279cdf0e10cSrcweir		$productversion = $allvariables->{'PRODUCTVERSION'};
1280cdf0e10cSrcweir		if ( $allvariables->{'PRODUCTEXTENSION'} ) { $productversion = $productversion . "/" . $allvariables->{'PRODUCTEXTENSION'}; }
1281cdf0e10cSrcweir	}
1282cdf0e10cSrcweir	$newline = "SUNW_PRODVERS=$productversion\n";
1283cdf0e10cSrcweir	add_one_line_into_file($changefile, $newline, $filename);
1284cdf0e10cSrcweir
1285cdf0e10cSrcweir	$newline = "SUNW_PKGVERS=1\.0\n";
1286cdf0e10cSrcweir	add_one_line_into_file($changefile, $newline, $filename);
1287cdf0e10cSrcweir
1288cdf0e10cSrcweir	if ( $allvariables->{'SUNW_PKGTYPE'} )
1289cdf0e10cSrcweir	{
1290cdf0e10cSrcweir		$newline = "SUNW_PKGTYPE=$allvariables->{'SUNW_PKGTYPE'}\n";
1291cdf0e10cSrcweir		add_one_line_into_file($changefile, $newline, $filename);
1292cdf0e10cSrcweir	}
1293cdf0e10cSrcweir    else
1294cdf0e10cSrcweir    {
1295cdf0e10cSrcweir        $newline = "SUNW_PKGTYPE=\n";
1296cdf0e10cSrcweir        add_one_line_into_file($changefile, $newline, $filename);
1297cdf0e10cSrcweir    }
1298cdf0e10cSrcweir
1299cdf0e10cSrcweir	$newline = "HOTLINE=Please contact your local service provider\n";
1300cdf0e10cSrcweir	add_one_line_into_file($changefile, $newline, $filename);
1301cdf0e10cSrcweir
1302cdf0e10cSrcweir	$newline = "EMAIL=\n";
1303cdf0e10cSrcweir	add_one_line_into_file($changefile, $newline, $filename);
1304cdf0e10cSrcweir
1305cdf0e10cSrcweir}
1306cdf0e10cSrcweir
1307cdf0e10cSrcweir#####################################################################
1308cdf0e10cSrcweir# epm uses as archtecture for Solaris x86 "i86pc". This has to be
1309cdf0e10cSrcweir# changed to "i386".
1310cdf0e10cSrcweir#####################################################################
1311cdf0e10cSrcweir
1312cdf0e10cSrcweirsub fix_architecture_setting
1313cdf0e10cSrcweir{
1314cdf0e10cSrcweir	my ($changefile) = @_;
1315cdf0e10cSrcweir
1316cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1317cdf0e10cSrcweir	{
1318cdf0e10cSrcweir		if ( ${$changefile}[$i] =~ /^\s*ARCH=i86pc\s*$/ )
1319cdf0e10cSrcweir		{
1320cdf0e10cSrcweir			${$changefile}[$i] =~ s/i86pc/i386/;
1321cdf0e10cSrcweir			last;
1322cdf0e10cSrcweir		}
1323cdf0e10cSrcweir
1324cdf0e10cSrcweir	}
1325cdf0e10cSrcweir}
1326cdf0e10cSrcweir
1327cdf0e10cSrcweir#####################################################################
1328cdf0e10cSrcweir# Adding a new line for topdir into specfile, removing old
1329cdf0e10cSrcweir# topdir if set.
1330cdf0e10cSrcweir#####################################################################
1331cdf0e10cSrcweir
1332cdf0e10cSrcweirsub set_topdir_in_specfile
1333cdf0e10cSrcweir{
1334cdf0e10cSrcweir	my ($changefile, $filename, $newepmdir) = @_;
1335cdf0e10cSrcweir
1336cdf0e10cSrcweir	# $newepmdir =~ s/^\s*\.//;	# removing leading "."
1337cdf0e10cSrcweir	$newepmdir = cwd() . $installer::globals::separator . $newepmdir; # only absolute path allowed
1338cdf0e10cSrcweir
1339cdf0e10cSrcweir	# removing "%define _topdir", if existing
1340cdf0e10cSrcweir
1341cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1342cdf0e10cSrcweir	{
1343cdf0e10cSrcweir		if ( ${$changefile}[$i] =~ /^\s*\%define _topdir\s+/ )
1344cdf0e10cSrcweir		{
1345cdf0e10cSrcweir			my $removeline = ${$changefile}[$i];
1346cdf0e10cSrcweir			$removeline =~ s/\s*$//;
1347cdf0e10cSrcweir			splice(@{$changefile},$i,1);
1348cdf0e10cSrcweir			my $infoline = "Info: Removed line \"$removeline\" from file $filename!\n";
1349cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1350cdf0e10cSrcweir			last;
1351cdf0e10cSrcweir		}
1352cdf0e10cSrcweir	}
1353cdf0e10cSrcweir
1354cdf0e10cSrcweir	# Adding "topdir" behind the line beginning with: Group:
1355cdf0e10cSrcweir
1356cdf0e10cSrcweir	my $inserted_line = 0;
1357cdf0e10cSrcweir
1358cdf0e10cSrcweir	my $topdirline = "\%define _topdir $newepmdir\n";
1359cdf0e10cSrcweir
1360cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1361cdf0e10cSrcweir	{
1362cdf0e10cSrcweir		if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1363cdf0e10cSrcweir		{
1364cdf0e10cSrcweir			splice(@{$changefile},$i+1,0,$topdirline);
1365cdf0e10cSrcweir			$inserted_line = 1;
1366cdf0e10cSrcweir			$topdirline =~ s/\s*$//;
1367cdf0e10cSrcweir			my $infoline = "Success: Added line $topdirline into file $filename!\n";
1368cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1369cdf0e10cSrcweir		}
1370cdf0e10cSrcweir	}
1371cdf0e10cSrcweir
1372cdf0e10cSrcweir	if (! $inserted_line) { installer::exiter::exit_program("ERROR: Did not find string \"Group:\" in file: $filename", "set_topdir_in_specfile"); }
1373cdf0e10cSrcweir
1374cdf0e10cSrcweir}
1375cdf0e10cSrcweir
1376cdf0e10cSrcweir#####################################################################
1377cdf0e10cSrcweir# Setting the packager in the spec file
1378cdf0e10cSrcweir# Syntax: Packager: abc@def
1379cdf0e10cSrcweir#####################################################################
1380cdf0e10cSrcweir
1381cdf0e10cSrcweirsub set_packager_in_specfile
1382cdf0e10cSrcweir{
1383cdf0e10cSrcweir	my ($changefile) = @_;
1384cdf0e10cSrcweir
1385cdf0e10cSrcweir	my $packager = $installer::globals::longmanufacturer;
1386cdf0e10cSrcweir
1387cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1388cdf0e10cSrcweir	{
1389cdf0e10cSrcweir		if ( ${$changefile}[$i] =~ /^\s*Packager\s*:\s*(.+?)\s*$/ )
1390cdf0e10cSrcweir		{
1391cdf0e10cSrcweir			my $oldstring = $1;
1392cdf0e10cSrcweir			${$changefile}[$i] =~ s/\Q$oldstring\E/$packager/;
1393cdf0e10cSrcweir			my $infoline = "Info: Changed Packager in spec file from $oldstring to $packager!\n";
1394cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1395cdf0e10cSrcweir			last;
1396cdf0e10cSrcweir		}
1397cdf0e10cSrcweir	}
1398cdf0e10cSrcweir}
1399cdf0e10cSrcweir
1400cdf0e10cSrcweir#####################################################################
1401cdf0e10cSrcweir# Setting the requirements in the spec file (i81494)
1402cdf0e10cSrcweir# Syntax: PreReq: "requirements" (only for shared extensions)
1403cdf0e10cSrcweir#####################################################################
1404cdf0e10cSrcweir
1405cdf0e10cSrcweirsub set_prereq_in_specfile
1406cdf0e10cSrcweir{
1407cdf0e10cSrcweir	my ($changefile) = @_;
1408cdf0e10cSrcweir
1409cdf0e10cSrcweir	my $prereq = "PreReq:";
1410cdf0e10cSrcweir
1411cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1412cdf0e10cSrcweir	{
1413cdf0e10cSrcweir		if ( ${$changefile}[$i] =~ /^\s*Requires:\s*(.+?)\s*$/ )
1414cdf0e10cSrcweir		{
1415cdf0e10cSrcweir			my $oldstring = ${$changefile}[$i];
1416cdf0e10cSrcweir			${$changefile}[$i] =~ s/Requires:/$prereq/;
1417cdf0e10cSrcweir			my $infoline = "Info: Changed requirements in spec file from $oldstring to ${$changefile}[$i]!\n";
1418cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1419cdf0e10cSrcweir		}
1420cdf0e10cSrcweir	}
1421cdf0e10cSrcweir}
1422cdf0e10cSrcweir
1423cdf0e10cSrcweir#####################################################################
1424cdf0e10cSrcweir# Setting the Auto[Req]Prov line and __find_requires
1425cdf0e10cSrcweir#####################################################################
1426cdf0e10cSrcweir
1427cdf0e10cSrcweirsub set_autoprovreq_in_specfile
1428cdf0e10cSrcweir{
1429cdf0e10cSrcweir    my ($changefile, $findrequires, $bindir) = @_;
1430cdf0e10cSrcweir
1431cdf0e10cSrcweir	my $autoreqprovline;
1432cdf0e10cSrcweir
1433cdf0e10cSrcweir    if ( $findrequires )
1434cdf0e10cSrcweir    {
1435cdf0e10cSrcweir        $autoreqprovline = "AutoProv\: no\n%define __find_requires $bindir/$findrequires\n";
1436cdf0e10cSrcweir    }
1437cdf0e10cSrcweir    else
1438cdf0e10cSrcweir    {
1439cdf0e10cSrcweir        $autoreqprovline = "AutoReqProv\: no\n";
1440cdf0e10cSrcweir    }
1441cdf0e10cSrcweir
1442cdf0e10cSrcweir    $autoreqprovline .= "%define _binary_filedigest_algorithm 1\n%define _binary_payload w9.gzdio\n";
1443cdf0e10cSrcweir
1444cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1445cdf0e10cSrcweir	{
1446cdf0e10cSrcweir        # Adding "autoreqprov" behind the line beginning with: Group:
1447cdf0e10cSrcweir		if ( ${$changefile}[$i] =~ /^\s*Group\:\s*/ )
1448cdf0e10cSrcweir		{
1449cdf0e10cSrcweir			splice(@{$changefile},$i+1,0,$autoreqprovline);
1450cdf0e10cSrcweir			$autoreqprovline =~ s/\s*$//;
1451cdf0e10cSrcweir            $infoline = "Success: Added line $autoreqprovline into spec file!\n";
1452cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1453cdf0e10cSrcweir
1454cdf0e10cSrcweir			last;
1455cdf0e10cSrcweir        }
1456cdf0e10cSrcweir    }
1457cdf0e10cSrcweir}
1458cdf0e10cSrcweir
1459cdf0e10cSrcweir#####################################################################
1460cdf0e10cSrcweir# Replacing Copyright with License in the spec file
1461cdf0e10cSrcweir# Syntax: License: LGPL, SISSL
1462cdf0e10cSrcweir#####################################################################
1463cdf0e10cSrcweir
1464cdf0e10cSrcweirsub set_license_in_specfile
1465cdf0e10cSrcweir{
1466cdf0e10cSrcweir	my ($changefile, $variableshashref) = @_;
1467cdf0e10cSrcweir
1468cdf0e10cSrcweir	my $license = $variableshashref->{'LICENSENAME'};
1469cdf0e10cSrcweir
1470cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1471cdf0e10cSrcweir	{
1472cdf0e10cSrcweir		if ( ${$changefile}[$i] =~ /^\s*Copyright\s*:\s*(.+?)\s*$/ )
1473cdf0e10cSrcweir		{
1474cdf0e10cSrcweir			${$changefile}[$i] = "License: $license\n";
1475cdf0e10cSrcweir			my $infoline = "Info: Replaced Copyright with License: $license !\n";
1476cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1477cdf0e10cSrcweir			last;
1478cdf0e10cSrcweir		}
1479cdf0e10cSrcweir	}
1480cdf0e10cSrcweir}
1481cdf0e10cSrcweir
1482cdf0e10cSrcweir#########################################################
1483cdf0e10cSrcweir# Building relocatable Solaris packages means:
1484cdf0e10cSrcweir# 1. Add "BASEDIR=/opt" into pkginfo
1485cdf0e10cSrcweir# 2. Remove "/opt/" from all objects in prototype file
1486cdf0e10cSrcweir# For step2 this function exists
1487cdf0e10cSrcweir# Sample: d none /opt/openofficeorg20/help 0755 root other
1488cdf0e10cSrcweir# -> d none openofficeorg20/help 0755 root other
1489cdf0e10cSrcweir#########################################################
1490cdf0e10cSrcweir
1491cdf0e10cSrcweirsub make_prototypefile_relocatable
1492cdf0e10cSrcweir{
1493cdf0e10cSrcweir	my ($prototypefile, $relocatablepath) = @_;
1494cdf0e10cSrcweir
1495cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1496cdf0e10cSrcweir	{
1497cdf0e10cSrcweir		if ( ${$prototypefile}[$i] =~ /^\s*\w\s+\w+\s+\/\w+/ )	# this is an object line
1498cdf0e10cSrcweir		{
1499cdf0e10cSrcweir			${$prototypefile}[$i] =~ s/$relocatablepath//;	# Important: $relocatablepath has a "/" at the end. Example "/opt/"
1500cdf0e10cSrcweir		}
1501cdf0e10cSrcweir	}
1502cdf0e10cSrcweir
1503cdf0e10cSrcweir	# If the $relocatablepath is "/opt/openoffice20/" the line "d none /opt/openoffice20" was not changed.
1504cdf0e10cSrcweir	# This line has to be removed now
1505cdf0e10cSrcweir
1506cdf0e10cSrcweir	if ( $relocatablepath ne "/" ) { $relocatablepath =~ s/\/\s*$//; }		# removing the ending slash
1507cdf0e10cSrcweir
1508cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1509cdf0e10cSrcweir	{
1510cdf0e10cSrcweir		if ( ${$prototypefile}[$i] =~ /^\s*d\s+\w+\s+\Q$relocatablepath\E/ )
1511cdf0e10cSrcweir		{
1512cdf0e10cSrcweir			my $line = ${$prototypefile}[$i];
1513cdf0e10cSrcweir			splice(@{$prototypefile},$i,1);	# removing the line
1514cdf0e10cSrcweir			$line =~ s/\s*$//;
1515cdf0e10cSrcweir			my $infoline = "Info: Removed line \"$line\" from prototype file!\n";
1516cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
1517cdf0e10cSrcweir			last;
1518cdf0e10cSrcweir		}
1519cdf0e10cSrcweir	}
1520cdf0e10cSrcweir
1521cdf0e10cSrcweir	# Making "\$" to "$" in prototype file. "\$" was created by epm.
1522cdf0e10cSrcweir
1523cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1524cdf0e10cSrcweir	{
1525cdf0e10cSrcweir		if ( ${$prototypefile}[$i] =~ /\\\$/ )
1526cdf0e10cSrcweir		{
1527cdf0e10cSrcweir			${$prototypefile}[$i] =~ s/\\\$/\$/g;
1528cdf0e10cSrcweir			my $infoline2 = "Info: Changed line in prototype file: ${$prototypefile}[$i] !\n";
1529cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline2);
1530cdf0e10cSrcweir		}
1531cdf0e10cSrcweir	}
1532cdf0e10cSrcweir}
1533cdf0e10cSrcweir
1534cdf0e10cSrcweir
1535cdf0e10cSrcweir#########################################################################
1536cdf0e10cSrcweir# In scp the flag VOLATEFILE can be used. This shall lead to style "v"
1537cdf0e10cSrcweir# in Solaris prototype file. This is not supported by epm and has
1538cdf0e10cSrcweir# therefore to be included in prototypefile, not in epm list file.
1539cdf0e10cSrcweir#########################################################################
1540cdf0e10cSrcweir
1541cdf0e10cSrcweirsub set_volatilefile_into_prototypefile
1542cdf0e10cSrcweir{
1543cdf0e10cSrcweir	my ($prototypefile, $filesref) = @_;
1544cdf0e10cSrcweir
1545cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1546cdf0e10cSrcweir	{
1547cdf0e10cSrcweir		my $onefile = ${$filesref}[$i];
1548cdf0e10cSrcweir
1549cdf0e10cSrcweir		my $styles = "";
1550cdf0e10cSrcweir		if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
1551cdf0e10cSrcweir
1552cdf0e10cSrcweir		if ( $styles =~ /\bVOLATILEFILE\b/ )
1553cdf0e10cSrcweir		{
1554cdf0e10cSrcweir			my $sourcepath = $onefile->{'sourcepath'};
1555cdf0e10cSrcweir
1556cdf0e10cSrcweir			for ( my $j = 0; $j <= $#{$prototypefile}; $j++ )
1557cdf0e10cSrcweir			{
1558cdf0e10cSrcweir				if (( ${$prototypefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$prototypefile}[$j] =~ /\=\Q$sourcepath\E\s+/ ))
1559cdf0e10cSrcweir				{
1560cdf0e10cSrcweir					my $oldline = ${$prototypefile}[$j];
1561cdf0e10cSrcweir					${$prototypefile}[$j] =~ s/^\s*f/v/;
1562cdf0e10cSrcweir					my $newline = ${$prototypefile}[$j];
1563cdf0e10cSrcweir					$oldline =~ s/\s*$//;
1564cdf0e10cSrcweir					$newline =~ s/\s*$//;
1565cdf0e10cSrcweir					my $infoline = "Volatile file: Changing content from \"$oldline\" to \"$newline\" .\n";
1566cdf0e10cSrcweir					push(@installer::globals::logfileinfo, $infoline);
1567cdf0e10cSrcweir					last;
1568cdf0e10cSrcweir				}
1569cdf0e10cSrcweir			}
1570cdf0e10cSrcweir		}
1571cdf0e10cSrcweir	}
1572cdf0e10cSrcweir}
1573cdf0e10cSrcweir
1574cdf0e10cSrcweir#########################################################################
1575cdf0e10cSrcweir# Replacing the variables in the Solaris patch shell scripts.
1576cdf0e10cSrcweir# Taking care, that multiple slashes are not always removed.
1577cdf0e10cSrcweir#########################################################################
1578cdf0e10cSrcweir
1579cdf0e10cSrcweirsub replace_variables_in_shellscripts_for_patch
1580cdf0e10cSrcweir{
1581cdf0e10cSrcweir	my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_;
1582cdf0e10cSrcweir
1583cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
1584cdf0e10cSrcweir	{
1585cdf0e10cSrcweir		if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ )
1586cdf0e10cSrcweir		{
1587cdf0e10cSrcweir			my $oldline = ${$scriptfile}[$i];
1588cdf0e10cSrcweir			if (( $oldstring eq "PRODUCTDIRECTORYNAME" ) && ( $newstring eq "" )) { $oldstring = $oldstring . "/"; }
1589cdf0e10cSrcweir			${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g;
1590cdf0e10cSrcweir			my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n";
1591cdf0e10cSrcweir			push(@installer::globals::logfileinfo, $infoline);
1592cdf0e10cSrcweir		}
1593cdf0e10cSrcweir	}
1594cdf0e10cSrcweir}
1595cdf0e10cSrcweir
1596cdf0e10cSrcweir#########################################################################
1597cdf0e10cSrcweir# Replacing the variables in the shell scripts or in the epm list file
1598cdf0e10cSrcweir# Linux: spec file
1599cdf0e10cSrcweir# Solaris: preinstall, postinstall, preremove, postremove
1600cdf0e10cSrcweir# If epm is used in the original version (not relocatable)
1601cdf0e10cSrcweir# the variables have to be exchanged in the list file,
1602cdf0e10cSrcweir# created for epm.
1603cdf0e10cSrcweir#########################################################################
1604cdf0e10cSrcweir
1605cdf0e10cSrcweirsub replace_variables_in_shellscripts
1606cdf0e10cSrcweir{
1607cdf0e10cSrcweir	my ($scriptfile, $scriptfilename, $oldstring, $newstring) = @_;
1608cdf0e10cSrcweir
1609cdf0e10cSrcweir	my $debug = 0;
1610cdf0e10cSrcweir	if ( $oldstring eq "PRODUCTDIRECTORYNAME" ) { $debug = 1; }
1611cdf0e10cSrcweir
1612cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$scriptfile}; $i++ )
1613cdf0e10cSrcweir	{
1614cdf0e10cSrcweir		if ( ${$scriptfile}[$i] =~ /\Q$oldstring\E/ )
1615cdf0e10cSrcweir		{
1616cdf0e10cSrcweir			my $oldline = ${$scriptfile}[$i];
1617cdf0e10cSrcweir			${$scriptfile}[$i] =~ s/\Q$oldstring\E/$newstring/g;
1618cdf0e10cSrcweir			${$scriptfile}[$i] =~ s/\/\//\//g;	# replacing "//" by "/" , if path $newstring is empty!
1619cdf0e10cSrcweir			my $infoline = "Info: Substituting in $scriptfilename $oldstring by $newstring\n";
1620cdf0e10cSrcweir			push(@installer::globals::logfileinfo, $infoline);
1621cdf0e10cSrcweir			if ( $debug )
1622cdf0e10cSrcweir			{
1623cdf0e10cSrcweir				$infoline = "Old Line: $oldline";
1624cdf0e10cSrcweir				push(@installer::globals::logfileinfo, $infoline);
1625cdf0e10cSrcweir				$infoline = "New Line: ${$scriptfile}[$i]";
1626cdf0e10cSrcweir				push(@installer::globals::logfileinfo, $infoline);
1627cdf0e10cSrcweir			}
1628cdf0e10cSrcweir		}
1629cdf0e10cSrcweir	}
1630cdf0e10cSrcweir}
1631cdf0e10cSrcweir
1632cdf0e10cSrcweir############################################################
1633cdf0e10cSrcweir# Determinig the directory created by epm, in which the
1634cdf0e10cSrcweir# RPMS or Solaris packages are created.
1635cdf0e10cSrcweir############################################################
1636cdf0e10cSrcweir
1637cdf0e10cSrcweirsub determine_installdir_ooo
1638cdf0e10cSrcweir{
1639cdf0e10cSrcweir	# A simple "ls" command returns the directory name
1640cdf0e10cSrcweir
1641cdf0e10cSrcweir	my $dirname = "";
1642cdf0e10cSrcweir
1643cdf0e10cSrcweir	my $systemcall = "ls |";
1644cdf0e10cSrcweir	open (LS, "$systemcall");
1645cdf0e10cSrcweir	$dirname = <LS>;
1646cdf0e10cSrcweir	close (LS);
1647cdf0e10cSrcweir
1648cdf0e10cSrcweir	$dirname =~ s/\s*$//;
1649cdf0e10cSrcweir
1650cdf0e10cSrcweir	my $infoline = "Info: Directory created by epm: $dirname\n";
1651cdf0e10cSrcweir	push(@installer::globals::logfileinfo, $infoline);
1652cdf0e10cSrcweir
1653cdf0e10cSrcweir	return $dirname;
1654cdf0e10cSrcweir}
1655cdf0e10cSrcweir
1656cdf0e10cSrcweir############################################################
1657cdf0e10cSrcweir# Setting the tab content into the file container
1658cdf0e10cSrcweir############################################################
1659cdf0e10cSrcweir
1660cdf0e10cSrcweirsub set_tab_into_datafile
1661cdf0e10cSrcweir{
1662cdf0e10cSrcweir	my ($changefile, $filesref) = @_;
1663cdf0e10cSrcweir
1664cdf0e10cSrcweir	my @newclasses = ();
1665cdf0e10cSrcweir	my $newclassesstring = "";
1666cdf0e10cSrcweir
1667cdf0e10cSrcweir	if ( $installer::globals::issolarispkgbuild )
1668cdf0e10cSrcweir	{
1669cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1670cdf0e10cSrcweir		{
1671cdf0e10cSrcweir			my $onefile = ${$filesref}[$i];
1672cdf0e10cSrcweir
1673cdf0e10cSrcweir			if ( $onefile->{'SolarisClass'} )
1674cdf0e10cSrcweir			{
1675cdf0e10cSrcweir				my $sourcepath = $onefile->{'sourcepath'};
1676cdf0e10cSrcweir
1677cdf0e10cSrcweir				for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1678cdf0e10cSrcweir				{
1679cdf0e10cSrcweir					if (( ${$changefile}[$j] =~ /^\s*f\s+none\s+/ ) && ( ${$changefile}[$j] =~ /\=\Q$sourcepath\E\s+/ ))
1680cdf0e10cSrcweir					{
1681cdf0e10cSrcweir						my $oldline = ${$changefile}[$j];
1682cdf0e10cSrcweir						${$changefile}[$j] =~ s/f\s+none/e $onefile->{'SolarisClass'}/;
1683cdf0e10cSrcweir						my $newline = ${$changefile}[$j];
1684cdf0e10cSrcweir						$oldline =~ s/\s*$//;
1685cdf0e10cSrcweir						$newline =~ s/\s*$//;
1686cdf0e10cSrcweir
1687cdf0e10cSrcweir						my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n";
1688cdf0e10cSrcweir						push(@installer::globals::logfileinfo, $infoline);
1689cdf0e10cSrcweir
1690cdf0e10cSrcweir						# collecting all new classes
1691cdf0e10cSrcweir						if (! installer::existence::exists_in_array($onefile->{'SolarisClass'}, \@newclasses))
1692cdf0e10cSrcweir						{
1693cdf0e10cSrcweir							push(@newclasses, $onefile->{'SolarisClass'});
1694cdf0e10cSrcweir						}
1695cdf0e10cSrcweir
1696cdf0e10cSrcweir						last;
1697cdf0e10cSrcweir					}
1698cdf0e10cSrcweir				}
1699cdf0e10cSrcweir			}
1700cdf0e10cSrcweir		}
1701cdf0e10cSrcweir
1702cdf0e10cSrcweir		$newclassesstring = installer::converter::convert_array_to_space_separated_string(\@newclasses);
1703cdf0e10cSrcweir	}
1704cdf0e10cSrcweir
1705cdf0e10cSrcweir	if ( $installer::globals::islinuxrpmbuild )
1706cdf0e10cSrcweir	{
1707cdf0e10cSrcweir		for ( my $i = 0; $i <= $#{$filesref}; $i++ )
1708cdf0e10cSrcweir		{
1709cdf0e10cSrcweir			my $onefile = ${$filesref}[$i];
1710cdf0e10cSrcweir
1711cdf0e10cSrcweir			if ( $onefile->{'SpecFileContent'} )
1712cdf0e10cSrcweir			{
1713cdf0e10cSrcweir				my $destination = $onefile->{'destination'};
1714cdf0e10cSrcweir
1715cdf0e10cSrcweir				for ( my $j = 0; $j <= $#{$changefile}; $j++ )
1716cdf0e10cSrcweir				{
1717cdf0e10cSrcweir					if ( ${$changefile}[$j] =~ /^\s*(\%attr\(.*\))\s+(\".*?\Q$destination\E\"\s*)$/ )
1718cdf0e10cSrcweir					{
1719cdf0e10cSrcweir						my $begin = $1;
1720cdf0e10cSrcweir						my $end = $2;
1721cdf0e10cSrcweir
1722cdf0e10cSrcweir						my $oldline = ${$changefile}[$j];
1723cdf0e10cSrcweir						${$changefile}[$j] = $begin . " " . $onefile->{'SpecFileContent'} . " " . $end;
1724cdf0e10cSrcweir						my $newline = ${$changefile}[$j];
1725cdf0e10cSrcweir
1726cdf0e10cSrcweir						$oldline =~ s/\s*$//;
1727cdf0e10cSrcweir						$newline =~ s/\s*$//;
1728cdf0e10cSrcweir
1729cdf0e10cSrcweir						my $infoline = "TAB: Changing content from \"$oldline\" to \"$newline\" .\n";
1730cdf0e10cSrcweir						push(@installer::globals::logfileinfo, $infoline);
1731cdf0e10cSrcweir
1732cdf0e10cSrcweir						last;
1733cdf0e10cSrcweir					}
1734cdf0e10cSrcweir				}
1735cdf0e10cSrcweir			}
1736cdf0e10cSrcweir		}
1737cdf0e10cSrcweir	}
1738cdf0e10cSrcweir
1739cdf0e10cSrcweir	return $newclassesstring;
1740cdf0e10cSrcweir}
1741cdf0e10cSrcweir
1742cdf0e10cSrcweir############################################################
1743cdf0e10cSrcweir# Including additional classes into the pkginfo file
1744cdf0e10cSrcweir############################################################
1745cdf0e10cSrcweir
1746cdf0e10cSrcweirsub include_classes_into_pkginfo
1747cdf0e10cSrcweir{
1748cdf0e10cSrcweir	my ($changefile, $classesstring) = @_;
1749cdf0e10cSrcweir
1750cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$changefile}; $i++ )
1751cdf0e10cSrcweir	{
1752cdf0e10cSrcweir		if ( ${$changefile}[$i] =~ /^\s*CLASSES\=none/ )
1753cdf0e10cSrcweir		{
1754cdf0e10cSrcweir			${$changefile}[$i] =~ s/\s*$//;
1755cdf0e10cSrcweir			my $oldline = ${$changefile}[$i];
1756cdf0e10cSrcweir			${$changefile}[$i] = ${$changefile}[$i] . " " . $classesstring . "\n";
1757cdf0e10cSrcweir			my $newline = ${$changefile}[$i];
1758cdf0e10cSrcweir			$newline =~ s/\s*$//;
1759cdf0e10cSrcweir
1760cdf0e10cSrcweir			my $infoline = "pkginfo file: Changing content from \"$oldline\" to \"$newline\" .\n";
1761cdf0e10cSrcweir			push(@installer::globals::logfileinfo, $infoline);
1762cdf0e10cSrcweir		}
1763cdf0e10cSrcweir	}
1764cdf0e10cSrcweir}
1765cdf0e10cSrcweir
1766cdf0e10cSrcweir##########################################################################################
1767cdf0e10cSrcweir# Checking, if an extension is included into the package (Linux).
1768cdf0e10cSrcweir# All extension files have to be installed into directory
1769cdf0e10cSrcweir# share/extension/install
1770cdf0e10cSrcweir# %attr(0444,root,root) "/opt/staroffice8/share/extension/install/SunSearchToolbar.oxt"
1771cdf0e10cSrcweir##########################################################################################
1772cdf0e10cSrcweir
1773cdf0e10cSrcweirsub is_extension_package
1774cdf0e10cSrcweir{
1775cdf0e10cSrcweir	my ($specfile) = @_;
1776cdf0e10cSrcweir
1777cdf0e10cSrcweir	my $is_extension_package = 0;
1778cdf0e10cSrcweir
1779cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$specfile}; $i++ )
1780cdf0e10cSrcweir	{
1781cdf0e10cSrcweir		my $line = ${$specfile}[$i];
1782cdf0e10cSrcweir		if ( $line =~ /share\/extension\/install\/.*?\.oxt\"\s*$/ )
1783cdf0e10cSrcweir		{
1784cdf0e10cSrcweir			$is_extension_package = 1;
1785cdf0e10cSrcweir			last;
1786cdf0e10cSrcweir		}
1787cdf0e10cSrcweir	}
1788cdf0e10cSrcweir
1789cdf0e10cSrcweir	return $is_extension_package;
1790cdf0e10cSrcweir}
1791cdf0e10cSrcweir
1792cdf0e10cSrcweir######################################################################
1793cdf0e10cSrcweir# Checking, if an extension is included into the package (Solaris).
1794cdf0e10cSrcweir# All extension files have to be installed into directory
1795cdf0e10cSrcweir# share/extension/install
1796cdf0e10cSrcweir######################################################################
1797cdf0e10cSrcweir
1798cdf0e10cSrcweirsub contains_extension_dir
1799cdf0e10cSrcweir{
1800cdf0e10cSrcweir	my ($prototypefile) = @_;
1801cdf0e10cSrcweir
1802cdf0e10cSrcweir	my $contains_extension_dir = 0;
1803cdf0e10cSrcweir
1804cdf0e10cSrcweir	# d none opt/openoffice.org3/share/extensions/
1805cdf0e10cSrcweir
1806cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1807cdf0e10cSrcweir	{
1808cdf0e10cSrcweir		my $line = ${$prototypefile}[$i];
1809cdf0e10cSrcweir		if ( $line =~ /^\s*d\s+none\s.*\/share\/extensions\// )
1810cdf0e10cSrcweir		{
1811cdf0e10cSrcweir			$contains_extension_dir = 1;
1812cdf0e10cSrcweir			last;
1813cdf0e10cSrcweir		}
1814cdf0e10cSrcweir	}
1815cdf0e10cSrcweir
1816cdf0e10cSrcweir	return $contains_extension_dir;
1817cdf0e10cSrcweir}
1818cdf0e10cSrcweir
1819cdf0e10cSrcweir############################################################
1820cdf0e10cSrcweir# A Solaris patch contains 7 specific scripts
1821cdf0e10cSrcweir############################################################
1822cdf0e10cSrcweir
1823cdf0e10cSrcweirsub add_scripts_into_prototypefile
1824cdf0e10cSrcweir{
1825cdf0e10cSrcweir	my ($prototypefile, $prototypefilename, $languagestringref, $staticpath) = @_;
1826cdf0e10cSrcweir
1827cdf0e10cSrcweir	# The files are stored in the directory $installer::globals::patchincludepath
1828cdf0e10cSrcweir	# The file names are available via @installer::globals::solarispatchscripts
1829cdf0e10cSrcweir
1830cdf0e10cSrcweir	my $path = $installer::globals::patchincludepath;
1831cdf0e10cSrcweir	$path =~ s/\/\s*$//;
1832cdf0e10cSrcweir	$path = $path . $installer::globals::separator;
1833cdf0e10cSrcweir
1834cdf0e10cSrcweir	my @newlines = ();
1835cdf0e10cSrcweir	my $is_extension_package = contains_extension_dir($prototypefile);
1836cdf0e10cSrcweir
1837cdf0e10cSrcweir	if ( $is_extension_package )
1838cdf0e10cSrcweir	{
1839cdf0e10cSrcweir		for ( my $i = 0; $i <= $#installer::globals::solarispatchscriptsforextensions; $i++ )
1840cdf0e10cSrcweir		{
1841cdf0e10cSrcweir			my $sourcefilename = $path . $installer::globals::solarispatchscriptsforextensions[$i];
1842cdf0e10cSrcweir			my $destfile = $installer::globals::solarispatchscriptsforextensions[$i];
1843cdf0e10cSrcweir
1844cdf0e10cSrcweir			# If the sourcepath has "_extension" in its name, this has to be removed
1845cdf0e10cSrcweir			$destfile =~ s/_extensions\s*$//;  # hard coded renaming of script name
1846cdf0e10cSrcweir
1847cdf0e10cSrcweir			# Creating unique directory name with $prototypefilename
1848cdf0e10cSrcweir			my $extensiondir = installer::systemactions::create_directories("extensionscripts", $languagestringref);
1849cdf0e10cSrcweir
1850cdf0e10cSrcweir			if ( $prototypefilename =~ /\/(\S*?)\s*$/ ) { $prototypefilename = $1; }
1851cdf0e10cSrcweir			$prototypefilename =~ s/\./_/g;
1852cdf0e10cSrcweir			my $destdir = $extensiondir . $installer::globals::separator . $prototypefilename;
1853cdf0e10cSrcweir			if ( ! -d $destdir ) { installer::systemactions::create_directory($destdir); }
1854cdf0e10cSrcweir			my $destpath = $destdir . $installer::globals::separator . $destfile;
1855cdf0e10cSrcweir			if ( -f $destpath ) { unlink($destpath); }
1856cdf0e10cSrcweir
1857cdf0e10cSrcweir			# Reading file
1858cdf0e10cSrcweir			my $scriptfile = installer::files::read_file($sourcefilename);
1859cdf0e10cSrcweir
1860cdf0e10cSrcweir			# Replacing variables
1861cdf0e10cSrcweir			my $oldstring = "PRODUCTDIRECTORYNAME";
1862cdf0e10cSrcweir			replace_variables_in_shellscripts_for_patch($scriptfile, $destpath, $oldstring, $staticpath);
1863cdf0e10cSrcweir
1864cdf0e10cSrcweir			# Saving file
1865cdf0e10cSrcweir			installer::files::save_file($destpath, $scriptfile);
1866cdf0e10cSrcweir
1867cdf0e10cSrcweir			# Writing file destination into prototype file
1868cdf0e10cSrcweir			my $line = "i $destfile=" . $destpath . "\n";
1869cdf0e10cSrcweir			push(@newlines, $line);
1870cdf0e10cSrcweir		}
1871cdf0e10cSrcweir	}
1872cdf0e10cSrcweir	else
1873cdf0e10cSrcweir	{
1874cdf0e10cSrcweir		for ( my $i = 0; $i <= $#installer::globals::solarispatchscripts; $i++ )
1875cdf0e10cSrcweir		{
1876cdf0e10cSrcweir			my $line = "i $installer::globals::solarispatchscripts[$i]=" . $path . $installer::globals::solarispatchscripts[$i] . "\n";
1877cdf0e10cSrcweir			push(@newlines, $line);
1878cdf0e10cSrcweir		}
1879cdf0e10cSrcweir	}
1880cdf0e10cSrcweir
1881cdf0e10cSrcweir	# Including the new lines after the last line starting with "i"
1882cdf0e10cSrcweir
1883cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$prototypefile}; $i++ )
1884cdf0e10cSrcweir	{
1885cdf0e10cSrcweir		if ( ${$prototypefile}[$i] =~ /^\s*i\s+copyright/ )
1886cdf0e10cSrcweir		{
1887cdf0e10cSrcweir			splice(@{$prototypefile}, $i, 1);	# ignoring old copyright text, using patch standard
1888cdf0e10cSrcweir			next;
1889cdf0e10cSrcweir		}
1890cdf0e10cSrcweir		if ( ${$prototypefile}[$i] =~ /^\s*i\s+/ ) { next; }
1891cdf0e10cSrcweir		splice(@{$prototypefile}, $i, 0, @newlines);
1892cdf0e10cSrcweir		last;
1893cdf0e10cSrcweir	}
1894cdf0e10cSrcweir}
1895cdf0e10cSrcweir
1896cdf0e10cSrcweir############################################################
1897cdf0e10cSrcweir# Adding patch infos in pkginfo file
1898cdf0e10cSrcweir############################################################
1899cdf0e10cSrcweir
1900cdf0e10cSrcweirsub include_patchinfos_into_pkginfo
1901cdf0e10cSrcweir{
1902cdf0e10cSrcweir	my ( $changefile, $filename, $variableshashref ) = @_;
1903cdf0e10cSrcweir
1904cdf0e10cSrcweir	# SUNW_PATCHID=101998-10
1905cdf0e10cSrcweir	# SUNW_OBSOLETES=114999-01 113999-01
1906cdf0e10cSrcweir	# SUNW_PKGTYPE=usr
1907cdf0e10cSrcweir	# SUNW_PKGVERS=1.0
1908cdf0e10cSrcweir	# SUNW_REQUIRES=126411-01
1909cdf0e10cSrcweir
1910cdf0e10cSrcweir	my $patchidname = "SOLSPARCPATCHID";
1911cdf0e10cSrcweir	if ( $installer::globals::issolarisx86build ) { $patchidname = "SOLIAPATCHID"; }
1912cdf0e10cSrcweir
1913cdf0e10cSrcweir	if ( ! $variableshashref->{$patchidname} ) { installer::exiter::exit_program("ERROR: Variable $patchidname not defined in zip list file!", "include_patchinfos_into_pkginfo"); }
1914cdf0e10cSrcweir
1915cdf0e10cSrcweir	my $newline = "SUNW_PATCHID=" . $variableshashref->{$patchidname} . "\n";
1916cdf0e10cSrcweir	add_one_line_into_file($changefile, $newline, $filename);
1917cdf0e10cSrcweir
1918cdf0e10cSrcweir	my $patchobsoletesname = "SOLSPARCPATCHOBSOLETES";
1919cdf0e10cSrcweir	if ( $installer::globals::issolarisx86build ) { $patchobsoletesname = "SOLIAPATCHOBSOLETES"; }
1920cdf0e10cSrcweir
1921cdf0e10cSrcweir	my $obsoletes = "";
1922cdf0e10cSrcweir	if ( $variableshashref->{$patchobsoletesname} ) { $obsoletes = $variableshashref->{$patchobsoletesname}; }
1923cdf0e10cSrcweir	$newline = "SUNW_OBSOLETES=" . $obsoletes . "\n";
1924cdf0e10cSrcweir	add_one_line_into_file($changefile, $newline, $filename);
1925cdf0e10cSrcweir
1926cdf0e10cSrcweir	my $patchrequiresname = "SOLSPARCPATCHREQUIRES";
1927cdf0e10cSrcweir	if ( $installer::globals::issolarisx86build ) { $patchrequiresname = "SOLIAPATCHREQUIRES"; }
1928cdf0e10cSrcweir
1929cdf0e10cSrcweir	if ( $variableshashref->{$patchrequiresname} )
1930cdf0e10cSrcweir	{
1931cdf0e10cSrcweir		my $requires = $variableshashref->{$patchrequiresname};
1932cdf0e10cSrcweir		$newline = "SUNW_REQUIRES=" . $requires . "\n";
1933cdf0e10cSrcweir		add_one_line_into_file($changefile, $newline, $filename);
1934cdf0e10cSrcweir	}
1935cdf0e10cSrcweir	$newline = "SUNW_PATCH_PROPERTIES=\n";
1936cdf0e10cSrcweir	add_one_line_into_file($changefile, $newline, $filename);
1937cdf0e10cSrcweir	# $newline = "SUNW_PKGTYPE=usr\n";
1938cdf0e10cSrcweir	# add_one_line_into_file($changefile, $newline, $filename);
1939cdf0e10cSrcweir
1940cdf0e10cSrcweir	# $newline = "SUNW_PKGVERS=1.0\n";
1941cdf0e10cSrcweir	# add_one_line_into_file($changefile, $newline, $filename);
1942cdf0e10cSrcweir}
1943cdf0e10cSrcweir
1944cdf0e10cSrcweir############################################################
1945cdf0e10cSrcweir# Setting the correct Solaris locales
1946cdf0e10cSrcweir############################################################
1947cdf0e10cSrcweir
1948cdf0e10cSrcweirsub get_solaris_language_for_langpack
1949cdf0e10cSrcweir{
1950cdf0e10cSrcweir	my ( $onelanguage ) = @_;
1951cdf0e10cSrcweir
1952cdf0e10cSrcweir	my $sollanguage = $onelanguage;
1953cdf0e10cSrcweir	$sollanguage =~ s/\-/\_/;
1954cdf0e10cSrcweir
1955cdf0e10cSrcweir	if ( $sollanguage eq "de" ) { $sollanguage = "de"; }
1956cdf0e10cSrcweir	elsif ( $sollanguage eq "en_US" ) { $sollanguage = "en_AU,en_CA,en_GB,en_IE,en_MT,en_NZ,en_US,en_US.UTF-8"; }
1957cdf0e10cSrcweir	elsif ( $sollanguage eq "es" ) { $sollanguage = "es"; }
1958cdf0e10cSrcweir	elsif ( $sollanguage eq "fr" ) { $sollanguage = "fr"; }
1959cdf0e10cSrcweir	elsif ( $sollanguage eq "hu" ) { $sollanguage = "hu_HU"; }
1960cdf0e10cSrcweir	elsif ( $sollanguage eq "it" ) { $sollanguage = "it"; }
1961cdf0e10cSrcweir	elsif ( $sollanguage eq "nl" ) { $sollanguage = "nl_BE,nl_NL"; }
1962cdf0e10cSrcweir	elsif ( $sollanguage eq "pl" ) { $sollanguage = "pl_PL"; }
1963cdf0e10cSrcweir	elsif ( $sollanguage eq "sv" ) { $sollanguage = "sv"; }
1964cdf0e10cSrcweir	elsif ( $sollanguage eq "pt" ) { $sollanguage = "pt_PT"; }
1965cdf0e10cSrcweir	elsif ( $sollanguage eq "pt_BR" ) { $sollanguage = "pt_BR"; }
1966cdf0e10cSrcweir	elsif ( $sollanguage eq "ru" ) { $sollanguage = "ru_RU"; }
1967cdf0e10cSrcweir	elsif ( $sollanguage eq "ja" ) { $sollanguage = "ja,ja_JP,ja_JP.PCK,ja_JP.UTF-8"; }
1968cdf0e10cSrcweir	elsif ( $sollanguage eq "ko" ) { $sollanguage = "ko,ko.UTF-8"; }
1969cdf0e10cSrcweir	elsif ( $sollanguage eq "zh_CN" ) { $sollanguage = "zh,zh.GBK,zh_CN.GB18030,zh.UTF-8"; }
1970cdf0e10cSrcweir	elsif ( $sollanguage eq "zh_TW" ) { $sollanguage = "zh_TW,zh_TW.BIG5,zh_TW.UTF-8,zh_HK.BIG5HK,zh_HK.UTF-8"; }
1971cdf0e10cSrcweir
1972cdf0e10cSrcweir	return $sollanguage;
1973cdf0e10cSrcweir}
1974cdf0e10cSrcweir
1975cdf0e10cSrcweir############################################################
1976cdf0e10cSrcweir# Adding language infos in pkginfo file
1977cdf0e10cSrcweir############################################################
1978cdf0e10cSrcweir
1979cdf0e10cSrcweirsub include_languageinfos_into_pkginfo
1980cdf0e10cSrcweir{
1981cdf0e10cSrcweir	my ( $changefile, $filename, $languagestringref, $onepackage, $variableshashref ) = @_;
1982cdf0e10cSrcweir
1983cdf0e10cSrcweir	# SUNWPKG_LIST=core01
1984cdf0e10cSrcweir	# SUNW_LOC=de
1985cdf0e10cSrcweir
1986cdf0e10cSrcweir	my $locallang = $onepackage->{'language'};
1987cdf0e10cSrcweir	my $solarislanguage = get_solaris_language_for_langpack($locallang);
1988cdf0e10cSrcweir
1989cdf0e10cSrcweir	my $newline = "SUNW_LOC=" . $solarislanguage . "\n";
1990cdf0e10cSrcweir	add_one_line_into_file($changefile, $newline, $filename);
1991cdf0e10cSrcweir
1992cdf0e10cSrcweir	# SUNW_PKGLIST is required, if SUNW_LOC is defined.
1993cdf0e10cSrcweir	if ( $onepackage->{'pkg_list_entry'} )
1994cdf0e10cSrcweir	{
1995cdf0e10cSrcweir		my $packagelistentry = $onepackage->{'pkg_list_entry'};
1996cdf0e10cSrcweir		installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
1997cdf0e10cSrcweir		$newline = "SUNW_PKGLIST=" . $packagelistentry . "\n";
1998cdf0e10cSrcweir		add_one_line_into_file($changefile, $newline, $filename);
1999cdf0e10cSrcweir	}
2000cdf0e10cSrcweir	else
2001cdf0e10cSrcweir	{
2002cdf0e10cSrcweir		# Using default package ooobasis30-core01.
2003cdf0e10cSrcweir		my $packagelistentry = "%BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core01";
2004cdf0e10cSrcweir		installer::packagelist::resolve_packagevariables(\$packagelistentry, $variableshashref, 1);
2005cdf0e10cSrcweir		$newline = "SUNW_PKGLIST=" . $packagelistentry . "\n";
2006cdf0e10cSrcweir		add_one_line_into_file($changefile, $newline, $filename);
2007cdf0e10cSrcweir	}
2008cdf0e10cSrcweir}
2009cdf0e10cSrcweir
2010cdf0e10cSrcweir############################################################
2011cdf0e10cSrcweir# Collecting all files included in patch in
2012cdf0e10cSrcweir# @installer::globals::patchfilecollector
2013cdf0e10cSrcweir############################################################
2014cdf0e10cSrcweir
2015cdf0e10cSrcweirsub collect_patch_files
2016cdf0e10cSrcweir{
2017cdf0e10cSrcweir	my ($file, $packagename, $prefix) = @_;
2018cdf0e10cSrcweir
2019cdf0e10cSrcweir	# $file is the spec file or the prototypefile
2020cdf0e10cSrcweir
2021cdf0e10cSrcweir	$prefix = $prefix . "/";
2022cdf0e10cSrcweir	my $packagenamestring = "Package " . $packagename . " \:\n";
2023cdf0e10cSrcweir	push(@installer::globals::patchfilecollector, $packagenamestring);
2024cdf0e10cSrcweir
2025cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$file}; $i++ )
2026cdf0e10cSrcweir	{
2027cdf0e10cSrcweir		my $line = ${$file}[$i];
2028cdf0e10cSrcweir
2029cdf0e10cSrcweir		if ( $installer::globals::islinuxrpmbuild )
2030cdf0e10cSrcweir		{
2031cdf0e10cSrcweir			# %attr(0444,root,root) "/opt/openofficeorg20/program/about.bmp"
2032cdf0e10cSrcweir
2033cdf0e10cSrcweir			if ( $line =~ /^\s*\%attr\(.*\)\s*\"(.*?)\"\s*$/ )
2034cdf0e10cSrcweir			{
2035cdf0e10cSrcweir				my $filename = $1 . "\n";
2036cdf0e10cSrcweir				$filename =~ s/^\s*\Q$prefix\E//;
2037cdf0e10cSrcweir				push(@installer::globals::patchfilecollector, $filename);
2038cdf0e10cSrcweir			}
2039cdf0e10cSrcweir		}
2040cdf0e10cSrcweir
2041cdf0e10cSrcweir		if ( $installer::globals::issolarispkgbuild )
2042cdf0e10cSrcweir		{
2043cdf0e10cSrcweir			# f none program/msomrl.rdb=/ab/SRC680/unxsols4.pro/bin/msomrl.rdb 0444 root bin
2044cdf0e10cSrcweir
2045cdf0e10cSrcweir			if ( $line =~ /^\s*f\s+\w+\s+(.*?)\=/ )
2046cdf0e10cSrcweir			{
2047cdf0e10cSrcweir				my $filename = $1 . "\n";
2048cdf0e10cSrcweir				push(@installer::globals::patchfilecollector, $filename);
2049cdf0e10cSrcweir			}
2050cdf0e10cSrcweir		}
2051cdf0e10cSrcweir	}
2052cdf0e10cSrcweir
2053cdf0e10cSrcweir	push(@installer::globals::patchfilecollector, "\n");
2054cdf0e10cSrcweir
2055cdf0e10cSrcweir}
2056cdf0e10cSrcweir
2057cdf0e10cSrcweir############################################################
2058cdf0e10cSrcweir# Including package names into the depend files.
2059cdf0e10cSrcweir# The package names have to be included into
2060cdf0e10cSrcweir# packagelist. They are already saved in
2061cdf0e10cSrcweir# %installer::globals::dependfilenames.
2062cdf0e10cSrcweir############################################################
2063cdf0e10cSrcweir
2064cdf0e10cSrcweirsub put_packagenames_into_dependfile
2065cdf0e10cSrcweir{
2066cdf0e10cSrcweir	my ( $file ) = @_;
2067cdf0e10cSrcweir
2068cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$file}; $i++ )
2069cdf0e10cSrcweir	{
2070cdf0e10cSrcweir		my $line = ${$file}[$i];
2071cdf0e10cSrcweir		if ( $line =~ /^\s*\w\s+(.*?)\s*$/ )
2072cdf0e10cSrcweir		{
2073cdf0e10cSrcweir			my $abbreviation = $1;
2074cdf0e10cSrcweir
2075cdf0e10cSrcweir            if ( $abbreviation =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package abbreviation \"$abbreviation\"!", "read_packagemap"); }
2076cdf0e10cSrcweir
2077cdf0e10cSrcweir			if ( exists($installer::globals::dependfilenames{$abbreviation}) )
2078cdf0e10cSrcweir			{
2079cdf0e10cSrcweir                my $packagename = $installer::globals::dependfilenames{$abbreviation};
2080cdf0e10cSrcweir                if ( $packagename =~ /\%/ ) { installer::exiter::exit_program("ERROR: Could not resolve all properties in Solaris package name \"$packagename\"!", "read_packagemap"); }
2081cdf0e10cSrcweir
2082cdf0e10cSrcweir				$line =~ s/\s*$//;
2083cdf0e10cSrcweir				${$file}[$i] = $line . "\t" . $packagename . "\n";
2084cdf0e10cSrcweir			}
2085cdf0e10cSrcweir			else
2086cdf0e10cSrcweir			{
2087cdf0e10cSrcweir				installer::exiter::exit_program("ERROR: Missing packagename for Solaris package \"$abbreviation\"!", "put_packagenames_into_dependfile");
2088cdf0e10cSrcweir			}
2089cdf0e10cSrcweir		}
2090cdf0e10cSrcweir	}
2091cdf0e10cSrcweir}
2092cdf0e10cSrcweir
2093cdf0e10cSrcweir############################################################
2094cdf0e10cSrcweir# Including the relocatable directory into
2095cdf0e10cSrcweir# spec file and pkginfo file
2096cdf0e10cSrcweir# Linux: set topdir in specfile
2097cdf0e10cSrcweir# Solaris: remove $relocatablepath (/opt/)
2098cdf0e10cSrcweir# for all objects in prototype file
2099cdf0e10cSrcweir# and changing "topdir" for Linux
2100cdf0e10cSrcweir############################################################
2101cdf0e10cSrcweir
2102cdf0e10cSrcweirsub prepare_packages
2103cdf0e10cSrcweir{
2104cdf0e10cSrcweir	my ($loggingdir, $packagename, $staticpath, $relocatablepath, $onepackage, $variableshashref, $filesref, $languagestringref) = @_;
2105cdf0e10cSrcweir
2106cdf0e10cSrcweir	my $filename = "";
2107cdf0e10cSrcweir	my $newline = "";
2108cdf0e10cSrcweir	my $newepmdir = $installer::globals::epmoutpath . $installer::globals::separator;
2109cdf0e10cSrcweir
2110cdf0e10cSrcweir	my $localrelocatablepath = $relocatablepath;
2111cdf0e10cSrcweir	if ( $localrelocatablepath ne "/" ) { $localrelocatablepath =~ s/\/\s*$//; }
2112cdf0e10cSrcweir
2113cdf0e10cSrcweir	if ( $installer::globals::issolarispkgbuild )
2114cdf0e10cSrcweir	{
2115cdf0e10cSrcweir		$filename = $packagename . ".pkginfo";
2116cdf0e10cSrcweir		$newline = "BASEDIR\=" . $localrelocatablepath . "\n";
2117cdf0e10cSrcweir	}
2118cdf0e10cSrcweir
2119cdf0e10cSrcweir	if ( $installer::globals::islinuxrpmbuild )
2120cdf0e10cSrcweir	{
2121cdf0e10cSrcweir		# if ( $localrelocatablepath =~ /^\s*$/ ) { $localrelocatablepath = "/"; }; # at least the "/"
2122cdf0e10cSrcweir		$filename =  $packagename . ".spec";
2123cdf0e10cSrcweir		$newline = "Prefix\:\ " . $localrelocatablepath . "\n";
2124cdf0e10cSrcweir	}
2125cdf0e10cSrcweir
2126cdf0e10cSrcweir	my $completefilename = $newepmdir . $filename;
2127cdf0e10cSrcweir
2128cdf0e10cSrcweir	if ( ! -f $completefilename) { installer::exiter::exit_program("ERROR: Did not find file: $completefilename", "prepare_packages"); }
2129cdf0e10cSrcweir	my $changefile = installer::files::read_file($completefilename);
2130cdf0e10cSrcweir	if ( $newline ne "" )
2131cdf0e10cSrcweir	{
2132cdf0e10cSrcweir		add_one_line_into_file($changefile, $newline, $filename);
2133cdf0e10cSrcweir		installer::files::save_file($completefilename, $changefile);
2134cdf0e10cSrcweir	}
2135cdf0e10cSrcweir
2136cdf0e10cSrcweir	# my $newepmdir = $completefilename;
2137cdf0e10cSrcweir	# installer::pathanalyzer::get_path_from_fullqualifiedname(\$newepmdir);
2138cdf0e10cSrcweir
2139cdf0e10cSrcweir	# adding new "topdir" and removing old "topdir" in specfile
2140cdf0e10cSrcweir
2141cdf0e10cSrcweir	if ( $installer::globals::islinuxrpmbuild )
2142cdf0e10cSrcweir	{
2143cdf0e10cSrcweir		set_topdir_in_specfile($changefile, $filename, $newepmdir);
2144cdf0e10cSrcweir		set_autoprovreq_in_specfile($changefile, $onepackage->{'findrequires'}, "$installer::globals::unpackpath" . "/bin");
2145cdf0e10cSrcweir		set_packager_in_specfile($changefile);
2146cdf0e10cSrcweir		if ( is_extension_package($changefile) ) { set_prereq_in_specfile($changefile); }
2147cdf0e10cSrcweir		set_license_in_specfile($changefile, $variableshashref);
2148cdf0e10cSrcweir		set_tab_into_datafile($changefile, $filesref);
2149cdf0e10cSrcweir		# check_requirements_in_specfile($changefile);
2150cdf0e10cSrcweir		installer::files::save_file($completefilename, $changefile);
2151cdf0e10cSrcweir		if ( $installer::globals::patch ) { collect_patch_files($changefile, $packagename, $localrelocatablepath); }
2152cdf0e10cSrcweir	}
2153cdf0e10cSrcweir
2154cdf0e10cSrcweir	# removing the relocatable path in prototype file
2155cdf0e10cSrcweir
2156cdf0e10cSrcweir	if ( $installer::globals::issolarispkgbuild )
2157cdf0e10cSrcweir	{
2158cdf0e10cSrcweir		set_revision_in_pkginfo($changefile, $filename, $variableshashref, $packagename);
2159cdf0e10cSrcweir		set_maxinst_in_pkginfo($changefile, $filename);
2160cdf0e10cSrcweir		set_solaris_parameter_in_pkginfo($changefile, $filename, $variableshashref);
2161cdf0e10cSrcweir		if ( $installer::globals::issolarisx86build ) { fix_architecture_setting($changefile); }
2162cdf0e10cSrcweir		if ( ! $installer::globals::patch ) { set_patchlist_in_pkginfo_for_respin($changefile, $filename, $variableshashref, $packagename); }
2163cdf0e10cSrcweir		if ( $installer::globals::patch ) { include_patchinfos_into_pkginfo($changefile, $filename, $variableshashref); }
2164cdf0e10cSrcweir		if (( $onepackage->{'language'} ) && ( $onepackage->{'language'} ne "" ) && ( $onepackage->{'language'} ne "en-US" )) { include_languageinfos_into_pkginfo($changefile, $filename, $languagestringref, $onepackage, $variableshashref); }
2165cdf0e10cSrcweir		installer::files::save_file($completefilename, $changefile);
2166cdf0e10cSrcweir
2167cdf0e10cSrcweir		my $prototypefilename = $packagename . ".prototype";
2168cdf0e10cSrcweir		$prototypefilename = $newepmdir . $prototypefilename;
2169cdf0e10cSrcweir		if (! -f $prototypefilename) { installer::exiter::exit_program("ERROR: Did not find prototype file: $prototypefilename", "prepare_packages"); }
2170cdf0e10cSrcweir
2171cdf0e10cSrcweir		my $prototypefile = installer::files::read_file($prototypefilename);
2172cdf0e10cSrcweir		make_prototypefile_relocatable($prototypefile, $relocatablepath);
2173cdf0e10cSrcweir		set_volatilefile_into_prototypefile($prototypefile, $filesref);
2174cdf0e10cSrcweir		my $classesstring = set_tab_into_datafile($prototypefile, $filesref);
2175cdf0e10cSrcweir		if ($classesstring)
2176cdf0e10cSrcweir		{
2177cdf0e10cSrcweir			include_classes_into_pkginfo($changefile, $classesstring);
2178cdf0e10cSrcweir			installer::files::save_file($completefilename, $changefile);
2179cdf0e10cSrcweir		}
2180cdf0e10cSrcweir
2181cdf0e10cSrcweir		if ( $installer::globals::patch ) { add_scripts_into_prototypefile($prototypefile, $prototypefilename, $languagestringref, $staticpath); }
2182cdf0e10cSrcweir
2183cdf0e10cSrcweir		installer::files::save_file($prototypefilename, $prototypefile);
2184cdf0e10cSrcweir		if ( $installer::globals::patch ) { collect_patch_files($prototypefile, $packagename, ""); }
2185cdf0e10cSrcweir
2186cdf0e10cSrcweir		# Adding package names into depend files for Solaris (not supported by epm)
2187cdf0e10cSrcweir		my $dependfilename = $packagename . ".depend";
2188cdf0e10cSrcweir		$dependfilename = $newepmdir . $dependfilename;
2189cdf0e10cSrcweir		if ( -f $dependfilename)
2190cdf0e10cSrcweir		{
2191cdf0e10cSrcweir			my $dependfile = installer::files::read_file($dependfilename);
2192cdf0e10cSrcweir			put_packagenames_into_dependfile($dependfile);
2193cdf0e10cSrcweir			installer::files::save_file($dependfilename, $dependfile);
2194cdf0e10cSrcweir		}
2195cdf0e10cSrcweir	}
2196cdf0e10cSrcweir
2197cdf0e10cSrcweir	return $newepmdir;
2198cdf0e10cSrcweir}
2199cdf0e10cSrcweir
2200cdf0e10cSrcweir############################################################
2201cdf0e10cSrcweir# Linux requirement for perl is changed by epm from
2202cdf0e10cSrcweir# /usr/bin/perl to perl .
2203cdf0e10cSrcweir# Requires: perl
2204cdf0e10cSrcweir############################################################
2205cdf0e10cSrcweir
2206cdf0e10cSrcweirsub check_requirements_in_specfile
2207cdf0e10cSrcweir{
2208cdf0e10cSrcweir	my ( $specfile ) = @_;
2209cdf0e10cSrcweir
2210cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$specfile}; $i++ )
2211cdf0e10cSrcweir	{
2212cdf0e10cSrcweir		if (( ${$specfile}[$i] =~ /^\s*Requires/ ) && ( ${$specfile}[$i] =~ /\bperl\b/ ) && ( ! (  ${$specfile}[$i] =~ /\/usr\/bin\/perl\b/ )))
2213cdf0e10cSrcweir		{
2214cdf0e10cSrcweir			my $oldline = ${$specfile}[$i];
2215cdf0e10cSrcweir			${$specfile}[$i] =~ s/perl/\/usr\/bin\/perl/;
2216cdf0e10cSrcweir			my $newline = ${$specfile}[$i];
2217cdf0e10cSrcweir
2218cdf0e10cSrcweir			$oldline =~ s/\s*$//;
2219cdf0e10cSrcweir			$newline =~ s/\s*$//;
2220cdf0e10cSrcweir			my $infoline = "Spec File: Changing content from \"$oldline\" to \"$newline\".\n";
2221cdf0e10cSrcweir			push(@installer::globals::logfileinfo, $infoline);
2222cdf0e10cSrcweir		}
2223cdf0e10cSrcweir	}
2224cdf0e10cSrcweir}
2225cdf0e10cSrcweir
2226cdf0e10cSrcweir###############################################################################
2227cdf0e10cSrcweir# Replacement of PRODUCTINSTALLLOCATION and PRODUCTDIRECTORYNAME in the
2228cdf0e10cSrcweir# epm list file.
2229cdf0e10cSrcweir# The complete rootpath is stored in $installer::globals::rootpath
2230cdf0e10cSrcweir# or for each package in $onepackage->{'destpath'}
2231cdf0e10cSrcweir# The static rootpath is stored in $staticpath
2232cdf0e10cSrcweir# The relocatable path is stored in $relocatablepath
2233cdf0e10cSrcweir# PRODUCTINSTALLLOCATION is the relocatable part ("/opt") and
2234cdf0e10cSrcweir# PRODUCTDIRECTORYNAME the static path ("openofficeorg20").
2235cdf0e10cSrcweir# In standard epm process:
2236cdf0e10cSrcweir# No usage of package specific variables like $BASEDIR, because
2237cdf0e10cSrcweir# 1. These variables would be replaced in epm process
2238cdf0e10cSrcweir# 2. epm version 3.7 does not support relocatable packages
2239cdf0e10cSrcweir###############################################################################
2240cdf0e10cSrcweir
2241cdf0e10cSrcweirsub resolve_path_in_epm_list_before_packaging
2242cdf0e10cSrcweir{
2243cdf0e10cSrcweir	my ($listfile, $listfilename, $variable, $path) = @_;
2244cdf0e10cSrcweir
2245cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Replacing variables in epm list file:");
2246cdf0e10cSrcweir
2247cdf0e10cSrcweir	$path =~ s/\/\s*$//;
2248cdf0e10cSrcweir	replace_variables_in_shellscripts($listfile, $listfilename, $variable, $path);
2249cdf0e10cSrcweir
2250cdf0e10cSrcweir}
2251cdf0e10cSrcweir
2252cdf0e10cSrcweir#################################################################
2253cdf0e10cSrcweir# Determining the rpm version. Beginning with rpm version 4.0
2254cdf0e10cSrcweir# the tool to create RPMs is "rpmbuild" and no longer "rpm"
2255cdf0e10cSrcweir#################################################################
2256cdf0e10cSrcweir
2257cdf0e10cSrcweirsub determine_rpm_version
2258cdf0e10cSrcweir{
2259cdf0e10cSrcweir	my $rpmversion = 0;
2260cdf0e10cSrcweir	my $rpmout = "";
2261cdf0e10cSrcweir	my $systemcall = "";
2262cdf0e10cSrcweir
2263cdf0e10cSrcweir	# my $systemcall = "rpm --version |";
2264cdf0e10cSrcweir	# "rpm --version" has problems since LD_LIBRARY_PATH was removed. Therefore the content of $RPM has to be called.
2265cdf0e10cSrcweir	# "rpm --version" and "rpmbuild --version" have the same output. Therefore $RPM can be used. Its value
2266cdf0e10cSrcweir	# is saved in $installer::globals::rpm
2267cdf0e10cSrcweir
2268cdf0e10cSrcweir	if ( $installer::globals::rpm ne "" )
2269cdf0e10cSrcweir	{
2270cdf0e10cSrcweir		$systemcall = "$installer::globals::rpm --version |";
2271cdf0e10cSrcweir	}
2272cdf0e10cSrcweir	else
2273cdf0e10cSrcweir	{
2274cdf0e10cSrcweir		$systemcall = "rpm --version |";
2275cdf0e10cSrcweir	}
2276cdf0e10cSrcweir
2277cdf0e10cSrcweir	open (RPM, "$systemcall");
2278cdf0e10cSrcweir	$rpmout = <RPM>;
2279cdf0e10cSrcweir	close (RPM);
2280cdf0e10cSrcweir
2281cdf0e10cSrcweir	if ( $rpmout ne "" )
2282cdf0e10cSrcweir	{
2283cdf0e10cSrcweir		$rpmout =~ s/\s*$//g;
2284cdf0e10cSrcweir
2285cdf0e10cSrcweir		my $infoline = "Systemcall: $systemcall\n";
2286cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
2287cdf0e10cSrcweir
2288cdf0e10cSrcweir		if ( $rpmout eq "" ) { $infoline = "ERROR: Could not find file \"rpm\" !\n"; }
2289cdf0e10cSrcweir		else { $infoline = "Success: rpm version: $rpmout\n"; }
2290cdf0e10cSrcweir
2291cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
2292cdf0e10cSrcweir
2293cdf0e10cSrcweir		if ( $rpmout =~ /(\d+)\.(\d+)\.(\d+)/ ) { $rpmversion = $1; }
2294cdf0e10cSrcweir		elsif ( $rpmout =~ /(\d+)\.(\d+)/ ) { $rpmversion = $1; }
2295cdf0e10cSrcweir		elsif ( $rpmout =~ /(\d+)/ ) { $rpmversion = $1; }
2296cdf0e10cSrcweir		else { installer::exiter::exit_program("ERROR: Unknown format: $rpmout ! Expected: \"a.b.c\", or \"a.b\", or \"a\"", "determine_rpm_version"); }
2297cdf0e10cSrcweir	}
2298cdf0e10cSrcweir
2299cdf0e10cSrcweir	return $rpmversion;
2300cdf0e10cSrcweir}
2301cdf0e10cSrcweir
2302cdf0e10cSrcweir####################################################
2303cdf0e10cSrcweir# Writing some info about rpm into the log file
2304cdf0e10cSrcweir####################################################
2305cdf0e10cSrcweir
2306cdf0e10cSrcweirsub log_rpm_info
2307cdf0e10cSrcweir{
2308cdf0e10cSrcweir	my $systemcall = "";
2309cdf0e10cSrcweir	my $infoline = "";
2310cdf0e10cSrcweir
2311cdf0e10cSrcweir	$infoline = "\nLogging rpmrc content using --showrc\n\n";
2312cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
2313cdf0e10cSrcweir
2314cdf0e10cSrcweir	if ( $installer::globals::rpm ne "" )
2315cdf0e10cSrcweir	{
2316cdf0e10cSrcweir		$systemcall = "$installer::globals::rpm --showrc |";
2317cdf0e10cSrcweir	}
2318cdf0e10cSrcweir	else
2319cdf0e10cSrcweir	{
2320cdf0e10cSrcweir		$systemcall = "rpm --showrc |";
2321cdf0e10cSrcweir	}
2322cdf0e10cSrcweir
2323cdf0e10cSrcweir	my @fullrpmout = ();
2324cdf0e10cSrcweir
2325cdf0e10cSrcweir	open (RPM, "$systemcall");
2326cdf0e10cSrcweir	while (<RPM>) {push(@fullrpmout, $_); }
2327cdf0e10cSrcweir	close (RPM);
2328cdf0e10cSrcweir
2329cdf0e10cSrcweir	if ( $#fullrpmout > -1 )
2330cdf0e10cSrcweir	{
2331cdf0e10cSrcweir		for ( my $i = 0; $i <= $#fullrpmout; $i++ )
2332cdf0e10cSrcweir		{
2333cdf0e10cSrcweir			my $rpmout = $fullrpmout[$i];
2334cdf0e10cSrcweir			$rpmout =~ s/\s*$//g;
2335cdf0e10cSrcweir
2336cdf0e10cSrcweir			$infoline = "$rpmout\n";
2337cdf0e10cSrcweir			$infoline =~ s/error/e_r_r_o_r/gi;  # avoiding log problems
2338cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
2339cdf0e10cSrcweir		}
2340cdf0e10cSrcweir	}
2341cdf0e10cSrcweir	else
2342cdf0e10cSrcweir	{
2343cdf0e10cSrcweir		$infoline = "Problem in systemcall: $systemcall : No return value\n";
2344cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
2345cdf0e10cSrcweir	}
2346cdf0e10cSrcweir
2347cdf0e10cSrcweir	$infoline = "End of logging rpmrc\n\n";
2348cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
2349cdf0e10cSrcweir}
2350cdf0e10cSrcweir
2351cdf0e10cSrcweir#################################################
2352cdf0e10cSrcweir# Systemcall to start the packaging process
2353cdf0e10cSrcweir#################################################
2354cdf0e10cSrcweir
2355cdf0e10cSrcweirsub create_packages_without_epm
2356cdf0e10cSrcweir{
2357cdf0e10cSrcweir	my ($epmdir, $packagename, $includepatharrayref, $allvariables, $languagestringref) = @_;
2358cdf0e10cSrcweir
2359cdf0e10cSrcweir	# Solaris: pkgmk -o -f solaris-2.8-sparc/SUNWso8m34.prototype -d solaris-2.8-sparc
2360cdf0e10cSrcweir	# Solaris: pkgtrans solaris-2.8-sparc SUNWso8m34.pkg SUNWso8m34
2361cdf0e10cSrcweir	# Solaris: tar -cf - SUNWso8m34 | gzip > SUNWso8m34.tar.gz
2362cdf0e10cSrcweir
2363cdf0e10cSrcweir	if ( $installer::globals::issolarispkgbuild )
2364cdf0e10cSrcweir	{
2365cdf0e10cSrcweir		my $prototypefile = $epmdir . $packagename . ".prototype";
2366cdf0e10cSrcweir		if (! -f $prototypefile) { installer::exiter::exit_program("ERROR: Did not find file: $prototypefile", "create_packages_without_epm"); }
2367cdf0e10cSrcweir
2368cdf0e10cSrcweir		my $destinationdir = $prototypefile;
2369cdf0e10cSrcweir		installer::pathanalyzer::get_path_from_fullqualifiedname(\$destinationdir);
2370cdf0e10cSrcweir		$destinationdir =~ s/\/\s*$//;	# removing ending slashes
2371cdf0e10cSrcweir
2372cdf0e10cSrcweir		# my $systemcall = "pkgmk -o -f $prototypefile -d $destinationdir \> /dev/null 2\>\&1";
2373cdf0e10cSrcweir		my $systemcall = "pkgmk -l 1073741824 -o -f $prototypefile -d $destinationdir 2\>\&1 |";
2374cdf0e10cSrcweir		installer::logger::print_message( "... $systemcall ...\n" );
2375cdf0e10cSrcweir
2376cdf0e10cSrcweir		my $maxpkgmkcalls = 3;
2377cdf0e10cSrcweir
2378cdf0e10cSrcweir		for ( my $i = 1; $i <= $maxpkgmkcalls; $i++ )
2379cdf0e10cSrcweir		{
2380cdf0e10cSrcweir			my @pkgmkoutput = ();
2381cdf0e10cSrcweir
2382cdf0e10cSrcweir			open (PKGMK, "$systemcall");
2383cdf0e10cSrcweir			while (<PKGMK>) {push(@pkgmkoutput, $_); }
2384cdf0e10cSrcweir			close (PKGMK);
2385cdf0e10cSrcweir
2386cdf0e10cSrcweir			my $returnvalue = $?;	# $? contains the return value of the systemcall
2387cdf0e10cSrcweir
2388cdf0e10cSrcweir			my $infoline = "Systemcall (Try $i): $systemcall\n";
2389cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
2390cdf0e10cSrcweir
2391cdf0e10cSrcweir			for ( my $j = 0; $j <= $#pkgmkoutput; $j++ )
2392cdf0e10cSrcweir			{
2393cdf0e10cSrcweir				if ( $i < $maxpkgmkcalls ) { $pkgmkoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
2394cdf0e10cSrcweir				push( @installer::globals::logfileinfo, "$pkgmkoutput[$j]");
2395cdf0e10cSrcweir			}
2396cdf0e10cSrcweir
2397cdf0e10cSrcweir			if ($returnvalue)
2398cdf0e10cSrcweir			{
2399cdf0e10cSrcweir				$infoline = "Try $i : Could not execute \"$systemcall\"!\n";
2400cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
2401cdf0e10cSrcweir				if ( $i == $maxpkgmkcalls ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
2402cdf0e10cSrcweir			}
2403cdf0e10cSrcweir			else
2404cdf0e10cSrcweir			{
2405cdf0e10cSrcweir				installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
2406cdf0e10cSrcweir				$infoline = "Success: Executed \"$systemcall\" successfully!\n";
2407cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
2408cdf0e10cSrcweir				last;
2409cdf0e10cSrcweir			}
2410cdf0e10cSrcweir		}
2411cdf0e10cSrcweir
2412cdf0e10cSrcweir		# It might be necessary to save uncompressed Solaris packages
2413cdf0e10cSrcweir
2414cdf0e10cSrcweir		if ( $allvariables->{'JDSBUILD'} )
2415cdf0e10cSrcweir		{
2416cdf0e10cSrcweir			if ( ! $installer::globals::jds_language_controlled )
2417cdf0e10cSrcweir			{
2418cdf0e10cSrcweir				my $correct_language = installer::worker::check_jds_language($allvariables, $languagestringref);
2419cdf0e10cSrcweir				$installer::globals::correct_jds_language = $correct_language;
2420cdf0e10cSrcweir				$installer::globals::jds_language_controlled = 1;
2421cdf0e10cSrcweir			}
2422cdf0e10cSrcweir
2423cdf0e10cSrcweir			if ( $installer::globals::correct_jds_language )
2424cdf0e10cSrcweir			{
2425cdf0e10cSrcweir				if ( $installer::globals::saved_packages_path eq "" )
2426cdf0e10cSrcweir				{
2427cdf0e10cSrcweir					$packagestempdir = installer::systemactions::create_directories("jds", $languagestringref);
2428cdf0e10cSrcweir					$installer::globals::saved_packages_path = $packagestempdir;
2429cdf0e10cSrcweir					push(@installer::globals::jdsremovedirs, $packagestempdir);
2430cdf0e10cSrcweir				}
2431cdf0e10cSrcweir
2432cdf0e10cSrcweir				$systemcall = "cd $destinationdir; cp -p -R $packagename $installer::globals::saved_packages_path;";
2433cdf0e10cSrcweir			 	make_systemcall($systemcall);
2434cdf0e10cSrcweir				installer::logger::print_message( "... $systemcall ...\n" );
2435cdf0e10cSrcweir
2436cdf0e10cSrcweir				# Setting unix rights to "775" for all created directories inside the package,
2437cdf0e10cSrcweir				# that is saved in temp directory
2438cdf0e10cSrcweir
2439cdf0e10cSrcweir				$systemcall = "cd $packagestempdir; find $packagename -type d -exec chmod 775 \{\} \\\;";
2440cdf0e10cSrcweir				installer::logger::print_message( "... $systemcall ...\n" );
2441cdf0e10cSrcweir
2442cdf0e10cSrcweir				$returnvalue = system($systemcall);
2443cdf0e10cSrcweir
2444cdf0e10cSrcweir				$infoline = "Systemcall: $systemcall\n";
2445cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
2446cdf0e10cSrcweir
2447cdf0e10cSrcweir				if ($returnvalue)
2448cdf0e10cSrcweir				{
2449cdf0e10cSrcweir					$infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2450cdf0e10cSrcweir					push( @installer::globals::logfileinfo, $infoline);
2451cdf0e10cSrcweir				}
2452cdf0e10cSrcweir				else
2453cdf0e10cSrcweir				{
2454cdf0e10cSrcweir					$infoline = "Success: Executed \"$systemcall\" successfully!\n";
2455cdf0e10cSrcweir					push( @installer::globals::logfileinfo, $infoline);
2456cdf0e10cSrcweir				}
2457cdf0e10cSrcweir			}
2458cdf0e10cSrcweir		}
2459cdf0e10cSrcweir
2460cdf0e10cSrcweir		# compressing packages
2461cdf0e10cSrcweir
2462cdf0e10cSrcweir		if ( ! $installer::globals::solarisdontcompress )
2463cdf0e10cSrcweir		{
2464cdf0e10cSrcweir			my $faspac = "faspac-so.sh";
2465cdf0e10cSrcweir
2466cdf0e10cSrcweir			my $compressorref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$faspac, $includepatharrayref, 0);
2467cdf0e10cSrcweir			if ($$compressorref ne "")
2468cdf0e10cSrcweir			{
2469cdf0e10cSrcweir				# Saving original pkginfo, to set time stamp later
2470cdf0e10cSrcweir				my $pkginfoorig = "$destinationdir/$packagename/pkginfo";
2471cdf0e10cSrcweir				my $pkginfotmp = "$destinationdir/$packagename" . ".pkginfo.tmp";
2472cdf0e10cSrcweir				$systemcall = "cp -p $pkginfoorig $pkginfotmp";
2473cdf0e10cSrcweir			 	make_systemcall($systemcall);
2474cdf0e10cSrcweir
2475cdf0e10cSrcweir				$faspac = $$compressorref;
2476cdf0e10cSrcweir				$infoline = "Found compressor: $faspac\n";
2477cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
2478cdf0e10cSrcweir
2479cdf0e10cSrcweir				installer::logger::print_message( "... $faspac ...\n" );
2480cdf0e10cSrcweir				installer::logger::include_timestamp_into_logfile("Starting $faspac");
2481cdf0e10cSrcweir
2482cdf0e10cSrcweir			 	$systemcall = "/bin/sh $faspac -a -q -d $destinationdir $packagename";	 # $faspac has to be the absolute path!
2483cdf0e10cSrcweir			 	make_systemcall($systemcall);
2484cdf0e10cSrcweir
2485cdf0e10cSrcweir			 	# Setting time stamp for pkginfo, because faspac-so.sh changed the pkginfo file,
2486cdf0e10cSrcweir			 	# updated the size and checksum, but not the time stamp.
2487cdf0e10cSrcweir			 	$systemcall = "touch -r $pkginfotmp $pkginfoorig";
2488cdf0e10cSrcweir			 	make_systemcall($systemcall);
2489cdf0e10cSrcweir				if ( -f $pkginfotmp ) { unlink($pkginfotmp); }
2490cdf0e10cSrcweir
2491cdf0e10cSrcweir				installer::logger::include_timestamp_into_logfile("End of $faspac");
2492cdf0e10cSrcweir			}
2493cdf0e10cSrcweir			else
2494cdf0e10cSrcweir			{
2495cdf0e10cSrcweir				$infoline = "Not found: $faspac\n";
2496cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
2497cdf0e10cSrcweir			}
2498cdf0e10cSrcweir		}
2499cdf0e10cSrcweir
2500cdf0e10cSrcweir		# Setting unix rights to "775" for all created directories inside the package
2501cdf0e10cSrcweir
2502cdf0e10cSrcweir		$systemcall = "cd $destinationdir; find $packagename -type d -exec chmod 775 \{\} \\\;";
2503cdf0e10cSrcweir		installer::logger::print_message( "... $systemcall ...\n" );
2504cdf0e10cSrcweir
2505cdf0e10cSrcweir		$returnvalue = system($systemcall);
2506cdf0e10cSrcweir
2507cdf0e10cSrcweir		$infoline = "Systemcall: $systemcall\n";
2508cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
2509cdf0e10cSrcweir
2510cdf0e10cSrcweir		if ($returnvalue)
2511cdf0e10cSrcweir		{
2512cdf0e10cSrcweir			$infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2513cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
2514cdf0e10cSrcweir		}
2515cdf0e10cSrcweir		else
2516cdf0e10cSrcweir		{
2517cdf0e10cSrcweir			$infoline = "Success: Executed \"$systemcall\" successfully!\n";
2518cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
2519cdf0e10cSrcweir		}
2520cdf0e10cSrcweir
2521cdf0e10cSrcweir		######################
2522cdf0e10cSrcweir		# making pkg files
2523cdf0e10cSrcweir		######################
2524cdf0e10cSrcweir
2525cdf0e10cSrcweir		# my $streamname = $packagename . ".pkg";
2526cdf0e10cSrcweir		# $systemcall = "pkgtrans $destinationdir $streamname $packagename";
2527cdf0e10cSrcweir		# print "... $systemcall ...\n";
2528cdf0e10cSrcweir
2529cdf0e10cSrcweir		# $returnvalue = system($systemcall);
2530cdf0e10cSrcweir
2531cdf0e10cSrcweir		# $infoline = "Systemcall: $systemcall\n";
2532cdf0e10cSrcweir		# push( @installer::globals::logfileinfo, $infoline);
2533cdf0e10cSrcweir
2534cdf0e10cSrcweir		# if ($returnvalue)
2535cdf0e10cSrcweir		# {
2536cdf0e10cSrcweir		# 	$infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2537cdf0e10cSrcweir		# 	push( @installer::globals::logfileinfo, $infoline);
2538cdf0e10cSrcweir		# }
2539cdf0e10cSrcweir		# else
2540cdf0e10cSrcweir		# {
2541cdf0e10cSrcweir		# 	$infoline = "Success: Executed \"$systemcall\" successfully!\n";
2542cdf0e10cSrcweir		# 	push( @installer::globals::logfileinfo, $infoline);
2543cdf0e10cSrcweir		# }
2544cdf0e10cSrcweir
2545cdf0e10cSrcweir		#########################
2546cdf0e10cSrcweir		# making tar.gz files
2547cdf0e10cSrcweir		#########################
2548cdf0e10cSrcweir
2549cdf0e10cSrcweir		# my $targzname = $packagename . ".tar.gz";
2550cdf0e10cSrcweir		# $systemcall = "cd $destinationdir; tar -cf - $packagename | gzip > $targzname";
2551cdf0e10cSrcweir		# print "... $systemcall ...\n";
2552cdf0e10cSrcweir
2553cdf0e10cSrcweir		# $returnvalue = system($systemcall);
2554cdf0e10cSrcweir
2555cdf0e10cSrcweir		# $infoline = "Systemcall: $systemcall\n";
2556cdf0e10cSrcweir		# push( @installer::globals::logfileinfo, $infoline);
2557cdf0e10cSrcweir
2558cdf0e10cSrcweir		# if ($returnvalue)
2559cdf0e10cSrcweir		# {
2560cdf0e10cSrcweir		#	$infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2561cdf0e10cSrcweir		#	push( @installer::globals::logfileinfo, $infoline);
2562cdf0e10cSrcweir		# }
2563cdf0e10cSrcweir		# else
2564cdf0e10cSrcweir		# {
2565cdf0e10cSrcweir		#	$infoline = "Success: Executed \"$systemcall\" successfully!\n";
2566cdf0e10cSrcweir		#	push( @installer::globals::logfileinfo, $infoline);
2567cdf0e10cSrcweir		# }
2568cdf0e10cSrcweir	}
2569cdf0e10cSrcweir
2570cdf0e10cSrcweir	# Linux: rpm -bb so8m35.spec	( -> dependency check abklemmen? )
2571cdf0e10cSrcweir
2572cdf0e10cSrcweir	if ( $installer::globals::islinuxrpmbuild )
2573cdf0e10cSrcweir	{
2574cdf0e10cSrcweir		my $specfilename = $epmdir . $packagename . ".spec";
2575cdf0e10cSrcweir		if (! -f $specfilename) { installer::exiter::exit_program("ERROR: Did not find file: $specfilename", "create_packages_without_epm"); }
2576cdf0e10cSrcweir
2577cdf0e10cSrcweir		# my $rpmcommand = "rpm";
2578cdf0e10cSrcweir		my $rpmcommand = $installer::globals::rpm;
2579cdf0e10cSrcweir		my $rpmversion = determine_rpm_version();
2580cdf0e10cSrcweir
2581cdf0e10cSrcweir		# if ( $rpmversion >= 4 ) { $rpmcommand = "rpmbuild"; }
2582cdf0e10cSrcweir
2583cdf0e10cSrcweir		# saving globally for later usage
2584cdf0e10cSrcweir		$installer::globals::rpmcommand = $rpmcommand;
2585cdf0e10cSrcweir		$installer::globals::rpmquerycommand = "rpm";
2586cdf0e10cSrcweir
2587cdf0e10cSrcweir		my $target = "";
2588cdf0e10cSrcweir		if ( $installer::globals::compiler =~ /unxlngi/) { $target = "i586"; }
2589cdf0e10cSrcweir		elsif ( $installer::globals::compiler =~ /unxlng/) {$target = (POSIX::uname())[4]; }
2590cdf0e10cSrcweir
2591cdf0e10cSrcweir		# rpm 4.6 ignores buildroot tag in spec file
2592cdf0e10cSrcweir
2593cdf0e10cSrcweir		my $buildrootstring = "";
2594cdf0e10cSrcweir
2595cdf0e10cSrcweir		if ( $rpmversion >= 4 )
2596cdf0e10cSrcweir		{
2597cdf0e10cSrcweir			my $dir = getcwd;
2598cdf0e10cSrcweir			my $buildroot = $dir . "/" . $epmdir . "buildroot/";
2599cdf0e10cSrcweir			$buildrootstring = "--buildroot=$buildroot";
2600cdf0e10cSrcweir			mkdir($buildroot = $dir . "/" . $epmdir . "BUILD/");
2601cdf0e10cSrcweir		}
2602cdf0e10cSrcweir
2603cdf0e10cSrcweir		if ( ! $installer::globals::rpminfologged )
2604cdf0e10cSrcweir		{
2605cdf0e10cSrcweir			log_rpm_info();
2606cdf0e10cSrcweir			$installer::globals::rpminfologged = 1;
2607cdf0e10cSrcweir		}
2608cdf0e10cSrcweir
2609cdf0e10cSrcweir		my $systemcall = "$rpmcommand -bb --define \"_unpackaged_files_terminate_build  0\" $specfilename --target $target $buildrootstring 2\>\&1 |";
2610cdf0e10cSrcweir
2611cdf0e10cSrcweir		installer::logger::print_message( "... $systemcall ...\n" );
2612cdf0e10cSrcweir
2613cdf0e10cSrcweir		my $maxrpmcalls = 3;
2614cdf0e10cSrcweir		my $rpm_failed = 0;
2615cdf0e10cSrcweir
2616cdf0e10cSrcweir		for ( my $i = 1; $i <= $maxrpmcalls; $i++ )
2617cdf0e10cSrcweir		{
2618cdf0e10cSrcweir			my @rpmoutput = ();
2619cdf0e10cSrcweir
2620cdf0e10cSrcweir			open (RPM, "$systemcall");
2621cdf0e10cSrcweir			while (<RPM>) {push(@rpmoutput, $_); }
2622cdf0e10cSrcweir			close (RPM);
2623cdf0e10cSrcweir
2624cdf0e10cSrcweir			my $returnvalue = $?;	# $? contains the return value of the systemcall
2625cdf0e10cSrcweir
2626cdf0e10cSrcweir			my $infoline = "Systemcall (Try $i): $systemcall\n";
2627cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
2628cdf0e10cSrcweir
2629cdf0e10cSrcweir			for ( my $j = 0; $j <= $#rpmoutput; $j++ )
2630cdf0e10cSrcweir			{
2631cdf0e10cSrcweir				# if ( $i < $maxrpmcalls ) { $rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig; }
2632cdf0e10cSrcweir				$rpmoutput[$j] =~ s/\bERROR\b/PROBLEM/ig;
2633cdf0e10cSrcweir				push( @installer::globals::logfileinfo, "$rpmoutput[$j]");
2634cdf0e10cSrcweir			}
2635cdf0e10cSrcweir
2636cdf0e10cSrcweir			if ($returnvalue)
2637cdf0e10cSrcweir			{
2638cdf0e10cSrcweir				$infoline = "Try $i : Could not execute \"$systemcall\"!\n";
2639cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
2640cdf0e10cSrcweir				$rpm_failed = 1;
2641cdf0e10cSrcweir			}
2642cdf0e10cSrcweir			else
2643cdf0e10cSrcweir			{
2644cdf0e10cSrcweir				installer::logger::print_message( "Success (Try $i): \"$systemcall\"\n" );
2645cdf0e10cSrcweir				$infoline = "Success: Executed \"$systemcall\" successfully!\n";
2646cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
2647cdf0e10cSrcweir				$rpm_failed = 0;
2648cdf0e10cSrcweir				last;
2649cdf0e10cSrcweir			}
2650cdf0e10cSrcweir		}
2651cdf0e10cSrcweir
2652cdf0e10cSrcweir		if ( $rpm_failed )
2653cdf0e10cSrcweir		{
2654cdf0e10cSrcweir			# Because of the problems with LD_LIBARY_PATH, a direct call of local "rpm" or "rpmbuild" might be successful
2655cdf0e10cSrcweir			my $rpmprog = "";
2656cdf0e10cSrcweir			if ( -f "/usr/bin/rpmbuild" ) { $rpmprog = "/usr/bin/rpmbuild"; }
2657cdf0e10cSrcweir			elsif ( -f "/usr/bin/rpm" ) { $rpmprog = "/usr/bin/rpm"; }
2658cdf0e10cSrcweir
2659cdf0e10cSrcweir			if ( $rpmprog ne "" )
2660cdf0e10cSrcweir			{
2661cdf0e10cSrcweir				installer::logger::print_message( "... $rpmprog ...\n" );
2662cdf0e10cSrcweir
2663cdf0e10cSrcweir				my $helpersystemcall = "$rpmprog -bb $specfilename --target $target $buildrootstring 2\>\&1 |";
2664cdf0e10cSrcweir
2665cdf0e10cSrcweir				my @helperrpmoutput = ();
2666cdf0e10cSrcweir
2667cdf0e10cSrcweir				open (RPM, "$helpersystemcall");
2668cdf0e10cSrcweir				while (<RPM>) {push(@helperrpmoutput, $_); }
2669cdf0e10cSrcweir				close (RPM);
2670cdf0e10cSrcweir
2671cdf0e10cSrcweir				my $helperreturnvalue = $?;	# $? contains the return value of the systemcall
2672cdf0e10cSrcweir
2673cdf0e10cSrcweir				$infoline = "\nLast try: Using $rpmprog directly (problem with LD_LIBARY_PATH)\n";
2674cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
2675cdf0e10cSrcweir
2676cdf0e10cSrcweir				$infoline = "\nSystemcall: $helpersystemcall\n";
2677cdf0e10cSrcweir				push( @installer::globals::logfileinfo, $infoline);
2678cdf0e10cSrcweir
2679cdf0e10cSrcweir				for ( my $j = 0; $j <= $#helperrpmoutput; $j++ ) { push( @installer::globals::logfileinfo, "$helperrpmoutput[$j]"); }
2680cdf0e10cSrcweir
2681cdf0e10cSrcweir				if ($helperreturnvalue)
2682cdf0e10cSrcweir				{
2683cdf0e10cSrcweir					$infoline = "Could not execute \"$helpersystemcall\"!\n";
2684cdf0e10cSrcweir					push( @installer::globals::logfileinfo, $infoline);
2685cdf0e10cSrcweir				}
2686cdf0e10cSrcweir				else
2687cdf0e10cSrcweir				{
2688cdf0e10cSrcweir					installer::logger::print_message( "Success: \"$helpersystemcall\"\n" );
2689cdf0e10cSrcweir					$infoline = "Success: Executed \"$helpersystemcall\" successfully!\n";
2690cdf0e10cSrcweir					push( @installer::globals::logfileinfo, $infoline);
2691cdf0e10cSrcweir					$rpm_failed = 0;
2692cdf0e10cSrcweir				}
2693cdf0e10cSrcweir			}
2694cdf0e10cSrcweir
2695cdf0e10cSrcweir			# Now it is really time to exit this packaging process, if the error still occurs
2696cdf0e10cSrcweir			if ( $rpm_failed ) { installer::exiter::exit_program("ERROR: \"$systemcall\"!", "create_packages_without_epm"); }
2697cdf0e10cSrcweir		}
2698cdf0e10cSrcweir	}
2699cdf0e10cSrcweir}
2700cdf0e10cSrcweir
2701cdf0e10cSrcweir#################################################
2702cdf0e10cSrcweir# Removing all temporary files created by epm
2703cdf0e10cSrcweir#################################################
2704cdf0e10cSrcweir
2705cdf0e10cSrcweirsub remove_temporary_epm_files
2706cdf0e10cSrcweir{
2707cdf0e10cSrcweir	my ($epmdir, $loggingdir, $packagename) = @_;
2708cdf0e10cSrcweir
2709cdf0e10cSrcweir	# saving the files into the loggingdir
2710cdf0e10cSrcweir
2711cdf0e10cSrcweir	if ( $installer::globals::issolarispkgbuild )
2712cdf0e10cSrcweir	{
2713cdf0e10cSrcweir		my @extensions = ();
2714cdf0e10cSrcweir		push(@extensions, ".pkginfo");
2715cdf0e10cSrcweir		push(@extensions, ".prototype");
2716cdf0e10cSrcweir		push(@extensions, ".postinstall");
2717cdf0e10cSrcweir		push(@extensions, ".postremove");
2718cdf0e10cSrcweir		push(@extensions, ".preinstall");
2719cdf0e10cSrcweir		push(@extensions, ".preremove");
2720cdf0e10cSrcweir		push(@extensions, ".depend");
2721cdf0e10cSrcweir
2722cdf0e10cSrcweir		for ( my $i = 0; $i <= $#extensions; $i++ )
2723cdf0e10cSrcweir		{
2724cdf0e10cSrcweir			my $removefile = $epmdir . $packagename . $extensions[$i];
2725cdf0e10cSrcweir			my $destfile = $loggingdir . $packagename . $extensions[$i] . ".log";
2726cdf0e10cSrcweir
2727cdf0e10cSrcweir			if (! -f $removefile) { next; }
2728cdf0e10cSrcweir
2729cdf0e10cSrcweir			my $systemcall = "mv -f $removefile $destfile";
2730cdf0e10cSrcweir			system($systemcall);	 # ignoring the return value
2731cdf0e10cSrcweir			$infoline = "Systemcall: $systemcall\n";
2732cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
2733cdf0e10cSrcweir		}
2734cdf0e10cSrcweir
2735cdf0e10cSrcweir		# removing the package
2736cdf0e10cSrcweir
2737cdf0e10cSrcweir#		my $removedir = $epmdir . $packagename;
2738cdf0e10cSrcweir#
2739cdf0e10cSrcweir#		my $systemcall = "rm -rf $removedir";
2740cdf0e10cSrcweir#
2741cdf0e10cSrcweir#		print "... $systemcall ...\n";
2742cdf0e10cSrcweir#
2743cdf0e10cSrcweir#		my $returnvalue = system($systemcall);
2744cdf0e10cSrcweir#
2745cdf0e10cSrcweir#		my $infoline = "Systemcall: $systemcall\n";
2746cdf0e10cSrcweir#		push( @installer::globals::logfileinfo, $infoline);
2747cdf0e10cSrcweir#
2748cdf0e10cSrcweir#		if ($returnvalue)
2749cdf0e10cSrcweir#		{
2750cdf0e10cSrcweir#			$infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2751cdf0e10cSrcweir#			push( @installer::globals::logfileinfo, $infoline);
2752cdf0e10cSrcweir#		}
2753cdf0e10cSrcweir#		else
2754cdf0e10cSrcweir#		{
2755cdf0e10cSrcweir#			$infoline = "Success: Executed \"$systemcall\" successfully!\n";
2756cdf0e10cSrcweir#			push( @installer::globals::logfileinfo, $infoline);
2757cdf0e10cSrcweir#		}
2758cdf0e10cSrcweir	}
2759cdf0e10cSrcweir
2760cdf0e10cSrcweir	if ( $installer::globals::islinuxrpmbuild )
2761cdf0e10cSrcweir	{
2762cdf0e10cSrcweir		my $removefile = $epmdir . $packagename . ".spec";
2763cdf0e10cSrcweir		my $destfile = $loggingdir . $packagename . ".spec.log";
2764cdf0e10cSrcweir
2765cdf0e10cSrcweir		 # if (! -f $removefile) { next; }
2766cdf0e10cSrcweir
2767cdf0e10cSrcweir		my $systemcall = "mv -f $removefile $destfile";
2768cdf0e10cSrcweir		system($systemcall);	 # ignoring the return value
2769cdf0e10cSrcweir		$infoline = "Systemcall: $systemcall\n";
2770cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
2771cdf0e10cSrcweir
2772cdf0e10cSrcweir		# removing the directory "buildroot"
2773cdf0e10cSrcweir
2774cdf0e10cSrcweir		my $removedir = $epmdir . "buildroot";
2775cdf0e10cSrcweir
2776cdf0e10cSrcweir		$systemcall = "rm -rf $removedir";
2777cdf0e10cSrcweir
2778cdf0e10cSrcweir		installer::logger::print_message( "... $systemcall ...\n" );
2779cdf0e10cSrcweir
2780cdf0e10cSrcweir		my $returnvalue = system($systemcall);
2781cdf0e10cSrcweir
2782cdf0e10cSrcweir		$removedir = $epmdir . "BUILD";
2783cdf0e10cSrcweir
2784cdf0e10cSrcweir		$systemcall = "rm -rf $removedir";
2785cdf0e10cSrcweir
2786cdf0e10cSrcweir		installer::logger::print_message( "... $systemcall ...\n" );
2787cdf0e10cSrcweir
2788cdf0e10cSrcweir		$returnvalue = system($systemcall);
2789cdf0e10cSrcweir
2790cdf0e10cSrcweir
2791cdf0e10cSrcweir		my $infoline = "Systemcall: $systemcall\n";
2792cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
2793cdf0e10cSrcweir
2794cdf0e10cSrcweir		if ($returnvalue)
2795cdf0e10cSrcweir		{
2796cdf0e10cSrcweir			$infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2797cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
2798cdf0e10cSrcweir		}
2799cdf0e10cSrcweir		else
2800cdf0e10cSrcweir		{
2801cdf0e10cSrcweir			$infoline = "Success: Executed \"$systemcall\" successfully!\n";
2802cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
2803cdf0e10cSrcweir		}
2804cdf0e10cSrcweir	}
2805cdf0e10cSrcweir}
2806cdf0e10cSrcweir
2807cdf0e10cSrcweir######################################################
2808cdf0e10cSrcweir# Making the systemcall
2809cdf0e10cSrcweir######################################################
2810cdf0e10cSrcweir
2811cdf0e10cSrcweirsub make_systemcall
2812cdf0e10cSrcweir{
2813cdf0e10cSrcweir	my ($systemcall) = @_;
2814cdf0e10cSrcweir
2815cdf0e10cSrcweir	my $returnvalue = system($systemcall);
2816cdf0e10cSrcweir
2817cdf0e10cSrcweir	my $infoline = "Systemcall: $systemcall\n";
2818cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
2819cdf0e10cSrcweir
2820cdf0e10cSrcweir	if ($returnvalue)
2821cdf0e10cSrcweir	{
2822cdf0e10cSrcweir		$infoline = "ERROR: Could not execute \"$systemcall\"!\n";
2823cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
2824cdf0e10cSrcweir	}
2825cdf0e10cSrcweir	else
2826cdf0e10cSrcweir	{
2827cdf0e10cSrcweir		$infoline = "Success: Executed \"$systemcall\" successfully!\n";
2828cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
2829cdf0e10cSrcweir	}
2830cdf0e10cSrcweir}
2831cdf0e10cSrcweir
2832cdf0e10cSrcweir###########################################################
2833cdf0e10cSrcweir# Creating a better directory structure in the solver.
2834cdf0e10cSrcweir###########################################################
2835cdf0e10cSrcweir
2836cdf0e10cSrcweirsub create_new_directory_structure
2837cdf0e10cSrcweir{
2838cdf0e10cSrcweir	my ($newepmdir) = @_;
2839cdf0e10cSrcweir
2840cdf0e10cSrcweir	my $newdir = $installer::globals::epmoutpath;
2841cdf0e10cSrcweir
2842cdf0e10cSrcweir	if ( $installer::globals::islinuxrpmbuild )
2843cdf0e10cSrcweir	{
2844cdf0e10cSrcweir		my $rpmdir;
2845cdf0e10cSrcweir                my $machine = "";
2846cdf0e10cSrcweir		if ( $installer::globals::compiler =~ /unxlngi/) {
2847cdf0e10cSrcweir                    $rpmdir = "$installer::globals::epmoutpath/RPMS/i586";
2848cdf0e10cSrcweir                }
2849cdf0e10cSrcweir		elsif ( $installer::globals::compiler =~ /unxlng/) {
2850cdf0e10cSrcweir                    $machine = (POSIX::uname())[4];
2851cdf0e10cSrcweir                    $rpmdir = "$installer::globals::epmoutpath/RPMS/$machine";
2852cdf0e10cSrcweir                }
2853cdf0e10cSrcweir                else { installer::exiter::exit_program("ERROR: rpmdir undefined !", "create_new_directory_structure"); }
2854cdf0e10cSrcweir
2855cdf0e10cSrcweir		my $systemcall = "mv $rpmdir/* $newdir";	# moving the rpms into the directory "RPMS"
2856cdf0e10cSrcweir
2857cdf0e10cSrcweir		my $returnvalue = system($systemcall);
2858cdf0e10cSrcweir
2859cdf0e10cSrcweir		my $infoline = "Systemcall: $systemcall\n";
2860cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
2861cdf0e10cSrcweir
2862cdf0e10cSrcweir		if ($returnvalue)
2863cdf0e10cSrcweir		{
2864cdf0e10cSrcweir			$infoline = "ERROR: Could not move content of \"$rpmdir\" to \"$newdir\"!\n";
2865cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
2866cdf0e10cSrcweir		}
2867cdf0e10cSrcweir		else
2868cdf0e10cSrcweir		{
2869cdf0e10cSrcweir			$infoline = "Success: Moved content of \"$rpmdir\" to \"$newdir\"!\n";
2870cdf0e10cSrcweir			push( @installer::globals::logfileinfo, $infoline);
2871cdf0e10cSrcweir		}
2872cdf0e10cSrcweir
2873cdf0e10cSrcweir		# and removing the empty directory
2874cdf0e10cSrcweir
2875cdf0e10cSrcweir		if ( $machine ne "" )
2876cdf0e10cSrcweir		{
2877cdf0e10cSrcweir			installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/$machine");
2878cdf0e10cSrcweir		}
2879cdf0e10cSrcweir		installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/x86_64");
2880cdf0e10cSrcweir		installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/i586");
2881cdf0e10cSrcweir		installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS/i386");
2882cdf0e10cSrcweir		installer::systemactions::remove_empty_directory("$installer::globals::epmoutpath/RPMS");
2883cdf0e10cSrcweir
2884cdf0e10cSrcweir	}
2885cdf0e10cSrcweir
2886cdf0e10cSrcweir	# Setting unix rights to "775" for $newdir ("RPMS" or "packages")
2887cdf0e10cSrcweir
2888cdf0e10cSrcweir	my $localcall = "chmod 775 $newdir \>\/dev\/null 2\>\&1";
2889cdf0e10cSrcweir	my $callreturnvalue = system($localcall);
2890cdf0e10cSrcweir
2891cdf0e10cSrcweir	my $callinfoline = "Systemcall: $localcall\n";
2892cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $callinfoline);
2893cdf0e10cSrcweir
2894cdf0e10cSrcweir	if ($callreturnvalue)
2895cdf0e10cSrcweir	{
2896cdf0e10cSrcweir		$callinfoline = "ERROR: Could not execute \"$localcall\"!\n";
2897cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $callinfoline);
2898cdf0e10cSrcweir	}
2899cdf0e10cSrcweir	else
2900cdf0e10cSrcweir	{
2901cdf0e10cSrcweir		$callinfoline = "Success: Executed \"$localcall\" successfully!\n";
2902cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $callinfoline);
2903cdf0e10cSrcweir	}
2904cdf0e10cSrcweir}
2905cdf0e10cSrcweir
2906cdf0e10cSrcweir######################################################
2907cdf0e10cSrcweir# Collect modules with product specific styles.
2908cdf0e10cSrcweir######################################################
2909cdf0e10cSrcweir
2910cdf0e10cSrcweirsub collect_modules_with_style
2911cdf0e10cSrcweir{
2912cdf0e10cSrcweir	my ($style, $modulesarrayref) = @_;
2913cdf0e10cSrcweir
2914cdf0e10cSrcweir	my @allmodules = ();
2915cdf0e10cSrcweir
2916cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$modulesarrayref}; $i++ )
2917cdf0e10cSrcweir	{
2918cdf0e10cSrcweir		my $onemodule = ${$modulesarrayref}[$i];
2919cdf0e10cSrcweir		my $styles = "";
2920cdf0e10cSrcweir		if ( $onemodule->{'Styles'} ) { $styles = $onemodule->{'Styles'}; }
2921cdf0e10cSrcweir		if ( $styles =~ /\b\Q$style\E\b/ )
2922cdf0e10cSrcweir		{
2923cdf0e10cSrcweir			push(@allmodules, $onemodule);
2924cdf0e10cSrcweir		}
2925cdf0e10cSrcweir	}
2926cdf0e10cSrcweir
2927cdf0e10cSrcweir	return \@allmodules;
2928cdf0e10cSrcweir}
2929cdf0e10cSrcweir
2930cdf0e10cSrcweir######################################################
2931cdf0e10cSrcweir# Remove modules without packagecontent.
2932cdf0e10cSrcweir######################################################
2933cdf0e10cSrcweir
2934cdf0e10cSrcweirsub remove_modules_without_package
2935cdf0e10cSrcweir{
2936cdf0e10cSrcweir	my ($allmodules) = @_;
2937cdf0e10cSrcweir
2938cdf0e10cSrcweir	my @allmodules = ();
2939cdf0e10cSrcweir
2940cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2941cdf0e10cSrcweir	{
2942cdf0e10cSrcweir		my $onemodule = ${$allmodules}[$i];
2943cdf0e10cSrcweir		my $packagename = "";
2944cdf0e10cSrcweir		if ( $onemodule->{'PackageName'} ) { $packagename = $onemodule->{'PackageName'}; }
2945cdf0e10cSrcweir		if ( $packagename ne "" )
2946cdf0e10cSrcweir		{
2947cdf0e10cSrcweir			push(@allmodules, $onemodule);
2948cdf0e10cSrcweir		}
2949cdf0e10cSrcweir	}
2950cdf0e10cSrcweir
2951cdf0e10cSrcweir	return \@allmodules;
2952cdf0e10cSrcweir}
2953cdf0e10cSrcweir
2954cdf0e10cSrcweir######################################################
2955cdf0e10cSrcweir# Unpacking tar.gz file and setting new packagename.
2956cdf0e10cSrcweir######################################################
2957cdf0e10cSrcweir
2958cdf0e10cSrcweirsub unpack_tar_gz_file
2959cdf0e10cSrcweir{
2960cdf0e10cSrcweir	my ($packagename, $destdir) = @_;
2961cdf0e10cSrcweir
2962cdf0e10cSrcweir	my $newpackagename = "";
2963cdf0e10cSrcweir
2964cdf0e10cSrcweir	if ( $packagename =~ /\.tar\.gz\s*$/ )
2965cdf0e10cSrcweir	{
2966cdf0e10cSrcweir		# Collecting all packages in directory "packages"
2967cdf0e10cSrcweir		my $oldcontent = installer::systemactions::read_directory($destdir);
2968cdf0e10cSrcweir
2969cdf0e10cSrcweir		# unpacking gunzip
2970cdf0e10cSrcweir		my $systemcall = "cd $destdir; cat $packagename | gunzip | tar -xf -";
2971cdf0e10cSrcweir		make_systemcall($systemcall);
2972cdf0e10cSrcweir
2973cdf0e10cSrcweir		# deleting the tar.gz files
2974cdf0e10cSrcweir		$systemcall = "cd $destdir; rm -f $packagename";
2975cdf0e10cSrcweir		make_systemcall($systemcall);
2976cdf0e10cSrcweir
2977cdf0e10cSrcweir		# Finding new content -> that is the package name
2978cdf0e10cSrcweir		my ($newcontent, $allcontent ) = installer::systemactions::find_new_content_in_directory($destdir, $oldcontent);
2979cdf0e10cSrcweir		$newpackagename = ${$newcontent}[0];
2980cdf0e10cSrcweir		installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$newpackagename);
2981cdf0e10cSrcweir	}
2982cdf0e10cSrcweir
2983cdf0e10cSrcweir	if ( $newpackagename ne "" ) { $packagename = $newpackagename; }
2984cdf0e10cSrcweir
2985cdf0e10cSrcweir	return $packagename;
2986cdf0e10cSrcweir}
2987cdf0e10cSrcweir
2988cdf0e10cSrcweir######################################################
2989cdf0e10cSrcweir# Copying files of child projects.
2990cdf0e10cSrcweir######################################################
2991cdf0e10cSrcweir
2992cdf0e10cSrcweirsub copy_childproject_files
2993cdf0e10cSrcweir{
2994cdf0e10cSrcweir	my ($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, $subdir, $includepatharrayref, $use_sopackpath) = @_;
2995cdf0e10cSrcweir
2996cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
2997cdf0e10cSrcweir	{
2998cdf0e10cSrcweir		my $localdestdir = $destdir;
2999cdf0e10cSrcweir		my $onemodule = ${$allmodules}[$i];
3000cdf0e10cSrcweir		my $packagename = $onemodule->{'PackageName'};
3001cdf0e10cSrcweir		my $sourcefile = "";
3002cdf0e10cSrcweir		if ( $use_sopackpath )
3003cdf0e10cSrcweir		{
3004cdf0e10cSrcweir			$sourcefile = $sopackpath . $installer::globals::separator . $installer::globals::compiler . $installer::globals::separator . $subdir . $installer::globals::separator . $packagename;
3005cdf0e10cSrcweir		}
3006cdf0e10cSrcweir		else
3007cdf0e10cSrcweir		{
3008cdf0e10cSrcweir			my $sourcepathref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packagename, $includepatharrayref, 1);
3009cdf0e10cSrcweir			$sourcefile = $$sourcepathref;
3010cdf0e10cSrcweir		}
3011cdf0e10cSrcweir
3012cdf0e10cSrcweir		if ( ! -f $sourcefile ) { installer::exiter::exit_program("ERROR: File not found: $sourcefile ($packagename) !", "copy_childproject_files"); }
3013cdf0e10cSrcweir		if ( $onemodule->{'Subdir'} )
3014cdf0e10cSrcweir		{
3015cdf0e10cSrcweir			$localdestdir = $localdestdir . $installer::globals::separator . $onemodule->{'Subdir'};
3016cdf0e10cSrcweir			if ( ! -d $localdestdir ) { installer::systemactions::create_directory($localdestdir); }
3017cdf0e10cSrcweir		}
3018cdf0e10cSrcweir		installer::systemactions::copy_one_file($sourcefile, $localdestdir);
3019cdf0e10cSrcweir		# Solaris: unpacking tar.gz files and setting new packagename
3020cdf0e10cSrcweir		if ( $installer::globals::issolarispkgbuild ) { $packagename = unpack_tar_gz_file($packagename, $localdestdir); }
3021cdf0e10cSrcweir
3022cdf0e10cSrcweir		if (( $installer::globals::isxpdplatform ) && ( $allvariables->{'XPDINSTALLER'} ))
3023cdf0e10cSrcweir		{
3024cdf0e10cSrcweir			installer::xpdinstaller::create_xpd_file_for_childproject($onemodule, $localdestdir, $packagename, $allvariableshashref, $modulesarrayref);
3025cdf0e10cSrcweir		}
3026cdf0e10cSrcweir	}
3027cdf0e10cSrcweir
3028cdf0e10cSrcweir}
3029cdf0e10cSrcweir
3030cdf0e10cSrcweir######################################################
3031cdf0e10cSrcweir# Copying files for system integration.
3032cdf0e10cSrcweir######################################################
3033cdf0e10cSrcweir
3034cdf0e10cSrcweirsub copy_and_unpack_tar_gz_files
3035cdf0e10cSrcweir{
3036cdf0e10cSrcweir	my ($sourcefile, $destdir) = @_;
3037cdf0e10cSrcweir
3038cdf0e10cSrcweir	my $systemcall = "cd $destdir; cat $sourcefile | gunzip | tar -xf -";
3039cdf0e10cSrcweir	make_systemcall($systemcall);
3040cdf0e10cSrcweir}
3041cdf0e10cSrcweir
3042cdf0e10cSrcweir######################################################
3043cdf0e10cSrcweir# Including child packages into the
3044cdf0e10cSrcweir# installation set.
3045cdf0e10cSrcweir######################################################
3046cdf0e10cSrcweir
3047cdf0e10cSrcweirsub put_childprojects_into_installset
3048cdf0e10cSrcweir{
3049cdf0e10cSrcweir	my ($newdir, $allvariables, $modulesarrayref, $includepatharrayref) = @_;
3050cdf0e10cSrcweir
3051cdf0e10cSrcweir	my $infoline = "";
3052cdf0e10cSrcweir
3053cdf0e10cSrcweir	my $sopackpath = "";
3054cdf0e10cSrcweir	if ( $ENV{'SO_PACK'} ) { $sopackpath  = $ENV{'SO_PACK'}; }
3055cdf0e10cSrcweir	else { installer::exiter::exit_program("ERROR: Environment variable SO_PACK not set!", "put_childprojects_into_installset"); }
3056cdf0e10cSrcweir
3057cdf0e10cSrcweir	my $destdir = "$newdir";
3058cdf0e10cSrcweir
3059cdf0e10cSrcweir	# adding Java
3060cdf0e10cSrcweir
3061cdf0e10cSrcweir	my $sourcefile = "";
3062cdf0e10cSrcweir
3063cdf0e10cSrcweir	# Finding the modules defined in scp (with flag JAVAMODULE, ADAMODULE, ...)
3064cdf0e10cSrcweir	# Getting name of package from scp-Module
3065cdf0e10cSrcweir	# Copy file into installation set
3066cdf0e10cSrcweir	# Create xpd file and put it into xpd directory
3067cdf0e10cSrcweir	# xpd file has to be created completely from module and package itself (-> no packagelist!)
3068cdf0e10cSrcweir
3069cdf0e10cSrcweir	if ( $allvariables->{'JAVAPRODUCT'} )
3070cdf0e10cSrcweir	{
3071cdf0e10cSrcweir		# Collect all modules with flag "JAVAMODULE"
3072cdf0e10cSrcweir		my $allmodules = collect_modules_with_style("JAVAMODULE", $modulesarrayref);
3073cdf0e10cSrcweir		$allmodules = remove_modules_without_package($allmodules);
3074cdf0e10cSrcweir		copy_childproject_files($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "jre", $includepatharrayref, 1);
3075cdf0e10cSrcweir	}
3076cdf0e10cSrcweir
3077cdf0e10cSrcweir	# Adding additional required packages (freetype).
3078cdf0e10cSrcweir	# This package names are stored in global array @installer::globals::requiredpackages
3079cdf0e10cSrcweir
3080cdf0e10cSrcweir	if ( $allvariables->{'ADDREQUIREDPACKAGES'} )
3081cdf0e10cSrcweir	{
3082cdf0e10cSrcweir		# Collect all modules with flag "REQUIREDPACKAGEMODULE"
3083cdf0e10cSrcweir		my $allmodules = collect_modules_with_style("REQUIREDPACKAGEMODULE", $modulesarrayref);
3084cdf0e10cSrcweir		$allmodules = remove_modules_without_package($allmodules);
3085cdf0e10cSrcweir		copy_childproject_files($allmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "requiredpackages", $includepatharrayref, 1);
3086cdf0e10cSrcweir	}
3087cdf0e10cSrcweir
3088cdf0e10cSrcweir	# Collect all modules with flag "USERLANDMODULE"
3089cdf0e10cSrcweir	my $alluserlandmodules = collect_modules_with_style("USERLANDMODULE", $modulesarrayref);
3090cdf0e10cSrcweir	$alluserlandmodules = remove_modules_without_package($alluserlandmodules);
3091cdf0e10cSrcweir	copy_childproject_files($alluserlandmodules, $sopackpath, $destdir, $modulesarrayref, $allvariables, "", $includepatharrayref, 0);
3092cdf0e10cSrcweir
3093cdf0e10cSrcweir}
3094cdf0e10cSrcweir
3095cdf0e10cSrcweir######################################################
3096cdf0e10cSrcweir# Checking whether the new content is a directory and
3097cdf0e10cSrcweir# not a package. If it is a directory, the complete
3098cdf0e10cSrcweir# content of the directory has to be added to the
3099cdf0e10cSrcweir# array newcontent.
3100cdf0e10cSrcweir######################################################
3101cdf0e10cSrcweir
3102cdf0e10cSrcweirsub control_subdirectories
3103cdf0e10cSrcweir{
3104cdf0e10cSrcweir	my ($content, $subdir) = @_;
3105cdf0e10cSrcweir
3106cdf0e10cSrcweir	my @newcontent = ();
3107cdf0e10cSrcweir
3108cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$content}; $i++ )
3109cdf0e10cSrcweir	{
3110cdf0e10cSrcweir		if ( -d ${$content}[$i] )
3111cdf0e10cSrcweir		{
3112cdf0e10cSrcweir			$subdir = ${$content}[$i];
3113cdf0e10cSrcweir			installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$subdir);
3114cdf0e10cSrcweir			my $allpackages = installer::systemactions::read_directory(${$content}[$i]);
3115cdf0e10cSrcweir			for ( my $j = 0; $j <= $#{$allpackages}; $j++ )
3116cdf0e10cSrcweir			{
3117cdf0e10cSrcweir				# Currently only Linux rpm is supported, debian packages cannot be installed via xpd installer
3118cdf0e10cSrcweir				if (( $installer::globals::islinuxbuild ) && ( ! ( ${$allpackages}[$j] =~ /\.rpm\s*$/ ))) { next; }
3119cdf0e10cSrcweir				push(@newcontent, ${$allpackages}[$j]);
3120cdf0e10cSrcweir			}
3121cdf0e10cSrcweir		}
3122cdf0e10cSrcweir		else
3123cdf0e10cSrcweir		{
3124cdf0e10cSrcweir			push(@newcontent, ${$content}[$i]);
3125cdf0e10cSrcweir		}
3126cdf0e10cSrcweir	}
3127cdf0e10cSrcweir
3128cdf0e10cSrcweir	return (\@newcontent, $subdir);
3129cdf0e10cSrcweir}
3130cdf0e10cSrcweir
3131cdf0e10cSrcweir######################################################
3132cdf0e10cSrcweir# Including the system integration files into the
3133cdf0e10cSrcweir# installation sets.
3134cdf0e10cSrcweir######################################################
3135cdf0e10cSrcweir
3136cdf0e10cSrcweirsub put_systemintegration_into_installset
3137cdf0e10cSrcweir{
3138cdf0e10cSrcweir	my ($newdir, $includepatharrayref, $allvariables, $modulesarrayref) = @_;
3139cdf0e10cSrcweir
3140cdf0e10cSrcweir	my $destdir = $newdir;
3141cdf0e10cSrcweir
3142cdf0e10cSrcweir	# adding System integration files
3143cdf0e10cSrcweir
3144cdf0e10cSrcweir	my $sourcefile = "";
3145cdf0e10cSrcweir
3146cdf0e10cSrcweir	# Finding the modules defined in scp (with flag SYSTEMMODULE)
3147cdf0e10cSrcweir	# Getting name of package from scp-Module
3148cdf0e10cSrcweir	# Search package in list off all include files
3149cdf0e10cSrcweir	# Copy file into installation set and unpack it (always tar.gz)
3150cdf0e10cSrcweir	# Create xpd file and put it into xpd directory
3151cdf0e10cSrcweir	# tar.gz can contain a different number of packages -> automatically create hidden sub modules
3152cdf0e10cSrcweir	# xpd file has to be created completely from module and package itself (-> no packagelist!)
3153cdf0e10cSrcweir
3154cdf0e10cSrcweir	# Collect all modules with flag "SYSTEMMODULE"
3155cdf0e10cSrcweir	my $allmodules = collect_modules_with_style("SYSTEMMODULE", $modulesarrayref);
3156cdf0e10cSrcweir	$allmodules = remove_modules_without_package($allmodules);
3157cdf0e10cSrcweir
3158cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$allmodules}; $i++ )
3159cdf0e10cSrcweir	{
3160cdf0e10cSrcweir		my $onemodule = ${$allmodules}[$i];
3161cdf0e10cSrcweir		my $packagetarfilename = $onemodule->{'PackageName'};
3162cdf0e10cSrcweir
3163cdf0e10cSrcweir		my $infoline = "Including into installation set: $packagetarfilename\n";
3164cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
3165cdf0e10cSrcweir
3166cdf0e10cSrcweir		my $sourcepathref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$packagetarfilename, $includepatharrayref, 1);
3167cdf0e10cSrcweir		if ( $$sourcepathref eq "" ) { installer::exiter::exit_program("ERROR: Source path not found for $packagetarfilename!", "copy_systemintegration_files"); }
3168cdf0e10cSrcweir
3169cdf0e10cSrcweir		# Collecting all packages in directory "packages" or "RPMS"
3170cdf0e10cSrcweir		my $oldcontent = installer::systemactions::read_directory($destdir);
3171cdf0e10cSrcweir
3172cdf0e10cSrcweir		copy_and_unpack_tar_gz_files($$sourcepathref, $destdir);
3173cdf0e10cSrcweir
3174cdf0e10cSrcweir		# Finding new content -> that is the package name
3175cdf0e10cSrcweir		my ($newcontent, $allcontent ) = installer::systemactions::find_new_content_in_directory($destdir, $oldcontent);
3176cdf0e10cSrcweir
3177cdf0e10cSrcweir		# special handling, if new content is a directory
3178cdf0e10cSrcweir		my $subdir = "";
3179cdf0e10cSrcweir		if ( ! $installer::globals::issolarispkgbuild ) { ($newcontent, $subdir) = control_subdirectories($newcontent); }
3180cdf0e10cSrcweir
3181cdf0e10cSrcweir		# Adding license content into Solaris packages
3182cdf0e10cSrcweir		if (( $installer::globals::issolarispkgbuild ) && ( $installer::globals::englishlicenseset ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} )) { installer::worker::add_license_into_systemintegrationpackages($destdir, $newcontent); }
3183cdf0e10cSrcweir
3184cdf0e10cSrcweir		if (( $installer::globals::isxpdplatform ) && ( $allvariables->{'XPDINSTALLER'} ))
3185cdf0e10cSrcweir		{
3186cdf0e10cSrcweir			installer::xpdinstaller::create_xpd_file_for_systemintegration($onemodule, $newcontent, $modulesarrayref, $subdir);
3187cdf0e10cSrcweir		}
3188cdf0e10cSrcweir	}
3189cdf0e10cSrcweir}
3190cdf0e10cSrcweir
3191cdf0e10cSrcweir######################################################
3192cdf0e10cSrcweir# Analyzing the Unix installation path.
3193cdf0e10cSrcweir# From the installation path /opt/openofficeorg20
3194cdf0e10cSrcweir# is the part /opt relocatable and the part
3195cdf0e10cSrcweir# openofficeorg20 static.
3196cdf0e10cSrcweir######################################################
3197cdf0e10cSrcweir
3198cdf0e10cSrcweirsub analyze_rootpath
3199cdf0e10cSrcweir{
3200cdf0e10cSrcweir	my ($rootpath, $staticpathref, $relocatablepathref, $allvariables) = @_;
3201cdf0e10cSrcweir
3202cdf0e10cSrcweir	$rootpath =~ s/\/\s*$//;	# removing ending slash
3203cdf0e10cSrcweir
3204cdf0e10cSrcweir	##############################################################
3205cdf0e10cSrcweir	# Version 1: "/opt" is variable and "openofficeorg20" fixed
3206cdf0e10cSrcweir	##############################################################
3207cdf0e10cSrcweir
3208cdf0e10cSrcweir	# my $staticpath = $rootpath;
3209cdf0e10cSrcweir	# installer::pathanalyzer::make_absolute_filename_to_relative_filename(\$staticpath);
3210cdf0e10cSrcweir	# $$staticpathref = $staticpath;				# will be "openofficeorg20"
3211cdf0e10cSrcweir
3212cdf0e10cSrcweir	# my $relocatablepath = $rootpath;
3213cdf0e10cSrcweir	# installer::pathanalyzer::get_path_from_fullqualifiedname(\$relocatablepath);
3214cdf0e10cSrcweir	# $$relocatablepathref = $relocatablepath;		# will be "/opt/"
3215cdf0e10cSrcweir
3216cdf0e10cSrcweir	##############################################################
3217cdf0e10cSrcweir	# Version 2: "/opt/openofficeorg20" is variable and "" fixed
3218cdf0e10cSrcweir	##############################################################
3219cdf0e10cSrcweir
3220cdf0e10cSrcweir	# if ( $$relocatablepathref eq "" )	# relocatablepath is not defined in package list
3221cdf0e10cSrcweir	# {
3222cdf0e10cSrcweir	#	$$staticpathref = "";	# will be ""
3223cdf0e10cSrcweir	#	$$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/openofficeorg20/"
3224cdf0e10cSrcweir	#	# setting the static path to the hostname of the directory with style OFFICEDIRECTORY
3225cdf0e10cSrcweir	#	if ( $allvariables->{'SETSTATICPATH'} ) { $$staticpathref = $installer::globals::officedirhostname; }
3226cdf0e10cSrcweir	#
3227cdf0e10cSrcweir	# }
3228cdf0e10cSrcweir	# else	# relocatablepath is defined in package list
3229cdf0e10cSrcweir	# {
3230cdf0e10cSrcweir	#	$$relocatablepathref =~ s/\/\s*$//;			# removing ending slash
3231cdf0e10cSrcweir	#	$$relocatablepathref = $$relocatablepathref . "\/";	# relocatable path must end with "/"
3232cdf0e10cSrcweir	#	my $staticpath = $rootpath;
3233cdf0e10cSrcweir	#	$staticpath =~ s/\Q$$relocatablepathref\E//;
3234cdf0e10cSrcweir	#	$staticpath =~ s/\/\s*$//;
3235cdf0e10cSrcweir	#	$$staticpathref = $staticpath;
3236cdf0e10cSrcweir	# }
3237cdf0e10cSrcweir
3238cdf0e10cSrcweir	##############################################################
3239cdf0e10cSrcweir	# Version 3: "/" is variable and "/opt/openofficeorg20" fixed
3240cdf0e10cSrcweir	##############################################################
3241cdf0e10cSrcweir
3242cdf0e10cSrcweir	$$relocatablepathref = "/";
3243cdf0e10cSrcweir	# Static path has to contain the office directory name. This is replaced in shellscripts.
3244cdf0e10cSrcweir	$$staticpathref = $rootpath . $installer::globals::separator . $installer::globals::officedirhostname;
3245cdf0e10cSrcweir	# For RPM version 3.x it is required, that Prefix is not "/" in spec file. In this case --relocate will not work,
3246cdf0e10cSrcweir	# because RPM 3.x says, that the package is not relocatable. Therefore we have to use Prefix=/opt and for
3247cdf0e10cSrcweir	# all usages of --relocate this path has to be on both sides of the "=": --relocate /opt=<myselectdir>/opt .
3248cdf0e10cSrcweir	if ( $installer::globals::islinuxrpmbuild )
3249cdf0e10cSrcweir	{
3250cdf0e10cSrcweir		$$relocatablepathref = $rootpath . "\/"; # relocatable path must end with "/", will be "/opt/"
3251cdf0e10cSrcweir		$$staticpathref = $installer::globals::officedirhostname; # to be used as replacement in shell scripts
3252cdf0e10cSrcweir	}
3253cdf0e10cSrcweir
3254cdf0e10cSrcweir	if ( $installer::globals::islinuxdebbuild )
3255cdf0e10cSrcweir	{
3256cdf0e10cSrcweir		$$relocatablepathref = "";
3257cdf0e10cSrcweir		# $$staticpathref is already "/opt/openoffice.org3", no additional $rootpath required.
3258cdf0e10cSrcweir		# $$staticpathref = $rootpath . $installer::globals::separator . $$staticpathref;  # no relocatibility for Debian
3259cdf0e10cSrcweir	}
3260cdf0e10cSrcweir
3261cdf0e10cSrcweir}
3262cdf0e10cSrcweir
3263cdf0e10cSrcweir######################################################
3264cdf0e10cSrcweir# Including license and readme into
3265cdf0e10cSrcweir# Unix installation sets.
3266cdf0e10cSrcweir######################################################
3267cdf0e10cSrcweir
3268cdf0e10cSrcweirsub put_installsetfiles_into_installset
3269cdf0e10cSrcweir{
3270cdf0e10cSrcweir	my ($destdir) = @_;
3271cdf0e10cSrcweir
3272cdf0e10cSrcweir	# All files for the installation set are saved in the global
3273cdf0e10cSrcweir	# array @installer::globals::installsetfiles
3274cdf0e10cSrcweir
3275cdf0e10cSrcweir	for ( my $i = 0; $i <= $#installer::globals::installsetfiles; $i++ )
3276cdf0e10cSrcweir	{
3277cdf0e10cSrcweir		my $onefile = $installer::globals::installsetfiles[$i];
3278cdf0e10cSrcweir		my $sourcefile = $onefile->{'sourcepath'};
3279cdf0e10cSrcweir		my $destfile = "";
3280cdf0e10cSrcweir		if ( $installer::globals::addjavainstaller ) { $destfile = $onefile->{'Name'}; }
3281cdf0e10cSrcweir		else { $destfile = $destdir . $installer::globals::separator . $onefile->{'Name'}; }
3282cdf0e10cSrcweir		installer::systemactions::copy_one_file($sourcefile, $destfile);
3283cdf0e10cSrcweir
3284cdf0e10cSrcweir		my $infoline = "Adding to installation set \"$destfile\" from source \"$sourcefile\".\n";
3285cdf0e10cSrcweir		push( @installer::globals::logfileinfo, $infoline);
3286cdf0e10cSrcweir	}
3287cdf0e10cSrcweir}
3288cdf0e10cSrcweir
3289cdf0e10cSrcweir######################################################
3290cdf0e10cSrcweir# Replacing one variable in patchinfo file
3291cdf0e10cSrcweir######################################################
3292cdf0e10cSrcweir
3293cdf0e10cSrcweirsub replace_one_variable_in_file
3294cdf0e10cSrcweir{
3295cdf0e10cSrcweir	my ( $file, $placeholder, $value ) = @_;
3296cdf0e10cSrcweir
3297cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$file}; $i++ )
3298cdf0e10cSrcweir	{
3299cdf0e10cSrcweir		${$file}[$i] =~ s/$placeholder/$value/g;
3300cdf0e10cSrcweir	}
3301cdf0e10cSrcweir}
3302cdf0e10cSrcweir
3303cdf0e10cSrcweir######################################################
3304cdf0e10cSrcweir# Setting variables in the patchinfo file
3305cdf0e10cSrcweir######################################################
3306cdf0e10cSrcweir
3307cdf0e10cSrcweirsub set_patchinfo
3308cdf0e10cSrcweir{
3309cdf0e10cSrcweir	my ( $patchinfofile, $patchid, $allvariables ) = @_;
3310cdf0e10cSrcweir
3311cdf0e10cSrcweir	# Setting: PATCHIDPLACEHOLDER and ARCHITECTUREPLACEHOLDER and PATCHCORRECTSPLACEHOLDER
3312cdf0e10cSrcweir
3313cdf0e10cSrcweir	replace_one_variable_in_file($patchinfofile, "PATCHIDPLACEHOLDER", $patchid);
3314cdf0e10cSrcweir
3315cdf0e10cSrcweir	my $architecture = "";
3316cdf0e10cSrcweir	if ( $installer::globals::issolarissparcbuild ) { $architecture = "sparc"; }
3317cdf0e10cSrcweir	if ( $installer::globals::issolarisx86build ) { $architecture = "i386"; }
3318cdf0e10cSrcweir
3319cdf0e10cSrcweir	replace_one_variable_in_file($patchinfofile, "ARCHITECTUREPLACEHOLDER", $architecture);
3320cdf0e10cSrcweir
3321cdf0e10cSrcweir	if ( ! $allvariables->{'SOLARISPATCHCORRECTS'} ) { installer::exiter::exit_program("ERROR: No setting for PATCH_CORRECTS in zip list file!", "set_patchinfo"); }
3322cdf0e10cSrcweir	my $patchcorrects = $allvariables->{'SOLARISPATCHCORRECTS'};
3323cdf0e10cSrcweir
3324cdf0e10cSrcweir	replace_one_variable_in_file($patchinfofile, "PATCHCORRECTSPLACEHOLDER", $patchcorrects);
3325cdf0e10cSrcweir
3326cdf0e10cSrcweir	# Setting also PATCH_REQUIRES in patch info file, if entry in zip list file exists
3327cdf0e10cSrcweir	my $requiresstring = "";
3328cdf0e10cSrcweir	if ( $installer::globals::issolarissparcbuild ) { $requiresstring = "SOLSPARCPATCHREQUIRES"; }
3329cdf0e10cSrcweir	if ( $installer::globals::issolarisx86build ) { $requiresstring = "SOLIAPATCHREQUIRES"; }
3330cdf0e10cSrcweir
3331cdf0e10cSrcweir	if ( $allvariables->{$requiresstring} )
3332cdf0e10cSrcweir	{
3333cdf0e10cSrcweir		my $newline = "PATCH_REQUIRES=\"" . $allvariables->{$requiresstring} . "\"" . "\n";
3334cdf0e10cSrcweir		push(@{$patchinfofile}, $newline);
3335cdf0e10cSrcweir	}
3336cdf0e10cSrcweir}
3337cdf0e10cSrcweir
3338cdf0e10cSrcweir######################################################
3339cdf0e10cSrcweir# Finalizing patch: Renaming directory and
3340cdf0e10cSrcweir# including additional patch files.
3341cdf0e10cSrcweir######################################################
3342cdf0e10cSrcweir
3343cdf0e10cSrcweirsub finalize_patch
3344cdf0e10cSrcweir{
3345cdf0e10cSrcweir	my ( $newepmdir, $allvariables ) = @_;
3346cdf0e10cSrcweir
3347cdf0e10cSrcweir	my $patchidname = "SOLSPARCPATCHID";
3348cdf0e10cSrcweir	if ( $installer::globals::issolarisx86build ) { $patchidname = "SOLIAPATCHID"; }
3349cdf0e10cSrcweir
3350cdf0e10cSrcweir	if ( ! $allvariables->{$patchidname} ) { installer::exiter::exit_program("ERROR: Variable $patchidname not defined in zip list file!", "finalize_patch"); }
3351cdf0e10cSrcweir	my $patchid = $allvariables->{$patchidname};
3352cdf0e10cSrcweir	installer::systemactions::rename_directory($newepmdir, $patchid);
3353cdf0e10cSrcweir
3354cdf0e10cSrcweir	# Copying all typical patch files into the patch directory
3355cdf0e10cSrcweir	# All patch file names are stored in @installer::globals::solarispatchfiles
3356cdf0e10cSrcweir	# Location of the file is $installer::globals::patchincludepath
3357cdf0e10cSrcweir
3358cdf0e10cSrcweir	my $sourcepath = $installer::globals::patchincludepath;
3359cdf0e10cSrcweir	$sourcepath =~ s/\/\s*$//;
3360cdf0e10cSrcweir
3361cdf0e10cSrcweir	for ( my $i = 0; $i <= $#installer::globals::solarispatchfiles; $i++ )
3362cdf0e10cSrcweir	{
3363cdf0e10cSrcweir		my $sourcefile = $sourcepath . $installer::globals::separator . $installer::globals::solarispatchfiles[$i];
3364cdf0e10cSrcweir		my $destfile = $patchid . $installer::globals::separator . $installer::globals::solarispatchfiles[$i];
3365cdf0e10cSrcweir		installer::systemactions::copy_one_file($sourcefile, $destfile);
3366cdf0e10cSrcweir	}
3367cdf0e10cSrcweir
3368cdf0e10cSrcweir	# And editing the patchinfo file
3369cdf0e10cSrcweir
3370cdf0e10cSrcweir	my $patchinfofilename = $patchid . $installer::globals::separator . "patchinfo";
3371cdf0e10cSrcweir	my $patchinfofile = installer::files::read_file($patchinfofilename);
3372cdf0e10cSrcweir	set_patchinfo($patchinfofile, $patchid, $allvariables);
3373cdf0e10cSrcweir	installer::files::save_file($patchinfofilename, $patchinfofile);
3374cdf0e10cSrcweir}
3375cdf0e10cSrcweir
3376cdf0e10cSrcweir######################################################
3377cdf0e10cSrcweir# Finalizing Linux patch: Renaming directory and
3378cdf0e10cSrcweir# including additional patch files.
3379cdf0e10cSrcweir######################################################
3380cdf0e10cSrcweir
3381cdf0e10cSrcweirsub finalize_linux_patch
3382cdf0e10cSrcweir{
3383cdf0e10cSrcweir	my ( $newepmdir, $allvariables, $includepatharrayref ) = @_;
3384cdf0e10cSrcweir
3385cdf0e10cSrcweir	# Copying the setup into the patch directory
3386cdf0e10cSrcweir	# and including the list of RPMs into it
3387cdf0e10cSrcweir
3388cdf0e10cSrcweir	print "... creating patch setup ...\n";
3389cdf0e10cSrcweir
3390cdf0e10cSrcweir	installer::logger::include_header_into_logfile("Creating Linux patch setup:");
3391cdf0e10cSrcweir
3392cdf0e10cSrcweir	# find and read setup script template
3393cdf0e10cSrcweir
3394cdf0e10cSrcweir	my $scriptfilename = "linuxpatchscript.sh";
3395cdf0e10cSrcweir	my $scriptref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$scriptfilename, $includepatharrayref, 0);
3396cdf0e10cSrcweir	if ($$scriptref eq "") { installer::exiter::exit_program("ERROR: Could not find patch script template $scriptfilename!", "finalize_linux_patch"); }
3397cdf0e10cSrcweir	my $scriptfile = installer::files::read_file($$scriptref);
3398cdf0e10cSrcweir
3399cdf0e10cSrcweir	my $infoline = "Found  script file $scriptfilename: $$scriptref \n";
3400cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
3401cdf0e10cSrcweir
3402cdf0e10cSrcweir	# Collecting all RPMs in the patch directory
3403cdf0e10cSrcweir
3404cdf0e10cSrcweir	my $fileextension = "rpm";
3405cdf0e10cSrcweir	my $rpmfiles = installer::systemactions::find_file_with_file_extension($fileextension, $newepmdir);
3406cdf0e10cSrcweir	if ( ! ( $#{$rpmfiles} > -1 )) { installer::exiter::exit_program("ERROR: Could not find rpm in directory $newepmdir!", "finalize_linux_patch"); }
3407cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ ) { installer::pathanalyzer::make_absolute_filename_to_relative_filename(\${$rpmfiles}[$i]); }
3408cdf0e10cSrcweir
3409cdf0e10cSrcweir#	my $installline = "";
3410cdf0e10cSrcweir#
3411cdf0e10cSrcweir#	for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ )
3412cdf0e10cSrcweir#	{
3413cdf0e10cSrcweir#		$installline = $installline . "  rpm --prefix \$PRODUCTINSTALLLOCATION -U $newepmdir/${$rpmfiles}[$i]\n";
3414cdf0e10cSrcweir#	}
3415cdf0e10cSrcweir#
3416cdf0e10cSrcweir#	$installline =~ s/\s*$//;
3417cdf0e10cSrcweir#
3418cdf0e10cSrcweir#	for ( my $j = 0; $j <= $#{$scriptfile}; $j++ )
3419cdf0e10cSrcweir#	{
3420cdf0e10cSrcweir#		${$scriptfile}[$j] =~ s/INSTALLLINES/$installline/;
3421cdf0e10cSrcweir#	}
3422cdf0e10cSrcweir
3423cdf0e10cSrcweir	# Searching packagename containing -core01
3424cdf0e10cSrcweir	my $found_package = 0;
3425cdf0e10cSrcweir	my $searchpackagename = "";
3426cdf0e10cSrcweir	for ( my $i = 0; $i <= $#{$rpmfiles}; $i++ )
3427cdf0e10cSrcweir	{
3428cdf0e10cSrcweir		if ( ${$rpmfiles}[$i] =~ /-core01-/ )
3429cdf0e10cSrcweir		{
3430cdf0e10cSrcweir			$searchpackagename = ${$rpmfiles}[$i];
3431cdf0e10cSrcweir			$found_package = 1;
3432cdf0e10cSrcweir			if ( $searchpackagename =~ /^\s*(.*?-core01)-.*/ ) { $searchpackagename = $1; }
3433cdf0e10cSrcweir			last;
3434cdf0e10cSrcweir		}
3435cdf0e10cSrcweir	}
3436cdf0e10cSrcweir
3437cdf0e10cSrcweir	if ( ! $found_package ) { installer::exiter::exit_program("ERROR: No package containing \"-core01\" found in directory \"$newepmdir\"", "finalize_linux_patch"); }
3438cdf0e10cSrcweir
3439cdf0e10cSrcweir	# Replacing the searchpackagename
3440cdf0e10cSrcweir	for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/SEARCHPACKAGENAMEPLACEHOLDER/$searchpackagename/; }
3441cdf0e10cSrcweir
3442cdf0e10cSrcweir	# Setting the PRODUCTDIRECTORYNAME to $installer::globals::officedirhostname
3443cdf0e10cSrcweir	for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/PRODUCTDIRECTORYNAME/$installer::globals::officedirhostname/; }
3444cdf0e10cSrcweir
3445cdf0e10cSrcweir	# Replacing the productname
3446cdf0e10cSrcweir	my $productname = $allvariables->{'PRODUCTNAME'};
3447cdf0e10cSrcweir	$productname = lc($productname);
3448cdf0e10cSrcweir	$productname =~ s/ /_/g;	# abc office -> abc_office
3449cdf0e10cSrcweir#	$productname =~ s/\.//g;	# openoffice.org -> openofficeorg
3450cdf0e10cSrcweir
3451cdf0e10cSrcweir	$infoline = "Adding productname $productname into Linux patch script\n";
3452cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
3453cdf0e10cSrcweir
3454cdf0e10cSrcweir	for ( my $j = 0; $j <= $#{$scriptfile}; $j++ ) { ${$scriptfile}[$j] =~ s/PRODUCTNAMEPLACEHOLDER/$productname/; }
3455cdf0e10cSrcweir
3456cdf0e10cSrcweir	# Saving the file
3457cdf0e10cSrcweir
3458cdf0e10cSrcweir	my $newscriptfilename = "setup"; # $newepmdir . $installer::globals::separator . "setup";
3459cdf0e10cSrcweir	installer::files::save_file($newscriptfilename, $scriptfile);
3460cdf0e10cSrcweir
3461cdf0e10cSrcweir	$infoline = "Saved Linux patch setup $newscriptfilename \n";
3462cdf0e10cSrcweir	push( @installer::globals::logfileinfo, $infoline);
3463cdf0e10cSrcweir
3464cdf0e10cSrcweir	# Setting unix rights 755
3465cdf0e10cSrcweir	my $localcall = "chmod 775 $newscriptfilename \>\/dev\/null 2\>\&1";
3466cdf0e10cSrcweir	system($localcall);
3467cdf0e10cSrcweir}
3468cdf0e10cSrcweir
3469cdf0e10cSrcweir1;
3470