Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into handle-non-git-patches
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Nov 5, 2019
2 parents a59672a + e2b1da8 commit c2822aa
Show file tree
Hide file tree
Showing 286 changed files with 644 additions and 358 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Release
on:
push:
tags: 'v*'

jobs:
homebrew:
name: Bump Homebrew formula
runs-on: ubuntu-latest
steps:
- uses: mislav/[email protected]
if: "!contains(github.ref, '-')" # skip prereleases
with:
formula-name: ruby-build
env:
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sudo: false
os:
- osx
- linux
install: git clone --depth 1 https://github.com/sstephenson/bats.git
script: PATH="./bats/bin:$PATH" script/test
language: c
Expand Down
37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ The build process may be configured through the following environment variables:
| `TMPDIR` | Where temporary files are stored. |
| `RUBY_BUILD_BUILD_PATH` | Where sources are downloaded and built. (Default: a timestamped subdirectory of `TMPDIR`) |
| `RUBY_BUILD_CACHE_PATH` | Where to cache downloaded package files. (Default: `~/.rbenv/cache` if invoked as rbenv plugin) |
| `RUBY_BUILD_HTTP_CLIENT` | One of `aria2c`, `curl`, or `wget` to use for downloading. (Default: first one found in PATH) |
| `RUBY_BUILD_ARIA2_OPTS` | Additional options to pass to `aria2c` for downloading. |
| `RUBY_BUILD_CURL_OPTS` | Additional options to pass to `curl` for downloading. |
| `RUBY_BUILD_WGET_OPTS` | Additional options to pass to `wget` for downloading. |
| `RUBY_BUILD_MIRROR_URL` | Custom mirror URL root. |
| `RUBY_BUILD_SKIP_MIRROR` | Always download from official sources, not mirrors. (Default: unset) |
| `RUBY_BUILD_SKIP_MIRROR` | Bypass the download mirror and fetch all package files from their original URLs. |
| `RUBY_BUILD_ROOT` | Custom build definition directory. (Default: `share/ruby-build`) |
| `RUBY_BUILD_DEFINITIONS` | Additional paths to search for build definitions. (Colon-separated list) |
| `CC` | Path to the C compiler. |
Expand Down Expand Up @@ -107,25 +111,30 @@ automatically verify the SHA2 checksum of each downloaded package before
installing it.

Checksums are optional and specified as anchors on the package URL in each
definition. (All bundled definitions include checksums.)
definition. All definitions bundled with ruby-build include checksums.

#### Package Mirrors

By default, ruby-build downloads package files from a mirror hosted on Amazon
CloudFront. If a package is not available on the mirror, if the mirror is
down, or if the download is corrupt, ruby-build will fall back to the official
URL specified in the definition file.
To speed up downloads, ruby-build fetches package files from a mirror hosted on
Amazon CloudFront. To benefit from this, the packages must specify their checksum:

You can point ruby-build to another mirror by specifying the
`RUBY_BUILD_MIRROR_URL` environment variable--useful if you'd like to run your
own local mirror, for example. Package mirror URLs are constructed by joining
this variable with the SHA2 checksum of the package file.
```sh
# example:
install_package "ruby-2.6.5" "https://ruby-lang.org/ruby-2.6.5.tgz#<SHA2>"
```

ruby-build will first try to fetch this package from `$RUBY_BUILD_MIRROR_URL/<SHA2>`
(note: this is the complete URL), where `<SHA2>` is the checksum for the file. It
will fall back to downloading the package from the original location if:
- the package was not found on the mirror;
- the mirror is down;
- the download is corrupt, i.e. the file's checksum doesn't match;
- no tool is available to calculate the checksum; or
- `RUBY_BUILD_SKIP_MIRROR` is enabled.

If you don't have an SHA2 program installed, ruby-build will skip the download
mirror and use official URLs instead. You can force ruby-build to bypass the
mirror by setting the `RUBY_BUILD_SKIP_MIRROR` environment variable.
You may specify a custom mirror by setting `RUBY_BUILD_MIRROR_URL`.

The official ruby-build download mirror is sponsored by
The default ruby-build download mirror is sponsored by
[Basecamp](https://basecamp.com/).

#### Keeping the build directory after installation
Expand Down
3 changes: 1 addition & 2 deletions bin/rbenv-install
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ for option in "${OPTIONS[@]}"; do
usage 0
;;
"l" | "list" )
echo "Available versions:"
definitions | indent
ruby-build --definitions
exit
;;
"f" | "force" )
Expand Down
104 changes: 65 additions & 39 deletions bin/ruby-build
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# --version Show version of ruby-build
#

RUBY_BUILD_VERSION="20180618"
RUBY_BUILD_VERSION="20191102"

OLDIFS="$IFS"

Expand Down Expand Up @@ -214,7 +214,6 @@ make_package() {
before_install_package "$package_name"
build_package "$package_name" $*
after_install_package "$package_name"
fix_directory_permissions
popd >&4
}

Expand Down Expand Up @@ -300,20 +299,25 @@ verify_checksum() {

http() {
local method="$1"
local url="$2"
local file="$3"
[ -n "$url" ] || return 1

if type aria2c &>/dev/null; then
"http_${method}_aria2c" "$url" "$file"
elif type curl &>/dev/null; then
"http_${method}_curl" "$url" "$file"
elif type wget &>/dev/null; then
"http_${method}_wget" "$url" "$file"
else
echo "error: please install \`aria2c\`, \`curl\` or \`wget\` and try again" >&2
exit 1
fi
[ -n "$2" ] || return 1
shift 1

RUBY_BUILD_HTTP_CLIENT="${RUBY_BUILD_HTTP_CLIENT:-$(detect_http_client)}"
[ -n "$RUBY_BUILD_HTTP_CLIENT" ] || return 1

"http_${method}_${RUBY_BUILD_HTTP_CLIENT}" "$@"
}

detect_http_client() {
local client
for client in aria2c curl wget; do
if type "$client" &>/dev/null; then
echo "$client"
return
fi
done
echo "error: install \`curl\`, \`wget\`, or \`aria2c\` to download packages" >&2
return 1
}

http_head_aria2c() {
Expand Down Expand Up @@ -350,6 +354,7 @@ fetch_tarball() {
local package_url="$2"
local mirror_url
local checksum
local extracted_dir

if [ "$package_url" != "${package_url/\#}" ]; then
checksum="${package_url#*#}"
Expand All @@ -374,17 +379,19 @@ fetch_tarball() {
fi

if ! reuse_existing_tarball "$package_filename" "$checksum"; then
local tarball_filename=$(basename $package_url)
local tarball_filename="$(basename "$package_url")"
echo "Downloading ${tarball_filename}..." >&2
http head "$mirror_url" &&
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
download_tarball "$package_url" "$package_filename" "$checksum"
fi

mkdir "$package_name"
{ if tar $tar_args "$package_filename"; then
if [ ! -d "$package_name" ]; then
extracted_dir="$(find_extracted_directory)"
mv "$extracted_dir" "$package_name"
fi

{ if tar $tar_args "$package_filename" -C "$package_name" --strip-components=1; then
ls >&2
if [ -z "$KEEP_BUILD_PATH" ]; then
rm -f "$package_filename"
else
Expand All @@ -394,6 +401,17 @@ fetch_tarball() {
} >&4 2>&1
}

find_extracted_directory() {
for f in *; do
if [ -d "$f" ]; then
echo "$f"
return
fi
done
echo "Extracted directory not found" >&2
return 1
}

reuse_existing_tarball() {
local package_filename="$1"
local checksum="$2"
Expand Down Expand Up @@ -594,7 +612,7 @@ build_package_standard_install_with_bundled_gems() {
build_package_standard_install "$@"
}

# Backword Compatibility for standard function
# Backward Compatibility for standard function
build_package_standard() {
build_package_standard_build "$@"
build_package_standard_install "$@"
Expand Down Expand Up @@ -753,11 +771,6 @@ after_install_package() {
local stub=1
}

fix_directory_permissions() {
# Ensure installed directories are not world-writable to avoid Bundler warnings
find "$PREFIX_PATH" -type d \( -perm -020 -o -perm -002 \) -exec chmod go-w {} \;
}

fix_rbx_gem_binstubs() {
local prefix="$1"
local gemdir="${prefix}/gems/bin"
Expand Down Expand Up @@ -785,13 +798,26 @@ fix_rbx_irb() {
true
}

require_java() {
local required="$1"
local java_version="$(java -version 2>&1)"
local version_string="$(grep 'java version' <<<"$java_version" | head -1 | grep -o '[0-9.]\+' || true)"
[ -n "$version_string" ] || version_string="$(grep 'openjdk version' <<<"$java_version" | head -1 | grep -o '[0-9.]\+' || true)"
IFS="."
local nums=($version_string)
IFS="$OLDIFS"
local found_version="${nums[0]}"
[ "$found_version" -gt 1 ] 2>/dev/null || found_version="${nums[1]}"
[ "$found_version" -ge "$required" ] 2>/dev/null && return 0
colorize 1 "ERROR" >&3
echo ": Java ${required} required, but your Java version was:" >&3
cat <<<"$java_version" >&3
return 1
}

# keep for backwards compatibility
require_java7() {
local version="$(java -version 2>&1 | grep '\(java\|openjdk\) version' | head -1)"
if [[ $version != *[789]* ]]; then
colorize 1 "ERROR" >&3
echo ": Java 7 required. Please install a 1.7-compatible JRE." >&3
return 1
fi
require_java 7
}

require_gcc() {
Expand Down Expand Up @@ -819,9 +845,9 @@ require_gcc() {

colorize 1 "TO FIX THE PROBLEM"
if type brew &>/dev/null; then
echo ": Install Homebrew's apple-gcc42 package with this"
echo ": Install Homebrew's GCC package with this"
echo -n "command: "
colorize 4 "brew tap homebrew/dupes ; brew install apple-gcc42"
colorize 4 "brew install [email protected]"
else
echo ": Install the official GCC compiler using these"
echo -n "packages: "
Expand Down Expand Up @@ -950,7 +976,7 @@ needs_yaml() {
use_homebrew_yaml() {
local libdir="$(brew --prefix libyaml 2>/dev/null || true)"
if [ -d "$libdir" ]; then
echo "ruby-build: use libyaml from homebrew"
echo "ruby-build: using libyaml from homebrew"
package_option ruby configure --with-libyaml-dir="$libdir"
else
return 1
Expand Down Expand Up @@ -985,7 +1011,7 @@ use_homebrew_readline() {
if [[ "$RUBY_CONFIGURE_OPTS" != *--with-readline-dir=* ]]; then
local libdir="$(brew --prefix readline 2>/dev/null || true)"
if [ -d "$libdir" ]; then
echo "ruby-build: use readline from homebrew"
echo "ruby-build: using readline from homebrew"
package_option ruby configure --with-readline-dir="$libdir"
else
return 1
Expand All @@ -1002,9 +1028,9 @@ has_broken_mac_openssl() {
}

use_homebrew_openssl() {
local ssldir="$(brew --prefix openssl 2>/dev/null || true)"
local ssldir="$(brew --prefix openssl@1.1 2>/dev/null || true)"
if [ -d "$ssldir" ]; then
echo "ruby-build: use openssl from homebrew"
echo "ruby-build: using openssl from homebrew"
package_option ruby configure --with-openssl-dir="$ssldir"
else
return 1
Expand Down Expand Up @@ -1340,7 +1366,7 @@ RUBY_BIN="${PREFIX_PATH}/bin/ruby"
CWD="$(pwd)"

if [ -z "$RUBY_BUILD_BUILD_PATH" ]; then
BUILD_PATH="${TMP}/ruby-build.${SEED}"
BUILD_PATH="$(mktemp -d "${LOG_PATH%.log}.XXXXXX")"
else
BUILD_PATH="$RUBY_BUILD_BUILD_PATH"
fi
Expand Down
13 changes: 0 additions & 13 deletions script/brew-publish

This file was deleted.

24 changes: 14 additions & 10 deletions script/release
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
set -e

git fetch -q --tags origin master
git checkout -q master
git merge --ff-only @{upstream}

existing="$(git tag --points-at HEAD)"
if [ -n "$existing" ]; then
echo "Aborting: HEAD is already tagged as '${existing}'" >&2
exit 1
fi

git checkout -q master

binfile="bin/ruby-build"
new_version="$(date '+%Y%m%d')"
version_tag="v${new_version}"
previous_tag="$(git tag | grep '^v' | sort | tail -1)"
previous_tag="$(git describe --tags HEAD --abbrev=0)"

if git diff --quiet "${previous_tag}..HEAD" -- bin share; then
echo "Aborting: No features to release since '${previous_tag}'" >&2
Expand All @@ -34,13 +34,17 @@ fi
sed -i.bak -E "s!^(RUBY_BUILD_VERSION=).+!\\1\"${new_version}\"!" "$binfile"
rm -f "${binfile}.bak"

git commit -m "ruby-build ${new_version}" "$binfile"
git tag "$version_tag"
git push origin master "${version_tag}"
git commit -m "ruby-build ${new_version}" -- "$binfile"

{ echo "ruby-build ${new_version}"
notes_file="$(mktemp)"
{ echo "ruby-build $new_version"
echo
git log --no-merges --format='%w(0,0,2)* %B' --reverse "${previous_tag}..HEAD^" -- bin share
} | hub release create -dF - "$version_tag" || true
git log --no-merges --format='* %s%n%w(0,2,2)%+b' --reverse "${previous_tag}..HEAD^" -- bin share
} >"$notes_file"
trap "rm -f '$notes_file'" EXIT

git tag "$version_tag" -F "$notes_file" --edit
git push origin master "${version_tag}"

script/brew-publish ruby-build rbenv/ruby-build "$version_tag"
git tag --list "$version_tag" --format='%(contents:subject)%0a%0a%(contents:body)' | \
hub release create -F- "$version_tag"
27 changes: 27 additions & 0 deletions script/update-rbx-defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby

require 'open-uri'
require 'pathname'

file = "https://raw.githubusercontent.com/postmodern/ruby-versions/master/rubinius/checksums.sha256"
dir = Pathname(File.expand_path("share/ruby-build"))

open(file).each do |package|
sha256, filename = package.chomp.split
version = filename.match(/rubinius-(3.[\d\.]+).tar.bz2/)

next unless version

version = version[1]
defname = "rbx-#{version}"

next if File.exists?(dir.join(defname))

definition = <<-TEMPLATE
require_llvm 3.7
install_package "openssl-1.0.2o" "https://www.openssl.org/source/openssl-1.0.2o.tar.gz#ec3f5c9714ba0fd45cb4e087301eb1336c317e0d20b575a125050470e8089e4d" mac_openssl --if has_broken_mac_openssl
install_package "rubinius-#{version}" "https://rubinius-releases-rubinius-com.s3.amazonaws.com/rubinius-#{version}.tar.bz2##{sha256}" rbx
TEMPLATE

File.open(dir.join(defname), "w"){|f| f.write definition}
end
Loading

0 comments on commit c2822aa

Please sign in to comment.