xref: /AOO41X/main/solenv/bin/modules/installer/parameter.pm (revision dfa12748791311fae2099f1ef2495cb571eaedf3)
19780544fSAndrew Rist#**************************************************************
2cdf0e10cSrcweir#
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
10cdf0e10cSrcweir#
119780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir#
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.
19cdf0e10cSrcweir#
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;
33cdf0e10cSrcweir
34cdf0e10cSrcweir############################################
35cdf0e10cSrcweir# Parameter Operations
36cdf0e10cSrcweir############################################
37cdf0e10cSrcweir
38cdf0e10cSrcweirsub usage
39cdf0e10cSrcweir{
40cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::parameter::usage"); }
41cdf0e10cSrcweir
42cdf0e10cSrcweir	print <<Ende;
43cdf0e10cSrcweir--------------------------------------------------------------------------------
44cdf0e10cSrcweir$installer::globals::prog
45cdf0e10cSrcweirThe following parameter are needed:
46cdf0e10cSrcweir-f: Path to the product list (required)
47cdf0e10cSrcweir-s: Path to the setup script (optional, if defined in product list)
48cdf0e10cSrcweir-i: Install path of the product (/opt/openofficeorg20) (optional)
49cdf0e10cSrcweir-p: Product from product list to be created (required)
50cdf0e10cSrcweir-l: Language of the product (comma and hash) (optional, defined in productlist)
51cdf0e10cSrcweir-b: Build, e.g. srx645 (optional)
52cdf0e10cSrcweir-m: Minor, e.g. m10 (optional)
53cdf0e10cSrcweir-simple: Path to do a simple install to
54cdf0e10cSrcweir-c: Compiler, e.g. wntmsci8, unxlngi5, unxsols4, ... (optional)
55cdf0e10cSrcweir-u: Path, in which zipfiles are unpacked (optional)
56cdf0e10cSrcweir-msitemplate: Source of the msi file templates (Windows compiler only)
57cdf0e10cSrcweir-msilanguage: Source of the msi file templates (Windows compiler only)
58cdf0e10cSrcweir-javalanguage: Source of the Java language files (opt., non-Windows only)
59cdf0e10cSrcweir-buildid: Current BuildID (optional)
60cdf0e10cSrcweir-pro: Product version
61cdf0e10cSrcweir-format: Package format
62cdf0e10cSrcweir-debian: Create Debian packages for Linux
63cdf0e10cSrcweir-dontunzip: do not unzip all files with flag ARCHIVE
64cdf0e10cSrcweir-dontcallepm : do not call epm to create install sets (opt., non-Windows only)
65cdf0e10cSrcweir-ispatchedepm : Usage of a patched (non-standard) epm (opt., non-Windows only)
66cdf0e10cSrcweir-copyproject : is set for projects that are only used for copying (optional)
67cdf0e10cSrcweir-languagepack : do create a languagepack, no product pack (optional)
68cdf0e10cSrcweir-patch : do create a patch (optional)
69cdf0e10cSrcweir-patchinc: Source for the patch include files (Solaris only)
70cdf0e10cSrcweir-dontstrip: No file stripping (Unix only)
71cdf0e10cSrcweir-log : Logging all available information (optional)
72cdf0e10cSrcweir-debug : Collecting debug information
73cdf0e10cSrcweir
74cdf0e10cSrcweirExamples for Windows:
75cdf0e10cSrcweir
76cdf0e10cSrcweirperl make_epmlist.pl -f zip.lst -p OfficeFAT -l en-US
77cdf0e10cSrcweir                     -u /export/unpack -buildid 8712
78cdf0e10cSrcweir                     -msitemplate /export/msi_files
79cdf0e10cSrcweir                     -msilanguage /export/msi_languages
80cdf0e10cSrcweir
81cdf0e10cSrcweirExamples for Non-Windows:
82cdf0e10cSrcweir
83cdf0e10cSrcweirperl make_epmlist.pl -f zip.lst -p OfficeFAT -l en-US -format rpm
84cdf0e10cSrcweir                     -u /export/unpack -buildid 8712 -ispatchedepm
85cdf0e10cSrcweir--------------------------------------------------------------------------------
86cdf0e10cSrcweirEnde
87cdf0e10cSrcweir	exit(-1);
88cdf0e10cSrcweir}
89cdf0e10cSrcweir
90cdf0e10cSrcweir#########################################
91cdf0e10cSrcweir# Writing all parameter into logfile
92cdf0e10cSrcweir#########################################
93cdf0e10cSrcweir
94cdf0e10cSrcweirsub saveparameter
95cdf0e10cSrcweir{
96cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::parameter::saveparameter"); }
97cdf0e10cSrcweir
98cdf0e10cSrcweir	my $include = "";
99cdf0e10cSrcweir
100cdf0e10cSrcweir	installer::logger::globallog("Command line arguments:");
101cdf0e10cSrcweir
102cdf0e10cSrcweir	for ( my $i = 0; $i <= $#ARGV; $i++ )
103cdf0e10cSrcweir	{
104cdf0e10cSrcweir		$include = $ARGV[$i] . "\n";
105cdf0e10cSrcweir		push(@installer::globals::globallogfileinfo, $include);
106cdf0e10cSrcweir	}
107cdf0e10cSrcweir
108cdf0e10cSrcweir	# also saving global settings:
109cdf0e10cSrcweir
110cdf0e10cSrcweir	$include = "Separator: $installer::globals::separator\n";
111cdf0e10cSrcweir	push(@installer::globals::globallogfileinfo, $include);
112cdf0e10cSrcweir
113cdf0e10cSrcweir}
114cdf0e10cSrcweir
115cdf0e10cSrcweir#####################################
116cdf0e10cSrcweir# Reading parameter
117cdf0e10cSrcweir#####################################
118cdf0e10cSrcweir
119cdf0e10cSrcweirsub getparameter
120cdf0e10cSrcweir{
121cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::parameter::getparameter"); }
122cdf0e10cSrcweir
123cdf0e10cSrcweir	while ( $#ARGV >= 0 )
124cdf0e10cSrcweir	{
125cdf0e10cSrcweir		my $param = shift(@ARGV);
126cdf0e10cSrcweir
127cdf0e10cSrcweir		if ($param eq "-f") { $installer::globals::ziplistname = shift(@ARGV); }
128cdf0e10cSrcweir		elsif ($param eq "-s") { $installer::globals::setupscriptname = shift(@ARGV); }
129cdf0e10cSrcweir		elsif ($param eq "-p") { $installer::globals::product = shift(@ARGV); }
130cdf0e10cSrcweir		elsif ($param eq "-l") { $installer::globals::languagelist = shift(@ARGV); }
131cdf0e10cSrcweir		elsif ($param eq "-b") { $installer::globals::build = shift(@ARGV); }
132cdf0e10cSrcweir		elsif ($param eq "-m") { $installer::globals::minor = shift(@ARGV); }
133cdf0e10cSrcweir		elsif ($param eq "-dontunzip") { $installer::globals::dounzip = 0; }
134cdf0e10cSrcweir		elsif ($param eq "-c") { $installer::globals::compiler = shift(@ARGV); }
135cdf0e10cSrcweir		elsif ($param eq "-pro") { $installer::globals::pro = 1; }
136cdf0e10cSrcweir		elsif ($param eq "-format") { $installer::globals::packageformat = shift(@ARGV); }
137cdf0e10cSrcweir		elsif ($param eq "-log") { $installer::globals::globallogging = 1; }
138cdf0e10cSrcweir		elsif ($param eq "-quiet") { $installer::globals::quiet = 1; }
139cdf0e10cSrcweir		elsif ($param eq "-verbose") { $installer::globals::quiet = 0; }
140cdf0e10cSrcweir		elsif ($param eq "-debug") { $installer::globals::debug = 1; }
141cdf0e10cSrcweir		elsif ($param eq "-tab") { $installer::globals::tab = 1; }
142cdf0e10cSrcweir		elsif ($param eq "-u") { $installer::globals::unpackpath = shift(@ARGV); }
143cdf0e10cSrcweir		elsif ($param eq "-i") { $installer::globals::rootpath = shift(@ARGV); }
144cdf0e10cSrcweir		elsif ($param eq "-dontcallepm") { $installer::globals::call_epm = 0; }
145cdf0e10cSrcweir		elsif ($param eq "-msitemplate") { $installer::globals::idttemplatepath = shift(@ARGV); }
146cdf0e10cSrcweir		elsif ($param eq "-msilanguage") { $installer::globals::idtlanguagepath = shift(@ARGV); }
147cdf0e10cSrcweir		elsif ($param eq "-patchinc") { $installer::globals::patchincludepath = shift(@ARGV); }
148cdf0e10cSrcweir		elsif ($param eq "-javalanguage") { $installer::globals::javalanguagepath = shift(@ARGV); }
149cdf0e10cSrcweir		elsif ($param eq "-buildid") { $installer::globals::buildid = shift(@ARGV); }
150cdf0e10cSrcweir		elsif ($param eq "-copyproject") { $installer::globals::is_copy_only_project = 1; }
151cdf0e10cSrcweir		elsif ($param eq "-languagepack") { $installer::globals::languagepack = 1; }
152cdf0e10cSrcweir		elsif ($param eq "-patch") { $installer::globals::patch = 1; }
153cdf0e10cSrcweir		elsif ($param eq "-debian") { $installer::globals::debian = 1; }
154cdf0e10cSrcweir		elsif ($param eq "-dontstrip") { $installer::globals::strip = 0; }
155cdf0e10cSrcweir		elsif ($param eq "-destdir")	# new parameter for simple installer
156cdf0e10cSrcweir		{
157cdf0e10cSrcweir			$installer::globals::rootpath ne "" && die "must set destdir before -i or -simple";
158cdf0e10cSrcweir			$installer::globals::destdir = shift @ARGV;
159cdf0e10cSrcweir		}
160cdf0e10cSrcweir		elsif ($param eq "-simple")		# new parameter for simple installer
161cdf0e10cSrcweir		{
162cdf0e10cSrcweir			$installer::globals::simple = 1;
163cdf0e10cSrcweir			$installer::globals::call_epm = 0;
164cdf0e10cSrcweir			$installer::globals::makedownload = 0;
165cdf0e10cSrcweir			$installer::globals::makejds = 0;
166cdf0e10cSrcweir			$installer::globals::strip = 0;
167cdf0e10cSrcweir			my $path = shift(@ARGV);
168cdf0e10cSrcweir			$path =~ s/^\Q$installer::globals::destdir\E//;
169cdf0e10cSrcweir			$installer::globals::rootpath = $path;
170cdf0e10cSrcweir		}
171cdf0e10cSrcweir		else
172cdf0e10cSrcweir		{
173cdf0e10cSrcweir			installer::logger::print_error( "unknown parameter: $param" );
174cdf0e10cSrcweir			usage();
175cdf0e10cSrcweir			exit(-1);
176cdf0e10cSrcweir		}
177cdf0e10cSrcweir	}
178cdf0e10cSrcweir
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.
205cdf0e10cSrcweir# This function creates absolute pathes.
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
222*dfa12748SYuri 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;
249cdf0e10cSrcweir
250cdf0e10cSrcweir				$$pathref =~ s/\//\\/g;
251cdf0e10cSrcweir			}
252cdf0e10cSrcweir		}
253cdf0e10cSrcweir	}
254cdf0e10cSrcweir	$$pathref =~ s/[\/\\]\s*$//;	# removing ending slashes
255cdf0e10cSrcweir}
256cdf0e10cSrcweir
257cdf0e10cSrcweir##################################################
258cdf0e10cSrcweir# Setting some global parameters
259cdf0e10cSrcweir# This has to be expanded with furher platforms
260cdf0e10cSrcweir##################################################
261cdf0e10cSrcweir
262cdf0e10cSrcweirsub setglobalvariables
263cdf0e10cSrcweir{
264cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::parameter::setglobalvariables"); }
265cdf0e10cSrcweir
266cdf0e10cSrcweir	# Setting the installertype directory corresponding to the environment variable PKGFORMAT
267cdf0e10cSrcweir	# The global variable $installer::globals::packageformat can only contain one package format.
268cdf0e10cSrcweir	# If PKGFORMAT cotains more than one format (for example "rpm deb") this is splitted in the
269cdf0e10cSrcweir	# makefile calling the perl program.
270cdf0e10cSrcweir	$installer::globals::installertypedir = $installer::globals::packageformat;
271cdf0e10cSrcweir
272cdf0e10cSrcweir	if ( $installer::globals::compiler =~ /wnt(msc|gcc)i/ )
273cdf0e10cSrcweir	{
274cdf0e10cSrcweir		$installer::globals::iswindowsbuild = 1;
275cdf0e10cSrcweir	}
276cdf0e10cSrcweir
277cdf0e10cSrcweir	if ( $installer::globals::compiler =~ /unxso[lg][siux]/ )
278cdf0e10cSrcweir	{
279cdf0e10cSrcweir		$installer::globals::issolarisbuild = 1;
280cdf0e10cSrcweir		if ( $installer::globals::packageformat eq "pkg" )
281cdf0e10cSrcweir		{
282cdf0e10cSrcweir			$installer::globals::issolarispkgbuild = 1;
283cdf0e10cSrcweir			$installer::globals::epmoutpath = "packages";
284cdf0e10cSrcweir			$installer::globals::isxpdplatform = 1;
285cdf0e10cSrcweir		}
286cdf0e10cSrcweir	}
287cdf0e10cSrcweir
288cdf0e10cSrcweir	if (( $installer::globals::compiler =~ /unxmacxi/ ) || ( $installer::globals::compiler =~ /unxmacxp/ ))
289cdf0e10cSrcweir	{
290cdf0e10cSrcweir		$installer::globals::ismacbuild = 1;
291cdf0e10cSrcweir
292cdf0e10cSrcweir		if ( $installer::globals::packageformat eq "dmg" )
293cdf0e10cSrcweir		{
294cdf0e10cSrcweir			$installer::globals::ismacdmgbuild = 1;
295cdf0e10cSrcweir		}
296cdf0e10cSrcweir	}
297cdf0e10cSrcweir
298cdf0e10cSrcweir	if ( $installer::globals::compiler =~ /unxfbsd/ )
299cdf0e10cSrcweir	{
300cdf0e10cSrcweir		$installer::globals::isfreebsdbuild = 1;
301cdf0e10cSrcweir
302cdf0e10cSrcweir		if ( $installer::globals::packageformat eq "bsd" )
303cdf0e10cSrcweir		{
304cdf0e10cSrcweir			$installer::globals::epmoutpath = "freebsd";
305cdf0e10cSrcweir			$installer::globals::isfreebsdpkgbuild = 1;
306cdf0e10cSrcweir		}
307cdf0e10cSrcweir	}
308cdf0e10cSrcweir
309cdf0e10cSrcweir	if ( $installer::globals::compiler =~ /unxso[lg]s/ ) { $installer::globals::issolarissparcbuild = 1; }
310cdf0e10cSrcweir
311cdf0e10cSrcweir	if ( $installer::globals::compiler =~ /unxso[lg]i/ ) { $installer::globals::issolarisx86build = 1; }
312cdf0e10cSrcweir
313cdf0e10cSrcweir	if ($ENV{OS} eq 'LINUX')
314cdf0e10cSrcweir	{
315cdf0e10cSrcweir		$installer::globals::islinuxbuild = 1;
316cdf0e10cSrcweir		if ( $installer::globals::packageformat eq "rpm" )
317cdf0e10cSrcweir		{
318cdf0e10cSrcweir			$installer::globals::islinuxrpmbuild = 1;
319cdf0e10cSrcweir			$installer::globals::isxpdplatform = 1;
320cdf0e10cSrcweir			$installer::globals::epmoutpath = "RPMS";
321cdf0e10cSrcweir			if ( $installer::globals::compiler =~ /unxlngi/ )
322cdf0e10cSrcweir			{
323cdf0e10cSrcweir				$installer::globals::islinuxintelrpmbuild = 1;
324cdf0e10cSrcweir			}
325cdf0e10cSrcweir			if ( $installer::globals::compiler =~ /unxlngppc/ )
326cdf0e10cSrcweir			{
327cdf0e10cSrcweir				$installer::globals::islinuxppcrpmbuild = 1;
328cdf0e10cSrcweir			}
329cdf0e10cSrcweir			if ( $installer::globals::compiler =~ /unxlngx/ )
330cdf0e10cSrcweir			{
331cdf0e10cSrcweir				$installer::globals::islinuxx86_64rpmbuild = 1;
332cdf0e10cSrcweir			}
333cdf0e10cSrcweir
334cdf0e10cSrcweir			if ( $installer::globals::rpm eq "" ) { installer::exiter::exit_program("ERROR: Environment variable \"\$RPM\" has to be defined!", "setglobalvariables"); }
335cdf0e10cSrcweir		}
336cdf0e10cSrcweir
337cdf0e10cSrcweir		# Creating Debian packages ?
338cdf0e10cSrcweir		if (( $installer::globals::packageformat eq "deb" ) || ( $installer::globals::debian ))
339cdf0e10cSrcweir		{
340cdf0e10cSrcweir			$installer::globals::debian = 1;
341cdf0e10cSrcweir			$installer::globals::packageformat = "deb";
342cdf0e10cSrcweir			my $message = "Creating Debian packages";
343cdf0e10cSrcweir			installer::logger::print_message( $message );
344cdf0e10cSrcweir			push(@installer::globals::globallogfileinfo, $message);
345cdf0e10cSrcweir			$installer::globals::islinuxrpmbuild = 0;
346cdf0e10cSrcweir			$installer::globals::islinuxdebbuild = 1;
347cdf0e10cSrcweir			$installer::globals::epmoutpath = "DEBS";
348cdf0e10cSrcweir			if ( $installer::globals::compiler =~ /unxlngi/ )
349cdf0e10cSrcweir			{
350cdf0e10cSrcweir				$installer::globals::islinuxinteldebbuild = 1;
351cdf0e10cSrcweir			}
352cdf0e10cSrcweir			if ( $installer::globals::compiler =~ /unxlngppc/ )
353cdf0e10cSrcweir			{
354cdf0e10cSrcweir				$installer::globals::islinuxppcdebbuild = 1;
355cdf0e10cSrcweir			}
356cdf0e10cSrcweir			if ( $installer::globals::compiler =~ /unxlngx/ )
357cdf0e10cSrcweir			{
358cdf0e10cSrcweir				$installer::globals::islinuxx86_64debbuild = 1;
359cdf0e10cSrcweir			}
360cdf0e10cSrcweir		}
361cdf0e10cSrcweir	}
362cdf0e10cSrcweir
363cdf0e10cSrcweir	# Defaulting to native package format for epm
364cdf0e10cSrcweir
365cdf0e10cSrcweir	if ( ! $installer::globals::packageformat ) { $installer::globals::packageformat = "native"; }
366cdf0e10cSrcweir
367cdf0e10cSrcweir	# extension, if $installer::globals::pro is set
368cdf0e10cSrcweir	if ($installer::globals::pro) { $installer::globals::productextension = ".pro"; }
369cdf0e10cSrcweir
370cdf0e10cSrcweir	# no languages defined as parameter
371cdf0e10cSrcweir	if ($installer::globals::languagelist eq "") { $installer::globals::languages_defined_in_productlist = 1; }
372cdf0e10cSrcweir
373cdf0e10cSrcweir	# setting and creating the unpackpath
374cdf0e10cSrcweir
375cdf0e10cSrcweir	if ($installer::globals::unpackpath eq "")	# unpackpath not set
376cdf0e10cSrcweir	{
377cdf0e10cSrcweir		$installer::globals::unpackpath = cwd();
378cdf0e10cSrcweir		if ( $installer::globals::iswin ) { $installer::globals::unpackpath =~ s/\//\\/g; }
379cdf0e10cSrcweir	}
380cdf0e10cSrcweir
381cdf0e10cSrcweir	if ( $installer::globals::localunpackdir ne "" ) { $installer::globals::unpackpath = $installer::globals::localunpackdir; }
382cdf0e10cSrcweir
383cdf0e10cSrcweir	if (!($installer::globals::unpackpath eq ""))
384cdf0e10cSrcweir	{
385cdf0e10cSrcweir		make_path_absolute(\$installer::globals::unpackpath);
386cdf0e10cSrcweir	}
387cdf0e10cSrcweir
388cdf0e10cSrcweir	$installer::globals::unpackpath =~ s/\Q$installer::globals::separator\E\s*$//;
389cdf0e10cSrcweir
390cdf0e10cSrcweir	if (! -d $installer::globals::unpackpath )	# create unpackpath
391cdf0e10cSrcweir	{
392cdf0e10cSrcweir		installer::systemactions::create_directory($installer::globals::unpackpath);
393cdf0e10cSrcweir	}
394cdf0e10cSrcweir
395cdf0e10cSrcweir	# setting jds exclude file list
396cdf0e10cSrcweir
397cdf0e10cSrcweir	if ( $installer::globals::islinuxrpmbuild )
398cdf0e10cSrcweir	{
399cdf0e10cSrcweir		$installer::globals::jdsexcludefilename = "jds_excludefiles_linux.txt";
400cdf0e10cSrcweir	}
401cdf0e10cSrcweir	if ( $installer::globals::issolarissparcbuild )
402cdf0e10cSrcweir	{
403cdf0e10cSrcweir		$installer::globals::jdsexcludefilename = "jds_excludefiles_solaris_sparc.txt";
404cdf0e10cSrcweir	}
405cdf0e10cSrcweir	if ( $installer::globals::issolarisx86build )
406cdf0e10cSrcweir	{
407cdf0e10cSrcweir		$installer::globals::jdsexcludefilename = "jds_excludefiles_solaris_intel.txt";
408cdf0e10cSrcweir	}
409cdf0e10cSrcweir
410cdf0e10cSrcweir	# setting and creating the temppath
411cdf0e10cSrcweir
412cdf0e10cSrcweir	if (( $ENV{'TMP'} ) || ( $ENV{'TEMP'} ) || ( $ENV{'TMPDIR'} ))
413cdf0e10cSrcweir	{
414cdf0e10cSrcweir		if ( $ENV{'TMP'} ) { $installer::globals::temppath = $ENV{'TMP'}; }
415cdf0e10cSrcweir		elsif ( $ENV{'TEMP'} )  { $installer::globals::temppath = $ENV{'TEMP'}; }
416cdf0e10cSrcweir		elsif ( $ENV{'TMPDIR'} )  { $installer::globals::temppath = $ENV{'TMPDIR'}; }
417cdf0e10cSrcweir		$installer::globals::temppath =~ s/\Q$installer::globals::separator\E\s*$//;	# removing ending slashes and backslashes
418cdf0e10cSrcweir		$installer::globals::temppath = $installer::globals::temppath . $installer::globals::separator . $installer::globals::globaltempdirname;
419cdf0e10cSrcweir		installer::systemactions::create_directory_with_privileges($installer::globals::temppath, "777");
420cdf0e10cSrcweir		my $dirsave = $installer::globals::temppath;
421cdf0e10cSrcweir
422cdf0e10cSrcweir		if ( $installer::globals::compiler =~ /^unxmac/ )
423cdf0e10cSrcweir		{
424cdf0e10cSrcweir			my $localcall = "chmod 777 $installer::globals::temppath \>\/dev\/null 2\>\&1";
425cdf0e10cSrcweir			system($localcall);
426cdf0e10cSrcweir		}
427cdf0e10cSrcweir
428cdf0e10cSrcweir		$installer::globals::temppath = $installer::globals::temppath . $installer::globals::separator . "i";
429cdf0e10cSrcweir		$installer::globals::temppath = installer::systemactions::create_pid_directory($installer::globals::temppath);
430cdf0e10cSrcweir		push(@installer::globals::removedirs, $installer::globals::temppath);
431cdf0e10cSrcweir
432cdf0e10cSrcweir		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"); }
433cdf0e10cSrcweir
434cdf0e10cSrcweir		$installer::globals::jdstemppath = $installer::globals::temppath;
435cdf0e10cSrcweir		$installer::globals::jdstemppath =~ s/i_/j_/;
436cdf0e10cSrcweir		push(@installer::globals::jdsremovedirs, $installer::globals::jdstemppath);
437cdf0e10cSrcweir		$installer::globals::temppath = $installer::globals::temppath . $installer::globals::separator . $installer::globals::compiler . $installer::globals::productextension;
438cdf0e10cSrcweir		installer::systemactions::create_directory($installer::globals::temppath);
439cdf0e10cSrcweir		if ( $^O =~ /cygwin/i )
440cdf0e10cSrcweir		{
441cdf0e10cSrcweir			$installer::globals::cyg_temppath = $installer::globals::temppath;
442cdf0e10cSrcweir			$installer::globals::cyg_temppath =~ s/\\/\\\\/g;
443cdf0e10cSrcweir			chomp( $installer::globals::cyg_temppath = qx{cygpath -w "$installer::globals::cyg_temppath"} );
444cdf0e10cSrcweir		}
445cdf0e10cSrcweir		$installer::globals::temppathdefined = 1;
446cdf0e10cSrcweir		$installer::globals::jdstemppathdefined = 1;
447cdf0e10cSrcweir	}
448cdf0e10cSrcweir	else
449cdf0e10cSrcweir	{
450cdf0e10cSrcweir		$installer::globals::temppathdefined = 0;
451cdf0e10cSrcweir		$installer::globals::jdstemppathdefined = 0;
452cdf0e10cSrcweir	}
453cdf0e10cSrcweir
454cdf0e10cSrcweir	# only one cab file, if Windows msp patches shall be prepared
455cdf0e10cSrcweir	if ( $installer::globals::prepare_winpatch ) { $installer::globals::number_of_cabfiles = 1; }
456cdf0e10cSrcweir
457cdf0e10cSrcweir}
458cdf0e10cSrcweir
459cdf0e10cSrcweir############################################
460cdf0e10cSrcweir# Controlling  the parameter that are
461cdf0e10cSrcweir# required for special processes
462cdf0e10cSrcweir############################################
463cdf0e10cSrcweir
464cdf0e10cSrcweirsub control_required_parameter
465cdf0e10cSrcweir{
466cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::parameter::control_required_parameter"); }
467cdf0e10cSrcweir
468cdf0e10cSrcweir	if (!($installer::globals::is_copy_only_project))
469cdf0e10cSrcweir	{
470cdf0e10cSrcweir		##############################################################################################
471cdf0e10cSrcweir		# idt template path. Only required for Windows build ($installer::globals::compiler =~ /wntmsci/)
472cdf0e10cSrcweir		# for the creation of the msi database.
473cdf0e10cSrcweir		##############################################################################################
474cdf0e10cSrcweir
475cdf0e10cSrcweir		if (($installer::globals::idttemplatepath eq "") && ($installer::globals::iswindowsbuild))
476cdf0e10cSrcweir		{
477cdf0e10cSrcweir			installer::logger::print_error( "idt template path not set (-msitemplate)!" );
478cdf0e10cSrcweir			usage();
479cdf0e10cSrcweir			exit(-1);
480cdf0e10cSrcweir		}
481cdf0e10cSrcweir
482cdf0e10cSrcweir		##############################################################################################
483cdf0e10cSrcweir		# idt language path. Only required for Windows build ($installer::globals::compiler =~ /wntmsci/)
484cdf0e10cSrcweir		# for the creation of the msi database.
485cdf0e10cSrcweir		##############################################################################################
486cdf0e10cSrcweir
487cdf0e10cSrcweir		if (($installer::globals::idtlanguagepath eq "") && ($installer::globals::iswindowsbuild))
488cdf0e10cSrcweir		{
489cdf0e10cSrcweir			installer::logger::print_error( "idt language path not set (-msilanguage)!" );
490cdf0e10cSrcweir			usage();
491cdf0e10cSrcweir			exit(-1);
492cdf0e10cSrcweir		}
493cdf0e10cSrcweir
494cdf0e10cSrcweir		# Analyzing the idt template path
495cdf0e10cSrcweir
496cdf0e10cSrcweir		if (!($installer::globals::idttemplatepath eq ""))	# idttemplatepath set, relative or absolute?
497cdf0e10cSrcweir		{
498cdf0e10cSrcweir			make_path_absolute(\$installer::globals::idttemplatepath);
499cdf0e10cSrcweir		}
500cdf0e10cSrcweir
501cdf0e10cSrcweir		installer::remover::remove_ending_pathseparator(\$installer::globals::idttemplatepath);
502cdf0e10cSrcweir
503cdf0e10cSrcweir		# Analyzing the idt language path
504cdf0e10cSrcweir
505cdf0e10cSrcweir		if (!($installer::globals::idtlanguagepath eq ""))	# idtlanguagepath set, relative or absolute?
506cdf0e10cSrcweir		{
507cdf0e10cSrcweir			make_path_absolute(\$installer::globals::idtlanguagepath);
508cdf0e10cSrcweir		}
509cdf0e10cSrcweir
510cdf0e10cSrcweir		installer::remover::remove_ending_pathseparator(\$installer::globals::idtlanguagepath);
511cdf0e10cSrcweir
512cdf0e10cSrcweir		# In the msi template directory a files "codes.txt" has to exist, in which the ProductCode
513cdf0e10cSrcweir		# and the UpgradeCode for the product are defined.
514cdf0e10cSrcweir		# The name "codes.txt" can be overwritten in Product definition with CODEFILENAME (msiglobal.pm)
515cdf0e10cSrcweir
516cdf0e10cSrcweir		if (( $installer::globals::iswindowsbuild ) && ( $installer::globals::packageformat ne "archive" ) && ( $installer::globals::packageformat ne "installed" ))
517cdf0e10cSrcweir		{
518cdf0e10cSrcweir			$installer::globals::codefilename = $installer::globals::idttemplatepath  . $installer::globals::separator . $installer::globals::codefilename;
519cdf0e10cSrcweir			installer::files::check_file($installer::globals::codefilename);
520cdf0e10cSrcweir			$installer::globals::componentfilename = $installer::globals::idttemplatepath  . $installer::globals::separator . $installer::globals::componentfilename;
521cdf0e10cSrcweir			installer::files::check_file($installer::globals::componentfilename);
522cdf0e10cSrcweir		}
523cdf0e10cSrcweir
524cdf0e10cSrcweir	}
525cdf0e10cSrcweir
526cdf0e10cSrcweir	#######################################
527cdf0e10cSrcweir	# Patch currently only available
528cdf0e10cSrcweir	# for Solaris packages and Linux
529cdf0e10cSrcweir	#######################################
530cdf0e10cSrcweir
531cdf0e10cSrcweir	if (( $installer::globals::patch ) && ( ! $installer::globals::issolarispkgbuild ) && ( ! $installer::globals::islinuxrpmbuild ) && ( ! $installer::globals::islinuxdebbuild ) && ( ! $installer::globals::iswindowsbuild ) && ( ! $installer::globals::ismacdmgbuild ))
532cdf0e10cSrcweir	{
533cdf0e10cSrcweir		installer::logger::print_error( "Sorry, Patch flag currently only available for Solaris pkg, Linux RPM and Windows builds!" );
534cdf0e10cSrcweir		usage();
535cdf0e10cSrcweir		exit(-1);
536cdf0e10cSrcweir	}
537cdf0e10cSrcweir
538cdf0e10cSrcweir	if (( $installer::globals::patch ) && ( $installer::globals::issolarispkgbuild ) && ( ! $installer::globals::patchincludepath ))
539cdf0e10cSrcweir	{
540cdf0e10cSrcweir		installer::logger::print_error( "Solaris patch requires parameter -patchinc !" );
541cdf0e10cSrcweir		usage();
542cdf0e10cSrcweir		exit(-1);
543cdf0e10cSrcweir	}
544cdf0e10cSrcweir
545cdf0e10cSrcweir	if (( $installer::globals::patch ) && ( $installer::globals::issolarispkgbuild ) && ( $installer::globals::patchincludepath ))
546cdf0e10cSrcweir	{
547cdf0e10cSrcweir		make_path_absolute(\$installer::globals::patchincludepath);
548cdf0e10cSrcweir		$installer::globals::patchincludepath = installer::converter::make_path_conform($installer::globals::patchincludepath);
549cdf0e10cSrcweir	}
550cdf0e10cSrcweir
551cdf0e10cSrcweir	#######################################
552cdf0e10cSrcweir	# Testing existence of files
553cdf0e10cSrcweir	# also for copy-only projects
554cdf0e10cSrcweir	#######################################
555cdf0e10cSrcweir
556cdf0e10cSrcweir	if ($installer::globals::ziplistname eq "")
557cdf0e10cSrcweir	{
558cdf0e10cSrcweir		installer::logger::print_error( "ERROR: Zip list file has to be defined (Parameter -f) !" );
559cdf0e10cSrcweir		usage();
560cdf0e10cSrcweir		exit(-1);
561cdf0e10cSrcweir	}
562cdf0e10cSrcweir	else
563cdf0e10cSrcweir	{
564cdf0e10cSrcweir		installer::files::check_file($installer::globals::ziplistname);
565cdf0e10cSrcweir	}
566cdf0e10cSrcweir
567cdf0e10cSrcweir	if ($installer::globals::setupscriptname eq "")	{ $installer::globals::setupscript_defined_in_productlist = 1; }
568cdf0e10cSrcweir	else { installer::files::check_file($installer::globals::setupscriptname); } # if the setupscript file is defined, it has to exist
569cdf0e10cSrcweir
570cdf0e10cSrcweir}
571cdf0e10cSrcweir
572cdf0e10cSrcweir################################################
573cdf0e10cSrcweir# Writing parameter to shell and into logfile
574cdf0e10cSrcweir################################################
575cdf0e10cSrcweir
576cdf0e10cSrcweirsub outputparameter
577cdf0e10cSrcweir{
578cdf0e10cSrcweir	if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::parameter::outputparameter"); }
579cdf0e10cSrcweir
580cdf0e10cSrcweir	my $element;
581cdf0e10cSrcweir
582cdf0e10cSrcweir	my @output = ();
583cdf0e10cSrcweir
584cdf0e10cSrcweir	push(@output, "\n########################################################\n");
585cdf0e10cSrcweir	push(@output, "$installer::globals::prog, version 1.0\n");
586cdf0e10cSrcweir	push(@output, "Product list file: $installer::globals::ziplistname\n");
587cdf0e10cSrcweir	if (!($installer::globals::setupscript_defined_in_productlist))
588cdf0e10cSrcweir	{
589cdf0e10cSrcweir		push(@output, "Setup script: $installer::globals::setupscriptname\n");
590cdf0e10cSrcweir	}
591cdf0e10cSrcweir	else
592cdf0e10cSrcweir	{
593cdf0e10cSrcweir		push(@output, "Taking setup script from solver\n");
594cdf0e10cSrcweir	}
595cdf0e10cSrcweir	push(@output, "Unpackpath: $installer::globals::unpackpath\n");
596cdf0e10cSrcweir	push(@output, "Compiler: $installer::globals::compiler\n");
597cdf0e10cSrcweir	push(@output, "Product: $installer::globals::product\n");
598cdf0e10cSrcweir	push(@output, "BuildID: $installer::globals::buildid\n");
599cdf0e10cSrcweir	push(@output, "Build: $installer::globals::build\n");
600cdf0e10cSrcweir	if ( $installer::globals::minor ) { push(@output, "Minor: $installer::globals::minor\n"); }
601cdf0e10cSrcweir	else  { push(@output, "No minor set\n"); }
602cdf0e10cSrcweir	if ( $installer::globals::pro ) { push(@output, "Product version\n"); }
603cdf0e10cSrcweir	else  { push(@output, "Non-Product version\n"); }
604cdf0e10cSrcweir	if ( $installer::globals::rootpath eq "" ) { push(@output, "Using default installpath\n"); }
605cdf0e10cSrcweir	else { push(@output, "Installpath: $installer::globals::rootpath\n"); }
606cdf0e10cSrcweir	push(@output, "Package format: $installer::globals::packageformat\n");
607cdf0e10cSrcweir	if (!($installer::globals::idttemplatepath eq ""))	{ push(@output, "msi templatepath: $installer::globals::idttemplatepath\n"); }
608cdf0e10cSrcweir	if ((!($installer::globals::idttemplatepath eq "")) && (!($installer::globals::iswindowsbuild))) { push(@output, "msi template path will be ignored for non Windows builds!\n"); }
609cdf0e10cSrcweir	if (!($installer::globals::idtlanguagepath eq ""))	{ push(@output, "msi languagepath: $installer::globals::idtlanguagepath\n"); }
610cdf0e10cSrcweir	if ((!($installer::globals::idtlanguagepath eq "")) && (!($installer::globals::iswindowsbuild))) { push(@output, "msi language path will be ignored for non Windows builds!\n"); }
611cdf0e10cSrcweir	if ((!($installer::globals::iswindowsbuild)) && ( $installer::globals::call_epm )) { push(@output, "Calling epm\n"); }
612cdf0e10cSrcweir	if ((!($installer::globals::iswindowsbuild)) && (!($installer::globals::call_epm))) { push(@output, "Not calling epm\n"); }
613cdf0e10cSrcweir	if (!($installer::globals::javalanguagepath eq "")) { push(@output, "Java language path: $installer::globals::javalanguagepath\n"); }
614cdf0e10cSrcweir	if ((!($installer::globals::javalanguagepath eq "")) && ($installer::globals::iswindowsbuild)) { push(@output, "Java language path will be ignored for Windows builds!\n"); }
615cdf0e10cSrcweir	if ( $installer::globals::patchincludepath ) { push(@output, "Patch include path: $installer::globals::patchincludepath\n"); }
616cdf0e10cSrcweir	if ( $installer::globals::globallogging ) { push(@output, "Complete logging activated\n"); }
617cdf0e10cSrcweir	if ( $installer::globals::debug ) { push(@output, "Debug is activated\n"); }
618cdf0e10cSrcweir	if ( $installer::globals::tab ) { push(@output, "TAB version\n"); }
619cdf0e10cSrcweir	if ( $installer::globals::strip ) { push(@output, "Stripping files\n"); }
620cdf0e10cSrcweir	else { push(@output, "No file stripping\n"); }
621cdf0e10cSrcweir	if ( $installer::globals::debian ) { push(@output, "Linux: Creating Debian packages\n"); }
622cdf0e10cSrcweir	if ( $installer::globals::dounzip ) { push(@output, "Unzip ARCHIVE files\n"); }
623cdf0e10cSrcweir	else  { push(@output, "Not unzipping ARCHIVE files\n"); }
624cdf0e10cSrcweir	if (!($installer::globals::languages_defined_in_productlist))
625cdf0e10cSrcweir	{
626cdf0e10cSrcweir		push(@output, "Languages:\n");
627cdf0e10cSrcweir		foreach $element (@installer::globals::languageproducts) { push(@output, "\t$element\n"); }
628cdf0e10cSrcweir	}
629cdf0e10cSrcweir	else
630cdf0e10cSrcweir	{
631cdf0e10cSrcweir		push(@output, "Languages defined in $installer::globals::ziplistname\n");
632cdf0e10cSrcweir	}
633cdf0e10cSrcweir	if ( $installer::globals::is_copy_only_project ) { push(@output, "This is a copy only project!\n"); }
634cdf0e10cSrcweir	if ( $installer::globals::languagepack ) { push(@output, "Creating language pack!\n"); }
635cdf0e10cSrcweir	if ( $installer::globals::patch ) { push(@output, "Creating patch!\n"); }
636cdf0e10cSrcweir	push(@output, "########################################################\n");
637cdf0e10cSrcweir
638cdf0e10cSrcweir	# output into shell and into logfile
639cdf0e10cSrcweir
640cdf0e10cSrcweir	for ( my $i = 0; $i <= $#output; $i++ )
641cdf0e10cSrcweir	{
642cdf0e10cSrcweir		installer::logger::print_message( $output[$i] );
643cdf0e10cSrcweir		push(@installer::globals::globallogfileinfo, $output[$i]);
644cdf0e10cSrcweir	}
645cdf0e10cSrcweir}
646cdf0e10cSrcweir
647cdf0e10cSrcweir1;
648