-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.sh
executable file
·169 lines (137 loc) · 4.28 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
#!/bin/bash
source /usr/share/annyung-release/functions.d/bash/functions
setAnsi
tcolor="${bblack}${bgwhite}"
errmsg () {
echo "$*" 1>&2
}
usage () {
echo "${bwhite}Usage:${normal} $0 [clean|pack|test [php-version]]"
exit 1
}
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
${bwhite}[ -f Makefile ] && make distclean
rm -rf autom4te.cache build include modules
rm -f .deps Makefile* ac*.m4 dyn*.m4 compile *.loT
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
rm -f tests/*.{diff,exp,log,out,php,sh,mem}
#rm -f ${mod_name}_arginfo.h && git checkout -- ${mod_name}_arginfo.h
${normal}----->
EOL
[ -f Makefile ] && make distclean
rm -rf autom4te.cache build include modules
rm -f .deps Makefile* ac*.m4 dyn*.m4 compile *.loT
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
rm -f tests/*.{diff,exp,log,out,php,sh,mem}
#rm -f ${mod_name}_arginfo.h && git checkout -- ${mod_name}_arginfo.h
;;
pack)
cp -af package.xml.tmpl package.xml
list=$(grep "md5sum" ./package.xml | sed -r 's/.*"@|@".*//g')
for i in ${list}
do
md5s=$(md5sum "$i" | awk '{print $1}')
perl -pi -e "s!\@${i}\@!${md5s}!g" ./package.xml
done
curdate=$(date +'%Y-%m-%d')
curtime=$(date +'%H:%M:%S')
perl -pi -e "s!\@curdate\@!${curdate}!g" ./package.xml
perl -pi -e "s!\@curtime\@!${curtime}!g" ./package.xml
pecl package
rm -f package.xml
;;
test)
# support PHP 4.3 and after
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"
LEGACY_TEST=0
if [[ $# == 2 ]]; then
./manage.sh clean
echo "${PHPIZE} && ./configure"
${PHPIZE} && ./configure && make -j8 || exit 0
fi
if [[ ! -f ./run-tests.php ]]; then
LEGACY_TEST=1
PHP_OPT="-d 'enable_dl=1' -d 'safe_mode=0' -d 'disable_error=0'"
fi
PHP_OPT+=" -d 'extension_dir=./modules/' -d 'extension=${mod_name}.so'"
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
exit $?
elif [[ -f ${3} ]]; then
cat <<-EOL
${bgreen}------------------------------------------------------------------------
Sample code execution:
${bcyan}${PHPBIN} ${PHP_OPT} ${3}
${bgreen}------------------------------------------------------------------------${normal}
EOL
eval "${PHPBIN} ${PHP_OPT} ${3}"
exit $?
fi
grep "^PHP_DEPRECATED_DIRECTIVES_REGEX =" Makefile | grep -q "safe_mode"
[[ $? == 0 ]] && {
perl -pi -e 's/safe_mode\|//g' Makefile
}
cat <<-EOL
${bwhite}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
${tcolor}** MAKE test:: ${normal}
${bwhite}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
${bcyan}make test PHP_EXECUTABLE=${PHPBIN}
${bwhite}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${normal}
EOL
(( LEGACY_TEST == 1 )) \
&& PHP_EXECUTABLE=${PHPBIN} bash /opt/php-qa/TEST-ENV/legacy-test.sh \
|| make test PHP_EXECUTABLE=${PHPBIN} <<< n
exit $?
;;
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/krisp_functions/g' build/gen_stub.php
${phpcmd} build/gen_stub.php -f *.stub.php
;;
*)
errmsg "Unsupport mode '${1}'"
exit 1
esac
exit 0