From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 642A5138350 for ; Mon, 30 Mar 2020 17:11:49 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A2586E0C07; Mon, 30 Mar 2020 17:11:48 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 74828E0C07 for ; Mon, 30 Mar 2020 17:11:48 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CAD0E34F010 for ; Mon, 30 Mar 2020 17:11:46 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id F369E162 for ; Mon, 30 Mar 2020 17:11:44 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1585588256.39f5044b32d30c5296fc103cd573737c084e3787.grobian@gentoo> Subject: [gentoo-commits] repo/proj/prefix:master commit in: scripts/ X-VCS-Repository: repo/proj/prefix X-VCS-Files: scripts/bootstrap-bash.sh X-VCS-Directories: scripts/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 39f5044b32d30c5296fc103cd573737c084e3787 X-VCS-Branch: master Date: Mon, 30 Mar 2020 17:11:44 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: dd5d3b4a-6ac6-4a09-bbd2-35794503f07c X-Archives-Hash: e50d2a21f510d536c674e1cab716f45b commit: 39f5044b32d30c5296fc103cd573737c084e3787 Author: Chris Slycord gmail com> AuthorDate: Mon Mar 30 17:10:56 2020 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Mon Mar 30 17:10:56 2020 +0000 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=39f5044b scripts/bootstrap-bash: fix bashisms, bug #714634 Closes: https://bugs.gentoo.org/714634 Signed-off-by: Fabian Groffen gentoo.org> scripts/bootstrap-bash.sh | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/scripts/bootstrap-bash.sh b/scripts/bootstrap-bash.sh index a3d78afea0..b24015fc19 100755 --- a/scripts/bootstrap-bash.sh +++ b/scripts/bootstrap-bash.sh @@ -10,7 +10,7 @@ if [ -z "$1" ] ; then echo "usage: ${0} " > /dev/stderr - exit -1 + exit 255 fi mkdir -p "$1" @@ -20,6 +20,22 @@ cd bash-build GENTOO_MIRRORS=${GENTOO_MIRRORS:="http://distfiles.gentoo.org/distfiles"} +command_exists() { + check_cmd="$1" + command -v $check_cmd >/dev/null 2>&1 +} + +same_file() { + file1="$1" + file2="$2" + + if [ "$(stat -c '%i%d' "$file1" "$file2" | sort -u | wc -l)" -eq 1 ]; then + return 0 + else + return 1 + fi +} + if [ ! -e bash-4.2.tar.gz ] ; then eerror() { echo "!!! $*" 1>&2; } einfo() { echo "* $*"; } @@ -27,18 +43,29 @@ if [ ! -e bash-4.2.tar.gz ] ; then 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 + if command_exists wget; then FETCH_COMMAND="wget" - [ $(wget -h) == *"--no-check-certificate"* ] && FETCH_COMMAND+=" --no-check-certificate" - elif [ x$(type -t curl) == "xfile" ] ; then + case "$(wget -h 2>&1)" in + *"--no-check-certificate"*) + FETCH_COMMAND="$FETCH_COMMAND --no-check-certificate" + ;; + esac + elif command_exists curl; 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 + elif command_exists fetch; then FETCH_COMMAND="fetch" - elif [ x$(type -t ftp) == "xfile" ] && - [ ${CHOST} != *-cygwin* || ! $(type -P ftp) -ef $(cygpath -S)/ftp ] ; then + elif command_exists ftp; then FETCH_COMMAND="ftp" - else + case "${CHOST}" in + *-cygwin*) + if same_file "$(command -v ftp)" "$(cygpath -S)/ftp"; then + FETCH_COMMAND='' + fi + ;; + esac + fi + if [ -z ${FETCH_COMMAND} ]; then 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}"