build-support/php: run `shfmt` on hooks

+164 -164
+33 -33
pkgs/build-support/php/builders/v2/hooks/composer-install-hook.sh
··· 11 11 source @phpScriptUtils@ 12 12 13 13 composerInstallConfigureHook() { 14 - echo "Executing composerInstallConfigureHook" 14 + echo "Executing composerInstallConfigureHook" 15 15 16 - setComposerRootVersion 16 + setComposerRootVersion 17 17 18 - if [[ ! -e "${composerVendor}" ]]; then 19 - echo "No local composer vendor found." >&2 20 - exit 1 21 - fi 18 + if [[ ! -e "${composerVendor}" ]]; then 19 + echo "No local composer vendor found." >&2 20 + exit 1 21 + fi 22 22 23 - install -Dm644 ${composerVendor}/composer.json . 23 + install -Dm644 ${composerVendor}/composer.json . 24 24 25 - if [[ -f "${composerVendor}/composer.lock" ]]; then 26 - install -Dm644 ${composerVendor}/composer.lock . 27 - fi 25 + if [[ -f "${composerVendor}/composer.lock" ]]; then 26 + install -Dm644 ${composerVendor}/composer.lock . 27 + fi 28 28 29 - if [[ -f "composer.lock" ]]; then 30 - chmod +w composer.lock 31 - fi 29 + if [[ -f "composer.lock" ]]; then 30 + chmod +w composer.lock 31 + fi 32 32 33 - chmod +w composer.json 33 + chmod +w composer.json 34 34 35 - echo "Finished composerInstallConfigureHook" 35 + echo "Finished composerInstallConfigureHook" 36 36 } 37 37 38 38 composerInstallBuildHook() { 39 - echo "Executing composerInstallBuildHook" 39 + echo "Executing composerInstallBuildHook" 40 40 41 - echo "Finished composerInstallBuildHook" 41 + echo "Finished composerInstallBuildHook" 42 42 } 43 43 44 44 composerInstallCheckHook() { 45 - echo "Executing composerInstallCheckHook" 45 + echo "Executing composerInstallCheckHook" 46 46 47 - checkComposerValidate 47 + checkComposerValidate 48 48 49 - echo "Finished composerInstallCheckHook" 49 + echo "Finished composerInstallCheckHook" 50 50 } 51 51 52 52 composerInstallInstallHook() { 53 - echo "Executing composerInstallInstallHook" 53 + echo "Executing composerInstallInstallHook" 54 54 55 - cp -ar ${composerVendor}/* . 55 + cp -ar ${composerVendor}/* . 56 56 57 - # Copy the relevant files only in the store. 58 - mkdir -p "$out"/share/php/"${pname}" 59 - cp -r . "$out"/share/php/"${pname}"/ 57 + # Copy the relevant files only in the store. 58 + mkdir -p "$out"/share/php/"${pname}" 59 + cp -r . "$out"/share/php/"${pname}"/ 60 60 61 - # Create symlinks for the binaries. 62 - mapfile -t BINS < <(jq -r -c 'try (.bin[] | select(test(".bat$")? | not) )' composer.json) 63 - for bin in "${BINS[@]}"; do 64 - echo -e "\e[32mCreating symlink ${bin}...\e[0m" 65 - mkdir -p "$out/bin" 66 - ln -s "$out/share/php/${pname}/${bin}" "$out/bin/$(basename "$bin")" 67 - done 61 + # Create symlinks for the binaries. 62 + mapfile -t BINS < <(jq -r -c 'try (.bin[] | select(test(".bat$")? | not) )' composer.json) 63 + for bin in "${BINS[@]}"; do 64 + echo -e "\e[32mCreating symlink ${bin}...\e[0m" 65 + mkdir -p "$out/bin" 66 + ln -s "$out/share/php/${pname}/${bin}" "$out/bin/$(basename "$bin")" 67 + done 68 68 69 - echo "Finished composerInstallInstallHook" 69 + echo "Finished composerInstallInstallHook" 70 70 }
+77 -77
pkgs/build-support/php/builders/v2/hooks/composer-vendor-hook.sh
··· 10 10 preInstallHooks+=(composerVendorInstallHook) 11 11 12 12 composerVendorConfigureHook() { 13 - echo "Executing composerVendorConfigureHook" 13 + echo "Executing composerVendorConfigureHook" 14 14 15 - setComposerRootVersion 15 + setComposerRootVersion 16 16 17 - if [[ -f "composer.lock" ]]; then 18 - echo -e "\e[32mUsing \`composer.lock\` file from the source package\e[0m" 19 - fi 17 + if [[ -f "composer.lock" ]]; then 18 + echo -e "\e[32mUsing \`composer.lock\` file from the source package\e[0m" 19 + fi 20 20 21 - if [[ -e "$composerLock" ]]; then 22 - echo -e "\e[32mUsing user provided \`composer.lock\` file from \`$composerLock\`\e[0m" 23 - install -Dm644 $composerLock ./composer.lock 24 - fi 21 + if [[ -e "$composerLock" ]]; then 22 + echo -e "\e[32mUsing user provided \`composer.lock\` file from \`$composerLock\`\e[0m" 23 + install -Dm644 $composerLock ./composer.lock 24 + fi 25 25 26 - if [[ ! -f "composer.lock" ]]; then 27 - composer \ 28 - --no-cache \ 29 - --no-install \ 30 - --no-interaction \ 31 - --no-progress \ 32 - --optimize-autoloader \ 33 - ${composerNoDev} \ 34 - ${composerNoPlugins} \ 35 - ${composerNoScripts} \ 36 - update 26 + if [[ ! -f "composer.lock" ]]; then 27 + composer \ 28 + --no-cache \ 29 + --no-install \ 30 + --no-interaction \ 31 + --no-progress \ 32 + --optimize-autoloader \ 33 + ${composerNoDev} \ 34 + ${composerNoPlugins} \ 35 + ${composerNoScripts} \ 36 + update 37 37 38 - if [[ -f "composer.lock" ]]; then 39 - install -Dm644 composer.lock -t $out/ 38 + if [[ -f "composer.lock" ]]; then 39 + install -Dm644 composer.lock -t $out/ 40 40 41 - echo 42 - echo -e "\e[31mERROR: No composer.lock found\e[0m" 43 - echo 44 - echo -e '\e[31mNo composer.lock file found, consider adding one to your repository to ensure reproducible builds.\e[0m' 45 - echo -e "\e[31mIn the meantime, a composer.lock file has been generated for you in $out/composer.lock\e[0m" 46 - echo 47 - echo -e '\e[31mTo fix the issue:\e[0m' 48 - echo -e "\e[31m1. Copy the composer.lock file from $out/composer.lock to the project's source:\e[0m" 49 - echo -e "\e[31m cp $out/composer.lock <path>\e[0m" 50 - echo -e '\e[31m2. Add the composerLock attribute, pointing to the copied composer.lock file:\e[0m' 51 - echo -e '\e[31m composerLock = ./composer.lock;\e[0m' 52 - echo 41 + echo 42 + echo -e "\e[31mERROR: No composer.lock found\e[0m" 43 + echo 44 + echo -e '\e[31mNo composer.lock file found, consider adding one to your repository to ensure reproducible builds.\e[0m' 45 + echo -e "\e[31mIn the meantime, a composer.lock file has been generated for you in $out/composer.lock\e[0m" 46 + echo 47 + echo -e '\e[31mTo fix the issue:\e[0m' 48 + echo -e "\e[31m1. Copy the composer.lock file from $out/composer.lock to the project's source:\e[0m" 49 + echo -e "\e[31m cp $out/composer.lock <path>\e[0m" 50 + echo -e '\e[31m2. Add the composerLock attribute, pointing to the copied composer.lock file:\e[0m' 51 + echo -e '\e[31m composerLock = ./composer.lock;\e[0m' 52 + echo 53 53 54 - exit 1 55 - fi 54 + exit 1 56 55 fi 56 + fi 57 57 58 - if [[ -f "composer.lock" ]]; then 59 - chmod +w composer.lock 60 - fi 58 + if [[ -f "composer.lock" ]]; then 59 + chmod +w composer.lock 60 + fi 61 61 62 - chmod +w composer.json 62 + chmod +w composer.json 63 63 64 - echo "Finished composerVendorConfigureHook" 64 + echo "Finished composerVendorConfigureHook" 65 65 } 66 66 67 67 composerVendorBuildHook() { 68 - echo "Executing composerVendorBuildHook" 68 + echo "Executing composerVendorBuildHook" 69 69 70 - setComposerEnvVariables 70 + setComposerEnvVariables 71 71 72 - composer \ 73 - --no-cache \ 74 - --no-interaction \ 75 - --no-progress \ 76 - --optimize-autoloader \ 77 - ${composerNoDev} \ 78 - ${composerNoPlugins} \ 79 - ${composerNoScripts} \ 80 - install 72 + composer \ 73 + --no-cache \ 74 + --no-interaction \ 75 + --no-progress \ 76 + --optimize-autoloader \ 77 + ${composerNoDev} \ 78 + ${composerNoPlugins} \ 79 + ${composerNoScripts} \ 80 + install 81 81 82 - echo "Finished composerVendorBuildHook" 82 + echo "Finished composerVendorBuildHook" 83 83 } 84 84 85 85 composerVendorCheckHook() { 86 - echo "Executing composerVendorCheckHook" 86 + echo "Executing composerVendorCheckHook" 87 87 88 - checkComposerValidate 88 + checkComposerValidate 89 89 90 - echo "Finished composerVendorCheckHook" 90 + echo "Finished composerVendorCheckHook" 91 91 } 92 92 93 93 composerVendorInstallHook() { 94 - echo "Executing composerVendorInstallHook" 94 + echo "Executing composerVendorInstallHook" 95 95 96 - mkdir -p $out 96 + mkdir -p $out 97 97 98 - cp -ar composer.json $(composer config vendor-dir) $out/ 99 - mapfile -t installer_paths < <(jq -r -c 'try((.extra."installer-paths") | keys[])' composer.json) 98 + cp -ar composer.json $(composer config vendor-dir) $out/ 99 + mapfile -t installer_paths < <(jq -r -c 'try((.extra."installer-paths") | keys[])' composer.json) 100 100 101 - for installer_path in "${installer_paths[@]}"; do 102 - # Remove everything after {$name} placeholder 103 - installer_path="${installer_path/\{\$name\}*/}"; 104 - out_installer_path="$out/${installer_path/\{\$name\}*/}"; 105 - # Copy the installer path if it exists 106 - if [[ -d "$installer_path" ]]; then 107 - mkdir -p $(dirname "$out_installer_path") 108 - echo -e "\e[32mCopying installer path $installer_path to $out_installer_path\e[0m" 109 - cp -ar "$installer_path" "$out_installer_path" 110 - # Strip out the git repositories 111 - find $out_installer_path -name .git -type d -prune -print -exec rm -rf {} ";" 112 - fi 113 - done 114 - 115 - if [[ -f "composer.lock" ]]; then 116 - cp -ar composer.lock $out/ 101 + for installer_path in "${installer_paths[@]}"; do 102 + # Remove everything after {$name} placeholder 103 + installer_path="${installer_path/\{\$name\}*/}" 104 + out_installer_path="$out/${installer_path/\{\$name\}*/}" 105 + # Copy the installer path if it exists 106 + if [[ -d "$installer_path" ]]; then 107 + mkdir -p $(dirname "$out_installer_path") 108 + echo -e "\e[32mCopying installer path $installer_path to $out_installer_path\e[0m" 109 + cp -ar "$installer_path" "$out_installer_path" 110 + # Strip out the git repositories 111 + find $out_installer_path -name .git -type d -prune -print -exec rm -rf {} ";" 117 112 fi 113 + done 118 114 119 - echo "Finished composerVendorInstallHook" 115 + if [[ -f "composer.lock" ]]; then 116 + cp -ar composer.lock $out/ 117 + fi 118 + 119 + echo "Finished composerVendorInstallHook" 120 120 }
+54 -54
pkgs/build-support/php/builders/v2/hooks/php-script-utils.bash
··· 2 2 declare -g -i composerStrictValidation="${composerStrictValidation:-0}" 3 3 4 4 setComposerRootVersion() { 5 - if [[ -n $version ]]; then 6 - echo -e "\e[32mSetting COMPOSER_ROOT_VERSION to $version\e[0m" 7 - export COMPOSER_ROOT_VERSION="$version" 8 - fi 5 + if [[ -n $version ]]; then 6 + echo -e "\e[32mSetting COMPOSER_ROOT_VERSION to $version\e[0m" 7 + export COMPOSER_ROOT_VERSION="$version" 8 + fi 9 9 } 10 10 11 11 setComposerEnvVariables() { 12 - echo -e "\e[32mSetting some required environment variables for Composer...\e[0m" 13 - export COMPOSER_MIRROR_PATH_REPOS=1 14 - export COMPOSER_HTACCESS_PROTECT=0 15 - export COMPOSER_FUND=0 12 + echo -e "\e[32mSetting some required environment variables for Composer...\e[0m" 13 + export COMPOSER_MIRROR_PATH_REPOS=1 14 + export COMPOSER_HTACCESS_PROTECT=0 15 + export COMPOSER_FUND=0 16 16 } 17 17 18 18 checkComposerValidate() { 19 - command="composer validate --strict --quiet --no-interaction --no-check-all --no-check-lock" 20 - if ! $command; then 21 - echo 22 - echo -e "\e[31mERROR: composer files validation failed\e[0m" 23 - echo 24 - echo -e '\e[31mThe validation of the composer.json failed.\e[0m' 25 - echo -e '\e[31mMake sure that the file composer.json is valid.\e[0m' 26 - echo 27 - echo -e '\e[31mTo address the issue efficiently, follow one of these steps:\e[0m' 28 - 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' 29 - 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' 30 - echo 19 + command="composer validate --strict --quiet --no-interaction --no-check-all --no-check-lock" 20 + if ! $command; then 21 + echo 22 + echo -e "\e[31mERROR: composer files validation failed\e[0m" 23 + echo 24 + echo -e '\e[31mThe validation of the composer.json failed.\e[0m' 25 + echo -e '\e[31mMake sure that the file composer.json is valid.\e[0m' 26 + echo 27 + echo -e '\e[31mTo address the issue efficiently, follow one of these steps:\e[0m' 28 + 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' 29 + 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' 30 + echo 31 31 32 - if [[ "${composerStrictValidation}" == "1" ]]; then 33 - echo 34 - echo -e '\e[33mThis check is blocking, set the attribute composerStrictValidation to false to make it not blocking.\e[0m' 35 - echo 36 - exit 1 37 - else 38 - echo 39 - echo -e '\e[33mThis check is not blocking, but it is recommended to fix the issue.\e[0m' 40 - echo 41 - fi 32 + if [[ "${composerStrictValidation}" == "1" ]]; then 33 + echo 34 + echo -e '\e[33mThis check is blocking, set the attribute composerStrictValidation to false to make it not blocking.\e[0m' 35 + echo 36 + exit 1 37 + else 38 + echo 39 + echo -e '\e[33mThis check is not blocking, but it is recommended to fix the issue.\e[0m' 40 + echo 42 41 fi 42 + fi 43 43 44 - command="composer validate --strict --no-ansi --no-interaction --quiet --no-check-all --check-lock" 45 - if ! $command; then 46 - echo 47 - echo -e "\e[31mERROR: composer files validation failed\e[0m" 48 - echo 49 - echo -e '\e[31mThe validation of the composer.json and composer.lock failed.\e[0m' 50 - echo -e '\e[31mMake sure that the file composer.lock is consistent with composer.json.\e[0m' 51 - echo 52 - 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' 53 - echo 54 - echo -e '\e[31mTo address the issue efficiently, follow one of these steps:\e[0m' 55 - 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' 56 - 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' 57 - echo 44 + command="composer validate --strict --no-ansi --no-interaction --quiet --no-check-all --check-lock" 45 + if ! $command; then 46 + echo 47 + echo -e "\e[31mERROR: composer files validation failed\e[0m" 48 + echo 49 + echo -e '\e[31mThe validation of the composer.json and composer.lock failed.\e[0m' 50 + echo -e '\e[31mMake sure that the file composer.lock is consistent with composer.json.\e[0m' 51 + echo 52 + 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' 53 + echo 54 + echo -e '\e[31mTo address the issue efficiently, follow one of these steps:\e[0m' 55 + 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' 56 + 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' 57 + echo 58 58 59 - if [[ "${composerStrictValidation}" == "1" ]]; then 60 - echo 61 - echo -e '\e[33mThis check is blocking, set the attribute composerStrictValidation to false to make it not blocking.\e[0m' 62 - echo 63 - exit 1 64 - else 65 - echo 66 - echo -e '\e[33mThis check is not blocking, but it is recommended to fix the issue.\e[0m' 67 - echo 68 - fi 59 + if [[ "${composerStrictValidation}" == "1" ]]; then 60 + echo 61 + echo -e '\e[33mThis check is blocking, set the attribute composerStrictValidation to false to make it not blocking.\e[0m' 62 + echo 63 + exit 1 64 + else 65 + echo 66 + echo -e '\e[33mThis check is not blocking, but it is recommended to fix the issue.\e[0m' 67 + echo 69 68 fi 69 + fi 70 70 }