2014-08-14 14:58:13 -04:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
|
|
|
|
|
|
|
versions=( "$@" )
|
|
|
|
if [ ${#versions[@]} -eq 0 ]; then
|
|
|
|
versions=( */ )
|
|
|
|
fi
|
|
|
|
versions=( "${versions[@]%/}" )
|
2015-03-23 16:34:12 -04:00
|
|
|
shaPage=$(curl -fsSL 'https://www.ruby-lang.org/en/downloads/')
|
2014-08-14 14:58:13 -04:00
|
|
|
|
2015-08-04 12:42:09 -04:00
|
|
|
latest_gem_version() {
|
|
|
|
curl -sSL "https://rubygems.org/api/v1/gems/$1.json" | sed -r 's/^.*"version":"([^"]+)".*$/\1/'
|
|
|
|
}
|
|
|
|
|
|
|
|
rubygems="$(latest_gem_version rubygems-update)"
|
|
|
|
bundler="$(latest_gem_version bundler)"
|
2015-06-12 14:06:36 -04:00
|
|
|
|
2014-08-14 14:58:13 -04:00
|
|
|
for version in "${versions[@]}"; do
|
2014-09-29 12:30:47 -04:00
|
|
|
fullVersion="$(curl -sSL --compressed "http://cache.ruby-lang.org/pub/ruby/$version/" \
|
2014-08-14 14:58:13 -04:00
|
|
|
| grep -E '<a href="ruby-'"$version"'.[^"]+\.tar\.bz2' \
|
|
|
|
| grep -vE 'preview|rc' \
|
|
|
|
| sed -r 's!.*<a href="ruby-([^"]+)\.tar\.bz2.*!\1!' \
|
|
|
|
| sort -V | tail -1)"
|
2015-03-23 16:34:12 -04:00
|
|
|
shaVal="$(echo $shaPage | sed -r "s/.*Ruby ${fullVersion}<\/a><br \/> sha256: ([^<]+).*/\1/")"
|
2014-08-14 14:58:13 -04:00
|
|
|
(
|
|
|
|
set -x
|
2015-06-12 14:06:36 -04:00
|
|
|
sed -ri '
|
|
|
|
s/^(ENV RUBY_MAJOR) .*/\1 '"$version"'/;
|
|
|
|
s/^(ENV RUBY_VERSION) .*/\1 '"$fullVersion"'/;
|
|
|
|
s/^(ENV RUBY_DOWNLOAD_SHA256) .*/\1 '"$shaVal"'/;
|
|
|
|
s/^(ENV BUNDLER_VERSION) .*/\1 '"$bundler"'/;
|
2015-08-04 12:42:09 -04:00
|
|
|
s/^(ENV RUBYGEMS_VERSION) .*/\1 '"$rubygems"'/;
|
2016-01-29 13:36:19 -05:00
|
|
|
' "$version"{/,/*/}Dockerfile
|
2015-08-19 14:55:20 -04:00
|
|
|
sed -ri 's/^(FROM ruby):.*/\1:'"$version"'/' "$version/"*"/Dockerfile"
|
2014-08-14 14:58:13 -04:00
|
|
|
)
|
|
|
|
done
|