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

3 4
set -e

5 6
top_dirs="nofib testsuite"

7 8 9 10
# Figure out where to get the other repositories from,
# based on where this GHC repo came from.
defaultrepo=`cat _darcs/prefs/defaultrepo`
case $defaultrepo in
Ian Lynagh's avatar
Ian Lynagh committed
11 12
  # HTTP or SSH:
  http://* | *:*)
13 14
    defaultrepo_base="`echo $defaultrepo | sed 's!/ghc$!!'`"
    defaultrepo_lib="$defaultrepo_base"/packages;;
Ian Lynagh's avatar
Ian Lynagh committed
15
  # Local filesystem (assumes a checked-out tree):
16
  /*)
17 18
    defaultrepo_base="$defaultrepo"
    defaultrepo_lib="$defaultrepo"/libraries;;
19
esac
Simon Marlow's avatar
Simon Marlow committed
20

21 22
quiet=NO

Alec Berryman's avatar
Alec Berryman committed
23
message()
24 25
{
  if [ "$quiet" = "NO" ]; then
26
     echo "$@"
27 28 29
  fi
}

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

Alec Berryman's avatar
Alec Berryman committed
52
darcsget()
53 54
{
  case $* in
55 56 57 58 59
    *--complete*|*--partial*)
      additional_flag="" ;;
    *)
      echo "warning: adding --partial, to override use --complete"
      additional_flag="--partial" ;;
60 61
  esac

62 63 64 65 66
  if test "$nofib" = "YES"; then
    if test -d nofib; then
      echo "warning: nofib already present; omitting"
    else
      repo="$defaultrepo_base"/nofib
67 68
      message "== running darcs get $additional_flag $@ $repo"
      darcs get $additional_flag "$@" $repo
69 70 71 72 73 74 75 76
    fi
  fi

  if test "$testsuite" = "YES"; then
    if test -d testsuite; then
      echo "warning: testsuite already present; omitting"
    else
      repo="$defaultrepo_base"/testsuite
77 78
      message "== running darcs get $additional_flag $@ $repo"
      darcs get $additional_flag "$@" $repo
79 80 81
    fi
  fi

82
  cd libraries
83

84
  if test "$extra" = "YES"; then
85 86 87 88 89 90
      packages=`cat core-packages extra-packages`
  else
      packages=`cat core-packages`
  fi

  for pkg in $packages; do
91 92 93
    if test -d $pkg; then
	echo "warning: $pkg already present; omitting"
    else
94
	repo=$defaultrepo_lib/$pkg
95 96
	message "== running darcs get $additional_flag $@ $repo"
	darcs get $additional_flag "$@" $repo
97 98
    fi
  done
99 100
}

101
if test ! -d _darcs -o ! -d compiler; then
102 103 104 105
  echo "error: darcs-all must be run from the top level of the ghc tree."
  exit 1;
fi

106 107 108 109
case $* in
  *-q*) quiet=YES;;
esac

110 111
# --extra says we grab the extra libs with 'get'.  It has no effect on
# the other commands.
112 113 114 115 116 117 118 119
extra=NO
# --nofib/--testsuite tell get to also grab the respective repos.
# They have no effect on the other commands.
nofib=NO
testsuite=NO

args_done=NO

120
while [ "$args_done" = NO ]
121 122 123 124 125 126 127 128
do
    case $1 in
      --extra) shift; extra=YES;;
      --nofib) shift; nofib=YES;;
      --testsuite) shift; testsuite=YES;;
      *) args_done=YES;;
    esac
done
129

130
case $1 in
131
  get)  shift; darcsget "$@";;
132
  # Hack around whatsnew failing if there are no changes
133 134
  w|wh|wha|what|whats|whatsn|whatsne|whatsnew) set +e; darcsall "$@";;
  *) darcsall "$@";;
135
esac