From 5dd95594637dbb6b03bc675c032a1bf430c4b0bf Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Wed, 14 Oct 2009 16:29:48 +0000 Subject: [PATCH] Add tarball syncing to darcs-all We now use it for libffi and the mingw tarballs --- darcs-all | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- tarballs | 13 +++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 tarballs diff --git a/darcs-all b/darcs-all index cdef628..69445d0 100644 --- 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 @@ -132,7 +140,7 @@ sub darcsall { @repos = ; 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 = ; + 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 { diff --git a/tarballs b/tarballs new file mode 100644 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 + -- 1.7.10.4