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