Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release-24.11] Manual backport of #372696 to release 24.11 #372751

Merged
merged 9 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 8 additions & 29 deletions pkgs/build-support/php/builders/v2/hooks/composer-install-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,17 @@ composerInstallConfigureHook() {
exit 1
fi

install -Dm644 ${composerVendor}/composer.{json,lock} .

if [[ ! -f "composer.lock" ]]; then
composer \
--no-install \
--no-interaction \
--no-progress \
--optimize-autoloader \
${composerNoDev:+--no-dev} \
${composerNoPlugins:+--no-plugins} \
${composerNoScripts:+--no-scripts} \
update

install -Dm644 composer.lock -t $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
install -Dm644 ${composerVendor}/composer.json .

exit 1
if [[ -f "${composerVendor}/composer.lock" ]]; then
install -Dm644 ${composerVendor}/composer.lock .
fi

if [[ -f "composer.lock" ]]; then
chmod +w composer.lock
fi

chmod +w composer.{json,lock}
chmod +w composer.json

echo "Finished composerInstallConfigureHook"
}
Expand Down
54 changes: 32 additions & 22 deletions pkgs/build-support/php/builders/v2/hooks/composer-vendor-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ composerVendorConfigureHook() {
install -Dm644 $composerLock ./composer.lock
fi


if [[ ! -f "composer.lock" ]]; then
composer \
--no-cache \
--no-install \
--no-interaction \
--no-progress \
Expand All @@ -33,25 +35,31 @@ composerVendorConfigureHook() {
${composerNoScripts:+--no-scripts} \
update

install -Dm644 composer.lock -t $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
if [[ -f "composer.lock" ]]; then
install -Dm644 composer.lock -t $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
fi

if [[ -f "composer.lock" ]]; then
chmod +w composer.lock
fi

chmod +w composer.{json,lock}
chmod +w composer.json

echo "Finished composerVendorConfigureHook"
}
Expand All @@ -62,10 +70,7 @@ composerVendorBuildHook() {
setComposerEnvVariables

composer \
`# The acpu-autoloader is not reproducible and has to be disabled.` \
`# Upstream PR: https://github.com/composer/composer/pull/12090` \
`# --apcu-autoloader` \
`# --apcu-autoloader-prefix="$(jq -r -c 'try ."content-hash"' < composer.lock)"` \
--no-cache \
--no-interaction \
--no-progress \
--optimize-autoloader \
Expand All @@ -89,7 +94,12 @@ composerVendorInstallHook() {
echo "Executing composerVendorInstallHook"

mkdir -p $out
cp -ar composer.{json,lock} $(composer config vendor-dir) $out/

cp -ar composer.json $(composer config vendor-dir) $out/

if [[ -f "composer.lock" ]]; then
cp -ar composer.lock $(composer config vendor-dir) $out/
fi

echo "Finished composerVendorInstallHook"
}
17 changes: 7 additions & 10 deletions pkgs/by-name/ph/phpdocumentor/package.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{ lib
, php
, fetchFromGitHub
, makeBinaryWrapper
{
lib,
php,
fetchFromGitHub,
makeBinaryWrapper,
}:

php.buildComposerProject (finalAttrs: {
Expand All @@ -11,7 +12,7 @@ php.buildComposerProject (finalAttrs: {
src = fetchFromGitHub {
owner = "phpDocumentor";
repo = "phpDocumentor";
rev = "v${finalAttrs.version}";
tag = "v${finalAttrs.version}";
hash = "sha256-zpAKygpxyKYfefa5ag76saTSQNLon/v3rYkl0Nj2+FM=";
};

Expand All @@ -22,14 +23,10 @@ php.buildComposerProject (finalAttrs: {

nativeBuildInputs = [ makeBinaryWrapper ];

installPhase = ''
runHook preInstall

postInstall = ''
wrapProgram "$out/bin/phpdoc" \
--set-default APP_CACHE_DIR /tmp \
--set-default APP_LOG_DIR /tmp/log

runHook postInstall
'';

meta = {
Expand Down
8 changes: 4 additions & 4 deletions pkgs/by-name/ph/phpunit/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

php.buildComposerProject2 (finalAttrs: {
pname = "phpunit";
version = "11.3.6";
version = "11.5.2";

src = fetchFromGitHub {
owner = "sebastianbergmann";
repo = "phpunit";
rev = finalAttrs.version;
hash = "sha256-bJdatRBrORR7KPcpRVIPYo2picQSfh8Pa0waeOZAH8Q=";
tag = finalAttrs.version;
hash = "sha256-0NVoaUFmmV4EtaErhaqLxJzCbD2WuMaVZC2OHG9+gSA=";
};

vendorHash = "sha256-wRgYEwbvvEGCp7/Rat+WUkvv04JqFHssHXtJjeQZo3o=";
vendorHash = "sha256-C1BmMURmAMQhDS6iAKC80wqZuYdSRPGyFpU9Jdr6snA=";

passthru = {
updateScript = nix-update-script { };
Expand Down
25 changes: 18 additions & 7 deletions pkgs/development/php-packages/composer/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@
lib,
stdenvNoCC,
fetchFromGitHub,
fetchpatch,
callPackage,
php,
unzip,
_7zz,
xz,
git,
gitMinimal,
curl,
cacert,
makeBinaryWrapper,
}:

stdenvNoCC.mkDerivation (finalAttrs: {
pname = "composer";
version = "2.8.1";
version = "2.8.4";

# Hash used by ../../../build-support/php/pkgs/composer-phar.nix to
# use together with the version from this package to keep the
# bootstrap phar file up-to-date together with the end user composer
# package.
passthru.pharHash = "sha256-kws3b70hR6Yj6ntwTrnTuLDWBymSIHqgU1qiH28FN44=";
passthru.pharHash = "sha256-xMTi4b6rDqBOC9BCpdu6n+2h+/XtoNNiA5WO3TQ8Coo=";

composer = callPackage ../../../build-support/php/pkgs/composer-phar.nix {
inherit (finalAttrs) version;
Expand All @@ -31,10 +32,20 @@ stdenvNoCC.mkDerivation (finalAttrs: {
src = fetchFromGitHub {
owner = "composer";
repo = "composer";
rev = finalAttrs.version;
hash = "sha256-5UcbEx1d5jEz73mTFTacifl6ykxm6yQw3wvkJQtINHs=";
tag = finalAttrs.version;
hash = "sha256-m4CfWWbrmMN0j27XaMx/KRbFjpW5iMMNUlAtzlrorJc=";
};

patches = [
# Fix an issue preventing reproducible builds
# This patch should be removed at the next release (2.8.5)
# More information at https://github.com/composer/composer/pull/12090
(fetchpatch {
url = "https://github.com/composer/composer/commit/7b1e983ce9a0b30a6369cda11a7d61cca9c1ce46.patch";
hash = "sha256-veBdfZxzgL/R3P87GpvxQc+es3AdpaKSzCX0DCzH63U=";
})
];

nativeBuildInputs = [ makeBinaryWrapper ];

buildInputs = [ php ];
Expand Down Expand Up @@ -86,7 +97,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {

outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "sha256-FfFwx5E2LVDSqo2P31fqtvk2P30XnTm+TUqhNSHTt/M=";
outputHash = "sha256-McyO3Z4PSyC6LiWt8rsXziAIbEqOhiaT77gUdzZ6tzw=";
};

installPhase = ''
Expand All @@ -101,7 +112,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
lib.makeBinPath [
_7zz
curl
git
gitMinimal
unzip
xz
]
Expand Down
Loading
Loading