Skip to content

Expose sha1 (and possibly other digests) on repository_ctx.download() #7323

Closed as not planned

Description

@kamalmarhubi

Description of the feature request:

Expose a sha1 argument on repository_ctx.download() and repository_ctx.download_and_extract(). Consider more hashes, and perhaps a generic digest argument.

Possible examples:

def _my_repo_rule_impl(rctx):
    # blah blah
    rctx.download(
        url = some_url,
        output = my_path
        sha1 = my_sha1
    )

or

def _my_repo_rule_impl(rctx):
    # blah blah
    rctx.download(
        url = some_url,
        output = my_path
        digest = "sha1:" + my_sha1
    )

Feature requests: what underlying problem are you trying to solve with this feature?

At the moment, only a sha256 can be passed to download() and download_and_extract(), which means that using already-existing sha1 hashes is not possible. For example, Maven repositories typically have sha1 and md5 hashes of their contents, but not sha256.

The native maven_jar rule accepts a sha1, and passes it through the cache machinery so that files end up under ${repository_cache}/content_addressable/sha1/. This is not available to Skylark, which prevents creating a Skylark equivalent of that rule. For example, this prevents java_import_external from being a true replacement for maven_jar, where you can generate repository rules directly from a Maven repo without downloading all artifacts.

This came up as I was evaluating @jin's rules_maven which relies on coursier to download and cache artifacts. I'd prefer to resolve artifacts using coursier or another program, but to have Bazel responsible for downloading and caching, generating repository rules that will be snapshotted in resolved.bzl.

Have you found anything relevant by searching the web?

I found #6016, which seems related but not the same. A solution would probably attempt to keep both in mind though.

Activity

  1. added
    team-ExternalDeps
    on Feb 11, 2019
  2. dslomov commented on Feb 11, 2019

    @dslomov
    Contributor

    @dkelmer wdyt? Is this a useful feature for cousrier integration?

  3. added
    P2
    on Mar 22, 2019
  4. added
    untriaged
    and removed
    P2
    on May 12, 2020
  5. added
    team-OSS
    on Jun 15, 2020
  6. added
    P3
    and removed
    untriaged
    on Feb 8, 2021
  7. devversion commented on Jun 12, 2021

    @devversion
    Contributor

    SHA1 seems now supported in ctx.download in subresource integrity format: c9e2be5

  8. removed
    team-OSS
    on Nov 29, 2021
  9. github-actions commented on May 24, 2023

    @github-actions

    Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

  10. added
    stale
    on May 24, 2023
  11. github-actions commented on Jun 7, 2023

    @github-actions

    This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3staleteam-ExternalDepstype: feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions