App-Sqitch
view release on metacpan or search on metacpan
inc/Module/Build/Sqitch.pm view on Meta::CPAN
package Module::Build::Sqitch;
use strict;
use warnings;
use Module::Build 0.35;
use base 'Module::Build';
use IO::File ();
use File::Spec ();
use Config ();
use File::Path ();
use File::Copy ();
__PACKAGE__->add_property($_) for qw(etcdir installed_etcdir);
# List one more more engines to include in a bundle install.
# --with postgres --with mysql
__PACKAGE__->add_property(with => []);
# Set dual_life to true to force dual-life modules such as Pod::Simple to be
# included in the bundle directory.
# --dual_life 1
__PACKAGE__->add_property(dual_life => 0);
sub new {
my ( $class, %p ) = @_;
if ($^O eq 'MSWin32') {
my $recs = $p{recommends} ||= {};
$recs->{$_} = 0 for qw(
Win32
Win32::Console::ANSI
Win32API::Net
);
$p{requires}{'Win32::Locale'} = 0;
$p{requires}{'Win32::ShellQuote'} = 0;
$p{requires}{'DateTime::TimeZone::Local::Win32'} = 0;
}
if (eval { require Hash::Merge; 1 } && $Hash::Merge::VERSION eq '0.298') {
warn join "\n", (
'**************************************************************',
'* You have Hash::Merge $Hash::Merge::VERSION, which is broken.',
"**************************************************************\n",
);
$p{requires}{'Hash::Merge'} = '0.299';
}
my $self = $class->SUPER::new(%p);
$self->add_build_element('etc');
$self->add_build_element('mo');
$self->add_build_element('sql');
return $self;
}
sub _getetc {
my $self = shift;
my $prefix;
if ($self->installdirs eq 'site') {
$prefix = $Config::Config{siteprefix} // $Config::Config{prefix};
} elsif ($self->installdirs eq 'vendor') {
$prefix = $Config::Config{vendorprefix} // $Config::Config{siteprefix} // $Config::Config{prefix};
} else {
$prefix = $Config::Config{prefix};
}
# Prefer the user-specified directory.
if (my $etc = $self->etcdir) {
return $etc;
}
# Use a directory under the install base (or prefix).
my @subdirs = qw(etc sqitch);
if ( my $dir = $self->install_base || $self->prefix ) {
return File::Spec->catdir( $dir, @subdirs );
}
# Go under Perl's prefix.
return File::Spec->catdir( $prefix, @subdirs );
}
sub ACTION_move_old_templates {
my $self = shift;
$self->depends_on('build');
# First, rename existing etc dir templates; They were moved in v0.980.
my $notify = 0;
my $tmpl_dir = File::Spec->catdir(
( $self->destdir ? $self->destdir : ()),
$self->_getetc,
'templates'
);
if (-e $tmpl_dir && -d _) {
# Scan for old templates, but only if we can read the directory.
if (opendir my $dh, $tmpl_dir) {
while (my $bn = readdir $dh) {
next unless $bn =~ /^(deploy|verify|revert)[.]tmpl([.]default)?$/;
my ($action, $default) = ($1, $2);
( run in 1.191 second using v1.01-cache-2.11-cpan-99c4e6809bf )