~ubuntu-branches/ubuntu/utopic/sbuild/utopic

« back to all changes in this revision

Viewing changes to lib/Sbuild/Log.pm

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-06-23 22:27:58 UTC
  • mfrom: (8.1.24) (3.3.23 sid)
  • Revision ID: package-import@ubuntu.com-20120623222758-48ljspppdh7xzu9i
Tags: 0.63.1-1ubuntu1
* Resynchronize with Debian testing. Remaining changes:
  - debian/patches/do-not-install-debfoster-into-chroots.patch:
    do not install debfoster into the chroots because it is in universe and
    not needed for package building itself.
  - debian/patches/run-pre-build-hooks-as-root.patch:
    run pre-build hooks as root
* Drop run-lintian-inside-chroot.patch: It hasn't been picked up
  by Debian and doesn't work quite right (LP: #940410)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# Log.pm: logging library for sbuild
3
 
# Copyright © 2005      Ryan Murray <rmurray@debian.org>
4
 
# Copyright © 2005-2006 Roger Leigh <rleigh@debian.org>
5
 
#
6
 
# This program is free software: you can redistribute it and/or modify
7
 
# it under the terms of the GNU General Public License as published by
8
 
# the Free Software Foundation, either version 2 of the License, or
9
 
# (at your option) any later version.
10
 
#
11
 
# This program is distributed in the hope that it will be useful, but
12
 
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 
# General Public License for more details.
15
 
#
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with this program.  If not, see
18
 
# <http://www.gnu.org/licenses/>.
19
 
#
20
 
#######################################################################
21
 
 
22
 
package Sbuild::Log;
23
 
 
24
 
use strict;
25
 
use warnings;
26
 
use File::Temp ();
27
 
use POSIX;
28
 
use FileHandle;
29
 
use File::Basename qw(basename);
30
 
use Sbuild qw(send_mail);
31
 
use Sbuild::LogBase;
32
 
 
33
 
sub open_log ($);
34
 
sub close_log ($);
35
 
 
36
 
BEGIN {
37
 
    use Exporter ();
38
 
    our (@ISA, @EXPORT);
39
 
 
40
 
    @ISA = qw(Exporter);
41
 
 
42
 
    @EXPORT = qw(open_log close_log);
43
 
}
44
 
 
45
 
my $main_logfile;
46
 
 
47
 
sub open_log ($) {
48
 
    my $conf = shift;
49
 
 
50
 
    my $main_distribution = $conf->get('DISTRIBUTION');
51
 
    my $date = strftime("%Y%m%d-%H%M",localtime);
52
 
 
53
 
    my $F = undef;
54
 
    $main_logfile = undef;
55
 
 
56
 
    if (!$conf->get('NOLOG')) {
57
 
        my $F = new File::Temp( TEMPLATE => "build-${main_distribution}-$date.XXXXXX",
58
 
                                DIR => $conf->get('BUILD_DIR'),
59
 
                                SUFFIX => '.log',
60
 
                                UNLINK => 0)
61
 
            or die "Can't open logfile: $!\n";
62
 
        $F->autoflush(1);
63
 
        $main_logfile = $F->filename;
64
 
    }
65
 
 
66
 
    return Sbuild::LogBase::open_log($conf, $F, undef);
67
 
}
68
 
 
69
 
sub close_log ($) {
70
 
    my $conf = shift;
71
 
 
72
 
    my $date = strftime("%Y%m%d-%H%M",localtime);
73
 
 
74
 
    Sbuild::LogBase::close_log($conf);
75
 
 
76
 
    if (!$conf->get('NOLOG') && !$conf->get('VERBOSE') &&
77
 
        -s $main_logfile && $conf->get('MAILTO')) {
78
 
        send_mail( $conf,
79
 
                   $conf->get('MAILTO'), "Log from sbuild $date",
80
 
                   $main_logfile ) if $conf->get('MAILTO');
81
 
    }
82
 
    elsif (!$conf->get('NOLOG') && ! -s $main_logfile) {
83
 
        unlink( $main_logfile );
84
 
    }
85
 
}
86
 
 
87
 
1;