@@ -293,7 +293,34 @@ jobs:
293293
294294 - name : Verify built RPM package contents
295295 run : |
296- ls rpm-src/noarch
296+ set -euxo pipefail
297+ rpm_file="$(ls rpm-src/noarch/wp-cli-*.noarch.rpm)"
298+ # The package must ship a launcher in the bin dir and the Phar in the data dir.
299+ rpm -qlp "$rpm_file" | tee /tmp/rpm-files.txt
300+ grep -qx '/usr/bin/wp' /tmp/rpm-files.txt
301+ grep -qx '/usr/share/wp-cli/wp-cli.phar' /tmp/rpm-files.txt
302+ # /usr/bin/wp must be the shell launcher that honors WP_CLI_PHP / WP_CLI_PHP_ARGS,
303+ # not the Phar itself.
304+ mkdir -p rpm-verify
305+ ( cd rpm-verify && rpm2cpio "../$rpm_file" | cpio -idm )
306+ test -x rpm-verify/usr/bin/wp
307+ head -n1 rpm-verify/usr/bin/wp | grep -q '^#!/bin/sh'
308+ grep -q '/usr/share/wp-cli/wp-cli.phar' rpm-verify/usr/bin/wp
309+ test -s rpm-verify/usr/share/wp-cli/wp-cli.phar
310+ # Run the extracted launcher through a probe standing in for PHP: it must
311+ # forward WP_CLI_PHP_ARGS before the Phar and export WP_CLI_PHP_USED. The
312+ # probe asserts and exits without needing the Phar at its installed path.
313+ printf '%s\n' \
314+ '#!/bin/sh' \
315+ 'case " $* " in' \
316+ ' *" -d memory_limit=256M "*) : ;;' \
317+ ' *) echo "WP_CLI_PHP_ARGS not forwarded: $*" >&2; exit 3 ;;' \
318+ 'esac' \
319+ '[ -n "$WP_CLI_PHP_USED" ] || { echo "WP_CLI_PHP_USED not exported" >&2; exit 4; }' \
320+ 'exit 0' \
321+ > /tmp/wp-cli-php-probe
322+ chmod +x /tmp/wp-cli-php-probe
323+ WP_CLI_PHP=/tmp/wp-cli-php-probe WP_CLI_PHP_ARGS="-d memory_limit=256M" rpm-verify/usr/bin/wp cli version
297324
298325 - name : Copy RPM package into builds folder
299326 run : |
@@ -346,7 +373,40 @@ jobs:
346373
347374 - name : Verify built DEB package contents
348375 run : |
349- ls .
376+ set -euxo pipefail
377+ deb_file="$(ls php-wpcli*all.deb)"
378+ # The package must ship a launcher in the bin dir and the Phar in the data dir.
379+ dpkg-deb -c "$deb_file" | tee /tmp/deb-files.txt
380+ grep -Eq ' \./usr/bin/wp$' /tmp/deb-files.txt
381+ grep -Eq ' \./usr/share/wp-cli/wp-cli.phar$' /tmp/deb-files.txt
382+ # Install the package and exercise the launcher (php ships on the runner).
383+ sudo dpkg -i "$deb_file" || sudo apt-get install -f -y
384+ test -x /usr/bin/wp
385+ head -n1 /usr/bin/wp | grep -q '^#!/bin/sh'
386+ test -s /usr/share/wp-cli/wp-cli.phar
387+ # Default interpreter works.
388+ wp --info
389+ wp cli version
390+ # A probe that stands in for PHP and asserts what the launcher forwarded:
391+ # it must receive WP_CLI_PHP_ARGS before the Phar and inherit WP_CLI_PHP_USED.
392+ printf '%s\n' \
393+ '#!/bin/sh' \
394+ 'case " $* " in' \
395+ ' *" -d memory_limit=256M "*) : ;;' \
396+ ' *) echo "WP_CLI_PHP_ARGS not forwarded: $*" >&2; exit 3 ;;' \
397+ 'esac' \
398+ '[ -n "$WP_CLI_PHP_USED" ] || { echo "WP_CLI_PHP_USED not exported" >&2; exit 4; }' \
399+ 'exit 0' \
400+ > /tmp/wp-cli-php-probe
401+ chmod +x /tmp/wp-cli-php-probe
402+ # Proves WP_CLI_PHP selects the interpreter AND WP_CLI_PHP_ARGS reaches it.
403+ WP_CLI_PHP=/tmp/wp-cli-php-probe WP_CLI_PHP_ARGS="-d memory_limit=256M" wp cli version
404+ # A deliberately broken WP_CLI_PHP must actually be used: if it were ignored,
405+ # this would still succeed. This is the regression guard for the whole fix.
406+ if WP_CLI_PHP=/bin/false wp cli version 2>/dev/null; then
407+ echo "WP_CLI_PHP was ignored by the launcher" >&2
408+ exit 1
409+ fi
350410
351411 - name : Copy DEB package into builds folder
352412 run : |
0 commit comments