40460c06102b2959deefbcc8f689f69650d6120c
[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/"
8 default_lib_repo_root=$default_repo_root/packages
9
10 quiet=NO
11
12 function message()
13 {
14   if [ "$quiet" = "NO" ]; then
15      echo $*
16   fi
17 }
18
19 function darcsall()
20 {
21   message "== running darcs $* at the top level"
22   darcs $*
23   for dir in $top_dirs; do
24     if test -d $dir -a -d $dir/_darcs; then
25         message "== running darcs $* in $dir"
26         darcs $* --repodir $dir
27     else
28         message "== $dir not present or not a repository; skipping"
29     fi
30   done
31   for pkg in `cat libraries/default-packages`; do
32     if test -d libraries/$pkg; then
33         message "== running darcs $* in libraries/$pkg"
34         darcs $* --repodir libraries/$pkg
35     else
36         echo "warning: $pkg doesn't seem to exist, use 'darcs-all get' to get it"
37     fi
38   done
39 }
40
41 function darcsget()
42 {
43   case $* in
44     *--partial*) ;;
45     *) echo "warning: adding --partial, to override use --complete"
46   esac
47
48   repo_root=`cat _darcs/prefs/defaultrepo`
49   case $repo_root in
50     /*) lib_repos=$repo_root/libraries;;
51     *)  lib_repos=$default_lib_repo_root;;
52   esac
53
54   cd libraries
55   for pkg in `cat default-packages`; do
56     if test -d $pkg; then
57         echo "warning: $pkg already present; omitting"
58     else
59         repo=$lib_repos/$pkg
60         message "== running darcs get --partial $* $repo"
61         darcs get --partial $* $repo
62     fi
63   done
64 }
65
66 if test ! -d _darcs -o ! -d ghc; then
67   echo "error: darcs-all must be run from the top level of the ghc tree."
68   exit 1;
69 fi
70
71 case $* in
72   *-q*) quiet=YES;;
73 esac
74
75 case $1 in
76   get)  shift; darcsget $*;;
77   # Hack around whatsnew failing if there are no changes
78   w|wh|wha|what|whats|whatsn|whatsne|whatsnew) set +e; darcsall $*;;
79   *) darcsall $*;;
80 esac