home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / perl5 / Debconf / Element / Noninteractive / Error.pm < prev    next >
Encoding:
Perl POD Document  |  2009-03-24  |  1.5 KB  |  64 lines

  1. #!/usr/bin/perl -w
  2. # This file was preprocessed, do not edit!
  3.  
  4.  
  5. package Debconf::Element::Noninteractive::Error;
  6. use strict;
  7. use Text::Wrap;
  8. use Debconf::Gettext;
  9. use Debconf::Config;
  10. use Debconf::Log ':all';
  11. use base qw(Debconf::Element::Noninteractive);
  12.  
  13.  
  14.  
  15. sub show {
  16.     my $this=shift;
  17.  
  18.     if ($this->question->flag('seen') ne 'true') {
  19.         $this->sendmail(gettext("Debconf was not configured to display this error message, so it mailed it to you."));
  20.     }
  21.     $this->value('');
  22. }
  23.  
  24.  
  25. sub sendmail {
  26.     my $this=shift;
  27.     my $footer=shift;
  28.     return unless length Debconf::Config->admin_email;
  29.     if (-x '/usr/bin/mail') {
  30.         debug user => "mailing a note";
  31.             my $title=gettext("Debconf").": ".
  32.             $this->frontend->title." -- ".
  33.             $this->question->description;
  34.         unless (open(MAIL, "|-")) { # child
  35.             exec("mail", "-s", $title, Debconf::Config->admin_email) or return '';
  36.         }
  37.         my $old_columns=$Text::Wrap::columns;
  38.         $Text::Wrap::columns=75;
  39.         if ($this->question->extended_description ne '') {
  40.             print MAIL wrap('', '', $this->question->extended_description);
  41.         }
  42.         else {
  43.             print MAIL wrap('', '', $this->question->description);
  44.         }
  45.         print MAIL "\n\n";
  46.         my $hostname=`hostname -f 2>/dev/null`;
  47.         if (! defined $hostname) {
  48.             $hostname="unknown system";
  49.         }
  50.         print MAIL "-- \n", sprintf(gettext("Debconf, running at %s"), $hostname, "\n");
  51.         print MAIL "[ ", wrap('', '', $footer), " ]\n" if $footer;
  52.         close MAIL or return '';
  53.  
  54.         $Text::Wrap::columns=$old_columns;
  55.     
  56.         $this->question->flag('seen', 'true');
  57.  
  58.         return 1;
  59.     }
  60. }
  61.  
  62.  
  63. 1
  64.