Merge branch 'master' into local-lib-scripts local-lib-scripts
Tomas Doran (t0m) [Wed, 30 Jun 2010 16:05:25 +0000 (17:05 +0100)]
Changes
Makefile.PL
script/bootstrap.pl [new file with mode: 0644]
script/env [new file with mode: 0755]
script/gitalist_cgi.pl
script/gitalist_create.pl
script/gitalist_fastcgi.pl
script/gitalist_server.pl
script/gitalist_test.pl

diff --git a/Changes b/Changes
index 7fa45d9..bce8db3 100644 (file)
--- a/Changes
+++ b/Changes
@@ -72,6 +72,7 @@ This file documents the revision history for Perl extension Gitalist.
     - Fix Makefile.PL to not need release deps when checking out of Git.
 
 0.000005 2010-01-09
+    - Require Git::PurePerl for Win32 compatibility.
     - Switch to IPC::Run::start for streamed mode, fixing RT#52658
       and the tests with FreeBSD.
     - Require new FCGI release in the FCGI script for upstream bug fixes.
@@ -94,6 +95,7 @@ This file documents the revision history for Perl extension Gitalist.
     - Decode getpwuid values correctly (Dagfinn Ilmari MannsÃ¥ker)
     - Generate correct provides information in META.yml so that search.cpan
       indexes the classes contained in Gitalist correctly.
+    - Dropped the dependency on File::Stat::ModeString
 
 0.000003 2009-12-09
     - Officially switch repository to Shadowcat
@@ -101,7 +103,6 @@ This file documents the revision history for Perl extension Gitalist.
     - Start streamlining and generally rejiging the layout.
     - Hacked in syntax highlighting to the blame view.
     - Further tweaks to the blame view, making it more informative.
-    - Dropped the dependency on File::Stat::ModeString
     - Move all POD below the code, for ::Repo and ::Project.
 
 0.000002 2009-12-06
index 3cdcbcd..6b85edf 100644 (file)
@@ -1,4 +1,6 @@
 #!/usr/bin/env perl
+use FindBin;
+BEGIN { do "$FindBin::Bin/script/env" or die $@ }
 
 use strict;
 use warnings;
diff --git a/script/bootstrap.pl b/script/bootstrap.pl
new file mode 100644 (file)
index 0000000..16a10ed
--- /dev/null
@@ -0,0 +1,78 @@
+#!/usr/bin/env perl
+
+# This script installs an initial local::lib into your application directory
+# named local-lib5, which automatically turns on local::lib support by default.
+
+# Needs to be run as script/bootstrap.pl
+
+# Will then install Module::Install, and all of your dependencies into
+# the local lib directory created.
+
+use strict;
+use warnings;
+
+use lib;
+use FindBin;
+use CPAN;
+
+# Do not take no for an answer.
+
+$ENV{CATALYST_LOCAL_LIB}=1;
+
+# Get the base paths and setup your %ENV
+
+my $basedir;
+if (-r "$FindBin::Bin/Makefile.PL") {
+    $basedir = $FindBin::Bin;
+}
+elsif (-r "$FindBin::Bin/../Makefile.PL") {
+    $basedir = "$FindBin::Bin/..";
+}
+
+$basedir ||= '';
+my $target = "$basedir/local-lib5";
+my $lib = "$target/lib/perl5";
+
+# Start installing stuff in the target dir
+$ENV{PERL_MM_OPT} = "INSTALL_BASE=$target";
+$ENV{PERL_MM_USE_DEFAULT} = "1";
+# And allow dependency checks to find it
+lib->import("$target/lib/perl5");
+
+# Deal with the weird case that cpan has never been run before and
+# cpan wants to create a .cpan directory in /root or somewhere you
+# can't access
+
+local %CPAN::Config;
+require CPAN::HandleConfig;
+CPAN::HandleConfig->load();
+$CPAN::Config->{prefs_dir} = "~/.cpan/prefs";
+
+force(qw/install local::lib/);
+
+require local::lib; # Turn local::lib on
+local::lib->import( $target );
+
+# Become fully self contained
+$ENV{PERL5LIB} = ""; # If we used a local::lib to bootstrap, this kills it.
+
+# Sorry kane ;)
+$ENV{PERL_AUTOINSTALL_PREFER_CPAN}=1;
+$ENV{PERL_MM_OPT} .= " INSTALLMAN1DIR=none INSTALLMAN3DIR=none";
+
+require lib::core::only;
+lib::core::only->import();
+local::lib->import( $target );
+
+# Force a re-install of local::lib here to get the dependencies for local::lib
+# It requires things which ensure we have an unfucked toolchain :)
+force(qw/install local::lib/);
+
+# Install the base modules
+install('Module::Install');
+install('YAML');
+install('CPAN');
+install('Module::Install::Catalyst');
+
+print "local::lib setup, type perl Makefile.PL && make installdeps to install dependencies";
+
diff --git a/script/env b/script/env
new file mode 100755 (executable)
index 0000000..78c367e
--- /dev/null
@@ -0,0 +1,79 @@
+#!/usr/bin/env perl
+# vim: set filetype=perl:
+
+# env is a perl script similar in concept to /usr/bin/env
+
+# If you have a local-lib5 directory then this script will set it up for
+# you as it executes.
+
+# If used like /usr/bin/env then it will run other commands based on
+# your current path settings (with a local::lib environment if present)
+#
+#  e.g. script/env bash
+#
+# NOTE: This environment _IS NOT_ self contained
+
+# If included inside another perl script, then it will be a no-op if
+# a local::lib environment is not present, but if one is, it will be
+# used as a --self-contained environment, expected to contain all non-core
+# dependencies for your perl
+#
+#  e.g.
+#       use FindBin;
+#       BEGIN { do "$FindBin::Bin/env" or die $@ }
+
+# The local::lib behavior can be explicitly enabled or disabled by setting
+# the CATALYST_LOCAL_LIB enviromnent variable to true or false.
+
+use strict;
+use warnings;
+use Carp;
+use lib;
+use FindBin;
+
+my $basedir;
+if (-r "$FindBin::Bin/Makefile.PL") {
+    $basedir = $FindBin::Bin;
+}
+elsif (-r "$FindBin::Bin/../Makefile.PL") {
+    $basedir = "$FindBin::Bin/..";
+}
+
+$basedir ||= '';
+my $target = "$basedir/local-lib5";
+
+my $on = -d $target;
+$on = ! ! $ENV{CATALYST_LOCAL_LIB}
+    if (exists $ENV{CATALYST_LOCAL_LIB} and defined $ENV{CATALYST_LOCAL_LIB});
+
+Carp::confess("Could not find local-lib5 from '$FindBin::Bin'")
+    if ($on && ! length $basedir);
+
+if ( $on ) {
+    # So we can find local::lib when fully self contained
+    lib->import("$target/lib/perl5");
+
+    # . for CPAN + app dir
+    my @include = ('.', "$basedir/lib");
+
+    $ENV{PERL5LIB} = join ':', @include;
+
+    # Sorry kane ;)
+    $ENV{PERL_AUTOINSTALL_PREFER_CPAN}=1;
+
+    $ENV{PERL_MM_OPT} .= " INSTALLMAN1DIR=none INSTALLMAN3DIR=none";
+
+    require local::lib;
+    require lib::core::only;
+    lib::core::only->import();
+    local::lib->import( $target );
+}
+
+unless ( caller ) {
+    if ( @ARGV ) {
+        exec @ARGV;
+    }
+}
+
+1;
+
index 9ef29e6..4afe54e 100755 (executable)
@@ -1,5 +1,8 @@
 #!/usr/bin/env perl
 
+use FindBin;
+BEGIN { do "$FindBin::Bin/env" or die $@ }
+
 use Catalyst::ScriptRunner;
 Catalyst::ScriptRunner->run('Gitalist', 'CGI');
 
index 41cf45e..b8e3fea 100755 (executable)
@@ -1,4 +1,6 @@
 #!/usr/bin/env perl
+use FindBin;
+BEGIN { do "$FindBin::Bin/env" or die $@ }
 
 use strict;
 use warnings;
index 37f989b..6948d49 100755 (executable)
@@ -1,4 +1,6 @@
 #!/usr/bin/env perl
+use FindBin;
+BEGIN { do "$FindBin::Bin/env" or die $@ }
 
 use Catalyst::ScriptRunner;
 Catalyst::ScriptRunner->run('Gitalist','FastCGI');
index 2e60bce..37d6b1f 100755 (executable)
@@ -1,4 +1,6 @@
 #!/usr/bin/env perl
+use FindBin;
+BEGIN { do "$FindBin::Bin/env" or die $@ }
 
 BEGIN {
     $ENV{CATALYST_SCRIPT_GEN} = 40;
index 67621d5..ab28c5c 100755 (executable)
@@ -1,4 +1,6 @@
 #!/usr/bin/env perl
+use FindBin;
+BEGIN { do "$FindBin::Bin/env" or die $@ }
 
 use Catalyst::ScriptRunner;
 Catalyst::ScriptRunner->run('Gitalist','Test');