Commit b370e7f1 authored by Tiago Dinis's avatar Tiago Dinis
Browse files

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
parent 5ae83c52
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -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"