build-support/php: add colors in case of errors

This commit is contained in:
Pol Dellaiera 2023-10-20 23:37:28 +02:00
parent 56720599ce
commit 921e3c16cc
No known key found for this signature in database
GPG key ID: D476DFE9C67467CA
2 changed files with 25 additions and 21 deletions

View file

@ -35,14 +35,16 @@ composerInstallConfigureHook() {
cp composer.lock $out/
echo
echo 'No composer.lock file found, consider adding one to your repository to ensure reproducible builds.'
echo "In the meantime, a composer.lock file has been generated for you in $out/composer.lock"
echo -e "\e[31mERROR: No composer.lock found\e[0m"
echo
echo 'To fix the issue:'
echo "1. Copy the composer.lock file from $out/composer.lock to the project's source:"
echo " cp $out/composer.lock <path>"
echo '2. Add the composerLock attribute, pointing to the copied composer.lock file:'
echo ' composerLock = ./composer.lock;'
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
@ -51,15 +53,15 @@ composerInstallConfigureHook() {
echo "Validating consistency between composer.lock and ${composerRepository}/composer.lock"
if ! @cmp@ -s "composer.lock" "${composerRepository}/composer.lock"; then
echo
echo "ERROR: vendorHash is out of date"
echo -e "\e[31mERROR: vendorHash is out of date\e[0m"
echo
echo "composer.lock is not the same in $composerRepository"
echo -e "\e[31mcomposer.lock is not the same in $composerRepository\e[0m"
echo
echo "To fix the issue:"
echo '1. Set vendorHash to an empty string: `vendorHash = "";`'
echo '2. Build the derivation and wait for it to fail with a hash mismatch'
echo '3. Copy the "got: sha256-..." value back into the vendorHash field'
echo ' You should have: vendorHash = "sha256-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=";'
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

View file

@ -31,14 +31,16 @@ composerRepositoryConfigureHook() {
cp composer.lock $out/
echo
echo 'No composer.lock file found, consider adding one to your repository to ensure reproducible builds.'
echo "In the meantime, a composer.lock file has been generated for you in $out/composer.lock"
echo -e "\e[31mERROR: No composer.lock found\e[0m"
echo
echo 'To fix the issue:'
echo "1. Copy the composer.lock file from $out/composer.lock to the project's source:"
echo " cp $out/composer.lock <path>"
echo '2. Add the composerLock attribute, pointing to the copied composer.lock file:'
echo ' composerLock = ./composer.lock;'
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