Pass anything through to darcs and let it do the failing on bad commands
[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 function darcsall()
11 {
12   echo == running darcs $* at the top level
13   darcs $*
14   for dir in $top_dirs; do
15     if test -d $dir -a -d $dir/_darcs; then
16         echo "== running darcs $* in $dir"
17         darcs $* --repodir $dir
18     else
19         echo "== $dir not present or not a repository; skipping"
20     fi
21   done
22   for pkg in `cat libraries/default-packages`; do
23     if test -d libraries/$pkg; then
24         echo "== running darcs $* in libraries/$pkg"
25         darcs $* --repodir libraries/$pkg
26     else
27         echo "warning: $dir doesn't seem to exist, use 'darcs-all get' to get it"
28     fi
29   done
30 }
31
32 function darcsget()
33 {
34   case $* in
35     *--partial*) ;;
36     *) echo "warning: adding --partial, to override use --complete"
37   esac
38
39   repo_root=`cat _darcs/prefs/defaultrepo`
40   case $repo_root in
41     /*) lib_repos=$repo_root/libraries;;
42     *)  lib_repos=$default_lib_repo_root;;
43   esac
44
45   cd libraries
46   for pkg in `cat default-packages`; do
47     if test -d $pkg; then
48         echo "warning: $pkg already present; omitting"
49     else
50         repo=$lib_repos/$pkg
51         echo "== running darcs get --partial $* $repo"
52         darcs get --partial $* $repo
53     fi
54   done
55 }
56
57 if test ! -d _darcs -o ! -d ghc; then
58   echo "error: darcs-all must be run from the top level of the ghc tree."
59   exit 1;
60 fi
61
62 case $1 in
63   get)  shift; darcsget $*;;
64   *) darcsall $*;;
65 esac