2 # vim: set filetype=perl:
4 # env is a perl script similar in concept to /usr/bin/env
6 # If you have a local-lib5 directory then this script will set it up for
9 # If used like /usr/bin/env then it will run other commands based on
10 # your current path settings (with a local::lib environment if present)
12 # e.g. script/env bash
14 # NOTE: This environment _IS NOT_ self contained
16 # If included inside another perl script, then it will be a no-op if
17 # a local::lib environment is not present, but if one is, it will be
18 # used as a --self-contained environment, expected to contain all non-core
19 # dependencies for your perl
23 # BEGIN { do "$FindBin::Bin/env" or die $@ }
25 # The local::lib behavior can be explicitly enabled or disabled by setting
26 # the CATALYST_LOCAL_LIB enviromnent variable to true or false.
36 # Look up to see find Makefile.PL aka the base of the local::lib install.
37 my $lookup; $lookup = sub {
38 my $dir = $_[0] || $FindBin::Bin;
40 return '' if Cwd::abs_path($dir) eq File::Spec->rootdir;
42 my $tryfile = File::Spec->catfile($dir, "Makefile.PL");
44 return -r $tryfile ? $dir : $lookup->( File::Spec->catdir($dir, File::Spec->updir) );
47 my $basedir = $lookup->();
50 my $target = "$basedir/local-lib5";
53 $on = ! ! $ENV{CATALYST_LOCAL_LIB}
54 if (exists $ENV{CATALYST_LOCAL_LIB} and defined $ENV{CATALYST_LOCAL_LIB});
56 Carp::confess("Could not find local-lib5 from '$FindBin::Bin'")
57 if ($on && ! length $basedir);
60 # So we can find local::lib when fully self contained
61 lib->import("$target/lib/perl5");
63 # . for CPAN + app dir
64 my @include = ('.', "$basedir/lib");
66 $ENV{PERL5LIB} = join ':', @include;
69 $ENV{PERL_AUTOINSTALL_PREFER_CPAN}=1;
71 $ENV{PERL_MM_OPT} .= " INSTALLMAN1DIR=none INSTALLMAN3DIR=none";
73 require lib::core::only;
75 lib::core::only->import();
76 local::lib->import( $target );