]> git.xonotic.org Git - xonotic/gmqcc.git/blob - misc/check-proj.sh
Don't need that, each directory already has its own progs.src
[xonotic/gmqcc.git] / misc / check-proj.sh
1 #!/bin/sh
2
3 host="gmqcc.qc.to"
4 location="$host/files"
5 list="$location/files"
6 hashes="$location/hashes"
7 options="$location/options"
8
9 #download required things
10 download_list=$(wget -qO- ${list})
11 download_hashes=$(wget -qO- ${hashes})
12 download_options=$(wget -qO- ${options})
13
14 download() {
15     pushd ~/.gmqcc/testsuite >> /dev/null
16     echo "$download_list" | while read -r line
17     do
18         echo "downloading $line ..."
19         wget -q "${location}/$line"
20     done
21
22     echo "$download_hashes" > ~/.gmqcc/testsuite/hashes
23     echo "$download_options" > ~/.gmqcc/testsuite/options
24
25     popd >> /dev/null
26 }
27
28 if [ -z "$download_list" -o -z "$download_hashes" -o -z "$download_options" ]; then
29     echo "failed to download required information to check projects."
30
31     if [ "$(ping -q -c1 "${host}")" ]; then
32         echo "host ${host} seems to be up but missing required files."
33         echo "please file bug report at: github.com/graphitemaster/gmqcc"
34     else
35         echo "host ${host} seems to be down, please try again later."
36     fi
37
38     echo "aborting"
39     exit 1
40 fi
41
42 # we have existing contents around
43 if [ -f ~/.gmqcc/testsuite/hashes -a -f ~/.gmqcc/testsuite/options ]; then
44     echo "$download_hashes" > /tmp/gmqcc_download_hashes
45     echo "$download_options" > /tmp/gmqcc_download_options
46
47     diff -u ~/.gmqcc/testsuite/hashes /tmp/gmqcc_download_hashes >> /dev/null
48     check_hash=$?
49     diff -u ~/.gmqcc/testsuite/options /tmp/gmqcc_download_options >> /dev/null
50     check_opts=$?
51
52     if [ $check_hash -ne 0 -o $check_opts -ne 0 ]; then
53         echo "consistency errors in hashes (possible update), obtaining fresh contents"
54         rm -rf ~/.gmqcc/testsuite/projects
55         rm ~/.gmqcc/testsuite/*.zip
56
57         download
58     fi
59 else
60     # do we even have the directory
61     echo "preparing project testsuite for the first time"
62     if [ ! -d ~/.gmqcc/testsuite ]; then
63         mkdir -p ~/.gmqcc/testsuite
64     fi
65
66     download
67 fi
68
69 if [ ! -d ~/.gmqcc/testsuite/projects ]; then
70     mkdir -p ~/.gmqcc/testsuite/projects
71     pushd ~/.gmqcc/testsuite/projects >> /dev/null
72     echo "$(ls ../ | cat | grep -v '^hashes$' | grep -v '^projects$')" | while read -r line
73     do
74         echo "extracting project $line"
75         mkdir "$(echo "$line" | sed 's/\(.*\)\..*/\1/')"
76         unzip -qq "../$line" -d $(echo "$line" | sed 's/\(.*\)\..*/\1/')
77     done
78     popd >> /dev/null
79 else
80     echo "previous state exists, using it"
81 fi
82
83 # compile projects in those directories
84 gmqcc_bin="gmqcc"
85 env -i type gmqcc 1>/dev/null 2>&1 || {
86     if [ -f ../gmqcc ]; then
87         echo "previous build of gmqcc exists, using it"
88         gmqcc_bin="$(pwd)/../gmqcc"
89     elif [ -f ./gmqcc ]; then
90         echo "previous build of gmqcc exists, using it"
91         gmqcc_bin="$(pwd)/gmqcc"
92     else
93         echo "gmqcc not installed and previous build doesn't exist"
94         echo "please run make, or make install"
95         exit 1
96     fi
97 }
98
99 pushd ~/.gmqcc/testsuite/projects >> /dev/null
100 find . -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | while read -r line
101 do
102     echo -n "compiling $line... "
103     pushd "$line" >> /dev/null
104     "$gmqcc_bin" $(cat ../../options | grep "$line:" | awk '{print $2}') > /dev/null 2>&1
105     if [ $? -ne 0 ]; then
106         echo "error"
107     else
108         echo "success"
109     fi
110
111     popd >> /dev/null
112 done
113 popd >> /dev/null