blob: 062c2f81a06795a5f2b703cc4dc22281d9bfe321 (
plain)
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
|
#!/bin/sh
# inter-dependencies checker.
with_mysqlnd=mysqlnd
dep_session=""
dep_filter=''
dep_eaccelerator='session'
dep_mysqlnd=''
dep_mysql="$dep_mysqlnd $with_mysqlnd"
dep_mysqli="$dep_mysqlnd $with_mysqlnd"
dep_pdo=""
dep_pdo_sqlite="$dep_pdo pdo"
dep_pdo_pgsql="$dep_pdo pdo"
dep_pdo_oci="$dep_pdo pdo"
dep_pdo_odbc="$dep_pdo pdo"
dep_pdo_firebird="$dep_pdo pdo"
dep_pdo_dblib="$dep_pdo pdo"
dep_pdo_mysql="$dep_pdo pdo $dep_mysqlnd $with_mysqlnd"
dep_simplexml=""
dep_imap=""
dep_phar=""
dep_sqlite="$dep_pdo pdo"
dep_fileinfo=""
dep_wddx='xml'
dep_xmlreader='dom'
dep_xmlrpc='xml'
dep_xsl='dom'
dep_snmp="snmp"
dep_opcache=''
php=${PHP:-$(php-config --php-binary)}
ext_dir=${EXTENSION_DIR:-$(php-config --extension-dir)}
conf_dir=${CONFIG_DIR:-$(php-config --sysconfdir)/conf.d $(php-config --sysconfdir)/cli.d}
test_deps() {
tmpini=$(mktemp)
# poldek --sn ac-ready -u php-*
for ext in ${*:-$ext_dir/*.so}; do
[ -f $ext ] || continue
ext=${ext##*/}; ext=${ext%.so}
deps=$(eval echo \$dep_$ext)
# add ext itself, if already not in list (spl case)
[[ $deps = *\ $ext\ * ]] || deps="$deps $ext"
echo -n "$ext (deps: ${deps# })..."
# special: opcache is listed as "Zend Opcache"
[ "$ext" = "opcache" ] && ext="zend opcache"
grep -rlE '^(zend_)?extension=('$(echo "${deps# }" | tr ' ' '|')')$' $conf_dir | LC_ALL=C sort | xargs cat > $tmpini
$php -n -d extension_dir=$ext_dir -c $tmpini -r "exit(extension_loaded('${ext}') ? 0 : 1);"
rc=$?
if [ $rc = 0 ]; then
echo OK
else
echo FAIL
echo "Failed config was:"
cat $tmpini
fi
done
}
_resolve_extension_deps() {
local name="$1"
eval echo \$dep_$ext
}
# Prints a load order (0-based integer) for the given extension name. Extension
# with lower load order should be loaded before exts with higher load order.
# It's based on number of dependencies of the extension (with exception for
# "imap"), which is flawed, but simple and good enough for now.
#
# _extension_load_order adopted from alpine linux:
# https://github.com/alpinelinux/aports/blob/v3.10.1/community/php7/APKBUILD#L639-L653
_extension_load_order() {
local name="$1"
local deps=$(eval "echo \$dep_$name")
case "$name" in
# XXX: This must be loaded after recode, even though it does
# not depend on it. So we must use this hack...
imap) echo 1;;
*) echo "${deps:=$(_resolve_extension_deps $name)}" | wc -w;;
esac
}
generate_ini() {
local load_order
rm -rf conf.d
install -d conf.d
for module in ${*:-$ext_dir/*.so}; do
[ -f $module ] || continue
extname=${module##*/}; extname=${extname%.so}
ext=extension
# opcache.so is zend extension
nm $module | grep -q zend_extension_entry && ext=zend_extension
load_order=$(_extension_load_order "$extname")
cat > conf.d/$(printf %02d $load_order)_$extname.ini <<-EOF
; Enable $extname $ext module
$ext=$extname
EOF
done
}
if [ -n "$GENERATE_INI" ]; then
generate_ini "$@"
else
test_deps "$@"
fi
|