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