Skip to content

Commit

Permalink
Add RUBY_BUILD_TARBALL_OVERRIDE to override the ruby tarball URL
Browse files Browse the repository at this point in the history
* Update the check for whether a package is a ruby.
  • Loading branch information
eregon committed Oct 11, 2023
1 parent d9af2ad commit 7f03f11
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
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 @@ -371,6 +371,10 @@ fetch_tarball() {
local checksum
local extracted_dir

if is_ruby_package "$1" && [ -n "$RUBY_BUILD_TARBALL_OVERRIDE" ]; then
package_url="$RUBY_BUILD_TARBALL_OVERRIDE"
fi

if [ "$package_url" != "${package_url/\#}" ]; then
checksum="${package_url#*#}"
package_url="${package_url%%#*}"
Expand Down Expand Up @@ -1203,14 +1207,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

0 comments on commit 7f03f11

Please sign in to comment.