use strict ; use warnings ; use Module::Build; my %all_modules ; my @split_modules ; my @pm_files = qw( lib/Eval//Context.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{'Eval-Context_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{'Eval-Context_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{'Eval-Context_USE_SVK_VERSION_FOR_DIST'}) { my ($version) = GetVersionAndRevisionFrom('lib/Eval//Context.pm') ; print "Generating version module ($version)\n" ; open VERSION, '>', 'Version.pm' or die "can't generate Version module: $!\n" ; print VERSION <SUPER::ACTION_build(@_); } #~ sub ACTION_latest #~ { #~ ACTION_dist(@_) ; #~ if($ENV{'Eval-Context_USE_SVK_VERSION_FOR_DIST'}) #~ { #~ my ($version) = GetVersionAndRevisionFrom('lib/Eval//Context.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{'Eval-Context_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{'Eval-Context_USE_SVK_VERSION_FOR_DIST'}) #~ { #~ my ($pbs_version) = GetVersionAndRevisionFrom('lib/Eval//Context.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 => 'Eval::Context', code => $code) ; my $build = $class->new ( module_name => 'Eval::Context', dist_version => GetVersionAndRevisionFrom('lib/Eval/Context.pm'), license => 'perl', requires => { 'Readonly' => 0, 'Data::Compare' => 0, 'Sub::Exporter' => 0, 'Package::Generator' => 0, 'Data::TreeDumper' => 0, 'File::Slurp' => 0, 'Sub::Install' => 0, 'Symbol' => 0, 'Safe' => 0, 'Data::Dumper' => 0, 'version' => 0.50, 'Directory::Scratch::Structured' => 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, 'Test::Output' => 0, }, pm_files => \%all_modules, autosplit => \@split_modules, #~ script_files => 'script/xxx.pl', dist_author => 'Khemir Nadim ibn Hamouda. ', dist_abstract => 'Evalute perl code in context wrapper ', ); $build->create_build_script;