nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 73 lines 1.8 kB view raw
1# shellcheck shell=bash 2 3declare -g out 4declare -g pname 5declare -g composerVendor 6declare -g -i composerStrictValidation="${composerStrictValidation:-0}" 7 8preConfigureHooks+=(composerInstallConfigureHook) 9preBuildHooks+=(composerInstallBuildHook) 10preCheckHooks+=(composerInstallCheckHook) 11preInstallHooks+=(composerInstallInstallHook) 12 13# shellcheck source=/dev/null 14source @phpScriptUtils@ 15 16composerInstallConfigureHook() { 17 echo "Executing composerInstallConfigureHook" 18 19 setComposerRootVersion 20 21 if [[ ! -e "${composerVendor}" ]]; then 22 echo "No local composer vendor found." >&2 23 exit 1 24 fi 25 26 install -Dm644 "${composerVendor}"/composer.json . 27 28 if [[ -f "${composerVendor}/composer.lock" ]]; then 29 install -Dm644 "${composerVendor}"/composer.lock . 30 fi 31 32 if [[ -f "composer.lock" ]]; then 33 chmod +w composer.lock 34 fi 35 36 chmod +w composer.json 37 38 echo "Finished composerInstallConfigureHook" 39} 40 41composerInstallBuildHook() { 42 echo "Executing composerInstallBuildHook" 43 44 echo "Finished composerInstallBuildHook" 45} 46 47composerInstallCheckHook() { 48 echo "Executing composerInstallCheckHook" 49 50 checkComposerValidate 51 52 echo "Finished composerInstallCheckHook" 53} 54 55composerInstallInstallHook() { 56 echo "Executing composerInstallInstallHook" 57 58 cp -ar "${composerVendor}"/* . 59 60 # Copy the relevant files only in the store. 61 mkdir -p "$out"/share/php/"${pname}" 62 cp -r . "$out"/share/php/"${pname}"/ 63 64 # Create symlinks for the binaries. 65 mapfile -t BINS < <(jq -r -c 'try (.bin[] | select(test(".bat$")? | not) )' composer.json) 66 for bin in "${BINS[@]}"; do 67 echo -e "\e[32mCreating symlink ${bin}...\e[0m" 68 mkdir -p "$out/bin" 69 ln -s "$out/share/php/${pname}/${bin}" "$out/bin/$(basename "$bin")" 70 done 71 72 echo "Finished composerInstallInstallHook" 73}