-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.sh
executable file
·178 lines (151 loc) · 4.51 KB
/
manage.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
#!/bin/bash
source /usr/share/annyung-release/functions.d/bash/functions
errmsg () {
echo "$*" 1>&2
}
usage () {
echo "Usage: $0 [clean|pack|test [php-version]]"
exit 1
}
ctrlModule () {
local mode=$1
local ver=$2
local m
case "${mode}" in
add)
for m in ${NEED_MODULES}
do
if [[ -f /opt/php-qa/php${ver}/modules/${m}.so ]]; then
if [[ ! -L ./modules/${m}.so ]]; then
ln -sf /opt/php-qa/php${ver}/modules/${m}.so ./modules/${m}.so
fi
fi
done
;;
*)
for m in ${NEED_MODULES}
do
[[ -L ./modules/${m}.so ]] && rm -f ./modules/${m}.so
done
esac
}
mod_name="$( grep "^ZEND_GET_MODULE" *.c | grep -Po '(?<=\()[a-z]+(?=\))' )"
opts=$(getopt -u -o h -l help -- "$@")
[ $? != 0 ] && usage
set -- ${opts}
for i
do
case "$i" in
-h|--help)
usage
shift
;;
--)
shift
break
;;
esac
done
mode="${1}"
case "${mode}" in
clean)
cat <<-EOL
[ -f Makefile ] && make distclean
rm -rf autom4te.cache build include modules
rm -f .deps Makefile* ac*.m4 compile
rm -f config.h* config.nice configure* config.sub config.guess
rm -f install-sh ltmain.sh missing mkinstalldirs run-tests.php
rm -f package.xml
find ./tests ! -name '*.phpt' -a ! -name '*.txt' -a -type f
----->
EOL
[ -f Makefile ] && make distclean
rm -rf autom4te.cache build include modules
rm -f .deps Makefile* ac*.m4 compile tags
rm -f config.h* config.nice configure* config.sub config.guess
rm -f install-sh ltmain.sh missing mkinstalldirs run-tests.php
rm -f tests/*.{diff,exp,log,out,php,sh,mem}
;;
pack)
rel="$( awk '/^#define BUILDVER / { print gensub(/"/, "", "g", $NF); }' php_${mod_name}.h )"
[[ -d ../mod_${mod_name}-${rel} ]] && rm -rf ../mod_${mod_name}-${rel}
mkdir -p ../mod_${mod_name}-${rel}
cp -af charset/ libgd/ tests/ ../mod_${mod_name}-${rel}
cp -af CREDITS Changelog README.md ../mod_${mod_name}-${rel}
cp -af *.m4 *.dsp *.c *.h ../mod_${mod_name}-${rel}
cd ..
tar cvfpJ mod_${mod_name}-${rel}.tar.xz mod_${mod_name}-${rel}
cd -
mv ../mod_${mod_name}-${rel}.tar.xz ./
[[ -d ../mod_${mod_name}-${rel} ]] && rm -rf ../mod_${mod_name}-${rel}
;;
test)
PHPBIN=/opt/php-qa/php${2}/bin/php
PHPIZE=/opt/php-qa/php${2}/bin/phpize
PHPCONFIG=/opt/php-qa/php${2}/bin/php-config
PHP_OPT="-n"
NEED_MODULES="iconv openssl"
if [[ $# == 2 ]]; then
./manage.sh clean
echo "${PHPIZE} && ./configure"
${PHPIZE} && ./configure && make -j8 || exit 0
fi
ctrlModule add ${2}
if (( $2 > 71 )); then
PHP_OPT+=" -d 'extension_dir=./modules/' -d 'extension=${mod_name}.so'"
else
PHP_OPT+=" -d 'track_errors=1' -d 'extension_dir=./modules/' -d 'extension=${mod_name}.so'"
fi
if [[ -f /opt/php-qa/php${2}/modules/iconv.so ]];then
PHP_OPT+=" -d 'extension=/opt/php-qa/php${2}/modules/iconv.so'"
fi
if [[ -f tests/${3}.php ]]; then
cat <<-EOL
${bgreen}------------------------------------------------------------------------
Sample code execution:
${bcyan}${PHPBIN} ${PHP_OPT} test/${3}.php
${bgreen}------------------------------------------------------------------------${normal}
EOL
${PHPBIN} ${PHP_OPT} test/${3}.php
#ctrlModule remove ${2}
exit $?
elif [[ -f ${3} ]]; then
cat <<-EOL
${bgreen}------------------------------------------------------------------------
Sample code execution:
${bcyan}${PHPBIN} ${PHP_OPT} ${3}
${bgreen}------------------------------------------------------------------------${normal}
EOL
eval "${PHPBIN} ${PHP_OPT} ${3}"
#ctrlModule remove ${2}
exit $?
fi
cat <<-EOL
${bwhite}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
${tcolor}** MAKE test:: ${normal}
${bwhite}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
${bcyan}make test PHP_EXECUTABLE=${PHPBIN}
${bwhite}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${normal}
EOL
make test PHP_EXECUTABLE=${PHPBIN} <<< n
#ctrlModule remove ${2}
;;
stub)
# stub tagging
# /** @generate-function-entries **/ build with function entryies
# /** @generate-legacy-arginfo **/ build with legacy style
if [[ ! -f build/gen_stub.php ]]; then
cat <<-EOL
ERROR: execute before PHP 8 build environment or before execute phpize
EOL
exit 1
fi
phpcmd="/usr/bin/php80"
perl -pi -e 's/ext_functions/${mod_name}_functions/g' build/gen_stub.php
${phpcmd} build/gen_stub.php -f *.stub.php
;;
*)
errmsg "Unsupport mode '${1}'"
exit 1
esac
exit 0