X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FHelper.pm;h=6aa714cbeffeeef98efb2484f26cb8236af545f0;hp=878dc76a80f47c28a4faaae2b0fb6caddc405146;hb=b1882228082cf4c6c231cacf16b54911b46fc22b;hpb=4e90e3c19d5c4411edb78516b07088da22a0d178 diff --git a/lib/Catalyst/Helper.pm b/lib/Catalyst/Helper.pm index 878dc76..6aa714c 100644 --- a/lib/Catalyst/Helper.pm +++ b/lib/Catalyst/Helper.pm @@ -90,7 +90,7 @@ sub mk_app { } if ( $gen_makefile ) { $self->_mk_makefile; - } + } if ( $gen_scripts ) { $self->_mk_cgi; $self->_mk_fastcgi; @@ -343,6 +343,13 @@ sub _mk_makefile { $self->{path} .= '.pm'; my $dir = $self->{dir}; $self->render_file( 'makefile', "$dir\/Makefile.PL" ); + + if ( $self->{makefile} ) { + # deprecate the old Build.PL file when regenerating Makefile.PL + $self->_deprecate_file( + File::Spec->catdir( $self->{dir}, 'Build.PL' ) + ); + } } sub _mk_readme { @@ -441,6 +448,28 @@ sub _mk_favicon { } +sub _deprecate_file { + my ( $self, $file ) = @_; + if ( -e $file ) { + my $oldcontent; + print qq/ deprecating "$file"\n/; + if ( my $f = IO::File->new("< $file") ) { + $oldcontent = join( '', (<$f>) ); + } + my $newfile = $file . '.deprecated'; + if ( my $f = IO::File->new("> $newfile") ) { + binmode $f; + print $f $oldcontent; + print qq/created "$newfile"\n/; + unlink $file; + print qq/removed "$file"\n/; + return 1; + } + Catalyst::Exception->throw( + message => qq/Couldn't create "$file", "$!"/ ); + } +} + =head1 HELPERS Helpers are classes that provide two methods.