| 1 |
#------------------------------------------------------------------------------- |
| 2 |
# This file was auto-generated by Devel::MaintBlead 0.08 on |
| 3 |
# Fri Dec 7 16:00:11 2012. |
| 4 |
|
| 5 |
# can also be called from Devel::MaintBlead, we need the main:: package |
| 6 |
package main; |
| 7 |
|
| 8 |
# mark that we've run this (for testing mostly) |
| 9 |
$Devel::MaintBlead::SIZE= 5642; |
| 10 |
|
| 11 |
# huh? |
| 12 |
if ( !$LIB_TREE or !$REQUIRED ) { |
| 13 |
print STDERR <<'HUH'; |
| 14 |
|
| 15 |
Please make sure the global variables $LIB_TREE and $REQUIRED are set before |
| 16 |
using the Devel::MaintBlead module in your Makefile.PL. |
| 17 |
|
| 18 |
HUH |
| 19 |
exit 1; |
| 20 |
} |
| 21 |
|
| 22 |
# private initializations |
| 23 |
my @lib_tree= split "/", $LIB_TREE; |
| 24 |
$lib_tree[$_]= "$lib_tree[ $_ - 1 ]/$lib_tree[$_]" foreach 1 .. $#lib_tree; |
| 25 |
my @postfix= qw( blead maint ); |
| 26 |
my %maint= map { $postfix[$_] => $_ } 0 .. $#postfix; |
| 27 |
my $auto_maint= ( $] < $REQUIRED ) || 0; |
| 28 |
|
| 29 |
#------------------------------------------------------------------------------- |
| 30 |
# set up file moving primitive |
| 31 |
use File::Copy (); |
| 32 |
sub mv { |
| 33 |
if ( -e $_[1] ) { |
| 34 |
print STDERR <<"HUH"; |
| 35 |
Cowardly refusing to overwrite |
| 36 |
|
| 37 |
$_[1] |
| 38 |
|
| 39 |
from |
| 40 |
|
| 41 |
$_[0] |
| 42 |
|
| 43 |
This should not happen. Please advise the author of Devel::MaintBlead on |
| 44 |
how you managed to do this. Thank you! |
| 45 |
HUH |
| 46 |
exit 1; |
| 47 |
} |
| 48 |
|
| 49 |
return File::Copy::mv(@_); |
| 50 |
} #mv |
| 51 |
|
| 52 |
#------------------------------------------------------------------------------- |
| 53 |
# set up file moving logic |
| 54 |
# |
| 55 |
# IN: 1 "from" interpolation |
| 56 |
# 2 "to" interpolation |
| 57 |
# 3 lib_tree setting (default: $LIB_TREE) |
| 58 |
|
| 59 |
sub mv_all { |
| 60 |
my ( $from, $to, $lib_tree )= @_; |
| 61 |
|
| 62 |
# move generic files |
| 63 |
if ( !$lib_tree ) { |
| 64 |
mv "MANIFEST$from", "MANIFEST$to" |
| 65 |
or die "Could not move file MANIFEST$from -> $to: $!\n"; |
| 66 |
foreach ( map { m#/([^/\.]+\.t)$from$# } glob( "t$from/*$from" ) ) { |
| 67 |
mv "t$from/$_$from", "t$to/$_$to" |
| 68 |
or die "Could not move file t$from/$_$from -> $to: $!\n"; |
| 69 |
} |
| 70 |
|
| 71 |
# use the base lib_tree |
| 72 |
$lib_tree= $LIB_TREE; |
| 73 |
} |
| 74 |
|
| 75 |
# just make sure it exists |
| 76 |
else { |
| 77 |
mkdir "lib$to/$lib_tree"; |
| 78 |
} |
| 79 |
|
| 80 |
# move lib files here |
| 81 |
foreach ( map { m#/([^/\.]+\.pm)$from$# } |
| 82 |
glob( "lib$from/$lib_tree/*$from" ) ) { |
| 83 |
mv "lib$from/$lib_tree/$_$from", "lib$to/$lib_tree/$_$to" |
| 84 |
or die "Could not move file $lib$from/$lib_tree/$_$from -> $to: $!\n"; |
| 85 |
} |
| 86 |
|
| 87 |
# remove now possibly empty subdirectories |
| 88 |
rmdir "lib$from/$lib_tree" if $from; |
| 89 |
|
| 90 |
# move them there for all subdirs |
| 91 |
mv_all( $from, $to, "$lib_tree/$_" ) |
| 92 |
foreach map { m#/([^/]+)$# } grep { -d } glob "lib$from/$lib_tree/*"; |
| 93 |
} #mv_all |
| 94 |
|
| 95 |
#------------------------------------------------------------------------------- |
| 96 |
# unlink_all |
| 97 |
# |
| 98 |
# IN: 1 initial directory to remove files from |
| 99 |
|
| 100 |
sub unlink_all { |
| 101 |
my ($dir)= @_; |
| 102 |
|
| 103 |
# remove all files from this dir (don't care whether worked) |
| 104 |
unlink glob "$dir/*"; |
| 105 |
|
| 106 |
# recursively unlink all files in all directories |
| 107 |
unlink_all($_) |
| 108 |
foreach grep { -d } glob "$dir/*"; |
| 109 |
} #unlink_all |
| 110 |
|
| 111 |
#------------------------------------------------------------------------------- |
| 112 |
|
| 113 |
# first time running Makefile.PL |
| 114 |
if ( !-e 'pm_to_blib' ) { |
| 115 |
|
| 116 |
# set default setting |
| 117 |
$MAINT= !glob( "lib_$postfix[1]/$LIB_TREE/*" ) || 0; |
| 118 |
open( OUT, ">default" ); |
| 119 |
print OUT $postfix[$MAINT]; |
| 120 |
close OUT; |
| 121 |
} |
| 122 |
|
| 123 |
# extract override if there is one |
| 124 |
my $type; |
| 125 |
@ARGV= |
| 126 |
grep { defined $maint{$_} ? ( $type= $_, $MAINT= $maint{$_}, 0 ) : 1 } @ARGV; |
| 127 |
|
| 128 |
# we have an override |
| 129 |
if ($type) { |
| 130 |
print STDERR "Forcing to use the '$type' version of the code\n"; |
| 131 |
open( OUT, ">default" ); |
| 132 |
print OUT $postfix[$MAINT]; |
| 133 |
close OUT; |
| 134 |
} |
| 135 |
|
| 136 |
# get default setting if necessary |
| 137 |
else { |
| 138 |
open( IN, 'default' ); |
| 139 |
$MAINT= $maint{ <IN> }; |
| 140 |
close IN; |
| 141 |
} |
| 142 |
|
| 143 |
# sorry, we can't help you |
| 144 |
if ( $auto_maint and !$MAINT ) { |
| 145 |
|
| 146 |
# can't do blead, autoselect active, so go to maint |
| 147 |
if ( $ENV{AUTO_SELECT_MAINT_OR_BLEAD} ) { |
| 148 |
$MAINT=1; |
| 149 |
} |
| 150 |
|
| 151 |
# alas, can't do blead |
| 152 |
else { |
| 153 |
$REQUIRED= sprintf '%1.6f', $REQUIRED; |
| 154 |
print STDERR <<"SORRY"; |
| 155 |
|
| 156 |
This distribution requires at least Perl $REQUIRED to be installed. Since this |
| 157 |
is an older distribution, with a history spanning almost a decade, it is also |
| 158 |
available inside this distribution as a previous incarnation, which is actively |
| 159 |
maintained as well. |
| 160 |
|
| 161 |
You can install that version of this distribution by running this $0 |
| 162 |
with the additional "maint" parameter, like so: |
| 163 |
|
| 164 |
$^X $0 maint @ARGV |
| 165 |
|
| 166 |
Or you can provide an automatic selection behavior, which would automatically |
| 167 |
select and install the right version of this distribution for the version of |
| 168 |
Perl provided, by setting the AUTO_SELECT_MAINT_OR_BLEAD environment variable |
| 169 |
to a true value. On Unix-like systems like so: |
| 170 |
|
| 171 |
AUTO_SELECT_MAINT_OR_BLEAD=1 $^X $0 @ARGV |
| 172 |
|
| 173 |
Thank you for your attention. |
| 174 |
|
| 175 |
SORRY |
| 176 |
|
| 177 |
my $line= (caller)[2]; |
| 178 |
eval <<"BYEBYE" or print STDERR $@; |
| 179 |
#line $line $0 |
| 180 |
require $REQUIRED; |
| 181 |
BYEBYE |
| 182 |
exit 1; |
| 183 |
} |
| 184 |
} |
| 185 |
|
| 186 |
# create shortcuts |
| 187 |
my $this= $postfix[$MAINT]; |
| 188 |
my $that= $postfix[ !$MAINT ]; |
| 189 |
|
| 190 |
# make sure empty directories exist, 'make dist' doesn't include them |
| 191 |
foreach my $postfix (@postfix) { |
| 192 |
mkdir "lib_$postfix"; |
| 193 |
mkdir "lib_$postfix/$_" foreach @lib_tree; |
| 194 |
mkdir "t_$postfix"; |
| 195 |
} |
| 196 |
|
| 197 |
# need to move files into place |
| 198 |
if ( my @files= glob( "lib_$this/$LIB_TREE/*" ) ) { |
| 199 |
print STDERR "Moving $this files into position\n"; |
| 200 |
|
| 201 |
# move current files away |
| 202 |
mv_all( '', "_$that" ); |
| 203 |
|
| 204 |
# put files into place |
| 205 |
mv_all( "_$this", '' ); |
| 206 |
|
| 207 |
# make sure we will copy to blib |
| 208 |
unlink_all("blib/lib/$LIB_TREE/*"); |
| 209 |
} |
| 210 |
|
| 211 |
# right files already there |
| 212 |
else { |
| 213 |
print STDERR "Files for $this already in position\n"; |
| 214 |
} |