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