X-Git-Url: https://git.tld-linux.org/?p=packages%2Fphp.git;a=blobdiff_plain;f=dep-tests.sh;h=062c2f81a06795a5f2b703cc4dc22281d9bfe321;hp=0a19c2397c0b1e92f60e95fc53b80ec328e17e1a;hb=HEAD;hpb=aef9a98d7828aeb48703ab2429a6968173d1addf diff --git a/dep-tests.sh b/dep-tests.sh old mode 100644 new mode 100755 index 0a19c23..062c2f8 --- a/dep-tests.sh +++ b/dep-tests.sh @@ -3,55 +3,114 @@ with_mysqlnd=mysqlnd -dep_spl="pcre simplexml" -dep_session="spl $dep_spl" -dep_filter='pcre' +dep_session="" +dep_filter='' dep_eaccelerator='session' -dep_mysql="$with_mysqlnd" -dep_mysqli="$dep_spl spl $with_mysqlnd" -dep_pdo="$dep_spl spl" +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 $with_mysqlnd" -dep_simplexml="$dep_spl spl" -dep_imap="pcre" -dep_phar="$dep_spl spl" +dep_pdo_mysql="$dep_pdo pdo $dep_mysqlnd $with_mysqlnd" +dep_simplexml="" +dep_imap="" +dep_phar="" dep_sqlite="$dep_pdo pdo" -dep_fileinfo="pcre" +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} -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# })..." - - grep -rlE '^extension=('$(echo "${deps# }" | tr ' ' '|')').so$' $conf_dir | LC_CTYPE=C LC_ALL= 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 -rm -f $t + +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