darcs-all 1.65 KB
Newer Older
1 2
#!/bin/sh

3 4
set -e

5 6
top_dirs="nofib testsuite"

Simon Marlow's avatar
Simon Marlow committed
7 8 9
default_repo_root="http://darcs.haskell.org/"
default_lib_repo_root=$default_repo_root/packages

10 11 12 13 14 15 16 17 18
quiet=NO

function message()
{
  if [ "$quiet" = "NO" ]; then
     echo $*
  fi
}

19 20
function darcsall()
{
21
  message "== running darcs $* at the top level"
Simon Marlow's avatar
Simon Marlow committed
22
  darcs $*
23 24
  for dir in $top_dirs; do
    if test -d $dir -a -d $dir/_darcs; then
25
	message "== running darcs $* in $dir"
Simon Marlow's avatar
Simon Marlow committed
26
	darcs $* --repodir $dir
27
    else
28
	message "== $dir not present or not a repository; skipping"
29 30
    fi
  done
Simon Marlow's avatar
Simon Marlow committed
31 32
  for pkg in `cat libraries/default-packages`; do
    if test -d libraries/$pkg; then
33
	message "== running darcs $* in libraries/$pkg"
Simon Marlow's avatar
Simon Marlow committed
34
	darcs $* --repodir libraries/$pkg
35
    else
36
	echo "warning: $pkg doesn't seem to exist, use 'darcs-all get' to get it"
37 38 39 40 41 42 43 44 45 46 47
    fi
  done
}

function darcsget()
{
  case $* in
    *--partial*) ;;
    *) echo "warning: adding --partial, to override use --complete"
  esac

Simon Marlow's avatar
Simon Marlow committed
48 49 50 51 52 53
  repo_root=`cat _darcs/prefs/defaultrepo`
  case $repo_root in
    /*) lib_repos=$repo_root/libraries;;
    *)  lib_repos=$default_lib_repo_root;;
  esac

54
  cd libraries
Simon Marlow's avatar
Simon Marlow committed
55 56 57
  for pkg in `cat default-packages`; do
    if test -d $pkg; then
	echo "warning: $pkg already present; omitting"
58
    else
Simon Marlow's avatar
Simon Marlow committed
59
	repo=$lib_repos/$pkg
60
	message "== running darcs get --partial $* $repo"
61 62 63 64 65
	darcs get --partial $* $repo
    fi
  done
}

66
if test ! -d _darcs; then
67 68 69 70
  echo "error: darcs-all must be run from the top level of the ghc tree."
  exit 1;
fi

71 72 73 74
case $* in
  *-q*) quiet=YES;;
esac

75 76
case $1 in
  get)  shift; darcsget $*;;
77 78
  # Hack around whatsnew failing if there are no changes
  w|wh|wha|what|whats|whatsn|whatsne|whatsnew) set +e; darcsall $*;;
79
  *) darcsall $*;;
80
esac