19780544fSAndrew Rist#**************************************************************
29780544fSAndrew Rist#
39780544fSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
49780544fSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
59780544fSAndrew Rist#  distributed with this work for additional information
69780544fSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
79780544fSAndrew Rist#  to you under the Apache License, Version 2.0 (the
89780544fSAndrew Rist#  "License"); you may not use this file except in compliance
99780544fSAndrew Rist#  with the License.  You may obtain a copy of the License at
109780544fSAndrew Rist#
119780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
129780544fSAndrew Rist#
139780544fSAndrew Rist#  Unless required by applicable law or agreed to in writing,
149780544fSAndrew Rist#  software distributed under the License is distributed on an
159780544fSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169780544fSAndrew Rist#  KIND, either express or implied.  See the License for the
179780544fSAndrew Rist#  specific language governing permissions and limitations
189780544fSAndrew Rist#  under the License.
199780544fSAndrew Rist#
209780544fSAndrew Rist#**************************************************************
219780544fSAndrew Rist
229780544fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweirpackage installer::parameter;
25cdf0e10cSrcweir
26cdf0e10cSrcweiruse Cwd;
27cdf0e10cSrcweiruse installer::exiter;
28cdf0e10cSrcweiruse installer::files;
29cdf0e10cSrcweiruse installer::globals;
30cdf0e10cSrcweiruse installer::logger;
31cdf0e10cSrcweiruse installer::remover;
32cdf0e10cSrcweiruse installer::systemactions;
33b274bc22SAndre Fischeruse strict;
34cdf0e10cSrcweir
35cdf0e10cSrcweir############################################
36cdf0e10cSrcweir# Parameter Operations
37cdf0e10cSrcweir############################################
38cdf0e10cSrcweir
39cdf0e10cSrcweirsub usage
40cdf0e10cSrcweir{
41cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::parameter::usage"); }
42cdf0e10cSrcweir
43cdf0e10cSrcweir	print <<Ende;
44cdf0e10cSrcweir--------------------------------------------------------------------------------
45cdf0e10cSrcweir$installer::globals::prog
46cdf0e10cSrcweirThe following parameter are needed:
47cdf0e10cSrcweir-f: Path to the product list (required)
48cdf0e10cSrcweir-s: Path to the setup script (optional, if defined in product list)
49cdf0e10cSrcweir-i: Install path of the product (/opt/openofficeorg20) (optional)
50cdf0e10cSrcweir-p: Product from product list to be created (required)
51cdf0e10cSrcweir-l: Language of the product (comma and hash) (optional, defined in productlist)
52cdf0e10cSrcweir-b: Build, e.g. srx645 (optional)
53cdf0e10cSrcweir-m: Minor, e.g. m10 (optional)
54cdf0e10cSrcweir-simple: Path to do a simple install to
55cdf0e10cSrcweir-c: Compiler, e.g. wntmsci8, unxlngi5, unxsols4, ... (optional)
56cdf0e10cSrcweir-u: Path, in which zipfiles are unpacked (optional)
57cdf0e10cSrcweir-msitemplate: Source of the msi file templates (Windows compiler only)
58cdf0e10cSrcweir-msilanguage: Source of the msi file templates (Windows compiler only)
59cdf0e10cSrcweir-javalanguage: Source of the Java language files (opt., non-Windows only)
60cdf0e10cSrcweir-buildid: Current BuildID (optional)
61cdf0e10cSrcweir-pro: Product version
62cdf0e10cSrcweir-format: Package format
63cdf0e10cSrcweir-debian: Create Debian packages for Linux
64cdf0e10cSrcweir-dontunzip: do not unzip all files with flag ARCHIVE
65cdf0e10cSrcweir-dontcallepm : do not call epm to create install sets (opt., non-Windows only)
66cdf0e10cSrcweir-ispatchedepm : Usage of a patched (non-standard) epm (opt., non-Windows only)
67cdf0e10cSrcweir-copyproject : is set for projects that are only used for copying (optional)
68cdf0e10cSrcweir-languagepack : do create a languagepack, no product pack (optional)
69cdf0e10cSrcweir-patch : do create a patch (optional)
70cdf0e10cSrcweir-patchinc: Source for the patch include files (Solaris only)
71cdf0e10cSrcweir-dontstrip: No file stripping (Unix only)
72cdf0e10cSrcweir-log : Logging all available information (optional)
73cdf0e10cSrcweir-debug : Collecting debug information
74cdf0e10cSrcweir
75cdf0e10cSrcweirExamples for Windows:
76cdf0e10cSrcweir
77cdf0e10cSrcweirperl make_epmlist.pl -f zip.lst -p OfficeFAT -l en-US
78cdf0e10cSrcweir                     -u /export/unpack -buildid 8712
79cdf0e10cSrcweir                     -msitemplate /export/msi_files
80cdf0e10cSrcweir                     -msilanguage /export/msi_languages
81cdf0e10cSrcweir
82cdf0e10cSrcweirExamples for Non-Windows:
83cdf0e10cSrcweir
84cdf0e10cSrcweirperl make_epmlist.pl -f zip.lst -p OfficeFAT -l en-US -format rpm
85cdf0e10cSrcweir                     -u /export/unpack -buildid 8712 -ispatchedepm
86cdf0e10cSrcweir--------------------------------------------------------------------------------
87cdf0e10cSrcweirEnde
88cdf0e10cSrcweir	exit(-1);
89cdf0e10cSrcweir}
90cdf0e10cSrcweir
91cdf0e10cSrcweir#########################################
92cdf0e10cSrcweir# Writing all parameter into logfile
93cdf0e10cSrcweir#########################################
94cdf0e10cSrcweir
95cdf0e10cSrcweirsub saveparameter
96cdf0e10cSrcweir{
97cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::parameter::saveparameter"); }
98cdf0e10cSrcweir
99b274bc22SAndre Fischer    $installer::logger::Global->printf("Command line arguments:\n");
100cdf0e10cSrcweir
101b274bc22SAndre Fischer    my $index = 0;
102b274bc22SAndre Fischer	foreach my $argument (@ARGV)
103cdf0e10cSrcweir	{
104b274bc22SAndre Fischer        $installer::logger::Global->printf("    %2d: %s\n", $index++, $argument);
105cdf0e10cSrcweir	}
106cdf0e10cSrcweir
107cdf0e10cSrcweir	# also saving global settings:
108b274bc22SAndre Fischer    $installer::logger::Global->printf("Separator: %s\n", $installer::globals::separator);
109cdf0e10cSrcweir}
110cdf0e10cSrcweir
111cdf0e10cSrcweir#####################################
112cdf0e10cSrcweir# Reading parameter
113cdf0e10cSrcweir#####################################
114cdf0e10cSrcweir
115cdf0e10cSrcweirsub getparameter
116cdf0e10cSrcweir{
117cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::parameter::getparameter"); }
118cdf0e10cSrcweir
119cdf0e10cSrcweir	while ( $#ARGV >= 0 )
120cdf0e10cSrcweir	{
121cdf0e10cSrcweir		my $param = shift(@ARGV);
122cdf0e10cSrcweir
123cdf0e10cSrcweir		if ($param eq "-f") { $installer::globals::ziplistname = shift(@ARGV); }
124cdf0e10cSrcweir		elsif ($param eq "-s") { $installer::globals::setupscriptname = shift(@ARGV); }
125cdf0e10cSrcweir		elsif ($param eq "-p") { $installer::globals::product = shift(@ARGV); }
126cdf0e10cSrcweir		elsif ($param eq "-l") { $installer::globals::languagelist = shift(@ARGV); }
127cdf0e10cSrcweir		elsif ($param eq "-b") { $installer::globals::build = shift(@ARGV); }
128cdf0e10cSrcweir		elsif ($param eq "-m") { $installer::globals::minor = shift(@ARGV); }
129cdf0e10cSrcweir		elsif ($param eq "-dontunzip") { $installer::globals::dounzip = 0; }
130cdf0e10cSrcweir		elsif ($param eq "-c") { $installer::globals::compiler = shift(@ARGV); }
131cdf0e10cSrcweir		elsif ($param eq "-pro") { $installer::globals::pro = 1; }
132cdf0e10cSrcweir		elsif ($param eq "-format") { $installer::globals::packageformat = shift(@ARGV); }
133cdf0e10cSrcweir		elsif ($param eq "-log") { $installer::globals::globallogging = 1; }
134cdf0e10cSrcweir		elsif ($param eq "-quiet") { $installer::globals::quiet = 1; }
135cdf0e10cSrcweir		elsif ($param eq "-verbose") { $installer::globals::quiet = 0; }
136cdf0e10cSrcweir		elsif ($param eq "-debug") { $installer::globals::debug = 1; }
137cdf0e10cSrcweir		elsif ($param eq "-tab") { $installer::globals::tab = 1; }
138cdf0e10cSrcweir		elsif ($param eq "-u") { $installer::globals::unpackpath = shift(@ARGV); }
139cdf0e10cSrcweir		elsif ($param eq "-i") { $installer::globals::rootpath = shift(@ARGV); }
140cdf0e10cSrcweir		elsif ($param eq "-dontcallepm") { $installer::globals::call_epm = 0; }
141cdf0e10cSrcweir		elsif ($param eq "-msitemplate") { $installer::globals::idttemplatepath = shift(@ARGV); }
142cdf0e10cSrcweir		elsif ($param eq "-msilanguage") { $installer::globals::idtlanguagepath = shift(@ARGV); }
143cdf0e10cSrcweir		elsif ($param eq "-patchinc") { $installer::globals::patchincludepath = shift(@ARGV); }
144cdf0e10cSrcweir		elsif ($param eq "-javalanguage") { $installer::globals::javalanguagepath = shift(@ARGV); }
145cdf0e10cSrcweir		elsif ($param eq "-buildid") { $installer::globals::buildid = shift(@ARGV); }
146cdf0e10cSrcweir		elsif ($param eq "-copyproject") { $installer::globals::is_copy_only_project = 1; }
147cdf0e10cSrcweir		elsif ($param eq "-languagepack") { $installer::globals::languagepack = 1; }
148cdf0e10cSrcweir		elsif ($param eq "-patch") { $installer::globals::patch = 1; }
149cdf0e10cSrcweir		elsif ($param eq "-debian") { $installer::globals::debian = 1; }
150cdf0e10cSrcweir		elsif ($param eq "-dontstrip") { $installer::globals::strip = 0; }
151cdf0e10cSrcweir		elsif ($param eq "-destdir")	# new parameter for simple installer
152cdf0e10cSrcweir		{
153cdf0e10cSrcweir			$installer::globals::rootpath ne "" && die "must set destdir before -i or -simple";
154cdf0e10cSrcweir			$installer::globals::destdir = shift @ARGV;
155cdf0e10cSrcweir		}
156cdf0e10cSrcweir		elsif ($param eq "-simple")		# new parameter for simple installer
157cdf0e10cSrcweir		{
158cdf0e10cSrcweir			$installer::globals::simple = 1;
159cdf0e10cSrcweir			$installer::globals::call_epm = 0;
160cdf0e10cSrcweir			$installer::globals::makedownload = 0;
161cdf0e10cSrcweir			$installer::globals::makejds = 0;
162cdf0e10cSrcweir			$installer::globals::strip = 0;
163cdf0e10cSrcweir			my $path = shift(@ARGV);
164cdf0e10cSrcweir			$path =~ s/^\Q$installer::globals::destdir\E//;
165cdf0e10cSrcweir			$installer::globals::rootpath = $path;
166cdf0e10cSrcweir		}
1679f91b7e3SAndre Fischer		elsif ($param eq "-release")
1689f91b7e3SAndre Fischer        {
1699f91b7e3SAndre Fischer            $installer::globals::is_release = 1;
1709f91b7e3SAndre Fischer        }
171cdf0e10cSrcweir		else
172cdf0e10cSrcweir		{
173cdf0e10cSrcweir			installer::logger::print_error( "unknown parameter: $param" );
174cdf0e10cSrcweir			usage();
175cdf0e10cSrcweir			exit(-1);
176cdf0e10cSrcweir		}
177cdf0e10cSrcweir	}
1781ba1fd99SAndre Fischer
179cdf0e10cSrcweir	# Usage of simple installer (not for Windows):
180cdf0e10cSrcweir	# $PERL -w $SOLARENV/bin/make_installer.pl \
181cdf0e10cSrcweir	# -f openoffice.lst -l en-US -p OpenOffice \
182cdf0e10cSrcweir	# -buildid $BUILD -rpm \
183cdf0e10cSrcweir	# -destdir /tmp/nurk -simple $INSTALL_PATH
184cdf0e10cSrcweir}
185cdf0e10cSrcweir
186cdf0e10cSrcweir############################################
187cdf0e10cSrcweir# Controlling  the fundamental parameter
188cdf0e10cSrcweir# (required for every process)
189cdf0e10cSrcweir############################################
190cdf0e10cSrcweir
191cdf0e10cSrcweirsub control_fundamental_parameter
192cdf0e10cSrcweir{
193cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::parameter::control_fundamental_parameter"); }
194cdf0e10cSrcweir
195cdf0e10cSrcweir	if ($installer::globals::product eq "")
196cdf0e10cSrcweir	{
197cdf0e10cSrcweir		installer::logger::print_error( "Product name not set!" );
198cdf0e10cSrcweir		usage();
199cdf0e10cSrcweir		exit(-1);
200cdf0e10cSrcweir	}
201cdf0e10cSrcweir}
202cdf0e10cSrcweir
203cdf0e10cSrcweir##########################################################
204cdf0e10cSrcweir# The path parameters can be relative or absolute.
20586e1cf34SPedro Giffuni# This function creates absolute paths.
206cdf0e10cSrcweir##########################################################
207cdf0e10cSrcweir
208cdf0e10cSrcweirsub make_path_absolute
209cdf0e10cSrcweir{
210cdf0e10cSrcweir	my ($pathref) = @_;
211cdf0e10cSrcweir
212cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::parameter::make_path_absolute : $$pathref"); }
213cdf0e10cSrcweir
214cdf0e10cSrcweir	if ( $installer::globals::isunix )
215cdf0e10cSrcweir	{
216cdf0e10cSrcweir		if (!($$pathref =~ /^\s*\//))	# this is a relative unix path
217cdf0e10cSrcweir		{
218cdf0e10cSrcweir			$$pathref = cwd() . $installer::globals::separator . $$pathref;
219cdf0e10cSrcweir		}
220cdf0e10cSrcweir	}
221cdf0e10cSrcweir
222dfa12748SYuri Dario	if ( $installer::globals::iswin || $installer::globals::isos2 )
223cdf0e10cSrcweir	{
224cdf0e10cSrcweir		if ( $^O =~ /cygwin/i )
225cdf0e10cSrcweir		{
226cdf0e10cSrcweir			if ( $$pathref !~ /^\s*\// && $$pathref !~ /^\s*\w\:/ )	# not an absolute POSIX or DOS path
227cdf0e10cSrcweir			{
228cdf0e10cSrcweir				$$pathref = cwd() . $installer::globals::separator . $$pathref;
229cdf0e10cSrcweir			}
230cdf0e10cSrcweir			my $p = $$pathref;
231cdf0e10cSrcweir			chomp( $p );
232cdf0e10cSrcweir			my $q = '';
233cdf0e10cSrcweir			# Avoid the $(LANG) problem.
234cdf0e10cSrcweir			if ($p =~ /(\A.*)(\$\(.*\Z)/) {
235cdf0e10cSrcweir				$p = $1;
236cdf0e10cSrcweir				$q = $2;
237cdf0e10cSrcweir			}
238cdf0e10cSrcweir			$p =~ s/\\/\\\\/g;
239cdf0e10cSrcweir			chomp( $p = qx{cygpath -w "$p"} );
240cdf0e10cSrcweir			$$pathref = $p.$q;
241cdf0e10cSrcweir			# Use windows paths, but with '/'s.
242cdf0e10cSrcweir			$$pathref =~ s/\\/\//g;
243cdf0e10cSrcweir		}
244cdf0e10cSrcweir		else
245cdf0e10cSrcweir		{
246cdf0e10cSrcweir			if (!($$pathref =~ /^\s*\w\:/))	# this is a relative windows path (no dos drive)
247cdf0e10cSrcweir			{
248cdf0e10cSrcweir				$$pathref = cwd() . $installer::globals::separator . $$pathref;
249*2f5c2846SYuri Dario				if ( $installer::globals::isos2 )
250*2f5c2846SYuri Dario				{
251*2f5c2846SYuri Dario					$$pathref =~ s/\\/\//g;
252*2f5c2846SYuri Dario				}
253*2f5c2846SYuri Dario				else
254*2f5c2846SYuri Dario				{
255*2f5c2846SYuri Dario					$$pathref =~ s/\//\\/g;
256*2f5c2846SYuri Dario				}
257cdf0e10cSrcweir
258cdf0e10cSrcweir			}
259cdf0e10cSrcweir		}
260cdf0e10cSrcweir	}
261cdf0e10cSrcweir	$$pathref =~ s/[\/\\]\s*$//;	# removing ending slashes
262cdf0e10cSrcweir}
263cdf0e10cSrcweir
264cdf0e10cSrcweir##################################################
265cdf0e10cSrcweir# Setting some global parameters
266cdf0e10cSrcweir# This has to be expanded with furher platforms
267cdf0e10cSrcweir##################################################
268cdf0e10cSrcweir
269cdf0e10cSrcweirsub setglobalvariables
270cdf0e10cSrcweir{
271cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::parameter::setglobalvariables"); }
272cdf0e10cSrcweir
273cdf0e10cSrcweir	# Setting the installertype directory corresponding to the environment variable PKGFORMAT
274cdf0e10cSrcweir	# The global variable $installer::globals::packageformat can only contain one package format.
275cdf0e10cSrcweir	# If PKGFORMAT cotains more than one format (for example "rpm deb") this is splitted in the
276cdf0e10cSrcweir	# makefile calling the perl program.
277cdf0e10cSrcweir	$installer::globals::installertypedir = $installer::globals::packageformat;
278cdf0e10cSrcweir
279cdf0e10cSrcweir	if ( $installer::globals::compiler =~ /wnt(msc|gcc)i/ )
280cdf0e10cSrcweir	{
281cdf0e10cSrcweir		$installer::globals::iswindowsbuild = 1;
282cdf0e10cSrcweir	}
283cdf0e10cSrcweir
284cdf0e10cSrcweir	if ( $installer::globals::compiler =~ /unxso[lg][siux]/ )
285cdf0e10cSrcweir	{
286cdf0e10cSrcweir		$installer::globals::issolarisbuild = 1;
287cdf0e10cSrcweir		if ( $installer::globals::packageformat eq "pkg" )
288cdf0e10cSrcweir		{
289cdf0e10cSrcweir			$installer::globals::issolarispkgbuild = 1;
290cdf0e10cSrcweir			$installer::globals::epmoutpath = "packages";
291cdf0e10cSrcweir			$installer::globals::isxpdplatform = 1;
292cdf0e10cSrcweir		}
293cdf0e10cSrcweir	}
294cdf0e10cSrcweir
295f6ef1f1eSHerbert Dürr	if( $installer::globals::compiler =~ /unxmac/ )
296cdf0e10cSrcweir	{
297cdf0e10cSrcweir		$installer::globals::ismacbuild = 1;
298cdf0e10cSrcweir
299cdf0e10cSrcweir		if ( $installer::globals::packageformat eq "dmg" )
300cdf0e10cSrcweir		{
301cdf0e10cSrcweir			$installer::globals::ismacdmgbuild = 1;
302cdf0e10cSrcweir		}
303cdf0e10cSrcweir	}
304cdf0e10cSrcweir
305cdf0e10cSrcweir	if ( $installer::globals::compiler =~ /unxfbsd/ )
306cdf0e10cSrcweir	{
307cdf0e10cSrcweir		$installer::globals::isfreebsdbuild = 1;
308cdf0e10cSrcweir
309cdf0e10cSrcweir		if ( $installer::globals::packageformat eq "bsd" )
310cdf0e10cSrcweir		{
311cdf0e10cSrcweir			$installer::globals::epmoutpath = "freebsd";
312cdf0e10cSrcweir			$installer::globals::isfreebsdpkgbuild = 1;
313cdf0e10cSrcweir		}
314cdf0e10cSrcweir	}
315cdf0e10cSrcweir
316cdf0e10cSrcweir	if ( $installer::globals::compiler =~ /unxso[lg]s/ ) { $installer::globals::issolarissparcbuild = 1; }
317cdf0e10cSrcweir
318cdf0e10cSrcweir	if ( $installer::globals::compiler =~ /unxso[lg]i/ ) { $installer::globals::issolarisx86build = 1; }
319cdf0e10cSrcweir
320cdf0e10cSrcweir	if ($ENV{OS} eq 'LINUX')
321cdf0e10cSrcweir	{
322cdf0e10cSrcweir		$installer::globals::islinuxbuild = 1;
323cdf0e10cSrcweir		if ( $installer::globals::packageformat eq "rpm" )
324cdf0e10cSrcweir		{
325cdf0e10cSrcweir			$installer::globals::islinuxrpmbuild = 1;
326cdf0e10cSrcweir			$installer::globals::isxpdplatform = 1;
327cdf0e10cSrcweir			$installer::globals::epmoutpath = "RPMS";
328cdf0e10cSrcweir			if ( $installer::globals::compiler =~ /unxlngi/ )
329cdf0e10cSrcweir			{
330cdf0e10cSrcweir				$installer::globals::islinuxintelrpmbuild = 1;
331cdf0e10cSrcweir			}
332cdf0e10cSrcweir			if ( $installer::globals::compiler =~ /unxlngppc/ )
333cdf0e10cSrcweir			{
334cdf0e10cSrcweir				$installer::globals::islinuxppcrpmbuild = 1;
335cdf0e10cSrcweir			}
336cdf0e10cSrcweir			if ( $installer::globals::compiler =~ /unxlngx/ )
337cdf0e10cSrcweir			{
338cdf0e10cSrcweir				$installer::globals::islinuxx86_64rpmbuild = 1;
339cdf0e10cSrcweir			}
340cdf0e10cSrcweir
341cdf0e10cSrcweir			if ( $installer::globals::rpm eq "" ) { installer::exiter::exit_program("ERROR: Environment variable \"\$RPM\" has to be defined!", "setglobalvariables"); }
342cdf0e10cSrcweir		}
343cdf0e10cSrcweir
344cdf0e10cSrcweir		# Creating Debian packages ?
345cdf0e10cSrcweir		if (( $installer::globals::packageformat eq "deb" ) || ( $installer::globals::debian ))
346cdf0e10cSrcweir		{
347cdf0e10cSrcweir			$installer::globals::debian = 1;
348cdf0e10cSrcweir			$installer::globals::packageformat = "deb";
349cdf0e10cSrcweir			my $message = "Creating Debian packages";
350b274bc22SAndre Fischer			$installer::logger::Info->print($message);
351b274bc22SAndre Fischer			$installer::logger::Global->print($message);
352cdf0e10cSrcweir			$installer::globals::islinuxrpmbuild = 0;
353cdf0e10cSrcweir			$installer::globals::islinuxdebbuild = 1;
354cdf0e10cSrcweir			$installer::globals::epmoutpath = "DEBS";
355cdf0e10cSrcweir			if ( $installer::globals::compiler =~ /unxlngi/ )
356cdf0e10cSrcweir			{
357cdf0e10cSrcweir				$installer::globals::islinuxinteldebbuild = 1;
358cdf0e10cSrcweir			}
359cdf0e10cSrcweir			if ( $installer::globals::compiler =~ /unxlngppc/ )
360cdf0e10cSrcweir			{
361cdf0e10cSrcweir				$installer::globals::islinuxppcdebbuild = 1;
362cdf0e10cSrcweir			}
363cdf0e10cSrcweir			if ( $installer::globals::compiler =~ /unxlngx/ )
364cdf0e10cSrcweir			{
365cdf0e10cSrcweir				$installer::globals::islinuxx86_64debbuild = 1;
366cdf0e10cSrcweir			}
367cdf0e10cSrcweir		}
368cdf0e10cSrcweir	}
369cdf0e10cSrcweir
370cdf0e10cSrcweir	# Defaulting to native package format for epm
371cdf0e10cSrcweir
372cdf0e10cSrcweir	if ( ! $installer::globals::packageformat ) { $installer::globals::packageformat = "native"; }
373cdf0e10cSrcweir
374cdf0e10cSrcweir	# extension, if $installer::globals::pro is set
375cdf0e10cSrcweir	if ($installer::globals::pro) { $installer::globals::productextension = ".pro"; }
376cdf0e10cSrcweir
377cdf0e10cSrcweir	# no languages defined as parameter
378cdf0e10cSrcweir	if ($installer::globals::languagelist eq "") { $installer::globals::languages_defined_in_productlist = 1; }
379cdf0e10cSrcweir
380cdf0e10cSrcweir	# setting and creating the unpackpath
381cdf0e10cSrcweir
382cdf0e10cSrcweir	if ($installer::globals::unpackpath eq "")	# unpackpath not set
383cdf0e10cSrcweir	{
384cdf0e10cSrcweir		$installer::globals::unpackpath = cwd();
385cdf0e10cSrcweir		if ( $installer::globals::iswin ) { $installer::globals::unpackpath =~ s/\//\\/g; }
386*2f5c2846SYuri Dario		if ( $installer::globals::isos2 ) { $installer::globals::unpackpath =~ s/\\/\//g; }
387cdf0e10cSrcweir	}
388cdf0e10cSrcweir
389cdf0e10cSrcweir	if ( $installer::globals::localunpackdir ne "" ) { $installer::globals::unpackpath = $installer::globals::localunpackdir; }
390cdf0e10cSrcweir
391cdf0e10cSrcweir	if (!($installer::globals::unpackpath eq ""))
392cdf0e10cSrcweir	{
393cdf0e10cSrcweir		make_path_absolute(\$installer::globals::unpackpath);
394cdf0e10cSrcweir	}
395cdf0e10cSrcweir
396cdf0e10cSrcweir	$installer::globals::unpackpath =~ s/\Q$installer::globals::separator\E\s*$//;
397cdf0e10cSrcweir
398cdf0e10cSrcweir	if (! -d $installer::globals::unpackpath )	# create unpackpath
399cdf0e10cSrcweir	{
400cdf0e10cSrcweir		installer::systemactions::create_directory($installer::globals::unpackpath);
401cdf0e10cSrcweir	}
402cdf0e10cSrcweir
403cdf0e10cSrcweir	# setting jds exclude file list
404cdf0e10cSrcweir
405cdf0e10cSrcweir	if ( $installer::globals::islinuxrpmbuild )
406cdf0e10cSrcweir	{
407cdf0e10cSrcweir		$installer::globals::jdsexcludefilename = "jds_excludefiles_linux.txt";
408cdf0e10cSrcweir	}
409cdf0e10cSrcweir	if ( $installer::globals::issolarissparcbuild )
410cdf0e10cSrcweir	{
411cdf0e10cSrcweir		$installer::globals::jdsexcludefilename = "jds_excludefiles_solaris_sparc.txt";
412cdf0e10cSrcweir	}
413cdf0e10cSrcweir	if ( $installer::globals::issolarisx86build )
414cdf0e10cSrcweir	{
415cdf0e10cSrcweir		$installer::globals::jdsexcludefilename = "jds_excludefiles_solaris_intel.txt";
416cdf0e10cSrcweir	}
417cdf0e10cSrcweir
418cdf0e10cSrcweir	# setting and creating the temppath
419cdf0e10cSrcweir
420cdf0e10cSrcweir	if (( $ENV{'TMP'} ) || ( $ENV{'TEMP'} ) || ( $ENV{'TMPDIR'} ))
421cdf0e10cSrcweir	{
422cdf0e10cSrcweir		if ( $ENV{'TMP'} ) { $installer::globals::temppath = $ENV{'TMP'}; }
423cdf0e10cSrcweir		elsif ( $ENV{'TEMP'} )  { $installer::globals::temppath = $ENV{'TEMP'}; }
424cdf0e10cSrcweir		elsif ( $ENV{'TMPDIR'} )  { $installer::globals::temppath = $ENV{'TMPDIR'}; }
425cdf0e10cSrcweir		$installer::globals::temppath =~ s/\Q$installer::globals::separator\E\s*$//;	# removing ending slashes and backslashes
426cdf0e10cSrcweir		$installer::globals::temppath = $installer::globals::temppath . $installer::globals::separator . $installer::globals::globaltempdirname;
427cdf0e10cSrcweir		installer::systemactions::create_directory_with_privileges($installer::globals::temppath, "777");
428cdf0e10cSrcweir		my $dirsave = $installer::globals::temppath;
429cdf0e10cSrcweir
430cdf0e10cSrcweir		if ( $installer::globals::compiler =~ /^unxmac/ )
431cdf0e10cSrcweir		{
432cdf0e10cSrcweir			my $localcall = "chmod 777 $installer::globals::temppath \>\/dev\/null 2\>\&1";
433cdf0e10cSrcweir			system($localcall);
434cdf0e10cSrcweir		}
435cdf0e10cSrcweir
436cdf0e10cSrcweir		$installer::globals::temppath = $installer::globals::temppath . $installer::globals::separator . "i";
437cdf0e10cSrcweir		$installer::globals::temppath = installer::systemactions::create_pid_directory($installer::globals::temppath);
438cdf0e10cSrcweir		push(@installer::globals::removedirs, $installer::globals::temppath);
439cdf0e10cSrcweir
440cdf0e10cSrcweir		if ( ! -d $installer::globals::temppath ) { installer::exiter::exit_program("ERROR: Failed to create directory $installer::globals::temppath ! Possible reason: Wrong privileges in directory $dirsave .", "setglobalvariables"); }
441cdf0e10cSrcweir
442cdf0e10cSrcweir		$installer::globals::jdstemppath = $installer::globals::temppath;
443cdf0e10cSrcweir		$installer::globals::jdstemppath =~ s/i_/j_/;
444cdf0e10cSrcweir		push(@installer::globals::jdsremovedirs, $installer::globals::jdstemppath);
445cdf0e10cSrcweir		$installer::globals::temppath = $installer::globals::temppath . $installer::globals::separator . $installer::globals::compiler . $installer::globals::productextension;
446cdf0e10cSrcweir		installer::systemactions::create_directory($installer::globals::temppath);
447cdf0e10cSrcweir		if ( $^O =~ /cygwin/i )
448cdf0e10cSrcweir		{
449cdf0e10cSrcweir			$installer::globals::cyg_temppath = $installer::globals::temppath;
450cdf0e10cSrcweir			$installer::globals::cyg_temppath =~ s/\\/\\\\/g;
451cdf0e10cSrcweir			chomp( $installer::globals::cyg_temppath = qx{cygpath -w "$installer::globals::cyg_temppath"} );
452cdf0e10cSrcweir		}
453cdf0e10cSrcweir		$installer::globals::temppathdefined = 1;
454cdf0e10cSrcweir		$installer::globals::jdstemppathdefined = 1;
455cdf0e10cSrcweir	}
456cdf0e10cSrcweir	else
457cdf0e10cSrcweir	{
458cdf0e10cSrcweir		$installer::globals::temppathdefined = 0;
459cdf0e10cSrcweir		$installer::globals::jdstemppathdefined = 0;
460cdf0e10cSrcweir	}
461cdf0e10cSrcweir
462cdf0e10cSrcweir	# only one cab file, if Windows msp patches shall be prepared
463cdf0e10cSrcweir	if ( $installer::globals::prepare_winpatch ) { $installer::globals::number_of_cabfiles = 1; }
464cdf0e10cSrcweir
465cdf0e10cSrcweir}
466cdf0e10cSrcweir
467cdf0e10cSrcweir############################################
468cdf0e10cSrcweir# Controlling  the parameter that are
469cdf0e10cSrcweir# required for special processes
470cdf0e10cSrcweir############################################
471cdf0e10cSrcweir
472cdf0e10cSrcweirsub control_required_parameter
473cdf0e10cSrcweir{
474cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::parameter::control_required_parameter"); }
475cdf0e10cSrcweir
476cdf0e10cSrcweir	if (!($installer::globals::is_copy_only_project))
477cdf0e10cSrcweir	{
478cdf0e10cSrcweir		##############################################################################################
479cdf0e10cSrcweir		# idt template path. Only required for Windows build ($installer::globals::compiler =~ /wntmsci/)
480cdf0e10cSrcweir		# for the creation of the msi database.
481cdf0e10cSrcweir		##############################################################################################
482cdf0e10cSrcweir
483cdf0e10cSrcweir		if (($installer::globals::idttemplatepath eq "") && ($installer::globals::iswindowsbuild))
484cdf0e10cSrcweir		{
485cdf0e10cSrcweir			installer::logger::print_error( "idt template path not set (-msitemplate)!" );
486cdf0e10cSrcweir			usage();
487cdf0e10cSrcweir			exit(-1);
488cdf0e10cSrcweir		}
489cdf0e10cSrcweir
490cdf0e10cSrcweir		##############################################################################################
491cdf0e10cSrcweir		# idt language path. Only required for Windows build ($installer::globals::compiler =~ /wntmsci/)
492cdf0e10cSrcweir		# for the creation of the msi database.
493cdf0e10cSrcweir		##############################################################################################
494cdf0e10cSrcweir
495cdf0e10cSrcweir		if (($installer::globals::idtlanguagepath eq "") && ($installer::globals::iswindowsbuild))
496cdf0e10cSrcweir		{
497cdf0e10cSrcweir			installer::logger::print_error( "idt language path not set (-msilanguage)!" );
498cdf0e10cSrcweir			usage();
499cdf0e10cSrcweir			exit(-1);
500cdf0e10cSrcweir		}
501cdf0e10cSrcweir
502cdf0e10cSrcweir		# Analyzing the idt template path
503cdf0e10cSrcweir
504cdf0e10cSrcweir		if (!($installer::globals::idttemplatepath eq ""))	# idttemplatepath set, relative or absolute?
505cdf0e10cSrcweir		{
506cdf0e10cSrcweir			make_path_absolute(\$installer::globals::idttemplatepath);
507cdf0e10cSrcweir		}
508cdf0e10cSrcweir
509cdf0e10cSrcweir		installer::remover::remove_ending_pathseparator(\$installer::globals::idttemplatepath);
510cdf0e10cSrcweir
511cdf0e10cSrcweir		# Analyzing the idt language path
512cdf0e10cSrcweir
513cdf0e10cSrcweir		if (!($installer::globals::idtlanguagepath eq ""))	# idtlanguagepath set, relative or absolute?
514cdf0e10cSrcweir		{
515cdf0e10cSrcweir			make_path_absolute(\$installer::globals::idtlanguagepath);
516cdf0e10cSrcweir		}
517cdf0e10cSrcweir
518cdf0e10cSrcweir		installer::remover::remove_ending_pathseparator(\$installer::globals::idtlanguagepath);
519cdf0e10cSrcweir
520cdf0e10cSrcweir		# In the msi template directory a files "codes.txt" has to exist, in which the ProductCode
521cdf0e10cSrcweir		# and the UpgradeCode for the product are defined.
522cdf0e10cSrcweir		# The name "codes.txt" can be overwritten in Product definition with CODEFILENAME (msiglobal.pm)
523cdf0e10cSrcweir
524cdf0e10cSrcweir		if (( $installer::globals::iswindowsbuild ) && ( $installer::globals::packageformat ne "archive" ) && ( $installer::globals::packageformat ne "installed" ))
525cdf0e10cSrcweir		{
526cdf0e10cSrcweir			$installer::globals::codefilename = $installer::globals::idttemplatepath  . $installer::globals::separator . $installer::globals::codefilename;
527cdf0e10cSrcweir			installer::files::check_file($installer::globals::codefilename);
528cdf0e10cSrcweir			$installer::globals::componentfilename = $installer::globals::idttemplatepath  . $installer::globals::separator . $installer::globals::componentfilename;
529cdf0e10cSrcweir			installer::files::check_file($installer::globals::componentfilename);
530cdf0e10cSrcweir		}
531cdf0e10cSrcweir
532cdf0e10cSrcweir	}
533cdf0e10cSrcweir
534cdf0e10cSrcweir	#######################################
535cdf0e10cSrcweir	# Patch currently only available
536cdf0e10cSrcweir	# for Solaris packages and Linux
537cdf0e10cSrcweir	#######################################
538cdf0e10cSrcweir
539cdf0e10cSrcweir	if (( $installer::globals::patch ) && ( ! $installer::globals::issolarispkgbuild ) && ( ! $installer::globals::islinuxrpmbuild ) && ( ! $installer::globals::islinuxdebbuild ) && ( ! $installer::globals::iswindowsbuild ) && ( ! $installer::globals::ismacdmgbuild ))
540cdf0e10cSrcweir	{
541cdf0e10cSrcweir		installer::logger::print_error( "Sorry, Patch flag currently only available for Solaris pkg, Linux RPM and Windows builds!" );
542cdf0e10cSrcweir		usage();
543cdf0e10cSrcweir		exit(-1);
544cdf0e10cSrcweir	}
545cdf0e10cSrcweir
546cdf0e10cSrcweir	if (( $installer::globals::patch ) && ( $installer::globals::issolarispkgbuild ) && ( ! $installer::globals::patchincludepath ))
547cdf0e10cSrcweir	{
548cdf0e10cSrcweir		installer::logger::print_error( "Solaris patch requires parameter -patchinc !" );
549cdf0e10cSrcweir		usage();
550cdf0e10cSrcweir		exit(-1);
551cdf0e10cSrcweir	}
552cdf0e10cSrcweir
553cdf0e10cSrcweir	if (( $installer::globals::patch ) && ( $installer::globals::issolarispkgbuild ) && ( $installer::globals::patchincludepath ))
554cdf0e10cSrcweir	{
555cdf0e10cSrcweir		make_path_absolute(\$installer::globals::patchincludepath);
556cdf0e10cSrcweir		$installer::globals::patchincludepath = installer::converter::make_path_conform($installer::globals::patchincludepath);
557cdf0e10cSrcweir	}
558cdf0e10cSrcweir
559cdf0e10cSrcweir	#######################################
560cdf0e10cSrcweir	# Testing existence of files
561cdf0e10cSrcweir	# also for copy-only projects
562cdf0e10cSrcweir	#######################################
563cdf0e10cSrcweir
564cdf0e10cSrcweir	if ($installer::globals::ziplistname eq "")
565cdf0e10cSrcweir	{
566cdf0e10cSrcweir		installer::logger::print_error( "ERROR: Zip list file has to be defined (Parameter -f) !" );
567cdf0e10cSrcweir		usage();
568cdf0e10cSrcweir		exit(-1);
569cdf0e10cSrcweir	}
570cdf0e10cSrcweir	else
571cdf0e10cSrcweir	{
572cdf0e10cSrcweir		installer::files::check_file($installer::globals::ziplistname);
573cdf0e10cSrcweir	}
574cdf0e10cSrcweir
575cdf0e10cSrcweir	if ($installer::globals::setupscriptname eq "")	{ $installer::globals::setupscript_defined_in_productlist = 1; }
576cdf0e10cSrcweir	else { installer::files::check_file($installer::globals::setupscriptname); } # if the setupscript file is defined, it has to exist
577cdf0e10cSrcweir
578cdf0e10cSrcweir}
579cdf0e10cSrcweir
580cdf0e10cSrcweir################################################
581cdf0e10cSrcweir# Writing parameter to shell and into logfile
582cdf0e10cSrcweir################################################
583cdf0e10cSrcweir
584b274bc22SAndre Fischersub outputparameter ()
585cdf0e10cSrcweir{
586cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::parameter::outputparameter"); }
587cdf0e10cSrcweir
588cdf0e10cSrcweir	my @output = ();
589cdf0e10cSrcweir
590b274bc22SAndre Fischer	push(@output, "\n");
591b274bc22SAndre Fischer	push(@output, "########################################################\n");
592cdf0e10cSrcweir	push(@output, "$installer::globals::prog, version 1.0\n");
593cdf0e10cSrcweir	push(@output, "Product list file: $installer::globals::ziplistname\n");
594cdf0e10cSrcweir	if (!($installer::globals::setupscript_defined_in_productlist))
595cdf0e10cSrcweir	{
596cdf0e10cSrcweir		push(@output, "Setup script: $installer::globals::setupscriptname\n");
597cdf0e10cSrcweir	}
598cdf0e10cSrcweir	else
599cdf0e10cSrcweir	{
600cdf0e10cSrcweir		push(@output, "Taking setup script from solver\n");
601cdf0e10cSrcweir	}
602cdf0e10cSrcweir	push(@output, "Unpackpath: $installer::globals::unpackpath\n");
603cdf0e10cSrcweir	push(@output, "Compiler: $installer::globals::compiler\n");
604cdf0e10cSrcweir	push(@output, "Product: $installer::globals::product\n");
605cdf0e10cSrcweir	push(@output, "BuildID: $installer::globals::buildid\n");
606cdf0e10cSrcweir	push(@output, "Build: $installer::globals::build\n");
607cdf0e10cSrcweir	if ( $installer::globals::minor ) { push(@output, "Minor: $installer::globals::minor\n"); }
608cdf0e10cSrcweir	else  { push(@output, "No minor set\n"); }
609cdf0e10cSrcweir	if ( $installer::globals::pro ) { push(@output, "Product version\n"); }
610cdf0e10cSrcweir	else  { push(@output, "Non-Product version\n"); }
611cdf0e10cSrcweir	if ( $installer::globals::rootpath eq "" ) { push(@output, "Using default installpath\n"); }
612cdf0e10cSrcweir	else { push(@output, "Installpath: $installer::globals::rootpath\n"); }
613cdf0e10cSrcweir	push(@output, "Package format: $installer::globals::packageformat\n");
614cdf0e10cSrcweir	if (!($installer::globals::idttemplatepath eq ""))	{ push(@output, "msi templatepath: $installer::globals::idttemplatepath\n"); }
615cdf0e10cSrcweir	if ((!($installer::globals::idttemplatepath eq "")) && (!($installer::globals::iswindowsbuild))) { push(@output, "msi template path will be ignored for non Windows builds!\n"); }
616cdf0e10cSrcweir	if (!($installer::globals::idtlanguagepath eq ""))	{ push(@output, "msi languagepath: $installer::globals::idtlanguagepath\n"); }
617cdf0e10cSrcweir	if ((!($installer::globals::idtlanguagepath eq "")) && (!($installer::globals::iswindowsbuild))) { push(@output, "msi language path will be ignored for non Windows builds!\n"); }
618cdf0e10cSrcweir	if ((!($installer::globals::iswindowsbuild)) && ( $installer::globals::call_epm )) { push(@output, "Calling epm\n"); }
619cdf0e10cSrcweir	if ((!($installer::globals::iswindowsbuild)) && (!($installer::globals::call_epm))) { push(@output, "Not calling epm\n"); }
620cdf0e10cSrcweir	if (!($installer::globals::javalanguagepath eq "")) { push(@output, "Java language path: $installer::globals::javalanguagepath\n"); }
621cdf0e10cSrcweir	if ((!($installer::globals::javalanguagepath eq "")) && ($installer::globals::iswindowsbuild)) { push(@output, "Java language path will be ignored for Windows builds!\n"); }
622cdf0e10cSrcweir	if ( $installer::globals::patchincludepath ) { push(@output, "Patch include path: $installer::globals::patchincludepath\n"); }
623cdf0e10cSrcweir	if ( $installer::globals::globallogging ) { push(@output, "Complete logging activated\n"); }
624cdf0e10cSrcweir	if ( $installer::globals::debug ) { push(@output, "Debug is activated\n"); }
625cdf0e10cSrcweir	if ( $installer::globals::tab ) { push(@output, "TAB version\n"); }
626cdf0e10cSrcweir	if ( $installer::globals::strip ) { push(@output, "Stripping files\n"); }
627cdf0e10cSrcweir	else { push(@output, "No file stripping\n"); }
628cdf0e10cSrcweir	if ( $installer::globals::debian ) { push(@output, "Linux: Creating Debian packages\n"); }
629cdf0e10cSrcweir	if ( $installer::globals::dounzip ) { push(@output, "Unzip ARCHIVE files\n"); }
630cdf0e10cSrcweir	else  { push(@output, "Not unzipping ARCHIVE files\n"); }
631cdf0e10cSrcweir	if (!($installer::globals::languages_defined_in_productlist))
632cdf0e10cSrcweir	{
63301a01bd6SAndre Fischer		push(@output, sprintf("Languages: %s\n", $installer::globals::languageproduct));
634cdf0e10cSrcweir	}
635cdf0e10cSrcweir	else
636cdf0e10cSrcweir	{
637cdf0e10cSrcweir		push(@output, "Languages defined in $installer::globals::ziplistname\n");
638cdf0e10cSrcweir	}
639cdf0e10cSrcweir	if ( $installer::globals::is_copy_only_project ) { push(@output, "This is a copy only project!\n"); }
640cdf0e10cSrcweir	if ( $installer::globals::languagepack ) { push(@output, "Creating language pack!\n"); }
641cdf0e10cSrcweir	if ( $installer::globals::patch ) { push(@output, "Creating patch!\n"); }
642cdf0e10cSrcweir	push(@output, "########################################################\n");
643cdf0e10cSrcweir
644cdf0e10cSrcweir	# output into shell and into logfile
645cdf0e10cSrcweir
646b274bc22SAndre Fischer	foreach my $line (@output)
647cdf0e10cSrcweir	{
648b274bc22SAndre Fischer	    $installer::logger::Info->print($line);
649cdf0e10cSrcweir	}
650cdf0e10cSrcweir}
651cdf0e10cSrcweir
652cdf0e10cSrcweir1;
653