Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / solenv / bin / modules / installer / environment.pm
blobcce32e4ab7463040663f7d38dd6cee6d172469a6
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package installer::environment;
21 use installer::globals;
23 ######################################################
24 # Create path variables from environment variables
25 ######################################################
27 sub create_pathvariables
29 my ($environment) = @_;
31 my %variables = ();
33 # The following variables are needed in the path file list
34 # solarenvpath, os, pmiscpath
36 $variables{'os'} = $installer::globals::compiler;
38 my $solarenvpath = "";
40 if ( $ENV{'SO_PACK'} ) { $solarenvpath = $ENV{'SO_PACK'}; }
41 # overriding with STAR_INSTPATH, if set
42 if ( $ENV{'STAR_INSTPATH'} ) { $solarenvpath = $ENV{'STAR_INSTPATH'}; }
44 $variables{'solarenvpath'} = $solarenvpath;
46 my $localpath = $environment->{'LOCAL_OUT'};
47 $variables{'localpath'} = $localpath;
49 my $localcommonpath = $environment->{'LOCAL_COMMON_OUT'};
50 $variables{'localcommonpath'} = $localcommonpath;
52 my $platformname = $environment->{'OUTPATH'};
53 $variables{'platformname'} = $platformname;
55 my $installscriptdir = $environment->{'WORKDIR'} . $installer::globals::separator . "InstallScriptTarget";
56 $variables{'installscriptdir'} = $installscriptdir;
58 my $extensionsdir = $environment->{'WORKDIR'} . $installer::globals::separator . "Extension";
59 $variables{'extensionsdir'} = $extensionsdir;
61 my $customtargetpath = $environment->{'WORKDIR'} . $installer::globals::separator . "CustomTarget";
62 $variables{'customtargetpath'} = $customtargetpath;
64 my $filelistpath = $environment->{'WORKDIR'};
65 $variables{'filelistpath'} = $filelistpath;
67 my $licensepath = $environment->{'SRCDIR'} . $installer::globals::separator . "readlicense_oo/license";
68 $variables{'licensepath'} = $licensepath;
70 my $packinfopath = $environment->{'SRCDIR'} . $installer::globals::separator . "setup_native/source/packinfo";
71 $variables{'packinfopath'} = $packinfopath;
73 return \%variables;
76 ##################################################
77 # Replacing tilde in paths, because of
78 # problem with deep recursion (task 104830)
79 ##################################################
81 sub check_tilde_in_directory
83 if ( $ENV{'HOME'} )
85 my $home = $ENV{'HOME'};
86 $home =~ s/\Q$installer::globals::separator\E\s*$//;
87 $installer::globals::localinstalldir =~ s/~/$home/;
88 my $infoline = "Info: Changing LOCALINSTALLDIR to $installer::globals::localinstalldir\n";
89 push(@installer::globals::logfileinfo, $infoline);
91 else
93 # exit, because "~" is not allowed, if HOME is not set
94 my $infoline = "ERROR: If \"~\" is used in \"LOCALINSTALLDIR\", environment variable \"HOME\" needs to be defined!\n";
95 push(@installer::globals::logfileinfo, $infoline);
96 die 'If "~" is used in "LOCALINSTALLDIR", environment variable "HOME" needs to be defined!';
100 ##################################################
101 # Setting some fundamental global variables.
102 # All these variables can be overwritten
103 # by parameters.
104 ##################################################
106 sub set_global_environment_variables
108 my ( $environment ) = @_;
110 $installer::globals::build = $environment->{'WORK_STAMP'};
111 $installer::globals::compiler = $environment->{'OUTPATH'};
113 if ( $ENV{'LAST_MINOR'} ) { $installer::globals::lastminor = $ENV{'LAST_MINOR'}; }
115 if ( $ENV{'ENABLE_DBGUTIL'} ) {} else { $installer::globals::pro = 1; }
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'}; }
124 if ( $ENV{'RPM'} ) { $installer::globals::rpm = $ENV{'RPM'}; }
125 if ( $ENV{'DONTCOMPRESS'} ) { $installer::globals::solarisdontcompress = 1; }
126 if ( $ENV{'IGNORE_ERROR_IN_LOGFILE'} ) { $installer::globals::ignore_error_in_logfile = 1; }
127 if (( $ENV{'DISABLE_STRIP'} ) && ( $ENV{'DISABLE_STRIP'} ne '' )) { $installer::globals::strip = 0; }
129 if ( $installer::globals::localinstalldir ) { $installer::globals::localinstalldirset = 1; }
130 # Special handling, if LOCALINSTALLDIR contains "~" in the path
131 if ( $installer::globals::localinstalldir =~ /^\s*\~/ ) { check_tilde_in_directory(); }