| 1 | package PITA::Scheme::Perl5; | ||
| 2 | |||
| 3 | # Auto-sensing Perl 5 scheme. | ||
| 4 | # Use Makefile.PL or Build.PL as appropriate. | ||
| 5 | |||
| 6 | # We won't know this until AFTER the extract_package method, | ||
| 7 | # so at the end of this method we will look for the appropriate | ||
| 8 | # file and rebless ourself into the class for it. | ||
| 9 | |||
| 10 | use 5.005; | ||
| 11 | use strict; | ||
| 12 | use File::Spec (); | ||
| 13 | use File::Which (); | ||
| 14 | use PITA::Scheme::Perl (); | ||
| 15 | |||
| 16 | use vars qw{$VERSION @ISA}; | ||
| 17 | BEGIN { | ||
| 18 | $VERSION = '0.43'; | ||
| 19 | @ISA = 'PITA::Scheme::Perl'; | ||
| 20 | } | ||
| 21 | |||
| 22 | |||
| 23 | |||
| 24 | |||
| 25 | |||
| 26 | ##################################################################### | ||
| 27 | # Constructor | ||
| 28 | |||
| 29 | sub new { | ||
| 30 | my $class = shift; | ||
| 31 | my $self = $class->SUPER::new(@_); | ||
| 32 | $self; | ||
| 33 | } | ||
| 34 | |||
| 35 | |||
| 36 | |||
| 37 | |||
| 38 | |||
| 39 | ##################################################################### | ||
| 40 | # PITA::Scheme Methods | ||
| 41 | |||
| 42 | sub default_path { | ||
| 43 | File::Which::which('perl') || ''; | ||
| 44 | } | ||
| 45 | |||
| 46 | sub prepare_package { | ||
| 47 | my $self = shift; | ||
| 48 | |||
| 49 | # Do the generic unpacking | ||
| 50 | $self->SUPER::prepare_package(@_); | ||
| 51 | |||
| 52 | # Use the Makefile.PL in preference to Build.PL as it should be | ||
| 53 | # more mature than a Module::Build installer. | ||
| 54 | # Whichever one we call, it will end up called the same | ||
| 55 | # prepare_package in ::Perl. This isn't a problem, as it knows | ||
| 56 | # how to shortcut. | ||
| 57 | if ( -f $self->workarea_file('Makefile.PL') ) { | ||
| 58 | require PITA::Scheme::Perl5::Make; | ||
| 59 | bless $self, 'PITA::Scheme::Perl5::Make'; | ||
| 60 | return $self->prepare_package; | ||
| 61 | |||
| 62 | } elsif ( -f $self->workarea_file('Build.PL') ) { | ||
| 63 | require PITA::Scheme::Perl5::Make; | ||
| 64 | bless $self, 'PITA::Scheme::Perl5::Make'; | ||
| 65 | return $self->prepare_package; | ||
| 66 | |||
| 67 | } | ||
| 68 | |||
| 69 | # Doesn't have either | ||
| 70 | Carp::croak("Perl5 package contains neither Makefile.PL or Build.PL"); | ||
| 71 | } | ||
| 72 | |||
| 73 | 1; |