summary refs log tree commit diff
path: root/pkgs/stdenv/generic/setup.sh
diff options
context:
space:
mode:
authorJeff Huffman <tejing@tejing.com>2023-01-21 05:33:20 -0500
committerJeff Huffman <tejing@tejing.com>2023-01-29 04:27:24 -0500
commit183939da54831b11f389d9863a0e5b41aaf1ddc5 (patch)
tree8a35c22a854a97d02bbb5d6d2339e561035186a5 /pkgs/stdenv/generic/setup.sh
parent2773ad7600eddefb8cbc221f8c5b94d2cc954bb5 (diff)
improve error when srcs is used with directories with the same post-hash name
Diffstat (limited to 'pkgs/stdenv/generic/setup.sh')
-rw-r--r--pkgs/stdenv/generic/setup.sh11
1 files changed, 10 insertions, 1 deletions
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh
index b1b982ecdffc1..cbf2a2ceb8dee 100644
--- a/pkgs/stdenv/generic/setup.sh
+++ b/pkgs/stdenv/generic/setup.sh
@@ -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