[project @ 2006-01-17 02:13:16 by wolfgang]
[ghc-hetmet.git] / darcs-all
1 #!/bin/sh
2
3 top_dirs="nofib testsuite"
4
5 default_repo_root="http://darcs.haskell.org/"
6 default_lib_repo_root=$default_repo_root/packages
7
8 function darcsall()
9 {
10   echo == running darcs $* at the top level
11   darcs $*
12   for dir in $top_dirs; do
13     if test -d $dir -a -d $dir/_darcs; then
14         echo "== running darcs $* in $dir"
15         darcs $* --repodir $dir
16     else
17         echo "== $dir not present or not a repository; skipping"
18     fi
19   done
20   for pkg in `cat libraries/default-packages`; do
21     if test -d libraries/$pkg; then
22         echo "== running darcs $* in libraries/$pkg"
23         darcs $* --repodir libraries/$pkg
24     else
25         echo "warning: $dir doesn't seem to exist, use 'darcs-all get' to get it"
26     fi
27   done
28 }
29
30 function darcsget()
31 {
32   case $* in
33     *--partial*) ;;
34     *) echo "warning: adding --partial, to override use --complete"
35   esac
36
37   repo_root=`cat _darcs/prefs/defaultrepo`
38   case $repo_root in
39     /*) lib_repos=$repo_root/libraries;;
40     *)  lib_repos=$default_lib_repo_root;;
41   esac
42
43   cd libraries
44   for pkg in `cat default-packages`; do
45     if test -d $pkg; then
46         echo "warning: $pkg already present; omitting"
47     else
48         repo=$lib_repos/$pkg
49         echo "== running darcs get --partial $* $repo"
50         darcs get --partial $* $repo
51     fi
52   done
53 }
54
55 if test ! -d _darcs -o ! -d ghc; then
56   echo "error: darcs-all must be run from the top level of the ghc tree."
57   exit 1;
58 fi
59
60 case $1 in
61   push|pull|wh*) darcsall $*;;
62   get)  shift; darcsget $*;;
63   *)    echo "syntax: ./darcs-all push|pull|whatsnew|get"; exit 1;;
64 esac