1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23 24package installer::exiter; 25 26use installer::files; 27use installer::globals; 28use installer::logger; 29use installer::systemactions; 30use installer::worker; 31 32############################################ 33# Exiting the program with an error 34# This function is used instead of "die" 35############################################ 36 37sub exit_program 38{ 39 my ($message, $function) = @_; 40 41 # If an installation set is currently created, the directory name is saved in $installer::globals::saveinstalldir 42 # If this directory name matches with "_inprogress", it has to be renamed into "_witherror" 43 44 if ( $installer::globals::saveinstalldir =~ /_inprogress/ ) { installer::systemactions::rename_string_in_directory($installer::globals::saveinstalldir, "_inprogress", "_witherror"); } 45 46 # Cleaning files from pool tooling 47 if ( $installer::globals::processhaspoolcheckfile ) { unlink $installer::globals::poolcheckfilename; } 48 if ( $installer::globals::processhaspoollockfile ) { unlink $installer::globals::poollockfilename; } 49 50 installer::worker::clean_output_tree(); # removing directories created in the output tree 51 52 # If @installer::globals::logfileinfo is not empty, it can be used. 53 # Otherwise the content of @installer::globals::globallogfileinfo has to be used. 54 55 my $infoline; 56 57 $installer::globals::logfilename = $installer::globals::exitlog . $installer::globals::logfilename; 58 59 if ( ! $installer::globals::globalinfo_copied ) { installer::logger::copy_globalinfo_into_logfile(); } 60 61 if ( $#installer::globals::logfileinfo > -1 ) 62 { 63 $installer::logger::Lang->print("\n"); 64 $installer::logger::Lang->print("***************************************************************\n"); 65 $installer::logger::Lang->print($message."\n"); 66 $installer::logger::Lang->printf("in function: %s\n", $function); 67 $installer::logger::Lang->printf("***************************************************************\n"); 68 69# installer::files::save_file($installer::globals::logfilename ,\@installer::globals::logfileinfo); 70 } 71 else 72 { 73 $installer::logger::Global->print("\n"); 74 $installer::logger::Global->print("***************************************************************\n"); 75 $installer::logger::Global->print($message."\n"); 76 $installer::logger::Global->printf("in function: %s\n", $function); 77 $installer::logger::Global->printf("***************************************************************\n"); 78 79# installer::files::save_file($installer::globals::logfilename ,\@installer::globals::globallogfileinfo); 80 } 81 installer::logger::print_error("$message\nin function: $function"); 82# installer::logger::print_error("Saved logfile: $installer::globals::logfilename\n"); 83 84 # Saving the debug info 85 86 if ( $installer::globals::debug ) { installer::logger::savedebug($installer::globals::exitlog); } 87 88 installer::logger::stoptime(); 89 90 if (defined($installer::globals::exithandler)) { 91 &$installer::globals::exithandler; 92 } 93 94 exit(-1); 95} 96 971; 98