Skip to content
This repository
Browse code

switch Configure.pl and gen_parrot.pl to git

  • Loading branch information...
commit fdbe4230886c0921eb3b686353d1a0beea7e66e6 1 parent 8c0b01f
Moritz Lenz authored November 14, 2010
10  Configure.pl
@@ -6,6 +6,8 @@
6 6
 use warnings;
7 7
 use Getopt::Long;
8 8
 use Cwd;
  9
+use lib "build/lib";
  10
+use Rakudo::CompareRevisions qw(compare_parrot_revs);
9 11
 
10 12
 MAIN: {
11 13
     my %options;
@@ -22,7 +24,6 @@
22 24
     open my $REQ, "build/PARROT_REVISION"
23 25
       || die "cannot open build/PARROT_REVISION\n";
24 26
     my ($reqsvn, $reqpar) = split(' ', <$REQ>);
25  
-    $reqsvn += 0;
26 27
     close $REQ;
27 28
 
28 29
     # Update/generate parrot build if needed
@@ -60,16 +61,17 @@
60 61
     if (!%config) {
61 62
         $parrot_errors .= "Unable to locate parrot_config\n";
62 63
     }
63  
-    elsif ($reqsvn > $config{'revision'} &&
  64
+    elsif (compare_parrot_revs($reqsvn, $config{'git_describe'}) < 0 &&
  65
+
64 66
             ($reqpar eq '' || version_int($reqpar) > version_int($config{'VERSION'}))) {
65  
-        $parrot_errors .= "Parrot revision r$reqsvn required (currently r$config{'revision'})\n";
  67
+        $parrot_errors .= "Parrot revision $reqsvn required (currently $config{'git_describe'})\n";
66 68
     }
67 69
 
68 70
     if ($parrot_errors) {
69 71
         die <<"END";
70 72
 ===SORRY!===
71 73
 $parrot_errors
72  
-To automatically checkout (svn) and build a copy of parrot r$reqsvn,
  74
+To automatically checkout (git) and build a copy of parrot $reqsvn,
73 75
 try re-running Configure.pl with the '--gen-parrot' option.
74 76
 Or, use the '--parrot-config' option to explicitly specify
75 77
 the location of parrot_config to be used to build NQP.
2  build/PARROT_REVISION
... ...
@@ -1 +1 @@
1  
-49077
  1
+RELEASE_2_9_1-261-g495feaf
48  build/gen_parrot.pl
@@ -21,33 +21,49 @@ =head2 DESCRIPTION
21 21
 use warnings;
22 22
 use 5.008;
23 23
 
  24
+use lib "build/lib";
  25
+use Rakudo::CompareRevisions qw(compare_parrot_revs);
  26
+
24 27
 #  Work out slash character to use.
25 28
 my $slash = $^O eq 'MSWin32' ? '\\' : '/';
26 29
 
27 30
 ##  determine what revision of Parrot we require
28 31
 open my $REQ, "build/PARROT_REVISION"
29 32
   || die "cannot open build/PARROT_REVISION\n";
30  
-my ($reqsvn, $reqpar) = split(' ', <$REQ>);
31  
-$reqsvn += 0;
  33
+my ($req, $reqpar) = split(' ', <$REQ>);
32 34
 close $REQ;
33 35
 
34 36
 {
35 37
     no warnings;
36 38
     if (open my $REV, '-|', "parrot_install${slash}bin${slash}parrot_config revision") {
37  
-        my $revision = 0+<$REV>;
  39
+        my $revision = <$REV>;
38 40
         close $REV;
39  
-        if ($revision >= $reqsvn) {
40  
-            print "Parrot r$revision already available (r$reqsvn required)\n";
  41
+        $revision =~ s/\s.*//s;
  42
+        if (compare_parrot_revs($revision, $req) >= 0) {
  43
+            print "Parrot $revision already available ($req required)\n";
41 44
             exit(0);
42 45
         }
43 46
     }
44 47
 }
45 48
 
46  
-print "Checking out Parrot r$reqsvn via svn...\n";
47  
-system(qw(svn checkout -r),  $reqsvn , qw(https://svn.parrot.org/parrot/trunk parrot));
  49
+print "Checking out Parrot $req via git...\n";
  50
+if (-d 'parrot') {
  51
+    if (-d 'parrot/.svn') {
  52
+        die "===SORRY===\n"
  53
+           ."Your 'parrot' directory is still an SVN repository.\n"
  54
+           ."Parrot switched to git recently; in order to replace your\n"
  55
+           ."repository by a git repository, please manually delete\n"
  56
+           ."the 'parrot' directory, and then re-run the command that caused\n"
  57
+           ."this error message\n";
  58
+    }
  59
+    system_or_die(qw(git fetch));
  60
+} else {
  61
+    system_or_die(qw(git clone git://github.com/parrot/parrot.git parrot));
  62
+}
48 63
 
49  
-chdir('parrot');
  64
+chdir('parrot') || die "Can't chdir to 'parrot': $!";
50 65
 
  66
+system_or_die(qw(git checkout),  $req);
51 67
 
52 68
 ##  If we have a Makefile from a previous build, do a 'make realclean'
53 69
 if (-f 'Makefile') {
@@ -55,23 +71,19 @@ =head2 DESCRIPTION
55 71
     my $make = $config{'make'};
56 72
     if ($make) {
57 73
         print "\nPerforming '$make realclean' ...\n";
58  
-        system($make, "realclean");
  74
+        system_or_die($make, "realclean");
59 75
     }
60 76
 }
61 77
 
62 78
 print "\nConfiguring Parrot ...\n";
63 79
 my @config_command = ($^X, 'Configure.pl', @ARGV);
64 80
 print "@config_command\n";
65  
-system @config_command;
  81
+system_or_die( @config_command );
66 82
 
67 83
 print "\nBuilding Parrot ...\n";
68 84
 my %config = read_parrot_config();
69 85
 my $make = $config{'make'} or exit(1);
70  
-my @make_opts;
71  
-if ($ENV{GNU_MAKE_JOBS}) {
72  
-    push @make_opts, '-j', $ENV{GNU_MAKE_JOBS}
73  
-}
74  
-system($make, 'install-dev', @make_opts);
  86
+system_or_die($make, 'install-dev');
75 87
 
76 88
 sub read_parrot_config {
77 89
     my %config = ();
@@ -83,4 +95,10 @@ sub read_parrot_config {
83 95
     }
84 96
     %config;
85 97
 }
  98
+    
  99
+sub system_or_die {
  100
+    my @cmd = @_;
86 101
 
  102
+    system( @cmd ) == 0
  103
+        or die "Command failed (status $?): @cmd\n";
  104
+}
31  build/lib/Rakudo/CompareRevisions.pm
... ...
@@ -0,0 +1,31 @@
  1
+package Rakudo::CompareRevisions;
  2
+use strict;
  3
+use warnings;
  4
+
  5
+use base qw(Exporter);
  6
+our @EXPORT_OK = qw(compare_parrot_revs parse_parrot_git_describe);
  7
+
  8
+sub parse_parrot_git_describe {
  9
+    my $g = shift;
  10
+    my $sep = qr/[_\W]/;
  11
+    $g =~ /^REL(?:EASE)?$sep(\d+)$sep(\d+)$sep(\d+)(?:-(\d+)-g[a-f0-9]*)?$/
  12
+        or die "Invalid revision specifier: '$g' "
  13
+               ."(expected something of format RELEASE_1_2_3-123-gdeadbee)\n";
  14
+    my @c = ($1, $2, $3, $4 || 0);
  15
+    return @c;
  16
+}
  17
+
  18
+sub compare_parrot_revs {
  19
+    my ($aa, $bb) = @_;
  20
+    return  1 if $bb =~ /^r?\d+$/;
  21
+    return -1 if $aa =~ /^r?\d+$/;
  22
+    my @a = parse_parrot_git_describe($aa);
  23
+    my @b = parse_parrot_git_describe($bb);
  24
+    for (0..3) {
  25
+        my $cmp = $a[$_] <=> $b[$_];
  26
+        return $cmp if $cmp;
  27
+    }
  28
+    return 0;
  29
+}
  30
+
  31
+1;

0 notes on commit fdbe423

Please sign in to comment.
Something went wrong with that request. Please try again.