-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker.sh
executable file
·202 lines (157 loc) · 4.05 KB
/
docker.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/bash
#
# Building for docker
# This is:
# * only needed until mkit does not have proper testing
# * meant to invoked by Dockerfile
#
# File: docker.sh
# Created: 250718
#
### FUNCTIONS ###
test_file()
{
typeset f="$1"
typeset basef="$(basename $f)"
[ ! -f "$f" ] && { echo "File $f does not exist."; return 1; }
echo "File ${basef} exists."
ls -lt "$f"
return 0
}
test_any()
{
typeset f="$1"
typeset basef="$(basename $f)"
[ ! -e "$f" ] && { echo "$f does not exist."; return 1; }
echo "File ${basef} exists."
ls -lt "$f"
return 0
}
test_dir()
{
typeset d="$1"
[ ! -d "$d" ] && { echo "Directory $d does not exist."; return 1; }
return 0
}
# tests for "default" profile
main_tests_default()
{
fails=0
echo "Starting tests..."
test_dir "$prefix/bin"
rc_bin=$?
[ "$rc_bin" -ne 0 ] && let fails="(( $fails + 1))"
test_file $python
rc_python=$?
rc_sslversion=0
rc_readline=0
[ "$rc_python" -eq 0 ] &&
{
echo "Testing correct OpenSSL module is built:"
echo "import _ssl; print(_ssl.OPENSSL_VERSION);" | ${python}
rc_sslversion=$?
echo "Testing readline"
echo "import readline;" | ${python}
rc_readline="$?"
} ||
{
let fails="(( $fails + 1))"
}
[ "$rc_sslversion" -ne 0 ] && let fails="(( $fails + 1))"
[ "$rc_readline" -ne 0 ] && let fails="(( $fails + 1))"
# mod_wsgi checks
test_file "$prefix/modules/mod_wsgi.so" || let fails="(( $fails + 1))"
test_file "$prefix/modules/mod_proxy_uwsgi.so" || let fails="(( $fails + 1))"
# readline
test_any "$prefix/lib/libhistory.a" || let fails="(( $fails + 1))"
test_any "$prefix/lib/libhistory.so" || let fails="(( $fails + 1))"
test_any "$prefix/lib/libreadline.a" || let fails="(( $fails + 1))"
echo
ls -lt "${prefix}/bin" || let fails="(( $fails + 1))"
[ "$rc" -eq 0 -a "$fails" -ne 0 ] &&
{
echo "Build succeeded but there were $fails test failures!"
return 1
}
return $rc
}
main_tests_uwsgi()
{
typeset any
fails=0
echo "Starting tests..."
test_dir "$prefix/bin"
rc_bin=$?
[ "$rc_bin" -ne 0 ] && let fails="(( $fails + 1))"
test_file $python
rc_python=$?
# libs test for: openssl & readline
typeset any_ssl="libcrypto.so.1.0.0 libssl.so.1.0.0"
typeset any_readline="libhistory.a libhistory.so"
for any in $any_ssl $any_readline
do
test_any "$prefix/lib/$any" || let fails="(( $fails + 1))"
done
rc_sslversion=0
rc_readline=0
[ "$rc_python" -eq 0 ] &&
{
echo "Testing correct OpenSSL module is built:"
echo "import _ssl; print(_ssl.OPENSSL_VERSION);" | ${python}
rc_sslversion=$?
echo "Testing readline"
echo "import readline;" | ${python}
rc_readline="$?"
} ||
{
let fails="(( $fails + 1))"
}
[ "$rc_sslversion" -ne 0 ] && let fails="(( $fails + 1))"
[ "$rc_readline" -ne 0 ] && let fails="(( $fails + 1))"
[ "$rc" -eq 0 -a "$fails" -ne 0 ] &&
{
echo "Build succeeded but there were $fails test failures!"
return 1
}
return $rc
}
### ENV ###
prefix="$1"; shift
profile="${1:-${PROFILE}}"; shift; unset PROFILE
profile="${profile:-default}" # sanity check
python="$prefix/bin/python3.10"
export fails=0
### MAIN ###
# NO_TIMESTAMP: using this option avoids recording build timestamp in executables making two builds with same input have the same output
mkdir -p $prefix && NO_TIMESTAMP=1 ./mkit.sh $prefix profile="${profile}"
rc=$?
echo "mkit rc: $rc"
[ "$rc" -ne 0 ] && exit $rc
for dir in $prefix/lib/python*/test
do
[ -d "$dir" ] && pytestlib="$dir"
done
[ -d "$pytestlib" ] && { echo "Deleting unneeded test lib"; rm -rf "$pytestlib"; }
# if KEEP_DOCS is not set delete documentation directories
[ -z "$KEEP_DOCS" ] &&
{
for dir in $prefix/man \
$prefix/manual \
$prefix/doc \
$prefix/share/doc \
$prefix/share/*-doc \
$prefix/share/man \
$prefix/share/info
do
[ -d "$dir" ] && { echo "Removing doc dir: " $dir; rm -rf "$dir"; }
done
}
# even if rc != 0: we do some tests anyway
tests="main_tests_${profile}"
type $tests > /dev/null 2>&1 # only execute the test function if it exists...
[ $? -eq 0 ] &&
{
$tests || exit $?
}
exit 0
### EOF ###