about summary refs log tree commit diff
path: root/pkgs/build-support/php/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/php/hooks')
-rw-r--r--pkgs/build-support/php/hooks/composer-install-hook.sh126
-rw-r--r--pkgs/build-support/php/hooks/composer-repository-hook.sh91
-rw-r--r--pkgs/build-support/php/hooks/default.nix39
-rw-r--r--pkgs/build-support/php/hooks/php-script-utils.bash77
4 files changed, 0 insertions, 333 deletions
diff --git a/pkgs/build-support/php/hooks/composer-install-hook.sh b/pkgs/build-support/php/hooks/composer-install-hook.sh
deleted file mode 100644
index a91263422bc84..0000000000000
--- a/pkgs/build-support/php/hooks/composer-install-hook.sh
+++ /dev/null
@@ -1,126 +0,0 @@
-declare composerRepository
-declare version
-declare composerNoDev
-declare composerNoPlugins
-declare composerNoScripts
-
-preConfigureHooks+=(composerInstallConfigureHook)
-preBuildHooks+=(composerInstallBuildHook)
-preCheckHooks+=(composerInstallCheckHook)
-preInstallHooks+=(composerInstallInstallHook)
-
-source @phpScriptUtils@
-
-composerInstallConfigureHook() {
-    echo "Executing composerInstallConfigureHook"
-
-    if [[ ! -e "${composerRepository}" ]]; then
-        echo "No local composer repository found."
-        exit 1
-    fi
-
-    if [[ -e "$composerLock" ]]; then
-        cp "$composerLock" composer.lock
-    fi
-
-    if [[ ! -f "composer.lock" ]]; then
-        setComposeRootVersion
-
-        composer \
-            --no-install \
-            --no-interaction \
-            --no-progress \
-            ${composerNoDev:+--no-dev} \
-            ${composerNoPlugins:+--no-plugins} \
-            ${composerNoScripts:+--no-scripts} \
-            update
-
-        mkdir -p $out
-        cp composer.lock $out/
-
-        echo
-        echo -e "\e[31mERROR: No composer.lock found\e[0m"
-        echo
-        echo -e '\e[31mNo composer.lock file found, consider adding one to your repository to ensure reproducible builds.\e[0m'
-        echo -e "\e[31mIn the meantime, a composer.lock file has been generated for you in $out/composer.lock\e[0m"
-        echo
-        echo -e '\e[31mTo fix the issue:\e[0m'
-        echo -e "\e[31m1. Copy the composer.lock file from $out/composer.lock to the project's source:\e[0m"
-        echo -e "\e[31m  cp $out/composer.lock <path>\e[0m"
-        echo -e '\e[31m2. Add the composerLock attribute, pointing to the copied composer.lock file:\e[0m'
-        echo -e '\e[31m  composerLock = ./composer.lock;\e[0m'
-        echo
-
-        exit 1
-    fi
-
-    echo "Validating consistency between composer.lock and ${composerRepository}/composer.lock"
-    if ! @cmp@ -s "composer.lock" "${composerRepository}/composer.lock"; then
-        echo
-        echo -e "\e[31mERROR: vendorHash is out of date\e[0m"
-        echo
-        echo -e "\e[31mcomposer.lock is not the same in $composerRepository\e[0m"
-        echo
-        echo -e "\e[31mTo fix the issue:\e[0m"
-        echo -e '\e[31m1. Set vendorHash to an empty string: `vendorHash = "";`\e[0m'
-        echo -e '\e[31m2. Build the derivation and wait for it to fail with a hash mismatch\e[0m'
-        echo -e '\e[31m3. Copy the "got: sha256-..." value back into the vendorHash field\e[0m'
-        echo -e '\e[31m   You should have: vendorHash = "sha256-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=";\e[0m'
-        echo
-
-        exit 1
-    fi
-
-    chmod +w composer.json composer.lock
-
-    echo "Finished composerInstallConfigureHook"
-}
-
-composerInstallBuildHook() {
-    echo "Executing composerInstallBuildHook"
-
-    setComposeRootVersion
-
-    # Since this file cannot be generated in the composer-repository-hook.sh
-    # because the file contains hardcoded nix store paths, we generate it here.
-    composer-local-repo-plugin --no-ansi build-local-repo-lock -m "${composerRepository}" .
-
-    echo "Finished composerInstallBuildHook"
-}
-
-composerInstallCheckHook() {
-    echo "Executing composerInstallCheckHook"
-
-    checkComposerValidate
-
-    echo "Finished composerInstallCheckHook"
-}
-
-composerInstallInstallHook() {
-    echo "Executing composerInstallInstallHook"
-
-    setComposeRootVersion
-
-    # Finally, run `composer install` to install the dependencies and generate
-    # the autoloader.
-    composer \
-      --no-interaction \
-      --no-progress \
-      ${composerNoDev:+--no-dev} \
-      ${composerNoPlugins:+--no-plugins} \
-      ${composerNoScripts:+--no-scripts} \
-      install
-
-    # Copy the relevant files only in the store.
-    mkdir -p "$out"/share/php/"${pname}"
-    cp -r . "$out"/share/php/"${pname}"/
-
-    # Create symlinks for the binaries.
-    jq -r -c 'try (.bin[] | select(test(".bat$")? | not) )' composer.json | while read -r bin; do
-        echo -e "\e[32mCreating symlink ${bin}...\e[0m"
-        mkdir -p "$out"/bin
-        ln -s "$out"/share/php/"${pname}"/"$bin" "$out"/bin/"$(basename "$bin")"
-    done
-
-    echo "Finished composerInstallInstallHook"
-}
diff --git a/pkgs/build-support/php/hooks/composer-repository-hook.sh b/pkgs/build-support/php/hooks/composer-repository-hook.sh
deleted file mode 100644
index c4fa0d52126c1..0000000000000
--- a/pkgs/build-support/php/hooks/composer-repository-hook.sh
+++ /dev/null
@@ -1,91 +0,0 @@
-declare composerLock
-declare version
-declare composerNoDev
-declare composerNoPlugins
-declare composerNoScripts
-declare composerStrictValidation
-
-preConfigureHooks+=(composerRepositoryConfigureHook)
-preBuildHooks+=(composerRepositoryBuildHook)
-preCheckHooks+=(composerRepositoryCheckHook)
-preInstallHooks+=(composerRepositoryInstallHook)
-
-source @phpScriptUtils@
-
-composerRepositoryConfigureHook() {
-    echo "Executing composerRepositoryConfigureHook"
-
-    if [[ -e "$composerLock" ]]; then
-        cp $composerLock composer.lock
-    fi
-
-    if [[ ! -f "composer.lock" ]]; then
-        setComposeRootVersion
-
-        composer \
-            --no-install \
-            --no-interaction \
-            --no-progress \
-            ${composerNoDev:+--no-dev} \
-            ${composerNoPlugins:+--no-plugins} \
-            ${composerNoScripts:+--no-scripts} \
-            update
-
-        mkdir -p $out
-        cp composer.lock $out/
-
-        echo
-        echo -e "\e[31mERROR: No composer.lock found\e[0m"
-        echo
-        echo -e '\e[31mNo composer.lock file found, consider adding one to your repository to ensure reproducible builds.\e[0m'
-        echo -e "\e[31mIn the meantime, a composer.lock file has been generated for you in $out/composer.lock\e[0m"
-        echo
-        echo -e '\e[31mTo fix the issue:\e[0m'
-        echo -e "\e[31m1. Copy the composer.lock file from $out/composer.lock to the project's source:\e[0m"
-        echo -e "\e[31m  cp $out/composer.lock <path>\e[0m"
-        echo -e '\e[31m2. Add the composerLock attribute, pointing to the copied composer.lock file:\e[0m'
-        echo -e '\e[31m  composerLock = ./composer.lock;\e[0m'
-        echo
-
-        exit 1
-    fi
-
-    echo "Finished composerRepositoryConfigureHook"
-}
-
-composerRepositoryBuildHook() {
-    echo "Executing composerRepositoryBuildHook"
-
-    mkdir -p repository
-
-    setComposeRootVersion
-
-    # Build the local composer repository
-    # The command 'build-local-repo' is provided by the Composer plugin
-    # nix-community/composer-local-repo-plugin.
-    composer-local-repo-plugin --no-ansi build-local-repo-lock ${composerNoDev:+--no-dev} -r repository
-
-    echo "Finished composerRepositoryBuildHook"
-}
-
-composerRepositoryCheckHook() {
-    echo "Executing composerRepositoryCheckHook"
-
-    checkComposerValidate
-
-    echo "Finished composerRepositoryCheckHook"
-}
-
-composerRepositoryInstallHook() {
-    echo "Executing composerRepositoryInstallHook"
-
-    mkdir -p $out
-
-    cp -ar repository/. $out/
-
-    # Copy the composer.lock files to the output directory, to be able to validate consistency with
-    # the src composer.lock file where this fixed-output derivation is used
-    cp composer.lock $out/
-
-    echo "Finished composerRepositoryInstallHook"
-}
diff --git a/pkgs/build-support/php/hooks/default.nix b/pkgs/build-support/php/hooks/default.nix
deleted file mode 100644
index ca96b1056db9d..0000000000000
--- a/pkgs/build-support/php/hooks/default.nix
+++ /dev/null
@@ -1,39 +0,0 @@
-{ lib
-, makeSetupHook
-, diffutils
-, jq
-, writeShellApplication
-, moreutils
-, cacert
-, buildPackages
-}:
-
-let
-  php-script-utils = writeShellApplication {
-    name = "php-script-utils";
-    runtimeInputs = [ jq ];
-    text = builtins.readFile ./php-script-utils.bash;
-  };
-in
-{
-  composerRepositoryHook = makeSetupHook
-    {
-      name = "composer-repository-hook.sh";
-      propagatedBuildInputs = [ jq moreutils cacert ];
-      substitutions = {
-        phpScriptUtils = lib.getExe php-script-utils;
-      };
-    } ./composer-repository-hook.sh;
-
-  composerInstallHook = makeSetupHook
-    {
-      name = "composer-install-hook.sh";
-      propagatedBuildInputs = [ jq moreutils cacert ];
-      substitutions = {
-        # Specify the stdenv's `diff` by abspath to ensure that the user's build
-        # inputs do not cause us to find the wrong `diff`.
-        cmp = "${lib.getBin buildPackages.diffutils}/bin/cmp";
-        phpScriptUtils = lib.getExe php-script-utils;
-      };
-    } ./composer-install-hook.sh;
-}
diff --git a/pkgs/build-support/php/hooks/php-script-utils.bash b/pkgs/build-support/php/hooks/php-script-utils.bash
deleted file mode 100644
index bba0242e65d1e..0000000000000
--- a/pkgs/build-support/php/hooks/php-script-utils.bash
+++ /dev/null
@@ -1,77 +0,0 @@
-declare version
-declare composerStrictValidation
-
-setComposeRootVersion() {
-    set +e # Disable exit on error
-
-    if [[ -v version ]]; then
-        echo -e "\e[32mSetting COMPOSER_ROOT_VERSION to $version\e[0m"
-        export COMPOSER_ROOT_VERSION=$version
-    fi
-
-    set -e
-}
-
-checkComposerValidate() {
-    if ! composer validate --strict --no-ansi --no-interaction --quiet --no-check-all --no-check-lock; then
-        if [ "1" == "${composerStrictValidation-}" ]; then
-            echo
-            echo -e "\e[31mERROR: composer files validation failed\e[0m"
-            echo
-            echo -e '\e[31mThe validation of the composer.json failed.\e[0m'
-            echo -e '\e[31mMake sure that the file composer.json is valid.\e[0m'
-            echo
-            echo -e '\e[31mTo address the issue efficiently, follow one of these steps:\e[0m'
-            echo -e '\e[31m  1. File an issue in the project'\''s issue tracker with detailed information, and apply any available remote patches as a temporary solution '\('with fetchpatch'\)'.\e[0m'
-            echo -e '\e[31m  2. If an immediate fix is needed or if reporting upstream isn'\''t suitable, develop a temporary local patch.\e[0m'
-            echo
-            exit 1
-        else
-            echo
-            echo -e "\e[33mWARNING: composer files validation failed\e[0m"
-            echo
-            echo -e '\e[33mThe validation of the composer.json failed.\e[0m'
-            echo -e '\e[33mMake sure that the file composer.json is valid.\e[0m'
-            echo
-            echo -e '\e[33mTo address the issue efficiently, follow one of these steps:\e[0m'
-            echo -e '\e[33m  1. File an issue in the project'\''s issue tracker with detailed information, and apply any available remote patches as a temporary solution with '\('with fetchpatch'\)'.\e[0m'
-            echo -e '\e[33m  2. If an immediate fix is needed or if reporting upstream isn'\''t suitable, develop a temporary local patch.\e[0m'
-            echo
-            echo -e '\e[33mThis check is not blocking, but it is recommended to fix the issue.\e[0m'
-            echo
-        fi
-    fi
-
-    if ! composer validate --strict --no-ansi --no-interaction --quiet --no-check-all --check-lock; then
-        if [ "1" == "${composerStrictValidation-}" ]; then
-            echo
-            echo -e "\e[31mERROR: composer files validation failed\e[0m"
-            echo
-            echo -e '\e[31mThe validation of the composer.json and composer.lock failed.\e[0m'
-            echo -e '\e[31mMake sure that the file composer.lock is consistent with composer.json.\e[0m'
-            echo
-            echo -e '\e[31mThis often indicates an issue with the upstream project, which can typically be resolved by reporting the issue to the relevant project maintainers.\e[0m'
-            echo
-            echo -e '\e[31mTo address the issue efficiently, follow one of these steps:\e[0m'
-            echo -e '\e[31m  1. File an issue in the project'\''s issue tracker with detailed information '\('run '\''composer update --lock --no-install'\'' to fix the issue'\)', and apply any available remote patches as a temporary solution with '\('with fetchpatch'\)'.\e[0m'
-            echo -e '\e[31m  2. If an immediate fix is needed or if reporting upstream isn'\''t suitable, develop a temporary local patch.\e[0m'
-            echo
-            exit 1
-        else
-            echo
-            echo -e "\e[33mWARNING: composer files validation failed\e[0m"
-            echo
-            echo -e '\e[33mThe validation of the composer.json and composer.lock failed.\e[0m'
-            echo -e '\e[33mMake sure that the file composer.lock is consistent with composer.json.\e[0m'
-            echo
-            echo -e '\e[33mThis often indicates an issue with the upstream project, which can typically be resolved by reporting the issue to the relevant project maintainers.\e[0m'
-            echo
-            echo -e '\e[33mTo address the issue efficiently, follow one of these steps:\e[0m'
-            echo -e '\e[33m  1. File an issue in the project'\''s issue tracker with detailed information '\('run '\''composer update --lock --no-install'\'' to fix the issue'\)', and apply any available remote patches as a temporary solution with '\('with fetchpatch'\)'.\e[0m'
-            echo -e '\e[33m  2. If an immediate fix is needed or if reporting upstream isn'\''t suitable, develop a temporary local patch.\e[0m'
-            echo
-            echo -e '\e[33mThis check is not blocking, but it is recommended to fix the issue.\e[0m'
-            echo
-        fi
-    fi
-}