Skip to content

🧹 Improve distfiles fetching system in util/build-deps.sh#285

Open
segin wants to merge 1 commit intomasterfrom
fix-distfiles-fetching-system-4133156286357211395
Open

🧹 Improve distfiles fetching system in util/build-deps.sh#285
segin wants to merge 1 commit intomasterfrom
fix-distfiles-fetching-system-4133156286357211395

Conversation

@segin
Copy link
Copy Markdown
Owner

@segin segin commented Apr 8, 2026

🛠️ What: Introduced a fetch_url function to util/build-deps.sh and updated distfiles_fetch to use it.
💡 Why: The dependency fetching script was tightly coupled to wget. Using a fallback mechanism ensures broader compatibility across POSIX systems (e.g., macOS often defaults to curl, FreeBSD uses fetch). It also properly surfaces failures if a URL isn't found (e.g., HTTP 404).
✅ Verification: Tested the updated build-deps.sh locally with zsh, confirming it successfully attempts curl and accurately fails out if a 404 page is encountered instead of swallowing the error.


PR created automatically by Jules for task 4133156286357211395 started by @segin

… downloading distfiles.

The new `fetch_url` function provides fallback logic to download files using `curl`, `wget`, or `fetch` (with appropriate flags) instead of hardcoding `wget`. It properly handles error returns and enables the script to run seamlessly on systems lacking `wget`.

Co-authored-by: segin <480709+segin@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings April 8, 2026 23:46
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a fetch_url utility function to provide a more robust and flexible way to download dependency files using curl, wget, or fetch. It also updates the distfiles_fetch logic to utilize this helper and includes error handling for failed downloads. Feedback was provided to include the -r flag for the fetch command to ensure consistent support for resuming interrupted downloads across all supported tools.

Comment thread util/build-deps.sh
elif command -v wget >/dev/null 2>&1; then
wget -c -O "$out" "$url"
elif command -v fetch >/dev/null 2>&1; then
fetch -o "$out" "$url"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The fetch command (commonly used on FreeBSD) is missing the flag to resume an interrupted download, which makes it inconsistent with the curl and wget implementations in this function. Adding the -r (or --restart) flag will ensure that partial downloads are resumed rather than overwritten, matching the behavior described in the comments and the implementation of the other tools.

Suggested change
fetch -o "$out" "$url"
fetch -r -o "$out" "$url"

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the dependency distfile download logic in util/build-deps.sh by introducing a downloader wrapper function, aiming to reduce coupling to wget and improve failure handling when downloads can’t be retrieved.

Changes:

  • Added fetch_url() to download via curl, wget, or fetch depending on availability.
  • Updated distfiles_fetch() to use fetch_url() and to fail fast when the download step fails.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread util/build-deps.sh
Comment on lines +121 to +130
if command -v curl >/dev/null 2>&1; then
curl -f -L -C - -o "$out" "$url"
elif command -v wget >/dev/null 2>&1; then
wget -c -O "$out" "$url"
elif command -v fetch >/dev/null 2>&1; then
fetch -o "$out" "$url"
else
notice "No download tool found. Please install curl, wget, or fetch."
return 1
fi
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetch_url selects the first available tool but does not actually fall back to the next tool if the chosen one fails (e.g., curl is installed but fails due to TLS/CA/config issues). If the intent is a real fallback mechanism, consider trying wget/fetch when curl exits non-zero (or adjust the PR description to clarify it’s only a tool-selection preference).

Suggested change
if command -v curl >/dev/null 2>&1; then
curl -f -L -C - -o "$out" "$url"
elif command -v wget >/dev/null 2>&1; then
wget -c -O "$out" "$url"
elif command -v fetch >/dev/null 2>&1; then
fetch -o "$out" "$url"
else
notice "No download tool found. Please install curl, wget, or fetch."
return 1
fi
local found_tool=0
local status=1
if command -v curl >/dev/null 2>&1; then
found_tool=1
curl -f -L -C - -o "$out" "$url" && return 0
status=$?
fi
if command -v wget >/dev/null 2>&1; then
found_tool=1
wget -c -O "$out" "$url" && return 0
status=$?
fi
if command -v fetch >/dev/null 2>&1; then
found_tool=1
fetch -o "$out" "$url" && return 0
status=$?
fi
if [ ${found_tool} -eq 0 ]; then
notice "No download tool found. Please install curl, wget, or fetch."
return 1
fi
return ${status}

Copilot uses AI. Check for mistakes.
Comment thread util/build-deps.sh
@@ -171,7 +187,10 @@ distfiles_fetch () {

# If the file exists but didn't pass check, or doesn't exist, we download it using -c (continue)
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says downloads use “-c (continue)”, but the fetch branch in fetch_url doesn’t request resume/continue behavior. Either update the comment to match reality, or add the appropriate resume flag for fetch (if supported) so behavior is consistent across download tools.

Suggested change
# If the file exists but didn't pass check, or doesn't exist, we download it using -c (continue)
# If the file exists but didn't pass check, or doesn't exist, download it again.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants