Alien-Tidyp

 view release on metacpan or  search on metacpan

inc/My/Builder.pm  view on Meta::CPAN

package My::Builder;

use strict;
use warnings;
use base 'Module::Build';

use lib "inc";
use File::Spec::Functions qw(catfile);
use ExtUtils::Command;
use File::Fetch;
use File::Temp qw(tempdir tempfile);
use File::Path qw();
use File::ShareDir;
use Digest::SHA qw(sha1_hex);
use Archive::Extract;
use Config;
use ExtUtils::Liblist;

sub ACTION_install {
  my $self = shift;
  my $sharedir = eval {File::ShareDir::dist_dir('Alien-Tidyp')} || '';
 
  if ( -d $sharedir ) {
    print STDERR "Removing the old '$sharedir'\n";
    File::Path::rmtree($sharedir);
    File::Path::mkpath($sharedir);    
  }
 
  return $self->SUPER::ACTION_install(@_);
}


sub ACTION_code {
  my $self = shift;

  unless (-e 'build_done') {
    $self->add_to_cleanup('build_done');
    my $inst = $self->notes('installed_tidyp');
    if (defined $inst) {
      $self->config_data('config', { LIBS   => $inst->{lflags},
                                     INC    => $inst->{cflags},
                                   });
    }
    else {
      # important directories
      my $download = 'download';
      my $patches = 'patches';
      my $build_src = 'build_src';
      # we are deriving the subdir name from VERSION as we want to prevent
      # troubles when user reinstalls the newer version of Alien::Tidyp
      my $build_out = catfile('sharedir', $self->{properties}->{dist_version});
      $self->add_to_cleanup($build_out);
      $self->add_to_cleanup($build_src);

      # get sources
      my $tarball = $self->args('srctarball');
      my $dir  = $self->notes('tidyp_dir');
      my $sha1 = $self->notes('tidyp_sha1');
      my @url = @{$self->notes('tidyp_url')};
      $self->notes('tidyp_src', "$build_src/$dir");      
      my $archive;
      if ($tarball && -f $tarball) {
        $archive = $tarball;
	$self->check_sha1sum($archive, $sha1) || die "###ERROR### Checksum failed '$archive'";
      }      
      elsif ($tarball && $tarball =~ /^[a-z]+:\/\//) {
        warn "Downloading from explicit URL: '$tarball'\n" if $tarball;



( run in 1.218 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )