Add tarball syncing to darcs-all
authorIan Lynagh <igloo@earth.li>
Wed, 14 Oct 2009 16:29:48 +0000 (16:29 +0000)
committerIan Lynagh <igloo@earth.li>
Wed, 14 Oct 2009 16:29:48 +0000 (16:29 +0000)
We now use it for libffi and the mingw tarballs

darcs-all
tarballs [new file with mode: 0644]

index cdef628..69445d0 100644 (file)
--- a/darcs-all
+++ b/darcs-all
@@ -112,6 +112,14 @@ sub warning {
     }
 }
 
     }
 }
 
+sub download {
+    my ($from, $to) = @_;
+
+    my @cmd = ("wget", $from, "-O", $to);
+    message "== running @cmd";
+    system @cmd;
+}
+
 sub darcs {
     message "== running darcs @_";
     system ("darcs", @_) == 0
 sub darcs {
     message "== running darcs @_";
     system ("darcs", @_) == 0
@@ -132,7 +140,7 @@ sub darcsall {
     @repos = <IN>;
     close IN;
 
     @repos = <IN>;
     close IN;
 
-    REPO: foreach (@repos) {
+    foreach (@repos) {
         chomp;
         if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
             $localpath = $1;
         chomp;
         if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
             $localpath = $1;
@@ -164,6 +172,10 @@ sub darcsall {
             die "Bad line: $_";
         }
     }
             die "Bad line: $_";
         }
     }
+
+    if ($_[0] eq "pull" || $_[0] eq "pul") {
+        &sync_tarballs();
+    }
 }
 
 sub darcsget {
 }
 
 sub darcsget {
@@ -215,6 +227,63 @@ sub darcsget {
             die "Bad line: $_";
         }
     }
             die "Bad line: $_";
         }
     }
+
+    &sync_tarballs();
+}
+
+sub sync_tarballs {
+    my $localpath;
+    my $localdirectory;
+    my $localfilename;
+    my $actualpath;
+    my $actualfilename;
+    my $remotepath;
+    my $path;
+    my @tarballs;
+    my %localtarballs;
+    my ($repo_base, $checked_out_tree) = getrepo();
+
+    message "== Syncing tarballs";
+
+    open IN, "< tarballs" or die "Can't open packages file";
+    @tarballs = <IN>;
+    close IN;
+
+    foreach (@tarballs) {
+        chomp;
+        if (m@^([^# ]+)/([^#/ ]+) +([^ ]+)$@) {
+            $localdirectory = $1;
+            $localfilename = $2;
+            $remotepath = $3;
+            $localpath = "$localdirectory/$localfilename";
+
+            $localtarballs{$localdirectory}{$localfilename} = 1;
+
+            if (! -e $localpath) {
+                if ($checked_out_tree) {
+                    $path = "$repo_base/$localpath";
+                }
+                else {
+                    $path = "$repo_base/$remotepath";
+                }
+                &download($path, $localpath);
+            }
+        }
+        elsif (! /^(#.*)?$/) {
+            die "Bad line: $_";
+        }
+    }
+
+    foreach $localdirectory (keys %localtarballs) {
+        FILE: foreach $actualpath (glob "$localdirectory/*.tar.gz $localdirectory/*.tar.bz2") {
+            $actualfilename = $actualpath;
+            $actualfilename =~ s#.*/##;
+            if (! defined($localtarballs{$localdirectory}{$actualfilename})) {
+                message "== Deleting $actualpath";
+                unlink $actualpath;
+            }
+        }
+    }
 }
 
 sub main {
 }
 
 sub main {
diff --git a/tarballs b/tarballs
new file mode 100644 (file)
index 0000000..5a7b72d
--- /dev/null
+++ b/tarballs
@@ -0,0 +1,13 @@
+# The format of the lines in this file is:
+#   localpath    remotepath
+# where
+#   * localpath is where to put the repository in a checked out tree,
+#   * remotepath is where the tarball is in the central repository.
+#
+# Lines that start with a '#' are comments.
+mingw/binutils-2.19.1-mingw32-bin.tar.gz    ghc-tarballs/binutils-2.19.1-mingw32-bin.tar.gz
+mingw/gcc-core-3.4.5-20060117-3.tar.gz      ghc-tarballs/gcc-core-3.4.5-20060117-3.tar.gz
+mingw/mingw-runtime-3.14.tar.gz             ghc-tarballs/mingw-runtime-3.14.tar.gz
+mingw/w32api-3.13-mingw32-dev.tar.gz        ghc-tarballs/w32api-3.13-mingw32-dev.tar.gz
+libffi/tarball/libffi-3.0.8.tar.gz          ghc-tarballs/libffi-3.0.8.tar.gz
+