Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file:/// handling in download tool #2635

Merged
merged 2 commits into from Jul 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion reference/conanfile/tools/files/downloads.rst
Expand Up @@ -90,6 +90,8 @@ Parameters:

- **conanfile** (Required): Conanfile object, use ``self`` always
- **url** (Required): URL to download. It can be a list, which only the first one will be downloaded, and the follow URLs will be used as mirror in case of download error.
Files accessible in the local filesystem can be referenced with a URL starting with ``file:///`` followed by the file path
(where the third ``/`` implies ``localhost``).
- **filename** (Required): Name of the file to be created in the local storage
- **verify** (Optional, Defaulted to ``True``): When False, disables https certificate validation.
- **retry** (Optional, Defaulted to ``1``): Number of retries in case of failure.
Expand Down Expand Up @@ -127,9 +129,13 @@ Examples:
# Download and check file checksum
download(self, "http://someurl/somefile.zip", "myfilename.zip", md5="e5d695597e9fa520209d1b41edad2a27")

# Retrieve file that is visible in the local filesystem
tools.download("file:///home/myuser/downloads/somefile.zip", "myfilename.zip", md5="e5d695597e9fa520209d1b41edad2a27")
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. an example with Windows path (e.g. with C: drive) would be useful
  2. does it work with relative path? if so, what are they relative to?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with those, clarifying that would be nice


# to add mirrors
download(self, ["https://ftp.gnu.org/gnu/gcc/gcc-9.3.0/gcc-9.3.0.tar.gz",
"http://mirror.linux-ia64.org/gnu/gcc/releases/gcc-9.3.0/gcc-9.3.0.tar.gz"],
"http://mirror.linux-ia64.org/gnu/gcc/releases/gcc-9.3.0/gcc-9.3.0.tar.gz",
"file:///home/myuser/localmirror/gcc-9.3.0/gcc-9.3.0.tar.gz"],
"gcc-9.3.0.tar.gz",
sha256="5258a9b6afe9463c2e56b9e8355b1a4bee125ca828b8078f910303bc2ef91fa6")

Expand Down