Import changes from ruby-build v20131030

This commit is contained in:
Yamashita Yuu 2013-11-01 18:30:00 +09:00
parent ccc51244e3
commit 498d226b2f
2 changed files with 81 additions and 67 deletions

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash
PYTHON_BUILD_VERSION="20130628"
PYTHON_BUILD_VERSION="20131030"
set -E
exec 3<&2 # preserve original stderr at fd 3
@ -96,6 +96,17 @@ file_is_not_empty() {
fi
}
num_cpu_cores() {
local num=""
if [ "Darwin" = "$(uname -s)" ]; then
num="$(sysctl -n hw.ncpu 2>/dev/null || true)"
elif [ -r /proc/cpuinfo ]; then
num="$(grep -c ^processor /proc/cpuinfo)"
[ "$num" -gt 0 ] || num=""
fi
echo "${num:-2}"
}
install_package() {
install_package_using "tarball" 1 "$@"
}
@ -267,36 +278,28 @@ fetch_tarball() {
fi
fi
local tar_args="xzvf"
local package_filename="${package_name}.tar.gz"
local package_suffix extract_option
case "${package_url}" in
*".tar.gz" )
package_suffix=".tar.gz"
extract_option="zxvf"
;;
*".tgz" )
package_suffix=".tgz"
extract_option="zxvf"
package_filename="${package_name}.tgz"
;;
*".tar.bz2" )
package_suffix=".tar.bz2"
extract_option="jxvf"
;;
* )
package_suffix=".${package_url##*.}"
extract_option="xvf"
package_filename="${package_name}.tar.bz2"
tar_args="${tar_args/z/j}"
;;
esac
local package_filename="${package_name}${package_suffix:-.tar.gz}"
symlink_tarball_from_cache "$package_filename" "$checksum" || {
if ! symlink_tarball_from_cache "$package_filename" "$checksum"; then
echo "Downloading ${package_filename}..." >&2
{ http head "$mirror_url" &&
download_tarball "$mirror_url" "$package_filename" "$checksum"
} ||
http head "$mirror_url" &&
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
download_tarball "$package_url" "$package_filename" "$checksum"
}
fi
{ if tar "${extract_options:-xvf}" "$package_filename"; then
{ if tar $tar_args "$package_filename"; then
if [ -z "$KEEP_BUILD_PATH" ]; then
rm -f "$package_filename"
else
@ -327,9 +330,12 @@ download_tarball() {
echo "-> $package_url" >&2
{ http get "$package_url" "$package_filename"
verify_checksum "$package_filename" "$checksum"
} >&4 2>&1 || return 1
if http get "$package_url" "$package_filename" >&4 2>&1; then
verify_checksum "$package_filename" "$checksum" >&4 2>&1 || return 1
else
echo "error: failed to download $package_filename" >&2
return 1
fi
if [ -n "$PYTHON_BUILD_CACHE_PATH" ]; then
local cached_package_filename="${PYTHON_BUILD_CACHE_PATH}/$package_filename"
@ -431,26 +437,24 @@ fetch_jar() {
fi
local package_filename="${package_name}.jar"
symlink_jar_from_cache "$package_filename" "$checksum" || {
if ! symlink_tarball_from_cache "$package_filename" "$checksum"; then
echo "Downloading ${package_filename}..." >&2
{ http head "$mirror_url" &&
download_jar "$mirror_url" "$package_filename" "$checksum"
} ||
download_jar "$package_url" "$package_filename" "$checksum"
}
{ $JAVA -jar ${package_name}.jar -s -d ${package_name}
rm -f "$package_filename"
http head "$mirror_url" &&
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
download_tarball "$package_url" "$package_filename" "$checksum"
fi
{ if $JAVA -jar ${package_name}.jar -s -d ${package_name}; then
if [ -z "$KEEP_BUILD_PATH" ]; then
rm -f "$package_filename"
else
true
fi
fi
} >&4 2>&1
}
symlink_jar_from_cache() {
symlink_tarball_from_cache "$@"
}
download_jar() {
download_tarball "$@"
}
fetch_zip() {
local package_name="$1"
local package_url="$2"
@ -467,13 +471,13 @@ fetch_zip() {
fi
local package_filename="${package_name}.zip"
symlink_zip_from_cache "$package_filename" "$checksum" || {
if ! symlink_tarball_from_cache "$package_filename" "$checksum"; then
echo "Downloading ${package_filename}..." >&2
{ http head "$mirror_url" &&
download_zip "$mirror_url" "$package_filename" "$checksum"
} ||
download_zip "$package_url" "$package_filename" "$checksum"
}
http head "$mirror_url" &&
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
download_tarball "$package_url" "$package_filename" "$checksum"
fi
{ if unzip "$package_filename"; then
if [ -z "$KEEP_BUILD_PATH" ]; then
@ -485,14 +489,6 @@ fetch_zip() {
} >&4 2>&1
}
symlink_zip_from_cache() {
symlink_tarball_from_cache "$@"
}
download_zip() {
download_tarball "$@"
}
build_package() {
local package_name="$1"
shift
@ -526,7 +522,7 @@ build_package_standard() {
if [ "${MAKEOPTS+defined}" ]; then
MAKE_OPTS="$MAKEOPTS"
elif [ -z "${MAKE_OPTS+defined}" ]; then
MAKE_OPTS="-j 2"
MAKE_OPTS="-j $(num_cpu_cores)"
fi
# Support YAML_CONFIGURE_OPTS, PYTHON_CONFIGURE_OPTS, etc.
@ -603,7 +599,7 @@ build_package_pypy_builder() {
build_package_copy() {
mkdir -p "$PREFIX_PATH"
cp -R . "$PREFIX_PATH"
cp -fR . "$PREFIX_PATH"
}
before_install_package() {
@ -825,6 +821,16 @@ build_package_mac_openssl() {
security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain >> "$pem_file"
}
# Ensure that directories listed in LDFLAGS exist
build_package_ldflags_dirs() {
local arg
for arg in $LDFLAGS; do
case "$arg" in
-L* ) mkdir -p "${arg#-L}" ;;
esac
done
}
has_broken_mac_readline() {
[ "$(uname -s)" = "Darwin" ] &&
_has_broken_mac_readline &&
@ -1058,6 +1064,8 @@ fi
PREFIX_PATH="${ARGUMENTS[1]}"
if [ -z "$PREFIX_PATH" ]; then
usage
elif [ "${PREFIX_PATH#/}" = "$PREFIX_PATH" ]; then
PREFIX_PATH="${PWD}/${PREFIX_PATH}"
fi
if [ -z "$TMPDIR" ]; then
@ -1066,6 +1074,11 @@ else
TMP="${TMPDIR%/}"
fi
if [ ! -w "$TMP" ] || [ ! -x "$TMP" ]; then
echo "python-build: TMPDIR=$TMP is set to a non-accessible location" >&2
exit 1
fi
# Work around warnings building Ruby 2.0 on Clang 2.x:
# pass -Wno-error=shorten-64-to-32 if the compiler accepts it.
#
@ -1077,7 +1090,11 @@ fi
#fi
if [ -z "$MAKE" ]; then
export MAKE="make"
if [[ "FreeBSD" = "$(uname -s)" ]]; then
export MAKE="gmake"
else
export MAKE="make"
fi
fi
if [ -n "$PYTHON_BUILD_CACHE_PATH" ] && [ -d "$PYTHON_BUILD_CACHE_PATH" ]; then

View file

@ -1,7 +1,12 @@
#!/bin/sh
# Usage: PREFIX=/usr/local ./install.sh
#
# Installs python-build under $PREFIX.
set -e
cd "$(dirname "$0")"
if [ -z "${PREFIX}" ]; then
PREFIX="/usr/local"
fi
@ -9,15 +14,7 @@ fi
BIN_PATH="${PREFIX}/bin"
SHARE_PATH="${PREFIX}/share/python-build"
mkdir -p "${BIN_PATH}"
mkdir -p "${SHARE_PATH}"
mkdir -p "$BIN_PATH" "$SHARE_PATH"
for file in bin/*; do
cp "${file}" "${BIN_PATH}"
done
for file in share/python-build/*; do
cp -Rp "${file}" "${SHARE_PATH}"
done
echo "Installed python-build at ${PREFIX}"
install -p bin/* "$BIN_PATH"
install -p share/python-build/* "$SHARE_PATH"