Skip to content

Commit

Permalink
[ruby] Build with base ruby 3.0 to bootstrap from git sources
Browse files Browse the repository at this point in the history
We recently updated the minimum required base ruby version to 3.0
(ruby/ruby#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.
  • Loading branch information
kateinoigakukun committed Feb 20, 2024
1 parent c89abc3 commit 50c7933
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
6 changes: 4 additions & 2 deletions projects/ruby/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
38 changes: 38 additions & 0 deletions projects/ruby/build_baseruby.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 50c7933

Please sign in to comment.