Initial l::l crap
[catagits/Gitalist.git] / script / bootstrap.pl
1 #!/usr/bin/env perl
2
3 # This script installs an initial local::lib into your application directory
4 # named local-lib5, which automatically turns on local::lib support by default.
5
6 # Needs to be run as script/bootstrap.pl
7
8 # Will then install Module::Install, and all of your dependencies into
9 # the local lib directory created.
10
11 use strict;
12 use warnings;
13
14 use lib;
15 use FindBin;
16 use CPAN;
17
18 # Do not take no for an answer.
19
20 $ENV{CATALYST_LOCAL_LIB}=1;
21
22 # Get the base paths and setup your %ENV
23
24 my $basedir;
25 if (-r "$FindBin::Bin/Makefile.PL") {
26     $basedir = $FindBin::Bin;
27 }
28 elsif (-r "$FindBin::Bin/../Makefile.PL") {
29     $basedir = "$FindBin::Bin/..";
30 }
31
32 $basedir ||= '';
33 my $target = "$basedir/local-lib5";
34 my $lib = "$target/lib/perl5";
35
36 # Start installing stuff in the target dir
37 $ENV{PERL_MM_OPT} = "INSTALL_BASE=$target";
38 $ENV{PERL_MM_USE_DEFAULT} = "1";
39 # And allow dependency checks to find it
40 lib->import("$target/lib/perl5");
41
42 # Deal with the weird case that cpan has never been run before and
43 # cpan wants to create a .cpan directory in /root or somewhere you
44 # can't access
45
46 local %CPAN::Config;
47 require CPAN::HandleConfig;
48 CPAN::HandleConfig->load();
49 $CPAN::Config->{prefs_dir} = "~/.cpan/prefs";
50
51 force(qw/install local::lib/);
52
53 require local::lib; # Turn local::lib on
54 local::lib->import( $target );
55
56 # Become fully self contained
57 $ENV{PERL5LIB} = ""; # If we used a local::lib to bootstrap, this kills it.
58
59 # Sorry kane ;)
60 $ENV{PERL_AUTOINSTALL_PREFER_CPAN}=1;
61 $ENV{PERL_MM_OPT} .= " INSTALLMAN1DIR=none INSTALLMAN3DIR=none";
62
63 local::lib->import( '--self-contained', $target );
64
65 # Force a re-install of local::lib here to get the dependencies for local::lib
66 # It requires things which ensure we have an unfucked toolchain :)
67 force(qw/install local::lib/);
68
69 # Install the base modules
70 install('Module::Install');
71 install('YAML');
72 install('CPAN');
73 install('Module::Install::Catalyst');
74
75 print "local::lib setup, type perl Makefile.PL && make installdeps to install dependencies";
76