From b9bddb9b12d265946d26a47b11b88de9087fb764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20K=C3=A4ppler?= Date: Wed, 30 Nov 2022 16:44:38 +0000 Subject: [PATCH] Verify mandatory Ruby patches exist --- ....patch => thread-memory-allocations.patch} | 0 ....patch => thread-memory-allocations.patch} | 0 patches/ruby/mandatory_patches | 1 + scripts/install-ruby | 19 ++++++++++++++++--- 4 files changed, 17 insertions(+), 3 deletions(-) rename patches/ruby/2.7/{thread-memory-allocations-2.7.patch => thread-memory-allocations.patch} (100%) rename patches/ruby/3.0/{thread-memory-allocations-3.0.patch => thread-memory-allocations.patch} (100%) create mode 100644 patches/ruby/mandatory_patches diff --git a/patches/ruby/2.7/thread-memory-allocations-2.7.patch b/patches/ruby/2.7/thread-memory-allocations.patch similarity index 100% rename from patches/ruby/2.7/thread-memory-allocations-2.7.patch rename to patches/ruby/2.7/thread-memory-allocations.patch diff --git a/patches/ruby/3.0/thread-memory-allocations-3.0.patch b/patches/ruby/3.0/thread-memory-allocations.patch similarity index 100% rename from patches/ruby/3.0/thread-memory-allocations-3.0.patch rename to patches/ruby/3.0/thread-memory-allocations.patch diff --git a/patches/ruby/mandatory_patches b/patches/ruby/mandatory_patches new file mode 100644 index 0000000..fb13254 --- /dev/null +++ b/patches/ruby/mandatory_patches @@ -0,0 +1 @@ +thread-memory-allocations diff --git a/scripts/install-ruby b/scripts/install-ruby index b04c9dd..eef6293 100755 --- a/scripts/install-ruby +++ b/scripts/install-ruby @@ -46,10 +46,23 @@ function build_common() { rm ruby.tar.gz cd /usr/src/ruby + # Process patch files + local ruby_version=$(cut -d '.' -f 1,2 <<< $RUBY_VERSION) + local patchdir="/patches/ruby/${ruby_version}" + + # Verify mandatory patches + while read -r patchname; do + local patchfile="${patchdir}/${patchname}.patch" + if [[ ! -f "${patchfile}" ]]; then + echo "!! Missing mandatory patch ${patchname}" + echo "!! Make sure ${patchfile} exists before proceeding." + exit 1 + fi + done < "/patches/ruby/mandatory_patches" + # Apply patches - ruby_version=`cut -d '.' -f 1,2 <<< $RUBY_VERSION` - if [[ -d "/patches/ruby/$ruby_version" ]]; then - for i in "/patches/ruby/$ruby_version"/*.patch; do + if [[ -d "${patchdir}" ]]; then + for i in "${patchdir}"/*.patch; do echo "$i..." patch -p1 -i "$i" done