aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-networking/recipes-extended/mime-construct/files/Signal.pm132
-rw-r--r--meta-networking/recipes-extended/mime-construct/files/WaitStat.pm178
-rw-r--r--meta-networking/recipes-extended/mime-construct/mime-construct_1.11.bb29
3 files changed, 339 insertions, 0 deletions
diff --git a/meta-networking/recipes-extended/mime-construct/files/Signal.pm b/meta-networking/recipes-extended/mime-construct/files/Signal.pm
new file mode 100644
index 0000000000..9280e88681
--- /dev/null
+++ b/meta-networking/recipes-extended/mime-construct/files/Signal.pm
@@ -0,0 +1,132 @@
+# $Id: Signal.pm,v 1.4 1998-10-27 16:16:13-05 roderick Exp $
+#
+# Copyright (c) 1997 Roderick Schertler. All rights reserved. This
+# program is free software; you can redistribute it and/or modify it
+# under the same terms as Perl itself.
+
+package IPC::Signal;
+
+use 5.003_94; # __PACKAGE__
+use strict;
+use vars qw($VERSION @ISA @EXPORT_OK $AUTOLOAD %Sig_num @Sig_name);
+
+require Exporter;
+
+$VERSION = '1.00';
+@ISA = qw(Exporter);
+@EXPORT_OK = qw(sig_num sig_name sig_translate_setup %Sig_num @Sig_name);
+%Sig_num = ();
+@Sig_name = ();
+
+sub sig_num ($);
+sub sig_name ($);
+
+sub sig_translate_setup () {
+ return if %Sig_num && @Sig_name;
+
+ require Config;
+
+ # In 5.005 the sig_num entries are comma separated and there's a
+ # trailing 0.
+ my $num = $Config::Config{'sig_num'};
+ if ($num =~ s/,//g) {
+ $num =~ s/\s+0$//;
+ }
+
+ my @name = split ' ', $Config::Config{'sig_name'};
+ my @num = split ' ', $num;
+
+ @name or die 'No signals defined';
+ @name == @num or die 'Signal name/number mismatch';
+
+ @Sig_num{@name} = @num;
+ keys %Sig_num == @name or die 'Duplicate signal names present';
+ for (@name) {
+ $Sig_name[$Sig_num{$_}] = $_
+ unless defined $Sig_name[$Sig_num{$_}];
+ }
+}
+
+# This autoload routine just is just for sig_num() and sig_name(). It
+# calls sig_translate_setup() and then snaps the real function definitions
+# into place.
+
+sub AUTOLOAD {
+ if ($AUTOLOAD ne __PACKAGE__ . '::sig_num'
+ && $AUTOLOAD ne __PACKAGE__ . '::sig_name') {
+ require Carp;
+ Carp::croak("Undefined subroutine &$AUTOLOAD called");
+ }
+ sig_translate_setup;
+ *sig_num = sub ($) { $Sig_num{$_[0]} };
+ *sig_name = sub ($) { $Sig_name[$_[0]] };
+ goto &$AUTOLOAD;
+}
+
+1
+
+__END__
+
+=head1 NAME
+
+IPC::Signal - Utility functions dealing with signals
+
+=head1 SYNOPSIS
+
+ $number = sig_num $name;
+ $name = sig_name $number;
+
+ sig_translate_setup;
+ $number = $Sig_num{$name};
+ $name = $Sig_name[$number];
+
+=head1 DESCRIPTION
+
+This module contains utility functions for dealing with signals.
+
+Nothing is exported by default.
+
+=over
+
+=item B<sig_num> I<chopped-signal-name>
+
+Returns the signal number of the signal whose name (sans C<SIG>) is
+I<chopped-signal-name>, or undef if there is no such signal.
+
+This function is prototyped to take a single scalar argument.
+
+=item B<sig_name> I<signal-number>
+
+Returns the chopped signal name (like C<HUP>) of signal number
+I<signal-number>, or undef if there is no such signal.
+
+This function is prototyped to take a single scalar argument.
+
+=item B<sig_translate_setup>
+
+If you want to use the @Sig_name and %Sig_num variables directly you must
+call B<sig_translate_setup> to initialize them. This isn't necessary if
+you only use the function interfaces sig_name() and sig_num().
+
+This function is prototyped to take no arguments.
+
+=item B<%Sig_num>
+
+A hash with chopped signal name keys (like C<HUP>) and integer signal
+number values.
+
+=item B<@Sig_name>
+
+An array mapping signal numbers to chopped signal names (like C<HUP>).
+
+=back
+
+=head1 AUTHOR
+
+Roderick Schertler <F<roderick@argon.org>>
+
+=head1 SEE ALSO
+
+perl(1).
+
+=cut
diff --git a/meta-networking/recipes-extended/mime-construct/files/WaitStat.pm b/meta-networking/recipes-extended/mime-construct/files/WaitStat.pm
new file mode 100644
index 0000000000..337e52a705
--- /dev/null
+++ b/meta-networking/recipes-extended/mime-construct/files/WaitStat.pm
@@ -0,0 +1,178 @@
+# $Id: WaitStat.pm,v 1.3 1999-10-21 12:39:43-04 roderick Exp $
+#
+# Copyright (c) 1997 Roderick Schertler. All rights reserved. This
+# program is free software; you can redistribute it and/or modify it
+# under the same terms as Perl itself.
+
+=head1 NAME
+
+Proc::WaitStat - Interpret and act on wait() status values
+
+=head1 SYNOPSIS
+
+ $description = waitstat $?;
+ exit waitstat_reuse $?;
+ waitstat_die $?, 'program-name';
+ close_die COMMAND, 'program-name';
+
+=head1 DESCRIPTION
+
+This module contains functions for interpreting and acting on wait
+status values.
+
+Nothing is exported by default.
+
+=over
+
+=cut
+
+package Proc::WaitStat;
+
+use 5.003_98; # piped close errno resetting
+use strict;
+use vars qw($VERSION @ISA @EXPORT_OK);
+
+use Carp qw(croak);
+use Exporter ();
+use IPC::Signal qw(sig_name);
+use POSIX qw(:sys_wait_h);
+
+$VERSION = '1.00';
+@ISA = qw(Exporter);
+@EXPORT_OK = qw(waitstat waitstat_reuse waitstat_die close_die);
+
+=item B<waitstat> I<wait-status>
+
+Returns a string representation of wait() status value I<wait-status>.
+Values returned are like C<"0"> and C<"64"> and C<"killed (SIGHUP)">.
+
+This function is prototyped to take a single scalar argument.
+
+=cut
+
+sub waitstat ($) {
+ my $status = shift;
+
+ if (WIFEXITED $status) {
+ WEXITSTATUS $status
+ }
+ elsif (WIFSIGNALED $status) {
+ # XXX WCOREDUMP
+ 'killed (SIG' . sig_name(WTERMSIG $status) . ')'
+ }
+ elsif (WIFSTOPPED $status) {
+ 'stopped (SIG' . sig_name(WSTOPSIG $status) . ')'
+ }
+ # XXX WIFCONTINUED
+ else {
+ "invalid wait status $status"
+ }
+}
+
+=item B<waitstat_reuse> I<wait-status>
+
+Turn I<wait-status> into a value which can be passed to B<exit>, converted
+in the same manner the shell uses. If I<wait-status> indicates a normal
+exit, return the exit value. If I<wait-status> instead indicates death by
+signal, return 128 plus the signal number.
+
+This function is prototyped to take a single scalar argument.
+
+=cut
+
+sub waitstat_reuse ($) {
+ my $status = shift;
+
+ if (WIFEXITED $status) {
+ WEXITSTATUS $status
+ }
+ elsif (WIFSIGNALED $status) {
+ 128 + WTERMSIG $status
+ }
+ elsif (WIFSTOPPED $status) {
+ 128 + WSTOPSIG $status
+ }
+ else {
+ croak "Invalid wait status $status";
+ }
+}
+
+=item B<waitstat_die> I<wait-status> I<program-name>
+
+die() if I<wait-status> is non-zero (mentioning I<program-name> as the
+source of the error).
+
+This function is prototyped to take two scalar arguments.
+
+=cut
+
+sub waitstat_die ($$) {
+ my ($status, $program) = @_;
+ croak "Non-zero exit (" . waitstat($status) .
+ ") from $program"
+ if $status;
+}
+
+=item B<close_die> I<filehandle> I<name>
+
+Close I<filehandle>, if that fails die() with an appropriate message
+which refers to I<name>. This handles failed closings of both programs
+and files properly.
+
+This function is prototyped to take a filehandle (actually, a glob ref)
+and a scalar.
+
+=cut
+
+sub close_die (*$) {
+ my ($fh, $name) = @_;
+
+ unless (ref $fh || ref \$fh eq 'GLOB') {
+ require Symbol;
+ $fh = Symbol::qualify_to_ref($fh, caller);
+ }
+
+ unless (close $fh) {
+ croak "Error closing $name: ",
+ $!+0 ? "$!" : 'non-zero exit (' . waitstat($?) . ')';
+ }
+}
+
+1
+
+__END__
+
+=back
+
+=head1 EXAMPLES
+
+ close SENDMAIL;
+ exit if $? == 0;
+ log "sendmail failure: ", waitstat $?;
+ exit EX_TEMPFAIL;
+
+ $pid == waitpid $pid, 0 or croak "Failed to reap $pid: $!";
+ exit waitstat_reuse $?;
+
+ $output = `some-program -with args`;
+ waitstat_die $?, 'some-program';
+ print "Output from some-process:\n", $output;
+
+ open PROGRAM, '| post-processor' or die "Can't fork: $!";
+ while (<IN>) {
+ print PROGRAM pre_process $_
+ or die "Error writing to post-processor: $!";
+ }
+ # This handles both flush failures at close time and a non-zero exit
+ # from the subprocess.
+ close_die PROGRAM, 'post-processor';
+
+=head1 AUTHOR
+
+Roderick Schertler <F<roderick@argon.org>>
+
+=head1 SEE ALSO
+
+perl(1), IPC::Signal(3pm).
+
+=cut
diff --git a/meta-networking/recipes-extended/mime-construct/mime-construct_1.11.bb b/meta-networking/recipes-extended/mime-construct/mime-construct_1.11.bb
new file mode 100644
index 0000000000..bf42a30510
--- /dev/null
+++ b/meta-networking/recipes-extended/mime-construct/mime-construct_1.11.bb
@@ -0,0 +1,29 @@
+SUMMARY = "Construct and optionally mail MIME messages"
+DESCRIPTION = "Constructs and (by default) mails MIME messages. \
+ It is entirely driven from the command line, it is \
+ designed to be used by other programs, or people who act \
+ like programs."
+HOMEPAGE = "http://search.cpan.org/~rosch/mime-construct/mime-construct"
+SECTION = "mail"
+LICENSE = "GPLv2+"
+LIC_FILES_CHKSUM = "file://debian/copyright;md5=5e2e5da619ac8ef8c84767ccc4656e96"
+
+SRC_URI = "${CPAN_MIRROR}/authors/id/R/RO/ROSCH/mime-construct-${PV}.tar.gz \
+ file://WaitStat.pm \
+ file://Signal.pm \
+ "
+SRC_URI[md5sum] = "73834ea780fbea81b89dbd9b2fb54f58"
+SRC_URI[sha256sum] = "4cd7bb61b51d41192d1498c1051aa6a4ccd75aeb09b71d2ec706a7084a4a9303"
+
+inherit cpan
+
+do_install () {
+ oe_runmake install DESTDIR="${D}"
+ install -d ${D}${libdir}/perl/vendor_perl/${@get_perl_version(d)}/Proc \
+ ${D}${libdir}/perl/vendor_perl/${@get_perl_version(d)}/IPC
+ install -m 644 ${WORKDIR}/WaitStat.pm \
+ ${D}${libdir}/perl/vendor_perl/${@get_perl_version(d)}/Proc
+ install -m 644 ${WORKDIR}/Signal.pm \
+ ${D}${libdir}/perl/vendor_perl/${@get_perl_version(d)}/IPC
+}
+RDEPENDS_${PN} = "postfix perl"