Created
August 5, 2010 18:09
-
-
Save tadzik/510123 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
sub notice (Str $what) { | |
say "\e[1m==> ", $what, "\e[0m"; | |
} | |
sub MAIN (Str $url) { | |
my $res; # for various run() calls | |
my $workdir = '.protominus.tmpdir'; | |
if $workdir.IO ~~ :e { | |
notice "Old $workdir exists, removing"; | |
if run "rm -rf $workdir" { | |
die "Could not remove $workdir, please do it yourself" | |
} | |
} | |
$url ~~ /(<-[\/]>+).git/; | |
my $name = $/[0]; | |
mkdir $workdir; | |
chdir $workdir; | |
notice "Cloning $name"; | |
$res = run "git clone $url"; | |
die "Failed cloning the repo!" if $res; | |
chdir $name; | |
notice 'Building'; | |
$res = run 'which ufo'; | |
if !$res { | |
run 'ufo'; | |
} else { | |
die "Oh noes, no ufo!" | |
} | |
$res = run 'make'; | |
die "Failed building the module!" if $res; | |
if 't'.IO ~~ :d { | |
notice 'Testing'; | |
$res = run 'make test'; | |
if $res { | |
die 'Testing failed, will not continue without --force' | |
} | |
} | |
notice 'Installing'; | |
run 'make install'; | |
chdir '../..'; | |
run "rm -rf $workdir"; | |
notice 'Cleaning up'; | |
} | |
sub USAGE { | |
say "Usage: protominus.pl <git repo url>" | |
} | |
# vim: ft=perl6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment