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::exiter; 29 30use installer::files; 31use installer::globals; 32use installer::logger; 33use installer::systemactions; 34use installer::worker; 35 36############################################ 37# Exiting the program with an error 38# This function is used instead of "die" 39############################################ 40 41sub exit_program 42{ 43 my ($message, $function) = @_; 44 45 # If an installation set is currently created, the directory name is saved in $installer::globals::saveinstalldir 46 # If this directory name matches with "_inprogress", it has to be renamed into "_witherror" 47 48 if ( $installer::globals::saveinstalldir =~ /_inprogress/ ) { installer::systemactions::rename_string_in_directory($installer::globals::saveinstalldir, "_inprogress", "_witherror"); } 49 50 # Cleaning files from pool tooling 51 if ( $installer::globals::processhaspoolcheckfile ) { unlink $installer::globals::poolcheckfilename; } 52 if ( $installer::globals::processhaspoollockfile ) { unlink $installer::globals::poollockfilename; } 53 54 installer::worker::clean_output_tree(); # removing directories created in the output tree 55 56 # If @installer::globals::logfileinfo is not empty, it can be used. 57 # Otherwise the content of @installer::globals::globallogfileinfo has to be used. 58 59 my $infoline; 60 61 $installer::globals::logfilename = $installer::globals::exitlog . $installer::globals::logfilename; 62 63 if ( ! $installer::globals::globalinfo_copied ) { installer::logger::copy_globalinfo_into_logfile(); } 64 65 if ( $#installer::globals::logfileinfo > -1 ) 66 { 67 $infoline = "\n***************************************************************\n"; 68 push(@installer::globals::logfileinfo, $infoline); 69 70 $infoline = "$message\n"; 71 push(@installer::globals::logfileinfo, $infoline); 72 73 $infoline = "in function: $function\n"; 74 push(@installer::globals::logfileinfo, $infoline); 75 76 $infoline = "***************************************************************\n"; 77 push(@installer::globals::logfileinfo, $infoline); 78 79 installer::files::save_file($installer::globals::logfilename ,\@installer::globals::logfileinfo); 80 } 81 else 82 { 83 $infoline = "\n***************************************************************\n"; 84 push(@installer::globals::globallogfileinfo, $infoline); 85 86 $infoline = "$message\n"; 87 push(@installer::globals::globallogfileinfo, $infoline); 88 89 $infoline = "in function: $function\n"; 90 push(@installer::globals::globallogfileinfo, $infoline); 91 92 $infoline = "***************************************************************\n"; 93 push(@installer::globals::globallogfileinfo, $infoline); 94 95 installer::files::save_file($installer::globals::logfilename ,\@installer::globals::globallogfileinfo); 96 } 97 installer::logger::print_error("$message\nin function: $function"); 98 installer::logger::print_error("Saved logfile: $installer::globals::logfilename\n"); 99 100 # Saving the debug info 101 102 if ( $installer::globals::debug ) { installer::logger::savedebug($installer::globals::exitlog); } 103 104 installer::logger::stoptime(); 105 106 if (defined($installer::globals::exithandler)) { 107 &$installer::globals::exithandler; 108 } 109 110 exit(-1); 111} 112 1131; 114