]> git.pld-linux.org Git - packages/php.git/commitdiff
dep-tests.sh: move main to function
authorElan Ruusamäe <glen@pld-linux.org>
Wed, 7 Aug 2019 20:08:32 +0000 (23:08 +0300)
committerElan Ruusamäe <glen@pld-linux.org>
Wed, 7 Aug 2019 20:56:55 +0000 (23:56 +0300)
dep-tests.sh

index 3d1a3983661e80ef308689363121d27303d3d3ea..c79530a89c00b12e699b63cbd7db1f40b2b5411d 100755 (executable)
@@ -33,31 +33,35 @@ dep_opcache='pcre'
 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# })..."
-
-       # special: opcache is listed as "Zend Opcache"
-       [ "$ext" = "opcache" ] && ext="zend opcache"
-
-       grep -rlE '^(zend_)?extension=('$(echo "${deps# }" | tr ' ' '|')').so$' $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
-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 ' ' '|')').so$' $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
+}
+
+test_deps "$@"
This page took 0.332642 seconds and 4 git commands to generate.