When executing the script download_prerequisites, the download speed may
be extremely slow and there is no any output, the users do not know what
happened.

Given the command wget and curl have options --verbose and --no-verbose,
add them for download_prerequisites to give a chance to see the details.

contrib/ChangeLog:

        * download_prerequisites
        (helptext): Document --verbose and --no-verbose.
        <arg parse>: Parse --verbose and --no-verbose.
        <fetch command>: Set option for wget and curl.

Signed-off-by: Tiezhu Yang <yangtie...@loongson.cn>
---
 contrib/download_prerequisites | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/contrib/download_prerequisites b/contrib/download_prerequisites
index 6adc97ef896..7a42bf141b0 100755
--- a/contrib/download_prerequisites
+++ b/contrib/download_prerequisites
@@ -48,13 +48,9 @@ graphite=1
 verify=1
 force=0
 only_gettext=false
+verbose=0
 OS=$(uname)
 
-if type wget > /dev/null ; then
-  fetch='wget'
-else
-  fetch='curl -LO'
-fi
 chksum_extension='sha512'
 directory='.'
 
@@ -77,6 +73,8 @@ The following options are available:
  --sha512         use SHA512 checksum to verify package integrity (default)
  --md5            use MD5 checksum to verify package integrity
  --only-gettext   inhibit downloading any package but gettext
+ --verbose        make the operation more talkative
+ --no-verbose     turn off verboseness, without being quiet (default)
  --help           show this text and exit
  --version        show version information and exit
 "
@@ -165,6 +163,12 @@ do
             --only-gettext)
                 only_gettext=true
                 ;;
+            --verbose)
+                verbose=1
+                ;;
+            --no-verbose)
+                verbose=0
+                ;;
             -*)
                 die "unknown option: ${arg}"
                 ;;
@@ -227,11 +231,23 @@ esac
 [ -d "${directory}" ]                                                         \
     || die "No such directory: ${directory}"
 
+if [ ${verbose} -gt 0 ]; then
+  option="--verbose"
+else
+  option="--no-verbose"
+fi
+
+if type wget > /dev/null ; then
+  fetch="wget ${option}"
+else
+  fetch="curl -LO ${option}"
+fi
+
 for ar in $(echo_archives)
 do
     if [ ${force} -gt 0 ]; then rm -f "${directory}/${ar}"; fi
     [ -e "${directory}/${ar}" ]                                               \
-        || ( cd "${directory}" && ${fetch} --no-verbose "${base_url}${ar}" )  \
+        || ( cd "${directory}" && ${fetch} "${base_url}${ar}" )               \
         || die "Cannot download ${ar} from ${base_url}"
 done
 unset ar
-- 
2.42.0

Reply via email to