summaryrefslogtreecommitdiff
blob: db9d8c2795880c4240e927802100f931acaf1434 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
# Copyright 2006-2024 Gentoo Authors; Distributed under the GPL v2

# bash installer
#
#  POSIX (?) /bin/sh which doesn't eat most of the stuff in the
# bootstrap-prefix script, among which the most important part:
# dynamic function calling.  So, we need to bootstrap bash outside the
# bootstrap script, which is the purpose of this script.

if [ -z "$1" ] ; then
	echo "usage: ${0} <location>" > /dev/stderr
	exit 255
fi

mkdir -p "$1"
cd "$1" || exit 1
mkdir bash-build
cd bash-build || exit 1

GENTOO_MIRRORS=${GENTOO_MIRRORS:="http://distfiles.prefix.bitzolder.nl/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 "* $*"; }

	if [ -z "${FETCH_COMMAND}" ] ; then
		# Try to find a download manager, we only deal with wget,
		# curl, FreeBSD's fetch and ftp.
		if command_exists wget; then
			FETCH_COMMAND="wget"
			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 command_exists fetch; then
			FETCH_COMMAND="fetch"
		elif command_exists ftp; then
			FETCH_COMMAND="ftp"
			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}"
			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 || exit 2

./configure --prefix="${1}"/usr --disable-nls
make
make install