Permalink
Browse files

switch Configure.pl and gen_parrot.pl to git

  • Loading branch information...
1 parent 8c0b01f commit fdbe4230886c0921eb3b686353d1a0beea7e66e6 @moritz moritz committed Nov 14, 2010
Showing with 71 additions and 20 deletions.
  1. +6 −4 Configure.pl
  2. +1 −1 build/PARROT_REVISION
  3. +33 −15 build/gen_parrot.pl
  4. +31 −0 build/lib/Rakudo/CompareRevisions.pm
View
@@ -6,6 +6,8 @@
use warnings;
use Getopt::Long;
use Cwd;
+use lib "build/lib";
+use Rakudo::CompareRevisions qw(compare_parrot_revs);
MAIN: {
my %options;
@@ -22,7 +24,6 @@
open my $REQ, "build/PARROT_REVISION"
|| die "cannot open build/PARROT_REVISION\n";
my ($reqsvn, $reqpar) = split(' ', <$REQ>);
- $reqsvn += 0;
close $REQ;
# Update/generate parrot build if needed
@@ -60,16 +61,17 @@
if (!%config) {
$parrot_errors .= "Unable to locate parrot_config\n";
}
- elsif ($reqsvn > $config{'revision'} &&
+ elsif (compare_parrot_revs($reqsvn, $config{'git_describe'}) < 0 &&
+
($reqpar eq '' || version_int($reqpar) > version_int($config{'VERSION'}))) {
- $parrot_errors .= "Parrot revision r$reqsvn required (currently r$config{'revision'})\n";
+ $parrot_errors .= "Parrot revision $reqsvn required (currently $config{'git_describe'})\n";
}
if ($parrot_errors) {
die <<"END";
===SORRY!===
$parrot_errors
-To automatically checkout (svn) and build a copy of parrot r$reqsvn,
+To automatically checkout (git) and build a copy of parrot $reqsvn,
try re-running Configure.pl with the '--gen-parrot' option.
Or, use the '--parrot-config' option to explicitly specify
the location of parrot_config to be used to build NQP.
@@ -1 +1 @@
-49077
+RELEASE_2_9_1-261-g495feaf
View
@@ -21,57 +21,69 @@ =head2 DESCRIPTION
use warnings;
use 5.008;
+use lib "build/lib";
+use Rakudo::CompareRevisions qw(compare_parrot_revs);
+
# Work out slash character to use.
my $slash = $^O eq 'MSWin32' ? '\\' : '/';
## determine what revision of Parrot we require
open my $REQ, "build/PARROT_REVISION"
|| die "cannot open build/PARROT_REVISION\n";
-my ($reqsvn, $reqpar) = split(' ', <$REQ>);
-$reqsvn += 0;
+my ($req, $reqpar) = split(' ', <$REQ>);
close $REQ;
{
no warnings;
if (open my $REV, '-|', "parrot_install${slash}bin${slash}parrot_config revision") {
- my $revision = 0+<$REV>;
+ my $revision = <$REV>;
close $REV;
- if ($revision >= $reqsvn) {
- print "Parrot r$revision already available (r$reqsvn required)\n";
+ $revision =~ s/\s.*//s;
+ if (compare_parrot_revs($revision, $req) >= 0) {
+ print "Parrot $revision already available ($req required)\n";
exit(0);
}
}
}
-print "Checking out Parrot r$reqsvn via svn...\n";
-system(qw(svn checkout -r), $reqsvn , qw(https://svn.parrot.org/parrot/trunk parrot));
+print "Checking out Parrot $req via git...\n";
+if (-d 'parrot') {
+ if (-d 'parrot/.svn') {
+ die "===SORRY===\n"
+ ."Your 'parrot' directory is still an SVN repository.\n"
+ ."Parrot switched to git recently; in order to replace your\n"
+ ."repository by a git repository, please manually delete\n"
+ ."the 'parrot' directory, and then re-run the command that caused\n"
+ ."this error message\n";
+ }
+ system_or_die(qw(git fetch));
+} else {
+ system_or_die(qw(git clone git://github.com/parrot/parrot.git parrot));
+}
-chdir('parrot');
+chdir('parrot') || die "Can't chdir to 'parrot': $!";
+system_or_die(qw(git checkout), $req);
## If we have a Makefile from a previous build, do a 'make realclean'
if (-f 'Makefile') {
my %config = read_parrot_config();
my $make = $config{'make'};
if ($make) {
print "\nPerforming '$make realclean' ...\n";
- system($make, "realclean");
+ system_or_die($make, "realclean");
}
}
print "\nConfiguring Parrot ...\n";
my @config_command = ($^X, 'Configure.pl', @ARGV);
print "@config_command\n";
-system @config_command;
+system_or_die( @config_command );
print "\nBuilding Parrot ...\n";
my %config = read_parrot_config();
my $make = $config{'make'} or exit(1);
-my @make_opts;
-if ($ENV{GNU_MAKE_JOBS}) {
- push @make_opts, '-j', $ENV{GNU_MAKE_JOBS}
-}
-system($make, 'install-dev', @make_opts);
+system_or_die($make, 'install-dev');
sub read_parrot_config {
my %config = ();
@@ -83,4 +95,10 @@ sub read_parrot_config {
}
%config;
}
+
+sub system_or_die {
+ my @cmd = @_;
+ system( @cmd ) == 0
+ or die "Command failed (status $?): @cmd\n";
+}
@@ -0,0 +1,31 @@
+package Rakudo::CompareRevisions;
+use strict;
+use warnings;
+
+use base qw(Exporter);
+our @EXPORT_OK = qw(compare_parrot_revs parse_parrot_git_describe);
+
+sub parse_parrot_git_describe {
+ my $g = shift;
+ my $sep = qr/[_\W]/;
+ $g =~ /^REL(?:EASE)?$sep(\d+)$sep(\d+)$sep(\d+)(?:-(\d+)-g[a-f0-9]*)?$/
+ or die "Invalid revision specifier: '$g' "
+ ."(expected something of format RELEASE_1_2_3-123-gdeadbee)\n";
+ my @c = ($1, $2, $3, $4 || 0);
+ return @c;
+}
+
+sub compare_parrot_revs {
+ my ($aa, $bb) = @_;
+ return 1 if $bb =~ /^r?\d+$/;
+ return -1 if $aa =~ /^r?\d+$/;
+ my @a = parse_parrot_git_describe($aa);
+ my @b = parse_parrot_git_describe($bb);
+ for (0..3) {
+ my $cmp = $a[$_] <=> $b[$_];
+ return $cmp if $cmp;
+ }
+ return 0;
+}
+
+1;

0 comments on commit fdbe423

Please sign in to comment.