Apache-Voodoo
view release on metacpan or search on metacpan
lib/Apache/Voodoo/Install.pm view on Meta::CPAN
############################################################################
#
# Apache::Voodoo::Install - Base package for Apache::Voodoo::Install::* objects.
#
# This package provides some basic common methods needed by all the "real work"
# Apache::Voodoo::Install::* objects.
#
###########################################################################
package Apache::Voodoo::Install;
$VERSION = "3.0200";
use strict;
use warnings;
use Data::Dumper;
################################################################################
# Sets / unsets the 'pretend' run mode
################################################################################
sub pretend {
my $self = shift;
$self->{'pretend'} = shift;
}
sub _printer {
my $self = shift;
my $level = shift;
if ($self->{'verbose'} >= $level) {
foreach (@_) {
if (ref($_)) {
print Dumper $_;
}
else {
print $_,"\n";
}
}
}
}
sub mesg {
my $self = shift;
$self->_printer(0,@_);
}
sub info {
my $self = shift;
$self->_printer(1,@_);
}
sub debug {
my $self = shift;
$self->_printer(2,@_);
}
sub make_symlink {
my $self = shift;
my $source = shift;
my $target = shift;
my $pretend = $self->{'pretend'};
$self->info("- Checking symlink $target");
lstat($target);
if (-e _ && -l _ ) {
# it's there and it's a link, let's make sure it points to the correct place.
my @ss = stat($target);
my @ts = stat($source);
if ($ss[1] != $ts[1]) {
# inode's are different.
$pretend || unlink($target) || $self->{ignore} || die "Can't remove bogus link: $!";
$pretend || symlink($source,$target) || $self->{ignore} || die "Can't create symlink: $!";
$self->debug(": invalid, fixed");
( run in 2.555 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )