[Lunar-commits] <lunar> Added support to choose internet protocol version for downloads

Stefan Wold ratler at lunar-linux.org
Sun Sep 7 14:35:29 CEST 2014


commit b1066754571294c7b59dc8ff62dfb25c030a51e2
Author: Stefan Wold <ratler at lunar-linux.org>
Date: Sun, 07 Sep 2014 14:34:12 +0200
URL: https://github.com/lunar-linux/lunar/commit/b1066754571294c7b59dc8ff62dfb25c030a51e2

Added support to choose internet protocol version for downloads
---
  menu/download.menu              | +35/-0    
  plugins/download-generic.plugin | +6/-0     
  prog/lget                       | +5/-1     
  prog/lin                        | +5/-1     
  4 files changed, 51 insertions(+), 2 deletions(-)

--- a/menu/download.menu
+++ b/menu/download.menu
@@ -166,6 +166,38 @@ FTP_ACTIVE=on in DETAILS file :=) or vice-versa."
    set_local_config "FTP_ACTIVE" "$FTP_ACTIVE"
 }
 
+set_ipv46() {
+  local USE_IPV4 USE_IPV6 USE_IPVANY
+
+  PROMPT="Please select the internet protocol version
+to use when downloading modules."
+  USE_IPV4=off
+  USE_IPV6=off
+  USE_IPVANY=off
+
+  if [ "$USE_IPV46" == "4" ]; then
+    USE_IPV4=on
+  elif [ "$USE_IPV46" == "6" ]; then
+    USE_IPV6=on
+  else
+    USE_IPVANY=on
+  fi
+
+  USE_IPV46=$($DIALOG  --title "Internet protocol version" \
+                    --ok-label  "Commit"     \
+                    --radiolist              \
+                    "$PROMPT"                \
+                    0 0 0                   \
+                    "Any" "Use system default" $USE_IPVANY \
+                    "4" "Internet protocol version 4 (ipv4)" $USE_IPV4  \
+                    "6" "Internet protocol version 6 (ipv6)"  $USE_IPV6)
+  if [ "$USE_IPV46" = "Any" ]; then
+    unset_local_config "USE_IPV46"
+  else
+    set_local_config "USE_IPV46" "$USE_IPV46"
+  fi
+}
+
 set_partial_downloads(){
 
    PROMPT="Please enable/disable the partial download option.
@@ -283,6 +315,7 @@ while
     C_HELP="Continue to get or re-get the partial downloads"
     N_HELP="How many times will wget try to download the file?"
     H_HELP="Cache usage for http downloads"
+    I_HELP="Internet protocol version to use when downloading a file"
     R_HELP="Per process download rate"
     P_HELP="Proxy Settings"
     E_HELP="Test all mirrors available on download"
@@ -298,6 +331,7 @@ while
                       "A"  "Ftp Active/Passive"          "$A_HELP"  \
                       "C"  "Partial Downloads"           "$C_HELP"  \
                       "H"  "Cache Usage"                 "$H_HELP"  \
+                      "I"  "Internet protocol version"   "$I_HELP"  \
                       "N"  "Number of Retries"           "$N_HELP"  \
                       "P"  "Proxies"                     "$P_HELP"  \
                       "R"  "Download Rate"               "$R_HELP"  \
@@ -309,6 +343,7 @@ while
       A)  set_ftp_active           ;;
       C)  set_partial_downloads    ;;
       H)  set_cache_usage          ;;
+      I)  set_ipv46                ;;
       N)  set_retries              ;;
       P)  proxy_menu               ;;
       R)  set_download_rate        ;;
--- a/plugins/download-generic.plugin
+++ b/plugins/download-generic.plugin
@@ -50,6 +50,12 @@ plugin_source_download_generic()  {
     WGET_OPTS+=" --no-check-certificate"
   fi
 
+  if [ "$USE_IPV46" == "6" ]; then
+    WGET_OPTS+=" -6"
+  elif [ "$USE_IPV46" == "4" ]; then
+    WGET_OPTS+=" -4"
+  fi
+
   WGET_OPTS+=" --tries=${NUM_RETRY:-5}"
 
   [ -n "$http_proxy" ] && export http_proxy=$http_proxy
--- a/prog/lget
+++ b/prog/lget
@@ -46,6 +46,8 @@ Optional Parameters:
    -v | --verbose               Increases the level of message output
    -w | --want version          Try to download a different version that is
                                 not in moonbase
+   -4 | --ipv4                  Download sources using ipv4
+   -6 | --ipv6                  Download sources using ipv6
 EOF
 
   exit  1
@@ -86,7 +88,7 @@ main() {
 . /etc/lunar/config
 . $BOOTSTRAP
 
-GETOPT_ARGS=$(getopt -q -n lget -o "adf:hu:vw:" -l "all,debug,from:,help,url:,verbose,want:" -- "$@")
+GETOPT_ARGS=$(getopt -q -n lget -o "adf:hu:vw:46" -l "all,debug,from:,help,url:,verbose,want:ipv4,ipv6" -- "$@")
 
 if [ -z "$?" ] ; then
   help | view_file
@@ -106,6 +108,8 @@ else
       -u|--url     ) export BASE_URL="$2" ;                     shift 2 ;;
       -v|--verbose ) export VERBOSE="on" ;                      shift   ;;
       -w|--want    ) export WANT_VERSION=$2 ;                   shift 2 ;;
+      -4|--ipv4    ) export USE_IPV46=4 ;                       shift   ;;
+      -6|--ipv6    ) export USE_IPV46=6 ;                       shift   ;;
       --) shift ; break ;;
       *) help ; exit ;;
     esac
--- a/prog/lin
+++ b/prog/lin
@@ -55,6 +55,8 @@ Optional Parameters:
 -v  |  --verbose                Increases the level of message output
 -w  |  --want version           Try to install a different version that is
                                 not in moonbase
+-4  | --ipv4                    Download sources using ipv4
+-6  | --ipv6                    Download sources using ipv6
 EOF
   exit  1
 }
@@ -240,7 +242,7 @@ main() {
 . /etc/lunar/config
 . $BOOTSTRAP
 
-GETOPT_ARGS=$(getopt -q -n lin -o "cdgf:hprRsvV:w:" -l "compile,debug,deps,download,from:,help,opts:,probe,reconfigure,resurrect,silent,verbose,Version:,want:" -- "$@")
+GETOPT_ARGS=$(getopt -q -n lin -o "cdgf:hprRsvV:w:46" -l "compile,debug,deps,download,from:,help,opts:,probe,reconfigure,resurrect,silent,verbose,Version:,want:,ipv4,ipv6" -- "$@")
 
 # the following trap makes sure all threads exit in case something weird
 # happens:
@@ -272,6 +274,8 @@ else
       -s|--silent      ) export SILENT="$1" ;                       shift   ;;
       -v|--verbose     ) export VERBOSE="on" ;                      shift   ;;
       -w|--want        ) export WANT_VERSION=$2 ;                   shift 2 ;;
+      -4|--ipv4        ) export USE_IPV46=4 ;                       shift   ;;
+      -6|--ipv6        ) export USE_IPV46=6 ;                       shift   ;;
       --) shift ; break ;;
       *) help ; break ;;
     esac




More information about the Lunar-commits mailing list