Package: di-netboot-assistant
Version: 0.36
Severity: wishlist
Tags: patch

The attached patch attached ensures di-netboot-assistant respects HTTP
Last-modified headers where appropriate and only re-downloads a image if
it has changed relative to a possible version in the cache.

In the case of wget, some ugly manuevering is required as the -N and -O
options are famously mutually exclusive. In addition, the change to curl's
options (filed elsewhere as #493664) is also incorporated here.


Regards,

-- 
Chris Lamb, UK                                       [EMAIL PROTECTED]
                                                            GPG: 0x634F9A20
diff -urNad di-netboot-assistant-0.36.orig/usr/bin/di-netboot-assistant 
di-netboot-assistant-0.36/usr/bin/di-netboot-assistant
--- di-netboot-assistant-0.36.orig/usr/bin/di-netboot-assistant 2008-08-04 
03:17:55.000000000 +0100
+++ di-netboot-assistant-0.36/usr/bin/di-netboot-assistant      2008-08-04 
03:37:36.000000000 +0100
@@ -30,6 +30,7 @@
 SYSLINUX=/usr/lib/syslinux/
 ELILO=/usr/lib/elilo/
 DL_CACHE=/var/cache/di-netboot-assistant/
+DL_TEMP=/var/cache/di-netboot-assistant/tmp/
 TFTP_ROOT=/var/lib/tftpboot
 REWRITEPKGPATH='\(debian\|ubuntu\)-installer'
 UMASKOLD=`umask -p`
@@ -269,9 +270,9 @@
 
        if [ ! "$OFFLINE" ]; then
                if which wget > /dev/null ; then
-                       GETTER="wget -c -x $WGET_VERBOSITY -O"
+                       GETTER="wget"
                elif which curl > /dev/null ; then
-                       GETTER="curl $CURL_VERBOSITY -o"
+                       GETTER="curl"
                else
                        echo "E: Can't download file. no download tool detected 
(wget or curl)." 1>&2
                        echo "" 1>&2
@@ -289,7 +290,39 @@
                [ -e $file.tmp ] && rm $file.tmp
 
                if [ ! "$OFFLINE" ]; then
-                       if $GETTER "$file.tmp" -- "$url" ; then
+                       downloaded="false"
+
+                       case "${GETTER}" in
+                               wget)
+                                       mkdir -p "${DL_TEMP}"
+                                       tmpfile="${DL_TEMP}/$(basename $url)"
+
+                                       if [ -f "$file" ]; then
+                                               cp --preserve=timestamps $file 
$tmpfile
+                                       fi
+
+                                       cd "${DL_TEMP}"
+                                       if wget -N -c $WGET_VERBOSITY -- 
"$url"; then
+                                               downloaded="true"
+                                               mv $tmpfile $file.tmp
+                                       fi
+
+                                       cd "$OLDPWD"
+                                       rm -rf "${DL_TEMP}"
+                                       ;;
+                               curl)
+                                       curl_timecond=""
+                                       if [ -f "$file" ]; then
+                                               curl_timecond="-z $file"
+                                       fi
+
+                                       if curl -f $curl_timecond 
$CURL_VERBOSITY -o "$file.tmp" -- "$url"; then
+                                               downloaded="true"
+                                       fi
+                                       ;;
+                       esac
+
+                       if [ $downloaded = "true" ]; then
                                fetch_date="$(date -R)"
                        else
                                echo "$EXTRA_DL_FILES" | tr " " "\n" | grep -qx 
$f || SUCCEED="failed"

Attachment: signature.asc
Description: PGP signature

Reply via email to