1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
use strict;
package inc::MY::Build;
use Module::Build;
our @ISA;
BEGIN {
push @ISA, 'Module::Build';
}
sub ACTION_distmeta
{
my $self = shift;
$self->SUPER::depends_on('distrss');
$self->SUPER::ACTION_distmeta;
}
# Override 'dist' to force a 'distcheck'
# (this is unfortunately not the default in M::B, which means it let you build
# and distribute a distribution which has an incorrect MANIFEST and lacks some
# files)
sub ACTION_dist
{
my $self = shift;
$self->SUPER::depends_on('distcheck');
$self->SUPER::ACTION_dist;
}
sub ACTION_tag
{
my $self = shift;
my $version = $self->dist_version;
my $tag = "release-$version";
my ($trunk, $repo, $revision);
local %ENV;
$ENV{LANG} = 'C';
open(my $svn_info, 'svn info|')
or die "Can't run 'svn info: $!'";
while (<$svn_info>) {
chomp;
/^URL: (.*)$/ and $trunk = $1;
}
close $svn_info;
die "'URL' not found in 'svn info' output " unless $trunk;
open($svn_info, "svn info $trunk|")
or die "Can't run 'svn info $trunk: $!'";
while (<$svn_info>) {
chomp;
/^Repository Root: (.*)$/ and $repo = $1;
/^Last Changed Rev: (\d+)/ and $revision = $1;
}
close $svn_info;
die "'Repository Root' or 'Last Changed Rev' not found in 'svn info' output " unless $repo && $revision;
# TODO Check if the tag already exists
print "Creating tag '$tag' from revision $revision\n";
my $cmd = qq|svn copy $trunk $repo/tags/$tag -m "CPAN release $version from r$revision."|;
print "$cmd\n";
if ($self->y_n("Do it?", 'n')) {
system $cmd;
} else {
printf "Abort.\n";
return 1;
}
}
sub ACTION_distrss
{
my $self = shift;
$self->do_create_Changes_RSS;
}
sub do_create_Changes_RSS
{
my $self = shift;
print "Creating Changes.{rss,yml}\n";
my %deps = (
'DateTime' => '0.53',
'Regexp::Grammars' => '1.002',
'Data::Recursive::Encode' => '0.03',
'DateTime::Format::W3CDTF' => '0.04',
'YAML' => '0.71',
'XML::RSS' => '1.47',
#'Toto' => '3',
);
my $ok = 1;
while (my ($mod, $ver) = each %deps) {
unless ($self->check_installed_version($mod, $ver)) {
$self->log_warn("missing module $mod $ver");
$ok = 0;
}
}
die "Can't build Changes.{rss,yml}" unless $ok;
#system $^X $^X, 'make-Changes-rss-2.pl';
require inc::MY::Build::Changes;
inc::MY::Build::Changes->build(dist_name => $self->dist_name);
# Prepare Changes.rss online distribution in the wiki of the Google Code
# project
require File::Spec;
my $f = File::Spec->catfile('..', $self->dist_name.".wiki", 'Changes.rss');
if (-e $f) {
require File::Copy;
File::Copy::syscopy('Changes.rss', $f);
}
}
1;
__END__
=head1 ACTIONS
=over 4
=item distrss
Creates 'Changes.rss' and 'Changes.yml' from 'Changes'.
=item tag
Makes the Subversion tag for the release.
=back
=cut
|