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