| 1 |
# |
| 2 |
# This file is part of the LibreOffice project. |
| 3 |
# |
| 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/. |
| 7 |
# |
| 8 |
# This file incorporates work covered by the following license notice: |
| 9 |
# |
| 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 . |
| 17 |
# |
| 18 |
|
| 19 |
package installer::environment; |
| 20 |
|
| 21 |
use strict; |
| 22 |
use warnings; |
| 23 |
|
| 24 |
use installer::globals; |
| 25 |
|
| 26 |
###################################################### |
| 27 |
# Create path variables from environment variables |
| 28 |
###################################################### |
| 29 |
|
| 30 |
sub create_pathvariables |
| 31 |
{ |
| 32 |
my ($environment) = @_; |
| 33 |
|
| 34 |
my %variables = (); |
| 35 |
|
| 36 |
# The following variables are needed in the path file list |
| 37 |
# solarenvpath, os, pmiscpath |
| 38 |
|
| 39 |
my $solarenvpath = ""; |
| 40 |
|
| 41 |
if ( $ENV{'SO_PACK'} ) { $solarenvpath = $ENV{'SO_PACK'}; } |
| 42 |
# overriding with STAR_INSTPATH, if set |
| 43 |
if ( $ENV{'STAR_INSTPATH'} ) { $solarenvpath = $ENV{'STAR_INSTPATH'}; } |
| 44 |
|
| 45 |
$variables{'solarenvpath'} = $solarenvpath; |
| 46 |
|
| 47 |
my $localpath = $environment->{'LOCAL_OUT'}; |
| 48 |
$variables{'localpath'} = $localpath; |
| 49 |
|
| 50 |
my $localcommonpath = $environment->{'LOCAL_COMMON_OUT'}; |
| 51 |
$variables{'localcommonpath'} = $localcommonpath; |
| 52 |
|
| 53 |
my $installscriptdir = $environment->{'WORKDIR'} . $installer::globals::separator . "InstallScriptTarget"; |
| 54 |
$variables{'installscriptdir'} = $installscriptdir; |
| 55 |
|
| 56 |
my $extensionsdir = $environment->{'WORKDIR'} . $installer::globals::separator . "Extension"; |
| 57 |
$variables{'extensionsdir'} = $extensionsdir; |
| 58 |
|
| 59 |
my $customtargetpath = $environment->{'WORKDIR'} . $installer::globals::separator . "CustomTarget"; |
| 60 |
$variables{'customtargetpath'} = $customtargetpath; |
| 61 |
|
| 62 |
my $filelistpath = $environment->{'WORKDIR'}; |
| 63 |
$variables{'filelistpath'} = $filelistpath; |
| 64 |
|
| 65 |
my $licensepath = $environment->{'WORKDIR'} . $installer::globals::separator . "CustomTarget/readlicense_oo/license"; |
| 66 |
$variables{'licensepath'} = $licensepath; |
| 67 |
|
| 68 |
my $packinfopath = $environment->{'SRCDIR'} . $installer::globals::separator . "setup_native/source/packinfo"; |
| 69 |
$variables{'packinfopath'} = $packinfopath; |
| 70 |
|
| 71 |
return \%variables; |
| 72 |
} |
| 73 |
|
| 74 |
################################################## |
| 75 |
# Replacing tilde in paths, because of |
| 76 |
# problem with deep recursion (task 104830) |
| 77 |
################################################## |
| 78 |
|
| 79 |
sub 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 |
die 'If "~" is used in "LOCALINSTALLDIR", environment variable "HOME" needs to be defined!'; |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
################################################## |
| 99 |
# Setting some fundamental global variables. |
| 100 |
# All these variables can be overwritten |
| 101 |
# by parameters. |
| 102 |
################################################## |
| 103 |
|
| 104 |
sub set_global_environment_variables |
| 105 |
{ |
| 106 |
my ( $environment ) = @_; |
| 107 |
|
| 108 |
$installer::globals::build = $environment->{'LIBO_VERSION_MAJOR'}.$environment->{'LIBO_VERSION_MINOR'}."0"; |
| 109 |
$installer::globals::os = $environment->{'OS'}; |
| 110 |
$installer::globals::com = $environment->{'COM'}; |
| 111 |
$installer::globals::cpuname = $environment->{'CPUNAME'}; |
| 112 |
$installer::globals::platformid = $environment->{'PLATFORMID'}; |
| 113 |
|
| 114 |
if ( $ENV{'ENABLE_DBGUTIL'} ) {} else { $installer::globals::pro = 1; } |
| 115 |
|
| 116 |
if ( $ENV{'VERBOSE'} && ( (lc $ENV{'VERBOSE'}) eq "false" ) ) { $installer::globals::quiet = 1; } |
| 117 |
if ( $ENV{'PREPARE_WINPATCH'} ) { $installer::globals::prepare_winpatch = 1; } |
| 118 |
if ( $ENV{'PREVIOUS_IDT_DIR'} ) { $installer::globals::previous_idt_dir = $ENV{'PREVIOUS_IDT_DIR'}; } |
| 119 |
if ( $ENV{'LOCALINSTALLDIR'} ) { $installer::globals::localinstalldir = $ENV{'LOCALINSTALLDIR'}; } |
| 120 |
if ( $ENV{'LOCALUNPACKDIR'} ) { $installer::globals::localunpackdir = $ENV{'LOCALUNPACKDIR'}; } |
| 121 |
if ( $ENV{'MAX_LANG_LENGTH'} ) { $installer::globals::max_lang_length = $ENV{'MAX_LANG_LENGTH'}; } |
| 122 |
|
| 123 |
if ( $ENV{'RPM'} ) { $installer::globals::rpm = $ENV{'RPM'}; } |
| 124 |
if ( $ENV{'DONTCOMPRESS'} ) { $installer::globals::solarisdontcompress = 1; } |
| 125 |
if ( $ENV{'IGNORE_ERROR_IN_LOGFILE'} ) { $installer::globals::ignore_error_in_logfile = 1; } |
| 126 |
if (( $ENV{'ENABLE_STRIP'} ) && ( $ENV{'ENABLE_STRIP'} ne '' )) { $installer::globals::strip = 1; } |
| 127 |
if (( $ENV{'DISABLE_STRIP'} ) && ( $ENV{'DISABLE_STRIP'} ne '' )) { $installer::globals::strip = 0; } |
| 128 |
|
| 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(); } |
| 132 |
} |
| 133 |
|
| 134 |
1; |