Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RUBY_BUILD_TARBALL_OVERRIDE to override the ruby tarball URL #2258

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ The build process may be configured through the following environment variables:
| `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_MIRROR_PACKAGE_URL` | Custom complete mirror URL (e.g. http://mirror.example.com/package-1.0.0.tar.gz). |
| `RUBY_BUILD_MIRROR_PACKAGE_URL` | Custom complete mirror URL (e.g. http://mirror.example.com/package-1.0.0.tar.gz). |
| `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_TARBALL_OVERRIDE` | Override the URL to fetch the ruby tarball from, optionally followed by `#checksum`. |
| `RUBY_BUILD_DEFINITIONS` | Additional paths to search for build definitions. (Colon-separated list) |
| `CC` | Path to the C compiler. |
| `RUBY_CFLAGS` | Additional `CFLAGS` options (_e.g.,_ to override `-O3`). |
Expand Down
17 changes: 15 additions & 2 deletions bin/ruby-build
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ fetch_tarball() {
local checksum
local extracted_dir

if is_ruby_package "$1" && [ -n "$RUBY_BUILD_TARBALL_OVERRIDE" ]; then
Copy link
Member Author

@eregon eregon Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason we need the is_ruby_package check is because fetch_tarball is also used for non-ruby packages like openssl and overriding both URLs with the same URL would make no sense.

package_url="$RUBY_BUILD_TARBALL_OVERRIDE"
fi

if [ "$package_url" != "${package_url/\#}" ]; then
checksum="${package_url#*#}"
package_url="${package_url%%#*}"
Expand Down Expand Up @@ -1257,14 +1261,23 @@ isolated_gem_install() {

apply_ruby_patch() {
local patchfile
case "$1" in
ruby-* | jruby-* | rubinius-* | truffleruby-* )
if is_ruby_package "$1"; then
patchfile="$(mktemp "${TMP}/ruby-patch.XXXXXX")"
cat "${2:--}" >"$patchfile"

local striplevel=0
grep -q '^--- a/' "$patchfile" && striplevel=1
patch -p$striplevel --force -i "$patchfile"
fi
}

is_ruby_package() {
case "$1" in
ruby-* | jruby-* | rubinius-* | truffleruby[+-]* | mruby-* | picoruby-* )
return 0
;;
*)
return 1
;;
esac
}
Expand Down