/usr/local/CPAN/List-Tuples/Build.PL
use strict ;
use warnings ;
use Module::Build;
my %all_modules ;
my @split_modules ;
my @pm_files = qw(
lib/List//Tuples.pm
);
for(@pm_files)
{
$all_modules{$_} = $_ ;
push @split_modules, $_ ;
}
sub GetVersionAndRevisionFrom
{
my ($file) = @_ ;
my $version_from = File::Spec->catfile( split '/', $file );
my $version = Module::Build->version_from_file($version_from);
if($ENV{'List-Tuples_USE_SVK_VERSION_FOR_DIST'})
{
my @svk_log = `svk log -r HEAD -q` ;
if(@svk_log)
{
my ($revision) = $svk_log[1] =~ m/^r([0-9]+):/ ;
print "using SVK revision $revision.\n" ;
return("${version}.${revision}") ;
}
else
{
print "Couldn't get SVK revision, using version from '$file'!\n" ;
return($version) ;
}
}
else
{
return($version) ;
}
}
my $code = <<'EOC'
use strict ;
use warnings ;
#~ use Data::TreeDumper ;
#~ print DumpTree \@_, 'args:' ;
sub GetVersionAndRevisionFrom
{
my ($file) = @_ ;
my $version_from = File::Spec->catfile( split '/', $file );
my $version = Module::Build->version_from_file($version_from);
if($ENV{'List-Tuples_USE_SVK_VERSION_FOR_DIST'})
{
my @svk_log = `svk log -r HEAD -q` ;
if(@svk_log)
{
my ($revision) = $svk_log[1] =~ m/^r([0-9]+):/ ;
print "using SVK revision $revision.\n" ;
return("${version}.${revision}") ;
}
else
{
print "Couldn't get SVK revision, using version from '$file'!\n" ;
return($version) ;
}
}
else
{
return($version) ;
}
}
#~ sub ACTION_
#~ {
#~ my $self = shift;
#~ print "\n";
#~ }
sub ACTION_build
{
my $self = shift;
if($ENV{'List-Tuples_USE_SVK_VERSION_FOR_DIST'})
{
my ($version) = GetVersionAndRevisionFrom('lib/List//Tuples.pm') ;
print "Generating version module ($version)\n" ;
open VERSION, '>', 'Version.pm' or die "can't generate Version module: $!\n" ;
print VERSION <<EOV ;
# version module automatically generated by the build system
package Tuples::Version ;
sub GetVersion {return '$version'} ;
1 ;
# end of generated version module
EOV
close VERSION ;
}
$self->SUPER::ACTION_build(@_);
}
#~ sub ACTION_latest
#~ {
#~ ACTION_dist(@_) ;
#~ if($ENV{'List-Tuples_USE_SVK_VERSION_FOR_DIST'})
#~ {
#~ my ($version) = GetVersionAndRevisionFrom('lib/List//Tuples.pm') ;
#~ my $source = "PerlBuildSystem-$pbs_version.tar.gz" ;
#~ my $destination = "PerlBuildSystem-latest.tar.gz" ;
#~ use Net::SCP qw(scp iscp);
#~ iscp($source, "nadim\@firewall:/var/www/localhost/htdocs/files_for_download/$destination");
#~ }
#~ }
#~ sub ACTION_dist
#~ {
#~ my $self = shift;
#~ if($ENV{'List-Tuples_USE_SVK_VERSION_FOR_DIST'})
#~ {
#~ my $have_svk = $self->do_system('svk --version');
#~ if($have_svk)
#~ {
#~ if($self->do_system('svk log -x -v > SVK_Changes'))
#~ {
#~ use File::Copy;
#~ move('SVK_Changes', 'Changes') ;
#~ }
#~ else
#~ {
#~ print "Couldn't get SVK log, 'Changes' will not be generated from SVK log!\n" ;
#~ }
#~ }
#~ else
#~ {
#~ print "SVK not found, 'Changes' will not be generated from SVK log!\n" ;
#~ }
#~ }
#~ $self->SUPER::ACTION_dist();
#~ if($ENV{'List-Tuples_USE_SVK_VERSION_FOR_DIST'})
#~ {
#~ my ($pbs_version) = GetVersionAndRevisionFrom('lib/List//Tuples.pm') ;
#~ my $source = "PerlBuildSystem-$pbs_version.tar.gz" ;
#~ my $destination = "PerlBuildSystem-bleed.tar.gz" ;
#~ use Net::SCP qw(scp iscp);
#~ iscp($source, "nadim\@firewall:/var/www/localhost/htdocs/files_for_download/$destination");
#~ }
#~ };
sub ACTION_inject
{
#~ my $self = shift;
# check cpan if mini inject is installed
# build
# from $self find how to update 02packages.details.txt.gz
die "'inject' not implemented yet!\n";
}
sub ACTION_update_cpan_mini
{
# build test and make a dist
die "'update_mini_cpan' not implemented yet!\n";
}
EOC
;
my $class = Module::Build->subclass(class => 'List::Tuples', code => $code) ;
my $build = $class->new
(
module_name => 'List::Tuples',
dist_version => GetVersionAndRevisionFrom('lib/List/Tuples.pm'),
license => 'perl',
requires =>
{
'Readonly' => 0,
'Data::Compare' => 0,
'Sub::Exporter' => 0,
'Data::TreeDumper' => 0,
'version' => 0.50,
'Carp::Diagnostics' => 0,
'Test::Block' => 0,
'Test::Dependencies' => 0,
'Test::Distribution' => 0,
'Test::Exception' => 0,
'Test::NoWarnings' => 0,
'Test::Warn' => 0,
'Test::Perl::Critic' => 0,
'Test::Pod' => 0,
'Test::Pod::Coverage' => 0,
'Test::Spelling' => 0,
'Test::Strict' => 0,
},
pm_files => \%all_modules,
autosplit => \@split_modules,
#~ script_files => 'script/xxx.pl',
dist_author => 'Khemir Nadim ibn Hamouda. <nadim@khemir.net>',
dist_abstract => 'Make tuples from lists',
);
$build->create_build_script;