Skip to content

Instantly share code, notes, and snippets.

@thenoseman
Last active May 15, 2017 23:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save thenoseman/10244189 to your computer and use it in GitHub Desktop.
Save thenoseman/10244189 to your computer and use it in GitHub Desktop.
Install a rbenv ruby version patched with the performance patches from rvm
#!/bin/bash
# This script creates a custom ruby definition for rbenv
# which incorporates the rvm patches from skaes.
#
# (c) frank.schumacher.privat@gmail.com
#
rubyexpress_repo="https://github.com/skaes/rvm-patchsets.git"
rubybuild_repo="https://github.com/sstephenson/ruby-build.git"
mkdir rbenv-railsexpress
cd rbenv-railsexpress
rm -rf ruby-build
rm -rf rvm-patchsets
tmp_dir=$(pwd)
echo "Fetching repos"
git clone ${rubybuild_repo}
git clone ${rubyexpress_repo}
echo ""
for patch_dir in rvm-patchsets/patches/ruby/2.1.* rvm-patchsets/patches/ruby/1.9.* rvm-patchsets/patches/ruby/2.2.* rvm-patchsets/patches/ruby/2.3.* ; do
patch_for_mri_version=${patch_dir##*/}
ruby_build_file=$(ls -1 ruby-build/share/ruby-build/${patch_for_mri_version}* | grep -e "-p[0-9]\{3,\}$" | sort -n | tail -n 1)
if [[ ! -f "${ruby_build_file}" ]]; then
ruby_build_file="ruby-build/share/ruby-build/${patch_for_mri_version}"
fi
echo "Found railsexpress patches for MRI ${patch_for_mri_version} in ${ruby_build_file}"
if [[ -f "${ruby_build_file}" ]]; then
cp ${ruby_build_file} ${patch_for_mri_version}
echo "# Apply railsexpress patches" > railsexpress.tmp
echo "build_package_railsexpress() {" >> railsexpress.tmp
echo " echo 'Applying patches ...'" >> railsexpress.tmp
for patch_file in ${patch_dir}/railsexpress/*; do
echo " patch -s -p1 < ${tmp_dir}/${patch_file}" >> railsexpress.tmp
done
echo "}" >> railsexpress.tmp
echo "" >> railsexpress.tmp
cat railsexpress.tmp ${patch_for_mri_version} | sed 's/ldflags_dirs/railsexpress ldflags_dirs/g' > ${patch_for_mri_version}-perf
rm ${patch_for_mri_version}
rm railsexpress.tmp
echo "Install patched ruby with 'RUBY_CONFIGURE_OPTS=--with-readline-dir=\"$(brew --prefix readline)\" CONFIGURE_OPTS=\"--disable-install-rdoc\" rbenv install rbenv-railsexpress/${patch_for_mri_version}-perf'"
echo ""
fi
done
rm -rf ${tmp_dir}/ruby-build
echo ""
echo "After installing the patched ruby 'rm -rf ${tmp_dir}' will remove all remainders of this operation"
@pnomolos
Copy link

@thenoseman Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment