summaryrefslogtreecommitdiff
path: root/darcs-all
blob: 65d661215e6c680e673273b4350334fb0cc596e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/sh

set -e

top_dirs="nofib testsuite"

# 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
  # HTTP or SSH:
  http://* | *:*)
    defaultrepo_base="`echo $defaultrepo | sed 's!/ghc$!!'`"
    defaultrepo_lib="$defaultrepo_base"/packages;;
  # Local filesystem (assumes a checked-out tree):
  /*)
    defaultrepo_base="$defaultrepo"
    defaultrepo_lib="$defaultrepo"/libraries;;
esac

quiet=NO

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

darcsall()
{
  message "== running darcs $@ at the top level"
  darcs "$@"
  for dir in $top_dirs; do
    if test -d $dir -a -d $dir/_darcs; then
	message "== running darcs $@ in $dir"
	darcs "$@" --repodir $dir
    else
	message "== $dir not present or not a repository; skipping"
    fi
  done
  for pkg in `cat libraries/core-packages libraries/extra-packages`; do
    if test -d libraries/$pkg; then
	message "== running darcs $@ in libraries/$pkg"
	darcs "$@" --repodir libraries/$pkg
    else
	echo "warning: $pkg doesn't seem to exist, use 'darcs-all get' to get it"
    fi
  done
}

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

  if test "$nofib" = "YES"; then
    if test -d nofib; then
      echo "warning: nofib already present; omitting"
    else
      repo="$defaultrepo_base"/nofib
      message "== running darcs get $additional_flag $@ $repo"
      darcs get $additional_flag "$@" $repo
    fi
  fi

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

  cd libraries

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

  for pkg in $packages; do
    if test -d $pkg; then
	echo "warning: $pkg already present; omitting"
    else
	repo=$defaultrepo_lib/$pkg
	message "== running darcs get $additional_flag $@ $repo"
	darcs get $additional_flag "$@" $repo
    fi
  done
}

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

case $* in
  *-q*) quiet=YES;;
esac

# --extra says we grab the extra libs with 'get'.  It has no effect on
# the other commands.
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

while [ "$args_done" = NO ]
do
    case $1 in
      --extra) shift; extra=YES;;
      --nofib) shift; nofib=YES;;
      --testsuite) shift; testsuite=YES;;
      *) args_done=YES;;
    esac
done

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