darcs-all 1.4 KB
Newer Older
1 2
#!/bin/sh

3 4
set -e

5 6
top_dirs="nofib testsuite"

Simon Marlow's avatar
Simon Marlow committed
7 8 9
default_repo_root="http://darcs.haskell.org/"
default_lib_repo_root=$default_repo_root/packages

10 11
function darcsall()
{
Simon Marlow's avatar
Simon Marlow committed
12 13
  echo == running darcs $* at the top level
  darcs $*
14 15 16
  for dir in $top_dirs; do
    if test -d $dir -a -d $dir/_darcs; then
	echo "== running darcs $* in $dir"
Simon Marlow's avatar
Simon Marlow committed
17
	darcs $* --repodir $dir
18 19 20 21
    else
	echo "== $dir not present or not a repository; skipping"
    fi
  done
Simon Marlow's avatar
Simon Marlow committed
22 23 24 25
  for pkg in `cat libraries/default-packages`; do
    if test -d libraries/$pkg; then
	echo "== running darcs $* in libraries/$pkg"
	darcs $* --repodir libraries/$pkg
26 27 28 29 30 31 32 33 34 35 36 37 38
    else
	echo "warning: $dir doesn't seem to exist, use 'darcs-all get' to get it"
    fi
  done
}

function darcsget()
{
  case $* in
    *--partial*) ;;
    *) echo "warning: adding --partial, to override use --complete"
  esac

Simon Marlow's avatar
Simon Marlow committed
39 40 41 42 43 44
  repo_root=`cat _darcs/prefs/defaultrepo`
  case $repo_root in
    /*) lib_repos=$repo_root/libraries;;
    *)  lib_repos=$default_lib_repo_root;;
  esac

45
  cd libraries
Simon Marlow's avatar
Simon Marlow committed
46 47 48
  for pkg in `cat default-packages`; do
    if test -d $pkg; then
	echo "warning: $pkg already present; omitting"
49
    else
Simon Marlow's avatar
Simon Marlow committed
50
	repo=$lib_repos/$pkg
51 52 53 54 55 56 57 58 59 60 61 62 63
	echo "== running darcs get --partial $* $repo"
	darcs get --partial $* $repo
    fi
  done
}

if test ! -d _darcs -o ! -d ghc; then
  echo "error: darcs-all must be run from the top level of the ghc tree."
  exit 1;
fi

case $1 in
  get)  shift; darcsget $*;;
64
  *) darcsall $*;;
65
esac