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
|
EXTENSIONS_DIRECTORY=$(cd "$TEST_OUTPUT_DIRECTORY/../custom/extensions" && pwd)
EXT_TEST_DIRECTORY=$(cd "$TEST_OUTPUT_DIRECTORY/extensions" && pwd)
lua_version() {
"$1" -e 'io.write(jit and jit.version or _VERSION)' 2>/dev/null ||
printf '%s' "$1"
}
interpreters=
ext_lua_versions=
for ext_lua_bin in luajit lua5.1 lua51 lua-5.1 lua5.2 lua52 lua-5.2 \
lua5.3 lua53 lua-5.3 lua5.4 lua54 lua-5.4 lua5.5 lua55 lua-5.5 lua
do
command -v "$ext_lua_bin" >/dev/null 2>&1 || continue
ext_lua_version=$(lua_version "$ext_lua_bin")
case "$ext_lua_version" in
"Lua 5."[1-5]|"LuaJIT 2."*)
;;
*)
continue
;;
esac
case "$ext_lua_versions" in
*"|$ext_lua_version|"*)
continue
;;
esac
ext_lua_versions="$ext_lua_versions|$ext_lua_version|"
interpreters="$interpreters $ext_lua_bin"
done
test -z "$interpreters" || test_set_prereq STANDALONE_LUA
lua_module_prereq() {
lua_prereq=$(printf '%s' "$*" | tr -c 'A-Za-z0-9' '_' | tr 'a-z' 'A-Z')
lua_prereq_bin=$1
shift
lua_prereq_code=
for lua_prereq_module
do
lua_prereq_code="$lua_prereq_code require('$lua_prereq_module')"
done
if "$lua_prereq_bin" -e "$lua_prereq_code" >/dev/null 2>&1
then
test_set_prereq "$lua_prereq"
fi
}
cgit_lua_probe() {
test "$CGIT_HAS_LUA" -eq 1 || return 1
cgit_lua_probe_gitdir=$1
shift
{
echo "function filter_open(...) end"
echo "function filter_write(str) end"
echo "function filter_close()"
echo "local ok = true"
for cgit_lua_probe_module in "$@"
do
echo "if not pcall(require, '$cgit_lua_probe_module') then"
echo "ok = false"
echo "end"
done
echo "if ok then html('LUA_PROBE_YES') else html('LUA_PROBE_NO') end"
echo "return 0"
echo "end"
} >lua-probe.lua
cat >lua-probe-cgitrc <<EOF
virtual-root=/
cache-size=0
repo.url=lua-probe
repo.path=$cgit_lua_probe_gitdir
repo.commit-filter=lua:$PWD/lua-probe.lua
EOF
CGIT_CONFIG="$PWD/lua-probe-cgitrc" QUERY_STRING="url=lua-probe/commit/" \
cgit >lua-probe.out 2>lua-probe.err ||
BAIL_OUT "cgit failed while probing its Lua for $*"
if grep LUA_PROBE_YES lua-probe.out >/dev/null
then
return 0
elif grep LUA_PROBE_NO lua-probe.out >/dev/null
then
return 1
fi
BAIL_OUT "probing cgit's Lua for $* gave no answer"
}
|