1*cdf0e10cSrcweir#*************************************************************************
2*cdf0e10cSrcweir#
3*cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir#
5*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir#
7*cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir#
9*cdf0e10cSrcweir# This file is part of OpenOffice.org.
10*cdf0e10cSrcweir#
11*cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir# only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir#
15*cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir#
21*cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir# version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir# <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir# for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir#
26*cdf0e10cSrcweir#*************************************************************************
27*cdf0e10cSrcweir
28*cdf0e10cSrcweirpackage installer::environment;
29*cdf0e10cSrcweir
30*cdf0e10cSrcweiruse installer::exiter;
31*cdf0e10cSrcweiruse installer::globals;
32*cdf0e10cSrcweir
33*cdf0e10cSrcweir######################################################
34*cdf0e10cSrcweir# Create path variables from environment variables
35*cdf0e10cSrcweir######################################################
36*cdf0e10cSrcweir
37*cdf0e10cSrcweirsub create_pathvariables
38*cdf0e10cSrcweir{
39*cdf0e10cSrcweir	my ($environment) = @_;
40*cdf0e10cSrcweir
41*cdf0e10cSrcweir	my %variables = ();
42*cdf0e10cSrcweir
43*cdf0e10cSrcweir	# The following variables are needed in the path file list
44*cdf0e10cSrcweir	# solarpath, solarenvpath, solarcommonpath, os, osdef, pmiscpath
45*cdf0e10cSrcweir
46*cdf0e10cSrcweir	my $solarpath = $environment->{'SOLARVERSION'} . $installer::globals::separator . $installer::globals::compiler . $installer::globals::productextension;
47*cdf0e10cSrcweir	$variables{'solarpath'} = $solarpath;
48*cdf0e10cSrcweir
49*cdf0e10cSrcweir	my $solarcommonpath = $environment->{'SOLARVERSION'} . $installer::globals::separator . "common" . $installer::globals::productextension;
50*cdf0e10cSrcweir	# my $solarcommonpath = $environment->{'SOLARVERSION'} . $installer::globals::separator . $environment->{'COMMON_OUTDIR'} . $installer::globals::productextension;
51*cdf0e10cSrcweir	$variables{'solarcommonpath'} = $solarcommonpath;
52*cdf0e10cSrcweir
53*cdf0e10cSrcweir	my $osdef = lc($environment->{'GUI'});
54*cdf0e10cSrcweir	$variables{'osdef'} = $osdef;
55*cdf0e10cSrcweir
56*cdf0e10cSrcweir	$variables{'os'} = $installer::globals::compiler;
57*cdf0e10cSrcweir
58*cdf0e10cSrcweir	my $solarenvpath = "";
59*cdf0e10cSrcweir
60*cdf0e10cSrcweir	if ( $ENV{'SO_PACK'} ) { $solarenvpath  = $ENV{'SO_PACK'}; }
61*cdf0e10cSrcweir	# overriding with STAR_INSTPATH, if set
62*cdf0e10cSrcweir	if ( $ENV{'STAR_INSTPATH'} ) { $solarenvpath = $ENV{'STAR_INSTPATH'}; }
63*cdf0e10cSrcweir
64*cdf0e10cSrcweir	$variables{'solarenvpath'} = $solarenvpath;
65*cdf0e10cSrcweir
66*cdf0e10cSrcweir	my $localpath  = $environment->{'LOCAL_OUT'};
67*cdf0e10cSrcweir	$variables{'localpath'} = $localpath;
68*cdf0e10cSrcweir
69*cdf0e10cSrcweir	my $localcommonpath  = $environment->{'LOCAL_COMMON_OUT'};
70*cdf0e10cSrcweir	$variables{'localcommonpath'} = $localcommonpath;
71*cdf0e10cSrcweir
72*cdf0e10cSrcweir	my $platformname  = $environment->{'OUTPATH'};
73*cdf0e10cSrcweir	$variables{'platformname'} = $platformname;
74*cdf0e10cSrcweir
75*cdf0e10cSrcweir	return \%variables;
76*cdf0e10cSrcweir}
77*cdf0e10cSrcweir
78*cdf0e10cSrcweir##################################################
79*cdf0e10cSrcweir# Replacing tilde in pathes, because of
80*cdf0e10cSrcweir# problem with deep recursion (task 104830)
81*cdf0e10cSrcweir##################################################
82*cdf0e10cSrcweir
83*cdf0e10cSrcweirsub check_tilde_in_directory
84*cdf0e10cSrcweir{
85*cdf0e10cSrcweir	if ( $ENV{'HOME'} )
86*cdf0e10cSrcweir	{
87*cdf0e10cSrcweir		my $home = $ENV{'HOME'};
88*cdf0e10cSrcweir		$home =~ s/\Q$installer::globals::separator\E\s*$//;
89*cdf0e10cSrcweir		$installer::globals::localinstalldir =~ s/~/$home/;
90*cdf0e10cSrcweir		my $infoline = "Info: Changing LOCALINSTALLDIR to $installer::globals::localinstalldir\n";
91*cdf0e10cSrcweir		push(@installer::globals::logfileinfo, $infoline);
92*cdf0e10cSrcweir	}
93*cdf0e10cSrcweir	else
94*cdf0e10cSrcweir	{
95*cdf0e10cSrcweir		# exit, because "~" is not allowed, if HOME is not set
96*cdf0e10cSrcweir		my $infoline = "ERROR: If \"~\" is used in \"LOCALINSTALLDIR\", environment variable \"HOME\" needs to be defined!\n";
97*cdf0e10cSrcweir		push(@installer::globals::logfileinfo, $infoline);
98*cdf0e10cSrcweir		installer::exiter::exit_program("ERROR: If \"~\" is used in \"LOCALINSTALLDIR\", environment variable \"HOME\" needs to be defined!", "check_tilde_in_directory");
99*cdf0e10cSrcweir	}
100*cdf0e10cSrcweir}
101*cdf0e10cSrcweir
102*cdf0e10cSrcweir##################################################
103*cdf0e10cSrcweir# Setting some fundamental global variables.
104*cdf0e10cSrcweir# All these variables can be overwritten
105*cdf0e10cSrcweir# by parameters.
106*cdf0e10cSrcweir##################################################
107*cdf0e10cSrcweir
108*cdf0e10cSrcweirsub set_global_environment_variables
109*cdf0e10cSrcweir{
110*cdf0e10cSrcweir	my ( $environment ) = @_;
111*cdf0e10cSrcweir
112*cdf0e10cSrcweir	$installer::globals::build = $environment->{'WORK_STAMP'};
113*cdf0e10cSrcweir	# $installer::globals::minor = $environment->{'UPDMINOR'};
114*cdf0e10cSrcweir	$installer::globals::compiler = $environment->{'OUTPATH'};
115*cdf0e10cSrcweir
116*cdf0e10cSrcweir	if ( $ENV{'UPDMINOR'} ) { $installer::globals::minor = $ENV{'UPDMINOR'}; }
117*cdf0e10cSrcweir	if ( $ENV{'LAST_MINOR'} ) { $installer::globals::lastminor = $ENV{'LAST_MINOR'}; }
118*cdf0e10cSrcweir
119*cdf0e10cSrcweir	if ( $ENV{'PROEXT'} ) { $installer::globals::pro = 1; }
120*cdf0e10cSrcweir
121*cdf0e10cSrcweir	if ( $ENV{'VERBOSE'} && ( (lc $ENV{'VERBOSE'}) eq "false" ) ) { $installer::globals::quiet = 1; }
122*cdf0e10cSrcweir	if ( $ENV{'PREPARE_WINPATCH'} ) { $installer::globals::prepare_winpatch = 1; }
123*cdf0e10cSrcweir	if ( $ENV{'PREVIOUS_IDT_DIR'} ) { $installer::globals::previous_idt_dir = $ENV{'PREVIOUS_IDT_DIR'}; }
124*cdf0e10cSrcweir	if ( $ENV{'LOCALINSTALLDIR'} ) { $installer::globals::localinstalldir = $ENV{'LOCALINSTALLDIR'}; }
125*cdf0e10cSrcweir	if ( $ENV{'LOCALUNPACKDIR'} ) { $installer::globals::localunpackdir = $ENV{'LOCALUNPACKDIR'}; }
126*cdf0e10cSrcweir	if ( $ENV{'MAX_LANG_LENGTH'} ) { $installer::globals::max_lang_length = $ENV{'MAX_LANG_LENGTH'}; }
127*cdf0e10cSrcweir
128*cdf0e10cSrcweir	if ( $ENV{'SOLAR_JAVA'} ) { $installer::globals::solarjavaset = 1; }
129*cdf0e10cSrcweir	if ( $ENV{'RPM'} ) { $installer::globals::rpm = $ENV{'RPM'}; }
130*cdf0e10cSrcweir	if ( $ENV{'DONTCOMPRESS'} ) { $installer::globals::solarisdontcompress = 1; }
131*cdf0e10cSrcweir	if ( $ENV{'IGNORE_ERROR_IN_LOGFILE'} ) { $installer::globals::ignore_error_in_logfile = 1; }
132*cdf0e10cSrcweir	if (( $ENV{'DISABLE_STRIP'} ) && ( $ENV{'DISABLE_STRIP'} ne '' )) { $installer::globals::strip = 0; }
133*cdf0e10cSrcweir
134*cdf0e10cSrcweir	if ( $installer::globals::localinstalldir ) { $installer::globals::localinstalldirset = 1; }
135*cdf0e10cSrcweir	# Special handling, if LOCALINSTALLDIR contains "~" in the path
136*cdf0e10cSrcweir	if ( $installer::globals::localinstalldir =~ /^\s*\~/ ) { check_tilde_in_directory(); }
137*cdf0e10cSrcweir}
138*cdf0e10cSrcweir
139*cdf0e10cSrcweir1;
140