]> git.xonotic.org Git - xonotic/gmqcc.git/blob - misc/check-proj.sh
a97030ae4a2119ab09c2049755c6c717cb7a5239
[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
8 #download required things
9 download_list=$(wget -qO- ${list})
10 download_hashes=$(wget -qO- ${hashes})
11
12 download() {
13     pushd ~/.gmqcc/testsuite >> /dev/null
14     echo "$download_list" | while read -r line
15     do
16         echo "downloading $line ..."
17         wget -q "${location}/$line"
18     done
19
20     echo "$download_hashes" > ~/.gmqcc/testsuite/hashes
21     popd >> /dev/null
22 }
23
24 if [ -z "$download_list" -o -z "$download_hashes" ]; then
25     echo "failed to download required information to check projects."
26
27     if [ "$(ping -q -c1 "${host}")" ]; then
28         echo "host ${host} seems to be up but missing required files."
29         echo "please file bug report at: github.com/graphitemaster/gmqcc"
30     else
31         echo "host ${host} seems to be down, please try again later."
32     fi
33
34     echo "aborting"
35     exit 1
36 fi
37
38 # we have existing contents around
39 if [ -f ~/.gmqcc/testsuite/hashes ]; then
40     echo "$download_hashes" > /tmp/gmqcc_download_hashes
41     diff -u ~/.gmqcc/testsuite/hashes /tmp/gmqcc_download_hashes >> /dev/null
42     if [ $? -ne 0 ]; then
43         echo "consistency errors in hashes (possible update), obtaining fresh contents"
44         rm -rf ~/.gmqcc/testsuite/projects
45         rm ~/.gmqcc/testsuite/*.zip
46
47         download
48     fi
49 else
50     # do we even have the directory
51     echo "preparing project testsuite for the first time"
52     if [ ! -d ~/.gmqcc/testsuite ]; then
53         mkdir -p ~/.gmqcc/testsuite
54     fi
55
56     download
57 fi
58
59 if [ ! -d ~/.gmqcc/testsuite/projects ]; then
60     mkdir -p ~/.gmqcc/testsuite/projects
61     pushd ~/.gmqcc/testsuite/projects >> /dev/null
62     echo "$(ls ../ | cat | grep -v '^hashes$' | grep -v '^projects$')" | while read -r line
63     do
64         echo "extracting project $line"
65         mkdir "$(echo "$line" | sed 's/\(.*\)\..*/\1/')"
66         unzip -qq "../$line" -d $(echo "$line" | sed 's/\(.*\)\..*/\1/')
67     done
68     popd >> /dev/null
69 else
70     echo "previous state exists, using it"
71 fi
72
73 # compile projects in those directories
74 pushd ~/.gmqcc/testsuite/projects >> /dev/null
75 find . -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | while read -r line
76 do
77     echo -n "compiling $line..."
78     pushd "$line" >> /dev/null
79     gmqcc -std=qcc >> /dev/null
80     if [ $? -ne 0 ]; then
81         echo "error"
82     else
83         echo "success"
84     fi
85
86     popd >> /dev/null
87 done
88 popd >> /dev/null