From 083a412b5d9da36614b02e36bae39518f7948f04 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Fri, 15 Sep 2017 07:58:44 -0700 Subject: [PATCH] Adjust "update.sh" to also scrape the news page (since the releases page doesn't seem to contain 2.3.5 or 2.2.8, and even 2.4.2 took a while to show up) --- update.sh | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/update.sh b/update.sh index 462afbda3..3d86d9859 100755 --- a/update.sh +++ b/update.sh @@ -8,7 +8,9 @@ if [ ${#versions[@]} -eq 0 ]; then versions=( */ ) fi versions=( "${versions[@]%/}" ) -releasePage="$(curl -fsSL 'https://www.ruby-lang.org/en/downloads/releases/')" + +releasesPage="$(curl -fsSL 'https://www.ruby-lang.org/en/downloads/releases/')" +newsPage="$(curl -fsSL 'https://www.ruby-lang.org/en/news/')" # occasionally, releases don't show up on the Releases page latest_gem_version() { curl -fsSL "https://rubygems.org/api/v1/gems/$1.json" | sed -r 's/^.*"version":"([^"]+)".*$/\1/' @@ -34,10 +36,25 @@ for version in "${versions[@]}"; do ); unset IFS fullVersion= + shaVal= for tryVersion in "${allVersions[@]}"; do - if echo "$releasePage" | grep -q "Ruby ${tryVersion}<"; then - fullVersion="$tryVersion" - break + if \ + { + versionReleasePage="$(echo "$releasesPage" | grep "Ruby $tryVersion" -A 2 | awk -F '"' '$1 == "Ruby '"$tryVersion"' Released' | cut -d'"' -f2)" \ + && [ "$versionReleasePage" ] + } \ + ; then + if \ + shaVal="$(curl -fsSL "https://www.ruby-lang.org/$versionReleasePage" |tac|tac| grep "ruby-$tryVersion.tar.xz" -A 5 | awk '/^SHA256:/ { print $2; exit }')" \ + && [ "$shaVal" ] \ + ; then + fullVersion="$tryVersion" + break + fi fi done @@ -45,8 +62,6 @@ for version in "${versions[@]}"; do echo >&2 "warning: cannot determine sha for $version (tried all of ${allVersions[*]}); skipping" continue fi - versionReleasePage="$(echo "$releasePage" | grep "Ruby $fullVersion" -A 2 | awk -F '"' '$1 == "