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