darcs-all 2.21 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 12
default_extra_repo_root="http://darcs.haskell.org/"
default_extra_lib_repo_root=$default_extra_repo_root/packages

13 14
quiet=NO

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

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

Alec Berryman's avatar
Alec Berryman committed
44
darcsget()
45 46 47 48 49 50
{
  case $* in
    *--partial*) ;;
    *) echo "warning: adding --partial, to override use --complete"
  esac

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

57
  cd libraries
58

59
  for pkg in `cat core-packages`; do
Simon Marlow's avatar
Simon Marlow committed
60 61
    if test -d $pkg; then
	echo "warning: $pkg already present; omitting"
62
    else
Simon Marlow's avatar
Simon Marlow committed
63
	repo=$lib_repos/$pkg
64
	message "== running darcs get --partial $* $repo"
65 66 67
	darcs get --partial $* $repo
    fi
  done
68 69 70 71 72 73 74 75 76 77 78 79

  if test "$extra" = "YES"; then
  for pkg in `cat extra-packages`; do
    if test -d $pkg; then
	echo "warning: $pkg already present; omitting"
    else
	repo=$default_extra_lib_repo_root/$pkg
	message "== running darcs get --partial $* $repo"
	darcs get --partial $* $repo
    fi
  done
  fi
80 81
}

82
if test ! -d _darcs -o ! -d compiler; then
83 84 85 86
  echo "error: darcs-all must be run from the top level of the ghc tree."
  exit 1;
fi

87 88 89 90
case $* in
  *-q*) quiet=YES;;
esac

91 92 93 94 95 96 97
# --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

98 99
case $1 in
  get)  shift; darcsget $*;;
100 101
  # Hack around whatsnew failing if there are no changes
  w|wh|wha|what|whats|whatsn|whatsne|whatsnew) set +e; darcsall $*;;
102
  *) darcsall $*;;
103
esac