Permalink
Browse files

Add tarball syncing to darcs-all

We now use it for libffi and the mingw tarballs
  • Loading branch information...
1 parent 62f4d7c commit 5dd95594637dbb6b03bc675c032a1bf430c4b0bf @igfoo igfoo committed Oct 14, 2009
Showing with 83 additions and 1 deletion.
  1. +70 −1 darcs-all
  2. +13 −0 tarballs
View
@@ -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
@@ -132,7 +140,7 @@ sub darcsall {
@repos = <IN>;
close IN;
- REPO: foreach (@repos) {
+ foreach (@repos) {
chomp;
if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
$localpath = $1;
@@ -164,6 +172,10 @@ sub darcsall {
die "Bad line: $_";
}
}
+
+ if ($_[0] eq "pull" || $_[0] eq "pul") {
+ &sync_tarballs();
+ }
}
sub darcsget {
@@ -215,6 +227,63 @@ sub darcsget {
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 {
View
@@ -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
+

0 comments on commit 5dd9559

Please sign in to comment.