[Rt-commit] rt branch, 4.0/cmd-symlinks, created. rt-4.0.1rc1-8-ge2899e7

Chia-liang Kao clkao at bestpractical.com
Wed Jun 1 03:58:14 EDT 2011


The branch, 4.0/cmd-symlinks has been created
        at  e2899e7d45d41a9b8bceb64834a33167d005080a (commit)

- Log -----------------------------------------------------------------
commit 9f01f1e48c0426dc6a5e595887b117c8aaa25e11
Author: Chia-liang Kao <clkao at bestpractical.com>
Date:   Wed Jun 1 15:35:26 2011 +0800

    mark command line boilerplate

diff --git a/bin/rt-crontool.in b/bin/rt-crontool.in
index 0eb61b4..4e5a876 100755
--- a/bin/rt-crontool.in
+++ b/bin/rt-crontool.in
@@ -50,7 +50,7 @@ use strict;
 use Carp;
 
 # fix lib paths, some may be relative
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
diff --git a/sbin/rt-attributes-viewer.in b/sbin/rt-attributes-viewer.in
index de2e2cc..508304c 100644
--- a/sbin/rt-attributes-viewer.in
+++ b/sbin/rt-attributes-viewer.in
@@ -50,7 +50,7 @@ use strict;
 use warnings;
 
 # fix lib paths, some may be relative
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
diff --git a/sbin/rt-clean-sessions.in b/sbin/rt-clean-sessions.in
index 9abd855..e49d569 100644
--- a/sbin/rt-clean-sessions.in
+++ b/sbin/rt-clean-sessions.in
@@ -50,7 +50,7 @@ use strict;
 use warnings;
 
 # fix lib paths, some may be relative
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
diff --git a/sbin/rt-dump-metadata.in b/sbin/rt-dump-metadata.in
index 6232468..13a8c0e 100755
--- a/sbin/rt-dump-metadata.in
+++ b/sbin/rt-dump-metadata.in
@@ -53,7 +53,7 @@ use strict;
 binmode( STDOUT, ":utf8" );
 
 # fix lib paths, some may be relative
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
     my @libs = ( "@RT_LIB_PATH@", "@LOCAL_LIB_PATH@" );
     my $bin_path;
diff --git a/sbin/rt-email-dashboards.in b/sbin/rt-email-dashboards.in
index ffbab83..5a08e71 100644
--- a/sbin/rt-email-dashboards.in
+++ b/sbin/rt-email-dashboards.in
@@ -50,7 +50,7 @@ use strict;
 use warnings;
 
 # fix lib paths, some may be relative
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
diff --git a/sbin/rt-email-digest.in b/sbin/rt-email-digest.in
index a17c24f..894ce73 100644
--- a/sbin/rt-email-digest.in
+++ b/sbin/rt-email-digest.in
@@ -49,7 +49,7 @@
 use warnings;
 use strict;
 
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
diff --git a/sbin/rt-email-group-admin.in b/sbin/rt-email-group-admin.in
index 2b12e1d..b3f0a69 100755
--- a/sbin/rt-email-group-admin.in
+++ b/sbin/rt-email-group-admin.in
@@ -87,7 +87,7 @@ use warnings;
 use strict;
 
 # fix lib paths, some may be relative
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
diff --git a/sbin/rt-fulltext-indexer.in b/sbin/rt-fulltext-indexer.in
index 98a41a9..74242e6 100644
--- a/sbin/rt-fulltext-indexer.in
+++ b/sbin/rt-fulltext-indexer.in
@@ -51,7 +51,7 @@ use warnings;
 no warnings 'once';
 
 # fix lib paths, some may be relative
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
@@ -74,7 +74,7 @@ BEGIN {
     }
 }
 
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     use RT;
     RT::LoadConfig();
     RT::Init();
diff --git a/sbin/rt-server.in b/sbin/rt-server.in
index 022559b..c216e82 100755
--- a/sbin/rt-server.in
+++ b/sbin/rt-server.in
@@ -50,7 +50,7 @@ use warnings;
 use strict;
 
 # fix lib paths, some may be relative
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     die <<EOT if ${^TAINT};
 RT does not run under Perl's "taint mode".  Remove -T from the command
 line, or remove the PerlTaintCheck parameter from your mod_perl
diff --git a/sbin/rt-session-viewer.in b/sbin/rt-session-viewer.in
index 9881294..6c407d7 100644
--- a/sbin/rt-session-viewer.in
+++ b/sbin/rt-session-viewer.in
@@ -50,7 +50,7 @@ use strict;
 use warnings;
 
 # fix lib paths, some may be relative
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index f7ef0a0..6c46827 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -52,7 +52,7 @@ use warnings;
 use vars qw($Nobody $SystemUser $item);
 
 # fix lib paths, some may be relative
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 02d3e68..3cfcd15 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -51,7 +51,7 @@ use warnings;
 no warnings 'once';
 
 # fix lib paths, some may be relative
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
@@ -74,7 +74,7 @@ BEGIN {
     }
 }
 
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     use RT;
     RT::LoadConfig();
     RT::Init();
diff --git a/sbin/rt-shredder.in b/sbin/rt-shredder.in
index fe970d7..a0e3411 100755
--- a/sbin/rt-shredder.in
+++ b/sbin/rt-shredder.in
@@ -111,7 +111,7 @@ use strict;
 use warnings FATAL => 'all';
 
 # fix lib paths, some may be relative
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
diff --git a/sbin/rt-validator.in b/sbin/rt-validator.in
index dc79c35..1c37e01 100644
--- a/sbin/rt-validator.in
+++ b/sbin/rt-validator.in
@@ -50,7 +50,7 @@ use strict;
 use warnings;
 
 # fix lib paths, some may be relative
-BEGIN {
+BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;

commit fa58ec8d21e699a40bcfeefa8f027b26e88daa3d
Author: Chia-liang Kao <clkao at bestpractical.com>
Date:   Wed Jun 1 15:48:25 2011 +0800

    get taint check its own begin block

diff --git a/sbin/rt-server.in b/sbin/rt-server.in
index c216e82..a27d268 100755
--- a/sbin/rt-server.in
+++ b/sbin/rt-server.in
@@ -49,14 +49,16 @@
 use warnings;
 use strict;
 
-# fix lib paths, some may be relative
-BEGIN { # BEGIN RT CMD BOILERPLATE
+BEGIN {
     die <<EOT if ${^TAINT};
 RT does not run under Perl's "taint mode".  Remove -T from the command
 line, or remove the PerlTaintCheck parameter from your mod_perl
 configuration.
 EOT
+}
 
+# fix lib paths, some may be relative
+BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;

commit 577ed072f6bc1974f0f0906b3b9cbd62d8697f8d
Author: Chia-liang Kao <clkao at bestpractical.com>
Date:   Wed Jun 1 15:50:30 2011 +0800

    Use Cwd::abs_path instead of FindBin to determine the base of the binary files for libs.
    
    You can now symlink the scripts into $PATH and they will find the
    correct lib paths and work fine.  also symlink of rt-server as psgi.app
    for your psgi server to load should also find the lib paths properly.

diff --git a/devel/tools/cmd-boilerplate b/devel/tools/cmd-boilerplate
new file mode 100644
index 0000000..e13ad71
--- /dev/null
+++ b/devel/tools/cmd-boilerplate
@@ -0,0 +1,87 @@
+#!/usr/bin/env perl
+
+
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+#                                          <jesse at bestpractical.com>
+#
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
+#
+# This work is made available to you under the terms of Version 2 of
+# the GNU General Public License. A copy of that license should have
+# been provided with this software, but in any event can be snarfed
+# from www.gnu.org.
+#
+# This work is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+#
+#
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# END BPS TAGGED BLOCK }}}
+use File::Find;
+
+File::Find::find({ no_chdir => 1, wanted => \&tag_it}, 'sbin', 'bin');
+
+sub tag_it {
+        my $file = $_;
+        return unless (-f $file);
+        return if $file !~ /.in$/;
+        open( FILE, '<', $file ) or die "Failed to open $file";
+        my $content = (join "", <FILE>);
+        close (FILE);
+        my $new = q'BEGIN { # BEGIN RT CMD BOILERPLATE
+    require File::Spec;
+    require Cwd;
+    my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
+    my $bin_path;
+
+    for my $lib (@libs) {
+        unless ( File::Spec->file_name_is_absolute($lib) ) {
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
+            $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
+        }
+        unshift @INC, $lib;
+    }
+
+}';
+        unless ($content =~ s/^BEGIN \{ # BEGIN RT CMD BOILERPLATE.*?^\}$/$new/ms) {
+            return;
+        }
+
+        warn $file;
+ 
+        open( FILE, '>', $file ) or die "couldn't write new file";
+        print FILE $content;
+        close FILE;
+
+}

commit e2899e7d45d41a9b8bceb64834a33167d005080a
Author: Chia-liang Kao <clkao at bestpractical.com>
Date:   Wed Jun 1 15:53:44 2011 +0800

    update the boilerplate for all scripts

diff --git a/bin/rt-crontool.in b/bin/rt-crontool.in
index 4e5a876..0627bdc 100755
--- a/bin/rt-crontool.in
+++ b/bin/rt-crontool.in
@@ -52,21 +52,13 @@ use Carp;
 # fix lib paths, some may be relative
 BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
+    require Cwd;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
 
     for my $lib (@libs) {
         unless ( File::Spec->file_name_is_absolute($lib) ) {
-            unless ($bin_path) {
-                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
-                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
-                }
-                else {
-                    require FindBin;
-                    no warnings "once";
-                    $bin_path = $FindBin::Bin;
-                }
-            }
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
             $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
         }
         unshift @INC, $lib;
diff --git a/devel/tools/cmd-boilerplate b/devel/tools/cmd-boilerplate
old mode 100644
new mode 100755
diff --git a/sbin/rt-attributes-viewer.in b/sbin/rt-attributes-viewer.in
index 508304c..7d4b449 100644
--- a/sbin/rt-attributes-viewer.in
+++ b/sbin/rt-attributes-viewer.in
@@ -52,25 +52,18 @@ use warnings;
 # fix lib paths, some may be relative
 BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
+    require Cwd;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
 
     for my $lib (@libs) {
         unless ( File::Spec->file_name_is_absolute($lib) ) {
-            unless ($bin_path) {
-                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
-                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
-                }
-                else {
-                    require FindBin;
-                    no warnings "once";
-                    $bin_path = $FindBin::Bin;
-                }
-            }
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
             $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
         }
         unshift @INC, $lib;
     }
+
 }
 
 use Getopt::Long;
diff --git a/sbin/rt-clean-sessions.in b/sbin/rt-clean-sessions.in
index e49d569..ef0ceb6 100644
--- a/sbin/rt-clean-sessions.in
+++ b/sbin/rt-clean-sessions.in
@@ -52,25 +52,18 @@ use warnings;
 # fix lib paths, some may be relative
 BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
+    require Cwd;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
 
     for my $lib (@libs) {
         unless ( File::Spec->file_name_is_absolute($lib) ) {
-            unless ($bin_path) {
-                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
-                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
-                }
-                else {
-                    require FindBin;
-                    no warnings "once";
-                    $bin_path = $FindBin::Bin;
-                }
-            }
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
             $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
         }
         unshift @INC, $lib;
     }
+
 }
 
 use Getopt::Long;
diff --git a/sbin/rt-dump-metadata.in b/sbin/rt-dump-metadata.in
index 13a8c0e..98b85fe 100755
--- a/sbin/rt-dump-metadata.in
+++ b/sbin/rt-dump-metadata.in
@@ -55,20 +55,13 @@ binmode( STDOUT, ":utf8" );
 # fix lib paths, some may be relative
 BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
-    my @libs = ( "@RT_LIB_PATH@", "@LOCAL_LIB_PATH@" );
+    require Cwd;
+    my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
 
     for my $lib (@libs) {
         unless ( File::Spec->file_name_is_absolute($lib) ) {
-            unless ($bin_path) {
-                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
-                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
-                } else {
-                    require FindBin;
-                    no warnings "once";
-                    $bin_path = $FindBin::Bin;
-                }
-            }
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
             $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
         }
         unshift @INC, $lib;
diff --git a/sbin/rt-email-dashboards.in b/sbin/rt-email-dashboards.in
index 5a08e71..5b5fd72 100644
--- a/sbin/rt-email-dashboards.in
+++ b/sbin/rt-email-dashboards.in
@@ -52,21 +52,13 @@ use warnings;
 # fix lib paths, some may be relative
 BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
+    require Cwd;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
 
     for my $lib (@libs) {
         unless ( File::Spec->file_name_is_absolute($lib) ) {
-            unless ($bin_path) {
-                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
-                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
-                }
-                else {
-                    require FindBin;
-                    no warnings "once";
-                    $bin_path = $FindBin::Bin;
-                }
-            }
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
             $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
         }
         unshift @INC, $lib;
diff --git a/sbin/rt-email-digest.in b/sbin/rt-email-digest.in
index 894ce73..feac4be 100644
--- a/sbin/rt-email-digest.in
+++ b/sbin/rt-email-digest.in
@@ -51,21 +51,13 @@ use strict;
 
 BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
+    require Cwd;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
 
     for my $lib (@libs) {
         unless ( File::Spec->file_name_is_absolute($lib) ) {
-            unless ($bin_path) {
-                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
-                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
-                }
-                else {
-                    require FindBin;
-                    no warnings "once";
-                    $bin_path = $FindBin::Bin;
-                }
-            }
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
             $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
         }
         unshift @INC, $lib;
diff --git a/sbin/rt-email-group-admin.in b/sbin/rt-email-group-admin.in
index b3f0a69..d4d4191 100755
--- a/sbin/rt-email-group-admin.in
+++ b/sbin/rt-email-group-admin.in
@@ -89,21 +89,13 @@ use strict;
 # fix lib paths, some may be relative
 BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
+    require Cwd;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
 
     for my $lib (@libs) {
         unless ( File::Spec->file_name_is_absolute($lib) ) {
-            unless ($bin_path) {
-                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
-                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
-                }
-                else {
-                    require FindBin;
-                    no warnings "once";
-                    $bin_path = $FindBin::Bin;
-                }
-            }
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
             $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
         }
         unshift @INC, $lib;
diff --git a/sbin/rt-fulltext-indexer.in b/sbin/rt-fulltext-indexer.in
index 74242e6..0d51248 100644
--- a/sbin/rt-fulltext-indexer.in
+++ b/sbin/rt-fulltext-indexer.in
@@ -53,25 +53,18 @@ no warnings 'once';
 # fix lib paths, some may be relative
 BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
+    require Cwd;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
 
     for my $lib (@libs) {
         unless ( File::Spec->file_name_is_absolute($lib) ) {
-            unless ($bin_path) {
-                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
-                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
-                }
-                else {
-                    require FindBin;
-                    no warnings "once";
-                    $bin_path = $FindBin::Bin;
-                }
-            }
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
             $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
         }
         unshift @INC, $lib;
     }
+
 }
 
 BEGIN { # BEGIN RT CMD BOILERPLATE
diff --git a/sbin/rt-server.in b/sbin/rt-server.in
index a27d268..bb4c664 100755
--- a/sbin/rt-server.in
+++ b/sbin/rt-server.in
@@ -60,21 +60,13 @@ EOT
 # fix lib paths, some may be relative
 BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
+    require Cwd;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
 
     for my $lib (@libs) {
         unless ( File::Spec->file_name_is_absolute($lib) ) {
-            unless ($bin_path) {
-                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
-                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
-                }
-                else {
-                    require FindBin;
-                    no warnings "once";
-                    $bin_path = $FindBin::Bin;
-                }
-            }
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
             $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
         }
         unshift @INC, $lib;
diff --git a/sbin/rt-session-viewer.in b/sbin/rt-session-viewer.in
index 6c407d7..f88295f 100644
--- a/sbin/rt-session-viewer.in
+++ b/sbin/rt-session-viewer.in
@@ -52,25 +52,18 @@ use warnings;
 # fix lib paths, some may be relative
 BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
+    require Cwd;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
 
     for my $lib (@libs) {
         unless ( File::Spec->file_name_is_absolute($lib) ) {
-            unless ($bin_path) {
-                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
-                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
-                }
-                else {
-                    require FindBin;
-                    no warnings "once";
-                    $bin_path = $FindBin::Bin;
-                }
-            }
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
             $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
         }
         unshift @INC, $lib;
     }
+
 }
 
 use Getopt::Long;
diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index 6c46827..ba40d21 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -54,21 +54,13 @@ use vars qw($Nobody $SystemUser $item);
 # fix lib paths, some may be relative
 BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
+    require Cwd;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
 
     for my $lib (@libs) {
         unless ( File::Spec->file_name_is_absolute($lib) ) {
-            unless ($bin_path) {
-                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
-                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
-                }
-                else {
-                    require FindBin;
-                    no warnings "once";
-                    $bin_path = $FindBin::Bin;
-                }
-            }
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
             $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
         }
         unshift @INC, $lib;
diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 3cfcd15..342887d 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -53,25 +53,18 @@ no warnings 'once';
 # fix lib paths, some may be relative
 BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
+    require Cwd;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
 
     for my $lib (@libs) {
         unless ( File::Spec->file_name_is_absolute($lib) ) {
-            unless ($bin_path) {
-                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
-                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
-                }
-                else {
-                    require FindBin;
-                    no warnings "once";
-                    $bin_path = $FindBin::Bin;
-                }
-            }
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
             $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
         }
         unshift @INC, $lib;
     }
+
 }
 
 BEGIN { # BEGIN RT CMD BOILERPLATE
diff --git a/sbin/rt-shredder.in b/sbin/rt-shredder.in
index a0e3411..fa9f047 100755
--- a/sbin/rt-shredder.in
+++ b/sbin/rt-shredder.in
@@ -113,21 +113,13 @@ use warnings FATAL => 'all';
 # fix lib paths, some may be relative
 BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
+    require Cwd;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
 
     for my $lib (@libs) {
         unless ( File::Spec->file_name_is_absolute($lib) ) {
-            unless ($bin_path) {
-                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
-                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
-                }
-                else {
-                    require FindBin;
-                    no warnings "once";
-                    $bin_path = $FindBin::Bin;
-                }
-            }
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
             $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
         }
         unshift @INC, $lib;
diff --git a/sbin/rt-validator.in b/sbin/rt-validator.in
index 1c37e01..bd5f696 100644
--- a/sbin/rt-validator.in
+++ b/sbin/rt-validator.in
@@ -52,21 +52,13 @@ use warnings;
 # fix lib paths, some may be relative
 BEGIN { # BEGIN RT CMD BOILERPLATE
     require File::Spec;
+    require Cwd;
     my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
     my $bin_path;
 
     for my $lib (@libs) {
         unless ( File::Spec->file_name_is_absolute($lib) ) {
-            unless ($bin_path) {
-                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
-                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
-                }
-                else {
-                    require FindBin;
-                    no warnings "once";
-                    $bin_path = $FindBin::Bin;
-                }
-            }
+            $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1];
             $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
         }
         unshift @INC, $lib;

-----------------------------------------------------------------------


More information about the Rt-commit mailing list