From 50c79336d0de87e0f77137530142625e1473c8f1 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 20 Feb 2024 13:14:24 +0000 Subject: [PATCH] [ruby] Build with base ruby 3.0 to bootstrap from git sources We recently updated the minimum required base ruby version to 3.0 (https://github.com/ruby/ruby/pull/9976). This change updates the Dockerfile to build base ruby from tarball and install it instead of using Ubuntu focal's ruby package, which is still 2.7. --- projects/ruby/Dockerfile | 6 ++++-- projects/ruby/build_baseruby.sh | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100755 projects/ruby/build_baseruby.sh diff --git a/projects/ruby/Dockerfile b/projects/ruby/Dockerfile index 899814767509..3f442c99738a 100644 --- a/projects/ruby/Dockerfile +++ b/projects/ruby/Dockerfile @@ -19,11 +19,13 @@ FROM gcr.io/oss-fuzz-base/base-builder RUN apt-get update -y && \ apt-get install -y libssl-dev libyaml-dev libreadline6-dev \ zlib1g-dev libncurses5-dev libffi-dev \ - bison autoconf ruby pkg-config + bison autoconf pkg-config +RUN mkdir $SRC/fuzz +COPY build_baseruby.sh $SRC/fuzz/ +RUN $SRC/fuzz/build_baseruby.sh RUN git clone https://github.com/ruby/ruby.git WORKDIR ruby COPY build.sh $SRC/ -RUN mkdir $SRC/fuzz COPY *.rb *.c *.options $SRC/fuzz/ diff --git a/projects/ruby/build_baseruby.sh b/projects/ruby/build_baseruby.sh new file mode 100755 index 000000000000..a9ddf6908c65 --- /dev/null +++ b/projects/ruby/build_baseruby.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +# This script builds and installs the base ruby, which is used to bootstrap ruby from git sources. + +set -euxo pipefail + +# NOTE: You can find tarball URLs and SHA256 checksums at https://www.ruby-lang.org/en/downloads +ruby_tarball_url=https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.6.tar.gz +ruby_tarball_sha256=6e6cbd490030d7910c0ff20edefab4294dfcd1046f0f8f47f78b597987ac683e + +# Download and verify the tarball +build_dir="$(mktemp -d -t build_baseruby.XXXXXX)" +curl -L -o "$build_dir/ruby.tar.gz" "$ruby_tarball_url" +echo "$ruby_tarball_sha256 $build_dir/ruby.tar.gz" | sha256sum -c - + +# Extract the tarball +tar -C "$build_dir" -xzf "$build_dir/ruby.tar.gz" --strip-components=1 + +# Build and install the base ruby +cd "$build_dir" +./configure --disable-install-doc +make -j"$(nproc)" +make install