forked from arminbiere/lingeling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare-competition.sh
executable file
·144 lines (117 loc) · 2.37 KB
/
prepare-competition.sh
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/sh
if [ -t 2 ]
then
BOLD="\033[1m"
GREEN="\033[1;32m"
NORMAL="\033[0m"
RED="\033[1;31m"
YELLOW="\033[1;33m"
else
BOLD=""
GREEN=""
NORMAL=""
RED=""
YELLOW=""
fi
script=`basename $0`
die () {
echo "${BOLD}$script: ${RED}error:${NORMAL} $*" 1>&2
exit 1
}
fatal () {
echo "${BOLD}$script: ${RED}fatal error:${NORMAL} $*" 1>&2
exit 1
}
msg () {
echo "$script: $*" 1>&2
}
wrn () {
echo "${BOLD}$script: ${YELLOW}warning:${NORMAL} $*" 1>&2
}
cd `dirname $0`
root=`pwd`
tmp=/tmp/`basename $script .sh`
name=$tmp.name
rm -f $tmp*
usage () {
cat <<EOF
usage: $script [-h][-f]
EOF
}
force=no
while [ $# -gt 0 ]
do
case "$1" in
-h) usage; exit 0;;
-f) force=yes;;
*) die "invalid option '$1'";;
esac
shift
done
if [ $force = yes ]
then
wrn "not checking commit status (due to '-f')"
forceoption="-f"
else
msg "will check commit status (use '-f' to disable)"
forceoption=""
fi
msg "first generating source code tar file"
./make-source-release.sh $forceoption -t $name || exit 1
source="`cat $name`"
[ -f "$source" ] || fatal "can not access tar '$source'"
msg "source code tar '$source'"
version=`cat VERSION`
base=lingeling-${version}-starexec
dir=/tmp/$base
rm -rf $dir
mkdir $dir
mkdir $dir/bin
mkdir $dir/build
mkdir $dir/archive
msg "generated '$dir' structure"
cp -p "$source" $dir/archive
msg "copied source code archive"
starexec_build=$dir/starexec_build
cat <<EOF >$starexec_build
#!/bin/sh
cd build
exec ./build.sh
EOF
chmod 755 $starexec_build
build=$dir/build/build.sh
cat <<EOF > $build
#!/bin/sh
tar xf ../archive/lingeling*
mv lingeling* lingeling
cd lingeling
./configure.sh
make all || exit 1
exec install -s build/lingeling ../../bin/
EOF
chmod 755 $build
starexec_run_default=$dir/bin/starexec_run_default
cat <<EOF >$starexec_run_default
#!/bin/sh
exec ./lingeling \$1
EOF
chmod 755 $starexec_run_default
msg "generated build and run scripts"
version=`cat VERSION`
description=$dir/starexec_description.txt
cat <<EOF>$description
Legacy SAT Solver with powerful Preprocessing and Inprocessing
EOF
msg "included the following description:"
printf $BOLD
cat $description
printf $NORMAL
zipfile=/tmp/$base.zip
rm -f $zipfile
cd $dir
zip -q -r $zipfile .
cd /tmp/
msg "generated ${GREEN}'$zipfile'${NORMAL}"
BYTES="`ls --block-size=1 -s $zipfile 2>/dev/null |awk '{print $1}'`"
msg "zip file has $BYTES bytes"
echo $zipfile