-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup
executable file
·66 lines (46 loc) · 1.38 KB
/
setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl
use strict;
use warnings;
use 5.010001;
use autodie;
use File::Spec;
use File::Fetch;
# At OS X Since Mozilla::CA is not installed, warning message will be displayed.
$File::Fetch::BLACKLIST = [ qw/lwp/ ];
my $home = File::Spec->catdir( $ENV{HOME}, '.enbld' );
my $cpanm = File::Spec->catfile( $home, 'etc', 'cpanm' );
my $extlib = File::Spec->catdir( $home, 'extlib' );
clear_MYMETA();
download_cpanm() unless ( -e $cpanm );
say "=====> Install Enbld to $home.";
print "\n";
system( "/usr/bin/perl $cpanm -L $extlib ." );
print "\n";
if ( $? ) {
if ( $? == -1 ) {
die( "Failed to execute cpanm\n" );
} elsif ( $? & 127 ) {
die( "Child died with signal\n" );
} else {
die( "Installation error. Exit code:" . ( $? >> 8 ));
}
}
print << 'EOF';
=====> Finish installation.
Please add following path to PATH.
$HOME/.enbld/bin
$HOME/.enbld/sbin
$HOME/.enbld/extlib/bin
Please add following path to MANPATH.
$HOME/.enbld/share/man
$HOME/.enbld/man
EOF
sub download_cpanm {
my $ff = File::Fetch->new( uri => 'http://xrl.us/cpanm' );
my $location = File::Spec->catdir( $ENV{HOME}, '.enbld', 'etc' );
my $where = $ff->fetch( to => $location ) or die $ff->error;
}
sub clear_MYMETA {
unlink( 'MYMETA.json' ) if ( -e 'MYMETA.json' );
unlink( 'MYMETA.yml' ) if ( -e 'MYMETA.yml' );
}