]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
simplaret: file retrieval enhancements
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Wed, 31 Jan 2007 23:23:48 +0000 (23:23 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Wed, 31 Jan 2007 23:23:48 +0000 (23:23 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@135 04377dda-e619-0410-9926-eae83683ac58

conf/simplepkg.conf.new
lib/common.sh
src/simplaret

index e1b989d3673353649ac34edb93a72a3953e1845b..bf6245079e49cebf2cecd3d9a23e0293fd1f7ab5 100644 (file)
@@ -46,8 +46,12 @@ STORAGE="/var/simplaret/packages"
 # to enable it, set to "1" or "yes"
 PASSIVE_FTP="1"
 
+# http retrieval tool
+# available parameters are "wget" or "curl"
+HTTP_TOOL="wget"
+
 # ftp retrieval tool
-# available parameters are "wget" or "ncftpget"
+# available parameters are "wget", "curl" or "ncftpget"
 FTP_TOOL="wget"
 
 # set connection timeout in seconds
index a140ccb89d81ac211b66c4d7ce2e739e7b4891b5..8647945828874fd8f2d5f379bb7491021a1c103e 100644 (file)
@@ -193,6 +193,7 @@ function eval_config {
     ROOT_PRIORITY="`eval_parameter ROOT_PRIORITY patches slackware extra testing pasture`"
     SIMPLARET_PURGE_WEEKS="`eval_parameter SIMPLARET_PURGE_WEEKS 0`"
     FTP_TOOL="`eval_parameter FTP_TOOL wget`"
+    HTTP_TOOL="`eval_parameter HTTP_TOOL wget`"
     CONNECT_TIMEOUT="`eval_parameter CONNECT_TIMEOUT 0`"
 
     SIMPLARET_CLEAN="`eval_boolean_parameter SIMPLARET_CLEAN 1`"
@@ -239,6 +240,18 @@ function eval_config {
     VERSION="$DEFAULT_VERSION"
   fi
 
+  if [ "$FTP_TOOL" != "wget" ] || [ "$FTP_TOOL" != "curl" ] || [ "$FTP_TOOL" != "ncftpget" ]; then
+    echo "$1 configuration error: invalid value $FTP_TOOL for config parameter FTP_TOOL"
+    echo "$1 assuming value \"wget\" for variable FTP_TOOL"
+    FTP_TOOL="wget"
+  fi
+
+  if [ "$HTTP_TOOL" != "wget" ] || [ "$HTTP_TOOL" != "curl" ]; then
+    echo "$1 configuration error: invalid value $HTTP_TOOL for config parameter HTTP_TOOL"
+    echo "$1 assuming value \"wget\" for variable HTTP_TOOL"
+    HTTP_TOOL="wget"
+  fi
+
   if which $SIMPLARET &> /dev/null; then
     if [ "$SIMPLARET_UPDATE" == "1" ]; then
       if [ "$2" == "-u" ]; then
index fd8113a59b5f6a8d01f96b300b54b6ab768c4817..0bc27d63758cb299a52034e423bb32eb08065289 100755 (executable)
@@ -38,7 +38,8 @@ function simplaret_usage {
 function simplaret_get_index {
 
   for file in `simplaret_metafiles`; do
-    simplaret_download $1 $file $2
+    echo $BASENAME: getting $1/$file
+    simplaret_download $1 $file $2 --no-verbose
   done
 
 }
@@ -69,10 +70,11 @@ function simplaret_check_index {
 function simplaret_download {
 
   # download a file from a repo to a folder
-  # usage: simplaret <repository_url> <package> <destination-folder>
+  # usage: simplaret <repository_url> <package> <destination-folder> [--no-verbose]
 
   local protocol file
-  local wget_timeout wget_passive_ftp
+  local wget_timeout wget_passive_ftp wget_verbose
+  local curl_timeout curl_passive_ftp
   local ncftpget_timeout ncftpget_passive_ftp
 
   protocol="`echo $1 | cut -d : -f 1`"
@@ -85,19 +87,31 @@ function simplaret_download {
   if [ ! -z "$CONNECT_TIMEOUT" ] || [ "$CONNECT_TIMEOUT" != "0" ]; then
     wget_timeout="--timeout $CONNECT_TIMEOUT"
     ncftpget_timeout="-t $CONNECT_TIMEOUT"
+    curl_timeout="--connect-timeout $CONNECT_TIMEOUT"
+  fi
+
+  if [ "$4" == "--no-verbose" ]; then
+    wget_verbose="--no-verbose"
   fi
 
   if [ "$protocol" == "http" ]; then
-    wget $wget_timeout $1/$2 -O $3/$file
+    if [ "$HTTP_TOOL" == "wget" ]; then
+      wget $wget_timeout $wget_verbose $1/$2 -O $3/$file
+    elif [ "$HTTP_TOOL" == "curl" ]; then
+      curl $curl_timeout $1/$2 > $3/$file
+    fi
   elif [ "$protocol" == "ftp" ]; then
     if [ "$PASSIVE_FTP" == "1" ]; then
       wget_passive_ftp="--passive-ftp"
       ncftpget_passive_ftp="-F"
+      curl_passive_ftp="--ftp-pasv"
     fi 
     if [ "$FTP_TOOL" == "ncftpget" ]; then
       ncftpget -c $ncftpget_timeout $ncftpget_passive_ftp $1/$2 > $3/$file
     elif [ "$FTP_TOOL" == "wget" ]; then
-      wget $wget_timeout $wget_passive_ftp $1/$2 -O $3/$file
+      wget $wget_timeout $wget_passive_ftp $wget_verbose $1/$2 -O $3/$file
+    elif [ "$FTP_TOOL" == "curl" ]; then
+      curl $curl_timeout $curl_passive_ftp $1/$2 > $3/$file
     else
       echo $BASENAME: error: invalid value for config variable FTP_TOOL: $FTP_TOOL
       echo $BASENAME: please check your config file $CONF