Skip to content

Commit b551fed

Browse files
committed
Imported changes from rbenv/ruby-build 20190401
1 parent 6efe9d1 commit b551fed

1 file changed

Lines changed: 78 additions & 37 deletions

File tree

‎plugins/python-build/bin/python-build‎

Lines changed: 78 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -326,31 +326,25 @@ verify_checksum() {
326326

327327
http() {
328328
local method="$1"
329-
local url="$2"
330-
local file="$3"
331-
[ -n "$url" ] || return 1
329+
[ -n "$2" ] || return 1
330+
shift 1
332331

333-
local http_client
334-
if [ -n "${PYTHON_BUILD_HTTP_CLIENT}" ]; then
335-
http_client="http_${method}_${PYTHON_BUILD_HTTP_CLIENT}"
336-
else
337-
if type aria2c &>/dev/null; then
338-
http_client="http_${method}_aria2c"
339-
elif type curl &>/dev/null; then
340-
http_client="http_${method}_curl"
341-
elif type wget &>/dev/null; then
342-
# SSL Certificate error with older wget that does not support Server Name Indication (#60)
343-
if [[ "$(wget --version 2>/dev/null || true)" = "GNU Wget 1.1"[0-3]* ]]; then
344-
echo "python-build: wget (< 1.14) doesn't support Server Name Indication. Please install curl (>= 7.18.1) and try again" >&2
345-
return 1
346-
fi
347-
http_client="http_${method}_wget"
348-
else
349-
echo "error: please install \`aria2c\`, \`curl\` or \`wget\` and try again" >&2
350-
exit 1
332+
PYTHON_BUILD_HTTP_CLIENT="${PYTHON_BUILD_HTTP_CLIENT:-$(detect_http_client)}"
333+
[ -n "$PYTHON_BUILD_HTTP_CLIENT" ] || return 1
334+
335+
"http_${method}_${PYTHON_BUILD_HTTP_CLIENT}" "$@"
336+
}
337+
338+
detect_http_client() {
339+
local client
340+
for client in aria2c curl wget; do
341+
if type "$client" &>/dev/null; then
342+
echo "$client"
343+
return
351344
fi
352-
fi
353-
"${http_client}" "$url" "$file"
345+
done
346+
echo "error: please install \`aria2c\`, \`curl\`, or \`wget\` and try again" >&2
347+
return 1
354348
}
355349

356350
http_head_aria2c() {
@@ -387,6 +381,7 @@ fetch_tarball() {
387381
local package_url="$2"
388382
local mirror_url
389383
local checksum
384+
local extracted_dir
390385

391386
if [ "$package_url" != "${package_url/\#}" ]; then
392387
checksum="${package_url#*#}"
@@ -419,14 +414,19 @@ fetch_tarball() {
419414
fi
420415

421416
if ! reuse_existing_tarball "$package_filename" "$checksum"; then
422-
local tarball_filename=$(basename $package_url)
417+
local tarball_filename="$(basename "$package_url")"
423418
echo "Downloading ${tarball_filename}..." >&2
424419
http head "$mirror_url" &&
425420
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
426421
download_tarball "$package_url" "$package_filename" "$checksum"
427422
fi
428423

429424
{ if tar $tar_args "$package_filename"; then
425+
if [ ! -d "$package_name" ]; then
426+
extracted_dir="$(find_extracted_directory)"
427+
mv "$extracted_dir" "$package_name"
428+
fi
429+
430430
if [ -z "$KEEP_BUILD_PATH" ]; then
431431
rm -f "$package_filename"
432432
else
@@ -436,6 +436,17 @@ fetch_tarball() {
436436
} >&4 2>&1
437437
}
438438

439+
find_extracted_directory() {
440+
for f in *; do
441+
if [ -d "$f" ]; then
442+
echo "$f"
443+
return
444+
fi
445+
done
446+
echo "Extracted directory not found" >&2
447+
return 1
448+
}
449+
439450
fetch_nightly_tarball() {
440451
local package_name="$1"
441452
local package_url="$2"
@@ -925,6 +936,13 @@ fix_jruby_shebangs() {
925936
done
926937
}
927938

939+
build_package_truffleruby() {
940+
build_package_copy
941+
942+
cd "${PREFIX_PATH}"
943+
./lib/truffle/post_install_hook.sh
944+
}
945+
928946
remove_windows_files() {
929947
cd "$PREFIX_PATH"
930948
rm -f bin/*.exe bin/*.dll bin/*.bat bin/jruby.sh
@@ -1223,9 +1241,9 @@ require_gcc() {
12231241

12241242
colorize 1 "TO FIX THE PROBLEM"
12251243
if type brew &>/dev/null; then
1226-
echo ": Install Homebrew's apple-gcc42 package with this"
1244+
echo ": Install Homebrew's GCC package with this"
12271245
echo -n "command: "
1228-
colorize 4 "brew tap homebrew/dupes ; brew install apple-gcc42"
1246+
colorize 4 "brew install gcc@4.9"
12291247
else
12301248
echo ": Install the official GCC compiler using these"
12311249
echo -n "packages: "
@@ -1544,8 +1562,8 @@ build_package_mac_openssl() {
15441562
local nokerberos
15451563
[[ "$1" != openssl-1.0.* ]] || nokerberos=1
15461564

1547-
# Compile a shared lib with zlib dynamically linked, no kerberos.
1548-
package_option openssl configure --openssldir="$OPENSSLDIR" zlib-dynamic no-ssl2 no-ssl3 no-krb5 shared
1565+
# Compile a shared lib with zlib dynamically linked.
1566+
package_option openssl configure --openssldir="$OPENSSLDIR" zlib-dynamic no-ssl3 shared ${nokerberos:+no-ssl2 no-krb5}
15491567

15501568
# Default MAKE_OPTS are -j 2 which can confuse the build. Thankfully, make
15511569
# gives precedence to the last -j option, so we can override that.
@@ -1561,15 +1579,38 @@ build_package_mac_openssl() {
15611579

15621580
# Post-install check that the openssl extension was built.
15631581
build_package_verify_openssl() {
1564-
"$RUBY_BIN" -e 'begin
1565-
require "openssl"
1566-
rescue LoadError
1567-
$stderr.puts "The Ruby openssl extension was not compiled. Missing the OpenSSL lib?"
1568-
$stderr.puts "Configure options used:"
1569-
require "rbconfig"; require "shellwords"
1570-
RbConfig::CONFIG.fetch("configure_args").shellsplit.each { |arg| $stderr.puts " #{arg}" }
1571-
exit 1
1572-
end' >&4 2>&1
1582+
"$RUBY_BIN" -e '
1583+
manager = ARGV[0]
1584+
packages = {
1585+
"apt-get" => Hash.new {|h,k| "lib#{k}-dev" }.update(
1586+
"openssl" => "libssl-dev",
1587+
"zlib" => "zlib1g-dev"
1588+
),
1589+
"yum" => Hash.new {|h,k| "#{k}-devel" }.update(
1590+
"yaml" => "libyaml-devel"
1591+
)
1592+
}
1593+
1594+
failed = %w[openssl readline zlib yaml].reject do |lib|
1595+
begin
1596+
require lib
1597+
rescue LoadError
1598+
$stderr.puts "The Ruby #{lib} extension was not compiled."
1599+
end
1600+
end
1601+
1602+
if failed.size > 0
1603+
$stderr.puts "ERROR: Ruby install aborted due to missing extensions"
1604+
$stderr.print "Try running `%s install -y %s` to fetch missing dependencies.\n\n" % [
1605+
manager,
1606+
failed.map { |lib| packages.fetch(manager)[lib] }.join(" ")
1607+
] unless manager.empty?
1608+
$stderr.puts "Configure options used:"
1609+
require "rbconfig"; require "shellwords"
1610+
RbConfig::CONFIG.fetch("configure_args").shellsplit.each { |arg| $stderr.puts " #{arg}" }
1611+
exit 1
1612+
end
1613+
' "$(basename "$(type -p yum apt-get | head -1)")" >&4 2>&1
15731614
}
15741615

15751616
# Ensure that directories listed in LDFLAGS exist

0 commit comments

Comments
 (0)