186771ee41a24cbf2152990d8203bd7f26811bd6
[ghc-hetmet.git] / darcs-all
1 #!/bin/sh
2
3 set -e
4
5 top_dirs="nofib testsuite"
6
7 default_repo_root="http://darcs.haskell.org/ghc-6.6/"
8 default_lib_repo_root=$default_repo_root/packages
9
10 default_extra_repo_root="http://darcs.haskell.org/"
11 default_extra_lib_repo_root=$default_extra_repo_root/packages
12
13 quiet=NO
14
15 message()
16 {
17   if [ "$quiet" = "NO" ]; then
18      echo $*
19   fi
20 }
21
22 darcsall()
23 {
24   message "== running darcs $* at the top level"
25   darcs $*
26   for dir in $top_dirs; do
27     if test -d $dir -a -d $dir/_darcs; then
28         message "== running darcs $* in $dir"
29         darcs $* --repodir $dir
30     else
31         message "== $dir not present or not a repository; skipping"
32     fi
33   done
34   for pkg in `cat libraries/core-packages libraries/extra-packages`; do
35     if test -d libraries/$pkg; then
36         message "== running darcs $* in libraries/$pkg"
37         darcs $* --repodir libraries/$pkg
38     else
39         echo "warning: $pkg doesn't seem to exist, use 'darcs-all get' to get it"
40     fi
41   done
42 }
43
44 darcsget()
45 {
46   case $* in
47     *--partial*) ;;
48     *) echo "warning: adding --partial, to override use --complete"
49   esac
50
51   repo_root=`cat _darcs/prefs/defaultrepo`
52   case $repo_root in
53     /*) lib_repos=$repo_root/libraries;;
54     *)  lib_repos=$default_lib_repo_root;;
55   esac
56
57   cd libraries
58
59   for pkg in `cat core-packages`; do
60     if test -d $pkg; then
61         echo "warning: $pkg already present; omitting"
62     else
63         repo=$lib_repos/$pkg
64         message "== running darcs get --partial $* $repo"
65         darcs get --partial $* $repo
66     fi
67   done
68
69   if test "$extra" = "YES"; then
70   for pkg in `cat extra-packages`; do
71     if test -d $pkg; then
72         echo "warning: $pkg already present; omitting"
73     else
74         repo=$default_extra_lib_repo_root/$pkg
75         message "== running darcs get --partial $* $repo"
76         darcs get --partial $* $repo
77     fi
78   done
79   fi
80 }
81
82 if test ! -d _darcs -o ! -d compiler; then
83   echo "error: darcs-all must be run from the top level of the ghc tree."
84   exit 1;
85 fi
86
87 case $* in
88   *-q*) quiet=YES;;
89 esac
90
91 # --extra says we grab the extra libs with 'get'.  It has no effect on
92 # the other commands.
93 extra=NO;
94 case $1 in
95   --extra) shift; extra=YES;
96 esac
97
98 case $1 in
99   get)  shift; darcsget $*;;
100   # Hack around whatsnew failing if there are no changes
101   w|wh|wha|what|whats|whatsn|whatsne|whatsnew) set +e; darcsall $*;;
102   *) darcsall $*;;
103 esac