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.
37 # Look up to see find Makefile.PL aka the base of the local::lib install.
38 my $lookup; $lookup = sub {
39 my $dir = $_[0] || $FindBin::Bin;
41 return '' if Cwd::abs_path($dir) eq File::Spec->rootdir;
43 my $tryfile = File::Spec->catfile($dir, "Makefile.PL");
45 return -r $tryfile ? $dir : $lookup->( File::Spec->catdir($dir, File::Spec->updir) );
48 my $basedir = $lookup->();
51 my $target = "$basedir/local-lib5";
54 $on = ! ! $ENV{CATALYST_LOCAL_LIB}
55 if (exists $ENV{CATALYST_LOCAL_LIB} and defined $ENV{CATALYST_LOCAL_LIB});
57 Carp::confess("Could not find local-lib5 from '$FindBin::Bin'")
58 if ($on && ! length $basedir);
61 # So we can find local::lib when fully self contained
62 lib->import("$target/lib/perl5");
64 # . for CPAN + app dir
65 my @include = ('.', "$basedir/lib");
67 $ENV{PERL5LIB} = join ':', @include;
70 $ENV{PERL_AUTOINSTALL_PREFER_CPAN}=1;
72 $ENV{PERL_MM_OPT} .= " INSTALLMAN1DIR=none INSTALLMAN3DIR=none";
74 require lib::core::only;
76 lib::core::only->import();
77 local::lib->import( $target );
81 die "No local::lib configured.";