[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Patch to tidy up wget use, and add return=4 when 404's are seen



On Mon, Feb 18, 2008 at 04:58:24PM +0100, Frans Pop wrote:
> On Saturday 16 February 2008, Philip Hands wrote:
> > I've tested this briefly, and it seems to work OK, but failed
> > with a grub error (that I notice has been mentioned by other, so
> > I'm currently assuming that's not related to this patch)
> >
> > First I've made preseed_fetch callable as fetch_url, so that it can
> > be used outside preseeding without treading on the contents of
> > /var/run/preseed.last_location
> 
> I've quickly read through the patch and there's one thing I really dislike: 
> the added dependency of net-retriever on preseed-common.

OK, that's gone

> I suggest to add either a script or a function library to di-utils that 
> performs either the "wget_plus" or the "fetch_url" functionality. I'm not 
> sure which of those 2x2 options would be the most logical.

I've gone for adding fetch_url, as it seems people either want raw wget,
or want something to make a best effort and tell them how it turned out
(i.e. fetch_url)

> I also wonder how this changes the logging (in syslog). If it still visible 
> what the result of a wget was?

Well, I've changed wget404 (ne. get_plus) so that it preserves STDOUT &
STDERR.  After getting that right, I notice that it's always called with
wget -q in fetch_url, so I didn't actually need to worry about STDOUT,
but it's probably best to have got it right in case someone wants to
use it separately later.

> A more descriptive name for wget_plus would be nice too...

wget404?  (other suggestions welcome -- it's only used internally by
the http/ftp method of fetch_url, so there's no problem with renaming it)

I attach the latest version of the patch.

I note that the patch still includes debug logging to /tmp/fetch-url.log
-- I'll get rid of that.

The patch to packages/kickseed/initrd-kickseed is untested, and was done
just to hint at how that code could be simplified if it used fetch-url.
I think it could have most of the other logic ripped out too if it used
urls like floppy://... and file://...  Also, it seems that an nfs method
that took care of mounting the share (like the floppy method does)
might get rid of the need for any of those case statements
Someone who knows their way around kickseed needs to confirm all this
though.

Cheers, Phil.

=-=-=-=-=-=-=-
diff -ruN --exclude .svn /home/phil/packages-orig/debian-installer-utils/debian/changelog packages/debian-installer-utils/debian/changelog
--- /home/phil/packages-orig/debian-installer-utils/debian/changelog	2008-03-01 15:20:38.000000000 +0000
+++ packages/debian-installer-utils/debian/changelog	2008-02-29 21:27:45.000000000 +0000
@@ -1,3 +1,9 @@
+debian-installer-utils (1.56) unstable; urgency=low
+
+  * move fetch-url here from preseed
+
+ -- Philip Hands <phil@cold.hands.com>  Fri, 29 Feb 2008 21:27:01 +0000
+
 debian-installer-utils (1.55) unstable; urgency=low
 
   * chroot-setup.sh: also mount /dev/pts to avoid errors like:
diff -ruN --exclude .svn /home/phil/packages-orig/debian-installer-utils/debian/di-utils.install packages/debian-installer-utils/debian/di-utils.install
--- /home/phil/packages-orig/debian-installer-utils/debian/di-utils.install	1970-01-01 01:00:00.000000000 +0100
+++ packages/debian-installer-utils/debian/di-utils.install	2008-02-29 20:08:46.000000000 +0000
@@ -0,0 +1 @@
+fetch-url-methods/* usr/lib/fetch-url
diff -ruN --exclude .svn /home/phil/packages-orig/debian-installer-utils/debian/rules packages/debian-installer-utils/debian/rules
--- /home/phil/packages-orig/debian-installer-utils/debian/rules	2008-03-01 15:20:38.000000000 +0000
+++ packages/debian-installer-utils/debian/rules	2008-02-29 21:48:43.000000000 +0000
@@ -40,13 +40,14 @@
 	dh_testroot
 	dh_clean -k
 	dh_install -pdi-utils anna-install apt-install debconf-disconnect \
-			      debconf-get debconf-set log-output \
+			      debconf-get debconf-set fetch-url log-output \
 			      register-module search-path update-dev \
 			      user-params in-target list-devices bin
 	dh_install -pdi-utils chroot-setup.sh lib
 	dh_installdirs -pdi-utils usr/lib/post-base-installer.d
 	install register-module.post-base-installer debian/di-utils/usr/lib/post-base-installer.d/10register-module
 	dh_install -pdi-utils-mapdevfs mapdevfs bin
+	dh_link -p di-utils /usr/lib/fetch-url/http /usr/lib/fetch-url/ftp
 	dh_installdebconf -a
 	dh_compress -a
 	dh_fixperms -a
diff -ruN --exclude .svn /home/phil/packages-orig/debian-installer-utils/fetch-url packages/debian-installer-utils/fetch-url
--- /home/phil/packages-orig/debian-installer-utils/fetch-url	1970-01-01 01:00:00.000000000 +0100
+++ packages/debian-installer-utils/fetch-url	2008-03-01 09:47:52.000000000 +0000
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. /usr/share/debconf/confmodule
+. /lib/preseed/preseed.sh
+
+url="$1"
+dst="$2"
+
+echo "URL=[$url] DST=[$dst]" >> /tmp/fetch-url.log
+
+proto=${url%%://*}
+
+. /usr/lib/fetch-url/$proto
+
+protocol_fetch "$url" "$dst"
diff -ruN --exclude .svn /home/phil/packages-orig/debian-installer-utils/fetch-url-methods/file packages/debian-installer-utils/fetch-url-methods/file
--- /home/phil/packages-orig/debian-installer-utils/fetch-url-methods/file	1970-01-01 01:00:00.000000000 +0100
+++ packages/debian-installer-utils/fetch-url-methods/file	2008-02-29 20:21:30.000000000 +0000
@@ -0,0 +1,10 @@
+protocol_fetch() {
+	FILE="${1#file://*}"
+	if [ ! -e "$FILE" ] ; then
+		return 4
+	elif ! cp "$FILE" $2; then
+		return 1
+	else
+		return 0
+	fi
+}
diff -ruN --exclude .svn /home/phil/packages-orig/debian-installer-utils/fetch-url-methods/floppy packages/debian-installer-utils/fetch-url-methods/floppy
--- /home/phil/packages-orig/debian-installer-utils/fetch-url-methods/floppy	1970-01-01 01:00:00.000000000 +0100
+++ packages/debian-installer-utils/fetch-url-methods/floppy	2008-02-29 20:21:30.000000000 +0000
@@ -0,0 +1,14 @@
+protocol_fetch() {
+	FILE="/floppy/${1#floppy://*}"
+
+	mountfloppy || true
+	touch /var/run/preseed-usedfloppy
+        
+	if [ ! -e "$FILE" ] ; then
+		return 4
+	elif ! cp "$FILE" $2; then
+		return 1
+	else
+		return 0
+	fi
+}
diff -ruN --exclude .svn /home/phil/packages-orig/debian-installer-utils/fetch-url-methods/http packages/debian-installer-utils/fetch-url-methods/http
--- /home/phil/packages-orig/debian-installer-utils/fetch-url-methods/http	1970-01-01 01:00:00.000000000 +0100
+++ packages/debian-installer-utils/fetch-url-methods/http	2008-03-01 13:42:40.000000000 +0000
@@ -0,0 +1,38 @@
+protocol_fetch() {
+	local url="$1"
+	local file="$2"
+
+	wget404() {
+	# wrapper for wget that returns 4 for 404 errors while preserving STDERR & STDOUT
+	# see README.wget404 in the debian-installer-utils udeb source for more info about this
+		local RETVAL=$( {
+			echo 1
+			wget "$@" 2>&1 >&3 && echo %OK%
+			echo %EOF%
+			} | ( sed -ne '1{h;d};/server returned error 404/{p;s/.*/4/;h;d};/^%OK%$/{s/.*/0/;h;d};$!p;$x;$w /dev/fd/4' >&2 ) 4>&1 
+		) 3>&1
+		echo "wget404 returns $RETVAL" >> /tmp/fetch-url.log
+		return $RETVAL
+	}
+
+	# use the proxy for wgets (should speed things up)
+	if db_get mirror/$proto/proxy; then
+		export ${proto}_proxy="$RET"
+	fi
+
+	for i in 1 2 3; do
+		if [ -e "$file" ]; then
+                        # busybox wget can sometimes become confused while
+                        # resuming, so if it fails, restart
+                        if wget404 -q -c "$url" -O "$file"; then
+                                return 0
+                        fi
+		fi
+
+		wget404 -q "$url" -O "$file"
+		local RET=$?
+
+		[ "$RET" = 1 ] || return $RET
+	done
+	return 1
+}
diff -ruN --exclude .svn /home/phil/packages-orig/debian-installer-utils/README packages/debian-installer-utils/README
--- /home/phil/packages-orig/debian-installer-utils/README	2008-03-01 15:20:38.000000000 +0000
+++ packages/debian-installer-utils/README	2008-02-29 20:31:10.000000000 +0000
@@ -29,6 +29,18 @@
 
 debconf-set: Sets a debconf question to a value.
 
+fetch-url: Takes two parameters, a url and a file, and grabs the url
+and puts it in the file.  It uses methods for each protocol that it
+finds in /usr/lib/fetch-url/ (this allows for new protocols to be added).
+It returns 0 on success, 1 on failure, and 4 in case the source file
+did not exist.
+The http/ftp method deserves special mention. It uses wget, and returns
+4 in case the remote server returns 404.  For other failures, it retries
+up to 3 times, and will attempt to continue downloads.  Don't use this
+on the assumption that it will overwrite an existing file, it will rather
+just append the tail end of a longer file if you try to overwrite a
+short file.
+
 register-module: Register a module to go in /etc/modules on the target. May
 be called before the target is mounted. Can optionally pass parameters that
 should be passed to the module on load; these are added to the appropriate
diff -ruN --exclude .svn /home/phil/packages-orig/debian-installer-utils/README.wget404 packages/debian-installer-utils/README.wget404
--- /home/phil/packages-orig/debian-installer-utils/README.wget404	1970-01-01 01:00:00.000000000 +0100
+++ packages/debian-installer-utils/README.wget404	2008-03-01 15:18:51.000000000 +0000
@@ -0,0 +1,88 @@
+README.wget404 -- adding a return code of 4 for 404 errors to wget
+
+[Rather than bloat the udeb with comments, the wget404 wrapper is documented here.]
+
+Here is a copy of the function being documented (since it's bound to
+get out of sync with the one in the http file, so you might as well see
+the one that's being documented as well ;-)
+
+As mentioned by Joey, the fragile bit of a script like this is due to
+it's dependence on wget's output not changing.  That being the case,
+I've made the search string quite long so that it's very unlikely to
+match something that's not a 404 error, and also ensured that if the
+output does change, the sed will fail safe by returning 1 (i.e. general
+error) if no specific error is found.
+
+	wget404() {
+	# wrapper for wget that returns 4 for 404 errors while preserving STDERR & STDOUT
+	# see README.wget404 in the debian-installer-utils udeb source for more info about this
+		local RETVAL=$( {
+			echo 1
+			wget "$@" 2>&1 >&3 && echo %OK%
+			echo %EOF%
+			} | ( sed -ne '1{h;d};/server returned error 404/{p;s/.*/4/;h;d};/^%OK%$/{s/.*/0/;h;d};$!p;$x;$w /dev/fd/4' >&2 ) 4>&1 
+		) 3>&1
+		echo "wget404 returns $RETVAL" >> /tmp/fetch-url.log
+		return $RETVAL
+	}
+
+The heart of this is the sed, which looks for the 404 error, while also
+outputting the original STDERR from wget untouched so that it's available
+for the caller.
+
+It manages this by doing the following:
+
+  1{h;d}  --  take the first line (provided by the echo 1) and put it in sed's hold space
+              this will provide a default return value of 1 unless something else happens
+
+  /server returned error 404/{p;s/.*/4/;h;d}
+          If we see a 404 error, print it, then turn it into a "4" and stuff it in the 
+          sed hold space, and finally, delete the "4"
+          This is where our return value of 4 comes from
+
+  /^%OK%$/{s/.*/0/;h;d}
+          If we see a "%OK%" line (provided by the echo %OK% if wget returns 0)
+          then we replace it with "0", stuff that in the hold space, and discard it
+
+  $!p    --  for all but the last line, print them
+
+  $x     -- when we get to the last line (provided by the echo %EOF%) swap the pattern
+            with the hold space -- so now we have our return code in the pattern space
+
+  $w /dev/fd/4 -- write the result to file handle 4
+
+The rest of this is just making sure that the standard error, and standard
+out pops out of the function as if it were just wget, while allowing us
+to do things with the results in between.
+
+So, we call wget and put it's STDERR on STDOUT, and it's STDOUT on file
+handle 3
+
+   2>&1 >&3
+
+that allows us to put the STDERR into sed to look for the 404 error
+
+then, we make sure that the sed outputs everything that it was given,
+and redirect that back onto STDERR:
+
+   >&2
+
+additionally, we're running the sed in a subshell, and the return value
+is going to pop out on file handle 4, so we need to make that STDOUT so
+that the $(...) can pick up on it and shove it into RETVAL, hence the:
+
+  4>&1
+
+finally, we've still got the wget's original STDOUT floating around on
+file handle 3, so to get it back we do:
+
+  3>&1
+
+I did think that one might be able to do this without the variable
+assignment, but that seems not to work for some reason.
+
+Of course, having managed to preserve the STDOUT & STDERR, I note that
+it's always called with a -q (quiet) and therefore shouldn't be producing
+STDOUT anyway -- Doh!
+
+Phil Hands -- 2008-02-29
diff -ruN --exclude .svn /home/phil/packages-orig/kickseed/initrd-kickseed packages/kickseed/initrd-kickseed
--- /home/phil/packages-orig/kickseed/initrd-kickseed	2008-02-14 05:14:41.000000000 +0000
+++ packages/kickseed/initrd-kickseed	2008-03-01 15:44:30.000000000 +0000
@@ -45,30 +45,14 @@
 	fi
 }
 
-FETCH_ERROR=
-fetch_url () {
-	local url="$1"
-	local file="$2"
-	iters=0
-	while [ $iters -lt 3 ]; do
-		# TODO proxy support? Would it be useful?
-		# TODO add progress bar
-		if FETCH_ERROR="$(wget -q "$url" -O "$file" 2>&1)"; then
-			return 0
-		fi
-		echo "$FETCH_ERROR" | logger -t kickseed
-		iters=$(($iters + 1))
-	done
-	return 1
-}
-
 KS="$(kickseed_cmdline /proc/cmdline ks)"
 KSCFG="$(kickseed_file "$KS")"
 
 case $KS in
 	ftp://*/*|http://*/*)
 		logger -t kickseed "Downloading kickstart file from $KS"
-		if ! fetch_url "$KS" "$KSCFG"; then
+		if ! FETCH_ERROR=$(fetch-url "$KS" "$KSCFG" 2>&1); then
+	                echo "$FETCH_ERROR" | logger -t kickseed
 			logger -t kickseed "... failed"
 			db_subst initrd-kickseed/wget-failed URL "$KS"
 			db_subst initrd-kickseed/wget-failed \
diff -ruN --exclude .svn /home/phil/packages-orig/net-retriever/debian/changelog packages/net-retriever/debian/changelog
--- /home/phil/packages-orig/net-retriever/debian/changelog	2008-03-01 15:20:36.000000000 +0000
+++ packages/net-retriever/debian/changelog	2008-02-29 21:45:40.000000000 +0000
@@ -1,3 +1,10 @@
+net-retriever (1.21) UNRELEASED; urgency=low
+
+  * take all wget references out, and instead use fetch-url from
+    di-utils 1.56
+
+ -- Philip Hands <phil@hands.com>  Fri, 15 Feb 2008 16:53:35 +0000
+
 net-retriever (1.20) unstable; urgency=low
 
   [ Updated translations ]
diff -ruN --exclude .svn /home/phil/packages-orig/net-retriever/debian/control packages/net-retriever/debian/control
--- /home/phil/packages-orig/net-retriever/debian/control	2008-03-01 15:20:36.000000000 +0000
+++ packages/net-retriever/debian/control	2008-02-29 21:44:48.000000000 +0000
@@ -10,7 +10,7 @@
 Package: net-retriever
 XC-Package-Type: udeb
 Architecture: all
-Depends: ${misc:Depends}, choose-mirror, configured-network, di-utils (>= 1.16), gpgv-udeb, debian-archive-keyring-udeb
+Depends: ${misc:Depends}, choose-mirror, configured-network, di-utils (>= 1.56), gpgv-udeb, debian-archive-keyring-udeb
 Provides: retriever
 Description: Fetch modules from the Internet
  This is a retriever that uses wget to fetch files over http or ftp.
diff -ruN --exclude .svn /home/phil/packages-orig/net-retriever/net-retriever packages/net-retriever/net-retriever
--- /home/phil/packages-orig/net-retriever/net-retriever	2008-03-01 15:20:36.000000000 +0000
+++ packages/net-retriever/net-retriever	2008-02-29 19:37:17.000000000 +0000
@@ -16,36 +16,11 @@
 hostname="$RET"
 db_get mirror/$protocol/directory
 directory="$RET"
-db_get mirror/$protocol/proxy
-proxy="$RET"
-if [ -n "$proxy" ]; then
-	if [ "$protocol" = http ]; then
-		export http_proxy="$proxy"
-	elif [ "$protocol" = ftp ]; then
-		export ftp_proxy="$proxy"
-	fi
-fi
+
 keyring=/usr/share/keyrings/archive.gpg
 
 fetch() {
-	url="${protocol}://${hostname}${directory}/$1"
-	iters=0
-	while [ $iters -lt 3 ]; do
-		if [ ! -e "$2" ]; then
-			wget -q "$url" -O "$2"
-			return $?
-		else
-			# busybox wget can sometimes become confused while 
-			# resuming, so if it fails, restart
-			if wget -c -q "$url" -O "$2"; then
-				return 0
-			else
-				wget -q "$url" -O "$2"
-				return $?
-			fi
-		fi
-		iters=$(($iters + 1))
-	done
+	fetch-url "${protocol}://${hostname}${directory}/$1" "$2"
 }
 
 checkmatch() {
diff -ruN --exclude .svn /home/phil/packages-orig/preseed/debian/changelog packages/preseed/debian/changelog
--- /home/phil/packages-orig/preseed/debian/changelog	2008-03-01 15:20:36.000000000 +0000
+++ packages/preseed/debian/changelog	2008-02-29 21:45:19.000000000 +0000
@@ -1,3 +1,16 @@
+preseed (1.36) UNRELEASED; urgency=low
+
+  * fix bug in fetch_method/http that would ignore ftp proxy
+  * take inspiration from net-retriever about wget -c
+  * add wrapper to wget that allows it to diferentiate 404s
+  * modify all fetch methods to return 4 for missing files
+  * split out fetch-url from preseed_fetch to allow for
+    it's use for downloading without interfering with the
+    preseed relative path magic
+  * move fetch-url and it's methods to di-utils (>= 1.56)
+
+ -- Philip Hands <phil@cold.hands.com>  Fri, 29 Feb 2008 20:00:44 +0000
+
 preseed (1.35) unstable; urgency=low
 
   [ Updated translations ]
diff -ruN --exclude .svn /home/phil/packages-orig/preseed/debian/control packages/preseed/debian/control
--- /home/phil/packages-orig/preseed/debian/control	2008-03-01 15:20:36.000000000 +0000
+++ packages/preseed/debian/control	2008-02-29 21:44:38.000000000 +0000
@@ -9,7 +9,7 @@
 Package: preseed-common
 Architecture: all
 Priority: standard
-Depends: ${misc:Depends}, ${shlibs:Depends}, di-utils (>= 1.14)
+Depends: ${misc:Depends}, ${shlibs:Depends}, di-utils (>= 1.56)
 Description: common files for preseeding
 XC-Package-Type: udeb
 
diff -ruN --exclude .svn /home/phil/packages-orig/preseed/debian/file-preseed.install packages/preseed/debian/file-preseed.install
--- /home/phil/packages-orig/preseed/debian/file-preseed.install	2008-03-01 15:20:36.000000000 +0000
+++ packages/preseed/debian/file-preseed.install	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-fetch-methods/floppy lib/preseed/fetch-methods
diff -ruN --exclude .svn /home/phil/packages-orig/preseed/debian/network-preseed.install packages/preseed/debian/network-preseed.install
--- /home/phil/packages-orig/preseed/debian/network-preseed.install	2008-03-01 15:20:36.000000000 +0000
+++ packages/preseed/debian/network-preseed.install	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-fetch-methods/http lib/preseed/fetch-methods
diff -ruN --exclude .svn /home/phil/packages-orig/preseed/debian/preseed-common.install packages/preseed/debian/preseed-common.install
--- /home/phil/packages-orig/preseed/debian/preseed-common.install	2008-03-01 15:20:36.000000000 +0000
+++ packages/preseed/debian/preseed-common.install	2008-02-29 19:55:35.000000000 +0000
@@ -4,4 +4,3 @@
 debconf-set-selections bin
 finish-install.d/07preseed usr/lib/finish-install.d
 post-base-installer.d/05preseed usr/lib/post-base-installer.d
-fetch-methods/file lib/preseed/fetch-methods
diff -ruN --exclude .svn /home/phil/packages-orig/preseed/debian/rules packages/preseed/debian/rules
--- /home/phil/packages-orig/preseed/debian/rules	2008-03-01 15:20:36.000000000 +0000
+++ packages/preseed/debian/rules	2008-02-29 20:02:25.000000000 +0000
@@ -18,8 +18,6 @@
 	for pkg in file-preseed network-preseed; do \
 		cp debian/$$pkg.isinstallable debian/$$pkg/DEBIAN/isinstallable; \
 	done
-	dh_link -p network-preseed lib/preseed/fetch-methods/http \
-		lib/preseed/fetch-methods/ftp
 	dh_compress
 	dh_fixperms
 	dh_installdeb
diff -ruN --exclude .svn /home/phil/packages-orig/preseed/fetch-methods/file packages/preseed/fetch-methods/file
--- /home/phil/packages-orig/preseed/fetch-methods/file	2008-03-01 15:20:36.000000000 +0000
+++ packages/preseed/fetch-methods/file	1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-protocol_fetch() {
-	FILE="${1#file://*}"
-	if [ ! -e "$FILE" ] || ! cp "$FILE" $2; then
-		return 1
-	else
-		return 0
-	fi
-}
diff -ruN --exclude .svn /home/phil/packages-orig/preseed/fetch-methods/floppy packages/preseed/fetch-methods/floppy
--- /home/phil/packages-orig/preseed/fetch-methods/floppy	2008-03-01 15:20:36.000000000 +0000
+++ packages/preseed/fetch-methods/floppy	1970-01-01 01:00:00.000000000 +0100
@@ -1,12 +0,0 @@
-protocol_fetch() {
-	FILE="/floppy/${1#floppy://*}"
-
-	mountfloppy || true
-	touch /var/run/preseed-usedfloppy
-        
-	if [ ! -e "$FILE" ] || ! cp "$FILE" $2; then
-		return 1
-	else
-		return 0
-	fi
-}
diff -ruN --exclude .svn /home/phil/packages-orig/preseed/fetch-methods/http packages/preseed/fetch-methods/http
--- /home/phil/packages-orig/preseed/fetch-methods/http	2008-03-01 15:20:36.000000000 +0000
+++ packages/preseed/fetch-methods/http	1970-01-01 01:00:00.000000000 +0100
@@ -1,19 +0,0 @@
-protocol_fetch() {
-	local url="$1"
-	local file="$2"
-	iters=0
-
-	# use the proxy for wgets (should speed things up)
-	if db_get mirror/http/proxy; then
-		export http_proxy="$RET"
-	fi
-
-	while [ $iters -lt 3 ]; do
-		# TODO add progress bar
-		if wget -q "$url" -O "$file"; then
-			return 0
-		fi
-		iters=$(($iters + 1))
-	done
-	return 1
-}
diff -ruN --exclude .svn /home/phil/packages-orig/preseed/preseed_fetch packages/preseed/preseed_fetch
--- /home/phil/packages-orig/preseed/preseed_fetch	2008-03-01 15:20:36.000000000 +0000
+++ packages/preseed/preseed_fetch	2008-03-01 09:21:03.000000000 +0000
@@ -1,16 +1,14 @@
 #!/bin/sh
 
-. /usr/share/debconf/confmodule
 . /lib/preseed/preseed.sh
 
 src="$1"
 dst="$2"
 
 last=/var/run/preseed.last_location
-
 url=$(make_absolute_url "$src" "$(test -r $last && cat $last)")
-proto=${url%%://*}
-
-. /lib/preseed/fetch-methods/$proto
+# Am suspicious that there are assumptions that we can overwrite
+# in preseeding, so lets discard old files for now
+[ -e $dst ] && rm $dst
 
-protocol_fetch "$url" "$dst"
+fetch-url "$url" "$dst" >&2
diff -ruN --exclude .svn /home/phil/packages-orig/preseed/README.preseed_fetch packages/preseed/README.preseed_fetch
--- /home/phil/packages-orig/preseed/README.preseed_fetch	2008-03-01 15:20:36.000000000 +0000
+++ packages/preseed/README.preseed_fetch	2008-03-01 15:28:41.000000000 +0000
@@ -1,6 +1,9 @@
 The preseed_fetch script takes a source and destination address, and
 copies the specified file from the source to the destination.
 
+fetch-url from di-utils actually does the heavy lifting, with
+preseed_fetch only adding the relative path functionality
+
 The source can be a fully qualified URL, an absolute path, or a relative path.
 
 If the source is not a full URL, the contents of /var/run/preseed.last_location


Reply to: