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

build.zig dependencies: support url mirrors #14291

Open
Tracked by #14265
andrewrk opened this issue Jan 13, 2023 · 1 comment
Open
Tracked by #14265

build.zig dependencies: support url mirrors #14291

andrewrk opened this issue Jan 13, 2023 · 1 comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Jan 13, 2023

Extracted from #14265.

.{
    .name = "libffmpeg",
    .version = "5.1.2",
    .dependencies = .{
        .libz = .{
            .url = .{
                "https://github.com/andrewrk/libz/archive/f0e53cc2391741034b144a2c2076ed8a9937b29b.tar.gz",
                "https://andrewkelley.me/temp/backup (2).tar.gz",
            },
            .hash = "sha256=c9b30cffc40999d2c078ff350cbcee642970a224fe123c756d0892f876cf1aae",
        },
    },
}

Note that the hash is the same regardless of which mirror URL is used.

URL mirrors are tried in succession; if one mirror fails to deliver a directory of files with a matching hash, then the next URL is tried, and so on until all the mirrors have been tried.

@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management labels Jan 13, 2023
@andrewrk andrewrk added this to the 0.12.0 milestone Jan 13, 2023
@motiejus
Copy link
Contributor

Some implementation details of a different package manager that does it as described: https://bazel.build/rules/lib/repo/http#http_archive-urls ; note urls is in the same scope as sha256, exactly like in this proposal.

Bazel maintains these files in ~/.cache/bazel/_bazel_<username>/cache/repos/v1/content_addressable/sha256. For example, https://<...>/java_tools_linux-v11.7.1.zip, whose sha256 is f78077f0c043... is stored like this:

$ cat ~/.cache/bazel/_bazel_motiejus/cache/repos/v1/content_addressable/sha256/f78077f0c043d0d13c82de0ee4a99753e66bb18ec46e3601fa2a10e7f26798a8/id-d5b73c8c527f33efb260613ab75629768c6244457266cd6a1009a996883b8956; echo
https://mirror.bazel.build/bazel_java_tools/releases/java/v11.7.1/java_tools_linux-v11.7.1.zip https://github.com/bazelbuild/java_tools/releases/download/java_v11.7.1/java_tools_linux-v11.7.1.zip

$ sha256sum ~/.cache/bazel/_bazel_motiejus/cache/repos/v1/content_addressable/sha256/f78077f0c043d0d13c82de0ee4a99753e66bb18ec46e3601fa2a10e7f26798a8/file 
f78077f0c043d0d13c82de0ee4a99753e66bb18ec46e3601fa2a10e7f26798a8  /home/motiejus/.cache/bazel/_bazel_motiejus/cache/repos/v1/content_addressable/sha256/f78077f0c043d0d13c82de0ee4a99753e66bb18ec46e3601fa2a10e7f26798a8/file

And before fetching the file it looks at the cache directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
Status: Fetching
Development

No branches or pull requests

2 participants