From 2a2668aef9183e06018ae5cc0172ae434fbd02ba Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Thu, 24 Jul 2008 05:48:47 +0100 Subject: Cache d-i kernel, initrd and mini.iso downloads (Closes: #492085) --- helpers/lh_binary_debian-installer | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/helpers/lh_binary_debian-installer b/helpers/lh_binary_debian-installer index 85d88e37c..d285f332f 100755 --- a/helpers/lh_binary_debian-installer +++ b/helpers/lh_binary_debian-installer @@ -191,6 +191,10 @@ Install_file() { cp "${FILE}" "${TARGET}"/"${LETTER}"/"${SOURCE}" } +# Set absolute directory for caching; we require it when we call Download_file +# from a non-standard cwd. +_LH_CACHE_DIR="$(pwd)/cache/binary_debian-installer" + Download_file () { local _LH_TARGET _LH_TARGET="${1}" @@ -198,7 +202,15 @@ Download_file () { local _LH_URL _LH_URL="${2}" - wget ${WGET_OPTIONS} -O "${_LH_TARGET}" "${_LH_URL}" + _LH_CACHE_FILE="${_LH_CACHE_DIR}/$(echo "${_LH_URL}" | sed 's|/|_|g')" + + if [ ! -f "${_LH_CACHE_FILE}" ] + then + mkdir -p ${_LH_CACHE_DIR} + wget ${WGET_OPTIONS} -O "${_LH_CACHE_FILE}" "${_LH_URL}" + fi + + cp -fl "${_LH_CACHE_FILE}" "${_LH_TARGET}" } VMLINUZ_DI="vmlinuz" -- cgit v1.2.3