commit:     db77fbabf914f5165a6be32f58fe0ebbe9940531
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 10 18:43:02 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Mar 10 18:43:02 2018 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=db77fbab

scripts/bootstrap-bash: copy efetch behaviour from bootstrap-prefix

ftp may not be available or working, so try the fallback behaviour from
bootstrap-prefix.

Patch based on patch by Askar Bektassov (Аскар Бектасов)

 scripts/bootstrap-bash.sh | 34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/scripts/bootstrap-bash.sh b/scripts/bootstrap-bash.sh
index be0b36d831..a3d78afea0 100755
--- a/scripts/bootstrap-bash.sh
+++ b/scripts/bootstrap-bash.sh
@@ -8,7 +8,10 @@
 # dynamic function calling.  So, we need to bootstrap bash outside the
 # bootstrap script, which is the purpose of this script.
 
-[ -z "$1" ] && exit -1
+if [ -z "$1" ] ; then
+       echo "usage: ${0} <location>" > /dev/stderr
+       exit -1
+fi
 
 mkdir -p "$1"
 cd "$1"
@@ -17,7 +20,34 @@ cd bash-build
 
 GENTOO_MIRRORS=${GENTOO_MIRRORS:="http://distfiles.gentoo.org/distfiles"}
 
-ftp "${GENTOO_MIRRORS}/bash-4.2.tar.gz"
+if [ ! -e bash-4.2.tar.gz ] ; then
+       eerror() { echo "!!! $*" 1>&2; }
+       einfo() { echo "* $*"; }
+
+       if [ -z ${FETCH_COMMAND} ] ; then
+               # Try to find a download manager, we only deal with wget,
+               # curl, FreeBSD's fetch and ftp.
+               if [ x$(type -t wget) == "xfile" ] ; then
+                       FETCH_COMMAND="wget"
+                       [ $(wget -h) == *"--no-check-certificate"* ] && 
FETCH_COMMAND+=" --no-check-certificate"
+               elif [ x$(type -t curl) == "xfile" ] ; then
+                       einfo "WARNING: curl doesn't fail when downloading 
fails, please check its output carefully!"
+                       FETCH_COMMAND="curl -f -L -O"
+               elif [ x$(type -t fetch) == "xfile" ] ; then
+                       FETCH_COMMAND="fetch"
+               elif [ x$(type -t ftp) == "xfile" ] &&
+                        [ ${CHOST} != *-cygwin* || ! $(type -P ftp) -ef 
$(cygpath -S)/ftp ] ; then
+                       FETCH_COMMAND="ftp"
+               else
+                       eerror "no suitable download manager found (need wget, 
curl, fetch or ftp)"
+                       eerror "could not download ${1##*/}"
+                       eerror "download the file manually, and put it in 
${PWD}"
+                       exit 1
+               fi
+       fi
+       ${FETCH_COMMAND} "${GENTOO_MIRRORS}/bash-4.2.tar.gz" < /dev/null
+fi
+
 gzip -d bash-4.2.tar.gz
 tar -xf bash-4.2.tar
 cd bash-4.2

Reply via email to