Created
October 26, 2022 15:02
-
-
Save isorsa/8a26e1d5dc7ddd786eaaa430b7f986b6 to your computer and use it in GitHub Desktop.
ruby latest setup for centos 7.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -ex | |
toolset=devtoolset-7 | |
yum install -y epel-release # EPEL repo | |
yum install -y centos-release-scl # shiny-new(er) compliers | |
# make sure there are no surprises installing from repos | |
grep -r gpgkey= /etc/yum.repos.d/ | cut -d= -f2 | xargs -L1 rpm --import | |
yum update -y # system update | |
# misc dev tools, but we're not going to use the ancient toolchain | |
yum groupinstall -y 'Development Tools' | |
yum install -y \ | |
${toolset}-toolchain bison-devel libtool git wget \ | |
libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel \ | |
zlib-devel openssl-devel libyaml-devel readline-devel curl-devel \ | |
openssl-devel pcre-devel memcached-devel ${toolset}-valgrind-devel \ | |
${toolset}-systemtap-sdt-devel ${toolset}-gcc-gdb-plugin \ | |
mariadb-devel postgresql-devel sqlite-devel hiredis-devel \ | |
ImageMagick-devel libidn-devel \ | |
latest_ruby_version() { | |
git ls-remote --tags https://github.com/ruby/ruby | | |
sed 's!.*/v!!;/[0-9]/!d;s/_/./g;/\//d;/\..*.\..*\./d' | | |
sort -V | | |
tail -1 | |
} | |
find_sha256sum() { | |
wget -O- https://www.ruby-lang.org/en/feeds/news.rss | | |
grep -A10 $1 | | |
grep SHA256 | | |
grep -Eo '[0-9a-f]{64}' | |
} | |
version=$(latest_ruby_version) | |
major_version=${version%*.*} | |
tarball=ruby-${version}.tar.xz | |
cd /usr/local/src | |
wget https://cache.ruby-lang.org/pub/ruby/${major_version}/$tarball -O $tarball | |
if [[ ! sha256sum $tarball =~ ^$(find_sha256sum $tarball) ]]; then | |
echo 'ERROR: hash mismatch on downloaded Ruby source tarball. Try again.' >&2 | |
false | |
fi | |
tar xf $tarball | |
rm -f $tarball | |
scl enable ${toolset} "$SHELL" <<NEXT_STAGE_SCRIPT | |
CFLAGS+=" -O2 -g -grecord-gcc-switches -fstack-protector-strong" | |
CFLAGS+=" -fstack-clash-protection -D_FORITIFY_SOURCE=2" | |
CFLAGS+=" -Wl,-z,relro -Wl,-z,now -Wl,-z,defs -pipe"; export CFLAGS | |
cd ruby-$version | |
./configure \ | |
--without-X11 \ | |
--without-tk \ | |
--enable-shared \ | |
--disable-install-doc \ | |
make -j4 install # -j OOM's on tiny boxes | |
cd .. | |
rm -rf ruby-$version | |
/usr/local/bin/gem update --system | |
[ -e ~/.gemrc ] || echo 'gem: --no-document' > ~/.gemrc | |
[ -e ~/.pryrc ] || echo "require 'spirit_hands'" > ~/.pryrc | |
/usr/local/bin/gem install \ | |
rake \ | |
bundler \ | |
bundler-audit \ | |
rubocop \ | |
specific_install \ | |
nokogiri \ | |
ox \ | |
oj \ | |
syck \ | |
multi_json \ | |
multi_xml \ | |
msgpack \ | |
grpc \ | |
grpc-tools \ | |
google-protobuf \ | |
net-http-persistent \ | |
net-http-pipeline \ | |
net-ssh \ | |
net-scp \ | |
faraday \ | |
faraday-cookie_jar \ | |
faraday-middleware \ | |
sass \ | |
haml \ | |
hamlit \ | |
mustache \ | |
execjs \ | |
puma \ | |
concurrent-ruby \ | |
concurrent-ruby-ext \ | |
ruby-progressbar \ | |
parallel \ | |
absolute_time \ | |
ruby-shadow \ | |
netrc \ | |
pg \ | |
mysql2 \ | |
sqlite3 \ | |
redis \ | |
hiredis \ | |
safe_yaml \ | |
rspec \ | |
minitest \ | |
chef \ | |
license_finder \ | |
yard \ | |
ronn \ | |
gem-man \ | |
gem-homepage \ | |
foreman_god \ | |
rbtrace \ | |
uniform_notifier \ | |
ruby-prof \ | |
ruby-prof-flamegraph \ | |
spirit_hands \ | |
/usr/local/bin/ruby -e 'puts "It works!"' | |
NEXT_STAGE_SCRIPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment