Skip to content

Commit

Permalink
Import changes from ruby-build v20150519
Browse files Browse the repository at this point in the history
  • Loading branch information
yyuu committed May 26, 2015
1 parent 9aee57d commit 648afe0
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 11 deletions.
4 changes: 2 additions & 2 deletions plugins/python-build/bin/pyenv-install
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ for option in "${OPTIONS[@]}"; do
exec python-build --version
;;
* )
usage 1
usage 1 >&2
;;
esac
done
Expand Down Expand Up @@ -246,7 +246,7 @@ if [ "$STATUS" == "2" ]; then
echo " brew update && brew upgrade pyenv"
elif [ -d "${here}/.git" ]; then
printf ":\n\n"
echo " cd ${here} && git pull"
echo " cd ${here} && git pull && cd -"
else
printf ".\n"
fi
Expand Down
51 changes: 43 additions & 8 deletions plugins/python-build/bin/python-build
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
# -k/--keep Do not remove source tree after installation
# -v/--verbose Verbose mode: print compilation status to stdout
# -p/--patch Apply a patch from stdin before building
# -4/--ipv4 Resolve names to IPv4 addresses only
# -6/--ipv6 Resolve names to IPv6 addresses only
# --definitions List all built-in definitions
# -g/--debug Build a debug version
#

PYTHON_BUILD_VERSION="20141028"
PYTHON_BUILD_VERSION="20150519"

set -E
exec 3<&2 # preserve original stderr at fd 3
Expand Down Expand Up @@ -231,7 +233,7 @@ compute_sha2() {
output="$(shasum -a 256 -b)" || return 1
echo "${output% *}"
elif type openssl &>/dev/null; then
local openssl="$(command -v "$(brew --prefix openssl 2>/dev/null)"/bin/openssl openssl | head -1)"
local openssl="$(command -v "$(brew --prefix openssl 2>/dev/null || true)"/bin/openssl openssl | head -1)"
output="$("$openssl" dgst -sha256 2>/dev/null)" || return 1
echo "${output##* }"
elif type sha256sum &>/dev/null; then
Expand Down Expand Up @@ -307,19 +309,31 @@ http() {
}

http_head_curl() {
curl -qsILf "$1" >&4 2>&1
options=""
[ -n "${IPV4}" ] && options="--ipv4"
[ -n "${IPV6}" ] && options="--ipv6"
curl -qsILf ${options} "$1" >&4 2>&1
}

http_get_curl() {
curl -q -o "${2:--}" -sSLf "$1"
options=""
[ -n "${IPV4}" ] && options="--ipv4"
[ -n "${IPV6}" ] && options="--ipv6"
curl -q -o "${2:--}" -sSLf ${options} "$1"
}

http_head_wget() {
wget -q --spider "$1" >&4 2>&1
options=""
[ -n "${IPV4}" ] && options="--inet4-only"
[ -n "${IPV6}" ] && options="--inet6-only"
wget -q --spider ${options} "$1" >&4 2>&1
}

http_get_wget() {
wget -nv -O "${2:--}" "$1"
options=""
[ -n "${IPV4}" ] && options="--inet4-only"
[ -n "${IPV6}" ] && options="--inet6-only"
wget -nv ${options} -O "${2:--}" "$1"
}

fetch_tarball() {
Expand Down Expand Up @@ -982,7 +996,7 @@ fix_rbx_gem_binstubs() {
binstub="${bindir}/${file##*/}"
rm -f "$binstub"
{ echo "#!${bindir}/ruby"
cat "$file"
grep -v '^#!' "$file"
} > "$binstub"
chmod +x "$binstub"
done
Expand All @@ -999,7 +1013,7 @@ fix_rbx_irb() {
}

require_java7() {
local version="$(java -version 2>&1 | head -1)"
local version="$(java -version 2>&1 | grep '\(java\|openjdk\) version' | head -1)"
if [[ $version != *1.[789]* ]]; then
colorize 1 "ERROR" >&3
echo ": Java 7 required. Please install a 1.7-compatible JRE." >&3
Expand Down Expand Up @@ -1117,6 +1131,19 @@ require_llvm() {
local llvm_config="${llvm_prefix}/bin/llvm-config"
if [ -x "$llvm_config" ]; then
package_option python configure --llvm-config="$llvm_config"
else
{ echo
colorize 1 "ERROR"
echo ": Rubinius will not be able to compile using Apple's LLVM-based "
echo "build tools on OS X. You will need to install LLVM 3.5 first."
echo
colorize 1 "TO FIX THE PROBLEM"
echo ": Install Homebrew's llvm package with this"
echo -n "command: "
colorize 4 "brew install llvm"
echo
} >&3
return 1
fi
fi
fi
Expand Down Expand Up @@ -1568,6 +1595,8 @@ unset VERBOSE
unset KEEP_BUILD_PATH
unset HAS_PATCH
unset DEBUG
unset IPV4
unset IPV6

PYTHON_BUILD_INSTALL_PREFIX="$(abs_dirname "$0")/.."

Expand Down Expand Up @@ -1600,6 +1629,12 @@ for option in "${OPTIONS[@]}"; do
"g" | "debug" )
DEBUG=true
;;
"4" | "ipv4")
IPV4=true
;;
"6" | "ipv6")
IPV6=true
;;
"version" )
version
exit 0
Expand Down
8 changes: 8 additions & 0 deletions plugins/python-build/test/build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,14 @@ OUT
# nop
}

@test "Java version string not on first line" {
# nop
}

@test "Java version string on OpenJDK" {
# nop
}

@test "non-writable TMPDIR aborts build" {
export TMPDIR="${TMP}/build"
mkdir -p "$TMPDIR"
Expand Down
2 changes: 1 addition & 1 deletion plugins/python-build/test/pyenv.bats
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ See all available versions with \`pyenv install --list'.
If the version you need is missing, try upgrading pyenv:
cd ${BATS_TEST_DIRNAME}/../../.. && git pull
cd ${BATS_TEST_DIRNAME}/../../.. && git pull && cd -
OUT

unstub python-build
Expand Down

0 comments on commit 648afe0

Please sign in to comment.