Files
computer-playbook/roles/web-app-mediawiki/files/install/helpers/composer_install.sh
kevinveenbirkenbachandClaude Opus 5 01eec179ee fix(web-app-mediawiki): drop require-dev before composer solves
The extension tarballs ship no composer.lock, so `composer install --no-dev`
degrades to a full solve that still resolves require-dev, as composer states
itself. Both configured addons pull mediawiki-codesniffer 50.0.0 there, which
pins php_codesniffer 3.13.5, and once an advisory landed against that version
composer refused to load it and the solve became unsatisfiable. The extension
install failed with rc 2 without a single line of this repository changing.

Stripping require-dev from the manifest before composer sees it keeps the
solve on the runtime constraints, which is what --no-dev was asking for. The
stripper decodes to objects rather than associative arrays, because an empty
JSON object would otherwise round-trip into an empty array and composer
rejects `[]` where its schema wants `{}`.

The work that runs inside the container moved out of the embedded shell string
into install/helpers/, which removes three levels of quoting from the calling
script and makes both helpers runnable by hand for debugging. The whole helper
directory is copied in, so adding a helper means dropping a file in there and
nothing else.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 20:09:52 +02:00

33 lines
950 B
Bash

#!/usr/bin/env bash
#
# Install one MediaWiki extension's composer dependencies. Runs INSIDE the
# MediaWiki container, staged there by composer_install_extension.sh.
#
# Uses /tmp/composer for HOME and CACHE to avoid /var/www permission issues,
# and strips require-dev first (see strip_require_dev.php for why). Emits a
# stable status line for the caller's changed_when.
#
# Usage:
# composer_install.sh EXT_DIR EXT_BRANCH EXT_NAME
set -euo pipefail
EXT_DIR="$1"
EXT_BRANCH="$2"
EXT_NAME="$3"
if [ ! -f "${EXT_DIR}/composer.json" ] || [ -f "${EXT_DIR}/vendor/autoload.php" ]; then
echo "COMPOSER_PRESENT:${EXT_NAME}"
exit 0
fi
install -d -m 0775 /tmp/composer/cache
export COMPOSER_HOME=/tmp/composer
export COMPOSER_CACHE_DIR=/tmp/composer/cache
export COMPOSER_ROOT_VERSION="dev-${EXT_BRANCH}"
cd "${EXT_DIR}"
php /tmp/strip_require_dev.php composer.json
composer install --no-dev -n --prefer-dist
echo "COMPOSER_INSTALLED:${EXT_NAME}"