3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #211910 from tejing1/srcs-name-collision

stdenv: Improve error from `stdenv` when `srcs` is used with colliding directories
This commit is contained in:
Sergei Trofimovich 2023-01-29 12:04:42 +00:00 committed by GitHub
commit b3a97d7eb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -992,13 +992,22 @@ stripHash() {
unpackCmdHooks+=(_defaultUnpack)
_defaultUnpack() {
local fn="$1"
local destination
if [ -d "$fn" ]; then
destination="$(stripHash "$fn")"
if [ -e "$destination" ]; then
echo "Cannot copy $fn to $destination: destination already exists!"
echo "Did you specify two \"srcs\" with the same \"name\"?"
return 1
fi
# We can't preserve hardlinks because they may have been
# introduced by store optimization, which might break things
# in the build.
cp -pr --reflink=auto -- "$fn" "$(stripHash "$fn")"
cp -pr --reflink=auto -- "$fn" "$destination"
else