forked from kufu/ruby-docker-images
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_ruby.sh
More file actions
executable file
·99 lines (85 loc) · 2.22 KB
/
install_ruby.sh
File metadata and controls
executable file
·99 lines (85 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
set -ex
RUBY_VERSION=${RUBY_VERSION-2.6.0}
RUBY_MAJOR=$(echo $RUBY_VERSION | sed -E 's/\.[0-9]+(-.*)?$//g')
RUBYGEMS_VERSION=${RUBYGEMS_VERSION-3.0.3}
wget -O index.txt "https://cache.ruby-lang.org/pub/ruby/index.txt"
case $RUBY_VERSION in
master:*)
RUBY_MASTER_COMMIT=$(echo $RUBY_VERSION | awk -F: '{print $2}' )
RUBY_VERSION=master
;;
2.7.0-preview1)
RUBY_DOWNLOAD_SHA256=8c546df3345398b3edc9d0ab097846f033783d33762889fd0f3dc8bb465c3354
;;
*)
entry=$(grep ruby-$RUBY_VERSION.tar.xz index.txt)
if test -z "$entry"; then
echo "Unsupported RUBY_VERSION ($RUBY_VERSION)" >2
exit 1
fi
RUBY_DOWNLOAD_SHA256=$(echo $entry | awk '{print $4}')
RUBY_DOWNLOAD_URI=$(echo $entry | awk '{print $2}')
;;
esac
case $RUBY_VERSION in
2.3.*)
# Need to down grade openssl to 1.0.x for Ruby 2.3.x
apt-get install -y --no-install-recommends libssl1.0-dev
;;
esac
if test -n "$RUBY_MASTER_COMMIT"; then
if test -f /usr/src/ruby/configure.ac; then
cd /usr/src/ruby
git pull --rebase origin
else
rm -r /usr/src/ruby
git clone https://github.com/ruby/ruby.git /usr/src/ruby
cd /usr/src/ruby
fi
git checkout $RUBY_MASTER_COMMIT
else
if test -z "$RUBY_DOWNLOAD_URI"; then
RUBY_DOWNLOAD_URI="https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR}/ruby-${RUBY_VERSION}.tar.xz"
fi
wget -O ruby.tar.xz $RUBY_DOWNLOAD_URI
echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c -
mkdir -p /usr/src/ruby
tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1
rm ruby.tar.xz
fi
(
cd /usr/src/ruby
autoconf
mkdir -p /tmp/ruby-build
pushd /tmp/ruby-build
gnuArch=$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)
/usr/src/ruby/configure \
--build="$gnuArch" \
--prefix=/usr/local \
--disable-install-doc \
--enable-shared \
optflags="-O3" \
debugflags="-g"
make -j "$(nproc)"
make install
popd
rm -rf /tmp/ruby-build
)
case $RUBY_VERSION in
master)
# DO NOTHING
;;
2.7.*)
# DO NOTHING
;;
2.6.*)
# DO NOTHING
;;
*)
gem update --system "$RUBYGEMS_VERSION"
;;
esac
rm -fr /usr/src/ruby /root/.gem/
# rough smoke test
(cd && ruby --version && gem --version && bundle --version)