From b370e7f14a0b865a99e4a45578c0a1f0f3926177 Mon Sep 17 00:00:00 2001 From: Tiago Dinis Date: Mon, 20 Jan 2025 11:53:47 +0000 Subject: [PATCH] pkgs/build-support/php/builders/v2: copy installer-paths to the output CMSes like Drupal or Wordpress use "extra.installer-paths" property to redirect certain packages to certain folders, which means only copying the vendor folder is not enough, we have to copy all dependencies in the installer-paths. Fixes #373626 pkgs/build-support/php/builders/v2: check if installer-paths exists before copying pkgs/build-support/php/builders/v2: strip out the git repositories --- .../builders/v2/hooks/composer-vendor-hook.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/php/builders/v2/hooks/composer-vendor-hook.sh b/pkgs/build-support/php/builders/v2/hooks/composer-vendor-hook.sh index 29bc95909d6f..d978c2800f40 100644 --- a/pkgs/build-support/php/builders/v2/hooks/composer-vendor-hook.sh +++ b/pkgs/build-support/php/builders/v2/hooks/composer-vendor-hook.sh @@ -96,9 +96,23 @@ composerVendorInstallHook() { mkdir -p $out cp -ar composer.json $(composer config vendor-dir) $out/ + mapfile -t installer_paths < <(jq -r 'try((.extra."installer-paths") | keys[])' composer.json) + + for installer_path in "${installer_paths[@]}"; do + # Remove everything after {$name} placeholder + installer_path="${installer_path/\{\$name\}*/}"; + out_installer_path="$out/${installer_path/\{\$name\}*/}"; + # Copy the installer path if it exists + if [[ -d "$installer_path" ]]; then + mkdir -p $(dirname "$out_installer_path") + cp -ar "$installer_path" "$out_installer_path" + # Strip out the git repositories + find $out_installer_path -name .git -type d -prune -print -exec rm -rf {} ";" + fi + done if [[ -f "composer.lock" ]]; then - cp -ar composer.lock $(composer config vendor-dir) $out/ + cp -ar composer.lock $out/ fi echo "Finished composerVendorInstallHook"