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 my $infoline = "Info: Changing LOCALINSTALLDIR to $installer::globals::localinstalldir\n"; 87 push(@installer::globals::logfileinfo, $infoline); 88 } 89 else 90 { 91 # exit, because "~" is not allowed, if HOME is not set 92 my $infoline = "ERROR: If \"~\" is used in \"LOCALINSTALLDIR\", environment variable \"HOME\" needs to be defined!\n"; 93 push(@installer::globals::logfileinfo, $infoline); 94 installer::exiter::exit_program("ERROR: If \"~\" is used in \"LOCALINSTALLDIR\", environment variable \"HOME\" needs to be defined!", "check_tilde_in_directory"); 95 } 96} 97 98################################################## 99# Setting some fundamental global variables. 100# All these variables can be overwritten 101# by parameters. 102################################################## 103 104sub set_global_environment_variables 105{ 106 my ( $environment ) = @_; 107 108 $installer::globals::build = $environment->{'WORK_STAMP'}; 109 # $installer::globals::minor = $environment->{'UPDMINOR'}; 110 $installer::globals::compiler = $environment->{'OUTPATH'}; 111 112 if ( $ENV{'UPDMINOR'} ) { $installer::globals::minor = $ENV{'UPDMINOR'}; } 113 if ( $ENV{'LAST_MINOR'} ) { $installer::globals::lastminor = $ENV{'LAST_MINOR'}; } 114 115 if ( $ENV{'PROEXT'} ) { $installer::globals::pro = 1; } 116 117 if ( $ENV{'VERBOSE'} && ( (lc $ENV{'VERBOSE'}) eq "false" ) ) { $installer::globals::quiet = 1; } 118 if ( $ENV{'PREPARE_WINPATCH'} ) { $installer::globals::prepare_winpatch = 1; } 119 if ( $ENV{'PREVIOUS_IDT_DIR'} ) { $installer::globals::previous_idt_dir = $ENV{'PREVIOUS_IDT_DIR'}; } 120 if ( $ENV{'LOCALINSTALLDIR'} ) { $installer::globals::localinstalldir = $ENV{'LOCALINSTALLDIR'}; } 121 if ( $ENV{'LOCALUNPACKDIR'} ) { $installer::globals::localunpackdir = $ENV{'LOCALUNPACKDIR'}; } 122 if ( $ENV{'MAX_LANG_LENGTH'} ) { $installer::globals::max_lang_length = $ENV{'MAX_LANG_LENGTH'}; } 123 124 if ( $ENV{'SOLAR_JAVA'} ) { $installer::globals::solarjavaset = 1; } 125 if ( $ENV{'RPM'} ) { $installer::globals::rpm = $ENV{'RPM'}; } 126 if ( $ENV{'DONTCOMPRESS'} ) { $installer::globals::solarisdontcompress = 1; } 127 if ( $ENV{'IGNORE_ERROR_IN_LOGFILE'} ) { $installer::globals::ignore_error_in_logfile = 1; } 128 if (( $ENV{'DISABLE_STRIP'} ) && ( $ENV{'DISABLE_STRIP'} ne '' )) { $installer::globals::strip = 0; } 129 130 if ( $installer::globals::localinstalldir ) { $installer::globals::localinstalldirset = 1; } 131 # Special handling, if LOCALINSTALLDIR contains "~" in the path 132 if ( $installer::globals::localinstalldir =~ /^\s*\~/ ) { check_tilde_in_directory(); } 133} 134 1351; 136