Import changes from ruby-build v20131225.1

This commit is contained in:
Yamashita Yuu 2013-12-27 18:44:54 +09:00
parent b70dcb9f2d
commit 1f76effbfb
2 changed files with 49 additions and 18 deletions

View file

@ -1,17 +1,21 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# Summary: Install a Python version using the python-build plugin # Summary: Install a Python version using python-build
# #
# Usage: pyenv install [-f|--force] [-g|--debug] [-k|--keep] [-v|--verbose] <version> # Usage: pyenv install [-f] [-kvp] <version>
# pyenv install [-f|--force] [-g|--debug] [-k|--keep] [-v|--verbose] <definition-file> # pyenv install [-f] [-kvp] <definition-file>
# pyenv install -l|--list # pyenv install -l|--list
# #
# -l/--list List all available versions # -l/--list List all available versions
# -f/--force Install even if the version appears to be installed already # -f/--force Install even if the version appears to be installed already
#
# python-build options:
#
# -k/--keep Keep source tree in $PYENV_BUILD_ROOT after installation # -k/--keep Keep source tree in $PYENV_BUILD_ROOT after installation
# (defaults to $PYENV_ROOT/sources) # (defaults to $PYENV_ROOT/sources)
# -g/--debug Build a debug version
# -v/--verbose Verbose mode: print compilation status to stdout # -v/--verbose Verbose mode: print compilation status to stdout
# -p/--patch Apply a patch from stdin before building
# -g/--debug Build a debug version
# #
# For detailed information on installing Python versions with # For detailed information on installing Python versions with
# python-build, including a list of environment variables for adjusting # python-build, including a list of environment variables for adjusting
@ -50,6 +54,7 @@ indent() {
unset FORCE unset FORCE
unset KEEP unset KEEP
unset VERBOSE unset VERBOSE
unset HAS_PATCH
unset DEBUG unset DEBUG
parse_options "$@" parse_options "$@"
@ -72,6 +77,9 @@ for option in "${OPTIONS[@]}"; do
"v" | "verbose" ) "v" | "verbose" )
VERBOSE="-v" VERBOSE="-v"
;; ;;
"p" | "patch" )
HAS_PATCH="-p"
;;
"g" | "debug" ) "g" | "debug" )
DEBUG="-g" DEBUG="-g"
;; ;;
@ -167,7 +175,7 @@ trap cleanup SIGINT
# Invoke `python-build` and record the exit status in $STATUS. # Invoke `python-build` and record the exit status in $STATUS.
STATUS=0 STATUS=0
python-build $KEEP $VERBOSE $DEBUG "$DEFINITION" "$PREFIX" || STATUS="$?" python-build $KEEP $VERBOSE $HAS_PATCH $DEBUG "$DEFINITION" "$PREFIX" || STATUS="$?"
# Display a more helpful message if the definition wasn't found. # Display a more helpful message if the definition wasn't found.
if [ "$STATUS" == "2" ]; then if [ "$STATUS" == "2" ]; then

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
PYTHON_BUILD_VERSION="20131211" PYTHON_BUILD_VERSION="20131225.1"
set -E set -E
exec 3<&2 # preserve original stderr at fd 3 exec 3<&2 # preserve original stderr at fd 3
@ -307,16 +307,14 @@ fetch_tarball() {
local tar_args="xzvf" local tar_args="xzvf"
local package_filename="${package_name}.tar.gz" local package_filename="${package_name}.tar.gz"
local package_suffix extract_option if [ "$package_url" != "${package_url%tgz}" ]; then
case "${package_url}" in package_filename="${package_filename%tar.gz}tgz"
*".tgz" ) fi
package_filename="${package_name}.tgz"
;; if [ "$package_url" != "${package_url%bz2}" ]; then
*".tar.bz2" ) package_filename="${package_filename%.gz}.bz2"
package_filename="${package_name}.tar.bz2"
tar_args="${tar_args/z/j}" tar_args="${tar_args/z/j}"
;; fi
esac
if ! symlink_tarball_from_cache "$package_filename" "$checksum"; then if ! symlink_tarball_from_cache "$package_filename" "$checksum"; then
echo "Downloading ${package_filename}..." >&2 echo "Downloading ${package_filename}..." >&2
@ -527,6 +525,8 @@ build_package() {
echo "Installing ${package_name}..." >&2 echo "Installing ${package_name}..." >&2
[ -n "$HAS_PATCH" ] && apply_python_patch "$package_name"
for command in $commands; do for command in $commands; do
"build_package_${command}" "$package_name" "build_package_${command}" "$package_name"
done done
@ -677,6 +677,7 @@ build_package_jruby() {
ln -fs jruby ruby ln -fs jruby ruby
install_jruby_launcher install_jruby_launcher
remove_windows_files remove_windows_files
fix_jruby_shebangs
} }
install_jruby_launcher() { install_jruby_launcher() {
@ -685,6 +686,15 @@ install_jruby_launcher() {
} >&4 2>&1 } >&4 2>&1
} }
fix_jruby_shebangs() {
for file in "${PREFIX_PATH}/bin"/*; do
if [ "$(head -c 20 "$file")" = "#!/usr/bin/env jruby" ]; then
sed -i.bak -E "1s:.+:#\!${PREFIX_PATH}/bin/jruby:" "$file"
rm "$file".bak
fi
done
}
remove_windows_files() { remove_windows_files() {
cd "$PREFIX_PATH" cd "$PREFIX_PATH"
rm -f bin/*.exe bin/*.dll bin/*.bat bin/jruby.sh rm -f bin/*.exe bin/*.dll bin/*.bat bin/jruby.sh
@ -1078,6 +1088,14 @@ isolated_gem_install() {
gem install "$@" gem install "$@"
} }
apply_python_patch() {
case "$1" in
Python-* | jython-* | pypy-* )
patch -p0 -i "${2:--}"
;;
esac
}
has_broken_mac_llvm_gcc() { has_broken_mac_llvm_gcc() {
[ "$(uname -s)" = "Darwin" ] && [ "$(uname -s)" = "Darwin" ] &&
[[ "$(gcc --version 2>/dev/null || true)" == *"llvm-gcc-4.2"* ]] [[ "$(gcc --version 2>/dev/null || true)" == *"llvm-gcc-4.2"* ]]
@ -1208,7 +1226,7 @@ version() {
usage() { usage() {
{ version { version
echo "usage: python-build [-g|--debug] [-k|--keep] [-v|--verbose] definition prefix" echo "usage: python-build [-k|--keep] [-v|--verbose] [-p|--patch] [-g|--debug] definition prefix"
echo " python-build --definitions" echo " python-build --definitions"
} >&2 } >&2
@ -1228,8 +1246,9 @@ list_definitions() {
unset VERBOSE unset VERBOSE
unset KEEP_BUILD_PATH unset KEEP_BUILD_PATH
PYTHON_BUILD_ROOT="$(abs_dirname "$0")/.." unset HAS_PATCH
unset DEBUG unset DEBUG
PYTHON_BUILD_ROOT="$(abs_dirname "$0")/.."
parse_options "$@" parse_options "$@"
@ -1239,8 +1258,9 @@ for option in "${OPTIONS[@]}"; do
usage without_exiting usage without_exiting
{ echo { echo
echo " -k/--keep Do not remove source tree after installation" echo " -k/--keep Do not remove source tree after installation"
echo " -g/--debug Build a debug version"
echo " -v/--verbose Verbose mode: print compilation status to stdout" echo " -v/--verbose Verbose mode: print compilation status to stdout"
echo " -p/--patch Apply a patch from stdin before building"
echo " -g/--debug Build a debug version"
echo " --definitions List all built-in definitions" echo " --definitions List all built-in definitions"
echo echo
} >&2 } >&2
@ -1256,6 +1276,9 @@ for option in "${OPTIONS[@]}"; do
"v" | "verbose" ) "v" | "verbose" )
VERBOSE=true VERBOSE=true
;; ;;
"p" | "patch" )
HAS_PATCH=true
;;
"g" | "debug" ) "g" | "debug" )
DEBUG=true DEBUG=true
;; ;;