ADAMK-Release
view release on metacpan or search on metacpan
lib/ADAMK/Release.pm view on Meta::CPAN
$self->github->url,
$self->github->error,
);
}
# This is total bulldozer coding, there is no reason whatsoever why
# this stuff should be in seperate methods except that it provides
# a little cleaner logical breakup, and maybe I want to subclass this
# someday or something.
$self->validate;
$self->assemble;
$self->build;
# Release the distribution
$self->upload if $self->release;
return;
}
sub validate {
my $self = shift;
unless ( $self->dist_version ) {
$self->error("Failed to find version number in main module");
}
unless ( $self->makefile_pl or $self->build_pl ) {
$self->error("Failed to find Makefile.PL or Build.PL");
}
return;
}
sub assemble {
my $self = shift;
# Create MANIFEST.SKIP
if ( -f $self->dist_manifest_add ) {
$self->shell(
$self->bin_cat,
$self->shared_manifest_skip,
$self->dist_manifest_add,
'>',
$self->dist_manifest_skip,
"Failed to merge common MANIFEST.SKIP with extra one",
);
} elsif ( not -f $self->dist_manifest ) {
$self->copy( $self->shared_manifest_skip => $self->dist_manifest_skip );
}
# Apply a default LICENSE file
unless ( -f $self->dist_license ) {
$self->copy( $self->shared_license => $self->dist_license );
}
# Add ppport.h if any XS files use it
if ( $self->find_ppport->in( $self->dist_dir ) ) {
Devel::PPPort::WriteFile( $self->dist_ppport );
}
# Copy in author tests as needed
unless ( -f $self->dist_99_author ) {
foreach my $xt ( qw{ pod.t pmv.t } ) {
next if -f catfile( $self->dist_xt, $xt );
$self->copy(
catfile( $self->shared_dir, $xt ),
catfile( $self->dist_xt, $xt ),
);
}
}
# Create the README file
unless ( -f $self->dist_readme ) {
my $dist_readme = $self->dist_readme;
my $module_pod = -f $self->module_pod ? $self->module_pod : $self->module_pm;
$self->shell(
$self->bin_cat,
$module_pod,
"| pod2text >",
$dist_readme,
"Error while generating README file '$dist_readme'",
)
}
# Localise all newlines in text files
$self->file_localize->localize( $self->dist_dir );
# Check for various unsafe things in Makefile.PL
if ( $self->makefile_pl ) {
if ( $self->makefile_pl =~ /use inc::Module::Install/ ) {
if ( $self->makefile_pl =~ /\bauto_install\b/ ) {
$self->error("Makefile.PL contains dangerous auto_install");
}
} else {
unless ( $self->makefile_pl =~ /use strict/ ) {
$self->error("Makefile.PL does not use strict");
}
unless ( $self->makefile_pl =~ /(?:use|require) \d/ ) {
$self->error("Makefile.PL does not declare a minimum Perl version");
}
}
}
# Check file permissions
foreach my $file ( sort $self->find_0644->in( $self->dist_dir ) ) {
my $mode = (stat($file))[2] & 07777;
next if $mode == 0644;
$self->shell(
$self->bin_chmod,
'0644',
$file,
"Error setting $file to 0644 permissions",
);
}
# Make sure exe files are marked with executable permissions
if ( $self->find_executable->in( $self->dist_dir ) ) {
$self->error("Found at least one .exe file without -x unix permissions");
}
# Check the Changes file
unless ( $self->no_changes ) {
lib/ADAMK/Release.pm view on Meta::CPAN
sub dist_tardist {
$_[0]->dist_file;
}
sub dist_file {
$_[0]->dist . '-' . $_[0]->dist_version . '.tar.gz';
}
sub dist_version {
$_[0]->module_version;
}
sub dist_makefile_pl {
'Makefile.PL';
}
sub dist_build_pl {
'Build.PL';
}
sub dist_changes {
'Changes';
}
sub dist_license {
'LICENSE';
}
sub dist_readme {
'README';
}
sub dist_meta_yml {
'META.yml';
}
sub dist_manifest {
'MANIFEST';
}
sub dist_manifest_skip {
'MANIFEST.SKIP';
}
sub dist_manifest_add {
'MANIFEST.SKIP.add';
}
sub dist_ppport {
'ppport.h';
}
sub dist_t {
't';
}
sub dist_data {
catdir('t', 'data');
}
sub dist_99_author {
catfile('t', '99_author.t');
}
sub dist_xt {
'xt';
}
sub module_pm {
catfile( 'lib', $_[0]->module_subpath ) . '.pm';
}
sub module_pod {
catfile( 'lib', $_[0]->module_subpath ) . '.pod';
}
sub module_subpath {
catdir( split /::/, $_[0]->module );
}
sub shared_manifest_skip {
catfile( $_[0]->shared_dir, 'MANIFEST.SKIP' );
}
sub shared_license {
catfile( $_[0]->shared_dir, 'LICENSE' );
}
sub shared_dir {
File::ShareDir::dist_dir('ADAMK-Release')
or $_[0]->error("Failed to find share directory");
}
######################################################################
# Support Methods
# Is a particular program installed, and where
sub which {
my $self = shift;
my $program = shift;
my ($location) = (`which $program`);
chomp $location;
unless ( $location ) {
$self->error("Can't find the required program '$program'. Please install it");
}
unless ( -r $location and -x $location ) {
$self->error("The required program '$program' is installed, but I do not have permission to read or execute it");
}
return $location;
}
sub copy {
my $self = shift;
my $from = shift;
my $to = shift;
File::Flat->copy( $from => $to ) and return 1;
$self->error("Failed to copy '$from' to '$to'");
}
( run in 1.300 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )