| 1 |
#!/usr/bin/env bash |
| 2 |
# Adds "warn_unsupported" or "warn_eol" to CRuby definitions based on the |
| 3 |
# information from endoflife.date. |
| 4 |
|
| 5 |
set -e |
| 6 |
|
| 7 |
date_to_seconds() { |
| 8 |
# BSD date |
| 9 |
date -jf '%Y-%m-%d' -v 0H -v 0M -v 0S "$1" '+%s' 2>/dev/null || |
| 10 |
# GNU date |
| 11 |
date --date "$1" '+%s' |
| 12 |
} |
| 13 |
|
| 14 |
now_seconds="$(date '+%s')" |
| 15 |
|
| 16 |
while read -r cycle eol_date; do |
| 17 |
eol_seconds="$(date_to_seconds "$eol_date")" |
| 18 |
days_to_eol=$(((eol_seconds - now_seconds) / 60 / 60 / 24)) |
| 19 |
if [ $days_to_eol -lt 0 ]; then |
| 20 |
grep -L warn_eol share/ruby-build/"$cycle"[.-]* | grep -ve '-dev$' | \ |
| 21 |
xargs sed -i.bak -E '/openssl/n; s/ warn_unsupported//; s/(.+)"/\1" warn_eol/' |
| 22 |
elif [ $days_to_eol -lt 180 ]; then |
| 23 |
grep -L warn_unsupported share/ruby-build/"$cycle"[.-]* | grep -ve '-dev$' | \ |
| 24 |
xargs sed -i.bak -E '/openssl/n; s/(.+)"/\1" warn_unsupported/' |
| 25 |
fi |
| 26 |
done < <( |
| 27 |
curl -fsSL https://endoflife.date/api/ruby.json | jq -r '.[] | [.cycle,.eol] | @tsv' |
| 28 |
printf "%s\t%s\n" "jruby-9.0" "1970-01-01" |
| 29 |
printf "%s\t%s\n" "jruby-9.1" "1970-01-01" |
| 30 |
printf "%s\t%s\n" "jruby-9.2" "1970-01-01" |
| 31 |
printf "%s\t%s\n" "jruby-9.3" "2024-01-01" |
| 32 |
printf "%s\t%s\n" "jruby-9.4" "2026-05-01" |
| 33 |
) |
| 34 |
|
| 35 |
num_updated="$(rm -fv share/ruby-build/*.bak | wc -l)" |
| 36 |
printf "definition files updated: %d\n" "$num_updated" |