ADAMK-Release

 view release on metacpan or  search on metacpan

lib/ADAMK/Release.pm  view on Meta::CPAN

	$self->shell(
		$self->bin_make,
		"manifest",
		"Error while creating the MANIFEST",
	);	
}

sub build_realclean {
	my $self = shift;

	# Clean up the distribution (always with root)
	$self->sudo(
		$self->bin_make,
		"realclean",
		'sudo make clean failed',
	);
	$self->remove( $self->dist_manifest );
}

sub build_perl {
	my $self = shift;

	# Create the Build file
	$self->shell(
		qw{ perl Build.PL },
		'Error while creating Makefile',
	);

	# Create the MANIFEST file
	$self->shell(
		"./Build",
		"manifest",
		'Error while creating the MANIFEST',
	);

	unless ( $self->no_test ) {
		# Test the distribution normally
		$self->shell(
			qw{ ./Build disttest },
			'disttest failed',
		);
	}

	# Build the tardist
	$self->shell(
		qw{ ./Build dist },
		'Error making distribution tarball',
	);

	return;
}

sub upload {
	my $self = shift;

	my $pauseid = $self->prompt("PAUSEID:");
	unless (_STRING($pauseid) and $pauseid =~ /^[A-Z]{3,}$/) {
		$self->error("Missing or invalid PAUSEID");
	}

	my $password = $self->password("Password:");
	unless (_STRING($password) and $password =~ /^\S{5,}$/) {
		$self->error("Missing or invalid CPAN password");
	}

	# Execute the upload to CPAN
	CPAN::Uploader->upload_file( $self->dist_tardist, {
		user     => $pauseid,
		password => $password,
	});
}





######################################################################
# Content and Scanning Methods

# Get the main github repository url for this release
sub dist_resource_repository {
	my $self = shift;

	return join( '',
		"https://github.com/",
		$self->github->username,
		$self->github->repository,
		'.git',
	);
}

sub makefile_pl {
	my $self = shift;
	unless ( defined $self->{makefile_pl} ) {
		my $file = $self->dist_makefile_pl;
		return undef unless -f $file;
		$self->{makefile_pl} = File::Slurp::read_file($file);
	}
	return $self->{makefile_pl};
}

sub build_pl {
	my $self = shift;
	unless ( defined $self->{build_pl} ) {
		my $file = $self->dist_build_pl;
		return undef unless -f $file;
		$self->{build_pl} = File::Slurp::read_file($file);
	}
	return $self->{build_pl};
}

sub module_doc {
	my $self = shift;
	unless ( exists $self->{module_doc} ) {
		if ( -f $self->module_pod ) {
			$self->{module_doc} = $self->module_pod;
		} else {
			$self->{module_doc} = $self->module_pm;
		}
	}
	return $self->{module_doc};
}

sub module_version {
	my $self = shift;
	unless ( $self->{module_version} ) {
		my $file    = $self->module_pm;
		my $version = Module::Extract::VERSION->parse_version_safely($file);
		unless ( $version and $version ne 'undef' ) {

lib/ADAMK/Release.pm  view on Meta::CPAN

		$self->sudo(
			"rm -rf $path",
			"Failed to remove '$path'"
		);
	}
	return 1;
}

sub sudo {
	my $self    = shift;
	my $message = pop @_;
	my $cmd     = join ' ', @_;
	my $env     = $self->env(
		ADAMK_RELEASE     => 1,
		RELEASE_TESTING   => $ENV{RELEASE_TESTING}   ? 1 : 0,
		AUTOMATED_TESTING => $ENV{AUTOMATED_TESTING} ? 1 : 0,
	);
	print "> (sudo) $cmd\n" if $self->verbose;
	my $sudo = $self->bin_sudo;
	my $rv   = ! system( "$sudo bash -c '$env $cmd'" );
	if ( $rv or ! @_ ) {
		return $rv;
	}
	$self->error($message);
}

sub shell {
	my $self    = shift;
	my $message = pop @_;
	my $cmd     = join ' ', @_;
	my $env     = $self->env(
		ADAMK_RELEASE     => 1,
		RELEASE_TESTING   => $ENV{RELEASE_TESTING}   ? 1 : 0,
		AUTOMATED_TESTING => $ENV{AUTOMATED_TESTING} ? 1 : 0,
	);
	print "> $cmd\n" if $self->verbose;
	my $rv = ! system( "$env $cmd" );
	if ( $rv or ! @_ ) {
		return $rv;
	}
	$self->error($message);
}

sub env {
	my $self = shift;
	my %env  = @_;
	join ' ', map { "$_=$env{$_}" } sort keys %env;
}

sub error {
	my $self    = shift;
	my $message = sprintf(shift, @_);
	Carp::croak($message);
}

sub prompt {
	my $self = shift;
	return IO::Prompt::Tiny::prompt(@_);
}

sub password {
	my $self     = shift;
	my $password = undef;
	if ( defined $_[0] ) {
		print "$_[0] ";
	}
	eval {
		Term::ReadKey::ReadMode('noecho');
		$password = <STDIN>;
	};
	Term::ReadKey::ReadMode(0);
	return undef if not defined $password;
	chomp($password);
	return $password;
}

1;

__END__

=head1 NAME

ADAMK::Release - 

=head1 DESCRIPTION

C<ADAMK::Release> is the backend behind the C<adamk-release> script that
is used to build distribution tarballs for modules with the minimalist
repository style.

=head1 AUTHORS

Adam Kennedy E<lt>adamk@cpan.orgE<gt>

=head1 SEE ALSO

L<http://ali.as/>

=head1 COPYRIGHT

Copyright 2013 Adam Kennedy.

This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the
LICENSE file included with this module.



( run in 1.441 second using v1.01-cache-2.11-cpan-39bf76dae61 )