Add RUBY_BUILD_TARBALL_OVERRIDE to override the ruby tarball URL

* Update the check for whether a package is a ruby.
This commit is contained in:
Benoit Daloze 2023-09-21 16:23:35 +02:00
parent 4bf2fece5e
commit 216084d334
2 changed files with 17 additions and 3 deletions

View file

@ -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`). |

View file

@ -381,6 +381,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%%#*}"
@ -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
}