[savepoint] Module::Build
authorMatthias Förste <foerste@schlittermann.de>
Wed, 01 Apr 2015 11:19:29 +0200
branchModule::Build
changeset 17 bd500305861e
parent 16 9501cc7d9177
child 18 6ebc687219db
[savepoint]
Build.PL
MANIFEST.SKIP
check_cert.pl
lib/nagios/plugins/ius/check_cert
--- a/Build.PL	Fri Mar 27 11:03:05 2015 +0100
+++ b/Build.PL	Wed Apr 01 11:19:29 2015 +0200
@@ -3,17 +3,66 @@
 use strict;
 use warnings;
 
+# b0rken umlauts in MYMETA.* files otherwise
+use utf8;
+
 use Module::Build;
 
-my $build = Module::Build->new
+my $class = Module::Build->subclass
+(
+    class => 'My::Builder',
+    relpath => { nagiosplugins => 'lib/nagios/plugins/ius' },
+    code => q{
+        sub ACTION_install {
+                my $self = shift;
+                my $relpath;
+                $relpath->{nagiosplugins} = 'lib/nagios/plugins/ius';
+#                for (qw(nagiosplugins)) {
+#                    $self->install_base_relpaths($_, $relpath->{$_});
+#                    $self->prefix_base_relpaths($_, $relpath->{$_});
+#                }
+                use Data::Dumper;
+                print Dumper($self);
+                print Dumper($self->install_base_relpaths());
+                print Dumper($self->prefix_relpaths());
+                print Dumper($self->installdirs());
+                print Dumper($self->install_path());
+                print Dumper($self->install_base());
+                print Dumper($self->install_destination('nagiosplugins'));
+                print Dumper($self->install_types());
+                $self->SUPER::ACTION_install;
+        }
+    },
+);
+
+#my $build = Module::Build->new
+my $build = $class->new
 (
     dist_name => 'nagios-plugin-cert',
     dist_author => 'Matthias Förste',
-    dist_version_from => 'lib/nagios/plugins/ius/check_cert',
+    dist_version_from => 'check_cert.pl',
     requires => {
         'Nagios::Plugin' => 0,
         'Crypt::OpenSSL::PKCS12' => 0,
         'Crypt::OpenSSL::X509' => 0
     },
+    extra_files => {
+        'check_cert.pl' => 'nagiosplugins/check_cert'
+    }
 );
+$build->add_build_element('extra');
+for my $e (qw(nagiosplugins)) {
+    # these seem to be used only when --install-base or --prefix is explicitly given; if only --installdirs or nothing at all is given we probably need to set install_path
+    $build->install_base_relpaths($e => $build->{relpath}->{$e});
+    $build->prefix_relpaths($_, $e => $build->{relpath}->{$e}) for (qw(site core vendor));
+}
+#$build->install_path(nagiosplugin => Module::Build::install_base() . 'lib/nagios/plugins/ius');
+
 $build->create_build_script;
+use Data::Dumper;
+#print Dumper($build->install_base_relpaths());
+#print Dumper($build->prefix_relpaths());
+#print Dumper($build->installdirs());
+#print Dumper($build->install_path());
+#print Dumper($build->install_base());
+print Dumper($build);
--- a/MANIFEST.SKIP	Fri Mar 27 11:03:05 2015 +0100
+++ b/MANIFEST.SKIP	Wed Apr 01 11:19:29 2015 +0200
@@ -74,3 +74,9 @@
 
 # Avoid mercurial version control files
 ^.hg(/|(ignore|tags)$)
+
+# Avoid vi editors swap files
+\.swp$
+
+# Avoid debian source package specific files
+^debian/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/check_cert.pl	Wed Apr 01 11:19:29 2015 +0200
@@ -0,0 +1,99 @@
+#!/usr/bin/perl
+
+#    Copyright (C) 2015  Matthias Förste
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+#    Matthias Förste <foerste@schlittermann.de>
+
+=encoding utf8
+=cut
+
+use strict;
+use warnings;
+
+#use Getopt::Long;
+use Pod::Usage;
+
+use Nagios::Plugin;
+
+package Nagios::Plugin::IUS::Cert;
+$VERSION = 2.0;
+
+my $np = Nagios::Plugin->new(  
+    usage => pod2usage ( -verbose => 0, -exitval => 0)
+);
+
+GetOptions(
+    "h|help" => sub { pod2usage( -verbose => 0, -exitval => 0 ) },
+    "m|man"  => sub {
+        pod2usage(
+            -verbose   => 2,
+            -exitval   => 0,
+            -noperldoc => ( `perldoc -V 2>/dev/null`, $? != 0 )[-1]
+        );
+    },
+) or pod2usage();
+
+
+__END__
+
+=pod
+
+=head1 NAME
+
+check_cert - check ssl certificate expiry
+
+=head1 SYNOPSIS
+
+check_cert [options] [directories]
+
+check_cert -m|--man
+           -h|--help
+
+=head1 DESCRIPTION
+
+This script checks the expiry of openssl certificates.
+
+=head1 OPTIONS
+
+=over
+
+=item B<-b|--binary> I<path>
+
+Path to the openssl binary (default: /usr/bin/openssl)
+
+=item B<-w|--warning> I<time>
+
+Return status I<warning> if certificate expires in less than <time>.
+
+=item B<-w|--critical> I<time>
+
+Return status I<critical> if certificate expires in less than <time>.
+
+=back
+
+=head1 NOTES
+
+Time Ranges may be given as <number><suffix>, where <suffix> can be one of s, m, h or d for seconds, minutes, hours or days (default).
+
+=head1 FILES
+
+Any files which may be used by 'check_cert' will be listed here.
+
+=head1 AUTHOR
+
+Matthias Förste <foerste@schlittermann.de>
+
+=cut
--- a/lib/nagios/plugins/ius/check_cert	Fri Mar 27 11:03:05 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-#!/usr/bin/perl
-
-#    Copyright (C) 2015  Matthias Förste
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-#    Matthias Förste <foerste@schlittermann.de>
-
-=encoding utf8
-=cut
-
-use strict;
-use warnings;
-
-#use Getopt::Long;
-use Pod::Usage;
-
-use Nagios::Plugin;
-
-package Nagios::Plugin::IUS::Cert
-$VERSION = 2.0;
-
-my $np = Nagios::Plugin->new(  
-         usage => pod2usage ( -verbose => 0, -exitval => 0)
-     );
-
-GetOptions(
-    "h|help" => sub { pod2usage( -verbose => 0, -exitval => 0 ) },
-    "m|man"  => sub {
-        pod2usage(
-            -verbose   => 2,
-            -exitval   => 0,
-            -noperldoc => ( `perldoc -V 2>/dev/null`, $? != 0 )[-1]
-        );
-    },
-) or pod2usage();
-
-__END__
-
-=pod
-
-=head1 NAME
-
-check_cert - check ssl certificate expiry
-
-=head1 SYNOPSIS
-
-check_cert [options] [directories]
-
-check_cert -m|--man
-           -h|--help
-
-=head1 DESCRIPTION
-
-This script checks the expiry of openssl certificates.
-
-=head1 OPTIONS
-
-=over
-
-=item B<-b|--binary> I<path>
-
-Path to the openssl binary (default: /usr/bin/openssl)
-
-=item B<-w|--warning> I<time>
-
-Return status I<warning> if certificate expires in less than <time>.
-
-=item B<-w|--critical> I<time>
-
-Return status I<critical> if certificate expires in less than <time>.
-
-=back
-
-=head1 NOTES
-
-Time Ranges may be given as <number><suffix>, where <suffix> can be one of s, m, h or d for seconds, minutes, hours or days (default).
-
-=head1 FILES
-
-List or describe any files which may be used by 'check_cert' here.
-
-=head1 AUTHOR
-
-Matthias Förste <foerste@schlittermann.de>
-
-=cut