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