• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env bash
2
3FOSSILS_SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
4FOSSILS_YAML="$(readlink -f "$1")"
5FOSSILS_RESULTS="$2"
6
7clone_fossils_db()
8{
9    local repo="$1"
10    local commit="$2"
11    rm -rf fossils-db
12    git clone --no-checkout "$repo" fossils-db
13    (cd fossils-db; git reset "$commit" || git reset "origin/$commit")
14}
15
16query_fossils_yaml()
17{
18    python3 "$FOSSILS_SCRIPT_DIR/query_fossils_yaml.py" \
19        --file "$FOSSILS_YAML" "$@"
20}
21
22create_clean_git()
23{
24    rm -rf .clean_git
25    cp -R .git .clean_git
26}
27
28restore_clean_git()
29{
30    rm -rf .git
31    cp -R .clean_git .git
32}
33
34fetch_fossil()
35{
36    local fossil="${1//,/?}"
37    echo -n "[fetch_fossil] Fetching $1... "
38    local output=$(git lfs pull -I "$fossil" 2>&1)
39    local ret=0
40    if [[ $? -ne 0 || ! -f "$1" ]]; then
41        echo "ERROR"
42        echo "$output"
43        ret=1
44    else
45        echo "OK"
46    fi
47    restore_clean_git
48    return $ret
49}
50
51if [[ -n "$(query_fossils_yaml fossils_db_repo)" ]]; then
52    clone_fossils_db "$(query_fossils_yaml fossils_db_repo)" \
53                     "$(query_fossils_yaml fossils_db_commit)"
54    cd fossils-db
55else
56    echo "Warning: No fossils-db entry in $FOSSILS_YAML, assuming fossils-db is current directory"
57fi
58
59# During git operations various git objects get created which
60# may take up significant space. Store a clean .git instance,
61# which we restore after various git operations to keep our
62# storage consumption low.
63create_clean_git
64
65for fossil in $(query_fossils_yaml fossils)
66do
67    fetch_fossil "$fossil" || exit $?
68    fossilize-replay --num-threads 4 $fossil 1>&2 2> $FOSSILS_RESULTS/fossil_replay.txt
69    if [ $? != 0 ]; then
70        echo "Replay of $fossil failed"
71        grep "pipeline crashed or hung" $FOSSILS_RESULTS/fossil_replay.txt
72        exit 1
73    fi
74    rm $fossil
75done
76
77exit $ret
78