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

3 4
set -e

5 6
top_dirs="nofib testsuite"

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

10 11
quiet=NO

Alec Berryman's avatar
Alec Berryman committed
12
message()
13 14 15 16 17 18
{
  if [ "$quiet" = "NO" ]; then
     echo $*
  fi
}

Alec Berryman's avatar
Alec Berryman committed
19
darcsall()
20
{
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
31
  for pkg in `cat libraries/core-packages libraries/extra-packages`; do
Simon Marlow's avatar
Simon Marlow committed
32
    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
    fi
  done
}

Alec Berryman's avatar
Alec Berryman committed
41
darcsget()
42 43 44 45 46 47
{
  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
55 56 57 58 59 60 61 62

  if test "$extra" = "YES"; then
      packages=`cat core-packages extra-packages`
  else
      packages=`cat core-packages`
  fi

  for pkg in $packages; do
Simon Marlow's avatar
Simon Marlow committed
63 64
    if test -d $pkg; then
	echo "warning: $pkg already present; omitting"
65
    else
Simon Marlow's avatar
Simon Marlow committed
66
	repo=$lib_repos/$pkg
67
	message "== running darcs get --partial $* $repo"
68 69 70 71 72
	darcs get --partial $* $repo
    fi
  done
}

73
if test ! -d _darcs -o ! -d compiler; then
74 75 76 77
  echo "error: darcs-all must be run from the top level of the ghc tree."
  exit 1;
fi

78 79 80 81
case $* in
  *-q*) quiet=YES;;
esac

82 83 84 85 86 87 88
# --extra says we grab the extra libs with 'get'.  It has no effect on
# the other commands.
extra=NO;
case $1 in
  --extra) shift; extra=YES;
esac

89 90
case $1 in
  get)  shift; darcsget $*;;
91 92
  # Hack around whatsnew failing if there are no changes
  w|wh|wha|what|whats|whatsn|whatsne|whatsnew) set +e; darcsall $*;;
93
  *) darcsall $*;;
94
esac