Update ooo320-m1
[ooovba.git] / solenv / bin / modules / installer / exiter.pm
blobad12493ffb76f7461c705f504d45b07382523d6e
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: exiter.pm,v $
11 # $Revision: 1.8 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 package installer::exiter;
34 use installer::files;
35 use installer::globals;
36 use installer::logger;
37 use installer::systemactions;
38 use installer::worker;
40 ############################################
41 # Exiting the program with an error
42 # This function is used instead of "die"
43 ############################################
45 sub exit_program
47 my ($message, $function) = @_;
49 # If an installation set is currently created, the directory name is saved in $installer::globals::saveinstalldir
50 # If this directory name matches with "_inprogress", it has to be renamed into "_witherror"
52 if ( $installer::globals::saveinstalldir =~ /_inprogress/ ) { installer::systemactions::rename_string_in_directory($installer::globals::saveinstalldir, "_inprogress", "_witherror"); }
54 # Cleaning files from pool tooling
55 if ( $installer::globals::processhaspoolcheckfile ) { unlink $installer::globals::poolcheckfilename; }
56 if ( $installer::globals::processhaspoollockfile ) { unlink $installer::globals::poollockfilename; }
58 installer::worker::clean_output_tree(); # removing directories created in the output tree
60 # If @installer::globals::logfileinfo is not empty, it can be used.
61 # Otherwise the content of @installer::globals::globallogfileinfo has to be used.
63 my $infoline;
65 $installer::globals::logfilename = $installer::globals::exitlog . $installer::globals::logfilename;
67 if ( ! $installer::globals::globalinfo_copied ) { installer::logger::copy_globalinfo_into_logfile(); }
69 if ( $#installer::globals::logfileinfo > -1 )
71 $infoline = "\n***************************************************************\n";
72 push(@installer::globals::logfileinfo, $infoline);
74 $infoline = "$message\n";
75 push(@installer::globals::logfileinfo, $infoline);
77 $infoline = "in function: $function\n";
78 push(@installer::globals::logfileinfo, $infoline);
80 $infoline = "***************************************************************\n";
81 push(@installer::globals::logfileinfo, $infoline);
83 installer::files::save_file($installer::globals::logfilename ,\@installer::globals::logfileinfo);
85 else
87 $infoline = "\n***************************************************************\n";
88 push(@installer::globals::globallogfileinfo, $infoline);
90 $infoline = "$message\n";
91 push(@installer::globals::globallogfileinfo, $infoline);
93 $infoline = "in function: $function\n";
94 push(@installer::globals::globallogfileinfo, $infoline);
96 $infoline = "***************************************************************\n";
97 push(@installer::globals::globallogfileinfo, $infoline);
99 installer::files::save_file($installer::globals::logfilename ,\@installer::globals::globallogfileinfo);
101 installer::logger::print_error("$message\nin function: $function");
102 installer::logger::print_error("Saved logfile: $installer::globals::logfilename\n");
104 # Saving the debug info
106 if ( $installer::globals::debug ) { installer::logger::savedebug($installer::globals::exitlog); }
108 installer::logger::stoptime();
110 if (defined($installer::globals::exithandler)) {
111 &$installer::globals::exithandler;
114 exit(-1);