-#!/bin/sh
-
-set -e
-
-top_dirs="nofib testsuite"
-
-default_repo_root="http://darcs.haskell.org/"
-default_lib_repo_root=$default_repo_root/packages
-
-function darcsall()
-{
- echo == running darcs $* at the top level
- darcs $*
- for dir in $top_dirs; do
- if test -d $dir -a -d $dir/_darcs; then
- echo "== running darcs $* in $dir"
- darcs $* --repodir $dir
- else
- echo "== $dir not present or not a repository; skipping"
- fi
- done
- for pkg in `cat libraries/default-packages`; do
- if test -d libraries/$pkg; then
- echo "== running darcs $* in libraries/$pkg"
- darcs $* --repodir libraries/$pkg
- else
- echo "warning: $dir doesn't seem to exist, use 'darcs-all get' to get it"
- fi
- done
+#!/usr/bin/perl -w
+
+use strict;
+
+# Usage:
+#
+# ./darcs-all [-q] [-s] [--nofib] [--testsuite] get [darcs get flags]
+# This gets the GHC core repos, if they do not already exist.
+# -q says to be quite, and -s to be silent.
+# --nofib, --testsuite also get the nofib and testsuite repos respectively
+# The darcs get flag you are most likely to want is --complete. By
+# default we pass darcs the --partial flag.
+#
+# ./darcs-all [-q] [-s] cmd [darcs cmd flags]
+# This runs the darcs "cmd" command, with any flags you give, in all
+# of the repos you have checked out. e.g.
+# ./darcs-all pull
+# ./darcs-all -q send --dry-run
+# -q says to be quite, and -s to be silent.
+
+$| = 1; # autoflush stdout after each print, to avoid output after die
+
+# Figure out where to get the other repositories from,
+# based on where this GHC repo came from.
+my $defaultrepo = `cat _darcs/prefs/defaultrepo`;
+chomp $defaultrepo;
+my $defaultrepo_base;
+my $checked_out_tree;
+
+if ($defaultrepo =~ /^...*:/) {
+ # HTTP or SSH
+ # Above regex says "at least two chars before the :", to avoid
+ # catching Win32 drives ("C:\").
+ $defaultrepo_base = $defaultrepo;
+ $defaultrepo_base =~ s#/[^/]+/?$##;
+ $checked_out_tree = 0;
+}
+elsif ($defaultrepo =~ /^\/|\.\.\/|.:(\/|\\)/) {
+ # Local filesystem, either absolute or relative path
+ # (assumes a checked-out tree):
+ $defaultrepo_base = $defaultrepo;
+ $checked_out_tree = 1;
+}
+else {
+ die "Couldn't work out defaultrepo";
+}
+
+my $verbose = 2;
+my $ignore_failure = 0;
+
+my %tags;
+
+sub message {
+ if ($verbose >= 2) {
+ print "@_\n";
+ }
+}
+
+sub warning {
+ if ($verbose >= 1) {
+ print "warning: @_\n";
+ }
+}
+
+sub darcs {
+ message "== running darcs @_";
+ system ("darcs", @_) == 0
+ or $ignore_failure
+ or die "darcs failed: $?";