From c813cadf896e4dfa7331a861bb8c1272c945d79e Mon Sep 17 00:00:00 2001 From: Dillon Giacoppo Date: Sun, 22 Dec 2024 17:24:05 +1100 Subject: [PATCH] [#144]: Add rctx.watch and repo name fix in deb_resolve --- apt/apt.bzl | 1 + apt/extensions.bzl | 1 + apt/private/deb_resolve.bzl | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apt/apt.bzl b/apt/apt.bzl index 402ecf3..24040c3 100644 --- a/apt/apt.bzl +++ b/apt/apt.bzl @@ -121,6 +121,7 @@ def _apt_install( """ _deb_resolve( name = name + "_resolve", + install_name = name, manifest = manifest, resolve_transitive = resolve_transitive, ) diff --git a/apt/extensions.bzl b/apt/extensions.bzl index 2368cc4..e77d1a4 100644 --- a/apt/extensions.bzl +++ b/apt/extensions.bzl @@ -41,6 +41,7 @@ def _distroless_extension(module_ctx): deb_resolve( name = install.name + "_resolve", + install_name = install.name, manifest = install.manifest, resolve_transitive = install.resolve_transitive, ) diff --git a/apt/private/deb_resolve.bzl b/apt/private/deb_resolve.bzl index 169c4fb..dcfdd92 100644 --- a/apt/private/deb_resolve.bzl +++ b/apt/private/deb_resolve.bzl @@ -10,6 +10,10 @@ load(":version_constraint.bzl", "version_constraint") def _parse_manifest(rctx, yq_toolchain_prefix, manifest): is_windows = repo_utils.is_windows(rctx) host_yq = Label("@{}_{}//:yq{}".format(yq_toolchain_prefix, repo_utils.platform(rctx), ".exe" if is_windows else "")) + + if hasattr(rctx, "watch"): + rctx.watch(manifest) + yq_args = [ str(rctx.path(host_yq)), str(rctx.path(manifest)), @@ -120,7 +124,7 @@ def _deb_resolve_impl(rctx): # NOTE: the split("~") is needed when we run bazel from another # directory, e.g. when running e2e tests we change dir to e2e/smoke # and then rctx.name is 'rules_distroless~~apt~bullseye' - repo_name = rctx.name.split("~")[-1].replace("_resolve", ""), + repo_name = rctx.attr.install_name, lock_label = lock_label, workspace_relative_path = workspace_relative_path, ), @@ -132,6 +136,7 @@ def _deb_resolve_impl(rctx): deb_resolve = repository_rule( implementation = _deb_resolve_impl, attrs = { + "install_name": attr.string(), "manifest": attr.label(), "resolve_transitive": attr.bool(default = True), "yq_toolchain_prefix": attr.string(default = "yq"),