Clean up library path fiddling across all scripts

This commit is contained in:
Oliver Gorwits
2014-03-11 21:40:58 +00:00
parent 58ffd7a53a
commit 47d712490e
11 changed files with 85 additions and 47 deletions

View File

@@ -1,14 +1,35 @@
#!/usr/bin/env perl
use FindBin;
FindBin::again();
use Path::Class 'dir';
use strict;
use warnings;
our $home = ($ENV{NETDISCO_HOME} || $ENV{HOME});
BEGIN {
# stuff useful locations into @INC
use FindBin;
FindBin::again();
# try to find a localenv if one isn't already in place.
if (!exists $ENV{PERL_LOCAL_LIB_ROOT}) {
use File::Spec;
my $localenv = File::Spec->catfile($FindBin::RealBin, 'localenv');
exec($localenv, $0, @ARGV) if -f $localenv;
$localenv = File::Spec->catfile($home, 'perl5', 'bin', 'localenv');
exec($localenv, $0, @ARGV) if -f $localenv;
die "Sorry, can't find libs required for App::Netdisco.\n"
if !exists $ENV{PERLBREW_PERL};
}
use Path::Class;
# stuff useful locations into @INC and $PATH
unshift @INC,
dir($FindBin::RealBin)->parent->subdir('lib')->stringify,
dir($FindBin::RealBin, 'lib')->stringify;
use Config;
$ENV{PATH} = $FindBin::RealBin . $Config{path_sep} . $ENV{PATH};
}
use App::Netdisco;