From 6538fac66feaa5cb7957013a29da704a09256e3f Mon Sep 17 00:00:00 2001
From: Chris Lamb <chris@chris-lamb.co.uk>
Date: Thu, 7 Aug 2008 20:08:04 +0100
Subject: Test whether to use hard-links when caching d-i downloads.

---
 helpers/lh_binary_debian-installer | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/helpers/lh_binary_debian-installer b/helpers/lh_binary_debian-installer
index c0bb74c..e579eec 100755
--- a/helpers/lh_binary_debian-installer
+++ b/helpers/lh_binary_debian-installer
@@ -216,7 +216,12 @@ Download_file () {
 		fi
 	fi
 
-	cp -fl "${_LH_CACHE_FILE}" "${_LH_TARGET}"
+	if [ "$(stat --printf %d "${_LH_CACHE_DIR}")" = "$(stat --printf %d ./)" ]
+	then
+		CP_OPTIONS="-l"
+	fi
+
+	cp -f ${CP_OPTIONS} -- "${_LH_CACHE_FILE}" "${_LH_TARGET}"
 }
 
 VMLINUZ_DI="vmlinuz"
-- 
cgit v1.0