Rex-Bundle
view release on metacpan or search on metacpan
lib/Rex/Bundle.pm view on Meta::CPAN
} elsif(-f "Makefile") {
$cmd = "make test";
} else {
die("not supported");
}
_call($cmd);
die("Error $cmd") if($? != 0);
chdir($cwd);
}
sub _install {
my($dir) = @_;
my $cwd = getcwd;
chdir(_work_dir() . '/' . $dir);
my $cmd;
if(-f "Build") {
$cmd = "./Build install --install_path lib=$cwd/$install_dir --install_path arch=$cwd/$install_dir --install_path script=$cwd/$install_dir/bin --install_path bin=$cwd/$install_dir/bin --install_path bindoc=$cwd/$install_dir/man --install_path l...
} elsif(-f "Makefile") {
$cmd = "make install";
} else {
die("not supported");
}
_call($cmd);
die("Error $cmd") if($? != 0);
chdir($cwd);
}
sub _gen_rnd {
my @chars = qw(a b c d e f g h i j k l m n o p u q s t u v w x y z 0 1 2 3 4 5 6 7 8 9);
my $ret = '';
for (0..4) {
$ret .= $chars[int(rand(scalar(@chars)))];
}
$ret;
}
sub _work_dir {
return $ENV{'HOME'} . '/.rexbundle';
}
sub _get_deps {
my ($dir) = @_;
my $cwd = getcwd;
chdir(_work_dir() . '/' . $dir);
my @ret;
my $found=0;
my $meta_file = "META.yml";
if(-f "MYMETA.yml") { $meta_file = "MYMETA.yml"; }
if(-f $meta_file) {
my $yaml = eval { local(@ARGV, $/) = ($meta_file); $_=<>; $_; };
eval {
my $struct = Load($yaml);
push(@ret, $struct->{'configure_requires'});
push(@ret, $struct->{'build_requires'});
push(@ret, $struct->{'requires'});
$found=1;
};
if($@) {
print STDERR "Error parseing META.yml :(\n";
# fallback and try Makefile.PL
}
} else {
# no meta.yml found :(
print STDERR "No META.yml found :(\n";
@ret = ();
}
if(!$found) {
if(-f "Makefile.PL") {
no strict;
no warnings 'all';
my $makefile = eval { local(@ARGV, $/) = ("Makefile.PL"); <>; };
my ($hash_string) = ($makefile =~ m/WriteMakefile\((.*?)\);/ms);
my $make_hash = eval "{$hash_string}";
if(exists $make_hash->{"PREREQ_PM"}) {
push @ret, $make_hash->{"PREREQ_PM"};
}
use strict;
use warnings;
}
}
chdir($cwd);
my @needed = grep { ! /^perl$/ } grep { ! eval { my $m = $_; $m =~ s{::}{/}g; require "$m.pm"; 1;} } @ret;
print "Found following dependencies: \n";
print Dumper(\@needed);
@needed;
}
sub _clone_repo {
my($repo, $path) = @_;
my $cmd = "%s %s %s %s";
my @p = ();
if($repo =~ m/^git/) {
@p = qw(git clone);
push @p, $repo, $path;
} elsif($repo =~ m/^svn/) {
@p = qw(svn export);
push @p, $repo, $path;
} else {
die("Repositoryformat not supported: $repo");
}
my $cwd = getcwd;
chdir(_work_dir());
_call(sprintf($cmd, @p));
chdir($cwd);
}
sub _call {
my ($cmd) = @_;
$ENV{'PERL5LIB'} .= ":$rex_file_dir/$install_dir";
$ENV{'PERLLIB'} .= ":$rex_file_dir/$install_dir";
system($cmd);
}
if( ! -d _work_dir() ) {
mkdir (_work_dir(), 0755);
}
srand;
1;
( run in 0.748 second using v1.01-cache-2.11-cpan-b16cb0d3907 )