2023-04-09 09:53:42 +00:00
|
|
|
declare composerLock
|
|
|
|
declare version
|
2023-08-21 10:19:17 +00:00
|
|
|
declare composerNoDev
|
|
|
|
declare composerNoPlugins
|
|
|
|
declare composerNoScripts
|
2023-10-20 21:36:26 +00:00
|
|
|
declare composerStrictValidation
|
2023-04-09 09:53:42 +00:00
|
|
|
|
|
|
|
preConfigureHooks+=(composerRepositoryConfigureHook)
|
|
|
|
preBuildHooks+=(composerRepositoryBuildHook)
|
|
|
|
preCheckHooks+=(composerRepositoryCheckHook)
|
|
|
|
preInstallHooks+=(composerRepositoryInstallHook)
|
|
|
|
|
2024-02-19 09:14:19 +00:00
|
|
|
source @phpScriptUtils@
|
|
|
|
|
2023-04-09 09:53:42 +00:00
|
|
|
composerRepositoryConfigureHook() {
|
|
|
|
echo "Executing composerRepositoryConfigureHook"
|
|
|
|
|
|
|
|
if [[ -e "$composerLock" ]]; then
|
|
|
|
cp $composerLock composer.lock
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -f "composer.lock" ]]; then
|
2024-02-19 09:14:19 +00:00
|
|
|
setComposeRootVersion
|
|
|
|
|
2023-10-04 12:58:40 +00:00
|
|
|
composer \
|
|
|
|
--no-ansi \
|
|
|
|
--no-install \
|
|
|
|
--no-interaction \
|
|
|
|
${composerNoDev:+--no-dev} \
|
|
|
|
${composerNoPlugins:+--no-plugins} \
|
|
|
|
${composerNoScripts:+--no-scripts} \
|
|
|
|
update
|
|
|
|
|
|
|
|
mkdir -p $out
|
|
|
|
cp composer.lock $out/
|
|
|
|
|
|
|
|
echo
|
2023-10-20 21:37:28 +00:00
|
|
|
echo -e "\e[31mERROR: No composer.lock found\e[0m"
|
2023-10-04 12:58:40 +00:00
|
|
|
echo
|
2023-10-20 21:37:28 +00:00
|
|
|
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'
|
2023-10-04 12:58:40 +00:00
|
|
|
echo
|
|
|
|
|
2023-10-04 11:34:43 +00:00
|
|
|
exit 1
|
2023-04-09 09:53:42 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Finished composerRepositoryConfigureHook"
|
|
|
|
}
|
|
|
|
|
|
|
|
composerRepositoryBuildHook() {
|
|
|
|
echo "Executing composerRepositoryBuildHook"
|
|
|
|
|
|
|
|
mkdir -p repository
|
|
|
|
|
2024-02-19 09:14:19 +00:00
|
|
|
setComposeRootVersion
|
|
|
|
|
2023-04-09 09:53:42 +00:00
|
|
|
# Build the local composer repository
|
|
|
|
# The command 'build-local-repo' is provided by the Composer plugin
|
|
|
|
# nix-community/composer-local-repo-plugin.
|
2024-02-13 14:33:27 +00:00
|
|
|
composer-local-repo-plugin --no-ansi build-local-repo-lock ${composerNoDev:+--no-dev} -r repository
|
2023-04-09 09:53:42 +00:00
|
|
|
|
|
|
|
echo "Finished composerRepositoryBuildHook"
|
|
|
|
}
|
|
|
|
|
|
|
|
composerRepositoryCheckHook() {
|
|
|
|
echo "Executing composerRepositoryCheckHook"
|
|
|
|
|
2024-03-05 14:25:16 +00:00
|
|
|
checkComposerValidate
|
2023-04-09 09:53:42 +00:00
|
|
|
|
|
|
|
echo "Finished composerRepositoryCheckHook"
|
|
|
|
}
|
|
|
|
|
|
|
|
composerRepositoryInstallHook() {
|
|
|
|
echo "Executing composerRepositoryInstallHook"
|
|
|
|
|
|
|
|
mkdir -p $out
|
|
|
|
|
|
|
|
cp -ar repository/. $out/
|
|
|
|
|
2023-10-04 11:34:43 +00:00
|
|
|
# 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
|
2023-04-09 09:53:42 +00:00
|
|
|
cp composer.lock $out/
|
|
|
|
|
|
|
|
echo "Finished composerRepositoryInstallHook"
|
|
|
|
}
|