packages: builder - tmpfile todo for lftp

glen glen at pld-linux.org
Mon Oct 24 10:53:13 CEST 2011


Author: glen                         Date: Mon Oct 24 08:53:13 2011 GMT
Module: packages                      Tag: HEAD
---- Log message:
- tmpfile todo for lftp

---- Files affected:
packages:
   builder (1.660 -> 1.661) 

---- Diffs:

================================================================
Index: packages/builder
diff -u packages/builder:1.660 packages/builder:1.661
--- packages/builder:1.660	Sun Oct 23 12:41:40 2011
+++ packages/builder	Mon Oct 24 10:53:08 2011
@@ -108,6 +108,7 @@
 PROTOCOL="http"
 
 # use lftp by default when available
+USE_LFTP=
 lftp --version > /dev/null 2>&1 && USE_LFTP=yes
 
 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
@@ -195,19 +196,6 @@
 	GETURI2="$GETURI"
 	OUTFILEOPT="-o"
 elif [ -n "$USE_LFTP" ]; then
-download_lftp() {
-	local url outfile retval
-	url="$1"
-	outfile="$2"
-	lftp -c "set net:max-retries $WGET_RETRIES; set http:user-agent \"$USER_AGENT\"; pget -n 10 -c \"$url\" -o \"$outfile.tmp\""
-	retval=$?
-	if [ $retval -eq 0 ]; then
-		mv -f "$outfile.tmp" "$outfile"
-	else
-		rm -f "$outfile.tmp"
-	fi
-	return $retval
-}
 	GETURI=download_lftp
 	GETURI2=$GETURI
 	OUTFILEOPT=""
@@ -269,6 +257,21 @@
 
 #---------------------------------------------
 # functions
+
+download_lftp() {
+	local url=$1 outfile=$2 retval tmpfile
+	# TODO: use mktemp
+	tmpfile=$outfile.tmp
+	lftp -c "set net:max-retries $WGET_RETRIES; set http:user-agent \"$USER_AGENT\"; pget -n 10 -c \"$url\" -o \"$tmpfile\""
+
+	retval=$?
+	if [ $retval -eq 0 ]; then
+		mv -f "$tmpfile" "$outfile"
+	else
+		rm -f "$tmpfile"
+	fi
+	return $retval
+}
 
 usage() {
 	if [ -n "$DEBUG" ]; then set -xv; fi
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/builder?r1=1.660&r2=1.661&f=u



More information about the pld-cvs-commit mailing list