Skip to content

Commit

Permalink
Item1126: Proper fix for this issue. LocalLib.txt is optional, but se…
Browse files Browse the repository at this point in the history
…tlib.cfg isn't. (ran perltidy -b too)

git-svn-id: http://svn.foswiki.org/trunk@2632 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OlivierRaginel authored and OlivierRaginel committed Feb 23, 2009
1 parent 43e03dc commit 25b0b37
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 28 deletions.
2 changes: 1 addition & 1 deletion core/bin/attach
Expand Up @@ -40,7 +40,7 @@ BEGIN {
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
require $setlibCfg;
}

use Foswiki;
Expand Down
2 changes: 1 addition & 1 deletion core/bin/changes
Expand Up @@ -40,7 +40,7 @@ BEGIN {
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
require $setlibCfg;
}

use Foswiki;
Expand Down
2 changes: 1 addition & 1 deletion core/bin/edit
Expand Up @@ -40,7 +40,7 @@ BEGIN {
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
require $setlibCfg;
}

use Foswiki;
Expand Down
2 changes: 1 addition & 1 deletion core/bin/login
Expand Up @@ -40,7 +40,7 @@ BEGIN {
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
require $setlibCfg;
}

use Foswiki;
Expand Down
2 changes: 1 addition & 1 deletion core/bin/logon
Expand Up @@ -40,7 +40,7 @@ BEGIN {
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
require $setlibCfg;
}

use Foswiki;
Expand Down
2 changes: 1 addition & 1 deletion core/bin/rdiff
Expand Up @@ -40,7 +40,7 @@ BEGIN {
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
require $setlibCfg;
}

use Foswiki;
Expand Down
2 changes: 1 addition & 1 deletion core/bin/rdiffauth
Expand Up @@ -40,7 +40,7 @@ BEGIN {
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
require $setlibCfg;
}

use Foswiki;
Expand Down
2 changes: 1 addition & 1 deletion core/bin/register
Expand Up @@ -40,7 +40,7 @@ BEGIN {
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
require $setlibCfg;
}

use Foswiki;
Expand Down
2 changes: 1 addition & 1 deletion core/bin/rename
Expand Up @@ -40,7 +40,7 @@ BEGIN {
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
require $setlibCfg;
}

use Foswiki;
Expand Down
2 changes: 1 addition & 1 deletion core/bin/resetpasswd
Expand Up @@ -40,7 +40,7 @@ BEGIN {
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
require $setlibCfg;
}

use Foswiki;
Expand Down
2 changes: 1 addition & 1 deletion core/bin/rest
Expand Up @@ -40,7 +40,7 @@ BEGIN {
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
require $setlibCfg;
}

use Foswiki;
Expand Down
45 changes: 29 additions & 16 deletions core/bin/setlib.cfg
Expand Up @@ -30,21 +30,29 @@
# $ENV{FOSWIKI_ASSERTS} = 1;
# to your bin/LocalLib.cfg

our $foswikiLibPath;
our @localPerlLibPath;
use strict;
use warnings;

my $LocalLib = __FILE__; # the dir where this setlib.cfg resides
# These might be defined in LocalLib.cfg
our ( $foswikiLibPath, @localPerlLibPath, $CPANBASE );
our $twikiLibPath; # For compatibility

my $LocalLib = __FILE__; # the dir where this setlib.cfg resides
$LocalLib =~ s/setlib.cfg$/LocalLib.cfg/;
require $LocalLib;
require $LocalLib if -r $LocalLib;

# if foswikiLibPath isn't defined, then see if $twikiLibPath is
# for compatibility
$foswikiLibPath = $twikiLibPath unless defined( $foswikiLibPath );
$foswikiLibPath = $twikiLibPath unless defined($foswikiLibPath);

unless (( defined ($foswikiLibPath) ) and (-e $foswikiLibPath)) {
( $foswikiLibPath ) = ($foswikiLibPath = Cwd::abs_path( "$bin/../lib" )) =~ /(.*)/;
unless ( ( defined($foswikiLibPath) ) and ( -e $foswikiLibPath ) ) {
require FindBin;
FindBin->again; # If we're running under mod_perl or the like
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
($foswikiLibPath) =
( $foswikiLibPath = Cwd::abs_path("$bin/../lib") ) =~ /(.*)/;
}
if ($foswikiLibPath eq "") {
if ( $foswikiLibPath eq "" ) {
$foswikiLibPath = "../lib";
warn "using relative path for libs - some plugins may break";
}
Expand All @@ -53,18 +61,23 @@ if ($foswikiLibPath eq "") {
my $defaultingCPANBASE = !defined($CPANBASE);
$CPANBASE = "$foswikiLibPath/CPAN/lib/" unless $CPANBASE;
if ( -e $CPANBASE ) {
require Config;
my $VER = $Config::Config{version};
my $SITEARCH = $Config::Config{archname};
push @localPerlLibPath, ( "$CPANBASE/arch", "$CPANBASE/$VER/$SITEARCH", "$CPANBASE/$VER", "$CPANBASE" );
require Config;
my $VER = $Config::Config{version};
my $SITEARCH = $Config::Config{archname};
push @localPerlLibPath,
(
"$CPANBASE/arch", "$CPANBASE/$VER/$SITEARCH",
"$CPANBASE/$VER", "$CPANBASE"
);
}

# Prepend to @INC, the Perl search path for modules
unshift @INC, $foswikiLibPath;
if ($defaultingCPANBASE) {
push @INC, @localPerlLibPath if @localPerlLibPath;
} else {
unshift @INC, @localPerlLibPath if @localPerlLibPath;
push @INC, @localPerlLibPath if @localPerlLibPath;
}
else {
unshift @INC, @localPerlLibPath if @localPerlLibPath;
}

1; # Return success for module loading
1; # Return success for module loading
2 changes: 1 addition & 1 deletion core/bin/view
Expand Up @@ -40,7 +40,7 @@ BEGIN {
my ($bin) = $FindBin::Bin =~ /^(.*)$/;
use Cwd ();
my ($setlibCfg) = Cwd::abs_path( "$bin/setlib.cfg" ) =~ /(.*)/;
eval 'require "'.$setlibCfg.'";';
require $setlibCfg;
}

use Foswiki;
Expand Down

0 comments on commit 25b0b37

Please sign in to comment.