summaryrefslogtreecommitdiffstats
path: root/pkgs/build-support/fetchdarcs/builder.sh
blob: 4fc993be54ffe284cbd58dd5e2b0185b113fd8a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
runHook preFetch

tagtext=""
tagflags=""
# Darcs hashes are sha1 (120 bits, 40-character hex)
if [[ "$rev" =~ [a-fA-F0-9]{40} ]]; then
    tagtext="(hash $rev)"
    tagflags="--to-hash=$rev"
elif test -n "$rev"; then
    tagtext="(tag $rev)"
    tagflags="--tag=$rev"
elif test -n "$context"; then
    tagtext="(context)"
    tagflags="--context=$context"
fi

# Repository list may contain ?. No glob expansion for that.
set -o noglob

success=
for repository in $repositories; do
    echo "Trying to clone $repository $tagtext into $out …"
    if darcs clone --lazy --no-cache $tagflags "$repository" "$out"; then
        # remove metadata, because it can change
        rm -rf "$out/_darcs"
        success=1
        break
    fi
done

set +o noglob

if [ -z "$success" ]; then
    echo "Error: couldn’t clone repository from any mirror" 1>&2
    exit 1
fi

runHook postFetch