1*9780544fSAndrew Rist#**************************************************************
2*9780544fSAndrew Rist#
3*9780544fSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
4*9780544fSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
5*9780544fSAndrew Rist#  distributed with this work for additional information
6*9780544fSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
7*9780544fSAndrew Rist#  to you under the Apache License, Version 2.0 (the
8*9780544fSAndrew Rist#  "License"); you may not use this file except in compliance
9*9780544fSAndrew Rist#  with the License.  You may obtain a copy of the License at
10*9780544fSAndrew Rist#
11*9780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
12*9780544fSAndrew Rist#
13*9780544fSAndrew Rist#  Unless required by applicable law or agreed to in writing,
14*9780544fSAndrew Rist#  software distributed under the License is distributed on an
15*9780544fSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9780544fSAndrew Rist#  KIND, either express or implied.  See the License for the
17*9780544fSAndrew Rist#  specific language governing permissions and limitations
18*9780544fSAndrew Rist#  under the License.
19*9780544fSAndrew Rist#
20*9780544fSAndrew Rist#**************************************************************
21*9780544fSAndrew Rist
22*9780544fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweirpackage installer::environment;
25cdf0e10cSrcweir
26cdf0e10cSrcweiruse installer::exiter;
27cdf0e10cSrcweiruse installer::globals;
28cdf0e10cSrcweir
29cdf0e10cSrcweir######################################################
30cdf0e10cSrcweir# Create path variables from environment variables
31cdf0e10cSrcweir######################################################
32cdf0e10cSrcweir
33cdf0e10cSrcweirsub create_pathvariables
34cdf0e10cSrcweir{
35cdf0e10cSrcweir	my ($environment) = @_;
36cdf0e10cSrcweir
37cdf0e10cSrcweir	my %variables = ();
38cdf0e10cSrcweir
39cdf0e10cSrcweir	# The following variables are needed in the path file list
40cdf0e10cSrcweir	# solarpath, solarenvpath, solarcommonpath, os, osdef, pmiscpath
41cdf0e10cSrcweir
42cdf0e10cSrcweir	my $solarpath = $environment->{'SOLARVERSION'} . $installer::globals::separator . $installer::globals::compiler . $installer::globals::productextension;
43cdf0e10cSrcweir	$variables{'solarpath'} = $solarpath;
44cdf0e10cSrcweir
45cdf0e10cSrcweir	my $solarcommonpath = $environment->{'SOLARVERSION'} . $installer::globals::separator . "common" . $installer::globals::productextension;
46cdf0e10cSrcweir	# my $solarcommonpath = $environment->{'SOLARVERSION'} . $installer::globals::separator . $environment->{'COMMON_OUTDIR'} . $installer::globals::productextension;
47cdf0e10cSrcweir	$variables{'solarcommonpath'} = $solarcommonpath;
48cdf0e10cSrcweir
49cdf0e10cSrcweir	my $osdef = lc($environment->{'GUI'});
50cdf0e10cSrcweir	$variables{'osdef'} = $osdef;
51cdf0e10cSrcweir
52cdf0e10cSrcweir	$variables{'os'} = $installer::globals::compiler;
53cdf0e10cSrcweir
54cdf0e10cSrcweir	my $solarenvpath = "";
55cdf0e10cSrcweir
56cdf0e10cSrcweir	if ( $ENV{'SO_PACK'} ) { $solarenvpath  = $ENV{'SO_PACK'}; }
57cdf0e10cSrcweir	# overriding with STAR_INSTPATH, if set
58cdf0e10cSrcweir	if ( $ENV{'STAR_INSTPATH'} ) { $solarenvpath = $ENV{'STAR_INSTPATH'}; }
59cdf0e10cSrcweir
60cdf0e10cSrcweir	$variables{'solarenvpath'} = $solarenvpath;
61cdf0e10cSrcweir
62cdf0e10cSrcweir	my $localpath  = $environment->{'LOCAL_OUT'};
63cdf0e10cSrcweir	$variables{'localpath'} = $localpath;
64cdf0e10cSrcweir
65cdf0e10cSrcweir	my $localcommonpath  = $environment->{'LOCAL_COMMON_OUT'};
66cdf0e10cSrcweir	$variables{'localcommonpath'} = $localcommonpath;
67cdf0e10cSrcweir
68cdf0e10cSrcweir	my $platformname  = $environment->{'OUTPATH'};
69cdf0e10cSrcweir	$variables{'platformname'} = $platformname;
70cdf0e10cSrcweir
71cdf0e10cSrcweir	return \%variables;
72cdf0e10cSrcweir}
73cdf0e10cSrcweir
74cdf0e10cSrcweir##################################################
75cdf0e10cSrcweir# Replacing tilde in pathes, because of
76cdf0e10cSrcweir# problem with deep recursion (task 104830)
77cdf0e10cSrcweir##################################################
78cdf0e10cSrcweir
79cdf0e10cSrcweirsub check_tilde_in_directory
80cdf0e10cSrcweir{
81cdf0e10cSrcweir	if ( $ENV{'HOME'} )
82cdf0e10cSrcweir	{
83cdf0e10cSrcweir		my $home = $ENV{'HOME'};
84cdf0e10cSrcweir		$home =~ s/\Q$installer::globals::separator\E\s*$//;
85cdf0e10cSrcweir		$installer::globals::localinstalldir =~ s/~/$home/;
86cdf0e10cSrcweir		my $infoline = "Info: Changing LOCALINSTALLDIR to $installer::globals::localinstalldir\n";
87cdf0e10cSrcweir		push(@installer::globals::logfileinfo, $infoline);
88cdf0e10cSrcweir	}
89cdf0e10cSrcweir	else
90cdf0e10cSrcweir	{
91cdf0e10cSrcweir		# exit, because "~" is not allowed, if HOME is not set
92cdf0e10cSrcweir		my $infoline = "ERROR: If \"~\" is used in \"LOCALINSTALLDIR\", environment variable \"HOME\" needs to be defined!\n";
93cdf0e10cSrcweir		push(@installer::globals::logfileinfo, $infoline);
94cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: If \"~\" is used in \"LOCALINSTALLDIR\", environment variable \"HOME\" needs to be defined!", "check_tilde_in_directory");
95cdf0e10cSrcweir	}
96cdf0e10cSrcweir}
97cdf0e10cSrcweir
98cdf0e10cSrcweir##################################################
99cdf0e10cSrcweir# Setting some fundamental global variables.
100cdf0e10cSrcweir# All these variables can be overwritten
101cdf0e10cSrcweir# by parameters.
102cdf0e10cSrcweir##################################################
103cdf0e10cSrcweir
104cdf0e10cSrcweirsub set_global_environment_variables
105cdf0e10cSrcweir{
106cdf0e10cSrcweir	my ( $environment ) = @_;
107cdf0e10cSrcweir
108cdf0e10cSrcweir	$installer::globals::build = $environment->{'WORK_STAMP'};
109cdf0e10cSrcweir	# $installer::globals::minor = $environment->{'UPDMINOR'};
110cdf0e10cSrcweir	$installer::globals::compiler = $environment->{'OUTPATH'};
111cdf0e10cSrcweir
112cdf0e10cSrcweir	if ( $ENV{'UPDMINOR'} ) { $installer::globals::minor = $ENV{'UPDMINOR'}; }
113cdf0e10cSrcweir	if ( $ENV{'LAST_MINOR'} ) { $installer::globals::lastminor = $ENV{'LAST_MINOR'}; }
114cdf0e10cSrcweir
115cdf0e10cSrcweir	if ( $ENV{'PROEXT'} ) { $installer::globals::pro = 1; }
116cdf0e10cSrcweir
117cdf0e10cSrcweir	if ( $ENV{'VERBOSE'} && ( (lc $ENV{'VERBOSE'}) eq "false" ) ) { $installer::globals::quiet = 1; }
118cdf0e10cSrcweir	if ( $ENV{'PREPARE_WINPATCH'} ) { $installer::globals::prepare_winpatch = 1; }
119cdf0e10cSrcweir	if ( $ENV{'PREVIOUS_IDT_DIR'} ) { $installer::globals::previous_idt_dir = $ENV{'PREVIOUS_IDT_DIR'}; }
120cdf0e10cSrcweir	if ( $ENV{'LOCALINSTALLDIR'} ) { $installer::globals::localinstalldir = $ENV{'LOCALINSTALLDIR'}; }
121cdf0e10cSrcweir	if ( $ENV{'LOCALUNPACKDIR'} ) { $installer::globals::localunpackdir = $ENV{'LOCALUNPACKDIR'}; }
122cdf0e10cSrcweir	if ( $ENV{'MAX_LANG_LENGTH'} ) { $installer::globals::max_lang_length = $ENV{'MAX_LANG_LENGTH'}; }
123cdf0e10cSrcweir
124cdf0e10cSrcweir	if ( $ENV{'SOLAR_JAVA'} ) { $installer::globals::solarjavaset = 1; }
125cdf0e10cSrcweir	if ( $ENV{'RPM'} ) { $installer::globals::rpm = $ENV{'RPM'}; }
126cdf0e10cSrcweir	if ( $ENV{'DONTCOMPRESS'} ) { $installer::globals::solarisdontcompress = 1; }
127cdf0e10cSrcweir	if ( $ENV{'IGNORE_ERROR_IN_LOGFILE'} ) { $installer::globals::ignore_error_in_logfile = 1; }
128cdf0e10cSrcweir	if (( $ENV{'DISABLE_STRIP'} ) && ( $ENV{'DISABLE_STRIP'} ne '' )) { $installer::globals::strip = 0; }
129cdf0e10cSrcweir
130cdf0e10cSrcweir	if ( $installer::globals::localinstalldir ) { $installer::globals::localinstalldirset = 1; }
131cdf0e10cSrcweir	# Special handling, if LOCALINSTALLDIR contains "~" in the path
132cdf0e10cSrcweir	if ( $installer::globals::localinstalldir =~ /^\s*\~/ ) { check_tilde_in_directory(); }
133cdf0e10cSrcweir}
134cdf0e10cSrcweir
135cdf0e10cSrcweir1;
136