Skip to content

Commit

Permalink
Merge pull request #36 from Shopify/rwstauner/http-get-stdout
Browse files Browse the repository at this point in the history
Support all ruby-build http clients
  • Loading branch information
rwstauner committed Feb 29, 2024
2 parents 44a551e + 3bab6e1 commit 7845cb1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions rubies/truffleruby+graalvm-gftc-dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
http_get_stdout () {
local f="$(mktemp "ruby-build.http.XXXXXX")"
http get "$1" "$f"
cat "$f"
rm -f "$f"
}

sort_release_urls () {
# With release names like /^(jdk-)?24.1.0-dev-20240207_2228$/
# strip everything up to the last dash so we can use the date as the sort field.
Expand All @@ -14,11 +21,11 @@ find_asset_url () {
# The releases page hides assets behind an "expanded_assets" url
# so we gather those, sort them according to "sort_release_urls" and store
# them in an array to loop over next.
IFS=$'\n' read -d '' -r -a assets_urls < <(http get "$releases_prefix" - | grep -oE "$releases_prefix/expanded_assets/[^\"]+" | $sort_release_urls)
IFS=$'\n' read -d '' -r -a assets_urls < <(http_get_stdout "$releases_prefix" | grep -oE "$releases_prefix/expanded_assets/[^\"]+" | $sort_release_urls)

# For each release look in the assets output for a download link to the specified filename.
for assets_url in "${assets_urls[@]}"; do
path="$(http get "$assets_url" - | grep -m1 -oE "/$repo/releases/download/[^/]+/$filename")"
path="$(http_get_stdout "$assets_url" | grep -m1 -oE "/$repo/releases/download/[^/]+/$filename")"
if [[ -n "$path" ]]; then
echo "https://github.com/$path"
return 0
Expand Down
11 changes: 9 additions & 2 deletions rubies/truffleruby-gftc-dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
http_get_stdout () {
local f="$(mktemp "ruby-build.http.XXXXXX")"
http get "$1" "$f"
cat "$f"
rm -f "$f"
}

sort_release_urls () {
# With release names like /^(jdk-)?24.1.0-dev-20240207_2228$/
# strip everything up to the last dash so we can use the date as the sort field.
Expand All @@ -14,11 +21,11 @@ find_asset_url () {
# The releases page hides assets behind an "expanded_assets" url
# so we gather those, sort them according to "sort_release_urls" and store
# them in an array to loop over next.
IFS=$'\n' read -d '' -r -a assets_urls < <(http get "$releases_prefix" - | grep -oE "$releases_prefix/expanded_assets/[^\"]+" | $sort_release_urls)
IFS=$'\n' read -d '' -r -a assets_urls < <(http_get_stdout "$releases_prefix" | grep -oE "$releases_prefix/expanded_assets/[^\"]+" | $sort_release_urls)

# For each release look in the assets output for a download link to the specified filename.
for assets_url in "${assets_urls[@]}"; do
path="$(http get "$assets_url" - | grep -m1 -oE "/$repo/releases/download/[^/]+/$filename")"
path="$(http_get_stdout "$assets_url" | grep -m1 -oE "/$repo/releases/download/[^/]+/$filename")"
if [[ -n "$path" ]]; then
echo "https://github.com/$path"
return 0
Expand Down

0 comments on commit 7845cb1

Please sign in to comment.