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[@]%/}" )
|
2016-03-31 20:13:29 -04:00
|
|
|
shaPage=$(curl -fsSL 'https://www.ruby-lang.org/en/downloads/' | tr '\r\n' ' ')
|
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
|
|
|
|
2016-01-29 13:39:48 -05:00
|
|
|
travisEnv=
|
2014-08-14 14:58:13 -04:00
|
|
|
for version in "${versions[@]}"; do
|
2016-03-31 20:13:29 -04:00
|
|
|
IFS=$'\n'; allVersions=(
|
2016-09-19 20:48:46 -04:00
|
|
|
$(curl -sSL --compressed "https://cache.ruby-lang.org/pub/ruby/$version/" \
|
2016-03-31 20:13:29 -04:00
|
|
|
| grep -E '<a href="ruby-'"$version"'.[^"]+\.tar\.bz2' \
|
|
|
|
| grep -vE 'preview|rc' \
|
|
|
|
| sed -r 's!.*<a href="ruby-([^"]+)\.tar\.bz2.*!\1!' \
|
|
|
|
| sort -rV)
|
|
|
|
); unset IFS
|
|
|
|
|
|
|
|
fullVersion=
|
|
|
|
for tryVersion in "${allVersions[@]}"; do
|
|
|
|
if echo "$shaPage" | grep -q "Ruby ${tryVersion}<"; then
|
|
|
|
fullVersion="$tryVersion"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "$fullVersion" ]; then
|
|
|
|
echo >&2 "warning: cannot determine sha for $version (tried all of ${allVersions[*]}); skipping"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
shaVal="$(echo "$shaPage" | sed -r "s/.*Ruby ${fullVersion}<\/a><br \/>\s*sha256: ([^<]+).*/\1/")"
|
2016-02-03 15:11:16 -05:00
|
|
|
|
|
|
|
sedStr="
|
|
|
|
s!%%VERSION%%!$version!g;
|
|
|
|
s!%%FULL_VERSION%%!$fullVersion!g;
|
|
|
|
s!%%SHA256%%!$shaVal!g;
|
|
|
|
s!%%RUBYGEMS%%!$rubygems!g;
|
|
|
|
s!%%BUNDLER%%!$bundler!g;
|
|
|
|
"
|
|
|
|
for variant in alpine slim onbuild ''; do
|
2016-01-29 13:39:48 -05:00
|
|
|
[ -d "$version/$variant" ] || continue
|
2016-02-03 15:11:16 -05:00
|
|
|
sed -r "$sedStr" "Dockerfile${variant:+-$variant}.template" > "$version/$variant/Dockerfile"
|
|
|
|
if [ "$variant" != 'onbuild' ]; then
|
|
|
|
travisEnv='\n - VERSION='"$version VARIANT=$variant$travisEnv"
|
|
|
|
fi
|
2016-01-29 13:39:48 -05:00
|
|
|
done
|
2014-08-14 14:58:13 -04:00
|
|
|
done
|
2016-01-29 13:39:48 -05:00
|
|
|
|
|
|
|
travis="$(awk -v 'RS=\n\n' '$1 == "env:" { $0 = "env:'"$travisEnv"'" } { printf "%s%s", $0, RS }' .travis.yml)"
|
|
|
|
echo "$travis" > .travis.yml
|